Prompt before deleting lists (#2043)
* Prompt before deleting lists. #1998 * Address pull request feedback
This commit is contained in:
parent
5fbd459aed
commit
cb2296f248
|
@ -130,9 +130,7 @@ class ListsActivity : BaseActivity(), Injectable, HasAndroidInjector {
|
||||||
else R.string.action_rename_list) { _, _ ->
|
else R.string.action_rename_list) { _, _ ->
|
||||||
onPickedDialogName(editText.text, list?.id)
|
onPickedDialogName(editText.text, list?.id)
|
||||||
}
|
}
|
||||||
.setNegativeButton(android.R.string.cancel) { d, _ ->
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
d.dismiss()
|
|
||||||
}
|
|
||||||
.show()
|
.show()
|
||||||
|
|
||||||
val positiveButton = dialog.getButton(Dialog.BUTTON_POSITIVE)
|
val positiveButton = dialog.getButton(Dialog.BUTTON_POSITIVE)
|
||||||
|
@ -143,6 +141,16 @@ class ListsActivity : BaseActivity(), Injectable, HasAndroidInjector {
|
||||||
editText.text?.let { editText.setSelection(it.length) }
|
editText.text?.let { editText.setSelection(it.length) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showListDeleteDialog(list: MastoList) {
|
||||||
|
AlertDialog.Builder(this)
|
||||||
|
.setMessage(getString(R.string.dialog_delete_list_warning, list.title))
|
||||||
|
.setPositiveButton(R.string.action_delete){ _, _ ->
|
||||||
|
viewModel.deleteList(list.id)
|
||||||
|
}
|
||||||
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun update(state: ListsViewModel.State) {
|
private fun update(state: ListsViewModel.State) {
|
||||||
adapter.submitList(state.lists)
|
adapter.submitList(state.lists)
|
||||||
|
@ -199,7 +207,7 @@ class ListsActivity : BaseActivity(), Injectable, HasAndroidInjector {
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.list_edit -> openListSettings(list)
|
R.id.list_edit -> openListSettings(list)
|
||||||
R.id.list_rename -> renameListDialog(list)
|
R.id.list_rename -> renameListDialog(list)
|
||||||
R.id.list_delete -> viewModel.deleteList(list.id)
|
R.id.list_delete -> showListDeleteDialog(list)
|
||||||
else -> return@setOnMenuItemClickListener false
|
else -> return@setOnMenuItemClickListener false
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
|
|
|
@ -594,5 +594,6 @@
|
||||||
<string name="wellbeing_hide_stats_posts">Hide quantitative stats on posts</string>
|
<string name="wellbeing_hide_stats_posts">Hide quantitative stats on posts</string>
|
||||||
<string name="wellbeing_hide_stats_profile">Hide quantitative stats on profiles</string>
|
<string name="wellbeing_hide_stats_profile">Hide quantitative stats on profiles</string>
|
||||||
<string name="error_upload_max_media_reached">You cannot upload more than %1$d media attachments.</string>
|
<string name="error_upload_max_media_reached">You cannot upload more than %1$d media attachments.</string>
|
||||||
|
<string name="dialog_delete_list_warning">Do you really want to delete the list %s?</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue