Skip to content
This repository was archived by the owner on May 23, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ fun showAddPollDialog(
.setBackgroundInsetStart(inset)
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok, null)
.setCancelable(false)
.create()

val adapter = AddPollOptionsAdapter(
Expand Down Expand Up @@ -96,19 +97,36 @@ fun showAddPollDialog(

binding.multipleChoicesCheckBox.isChecked = poll?.multiple == true

fun newPoll() = NewPoll(
options = adapter.pollOptions,
expiresIn = durations[selectedDurationIndex],
multiple = binding.multipleChoicesCheckBox.isChecked
)

val existingPoll = newPoll()

dialog.setOnShowListener {
val button = dialog.getButton(AlertDialog.BUTTON_POSITIVE)
button.setOnClickListener {
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
onUpdatePoll(
NewPoll(
options = adapter.pollOptions,
expiresIn = durations[selectedDurationIndex],
multiple = binding.multipleChoicesCheckBox.isChecked
)
newPoll()
)

dialog.dismiss()
}

dialog.getButton(AlertDialog.BUTTON_NEGATIVE)?.setOnClickListener {
if (existingPoll != newPoll()) {
MaterialAlertDialogBuilder(context)
.setMessage(R.string.confirm_dismiss_caption)
.setPositiveButton(R.string.yes) { _, _ ->
dialog.dismiss()
}
.setNegativeButton(R.string.no, null)
.show()
} else {
dialog.dismiss()
}
}
}

dialog.show()
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,7 @@
<string name="yes">Yes</string>
<string name="no">No</string>
<string name="confirm_dismiss_caption">Discard caption changes?</string>
<string name="confirm_dismiss_poll">Discard poll changes?</string>

<string name="unblock_success">Unblocked %1$s</string>
<string name="unmute_success">Unmuted %1$s</string>
Expand Down