From bd296276fb60a52a4cc6331757abe94427a1ec6b Mon Sep 17 00:00:00 2001
From: David Allison <62114487+david-allison@users.noreply.github.com>
Date: Thu, 20 Jun 2024 13:11:55 +0100
Subject: [PATCH] improvement(rename-flag): remove 'ok/cancel'
* This made it more obvious that the 'tick' should be pressed
* Cancel didn't work as expected
* OK didn't perform saves
Prompted by
https://redirect.github.com/ankidroid/Anki-Android/pull/16244#issuecomment-2180497998
Related: 16205
---
.../ichi2/anki/dialogs/FlagRenameDialog.kt | 24 -------------------
AnkiDroid/src/main/res/values/03-dialogs.xml | 3 ---
2 files changed, 27 deletions(-)
diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/FlagRenameDialog.kt b/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/FlagRenameDialog.kt
index ab86381101c5..44d9e7987ad1 100644
--- a/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/FlagRenameDialog.kt
+++ b/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/FlagRenameDialog.kt
@@ -28,10 +28,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.ichi2.anki.Flag
import com.ichi2.anki.R
-import com.ichi2.anki.showThemedToast
import com.ichi2.utils.customView
-import com.ichi2.utils.negativeButton
-import com.ichi2.utils.positiveButton
import com.ichi2.utils.title
import kotlinx.coroutines.launch
import timber.log.Timber
@@ -48,9 +45,6 @@ class FlagRenameDialog : DialogFragment() {
val builder = AlertDialog.Builder(requireContext()).apply {
customView(view = dialogView, 4, 4, 4, 4)
title(R.string.rename_flag)
- // positiveButton is set in onResume so dialog is not always dismissed
- positiveButton(R.string.dialog_ok, click = null)
- negativeButton(R.string.dialog_cancel)
}
val dialog = builder.create()
@@ -59,24 +53,6 @@ class FlagRenameDialog : DialogFragment() {
return dialog
}
- override fun onResume() {
- super.onResume()
- (dialog as AlertDialog).positiveButton.setOnClickListener {
- // TODO: Extract pending changes from the adapter and save them
- if (!::flagAdapter.isInitialized) return@setOnClickListener
- val pendingChanges = flagAdapter.currentList.filter { it.isInEditMode }
- if (pendingChanges.any()) {
- Timber.i("Attempted to close with %d pending changes", pendingChanges.size)
- showThemedToast(R.string.confirm_before_saving, true)
- return@setOnClickListener
- }
-
- Timber.i("Closing dialog", pendingChanges.size)
- activity?.invalidateOptionsMenu()
- dismiss()
- }
- }
-
override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)
activity?.invalidateOptionsMenu()
diff --git a/AnkiDroid/src/main/res/values/03-dialogs.xml b/AnkiDroid/src/main/res/values/03-dialogs.xml
index 4f5fa9c1343b..dcb26acbb988 100644
--- a/AnkiDroid/src/main/res/values/03-dialogs.xml
+++ b/AnkiDroid/src/main/res/values/03-dialogs.xml
@@ -278,7 +278,4 @@ also changes the interval of the card"
The system WebView is outdated. Some features won’t work correctly. Please update it.\n\nInstalled version: %1$d\nMinimum required version: %2$d
-
-
- Confirm all changes before saving