diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-03-15 17:37:13 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-03-15 17:37:13 +0000 |
commit | ade58b82a37e72490c4a69992403323fed2801ea (patch) | |
tree | f09e632472692a763fa268523606ac589db10e00 | |
parent | 5f635e80fe09cb39edbb5557461287e12f3fbefc (diff) | |
parent | 323368eb4fc9b4dd045e39f4e8cf5e69baa487e8 (diff) | |
download | Launcher3-android-14.0.0_r32.tar.gz |
Merge cherrypicks of ['googleplex-android-review.googlesource.com/25834525'] into sparse-11480754-L62600030002545018.android-14.0.0_r32android-14.0.0_r31android14-qpr2-s2-release
SPARSE_CHANGE: Ic8ac68d21c64a909a1035339d36f9c3b50a8963c
Change-Id: I3f0b066c5301ace78e9a179d130eaa9e2c60e334
8 files changed, 137 insertions, 21 deletions
diff --git a/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java b/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java index 7c30111c1f..6b5b9f132f 100644 --- a/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java @@ -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; + } } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 4290948ad2..f9d92a6490 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -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; diff --git a/quickstep/src/com/android/quickstep/NavHandle.java b/quickstep/src/com/android/quickstep/NavHandle.java new file mode 100644 index 0000000000..da3311f475 --- /dev/null +++ b/quickstep/src/com/android/quickstep/NavHandle.java @@ -0,0 +1,54 @@ +/* + * 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); + } +} diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java index a8c680958f..723af43468 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.java +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java @@ -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 = diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java index bd4625b7f7..aa55e67ca6 100644 --- a/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -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()) { diff --git a/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressHandler.java b/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressHandler.java index 4d47f07b04..1d00e533f5 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressHandler.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressHandler.java @@ -22,6 +22,7 @@ import androidx.annotation.Nullable; import com.android.launcher3.R; import com.android.launcher3.util.ResourceBasedOverride; +import com.android.quickstep.NavHandle; /** * Class for extending nav handle long press behavior @@ -42,19 +43,26 @@ public class NavHandleLongPressHandler implements ResourceBasedOverride { * A Runnable is returned here to ensure the InputConsumer can call * {@link android.view.InputMonitor#pilferPointers()} before invoking the long press behavior * since pilfering can break the long press behavior. + * + * @param navHandle to handle this long press */ - public @Nullable Runnable getLongPressRunnable() { + public @Nullable Runnable getLongPressRunnable(NavHandle navHandle) { return null; } /** * Called when nav handle gesture starts. + * + * @param navHandle to handle the animation for this touch */ - public void onTouchStarted() {} + public void onTouchStarted(NavHandle navHandle) {} /** * Called when nav handle gesture is finished by the user lifting their finger or the system * cancelling the touch for some other reason. + * + * @param navHandle to handle the animation for this touch + * @param reason why the touch ended */ - public void onTouchFinished(String reason) {} + public void onTouchFinished(NavHandle navHandle, String reason) {} } diff --git a/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java index 0a558e2a98..4c0b55088e 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java @@ -17,7 +17,9 @@ package com.android.quickstep.inputconsumers; import static com.android.launcher3.LauncherPrefs.LONG_PRESS_NAV_HANDLE_TIMEOUT_MS; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_DEEP_PRESS_NAVBAR; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_DEEP_PRESS_STASHED_TASKBAR; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_LONG_PRESS_NAVBAR; +import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_LONG_PRESS_STASHED_TASKBAR; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import android.content.Context; @@ -25,11 +27,11 @@ import android.view.MotionEvent; import android.view.ViewConfiguration; import com.android.launcher3.LauncherPrefs; -import com.android.launcher3.R; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.logging.StatsLogManager; import com.android.launcher3.util.DisplayController; import com.android.quickstep.InputConsumer; +import com.android.quickstep.NavHandle; import com.android.quickstep.RecentsAnimationDeviceState; import com.android.quickstep.TopTaskTracker; import com.android.systemui.shared.system.InputMonitorCompat; @@ -47,6 +49,7 @@ public class NavHandleLongPressInputConsumer extends DelegateInputConsumer { private final float mTouchSlopSquared; private final int mLongPressTimeout; private final boolean mDeepPressEnabled; + private final NavHandle mNavHandle; private final StatsLogManager mStatsLogManager; private final TopTaskTracker mTopTaskTracker; @@ -54,10 +57,9 @@ public class NavHandleLongPressInputConsumer extends DelegateInputConsumer { private boolean mDeepPressLogged; // Whether deep press has been logged for the current touch. public NavHandleLongPressInputConsumer(Context context, InputConsumer delegate, - InputMonitorCompat inputMonitor, RecentsAnimationDeviceState deviceState) { + InputMonitorCompat inputMonitor, RecentsAnimationDeviceState deviceState, + NavHandle navHandle) { super(delegate, inputMonitor); - mNavHandleWidth = context.getResources().getDimensionPixelSize( - R.dimen.navigation_home_handle_width); mScreenWidth = DisplayController.INSTANCE.get(context).getInfo().currentSize.x; mDeepPressEnabled = FeatureFlags.ENABLE_LPNH_DEEP_PRESS.get(); if (FeatureFlags.CUSTOM_LPNH_THRESHOLDS.get()) { @@ -66,6 +68,8 @@ public class NavHandleLongPressInputConsumer extends DelegateInputConsumer { mLongPressTimeout = ViewConfiguration.getLongPressTimeout(); } mTouchSlopSquared = deviceState.getSquaredTouchSlop(); + mNavHandle = navHandle; + mNavHandleWidth = navHandle.getNavHandleWidth(context); mNavHandleLongPressHandler = NavHandleLongPressHandler.newInstance(context); mStatsLogManager = StatsLogManager.newInstance(context); mTopTaskTracker = TopTaskTracker.INSTANCE.get(context); @@ -89,6 +93,11 @@ public class NavHandleLongPressInputConsumer extends DelegateInputConsumer { } } + @Override + public void onHoverEvent(MotionEvent ev) { + mDelegate.onHoverEvent(ev); + } + private void handleMotionEvent(MotionEvent ev) { switch (ev.getAction()) { case MotionEvent.ACTION_DOWN -> { @@ -98,9 +107,8 @@ public class NavHandleLongPressInputConsumer extends DelegateInputConsumer { mCurrentDownEvent = MotionEvent.obtain(ev); mDeepPressLogged = false; if (isInNavBarHorizontalArea(ev.getRawX())) { - mNavHandleLongPressHandler.onTouchStarted(); - MAIN_EXECUTOR.getHandler().postDelayed(mTriggerLongPress, - mLongPressTimeout); + mNavHandleLongPressHandler.onTouchStarted(mNavHandle); + MAIN_EXECUTOR.getHandler().postDelayed(mTriggerLongPress, mLongPressTimeout); } } case MotionEvent.ACTION_MOVE -> { @@ -127,8 +135,9 @@ public class NavHandleLongPressInputConsumer extends DelegateInputConsumer { // Log deep press even if feature is disabled. String runningPackage = mTopTaskTracker.getCachedTopTask( /* filterOnlyVisibleRecents */ true).getPackageName(); - mStatsLogManager.logger().withPackageName(runningPackage) - .log(LAUNCHER_DEEP_PRESS_NAVBAR); + mStatsLogManager.logger().withPackageName(runningPackage).log( + mNavHandle.isNavHandleStashedTaskbar() ? LAUNCHER_DEEP_PRESS_STASHED_TASKBAR + : LAUNCHER_DEEP_PRESS_NAVBAR); mDeepPressLogged = true; // But only trigger if the feature is enabled. @@ -142,9 +151,11 @@ public class NavHandleLongPressInputConsumer extends DelegateInputConsumer { private void triggerLongPress() { String runningPackage = mTopTaskTracker.getCachedTopTask( /* filterOnlyVisibleRecents */ true).getPackageName(); - mStatsLogManager.logger().withPackageName(runningPackage).log(LAUNCHER_LONG_PRESS_NAVBAR); + mStatsLogManager.logger().withPackageName(runningPackage).log( + mNavHandle.isNavHandleStashedTaskbar() ? LAUNCHER_LONG_PRESS_STASHED_TASKBAR + : LAUNCHER_LONG_PRESS_NAVBAR); - Runnable longPressRunnable = mNavHandleLongPressHandler.getLongPressRunnable(); + Runnable longPressRunnable = mNavHandleLongPressHandler.getLongPressRunnable(mNavHandle); if (longPressRunnable == null) { return; } @@ -161,7 +172,7 @@ public class NavHandleLongPressInputConsumer extends DelegateInputConsumer { private void cancelLongPress(String reason) { MAIN_EXECUTOR.getHandler().removeCallbacks(mTriggerLongPress); - mNavHandleLongPressHandler.onTouchFinished(reason); + mNavHandleLongPressHandler.onTouchFinished(mNavHandle, reason); } private boolean isInNavBarHorizontalArea(float x) { diff --git a/src/com/android/launcher3/logging/StatsLogManager.java b/src/com/android/launcher3/logging/StatsLogManager.java index d8388c2709..5fa2d57868 100644 --- a/src/com/android/launcher3/logging/StatsLogManager.java +++ b/src/com/android/launcher3/logging/StatsLogManager.java @@ -281,6 +281,12 @@ public class StatsLogManager implements ResourceBasedOverride { @UiEvent(doc = "User long presses on the bottom bezel area.") LAUNCHER_LONG_PRESS_NAVBAR(1544), + @UiEvent(doc = "User deep presses on the stashed taskbar") + LAUNCHER_DEEP_PRESS_STASHED_TASKBAR(1602), + + @UiEvent(doc = "User long presses on the stashed taskbar") + LAUNCHER_LONG_PRESS_STASHED_TASKBAR(1592), + @UiEvent(doc = "User swipes or fling in UP direction from bottom bazel area.") LAUNCHER_HOME_GESTURE(574), |