From fa73257002ddf6b3e5aa3b8945fab78ce3ec0525 Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Fri, 6 Jan 2023 13:00:35 -0600 Subject: [wallet] Add delete dialog in transactions list --- .../wallet/transactions/TransactionsFragment.kt | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'wallet/src/main/java') diff --git a/wallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt b/wallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt index 0e7ef07..1926217 100644 --- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt +++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt @@ -25,6 +25,8 @@ import android.view.MenuItem import android.view.View import android.view.View.INVISIBLE import android.view.ViewGroup +import androidx.annotation.StringRes +import androidx.appcompat.app.AlertDialog import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView.OnQueryTextListener import androidx.fragment.app.Fragment @@ -216,11 +218,28 @@ class TransactionsFragment : Fragment(), OnTransactionClickListener, ActionMode. return false // no update needed } + @StringRes + val deleteDialogTitle = R.string.transactions_delete + @StringRes + val deleteDialogMessage = R.string.transactions_delete_selected_dialog_message + @StringRes + val deleteDialogButton = R.string.transactions_delete + override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean { when (item.itemId) { R.id.transaction_delete -> { tracker?.selection?.toList()?.let { transactionIds -> - transactionManager.deleteTransactions(transactionIds) + AlertDialog.Builder(requireContext(), R.style.DialogTheme) + .setTitle(deleteDialogTitle) + .setMessage(deleteDialogMessage) + .setPositiveButton(R.string.cancel) { dialog, _ -> + dialog.cancel() + } + .setNegativeButton(deleteDialogButton) { dialog, _ -> + transactionManager.deleteTransactions(transactionIds) + dialog.dismiss() + } + .show() } mode.finish() } -- cgit v1.2.3