browser scrollbar: record lost release at the end
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 67/100
Research direction
Start with AnkiDroid/src/test/java/com/ichi2/anki/ui/RecyclerFastScrollerTest.kt and inspect the existing test for releasing the thumb at the end before layout reaches the last row. Read the fast scroller's touch and layout handling to find why the final row remains scrollable after release. Reproduce the failure with this test, then confirm it passes when release leaves the final row fully visible.
Written by the indexing model from the issue text.
Description
Subject: [PATCH] [EXISTING] test(scrollbar): record lost release at the end
---
Index: AnkiDroid/src/test/java/com/ichi2/anki/ui/RecyclerFastScrollerTest.kt
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/ui/RecyclerFastScrollerTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/ui/RecyclerFastScrollerTest.kt
--- a/AnkiDroid/src/test/java/com/ichi2/anki/ui/RecyclerFastScrollerTest.kt (revision dd0e6adae7311ec020eb84ad6d723bdf3ccf384b)
+++ b/AnkiDroid/src/test/java/com/ichi2/anki/ui/RecyclerFastScrollerTest.kt (revision e1115797e35deb6d59ff712b634101f16bb8e3d1)
@@ -17,8 +17,11 @@
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.ichi2.anki.EmptyApplicationCategory
import com.ichi2.testutils.EmptyApplication
+import com.ichi2.testutils.rules.ExistingIssue
+import com.ichi2.testutils.rules.ExistingIssueRule
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.equalTo
+import org.junit.Rule
import org.junit.Test
import org.junit.experimental.categories.Category
import org.junit.runner.RunWith
@@ -31,6 +34,21 @@
@Config(application = EmptyApplication::class)
@Category(EmptyApplicationCategory::class)
class RecyclerFastScrollerTest {
+ @get:Rule(order = Int.MIN_VALUE)
+ val existingIssueRule = ExistingIssueRule()
+
+ @Test
+ @ExistingIssue
+ fun `releasing the thumb at the end before layout reaches the last row`() {
+ val list = FastScrollerTestList(evenRows(200))
+ assertThat("the test starts away from the end", list.canScrollDown, equalTo(true))
+ list.press()
+ list.moveTo(trackProportion = 1f, advanceFrame = false)
+ list.release()
+
+ assertThat("the release leaves the final row fully visible", list.canScrollDown, equalTo(false))
+ }
+
@Test
fun `scroller hides after a thumb drag`() {
val list = FastScrollerTestList(evenRows(200))
@@ -87,6 +105,8 @@
val isScrollerHidden: Boolean get() = scroller.translationX == scroller.hiddenTranslationX.toFloat()
+ val canScrollDown: Boolean get() = recyclerView.canScrollVertically(1)
+
init {
scroller.attachRecyclerView(recyclerView)
activity.setContentView(root, ViewGroup.LayoutParams(WIDTH, HEIGHT))
@@ -95,9 +115,13 @@
fun press() = touch(MotionEvent.ACTION_DOWN, (scroller.handle.top + scroller.handle.bottom) / 2f)
- fun moveTo(trackProportion: Float) {
+ fun moveTo(
+ trackProportion: Float,
+ advanceFrame: Boolean = true,
+ ) {
val thumbHeight = scroller.handle.height
- touch(MotionEvent.ACTION_MOVE, thumbHeight / 2f + trackProportion * (HEIGHT - thumbHeight))
+ val travel = scroller.height - scroller.handleBottomInset - thumbHeight
+ touch(MotionEvent.ACTION_MOVE, thumbHeight / 2f + trackProportion * travel, advanceFrame)
}
fun release() = touch(MotionEvent.ACTION_UP, fingerY)
@@ -107,12 +131,13 @@
private fun touch(
action: Int,
y: Float,
+ advanceFrame: Boolean = true,
) {
fingerY = y
val event = MotionEvent.obtain(downTime, SystemClock.uptimeMillis(), action, scroller.width / 2f, y, 0)
scroller.dispatchTouchEvent(event)
event.recycle()
- showNextFrame()
+ if (advanceFrame) showNextFrame()
}
private fun showNextFrame() = shadowOf(Looper.getMainLooper()).idleFor(FRAME_INTERVAL)
- 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
-
Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ankidroid/Anki-Android#23390 ·
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
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 ·