Skip to content

Commit

Permalink
improvement(rename-flag): remove 'ok/cancel'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
david-allison authored and mikehardy committed Jun 20, 2024
1 parent 11f7d5a commit bd29627
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 27 deletions.
24 changes: 0 additions & 24 deletions AnkiDroid/src/main/java/com/ichi2/anki/dialogs/FlagRenameDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()

Expand All @@ -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()
Expand Down
3 changes: 0 additions & 3 deletions AnkiDroid/src/main/res/values/03-dialogs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,4 @@ also changes the interval of the card"

<!-- Outdated WebView dialog -->
<string name="webview_update_message">The system WebView is outdated. Some features won’t work correctly. Please update it.\n\nInstalled version: %1$d\nMinimum required version: %2$d</string>

<!-- Rename Flags -->
<string name="confirm_before_saving">Confirm all changes before saving</string>
</resources>

0 comments on commit bd29627

Please sign in to comment.