Answer button settings disappear in short windows

Open
#23,368 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

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

Research direction

Read the compact-window Compose test in AnkiDroid/src/test/java/com/ichi2/anki/preferences/AnswerButtonsCompactWindowTest.kt and the settings UI it exercises, starting with AnswerButtonsSettingsFragment. Run the test with its short-window qualifiers and large font scale; done means the answer button setting remains visible and can be toggled. The issue says this regression is blocked by #23321, so check that work before starting.

Written by the indexing model from the issue text.

Description

Blocked by dependency

This is a known and accepted regression in the linked PR.

  • Introduced and blocked by: #23321

Assisted-by: GPT-6.1-Sol xhigh & GPT-6-Astra xhigh

Subject: Answer button settings disappear in short windows

With large system text in a short window, the fixed preview consumes the controls viewport and prevents changing settings.

---
diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/preferences/AnswerButtonsCompactWindowTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/preferences/AnswerButtonsCompactWindowTest.kt
new file mode 100644
index 0000000000..1e8ded3737
--- /dev/null
+++ b/AnkiDroid/src/test/java/com/ichi2/anki/preferences/AnswerButtonsCompactWindowTest.kt
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package com.ichi2.anki.preferences
+
+import androidx.compose.ui.test.assertIsDisplayed
+import androidx.compose.ui.test.click
+import androidx.compose.ui.test.junit4.v2.createEmptyComposeRule
+import androidx.compose.ui.test.onNodeWithText
+import androidx.compose.ui.test.performScrollTo
+import androidx.compose.ui.test.performTouchInput
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import com.ichi2.anki.RobolectricTest
+import com.ichi2.anki.settings.Prefs
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.robolectric.Robolectric
+import org.robolectric.RuntimeEnvironment
+import org.robolectric.annotation.Config
+import kotlin.test.assertTrue
+import com.ichi2.anki.common.android.R as CommonR
+
+@RunWith(AndroidJUnit4::class)
+@Config(qualifiers = "w640dp-h220dp-land")
+class AnswerButtonsCompactWindowTest : RobolectricTest() {
+    @get:Rule
+    val composeRule = createEmptyComposeRule()
+
+    @Test
+    fun `answer button switch remains usable in a short window with large text`() {
+        RuntimeEnvironment.setFontScale(2f)
+        Prefs.isNewStudyScreenEnabled = true
+        Prefs.showAnswerButtons = false
+        val intent = PreferencesActivity.getIntent(targetContext, AnswerButtonsSettingsFragment::class)
+        val controller =
+            Robolectric
+                .buildActivity(PreferencesActivity::class.java, intent)
+                .create()
+                .start()
+                .resume()
+                .visible()
+        saveControllerForCleanup(controller)
+        advanceRobolectricLooper()
+
+        composeRule
+            .onNodeWithText(targetContext.getString(CommonR.string.show_answer_buttons))
+            .performScrollTo()
+            .assertIsDisplayed()
+            .performTouchInput { click() }
+        assertTrue(Prefs.showAnswerButtons)
+    }
+}

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

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.