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

Commit 323368eb authored by Andy Wickham's avatar Andy Wickham Committed by Android Build Coastguard Worker
Browse files

Allow stashed taskbar to be long pressed.

Bug: 319175012
Test: Manual and unit test
Flag: NA
(see other change)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:caf0c35661f0858fbbd16d1105f18450fc8cf566)
Merged-In: Ic8ac68d21c64a909a1035339d36f9c3b50a8963c
Change-Id: Ic8ac68d21c64a909a1035339d36f9c3b50a8963c
parent 5f635e80
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_N
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Outline;
@@ -37,6 +38,7 @@ import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.Executors;
import com.android.launcher3.util.MultiPropertyFactory;
import com.android.launcher3.util.MultiValueAlpha;
import com.android.quickstep.NavHandle;
import com.android.systemui.shared.navigationbar.RegionSamplingHelper;

import java.io.PrintWriter;
@@ -44,7 +46,8 @@ import java.io.PrintWriter;
/**
 * Handles properties/data collection, then passes the results to our stashed handle View to render.
 */
public class StashedHandleViewController implements TaskbarControllers.LoggableTaskbarController {
public class StashedHandleViewController implements TaskbarControllers.LoggableTaskbarController,
        NavHandle {

    public static final int ALPHA_INDEX_STASHED = 0;
    public static final int ALPHA_INDEX_HOME_DISABLED = 1;
@@ -302,4 +305,24 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT
        pw.println(prefix + "\tmStashedHandleHeight=" + mStashedHandleHeight);
        mRegionSamplingHelper.dump(prefix, pw);
    }

    @Override
    public void animateNavBarLongPress(boolean isTouchDown, boolean shrink, long durationMs) {
        // TODO(b/308693847): Animate similarly to NavigationHandle.java (SysUI).
    }

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

    @Override
    public boolean canNavHandleBeLongPressed() {
        return isStashedHandleVisible();
    }

    @Override
    public int getNavHandleWidth(Context context) {
        return mStashedHandleWidth;
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ import com.android.launcher3.util.TraceHelper;
import com.android.launcher3.util.VibratorWrapper;
import com.android.launcher3.util.ViewCache;
import com.android.launcher3.views.ActivityContext;
import com.android.quickstep.NavHandle;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
import com.android.systemui.shared.recents.model.Task;
@@ -580,6 +581,11 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
        return mControllers.bubbleControllers.orElse(null);
    }

    @NonNull
    public NavHandle getNavHandle() {
        return mControllers.stashedHandleViewController;
    }

    @Override
    public ViewCache getViewCache() {
        return mViewCache;
+54 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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.quickstep;

import android.content.Context;

import com.android.launcher3.R;

/**
 * Control and get information about the gesture nav bar at the bottom of the screen, which has
 * historically been drawn by SysUI, but is also emulated by the stashed Taskbar on large screens.
 */
public interface NavHandle {

    /**
     * Animate the nav bar being long-pressed.
     *
     * @param isTouchDown {@code true} if the button is starting to be pressed ({@code false} if
     *                                released or canceled)
     * @param shrink {@code true} if the handle should shrink, {@code false} if it should grow
     * @param durationMs how long the animation should take (for the {@code isTouchDown} case, this
     *                   should be the same as the amount of time to trigger a long-press)
     */
    void animateNavBarLongPress(boolean isTouchDown, boolean shrink, long durationMs);

    /** @return {@code true} if this nav handle is actually the stashed taskbar */
    default boolean isNavHandleStashedTaskbar() {
        return false;
    }

    /** @return {@code true} if this nav handle can currently accept long presses */
    default boolean canNavHandleBeLongPressed() {
        return true;
    }

    /** @return the width of this nav handle, in pixels */
    default int getNavHandleWidth(Context context) {
        return context.getResources().getDimensionPixelSize(R.dimen.navigation_home_handle_width);
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ import java.util.List;
/**
 * Holds the reference to SystemUI.
 */
public class SystemUiProxy implements ISystemUiProxy {
public class SystemUiProxy implements ISystemUiProxy, NavHandle {
    private static final String TAG = SystemUiProxy.class.getSimpleName();

    public static final MainThreadInitializedObject<SystemUiProxy> INSTANCE =
+12 −4
Original line number Diff line number Diff line
@@ -986,14 +986,22 @@ public class TouchInteractionService extends Service {
                    base = new TaskbarUnstashInputConsumer(this, base, mInputMonitorCompat, tac,
                            mOverviewCommandHelper);
                }
            } else if (canStartSystemGesture && !previousGestureState.isRecentsAnimationRunning()) {
            }

            NavHandle navHandle = tac != null ? tac.getNavHandle()
                    : SystemUiProxy.INSTANCE.get(this);
            if (canStartSystemGesture && !previousGestureState.isRecentsAnimationRunning()
                    && navHandle.canNavHandleBeLongPressed()) {
                reasonString.append(NEWLINE_PREFIX)
                        .append(reasonPrefix)
                        .append(SUBSTRING_PREFIX)
                        .append("Not running recents animation, ")
                        .append("using NavHandleLongPressInputConsumer");
                        .append("Not running recents animation, ");
                if (tac != null && tac.getNavHandle().canNavHandleBeLongPressed()) {
                    reasonString.append("stashed handle is long-pressable, ");
                }
                reasonString.append("using NavHandleLongPressInputConsumer");
                base = new NavHandleLongPressInputConsumer(this, base, mInputMonitorCompat,
                        mDeviceState);
                        mDeviceState, navHandle);
            }

            if (mDeviceState.isBubblesExpanded()) {
Loading