diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt b/AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt index 23eb2c324c9a..2ff09f7a0c9f 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/CardBrowser.kt @@ -38,6 +38,7 @@ import androidx.annotation.CheckResult import androidx.annotation.MainThread import androidx.annotation.VisibleForTesting import androidx.appcompat.widget.SearchView +import androidx.appcompat.widget.ThemeUtils import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.LinearLayoutManager @@ -1016,9 +1017,14 @@ open class CardBrowser : } for ((flag, displayName) in Flag.queryDisplayNames()) { - subMenu - .add(groupId, flag.code, Menu.NONE, displayName) - .setIcon(flag.drawableRes) + val item = + subMenu + .add(groupId, flag.code, Menu.NONE, displayName) + .setIcon(flag.drawableRes) + if (flag == Flag.NONE) { + val color = ThemeUtils.getThemeAttrColor(this@CardBrowser, android.R.attr.colorControlNormal) + item.icon?.mutate()?.setTint(color) + } } } } diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/Flag.kt b/AnkiDroid/src/main/java/com/ichi2/anki/Flag.kt index 996a76041da9..e6d4bbe72da1 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/Flag.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/Flag.kt @@ -37,13 +37,8 @@ enum class Flag( * Color for the background of cards with this flag in the card browser. */ @ColorRes val browserColorRes: Int?, - /** - * Flag drawn to represents this flagInTheReviewer if it differs from [drawableRes]. - * @TODO: Checks whether we can use colorControlNormal everywhere. - */ - @DrawableRes val drawableReviewerRes: Int? = null, ) { - NONE(0, R.id.flag_none, R.drawable.ic_flag_lightgrey, null, R.drawable.ic_flag_transparent), + NONE(0, R.id.flag_none, R.drawable.ic_flag_transparent, null), RED(1, R.id.flag_red, R.drawable.ic_flag_red, R.color.flag_red), ORANGE( 2, @@ -68,11 +63,6 @@ enum class Flag( ), ; - /** - * Flag drawn to represents this flagInTheReviewer. - */ - @DrawableRes fun drawableReviewerRes() = drawableReviewerRes ?: drawableRes - /** * Retrieves the name associated with the flag. This may be user-defined * diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt b/AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt index b21e346a35c2..08d6c0cb7440 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt @@ -49,6 +49,7 @@ import androidx.annotation.IntDef import androidx.annotation.VisibleForTesting import androidx.appcompat.app.AlertDialog import androidx.appcompat.view.menu.MenuBuilder +import androidx.appcompat.widget.ThemeUtils import androidx.appcompat.widget.Toolbar import androidx.core.app.ActivityCompat import androidx.core.content.ContextCompat @@ -736,9 +737,13 @@ open class Reviewer : val flagIcon = menu.findItem(R.id.action_flag) if (flagIcon != null) { if (currentCard != null) { - flagIcon.setIcon(currentCard!!.userFlag().drawableReviewerRes()) + val flag = currentCard!!.userFlag() + flagIcon.setIcon(flag.drawableRes) + if (flag == Flag.NONE && actionButtons.status.flagsIsOverflown()) { + val flagColor = ThemeUtils.getThemeAttrColor(this, android.R.attr.colorControlNormal) + flagIcon.icon?.mutate()?.setTint(flagColor) + } } - flagIcon.iconAlpha = alpha } // Anki Desktop Translations @@ -881,11 +886,8 @@ open class Reviewer : private fun setupFlags(subMenu: SubMenu) { lifecycleScope.launch { for ((flag, displayName) in Flag.queryDisplayNames()) { - val menuItem = - subMenu - .add(Menu.NONE, flag.code, Menu.NONE, displayName) - .setIcon(flag.drawableRes) - flagItemIds.add(menuItem.itemId) + subMenu.findItem(flag.id).setTitle(displayName) + flagItemIds.add(flag.id) } } } diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/reviewer/ActionButtonStatus.kt b/AnkiDroid/src/main/java/com/ichi2/anki/reviewer/ActionButtonStatus.kt index 4e8712ed30a8..ebf8986cd478 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/reviewer/ActionButtonStatus.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/reviewer/ActionButtonStatus.kt @@ -109,6 +109,8 @@ class ActionButtonStatus { fun buryIsDisabled(): Boolean = customButtons[R.id.action_bury] == MENU_DISABLED + fun flagsIsOverflown(): Boolean = customButtons[R.id.action_flag] == SHOW_AS_ACTION_NEVER + companion object { const val SHOW_AS_ACTION_NEVER = MenuItem.SHOW_AS_ACTION_NEVER const val SHOW_AS_ACTION_IF_ROOM = MenuItem.SHOW_AS_ACTION_IF_ROOM diff --git a/AnkiDroid/src/main/res/menu/reviewer.xml b/AnkiDroid/src/main/res/menu/reviewer.xml index 45ffd00c309a..dff569ffb447 100644 --- a/AnkiDroid/src/main/res/menu/reviewer.xml +++ b/AnkiDroid/src/main/res/menu/reviewer.xml @@ -58,7 +58,38 @@ android:icon="@drawable/ic_flag_transparent" ankidroid:showAsAction="always" > - + + + + + + + +