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

Commit 2563095d authored by Alan Viverette's avatar Alan Viverette
Browse files

Prevent drag-to-open from cycling pressed state, propagate hotspot

Avoids unnecessary changes to pressed state. Ensures hotspot propagates
to both the list view and the list item view since both receive the
pressed state.

Bug: 19134424
Change-Id: If2496ce2042e43fe1c1efd527eeca10dc53e1f4a
parent d57adbbc
Loading
Loading
Loading
Loading
+19 −6
Original line number Original line Diff line number Diff line
@@ -1648,19 +1648,32 @@ public class ListPopupWindow {
        private void setPressedItem(View child, int position, float x, float y) {
        private void setPressedItem(View child, int position, float x, float y) {
            mDrawsInPressedState = true;
            mDrawsInPressedState = true;


            // Ordering is essential. First update the pressed state and layout
            // Ordering is essential. First, update the container's pressed state.
            // the children. This will ensure the selector actually gets drawn.
            drawableHotspotChanged(x, y);
            if (!isPressed()) {
                setPressed(true);
                setPressed(true);
            }

            // Next, run layout if we need to stabilize child positions.
            if (mDataChanged) {
                layoutChildren();
                layoutChildren();
            }


            // Manage the pressed view based on motion position. This allows us to
            // Manage the pressed view based on motion position. This allows us to
            // play nicely with actual touch and scroll events.
            // play nicely with actual touch and scroll events.
            final View motionView = getChildAt(mMotionPosition - mFirstPosition);
            final View motionView = getChildAt(mMotionPosition - mFirstPosition);
            if (motionView != null) {
            if (motionView != null && motionView != child && motionView.isPressed()) {
                motionView.setPressed(false);
                motionView.setPressed(false);
            }
            }
            mMotionPosition = position;
            mMotionPosition = position;

            // Offset for child coordinates.
            final float childX = x - child.getLeft();
            final float childY = y - child.getTop();
            child.drawableHotspotChanged(childX, childY);
            if (!child.isPressed()) {
                child.setPressed(true);
                child.setPressed(true);
            }


            // Ensure that keyboard focus starts from the last touched position.
            // Ensure that keyboard focus starts from the last touched position.
            setSelectedPositionInt(position);
            setSelectedPositionInt(position);