Loading src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java +44 −21 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ import android.view.View; import android.view.ViewConfiguration; import android.widget.TextView; import com.android.launcher3.config.FeatureFlags; /** * The track and scrollbar that shows when you scroll the list. */ Loading Loading @@ -198,6 +200,11 @@ public class BaseRecyclerViewFastScrollBar { case MotionEvent.ACTION_DOWN: if (isNearThumb(downX, downY)) { mTouchOffsetY = downY - mThumbOffsetY; } else if (FeatureFlags.LAUNCHER3_DIRECT_SCROLL && mRv.supportsFastScrolling() && isNearScrollBar(downX)) { calcTouchOffsetAndPrepToFastScroll(downY, lastY); updateFastScrollSectionNameAndThumbOffset(lastY, y); } break; case MotionEvent.ACTION_MOVE: Loading @@ -207,6 +214,27 @@ public class BaseRecyclerViewFastScrollBar { if (!mIsDragging && !mIgnoreDragGesture && mRv.supportsFastScrolling() && isNearThumb(downX, lastY) && Math.abs(y - downY) > config.getScaledTouchSlop()) { calcTouchOffsetAndPrepToFastScroll(downY, lastY); } if (mIsDragging) { updateFastScrollSectionNameAndThumbOffset(lastY, y); } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mTouchOffsetY = 0; mLastTouchY = 0; mIgnoreDragGesture = false; if (mIsDragging) { mIsDragging = false; animatePopupVisibility(false); showActiveScrollbar(false); } break; } } private void calcTouchOffsetAndPrepToFastScroll(int downY, int lastY) { mRv.getParent().requestDisallowInterceptTouchEvent(true); mIsDragging = true; if (mCanThumbDetach) { Loading @@ -216,7 +244,8 @@ public class BaseRecyclerViewFastScrollBar { animatePopupVisibility(true); showActiveScrollbar(true); } if (mIsDragging) { private void updateFastScrollSectionNameAndThumbOffset(int lastY, int y) { // Update the fastscroller section name at this touch position int bottom = mRv.getScrollbarTrackHeight() - mThumbHeight; float boundedY = (float) Math.max(0, Math.min(bottom, y - mTouchOffsetY)); Loading @@ -230,20 +259,6 @@ public class BaseRecyclerViewFastScrollBar { mLastTouchY = boundedY; setThumbOffsetY((int) mLastTouchY); } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mTouchOffsetY = 0; mLastTouchY = 0; mIgnoreDragGesture = false; if (mIsDragging) { mIsDragging = false; animatePopupVisibility(false); showActiveScrollbar(false); } break; } } public void draw(Canvas canvas) { if (mThumbOffsetY < 0) { Loading Loading @@ -277,7 +292,7 @@ public class BaseRecyclerViewFastScrollBar { } /** * Returns whether the specified points are near the scroll bar bounds. * Returns whether the specified point is inside the thumb bounds. */ public boolean isNearThumb(int x, int y) { int left = getDrawLeft(); Loading @@ -286,6 +301,14 @@ public class BaseRecyclerViewFastScrollBar { return mTmpRect.contains(x, y); } /** * Returns whether the specified x position is near the scroll bar. */ public boolean isNearScrollBar(int x) { int left = getDrawLeft(); return x >= left && x <= left + mMaxWidth; } private void animatePopupVisibility(boolean visible) { if (mPopupVisible != visible) { mPopupVisible = visible; Loading src_config/com/android/launcher3/config/FeatureFlags.java +2 −0 Original line number Diff line number Diff line Loading @@ -37,4 +37,6 @@ public final class FeatureFlags { public static final boolean PULLDOWN_SEARCH = false; // When enabled the status bar may show dark icons based on the top of the wallpaper. public static final boolean LIGHT_STATUS_BAR = false; // When enabled allows to use any point on the fast scrollbar to start dragging. public static final boolean LAUNCHER3_DIRECT_SCROLL = true; } Loading
src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java +44 −21 Original line number Diff line number Diff line Loading @@ -28,6 +28,8 @@ import android.view.View; import android.view.ViewConfiguration; import android.widget.TextView; import com.android.launcher3.config.FeatureFlags; /** * The track and scrollbar that shows when you scroll the list. */ Loading Loading @@ -198,6 +200,11 @@ public class BaseRecyclerViewFastScrollBar { case MotionEvent.ACTION_DOWN: if (isNearThumb(downX, downY)) { mTouchOffsetY = downY - mThumbOffsetY; } else if (FeatureFlags.LAUNCHER3_DIRECT_SCROLL && mRv.supportsFastScrolling() && isNearScrollBar(downX)) { calcTouchOffsetAndPrepToFastScroll(downY, lastY); updateFastScrollSectionNameAndThumbOffset(lastY, y); } break; case MotionEvent.ACTION_MOVE: Loading @@ -207,6 +214,27 @@ public class BaseRecyclerViewFastScrollBar { if (!mIsDragging && !mIgnoreDragGesture && mRv.supportsFastScrolling() && isNearThumb(downX, lastY) && Math.abs(y - downY) > config.getScaledTouchSlop()) { calcTouchOffsetAndPrepToFastScroll(downY, lastY); } if (mIsDragging) { updateFastScrollSectionNameAndThumbOffset(lastY, y); } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mTouchOffsetY = 0; mLastTouchY = 0; mIgnoreDragGesture = false; if (mIsDragging) { mIsDragging = false; animatePopupVisibility(false); showActiveScrollbar(false); } break; } } private void calcTouchOffsetAndPrepToFastScroll(int downY, int lastY) { mRv.getParent().requestDisallowInterceptTouchEvent(true); mIsDragging = true; if (mCanThumbDetach) { Loading @@ -216,7 +244,8 @@ public class BaseRecyclerViewFastScrollBar { animatePopupVisibility(true); showActiveScrollbar(true); } if (mIsDragging) { private void updateFastScrollSectionNameAndThumbOffset(int lastY, int y) { // Update the fastscroller section name at this touch position int bottom = mRv.getScrollbarTrackHeight() - mThumbHeight; float boundedY = (float) Math.max(0, Math.min(bottom, y - mTouchOffsetY)); Loading @@ -230,20 +259,6 @@ public class BaseRecyclerViewFastScrollBar { mLastTouchY = boundedY; setThumbOffsetY((int) mLastTouchY); } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mTouchOffsetY = 0; mLastTouchY = 0; mIgnoreDragGesture = false; if (mIsDragging) { mIsDragging = false; animatePopupVisibility(false); showActiveScrollbar(false); } break; } } public void draw(Canvas canvas) { if (mThumbOffsetY < 0) { Loading Loading @@ -277,7 +292,7 @@ public class BaseRecyclerViewFastScrollBar { } /** * Returns whether the specified points are near the scroll bar bounds. * Returns whether the specified point is inside the thumb bounds. */ public boolean isNearThumb(int x, int y) { int left = getDrawLeft(); Loading @@ -286,6 +301,14 @@ public class BaseRecyclerViewFastScrollBar { return mTmpRect.contains(x, y); } /** * Returns whether the specified x position is near the scroll bar. */ public boolean isNearScrollBar(int x) { int left = getDrawLeft(); return x >= left && x <= left + mMaxWidth; } private void animatePopupVisibility(boolean visible) { if (mPopupVisible != visible) { mPopupVisible = visible; Loading
src_config/com/android/launcher3/config/FeatureFlags.java +2 −0 Original line number Diff line number Diff line Loading @@ -37,4 +37,6 @@ public final class FeatureFlags { public static final boolean PULLDOWN_SEARCH = false; // When enabled the status bar may show dark icons based on the top of the wallpaper. public static final boolean LIGHT_STATUS_BAR = false; // When enabled allows to use any point on the fast scrollbar to start dragging. public static final boolean LAUNCHER3_DIRECT_SCROLL = true; }