Create polls (#1452)

* add AddPollDialog

* add support for pleroma poll options

* add PollPreviewView

* add Poll support to drafts

* add license header, cleanup

* rename drawable files to correct size

* fix tests

* fix bug with Poll having wrong duration after delete&redraft

* add input validation

* grey out poll button when its disabled

* code cleanup & small improvements
This commit is contained in:
Konrad Pozniak 2019-08-22 20:30:08 +02:00 committed by GitHub
commit 51c6852492
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
61 changed files with 1540 additions and 76 deletions

View file

@ -190,6 +190,15 @@
android:padding="8dp"
android:text="@string/action_add_media"
android:textSize="?attr/status_text_medium" />
<TextView
android:id="@+id/action_add_poll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="8dp"
android:padding="8dp"
android:text="@string/action_add_poll"
android:textSize="?attr/status_text_medium" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView

View file

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="16dp"
android:paddingTop="8dp"
android:paddingEnd="16dp">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/pollChoices"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
android:overScrollMode="never"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/addChoiceButton"
style="@style/TuskyButton.Outlined"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:text="@string/add_poll_choice"
app:layout_constraintEnd_toStartOf="@id/pollDurationSpinner"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/pollChoices" />
<androidx.appcompat.widget.AppCompatSpinner
android:id="@+id/pollDurationSpinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:entries="@array/poll_duration_names"
app:layout_constraintBottom_toBottomOf="@id/addChoiceButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/addChoiceButton"
app:layout_constraintTop_toTopOf="@id/addChoiceButton" />
<CheckBox
android:id="@+id/multipleChoicesCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="@string/poll_allow_multiple_choices"
app:buttonTint="?attr/compound_button_color"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/addChoiceButton" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>

View file

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/optionTextInputLayout"
style="@style/TuskyTextInput"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_weight="1">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/optionEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
<ImageButton
android:id="@+id/deleteButton"
style="?attr/image_button_style"
android:layout_marginStart="8dp"
android:layout_width="32dp"
android:layout_height="32dp"
android:contentDescription="@string/action_remove"
android:layout_gravity="bottom"
android:layout_marginBottom="8dp"
android:src="@drawable/ic_clear_24dp" />
</LinearLayout>

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawablePadding="4dp"
android:ellipsize="end"
android:focusableInTouchMode="false"
android:gravity="center_vertical"
android:lines="1"
android:maxEms="20" />

View file

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:background="@drawable/card_frame"
tools:padding="@dimen/poll_preview_padding"
tools:parentTag="android.widget.LinearLayout">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_poll_24dp"
android:drawablePadding="4dp"
android:gravity="center_vertical"
android:text="@string/create_poll_title"
android:textStyle="bold" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/pollPreviewOptions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:nestedScrollingEnabled="false"
android:overScrollMode="never"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<TextView
android:id="@+id/pollDurationPreview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
tools:text="5 Minutes" />
</merge>