Loading src/com/android/launcher3/widget/picker/WidgetsFullSheet.java +46 −0 Original line number Diff line number Diff line Loading @@ -169,6 +169,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet private View mSearchBarContainer; private WidgetsSearchBar mSearchBar; private TextView mHeaderTitle; private @Nullable WidgetsRecyclerView mCurrentTouchEventRecyclerView; public WidgetsFullSheet(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); Loading Loading @@ -642,6 +643,51 @@ public class WidgetsFullSheet extends BaseWidgetSheet return sheet; } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { return isTouchOnScrollbar(ev) || super.onInterceptTouchEvent(ev); } @Override public boolean onTouchEvent(MotionEvent ev) { return maybeHandleTouchEvent(ev) || super.onTouchEvent(ev); } private boolean maybeHandleTouchEvent(MotionEvent ev) { boolean isEventHandled = false; if (ev.getAction() == MotionEvent.ACTION_DOWN) { mCurrentTouchEventRecyclerView = isTouchOnScrollbar(ev) ? getRecyclerView() : null; } if (mCurrentTouchEventRecyclerView != null) { final float offsetX = mContent.getX(); final float offsetY = mContent.getY(); ev.offsetLocation(-offsetX, -offsetY); isEventHandled = mCurrentTouchEventRecyclerView.dispatchTouchEvent(ev); ev.offsetLocation(offsetX, offsetY); } if (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_CANCEL) { mCurrentTouchEventRecyclerView = null; } return isEventHandled; } private boolean isTouchOnScrollbar(MotionEvent ev) { final float offsetX = mContent.getX(); final float offsetY = mContent.getY(); WidgetsRecyclerView rv = getRecyclerView(); ev.offsetLocation(-offsetX, -offsetY); boolean isOnScrollBar = rv != null && rv.getScrollbar() != null && rv.isHitOnScrollBar(ev); ev.offsetLocation(offsetX, offsetY); return isOnScrollBar; } /** Gets the {@link WidgetsRecyclerView} which shows all widgets in {@link WidgetsFullSheet}. */ @VisibleForTesting public static WidgetsRecyclerView getWidgetsView(Launcher launcher) { Loading src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java +10 −2 Original line number Diff line number Diff line Loading @@ -127,8 +127,7 @@ public class WidgetsRecyclerView extends FastScrollRecyclerView implements OnIte @Override public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) { if (e.getAction() == MotionEvent.ACTION_DOWN) { mTouchDownOnScroller = mScrollbar.isHitInParent(e.getX(), e.getY(), mFastScrollerOffset); mTouchDownOnScroller = isHitOnScrollBar(e); } if (mTouchDownOnScroller) { final boolean result = mScrollbar.handleTouchEvent(e, mFastScrollerOffset); Loading @@ -144,6 +143,15 @@ public class WidgetsRecyclerView extends FastScrollRecyclerView implements OnIte } } /** * Detects whether a {@code MotionEvent} is on the scroll bar * @param e The {@code MotionEvent} on the screen * @return {@code true} if the motion is on the scroll bar */ boolean isHitOnScrollBar(MotionEvent e) { return mScrollbar.isHitInParent(e.getX(), e.getY(), mFastScrollerOffset); } @Override public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) { } Loading Loading
src/com/android/launcher3/widget/picker/WidgetsFullSheet.java +46 −0 Original line number Diff line number Diff line Loading @@ -169,6 +169,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet private View mSearchBarContainer; private WidgetsSearchBar mSearchBar; private TextView mHeaderTitle; private @Nullable WidgetsRecyclerView mCurrentTouchEventRecyclerView; public WidgetsFullSheet(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); Loading Loading @@ -642,6 +643,51 @@ public class WidgetsFullSheet extends BaseWidgetSheet return sheet; } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { return isTouchOnScrollbar(ev) || super.onInterceptTouchEvent(ev); } @Override public boolean onTouchEvent(MotionEvent ev) { return maybeHandleTouchEvent(ev) || super.onTouchEvent(ev); } private boolean maybeHandleTouchEvent(MotionEvent ev) { boolean isEventHandled = false; if (ev.getAction() == MotionEvent.ACTION_DOWN) { mCurrentTouchEventRecyclerView = isTouchOnScrollbar(ev) ? getRecyclerView() : null; } if (mCurrentTouchEventRecyclerView != null) { final float offsetX = mContent.getX(); final float offsetY = mContent.getY(); ev.offsetLocation(-offsetX, -offsetY); isEventHandled = mCurrentTouchEventRecyclerView.dispatchTouchEvent(ev); ev.offsetLocation(offsetX, offsetY); } if (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_CANCEL) { mCurrentTouchEventRecyclerView = null; } return isEventHandled; } private boolean isTouchOnScrollbar(MotionEvent ev) { final float offsetX = mContent.getX(); final float offsetY = mContent.getY(); WidgetsRecyclerView rv = getRecyclerView(); ev.offsetLocation(-offsetX, -offsetY); boolean isOnScrollBar = rv != null && rv.getScrollbar() != null && rv.isHitOnScrollBar(ev); ev.offsetLocation(offsetX, offsetY); return isOnScrollBar; } /** Gets the {@link WidgetsRecyclerView} which shows all widgets in {@link WidgetsFullSheet}. */ @VisibleForTesting public static WidgetsRecyclerView getWidgetsView(Launcher launcher) { Loading
src/com/android/launcher3/widget/picker/WidgetsRecyclerView.java +10 −2 Original line number Diff line number Diff line Loading @@ -127,8 +127,7 @@ public class WidgetsRecyclerView extends FastScrollRecyclerView implements OnIte @Override public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) { if (e.getAction() == MotionEvent.ACTION_DOWN) { mTouchDownOnScroller = mScrollbar.isHitInParent(e.getX(), e.getY(), mFastScrollerOffset); mTouchDownOnScroller = isHitOnScrollBar(e); } if (mTouchDownOnScroller) { final boolean result = mScrollbar.handleTouchEvent(e, mFastScrollerOffset); Loading @@ -144,6 +143,15 @@ public class WidgetsRecyclerView extends FastScrollRecyclerView implements OnIte } } /** * Detects whether a {@code MotionEvent} is on the scroll bar * @param e The {@code MotionEvent} on the screen * @return {@code true} if the motion is on the scroll bar */ boolean isHitOnScrollBar(MotionEvent e) { return mScrollbar.isHitInParent(e.getX(), e.getY(), mFastScrollerOffset); } @Override public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) { } Loading