From cb2296f2482bca1ad97483ce7079d460561ca99e Mon Sep 17 00:00:00 2001 From: Levi Bard Date: Mon, 18 Jan 2021 11:40:13 +0100 Subject: [PATCH] Prompt before deleting lists (#2043) * Prompt before deleting lists. #1998 * Address pull request feedback --- .../com/keylesspalace/tusky/ListsActivity.kt | 16 ++++++++++++---- app/src/main/res/values/strings.xml | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/ListsActivity.kt b/app/src/main/java/com/keylesspalace/tusky/ListsActivity.kt index 3894f652d..994069f7a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ListsActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/ListsActivity.kt @@ -130,9 +130,7 @@ class ListsActivity : BaseActivity(), Injectable, HasAndroidInjector { else R.string.action_rename_list) { _, _ -> onPickedDialogName(editText.text, list?.id) } - .setNegativeButton(android.R.string.cancel) { d, _ -> - d.dismiss() - } + .setNegativeButton(android.R.string.cancel, null) .show() val positiveButton = dialog.getButton(Dialog.BUTTON_POSITIVE) @@ -143,6 +141,16 @@ class ListsActivity : BaseActivity(), Injectable, HasAndroidInjector { 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) { adapter.submitList(state.lists) @@ -199,7 +207,7 @@ class ListsActivity : BaseActivity(), Injectable, HasAndroidInjector { when (item.itemId) { R.id.list_edit -> openListSettings(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 } true diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d0bc048dd..7f1ec78fc 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -594,5 +594,6 @@ Hide quantitative stats on posts Hide quantitative stats on profiles You cannot upload more than %1$d media attachments. + Do you really want to delete the list %s?