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

Commit f886946a authored by Matthew Ng's avatar Matthew Ng
Browse files

Reduced down slop and added action for expanding notifications (1/2)

Added an option to select expanding notifications to execute after a
gesture. Exploring swipe down by reducing the touch slope to a smaller
value to execute more. Since it is swiping towards the edge, less events
will be received and typically hard to trigger when swiping other
directions.

Bug: 112934365
Test: manual
Change-Id: I6a854043183d85b43d32633c5fbe88262f473012
parent 7d49735d
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -158,6 +158,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
    private NavigationBackAction mBackAction;
    private QuickSwitchAction mQuickSwitchAction;
    private NavigationAssistantAction mAssistantAction;
    private NavigationNotificationPanelAction mNotificationPanelAction;

    /**
     * Helper that is responsible for showing the right toast when a disallowed activity operation
@@ -374,6 +375,10 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
            mAssistantAction = new NavigationAssistantAction(this, mOverviewProxyService,
                    assistManager);
        }
        if (mNotificationPanelAction == null) {
            mNotificationPanelAction = new NavigationNotificationPanelAction(this,
                    mOverviewProxyService, panel);
        }
        if (mGestureHelper instanceof QuickStepController) {
            ((QuickStepController) mGestureHelper).setComponents(this);
            updateNavigationGestures();
@@ -406,6 +411,8 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
                return mQuickSwitchAction;
            case NavigationPrototypeController.ACTION_ASSISTANT:
                return mAssistantAction;
            case NavigationPrototypeController.ACTION_EXPAND_NOTIFICATION:
                return mNotificationPanelAction;
            case NavigationPrototypeController.ACTION_NOTHING:
                return null;
            default:
+50 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.statusbar.phone;

import android.annotation.NonNull;
import android.view.MotionEvent;

import com.android.systemui.recents.OverviewProxyService;

/**
 * Triggers notification panel to be expanded when executed
 */
public class NavigationNotificationPanelAction extends NavigationGestureAction {
    private final NotificationPanelView mPanelView;

    public NavigationNotificationPanelAction(@NonNull NavigationBarView navigationBarView,
            @NonNull OverviewProxyService service, @NonNull NotificationPanelView panelView) {
        super(navigationBarView, service);
        mPanelView = panelView;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

    @Override
    public boolean disableProxyEvents() {
        return true;
    }

    @Override
    public void onGestureStart(MotionEvent event) {
        mPanelView.expand(true);
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ public class NavigationPrototypeController extends ContentObserver {

    @Retention(RetentionPolicy.SOURCE)
    @IntDef({ACTION_DEFAULT, ACTION_QUICKSTEP, ACTION_QUICKSCRUB, ACTION_BACK,
            ACTION_QUICKSWITCH, ACTION_NOTHING, ACTION_ASSISTANT})
            ACTION_QUICKSWITCH, ACTION_NOTHING, ACTION_ASSISTANT, ACTION_EXPAND_NOTIFICATION})
    @interface GestureAction {}
    static final int ACTION_DEFAULT = 0;
    static final int ACTION_QUICKSTEP = 1;
@@ -50,6 +50,7 @@ public class NavigationPrototypeController extends ContentObserver {
    static final int ACTION_QUICKSWITCH = 4;
    static final int ACTION_NOTHING = 5;
    static final int ACTION_ASSISTANT = 6;
    static final int ACTION_EXPAND_NOTIFICATION = 7;

    private OnPrototypeChangedListener mListener;

+13 −5
Original line number Diff line number Diff line
@@ -281,7 +281,8 @@ public class QuickStepController implements GestureHelper {
                int xDiff = Math.abs(x - mTouchDownX);
                int yDiff = Math.abs(y - mTouchDownY);

                boolean exceededSwipeHorizontalTouchSlop, exceededSwipeVerticalTouchSlop;
                boolean exceededSwipeHorizontalTouchSlop, exceededSwipeVerticalTouchSlop,
                        exceededSwipeVerticalDragSlop;
                int posH, touchDownH, posV, touchDownV;

                if (isNavBarVertical()) {
@@ -289,6 +290,8 @@ public class QuickStepController implements GestureHelper {
                            yDiff > NavigationBarCompat.getQuickScrubTouchSlopPx() && yDiff > xDiff;
                    exceededSwipeVerticalTouchSlop =
                            xDiff > NavigationBarCompat.getQuickStepTouchSlopPx() && xDiff > yDiff;
                    exceededSwipeVerticalDragSlop =
                            xDiff > NavigationBarCompat.getQuickStepDragSlopPx() && xDiff > yDiff;
                    posH = y;
                    touchDownH = mTouchDownY;
                    posV = x;
@@ -298,6 +301,8 @@ public class QuickStepController implements GestureHelper {
                            xDiff > NavigationBarCompat.getQuickScrubTouchSlopPx() && xDiff > yDiff;
                    exceededSwipeVerticalTouchSlop =
                            yDiff > NavigationBarCompat.getQuickStepTouchSlopPx() && yDiff > xDiff;
                    exceededSwipeVerticalDragSlop =
                            yDiff > NavigationBarCompat.getQuickStepDragSlopPx() && yDiff > xDiff;
                    posH = x;
                    touchDownH = mTouchDownX;
                    posV = y;
@@ -309,11 +314,14 @@ public class QuickStepController implements GestureHelper {
                    mCurrentAction.onGestureMove(x, y);
                } else {
                    // Detect gesture and try to execute an action, only one can run at a time
                    if (exceededSwipeVerticalTouchSlop) {
                    if (exceededSwipeVerticalTouchSlop || exceededSwipeVerticalDragSlop) {
                        if (mDragVPositive ? (posV < touchDownV) : (posV > touchDownV)) {
                            // Swipe up gesture must use the larger slop
                            if (exceededSwipeVerticalTouchSlop) {
                                // Swiping up gesture
                                tryToStartGesture(mGestureActions[ACTION_SWIPE_UP_INDEX],
                                        false /* alignedWithNavBar */, event);
                            }
                        } else {
                            // Swiping down gesture
                            tryToStartGesture(mGestureActions[ACTION_SWIPE_DOWN_INDEX],
+31 −0
Original line number Diff line number Diff line
# Copyright (C) 2019 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE := frameworks-base-overlays

LOCAL_REQUIRED_MODULES := \
	ExperimentNavigationBarFloatingOverlay \
	ExperimentNavigationBarDefaultOverlay \
	ExperimentNavigationBarSlimOverlay32 \
	ExperimentNavigationBarSlimOverlay40 \
	ExperimentNavigationBarLargeOverlay56 \
	ExperimentNavigationBarLargeOverlay64 \
	IconShapeSquareOverlay \

include $(BUILD_PHONY_PACKAGE)

include $(call first-makefiles-under,$(LOCAL_PATH))
Loading