Prompt before deleting lists (#2043)

* Prompt before deleting lists. #1998

* Address pull request feedback
main
Levi Bard 4 years ago committed by Alibek Omarov
parent 6b93d02952
commit e162583309
  1. 16
      app/src/main/java/com/keylesspalace/tusky/ListsActivity.kt
  2. 1
      app/src/main/res/values/strings.xml

@ -132,9 +132,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)
@ -145,6 +143,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)
@ -201,7 +209,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

@ -596,6 +596,7 @@
<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>
<string name="wellbeing_mode_notice">Some information that might affect your mental wellbeing will be hidden. This includes:\n\n <string name="wellbeing_mode_notice">Some information that might affect your mental wellbeing will be hidden. This includes:\n\n
- Favorite/Boost/Follow notifications\n - Favorite/Boost/Follow notifications\n

Loading…
Cancel
Save