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

Commit c7a252d5 authored by András Kurucz's avatar András Kurucz
Browse files

[Flexiglass] Don't expand the shade by dragging on a notification over lockscreen

The motion to expand a notification over the lockscreen changes with
flexiglass. The drag will only expand the notification first (as opposed
to control the shade expansion), and if the user has dragged far enough,
it will expand the shade when the gesture is finalized.

This CL achieves this by NOT setting NSSL#mIsBeingDragged to true, from
a gesture that is expanding a notification over the lockscreen.

Bug: 359957196
Test: Drag down on a Notification on the LS -> verify that
       - the shade is NOT expanding during the gesture
       - touches during the gesture are not dispatched to the scene framework
       - if dragged far enough, finishing the gesture opens the shade
       - if not dragged far enough, finishing the gesture collapses the
	 notification back to its original lockscreen height
Flag: com.android.systemui.scene_container

Change-Id: Ifc669f4ad1318d758ef7e3d9899c6a8a697ae7fa
parent 70057436
Loading
Loading
Loading
Loading
+50 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import static com.android.systemui.statusbar.StatusBarState.SHADE;
import static com.android.systemui.statusbar.notification.row.NotificationRowContentBinder.FLAG_CONTENT_VIEW_ALL;
import static com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout.ROWS_ALL;

import static com.google.common.truth.Truth.assertThat;

import static kotlinx.coroutines.flow.FlowKt.emptyFlow;

import static org.mockito.ArgumentMatchers.any;
@@ -766,6 +768,54 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase {
        ));
    }

    @Test
    @EnableSceneContainer
    public void onTouchEvent_lockScreenExpandSwallowsIt() {
        initController(/* viewIsAttached= */ true);
        when(mNotificationStackScrollLayout.getExpandHelper()).thenReturn(mExpandHelper);
        when(mNotificationStackScrollLayout.isExpanded()).thenReturn(true);
        NotificationStackScrollLayoutController.TouchHandler touchHandler =
                mController.getTouchHandler();

        MotionEvent event = MotionEvent.obtain(
                /* downTime= */ 0,
                /* eventTime= */ 0,
                MotionEvent.ACTION_DOWN,
                0,
                0,
                /* metaState= */ 0
        );
        when(mDragDownHelper.onTouchEvent(event)).thenReturn(true);
        boolean touchHandled = touchHandler.onTouchEvent(event);

        assertThat(touchHandled).isTrue();
        verify(mNotificationStackScrollLayout, never()).onScrollTouch(any());
    }

    @Test
    @EnableSceneContainer
    public void onInterceptTouchEvent_lockScreenExpandSwallowsIt() {
        initController(/* viewIsAttached= */ true);
        when(mNotificationStackScrollLayout.getExpandHelper()).thenReturn(mExpandHelper);
        when(mNotificationStackScrollLayout.isExpanded()).thenReturn(true);
        NotificationStackScrollLayoutController.TouchHandler touchHandler =
                mController.getTouchHandler();

        MotionEvent event = MotionEvent.obtain(
                /* downTime= */ 0,
                /* eventTime= */ 0,
                MotionEvent.ACTION_DOWN,
                0,
                0,
                /* metaState= */ 0
        );
        when(mDragDownHelper.onInterceptTouchEvent(event)).thenReturn(true);
        boolean touchIntercepted = touchHandler.onInterceptTouchEvent(event);

        assertThat(touchIntercepted).isTrue();
        verify(mNotificationStackScrollLayout, never()).onInterceptTouchEventScroll(event);
    }

    private LogMaker logMatcher(int category, int type) {
        return argThat(new LogMatcher(category, type));
    }
+17 −11
Original line number Diff line number Diff line
@@ -2079,16 +2079,19 @@ public class NotificationStackScrollLayoutController implements Dumpable {
                    && !mView.getOnlyScrollingInThisMotion() && guts == null && !skipForDragging) {
                expandWantsIt = mView.getExpandHelper().onInterceptTouchEvent(ev);
            }
            boolean scrollWantsIt = false;
            if (mLongPressedView == null && !mSwipeHelper.isSwiping()
                    && !mView.isExpandingNotification() && !skipForDragging) {
                scrollWantsIt = mView.onInterceptTouchEventScroll(ev);
            }
            boolean lockscreenExpandWantsIt = false;
            if (shouldLockscreenExpandHandleTouch()) {
                lockscreenExpandWantsIt =
                        getLockscreenExpandTouchHelper().onInterceptTouchEvent(ev);
            }
            boolean scrollWantsIt = false;
            if (mLongPressedView == null
                    && !mSwipeHelper.isSwiping() // horizontal swipe to dismiss
                    && !mView.isExpandingNotification() // vertical swipe to expand
                    && !lockscreenExpandWantsIt // vertical swipe to expand over lockscreen
                    && !skipForDragging) {
                scrollWantsIt = mView.onInterceptTouchEventScroll(ev);
            }
            boolean hunWantsIt = false;
            if (shouldHeadsUpHandleTouch()) {
                hunWantsIt = mHeadsUpTouchHelper.onInterceptTouchEvent(ev);
@@ -2097,6 +2100,7 @@ public class NotificationStackScrollLayoutController implements Dumpable {
            if (mLongPressedView == null && !mView.isBeingDragged()
                    && !mView.isExpandingNotification()
                    && !mView.getExpandedInThisMotion()
                    && !lockscreenExpandWantsIt
                    && !mView.getOnlyScrollingInThisMotion()
                    && !mView.getDisallowDismissInThisMotion()
                    && !skipForDragging) {
@@ -2160,26 +2164,28 @@ public class NotificationStackScrollLayoutController implements Dumpable {
                    }
                }
            }
            // true when a notification is being dragged to expand over the lockscreen
            boolean lockscreenExpandWantsIt = false;
            if (shouldLockscreenExpandHandleTouch()) {
                lockscreenExpandWantsIt = getLockscreenExpandTouchHelper().onTouchEvent(ev);
            }
            boolean horizontalSwipeWantsIt = false;
            boolean scrollerWantsIt = false;
            // NOTE: the order of these is important. If reversed, onScrollTouch will reset on an
            // UP event, causing horizontalSwipeWantsIt to be set to true on vertical swipes.
            if (mLongPressedView == null && !mView.isBeingDragged()
                    && !expandingNotification
                    && !lockscreenExpandWantsIt
                    && !mView.getExpandedInThisMotion()
                    && !onlyScrollingInThisMotion
                    && !mView.getDisallowDismissInThisMotion()) {
                horizontalSwipeWantsIt = mSwipeHelper.onTouchEvent(ev);
            }
            if (mLongPressedView == null && mView.isExpanded() && !mSwipeHelper.isSwiping()
                    && !expandingNotification && !mView.getDisallowScrollingInThisMotion()) {
                    && !expandingNotification && !lockscreenExpandWantsIt
                    && !mView.getDisallowScrollingInThisMotion()) {
                scrollerWantsIt = mView.onScrollTouch(ev);
            }
            boolean lockscreenExpandWantsIt = false;
            if (shouldLockscreenExpandHandleTouch()) {
                lockscreenExpandWantsIt =
                        getLockscreenExpandTouchHelper().onTouchEvent(ev);
            }
            boolean hunWantsIt = false;
            if (shouldHeadsUpHandleTouch()) {
                hunWantsIt = mHeadsUpTouchHelper.onTouchEvent(ev);