browse: nav reveal during thumb drag
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start with AnkiDroid/src/test/java/com/ichi2/anki/BottomNavigationScrollTest.kt and read the existing browser navigation scroll tests. Run the new thumb drag test to reproduce the behavior: during a drag toward later rows, navigation should stay hidden while more rows remain below the viewport. Then trace the scroll and navigation behavior involved and confirm the test passes.
Written by the indexing model from the issue text.
Description
Subject: [PATCH] [EXISTING] test(browse): record nav reveal during thumb drag
---
Index: AnkiDroid/src/test/java/com/ichi2/anki/BottomNavigationScrollTest.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/BottomNavigationScrollTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/BottomNavigationScrollTest.kt
--- a/AnkiDroid/src/test/java/com/ichi2/anki/BottomNavigationScrollTest.kt (revision e1115797e35deb6d59ff712b634101f16bb8e3d1)
+++ b/AnkiDroid/src/test/java/com/ichi2/anki/BottomNavigationScrollTest.kt (revision 1d7069aafdd8a0cdc6afa17486841adaccc6c4fb)
@@ -32,10 +32,13 @@
import com.ichi2.anki.settings.Prefs
import com.ichi2.anki.ui.RecyclerFastScroller
import com.ichi2.testutils.dispatchInsets
+import com.ichi2.testutils.rules.ExistingIssue
+import com.ichi2.testutils.rules.ExistingIssueRule
import com.ichi2.testutils.withPref
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.equalTo
import org.hamcrest.Matchers.lessThanOrEqualTo
+import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.Shadows.shadowOf
@@ -45,6 +48,9 @@
@RunWith(AndroidJUnit4::class)
class BottomNavigationScrollTest : RobolectricTest() {
+ @get:Rule(order = Int.MIN_VALUE)
+ val existingIssueRule = ExistingIssueRule()
+
@Test
fun `reaching the last browser row shows navigation and keeps the row above it`() {
repeat(80) { addBasicNote("Card $it", "Answer") }
@@ -111,6 +117,58 @@
}
}
+ @Test
+ @ExistingIssue
+ fun `dragging the scrollbar toward later rows keeps navigation hidden mid-list`() {
+ repeat(200) { addBasicNote("Card $it", "Answer") }
+ withBottomNavigation { activity ->
+ val nav = activity.bottomNav
+ nav.selectedItemId = NavigationItem.BROWSER.id
+ advanceRobolectricLooper()
+ val list = activity.findViewById<RecyclerView>(R.id.card_browser_list)
+ list.descendantFocusability = ViewGroup.FOCUS_BLOCK_DESCENDANTS
+ val layout = list.layoutManager as LinearLayoutManager
+ list.scrollToPosition(50)
+ advanceRobolectricLooper()
+ val behavior = HideViewOnScrollBehavior.from(nav)
+ behavior.slideOut(nav)
+ advanceRobolectricLooper()
+ assertThat("navigation starts hidden", behavior.isScrolledOut, equalTo(true))
+
+ val scroller = activity.findViewById<RecyclerFastScroller>(R.id.browser_scroller)
+ scroller.isHidingEnabled = false
+ scroller.show(animate = false)
+ advanceRobolectricLooper()
+ val startPosition = layout.findFirstVisibleItemPosition()
+ val position = IntArray(2).also(scroller::getLocationInWindow)
+ val startY = position[1] + scroller.handle.top + scroller.handle.height / 2f
+ val endY = position[1] + scroller.height * 0.6f
+ val startTime = SystemClock.uptimeMillis()
+ val x = position[0] + scroller.width / 2f
+
+ fun touch(
+ action: Int,
+ elapsed: Long,
+ y: Float,
+ ) {
+ val event = MotionEvent.obtain(startTime, startTime + elapsed, action, x, y, 0)
+ activity.dispatchTouchEvent(event)
+ event.recycle()
+ }
+
+ touch(MotionEvent.ACTION_DOWN, 0, startY)
+ for (step in 1..5) {
+ touch(MotionEvent.ACTION_MOVE, step * 10L, startY + (endY - startY) * step / 5f)
+ }
+ touch(MotionEvent.ACTION_UP, 60, endY)
+ advanceRobolectricLooper()
+
+ assertThat("the thumb drag moved toward later rows", layout.findFirstVisibleItemPosition() > startPosition, equalTo(true))
+ assertThat("more rows remain below the viewport", list.canScrollVertically(1), equalTo(true))
+ assertThat("navigation stays hidden in the middle of the list", behavior.isScrolledOut, equalTo(true))
+ }
+ }
+
@Test
fun `navigation stays visible when the browser list fits on screen`() =
withBottomNavigation { activity ->
- Dominant language
- Kotlin
- Stars
- 12.3k
- Forks
- 3.1k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 383
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ankidroid/Anki-Android
-
Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ankidroid/Anki-Android#23392 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
ankidroid/Anki-Android#23385 · 1 reaction ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
ankidroid/Anki-Android#23374 ·
Maintainers usually reply within 1 day
-
Selected custom-study tags become unreadablePossibly taken @chesh-ire claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ankidroid/Anki-Android#23352 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
-
Good First Issue
Difficulty 2/5 1-3 hours Newbie friendliness 61/100
ankidroid/Anki-Android#23350 ·
Maintainers usually reply within 1 day
All issues in ankidroid/Anki-Android
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
LeanBitLab/LeanType#864 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 61/100
PixelPlayerHQ/PixelPlayerOSS#249 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
streetcomplete/StreetComplete#7395 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
134130/intellij-mise#552 ·