diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt b/AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt index 61cdbabe6d5d..ba45c155a78a 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt @@ -735,6 +735,7 @@ open class CardBrowser : // restore drawer click listener and icon restoreDrawerIcon() menuInflater.inflate(R.menu.card_browser, menu) + setFlagTitles(menu) saveSearchItem = menu.findItem(R.id.action_save_search) saveSearchItem?.isVisible = false // the searchview's query always starts empty. mySearchesItem = menu.findItem(R.id.action_list_my_searches) @@ -788,6 +789,7 @@ open class CardBrowser : } else { // multi-select mode menuInflater.inflate(R.menu.card_browser_multiselect, menu) + setMultiSelectFlagTitles(menu) showBackIcon() increaseHorizontalPaddingOfOverflowMenuIcons(menu) } @@ -821,6 +823,28 @@ open class CardBrowser : } } + private fun setFlagTitles(menu: Menu) { + menu.findItem(R.id.action_select_flag_zero).title = Flag.NONE.displayName() + menu.findItem(R.id.action_select_flag_one).title = Flag.RED.displayName() + menu.findItem(R.id.action_select_flag_two).title = Flag.ORANGE.displayName() + menu.findItem(R.id.action_select_flag_three).title = Flag.GREEN.displayName() + menu.findItem(R.id.action_select_flag_four).title = Flag.BLUE.displayName() + menu.findItem(R.id.action_select_flag_five).title = Flag.PINK.displayName() + menu.findItem(R.id.action_select_flag_six).title = Flag.TURQUOISE.displayName() + menu.findItem(R.id.action_select_flag_seven).title = Flag.PURPLE.displayName() + } + + private fun setMultiSelectFlagTitles(menu: Menu) { + menu.findItem(R.id.action_flag_zero).title = Flag.NONE.displayName() + menu.findItem(R.id.action_flag_one).title = Flag.RED.displayName() + menu.findItem(R.id.action_flag_two).title = Flag.ORANGE.displayName() + menu.findItem(R.id.action_flag_three).title = Flag.GREEN.displayName() + menu.findItem(R.id.action_flag_four).title = Flag.BLUE.displayName() + menu.findItem(R.id.action_flag_five).title = Flag.PINK.displayName() + menu.findItem(R.id.action_flag_six).title = Flag.TURQUOISE.displayName() + menu.findItem(R.id.action_flag_seven).title = Flag.PURPLE.displayName() + } + private fun updatePreviewMenuItem() { previewItem?.isVisible = viewModel.rowCount > 0 } diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/Flag.kt b/AnkiDroid/src/main/java/com/ichi2/anki/Flag.kt index fb0464b4df93..22dac034004d 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/Flag.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/Flag.kt @@ -17,6 +17,7 @@ package com.ichi2.anki import androidx.annotation.ColorRes import androidx.annotation.DrawableRes +import com.ichi2.anki.CollectionManager.TR import com.ichi2.libanki.Card import com.ichi2.libanki.CardId import com.ichi2.libanki.Collection @@ -31,6 +32,17 @@ enum class Flag(val code: Int, @DrawableRes val drawableRes: Int, @ColorRes val TURQUOISE(6, R.drawable.ic_flag_turquoise, R.color.flag_turquoise), PURPLE(7, R.drawable.ic_flag_purple, R.color.flag_purple); + fun displayName(): String = when (this) { + NONE -> TR.browsingNoFlag() + RED -> TR.actionsFlagRed() + ORANGE -> TR.actionsFlagOrange() + GREEN -> TR.actionsFlagGreen() + BLUE -> TR.actionsFlagBlue() + PINK -> TR.actionsFlagPink() + TURQUOISE -> TR.actionsFlagTurquoise() + PURPLE -> TR.actionsFlagPurple() + } + companion object { fun fromCode(code: Int): Flag { return entries.first { it.code == code } diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt b/AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt index b6d80b1e9598..56e17cca75f1 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt @@ -45,6 +45,7 @@ import anki.frontend.SetSchedulingStatesRequest import com.google.android.material.color.MaterialColors import com.google.android.material.snackbar.Snackbar import com.ichi2.anim.ActivityTransitionAnimation.getInverseTransition +import com.ichi2.anki.CollectionManager.TR import com.ichi2.anki.CollectionManager.withCol import com.ichi2.anki.Whiteboard.Companion.createInstance import com.ichi2.anki.Whiteboard.OnPaintColorChangeListener @@ -692,6 +693,7 @@ open class Reviewer : Timber.d("onCreateOptionsMenu()") // NOTE: This is called every time a new question is shown via invalidate options menu menuInflater.inflate(R.menu.reviewer, menu) + setFlagTitles(menu) displayIcons(menu) actionButtons.setCustomButtonsStatus(menu) val alpha = Themes.ALPHA_ICON_ENABLED_LIGHT @@ -848,6 +850,17 @@ open class Reviewer : return super.onCreateOptionsMenu(menu) } + private fun setFlagTitles(menu: Menu) { + menu.findItem(R.id.action_flag_zero).title = Flag.NONE.displayName() + menu.findItem(R.id.action_flag_one).title = Flag.RED.displayName() + menu.findItem(R.id.action_flag_two).title = Flag.ORANGE.displayName() + menu.findItem(R.id.action_flag_three).title = Flag.GREEN.displayName() + menu.findItem(R.id.action_flag_four).title = Flag.BLUE.displayName() + menu.findItem(R.id.action_flag_five).title = Flag.PINK.displayName() + menu.findItem(R.id.action_flag_six).title = Flag.TURQUOISE.displayName() + menu.findItem(R.id.action_flag_seven).title = Flag.PURPLE.displayName() + } + @SuppressLint("RestrictedApi") private fun displayIcons(menu: Menu) { try { diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerFragment.kt b/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerFragment.kt index c3afb236ba07..a9d107202e92 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerFragment.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/previewer/PreviewerFragment.kt @@ -97,6 +97,7 @@ class PreviewerFragment : } /* ************************************* Menu items ************************************* */ val menu = view.findViewById(R.id.toolbar).menu + setFlagTitles(menu) lifecycleScope.launch { viewModel.backSideOnly @@ -204,6 +205,17 @@ class PreviewerFragment : return true } + private fun setFlagTitles(menu: Menu) { + menu.findItem(R.id.action_flag_zero).title = Flag.NONE.displayName() + menu.findItem(R.id.action_flag_one).title = Flag.RED.displayName() + menu.findItem(R.id.action_flag_two).title = Flag.ORANGE.displayName() + menu.findItem(R.id.action_flag_three).title = Flag.GREEN.displayName() + menu.findItem(R.id.action_flag_four).title = Flag.BLUE.displayName() + menu.findItem(R.id.action_flag_five).title = Flag.PINK.displayName() + menu.findItem(R.id.action_flag_six).title = Flag.TURQUOISE.displayName() + menu.findItem(R.id.action_flag_seven).title = Flag.PURPLE.displayName() + } + private fun setBackSideOnlyButtonIcon(menu: Menu, isBackSideOnly: Boolean) { menu.findItem(R.id.action_back_side_only).apply { if (isBackSideOnly) { diff --git a/AnkiDroid/src/main/res/menu/card_browser.xml b/AnkiDroid/src/main/res/menu/card_browser.xml index df6f66f27417..2481fbcaf0e8 100644 --- a/AnkiDroid/src/main/res/menu/card_browser.xml +++ b/AnkiDroid/src/main/res/menu/card_browser.xml @@ -1,5 +1,6 @@ + xmlns:ankidroid="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> + tools:title="No Flag"/> diff --git a/AnkiDroid/src/main/res/menu/card_browser_multiselect.xml b/AnkiDroid/src/main/res/menu/card_browser_multiselect.xml index 5ce4d906c154..64deb37a7150 100644 --- a/AnkiDroid/src/main/res/menu/card_browser_multiselect.xml +++ b/AnkiDroid/src/main/res/menu/card_browser_multiselect.xml @@ -27,34 +27,34 @@ + tools:title="No Flag"/> diff --git a/AnkiDroid/src/main/res/menu/previewer.xml b/AnkiDroid/src/main/res/menu/previewer.xml index 7643e7472d9b..1c53b71283d6 100644 --- a/AnkiDroid/src/main/res/menu/previewer.xml +++ b/AnkiDroid/src/main/res/menu/previewer.xml @@ -15,7 +15,8 @@ ~ this program. If not, see . --> + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> + tools:title="No Flag"/> diff --git a/AnkiDroid/src/main/res/menu/reviewer.xml b/AnkiDroid/src/main/res/menu/reviewer.xml index afed334af0f9..486aa6c9079e 100644 --- a/AnkiDroid/src/main/res/menu/reviewer.xml +++ b/AnkiDroid/src/main/res/menu/reviewer.xml @@ -60,34 +60,34 @@ + tools:title="No Flag"/> diff --git a/AnkiDroid/src/main/res/values/01-core.xml b/AnkiDroid/src/main/res/values/01-core.xml index a1915a8e5244..7580091f1c7c 100644 --- a/AnkiDroid/src/main/res/values/01-core.xml +++ b/AnkiDroid/src/main/res/values/01-core.xml @@ -85,14 +85,6 @@ Delete note Flag Flag card - No flag - Red flag - Orange flag - Green flag - Blue flag - Pink flag - Turquoise flag - Purple flag Edit tags Really delete this note and all its cards?\n%s Lookup in %1$s