Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d361a4f9 authored by Alan Viverette's avatar Alan Viverette
Browse files

Use touch hotspot in drag-to-open, fix forwarding cancellation

BUG: 14230395
Change-Id: Ibea615bcd6a2e57fca8b49ffea23f0df951d497c
parent 0923be20
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -2494,6 +2494,17 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
        }
    }

    /**
     * Positions the selector in a way that mimics touch.
     */
    void positionSelectorLikeTouch(int position, View sel, float x, float y) {
        positionSelectorLikeFocus(position, sel);

        if (mSelector != null && position != INVALID_POSITION) {
            mSelector.setHotspot(x, y);
        }
    }

    /**
     * Positions the selector in a way that mimics keyboard focus.
     */
+2 −1
Original line number Diff line number Diff line
@@ -668,7 +668,8 @@ public class ActionMenuPresenter extends BaseMenuPresenter
        private SubMenuBuilder mSubMenu;

        public ActionButtonSubmenu(Context context, SubMenuBuilder subMenu) {
            super(context, subMenu);
            super(context, subMenu, null, false,
                    com.android.internal.R.attr.actionOverflowMenuStyle);
            mSubMenu = subMenu;

            MenuItemImpl item = (MenuItemImpl) subMenu.getItem();
+10 −4
Original line number Diff line number Diff line
@@ -1363,7 +1363,13 @@ public class ListPopupWindow {
            // Forward converted event to destination view, then recycle it.
            final boolean handled = dst.onForwardedEvent(dstEvent, mActivePointerId);
            dstEvent.recycle();
            return handled;

            // Always cancel forwarding when the touch stream ends.
            final int action = srcEvent.getActionMasked();
            final boolean keepForwarding = action != MotionEvent.ACTION_UP
                    && action != MotionEvent.ACTION_CANCEL;

            return handled && keepForwarding;
        }

        private class DisallowIntercept implements Runnable {
@@ -1492,7 +1498,7 @@ public class ListPopupWindow {
                    }

                    final View child = getChildAt(position - getFirstVisiblePosition());
                    setPressedItem(child, position);
                    setPressedItem(child, position, x, y);
                    handledEvent = true;

                    if (actionMasked == MotionEvent.ACTION_UP) {
@@ -1555,7 +1561,7 @@ public class ListPopupWindow {
            }
        }

        private void setPressedItem(View child, int position) {
        private void setPressedItem(View child, int position, float x, float y) {
            mDrawsInPressedState = true;

            // Ordering is essential. First update the pressed state and layout
@@ -1565,7 +1571,7 @@ public class ListPopupWindow {

            // Ensure that keyboard focus starts from the last touched position.
            setSelectedPositionInt(position);
            positionSelectorLikeFocus(position, child);
            positionSelectorLikeTouch(position, child, x, y);

            // Refresh the drawable state to reflect the new pressed state,
            // which will also update the selector state.