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

Commit 0548fbc2 authored by Matthew Ng's avatar Matthew Ng
Browse files

Added assistant as an action for possible gestures

Also matched launcher with the stabilization flag only used for the new
quick step swiped right to left and vice versa.

Bug: 112934365
Test: atest QuickStepControllerTest
Change-Id: Ia6801f96e60c8764448bca6667b93846ef637318
parent b8c30bbf
Loading
Loading
Loading
Loading
+49 −0
Original line number Original line 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.os.Bundle;
import android.view.MotionEvent;

import com.android.systemui.assist.AssistManager;
import com.android.systemui.recents.OverviewProxyService;

/**
 * Assistant is triggered with this action
 */
public class NavigationAssistantAction extends NavigationGestureAction {
    private static final String TAG = "NavigationAssistantActions";

    private final AssistManager mAssistManager;

    public NavigationAssistantAction(@NonNull NavigationBarView navigationBarView,
            @NonNull OverviewProxyService service, AssistManager assistManager) {
        super(navigationBarView, service);
        mAssistManager = assistManager;
    }

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

    @Override
    public void onGestureStart(MotionEvent event) {
        mAssistManager.startAssist(new Bundle());
    }
}
+2 −3
Original line number Original line Diff line number Diff line
@@ -67,7 +67,7 @@ public class NavigationBackAction extends NavigationGestureAction {


    @Override
    @Override
    public boolean isEnabled() {
    public boolean isEnabled() {
        return !getGlobalBoolean(NavigationPrototypeController.NAVBAR_EXPERIMENTS_DISABLED);
        return true;
    }
    }


    @Override
    @Override
@@ -102,8 +102,7 @@ public class NavigationBackAction extends NavigationGestureAction {
    }
    }


    private boolean shouldExecuteBackOnUp() {
    private boolean shouldExecuteBackOnUp() {
        return !getGlobalBoolean(NavigationPrototypeController.NAVBAR_EXPERIMENTS_DISABLED)
        return getGlobalBoolean(BACK_AFTER_END_PROP);
                && getGlobalBoolean(BACK_AFTER_END_PROP);
    }
    }


    private void sendEvent(int action, int code) {
    private void sendEvent(int action, int code) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -254,7 +254,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
            mIsOnDefaultDisplay = display.getDisplayId() == Display.DEFAULT_DISPLAY;
            mIsOnDefaultDisplay = display.getDisplayId() == Display.DEFAULT_DISPLAY;
        }
        }


        mNavigationBarView.setComponents(mStatusBar.getPanel());
        mNavigationBarView.setComponents(mStatusBar.getPanel(), mAssistManager);
        mNavigationBarView.setDisabledFlags(mDisabledFlags1);
        mNavigationBarView.setDisabledFlags(mDisabledFlags1);
        mNavigationBarView.setOnVerticalChangedListener(this::onVerticalChanged);
        mNavigationBarView.setOnVerticalChangedListener(this::onVerticalChanged);
        mNavigationBarView.setOnTouchListener(this::onNavigationTouch);
        mNavigationBarView.setOnTouchListener(this::onNavigationTouch);
+11 −1
Original line number Original line Diff line number Diff line
@@ -69,6 +69,7 @@ import com.android.systemui.DockedStackExistsListener;
import com.android.systemui.Interpolators;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.R;
import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.plugins.PluginListener;
import com.android.systemui.plugins.PluginListener;
import com.android.systemui.plugins.statusbar.phone.NavGesture;
import com.android.systemui.plugins.statusbar.phone.NavGesture;
import com.android.systemui.plugins.statusbar.phone.NavGesture.GestureHelper;
import com.android.systemui.plugins.statusbar.phone.NavGesture.GestureHelper;
@@ -156,6 +157,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
    private QuickStepAction mQuickStepAction;
    private QuickStepAction mQuickStepAction;
    private NavigationBackAction mBackAction;
    private NavigationBackAction mBackAction;
    private QuickSwitchAction mQuickSwitchAction;
    private QuickSwitchAction mQuickSwitchAction;
    private NavigationAssistantAction mAssistantAction;


    /**
    /**
     * Helper that is responsible for showing the right toast when a disallowed activity operation
     * Helper that is responsible for showing the right toast when a disallowed activity operation
@@ -366,8 +368,12 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
        return mBarTransitions.getLightTransitionsController();
        return mBarTransitions.getLightTransitionsController();
    }
    }


    public void setComponents(NotificationPanelView panel) {
    public void setComponents(NotificationPanelView panel, AssistManager assistManager) {
        mPanelView = panel;
        mPanelView = panel;
        if (mAssistantAction == null) {
            mAssistantAction = new NavigationAssistantAction(this, mOverviewProxyService,
                    assistManager);
        }
        if (mGestureHelper instanceof QuickStepController) {
        if (mGestureHelper instanceof QuickStepController) {
            ((QuickStepController) mGestureHelper).setComponents(this);
            ((QuickStepController) mGestureHelper).setComponents(this);
            updateNavigationGestures();
            updateNavigationGestures();
@@ -398,6 +404,10 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
                return mBackAction;
                return mBackAction;
            case NavigationPrototypeController.ACTION_QUICKSWITCH:
            case NavigationPrototypeController.ACTION_QUICKSWITCH:
                return mQuickSwitchAction;
                return mQuickSwitchAction;
            case NavigationPrototypeController.ACTION_ASSISTANT:
                return mAssistantAction;
            case NavigationPrototypeController.ACTION_NOTHING:
                return null;
            default:
            default:
                return defaultAction;
                return defaultAction;
        }
        }
+23 −0
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@ import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.content.Context;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Canvas;
import android.provider.Settings;
import android.view.MotionEvent;
import android.view.MotionEvent;


import com.android.systemui.recents.OverviewProxyService;
import com.android.systemui.recents.OverviewProxyService;
@@ -32,6 +33,9 @@ import com.android.systemui.recents.OverviewProxyService;
 * A gesture action that would be triggered and reassigned by {@link QuickStepController}
 * A gesture action that would be triggered and reassigned by {@link QuickStepController}
 */
 */
public abstract class NavigationGestureAction {
public abstract class NavigationGestureAction {
    private static final String ENABLE_TASK_STABILIZER_FLAG = "ENABLE_TASK_STABILIZER";

    static private boolean sLastTaskStabilizationFlag;


    protected final NavigationBarView mNavigationBarView;
    protected final NavigationBarView mNavigationBarView;
    protected final OverviewProxyService mProxySender;
    protected final OverviewProxyService mProxySender;
@@ -45,6 +49,9 @@ public abstract class NavigationGestureAction {
            @NonNull OverviewProxyService service) {
            @NonNull OverviewProxyService service) {
        mNavigationBarView = navigationBarView;
        mNavigationBarView = navigationBarView;
        mProxySender = service;
        mProxySender = service;
        sLastTaskStabilizationFlag = Settings.Global.getInt(
                mNavigationBarView.getContext().getContentResolver(),
                ENABLE_TASK_STABILIZER_FLAG, 0) != 0;
    }
    }


    /**
    /**
@@ -74,6 +81,15 @@ public abstract class NavigationGestureAction {
     */
     */
    public void startGesture(MotionEvent event) {
    public void startGesture(MotionEvent event) {
        mIsActive = true;
        mIsActive = true;

        // Tell launcher that this action requires a stable task list or not
        boolean flag = requiresStableTaskList();
        if (flag != sLastTaskStabilizationFlag) {
            Settings.Global.putInt(mNavigationBarView.getContext().getContentResolver(),
                    ENABLE_TASK_STABILIZER_FLAG, flag ? 1 : 0);
            sLastTaskStabilizationFlag = flag;
        }

        onGestureStart(event);
        onGestureStart(event);
    }
    }


@@ -146,6 +162,13 @@ public abstract class NavigationGestureAction {
     */
     */
    public abstract boolean isEnabled();
    public abstract boolean isEnabled();


    /**
     * @return action requires a stable task list from launcher
     */
    protected boolean requiresStableTaskList() {
        return false;
    }

    protected void onDarkIntensityChange(float intensity) {
    protected void onDarkIntensityChange(float intensity) {
    }
    }


Loading