From b0edaeb268db46c00729ae29d0abf36b6be614e5 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Wed, 26 Sep 2018 13:16:24 -0700 Subject: [PATCH] Align rounded corner of fastscroller popup with the top of the thumb. Bug: 63852509 Change-Id: I90b6d3e87206a53cfb4c8025a8e5f9597cf73898 --- .../views/RecyclerViewFastScroller.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/com/android/launcher3/views/RecyclerViewFastScroller.java b/src/com/android/launcher3/views/RecyclerViewFastScroller.java index f0d6de20f6..883cbeed9c 100644 --- a/src/com/android/launcher3/views/RecyclerViewFastScroller.java +++ b/src/com/android/launcher3/views/RecyclerViewFastScroller.java @@ -175,6 +175,7 @@ public class RecyclerViewFastScroller extends View { if (mThumbOffsetY == y) { return; } + updatePopupY((int) y); mThumbOffsetY = y; invalidate(); } @@ -281,7 +282,6 @@ public class RecyclerViewFastScroller extends View { mPopupView.setText(sectionName); } animatePopupVisibility(!sectionName.isEmpty()); - updatePopupY(lastY); mLastTouchY = boundedY; setThumbOffsetY((int) mLastTouchY); } @@ -299,11 +299,14 @@ public class RecyclerViewFastScroller extends View { canvas.translate(0, mThumbOffsetY); halfW += mThumbPadding; - float r = mWidth + mThumbPadding + mThumbPadding; + float r = getScrollThumbRadius(); canvas.drawRoundRect(-halfW, 0, halfW, mThumbHeight, r, r, mThumbPaint); canvas.restoreToCount(saveCount); } + private float getScrollThumbRadius() { + return mWidth + mThumbPadding + mThumbPadding; + } /** * Animates the width of the scrollbar. @@ -352,11 +355,15 @@ public class RecyclerViewFastScroller extends View { } private void updatePopupY(int lastTouchY) { + if (!mPopupVisible) { + return; + } int height = mPopupView.getHeight(); - float top = lastTouchY - (FAST_SCROLL_OVERLAY_Y_OFFSET_FACTOR * height) - + mRv.getScrollBarTop(); - top = Utilities.boundToRange(top, - mMaxWidth, mRv.getScrollbarTrackHeight() - mMaxWidth - height); + // Aligns the rounded corner of the pop up with the top of the thumb. + float top = mRv.getScrollBarTop() + lastTouchY + (getScrollThumbRadius() / 2f) + - (height / 2f); + top = Utilities.boundToRange(top, 0, + getTop() + mRv.getScrollBarTop() + mRv.getScrollbarTrackHeight() - height); mPopupView.setTranslationY(top); }