Selected custom-study tags become unreadable

Open Beginner friendly
#23,352 1 comment 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@chesh-ire is already working on this.

Since Nov 17, 2026.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
62/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
android, kotlin
Domain
frontend, mobile

Research direction

Start with IncludedExcludedTagsAdapter and the included test AnkiDroid/src/test/java/com/ichi2/anki/dialogs/customstudy/IncludedExcludedTagsAdapterTest.kt, which checks selected tag contrast in E-ink day and night modes. Reproduce the unreadable label and inspect how selection changes its text and background colors. Done when selected Include and Exclude tags remain readable in both modes and deselecting restores the original text colors.

Written by the indexing model from the issue text.

Description

Subject: [EXISTING] Selected custom-study tags become unreadable

Selecting an Include or Exclude tag in E-ink hides its label against the selected background, including in the new night theme.

⚠️ This issue existed before the PR and should likely be split off into a separate issue.

---
diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/customstudy/IncludedExcludedTagsAdapterTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/customstudy/IncludedExcludedTagsAdapterTest.kt
new file mode 100644
index 0000000000..2f94e9c6a0
--- /dev/null
+++ b/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/customstudy/IncludedExcludedTagsAdapterTest.kt
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package com.ichi2.anki.dialogs.customstudy
+
+import android.graphics.drawable.ColorDrawable
+import android.view.ContextThemeWrapper
+import android.widget.FrameLayout
+import androidx.core.graphics.ColorUtils
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import com.ichi2.anki.RobolectricTest
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.robolectric.RuntimeEnvironment
+import kotlin.test.assertEquals
+import kotlin.test.assertTrue
+import com.ichi2.anki.common.android.R as CommonR
+
+@RunWith(AndroidJUnit4::class)
+class IncludedExcludedTagsAdapterTest : RobolectricTest() {
+    @Test
+    fun `selected E-ink tags remain readable in day mode`() {
+        assertSelectedTagsReadable("+notnight")
+    }
+
+    @Test
+    fun `selected E-ink tags remain readable in night mode`() {
+        assertSelectedTagsReadable("+night")
+    }
+
+    private fun assertSelectedTagsReadable(qualifiers: String) {
+        RuntimeEnvironment.setQualifiers(qualifiers)
+        val context = ContextThemeWrapper(targetContext, CommonR.style.Theme_AnkiDroid_Eink)
+        for (mode in IncludedExcludedTagsAdapter.TagsSelectionMode.entries) {
+            val adapter = IncludedExcludedTagsAdapter(context, mode).apply {
+                isEnabled = true
+                tags = mutableListOf(TagIncludedExcluded("exam"))
+            }
+            val holder = adapter.onCreateViewHolder(FrameLayout(context), 0)
+            adapter.onBindViewHolder(holder, 0)
+            val label = holder.tagView
+            val originalTextColors = label.textColors
+            label.performClick()
+            adapter.onBindViewHolder(holder, 0)
+            val background = (label.background as ColorDrawable).color
+            val contrast = ColorUtils.calculateContrast(label.currentTextColor, background)
+            assertTrue(contrast >= 4.5, "Selected $mode tag contrast was $contrast in $qualifiers")
+            label.performClick()
+            adapter.onBindViewHolder(holder, 0)
+            assertEquals(originalTextColors, label.textColors, "Deselected $mode tag must restore its text colors")
+        }
+    }
+}

Originally posted by @david-allison in https://github.com/ankidroid/Anki-Android/pull/23308#pullrequestreview-5927866540

Dominant language
Kotlin
Stars
12.3k
Forks
3.1k
Avg merge
1d 11h
Merged PRs (30d)
383

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ankidroid/Anki-Android

All issues in ankidroid/Anki-Android

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.