Back exits DeckPicker after tablet recreation

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

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

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

Research direction

Start from AnkiDroid/src/test/java/com/ichi2/anki/DeckPickerPaneBackPriorityTest.kt: the added test recreates DeckPicker, opens reminders, and asserts Back does not finish the activity. Run that test in isolation first, then trace how DeckPicker registers its back callback and restores the reminders fragment after recreate(). Done means the new test passes and Back from reminders returns to Study Options rather than exiting DeckPicker.

Written by the indexing model from the issue text.

Description

Blocked by dependency

Assisted-by: GPT-6.1-Sol xhigh

Patch order: this patch follows the overlay regression patch liked in the PR.

Subject: [EXISTING] Back exits DeckPicker after tablet recreation

After tablet recreation, opening reminders and pressing Back closes DeckPicker instead of returning to Study Options.

⚠️ 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/DeckPickerPaneBackPriorityTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/DeckPickerPaneBackPriorityTest.kt
index 3fc345c9e02fb061b0d3f36c4509c2fdb09d3462..574bac4cfabff4ac216aa908fc37910db1b494c0 100644
--- a/AnkiDroid/src/test/java/com/ichi2/anki/DeckPickerPaneBackPriorityTest.kt
+++ b/AnkiDroid/src/test/java/com/ichi2/anki/DeckPickerPaneBackPriorityTest.kt
@@ -77,6 +77,24 @@ class DeckPickerPaneBackPriorityTest : RobolectricTest() {
         assertFalse(activity.isFinishing)
     }
 
+    @Test
+    fun `back returns from reminders after tablet recreation`() {
+        val controller = launchStudyOptions()
+        controller.recreate()
+        val activity = controller.get()
+        activity.viewModel.awaitStartup()
+        advanceRobolectricLooper()
+        assertNotNull(activity.fragment)
+        openReminders(activity)
+
+        activity.onBackPressedDispatcher.onBackPressed()
+        advanceRobolectricLooper()
+
+        assertFalse(activity.isFinishing, "Back must return to study options rather than close DeckPicker")
+        assertNotNull(activity.fragment)
+        assertTrue(reminders(activity) == null)
+    }
+
     private fun launchWithReminders(): DeckPicker {
         val activity = launchStudyOptions().get()
         openReminders(activity)

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

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.