Merge pull request #2259 from nextcloud/bugfix/2257/polishPolls

📊 Polishing polls
This commit is contained in:
Andy Scherzinger 2022-08-01 16:50:43 +02:00 committed by GitHub
commit 107403d692
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 147 additions and 63 deletions

View file

@ -24,6 +24,7 @@ import android.annotation.SuppressLint
import android.text.Editable
import android.text.TextWatcher
import androidx.recyclerview.widget.RecyclerView
import com.nextcloud.talk.R
import com.nextcloud.talk.databinding.PollCreateOptionsItemBinding
import com.nextcloud.talk.utils.EmojiTextInputEditText
@ -43,13 +44,13 @@ class PollCreateOptionViewHolder(
) {
textListener?.let {
binding.pollOptionText.removeTextChangedListener(it)
binding.pollOptionTextEdit.removeTextChangedListener(it)
}
binding.pollOptionText.setText(pollCreateOptionItem.pollOption)
binding.pollOptionTextEdit.setText(pollCreateOptionItem.pollOption)
if (focus) {
itemsListener.requestFocus(binding.pollOptionText)
itemsListener.requestFocus(binding.pollOptionTextEdit)
}
binding.pollOptionDelete.setOnClickListener {
@ -57,7 +58,16 @@ class PollCreateOptionViewHolder(
}
textListener = getTextWatcher(pollCreateOptionItem, itemsListener)
binding.pollOptionText.addTextChangedListener(textListener)
binding.pollOptionTextEdit.addTextChangedListener(textListener)
binding.pollOptionTextInputLayout.hint = String.format(
binding.pollOptionTextInputLayout.resources.getString(R.string.polls_option_hint),
position + 1
)
binding.pollOptionDelete.contentDescription = String.format(
binding.pollOptionTextInputLayout.resources.getString(R.string.polls_option_delete),
position + 1
)
}
private fun getTextWatcher(

View file

@ -29,7 +29,7 @@ class PollCreateOptionsAdapter(
private val clickListener: PollCreateOptionsItemListener
) : RecyclerView.Adapter<PollCreateOptionViewHolder>() {
internal var list: ArrayList<PollCreateOptionItem> = ArrayList<PollCreateOptionItem>()
internal var list: ArrayList<PollCreateOptionItem> = ArrayList()
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PollCreateOptionViewHolder {
val itemBinding = PollCreateOptionsItemBinding.inflate(LayoutInflater.from(parent.context), parent, false)

View file

@ -72,10 +72,10 @@ class PollResultVotersOverviewViewHolder(
roundingParams.roundAsCircle = true
roundingParams.borderColor = ResourcesCompat.getColor(
itemView.context.resources!!,
R.color.colorPrimary,
R.color.vote_dialog_background,
null
)
roundingParams.borderWidth = 2.0f
roundingParams.borderWidth = DisplayUtils.convertDpToPixel(2.0f, itemView.context)
avatar.hierarchy.roundingParams = roundingParams
avatar.controller = getAvatarDraweeController(pollDetails)
@ -134,7 +134,7 @@ class PollResultVotersOverviewViewHolder(
const val AVATAR_SIZE = 60
const val AVATAR_RADIUS = 5f
const val MAX_AVATARS = 10
const val AVATAR_OFFSET = AVATAR_SIZE - 10
const val AVATAR_OFFSET = AVATAR_SIZE - 20
const val DOTS_OFFSET = 70
const val DOTS_TEXT = ""
}

View file

@ -102,7 +102,7 @@ class PollCreateDialogFragment : DialogFragment(), PollCreateOptionsItemListener
dismiss()
}
binding.pollCreateQuestion.addTextChangedListener(object : TextWatcher {
binding.pollCreateQuestionTextEdit.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(s: Editable) {
// unused atm
}
@ -161,8 +161,8 @@ class PollCreateDialogFragment : DialogFragment(), PollCreateOptionsItemListener
}
override fun requestFocus(textField: EditText) {
if (binding.pollCreateQuestion.text.isBlank()) {
binding.pollCreateQuestion.requestFocus()
if (binding.pollCreateQuestionTextEdit.text?.isBlank() == true) {
binding.pollCreateQuestionTextEdit.requestFocus()
} else {
textField.requestFocus()
}

View file

@ -1,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Nextcloud Talk application
~
~ @author Andy Scherzinger
~ @author Marcel Hibbe
~ Copyright (C) 2022 Andy Scherzinger <info@andy-scherzinger.de>
~ Copyright (C) 2022 Marcel Hibbe <dev@mhibbe.de>
~
~ This program is free software: you can redistribute it and/or modify
@ -24,35 +26,62 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/standard_padding"
tools:background="@color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:orientation="vertical"
android:paddingTop="@dimen/dialog_padding_top_bottom">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/dialog_padding"
android:paddingEnd="@dimen/dialog_padding"
android:paddingBottom="@dimen/standard_half_padding"
android:text="@string/polls_question"
android:textColor="@color/colorPrimary"
android:textStyle="bold"
android:text="@string/polls_question" />
android:textStyle="bold" />
<EditText
android:id="@+id/poll_create_question"
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/poll_create_question_text_input_layout"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
tools:ignore="Autofill,LabelFor"/>
android:layout_marginStart="@dimen/dialog_padding"
android:layout_marginEnd="@dimen/dialog_padding"
android:hint="@string/polls_question_hint"
android:minHeight="@dimen/min_size_clickable_area"
app:boxStrokeColor="@color/colorPrimary"
app:errorTextAppearance="@style/ErrorAppearance"
app:hintTextColor="@color/colorPrimary">
<com.nextcloud.talk.utils.EmojiTextInputEditText
android:id="@+id/poll_create_question_text_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="textMultiLine"
android:singleLine="true"
android:textAlignment="viewStart">
<requestFocus />
</com.nextcloud.talk.utils.EmojiTextInputEditText>
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/standard_padding"
android:paddingBottom="@dimen/standard_half_padding"
android:paddingStart="@dimen/dialog_padding"
android:paddingEnd="@dimen/dialog_padding"
android:text="@string/polls_options"
android:textColor="@color/colorPrimary"
android:textStyle="bold"
android:layout_marginTop="@dimen/standard_margin"
android:text="@string/polls_options" />
android:textStyle="bold" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/poll_create_options_list"
@ -65,59 +94,72 @@
style="@style/OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/standard_half_margin"
app:icon="@drawable/ic_add_grey600_24px"
android:layout_marginStart="@dimen/dialog_padding"
android:layout_marginEnd="@dimen/dialog_padding"
android:minHeight="@dimen/min_size_clickable_area"
android:text="@string/polls_add_option"
app:cornerRadius="@dimen/button_corner_radius"
app:layout_constraintEnd_toEndOf="parent"
android:text="@string/polls_add_option" />
app:icon="@drawable/ic_add_grey600_24px" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/colorPrimary"
android:textStyle="bold"
android:layout_marginTop="@dimen/standard_margin"
android:layout_marginBottom="@dimen/standard_half_margin"
android:text="@string/polls_settings" />
android:paddingStart="@dimen/dialog_padding"
android:paddingEnd="@dimen/dialog_padding"
android:text="@string/polls_settings"
android:textColor="@color/colorPrimary"
android:textStyle="bold" />
<CheckBox
android:id="@+id/poll_private_poll_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/default_checkbox_dialog_start_margin"
android:minHeight="@dimen/min_size_clickable_area"
android:paddingStart="@dimen/standard_half_padding"
android:paddingEnd="@dimen/standard_padding"
android:text="@string/polls_private_poll" />
<CheckBox
android:id="@+id/poll_multiple_answers_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/default_checkbox_dialog_start_margin"
android:minHeight="@dimen/min_size_clickable_area"
android:paddingStart="@dimen/standard_half_padding"
android:paddingEnd="@dimen/standard_padding"
android:text="@string/polls_multiple_answers" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/standard_half_margin"
android:gravity="end"
android:orientation="horizontal"
android:layout_marginTop="@dimen/standard_margin"
android:gravity="end">
android:paddingStart="@dimen/dialog_padding"
android:paddingEnd="@dimen/dialog_padding"
android:paddingBottom="@dimen/dialog_padding_top_bottom">
<com.google.android.material.button.MaterialButton
android:id="@+id/poll_dismiss"
style="@style/OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/standard_half_margin"
android:text="@string/nc_common_dismiss"
app:cornerRadius="@dimen/button_corner_radius"
app:layout_constraintEnd_toEndOf="parent"
android:text="@string/nc_common_dismiss" />
app:layout_constraintEnd_toEndOf="parent" />
<com.google.android.material.button.MaterialButton
android:id="@+id/poll_create_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/standard_half_margin"
app:cornerRadius="@dimen/button_corner_radius"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginStart="@dimen/standard_margin"
android:layout_marginEnd="@dimen/zero"
android:text="@string/nc_create_poll"
android:theme="@style/Button.Primary" />
android:theme="@style/Button.Primary"
app:cornerRadius="@dimen/button_corner_radius"
app:layout_constraintEnd_toEndOf="parent" />
</LinearLayout>
</LinearLayout>

View file

@ -19,11 +19,11 @@
-->
<LinearLayout 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="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
tools:background="@color/white"
android:orientation="vertical">
android:orientation="vertical"
tools:background="@color/white">
<LinearLayout
android:id="@+id/poll_results_list_wrapper"
@ -46,17 +46,19 @@
<com.google.android.material.button.MaterialButton
android:id="@+id/poll_results_end_poll_button"
style="@style/Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/polls_end_poll"
style="@style/OutlinedButton"
android:layout_marginEnd="@dimen/standard_margin"
android:minHeight="@dimen/min_size_clickable_area"
android:text="@string/polls_end_poll"
app:cornerRadius="@dimen/button_corner_radius" />
<com.google.android.material.button.MaterialButton
android:id="@+id/edit_vote_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="@dimen/min_size_clickable_area"
android:text="@string/polls_edit_vote"
android:theme="@style/Button.Primary"
app:cornerRadius="@dimen/button_corner_radius" />

View file

@ -55,32 +55,36 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/standard_margin"
android:layout_marginEnd="4dp"
android:gravity="end">
<com.google.android.material.button.MaterialButton
android:id="@+id/poll_vote_end_poll_button"
style="@style/Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/polls_end_poll"
style="@style/OutlinedButton"
android:layout_marginEnd="@dimen/standard_margin"
android:minHeight="@dimen/min_size_clickable_area"
android:text="@string/polls_end_poll"
app:cornerRadius="@dimen/button_corner_radius" />
<com.google.android.material.button.MaterialButton
android:id="@+id/poll_vote_edit_dismiss"
style="@style/OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/nc_common_dismiss"
style="@style/OutlinedButton"
android:layout_marginEnd="@dimen/standard_margin"
android:minHeight="@dimen/min_size_clickable_area"
android:text="@string/nc_common_dismiss"
android:visibility="gone"
app:cornerRadius="@dimen/button_corner_radius"
tools:visibility="visible"/>
tools:visibility="visible" />
<com.google.android.material.button.MaterialButton
android:id="@+id/poll_vote_submit_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="@dimen/min_size_clickable_area"
android:text="@string/polls_submit_vote"
android:theme="@style/Button.Primary"
app:cornerRadius="@dimen/button_corner_radius" />

View file

@ -1,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Nextcloud Talk application
~
~ @author Andy Scherzinger
~ @author Marcel Hibbe
~ Copyright (C) 2022 Andy Scherzinger <info@andy-scherzinger.de>
~ Copyright (C) 2022 Marcel Hibbe <dev@mhibbe.de>
~
~ This program is free software: you can redistribute it and/or modify
@ -23,25 +25,43 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/min_size_clickable_area"
android:orientation="horizontal"
android:paddingStart="@dimen/dialog_padding"
android:paddingBottom="@dimen/standard_half_margin"
android:paddingEnd="@dimen/zero"
tools:background="@color/white">
<EditText
android:id="@+id/poll_option_text"
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/poll_option_text_input_layout"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:minHeight="@dimen/min_size_clickable_area"
android:layout_marginEnd="@dimen/standard_half_margin"
android:layout_weight="1"
android:singleLine="true"
android:inputType="text"
tools:ignore="Autofill,LabelFor" />
app:boxStrokeColor="@color/colorPrimary"
app:errorTextAppearance="@style/ErrorAppearance"
app:hintTextColor="@color/colorPrimary">
<com.nextcloud.talk.utils.EmojiTextInputEditText
android:id="@+id/poll_option_text_edit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="text"
android:singleLine="true"
android:textAlignment="viewStart" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
android:id="@+id/poll_option_delete"
style="@style/Widget.AppTheme.Button.IconButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:contentDescription="@string/nc_action_open_main_menu"
android:layout_width="@dimen/min_size_clickable_area"
android:layout_height="@dimen/min_size_clickable_area"
android:layout_marginEnd="@dimen/standard_half_margin"
android:contentDescription="@string/polls_option_delete"
app:cornerRadius="@dimen/button_corner_radius"
app:icon="@drawable/ic_baseline_close_24"
app:iconTint="@color/fontAppbar" />

View file

@ -48,7 +48,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:indeterminate="false"
app:indicatorColor="@color/poll_bar_color"
app:indicatorColor="@color/colorPrimary"
app:layout_constraintStart_toStartOf="@+id/poll_option_text"
app:layout_constraintTop_toBottomOf="@+id/poll_option_text"
app:trackColor="@color/dialog_background"

View file

@ -75,4 +75,5 @@
<color name="grey_200">#818181</color>
<color name="dialog_background">#353535</color>
<color name="vote_dialog_background">#424242</color>
</resources>

View file

@ -106,11 +106,9 @@
<color name="list_divider_background">#eeeeee</color>
<color name="grey_200">#EEEEEE</color>
<!-- poll -->
<color name="poll_bar_color">#8dd4f6</color>
<!-- this is just a helper for status icon background because getting the background color of a dialog is not
possible?! don't use this to set the background of dialogs -->
<color name="dialog_background">#FFFFFF</color>
<color name="vote_dialog_background">#FFFFFF</color>
</resources>

View file

@ -59,6 +59,8 @@
<dimen name="standard_half_padding">8dp</dimen>
<dimen name="standard_half_margin">8dp</dimen>
<dimen name="default_login_width">400dp</dimen>
<dimen name="dialog_padding">24dp</dimen>
<dimen name="dialog_padding_top_bottom">18dp</dimen>
<dimen name="call_grid_item_min_height">180dp</dimen>
<dimen name="call_controls_height">110dp</dimen>
@ -71,5 +73,7 @@
<dimen name="reaction_bottom_sheet_layout_size">40dp</dimen>
<dimen name="standard_eighth_margin">2dp</dimen>
<dimen name="default_checkbox_dialog_start_margin">18dp</dimen>
<dimen name="mediatab_file_icon_size">50dp</dimen>
</resources>

View file

@ -537,13 +537,16 @@
<string name="polls_add_option">Add option</string>
<string name="polls_edit_vote">Edit vote</string>
<string name="polls_submit_vote">Vote</string>
<string name="polls_voted_hidden_success">Successfully voted</string>
<string name="polls_voted_hidden_success">Vote submitted</string>
<string name="polls_end_poll">End poll</string>
<string name="polls_end_poll_confirm">Do you really want to end this poll? This can\'t be undone.</string>
<string name="polls_max_votes_reached">You can\'t vote with more options for this poll.</string>
<string name="polls_results_subtitle">Results</string>
<string name="polls_question">Question</string>
<string name="polls_question_hint">Your question</string>
<string name="polls_options">Options</string>
<string name="polls_option_hint">Option %1$s</string>
<string name="polls_option_delete">Delete option %1$s</string>
<string name="polls_settings">Settings</string>
<string name="polls_private_poll">Private poll</string>
<string name="polls_multiple_answers">Multiple answers</string>