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

Commit 7bbcd229 authored by 0's avatar 0
Browse files

[flexiglass] Handle HUN touch when touches are dispatched to NSSL

In flexiglass, we need HeadsUpTouchHelper to correctly handle HUN gestures when the HUN doesn't have an onClick and the gesture gets distpached to NSSL.

Bug: 371235563
Test: Manually verified dragging on HUN to expand shade works with both clickable and non-clickable HUNs
Test: ExpandShadeFromHun e2e test passes with both flexiglass on and off
Flag: com.android.systemui.scene_container
Change-Id: If25b4d3c2e6be1bbd0f8581f480915f9f6cfb667
parent 5bc4afb9
Loading
Loading
Loading
Loading
+74 −21
Original line number Diff line number Diff line
@@ -115,6 +115,7 @@ public class HeadsUpTouchHelper implements Gefingerpoken {
                final float h = y - mInitialTouchY;
                if (mTouchingHeadsUpView && Math.abs(h) > mTouchSlop
                        && Math.abs(h) > Math.abs(x - mInitialTouchX)) {
                    if (!SceneContainerFlag.isEnabled()) {
                        setTrackingHeadsUp(true);
                        mCollapseSnoozes = h < 0;
                        mInitialTouchX = x;
@@ -124,14 +125,13 @@ public class HeadsUpTouchHelper implements Gefingerpoken {
                        mPanel.setHeadsUpDraggingStartingHeight(startHeight);
                        mPanel.startExpand(x, y, true /* startTracking */, startHeight);

                    if (!SceneContainerFlag.isEnabled()) {
                        // This call needs to be after the expansion start otherwise we will get a
                        // flicker of one frame as it's not expanded yet.
                        mHeadsUpManager.unpinAll(true);
                    }

                        clearNotificationEffects();
                        endMotion();
                    }
                    return true;
                }
                break;
@@ -167,6 +167,58 @@ public class HeadsUpTouchHelper implements Gefingerpoken {

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (SceneContainerFlag.isEnabled()) {
            int pointerIndex = event.findPointerIndex(mTrackingPointer);
            if (pointerIndex < 0) {
                pointerIndex = 0;
                mTrackingPointer = event.getPointerId(pointerIndex);
            }
            final float x = event.getX(pointerIndex);
            final float y = event.getY(pointerIndex);
            switch (event.getActionMasked()) {
                case MotionEvent.ACTION_POINTER_UP:
                    final int upPointer = event.getPointerId(event.getActionIndex());
                    if (mTrackingPointer == upPointer) {
                        // gesture is ongoing, find a new pointer to track
                        final int newIndex = event.getPointerId(0) != upPointer ? 0 : 1;
                        mTrackingPointer = event.getPointerId(newIndex);
                        mInitialTouchX = event.getX(newIndex);
                        mInitialTouchY = event.getY(newIndex);
                    }
                    break;
                case MotionEvent.ACTION_MOVE:
                    final float h = y - mInitialTouchY;
                    if (mTouchingHeadsUpView && Math.abs(h) > mTouchSlop
                            && Math.abs(h) > Math.abs(x - mInitialTouchX)) {
                        setTrackingHeadsUp(true);
                        mCollapseSnoozes = h < 0;
                        mInitialTouchX = x;
                        mInitialTouchY = y;
                        int startHeight = (int) (mPickedChild.getActualHeight()
                                + mPickedChild.getTranslationY());
                        mPanel.setHeadsUpDraggingStartingHeight(startHeight);
                        mPanel.startExpand(x, y, true /* startTracking */, startHeight);

                        clearNotificationEffects();
                        endMotion();
                        return true;
                    }
                    break;
                case MotionEvent.ACTION_CANCEL:
                case MotionEvent.ACTION_UP:
                    if (mPickedChild != null && mTouchingHeadsUpView) {
                        // We may swallow this click if the heads up just came in.
                        if (mHeadsUpManager.shouldSwallowClick(
                                mPickedChild.getEntry().getSbn().getKey())) {
                            endMotion();
                            return true;
                        }
                    }
                    endMotion();
                    return false;
            }
            return false;
        } else {
            if (!mTrackingHeadsUp) {
                return false;
            }
@@ -179,6 +231,7 @@ public class HeadsUpTouchHelper implements Gefingerpoken {
            }
            return true;
        }
    }

    private void endMotion() {
        mTrackingPointer = -1;
+3 −3
Original line number Diff line number Diff line
@@ -2122,9 +2122,6 @@ public class NotificationStackScrollLayoutController implements Dumpable {
            boolean hunWantsIt = false;
            if (shouldHeadsUpHandleTouch()) {
                hunWantsIt = mHeadsUpTouchHelper.onInterceptTouchEvent(ev);
                if (hunWantsIt) {
                    mView.startDraggingOnHun();
                }
            }
            boolean swipeWantsIt = false;
            if (mLongPressedView == null && !mView.isBeingDragged()
@@ -2210,6 +2207,9 @@ public class NotificationStackScrollLayoutController implements Dumpable {
            boolean hunWantsIt = false;
            if (shouldHeadsUpHandleTouch()) {
                hunWantsIt = mHeadsUpTouchHelper.onTouchEvent(ev);
                if (hunWantsIt) {
                    mView.startDraggingOnHun();
                }
            }

            // Check if we need to clear any snooze leavebehinds