mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
Remove ENABLE_TRANSIENT_TASKBAR and long-press stash support
Flag: NA Test: manual, TaplTestsTaskbar, TaplTestsPersistent, TaplTestsTransient Fixes: 270395798 Change-Id: I4ecf5ddcd1206e846538175c684043c5e065fd5d
This commit is contained in:
@@ -1141,15 +1141,6 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
return mControllers.taskbarStashController.isStashed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when we detect a long press in the nav region before passing the gesture slop.
|
||||
*
|
||||
* @return Whether taskbar handled the long press, and thus should cancel the gesture.
|
||||
*/
|
||||
public boolean onLongPressToUnstashTaskbar() {
|
||||
return mControllers.taskbarStashController.onLongPressToUnstashTaskbar();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when we want to unstash taskbar when user performs swipes up gesture.
|
||||
*/
|
||||
@@ -1205,28 +1196,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
* @param animateForward Whether to animate towards the unstashed hint state or back to stashed.
|
||||
*/
|
||||
public void startTaskbarUnstashHint(boolean animateForward) {
|
||||
// TODO(b/270395798): Clean up forceUnstash after removing long-press unstashing code.
|
||||
startTaskbarUnstashHint(animateForward, /* forceUnstash = */ false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when we detect a motion down or up/cancel in the nav region while stashed.
|
||||
*
|
||||
* @param animateForward Whether to animate towards the unstashed hint state or back to stashed.
|
||||
* @param forceUnstash Whether we force the unstash hint.
|
||||
*/
|
||||
public void startTaskbarUnstashHint(boolean animateForward, boolean forceUnstash) {
|
||||
// TODO(b/270395798): Clean up forceUnstash after removing long-press unstashing code.
|
||||
mControllers.taskbarStashController.startUnstashHint(animateForward, forceUnstash);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables manual taskbar stashing. This method should only be used for tests that need to
|
||||
* stash/unstash the taskbar.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public void enableManualStashingDuringTests(boolean enableManualStashing) {
|
||||
mControllers.taskbarStashController.enableManualStashingDuringTests(enableManualStashing);
|
||||
mControllers.taskbarStashController.startUnstashHint(animateForward);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1239,15 +1209,12 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
}
|
||||
|
||||
/**
|
||||
* Unstashes the Taskbar if it is stashed. This method should only be used to unstash the
|
||||
* taskbar at the end of a test.
|
||||
* Unstashes the Taskbar if it is stashed.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public void unstashTaskbarIfStashed() {
|
||||
if (DisplayController.isTransientTaskbar(this)) {
|
||||
mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(false);
|
||||
} else {
|
||||
mControllers.taskbarStashController.onLongPressToUnstashTaskbar();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -158,8 +158,7 @@ public class TaskbarForceVisibleImmersiveController implements TouchController {
|
||||
|
||||
@Override
|
||||
public boolean onControllerInterceptTouchEvent(MotionEvent ev) {
|
||||
if (!isNavbarShownInImmersiveMode()
|
||||
|| mControllers.taskbarStashController.supportsManualStashing()) {
|
||||
if (!isNavbarShownInImmersiveMode()) {
|
||||
return false;
|
||||
}
|
||||
return onControllerTouchEvent(ev);
|
||||
|
||||
@@ -15,17 +15,12 @@
|
||||
*/
|
||||
package com.android.launcher3.taskbar;
|
||||
|
||||
import static android.view.HapticFeedbackConstants.LONG_PRESS;
|
||||
import static android.view.accessibility.AccessibilityManager.FLAG_CONTENT_CONTROLS;
|
||||
|
||||
import static com.android.app.animation.Interpolators.EMPHASIZED;
|
||||
import static com.android.app.animation.Interpolators.FINAL_FRAME;
|
||||
import static com.android.app.animation.Interpolators.INSTANT;
|
||||
import static com.android.app.animation.Interpolators.LINEAR;
|
||||
import static com.android.launcher3.LauncherPrefs.TASKBAR_PINNING;
|
||||
import static com.android.launcher3.config.FeatureFlags.enableTaskbarPinning;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_HIDE;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_SHOW;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TRANSIENT_TASKBAR_HIDE;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TRANSIENT_TASKBAR_SHOW;
|
||||
import static com.android.launcher3.taskbar.TaskbarKeyguardController.MASK_ANY_SYSUI_LOCKED;
|
||||
@@ -44,7 +39,6 @@ import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.app.RemoteAction;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
@@ -62,9 +56,7 @@ import androidx.annotation.VisibleForTesting;
|
||||
import com.android.internal.jank.InteractionJankMonitor;
|
||||
import com.android.launcher3.Alarm;
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.LauncherPrefs;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.anim.AnimatedFloat;
|
||||
import com.android.launcher3.anim.AnimatorListeners;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
@@ -86,27 +78,26 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
public static final int FLAG_IN_APP = 1 << 0;
|
||||
public static final int FLAG_STASHED_IN_APP_MANUAL = 1 << 1; // long press, persisted
|
||||
public static final int FLAG_STASHED_IN_APP_SYSUI = 1 << 2; // shade open, ...
|
||||
public static final int FLAG_STASHED_IN_APP_SETUP = 1 << 3; // setup wizard and AllSetActivity
|
||||
public static final int FLAG_STASHED_IN_APP_IME = 1 << 4; // IME is visible
|
||||
public static final int FLAG_IN_STASHED_LAUNCHER_STATE = 1 << 5;
|
||||
public static final int FLAG_STASHED_IN_TASKBAR_ALL_APPS = 1 << 6; // All apps is visible.
|
||||
public static final int FLAG_IN_SETUP = 1 << 7; // In the Setup Wizard
|
||||
public static final int FLAG_STASHED_SMALL_SCREEN = 1 << 8; // phone screen gesture nav, stashed
|
||||
public static final int FLAG_STASHED_IN_APP_AUTO = 1 << 9; // Autohide (transient taskbar).
|
||||
public static final int FLAG_STASHED_SYSUI = 1 << 10; // app pinning,...
|
||||
public static final int FLAG_STASHED_DEVICE_LOCKED = 1 << 11; // device is locked: keyguard, ...
|
||||
public static final int FLAG_IN_OVERVIEW = 1 << 12; // launcher is in overview
|
||||
public static final int FLAG_STASHED_IN_APP_SYSUI = 1 << 1; // shade open, ...
|
||||
public static final int FLAG_STASHED_IN_APP_SETUP = 1 << 2; // setup wizard and AllSetActivity
|
||||
public static final int FLAG_STASHED_IN_APP_IME = 1 << 3; // IME is visible
|
||||
public static final int FLAG_IN_STASHED_LAUNCHER_STATE = 1 << 4;
|
||||
public static final int FLAG_STASHED_IN_TASKBAR_ALL_APPS = 1 << 5; // All apps is visible.
|
||||
public static final int FLAG_IN_SETUP = 1 << 6; // In the Setup Wizard
|
||||
public static final int FLAG_STASHED_SMALL_SCREEN = 1 << 7; // phone screen gesture nav, stashed
|
||||
public static final int FLAG_STASHED_IN_APP_AUTO = 1 << 8; // Autohide (transient taskbar).
|
||||
public static final int FLAG_STASHED_SYSUI = 1 << 9; // app pinning,...
|
||||
public static final int FLAG_STASHED_DEVICE_LOCKED = 1 << 10; // device is locked: keyguard, ...
|
||||
public static final int FLAG_IN_OVERVIEW = 1 << 11; // launcher is in overview
|
||||
|
||||
// If any of these flags are enabled, isInApp should return true.
|
||||
private static final int FLAGS_IN_APP = FLAG_IN_APP | FLAG_IN_SETUP;
|
||||
|
||||
// If we're in an app and any of these flags are enabled, taskbar should be stashed.
|
||||
private static final int FLAGS_STASHED_IN_APP = FLAG_STASHED_IN_APP_MANUAL
|
||||
| FLAG_STASHED_IN_APP_SYSUI | FLAG_STASHED_IN_APP_SETUP
|
||||
| FLAG_STASHED_IN_APP_IME | FLAG_STASHED_IN_TASKBAR_ALL_APPS
|
||||
| FLAG_STASHED_SMALL_SCREEN | FLAG_STASHED_IN_APP_AUTO;
|
||||
private static final int FLAGS_STASHED_IN_APP = FLAG_STASHED_IN_APP_SYSUI
|
||||
| FLAG_STASHED_IN_APP_SETUP | FLAG_STASHED_IN_APP_IME
|
||||
| FLAG_STASHED_IN_TASKBAR_ALL_APPS | FLAG_STASHED_SMALL_SCREEN
|
||||
| FLAG_STASHED_IN_APP_AUTO;
|
||||
|
||||
// If any of these flags are enabled, inset apps by our stashed height instead of our unstashed
|
||||
// height. This way the reported insets are consistent even during transitions out of the app.
|
||||
@@ -166,21 +157,11 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
*/
|
||||
private static final long TASKBAR_STASH_ICON_ALPHA_HOME_TO_APP_START_DELAY = 66;
|
||||
|
||||
/**
|
||||
* The scale that TaskbarView animates to when hinting towards the stashed state.
|
||||
*/
|
||||
private static final float STASHED_TASKBAR_HINT_SCALE = 0.9f;
|
||||
|
||||
/**
|
||||
* The scale that the stashed handle animates to when hinting towards the unstashed state.
|
||||
*/
|
||||
private static final float UNSTASHED_TASKBAR_HANDLE_HINT_SCALE = 1.1f;
|
||||
|
||||
/**
|
||||
* The SharedPreferences key for whether user has manually stashed the taskbar.
|
||||
*/
|
||||
private static final String SHARED_PREFS_STASHED_KEY = "taskbar_is_stashed";
|
||||
|
||||
/**
|
||||
* Whether taskbar should be stashed out of the box.
|
||||
*/
|
||||
@@ -224,7 +205,6 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
private @interface StashAnimation {}
|
||||
|
||||
private final TaskbarActivityContext mActivity;
|
||||
private final SharedPreferences mPrefs;
|
||||
private final int mStashedHeight;
|
||||
private final int mUnstashedHeight;
|
||||
private final SystemUiProxy mSystemUiProxy;
|
||||
@@ -253,8 +233,6 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
private boolean mIsImeShowing;
|
||||
private boolean mIsImeSwitcherShowing;
|
||||
|
||||
private boolean mEnableManualStashingDuringTests = false;
|
||||
|
||||
private final Alarm mTimeoutAlarm = new Alarm();
|
||||
private boolean mEnableBlockingTimeoutDuringTests = false;
|
||||
|
||||
@@ -274,7 +252,6 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
|
||||
public TaskbarStashController(TaskbarActivityContext activity) {
|
||||
mActivity = activity;
|
||||
mPrefs = LauncherPrefs.getPrefs(mActivity);
|
||||
mSystemUiProxy = SystemUiProxy.INSTANCE.get(activity);
|
||||
mAccessibilityManager = mActivity.getSystemService(AccessibilityManager.class);
|
||||
|
||||
@@ -328,15 +305,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
mTaskbarStashedHandleHintScale = stashedHandleController.getStashedHandleHintScale();
|
||||
|
||||
boolean isTransientTaskbar = DisplayController.isTransientTaskbar(mActivity);
|
||||
// We use supportsVisualStashing() here instead of supportsManualStashing() because we want
|
||||
// it to work properly for tests that recreate taskbar. This check is here just to ensure
|
||||
// that taskbar unstashes when going to 3 button mode (supportsVisualStashing() false).
|
||||
boolean isManuallyStashedInApp = supportsVisualStashing()
|
||||
&& !isTransientTaskbar
|
||||
&& !enableTaskbarPinning()
|
||||
&& mPrefs.getBoolean(SHARED_PREFS_STASHED_KEY, DEFAULT_STASHED_PREF);
|
||||
boolean isInSetup = !mActivity.isUserSetupComplete() || setupUIVisible;
|
||||
updateStateForFlag(FLAG_STASHED_IN_APP_MANUAL, isManuallyStashedInApp);
|
||||
updateStateForFlag(FLAG_STASHED_IN_APP_AUTO,
|
||||
isTransientTaskbar && !mTaskbarSharedState.taskbarWasPinned);
|
||||
updateStateForFlag(FLAG_STASHED_IN_APP_SETUP, isInSetup);
|
||||
@@ -361,28 +330,6 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
return !mActivity.isThreeButtonNav() && mControllers.uiController.supportsVisualStashing();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the user can manually stash the taskbar based on the current device state.
|
||||
*/
|
||||
protected boolean supportsManualStashing() {
|
||||
if (enableTaskbarPinning() && LauncherPrefs.get(mActivity).get(TASKBAR_PINNING)) {
|
||||
return false;
|
||||
}
|
||||
return supportsVisualStashing()
|
||||
&& isInApp()
|
||||
&& (!Utilities.isRunningInTestHarness() || mEnableManualStashingDuringTests)
|
||||
&& !DisplayController.isTransientTaskbar(mActivity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables support for manual stashing. This should only be used to add this functionality
|
||||
* to Launcher specific tests.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public void enableManualStashingDuringTests(boolean enableManualStashing) {
|
||||
mEnableManualStashingDuringTests = enableManualStashing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the auto timeout for taskbar stashing. This method should only be used for taskbar
|
||||
* testing.
|
||||
@@ -577,53 +524,6 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
/* shouldBubblesFollow= */ !bubbleBarExpanded);
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be called when long pressing the nav region when taskbar is present.
|
||||
* @return Whether taskbar was stashed and now is unstashed.
|
||||
*/
|
||||
public boolean onLongPressToUnstashTaskbar() {
|
||||
if (!isStashed()) {
|
||||
// We only listen for long press on the nav region to unstash the taskbar. To stash the
|
||||
// taskbar, we use an OnLongClickListener on TaskbarView instead.
|
||||
return false;
|
||||
}
|
||||
if (!canCurrentlyManuallyUnstash()) {
|
||||
return false;
|
||||
}
|
||||
if (updateAndAnimateIsManuallyStashedInApp(false)) {
|
||||
mControllers.taskbarActivityContext.getDragLayer().performHapticFeedback(LONG_PRESS);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether taskbar will unstash when long pressing it based on the current state. The
|
||||
* only time this is true is if the user is in an app and the taskbar is only stashed because
|
||||
* the user previously long pressed to manually stash (not due to other reasons like IME).
|
||||
*/
|
||||
private boolean canCurrentlyManuallyUnstash() {
|
||||
return (mState & (FLAG_IN_APP | FLAGS_STASHED_IN_APP))
|
||||
== (FLAG_IN_APP | FLAG_STASHED_IN_APP_MANUAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates whether we should stash the taskbar when in apps, and animates to the changed state.
|
||||
* @return Whether we started an animation to either be newly stashed or unstashed.
|
||||
*/
|
||||
public boolean updateAndAnimateIsManuallyStashedInApp(boolean isManuallyStashedInApp) {
|
||||
if (!supportsManualStashing()) {
|
||||
return false;
|
||||
}
|
||||
if (hasAnyFlag(FLAG_STASHED_IN_APP_MANUAL) != isManuallyStashedInApp) {
|
||||
mPrefs.edit().putBoolean(SHARED_PREFS_STASHED_KEY, isManuallyStashedInApp).apply();
|
||||
updateStateForFlag(FLAG_STASHED_IN_APP_MANUAL, isManuallyStashedInApp);
|
||||
applyState();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Toggles the Taskbar's stash state. */
|
||||
public void toggleTaskbarStash() {
|
||||
if (!DisplayController.isTransientTaskbar(mActivity) || !hasAnyFlag(FLAGS_IN_APP)) return;
|
||||
@@ -910,21 +810,6 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Creates and starts a partial stash animation, hinting at the new state that will trigger when
|
||||
* long press is detected.
|
||||
* @param animateForward Whether we are going towards the new stashed state or returning to the
|
||||
* unstashed state.
|
||||
*/
|
||||
public void startStashHint(boolean animateForward) {
|
||||
if (isStashed() || !supportsManualStashing()) {
|
||||
// Already stashed, no need to hint in that direction.
|
||||
return;
|
||||
}
|
||||
mIconScaleForStash.animateToValue(
|
||||
animateForward ? STASHED_TASKBAR_HINT_SCALE : 1)
|
||||
.setDuration(TASKBAR_HINT_STASH_DURATION).start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and starts a partial unstash animation, hinting at the new state that will trigger
|
||||
@@ -932,19 +817,12 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
*
|
||||
* @param animateForward Whether we are going towards the new unstashed state or returning to
|
||||
* the stashed state.
|
||||
* @param forceUnstash Whether we force the unstash hint to animate.
|
||||
*/
|
||||
protected void startUnstashHint(boolean animateForward, boolean forceUnstash) {
|
||||
protected void startUnstashHint(boolean animateForward) {
|
||||
if (!isStashed()) {
|
||||
// Already unstashed, no need to hint in that direction.
|
||||
return;
|
||||
}
|
||||
// TODO(b/270395798): Clean up after removing long-press unstashing code path.
|
||||
if (!canCurrentlyManuallyUnstash() && !forceUnstash) {
|
||||
// If any other flags are causing us to be stashed, long press won't cause us to
|
||||
// unstash, so don't hint that it will.
|
||||
return;
|
||||
}
|
||||
mTaskbarStashedHandleHintScale.animateToValue(
|
||||
animateForward ? UNSTASHED_TASKBAR_HANDLE_HINT_SCALE : 1)
|
||||
.setDuration(TASKBAR_HINT_STASH_DURATION).start();
|
||||
@@ -1097,13 +975,6 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
mControllers.taskbarAutohideSuspendController.updateFlag(
|
||||
TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_IN_LAUNCHER, !isInApp());
|
||||
}
|
||||
if (hasAnyFlag(changedFlags, FLAG_STASHED_IN_APP_MANUAL)) {
|
||||
if (hasAnyFlag(FLAG_STASHED_IN_APP_MANUAL)) {
|
||||
mActivity.getStatsLogManager().logger().log(LAUNCHER_TASKBAR_LONGPRESS_HIDE);
|
||||
} else {
|
||||
mActivity.getStatsLogManager().logger().log(LAUNCHER_TASKBAR_LONGPRESS_SHOW);
|
||||
}
|
||||
}
|
||||
if (hasAnyFlag(changedFlags, FLAG_STASHED_IN_APP_AUTO)) {
|
||||
mActivity.getStatsLogManager().logger().log(hasAnyFlag(FLAG_STASHED_IN_APP_AUTO)
|
||||
? LAUNCHER_TRANSIENT_TASKBAR_HIDE
|
||||
@@ -1227,7 +1098,6 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba
|
||||
private static String getStateString(int flags) {
|
||||
StringJoiner sj = new StringJoiner("|");
|
||||
appendFlag(sj, flags, FLAGS_IN_APP, "FLAG_IN_APP");
|
||||
appendFlag(sj, flags, FLAG_STASHED_IN_APP_MANUAL, "FLAG_STASHED_IN_APP_MANUAL");
|
||||
appendFlag(sj, flags, FLAG_STASHED_IN_APP_SYSUI, "FLAG_STASHED_IN_APP_SYSUI");
|
||||
appendFlag(sj, flags, FLAG_STASHED_IN_APP_SETUP, "FLAG_STASHED_IN_APP_SETUP");
|
||||
appendFlag(sj, flags, FLAG_STASHED_IN_APP_IME, "FLAG_STASHED_IN_APP_IME");
|
||||
|
||||
@@ -261,8 +261,6 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
mIconClickListener = mControllerCallbacks.getIconOnClickListener();
|
||||
mIconLongClickListener = mControllerCallbacks.getIconOnLongClickListener();
|
||||
|
||||
setOnLongClickListener(mControllerCallbacks.getBackgroundOnLongClickListener());
|
||||
|
||||
if (mAllAppsButton != null) {
|
||||
mAllAppsButton.setOnClickListener(mControllerCallbacks.getAllAppsButtonClickListener());
|
||||
}
|
||||
@@ -513,24 +511,6 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if (mIconLayoutBounds.left <= event.getX() && event.getX() <= mIconLayoutBounds.right) {
|
||||
// Don't allow long pressing between icons, or above/below them.
|
||||
return true;
|
||||
}
|
||||
if (mControllerCallbacks.onTouchEvent(event)) {
|
||||
int oldAction = event.getAction();
|
||||
try {
|
||||
event.setAction(MotionEvent.ACTION_CANCEL);
|
||||
return super.onTouchEvent(event);
|
||||
} finally {
|
||||
event.setAction(oldAction);
|
||||
}
|
||||
}
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given MotionEvent, *in screen coorindates*, is within any Taskbar item's
|
||||
* touch bounds.
|
||||
|
||||
@@ -22,7 +22,6 @@ import static com.android.launcher3.LauncherAnimUtils.VIEW_ALPHA;
|
||||
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X;
|
||||
import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_Y;
|
||||
import static com.android.launcher3.Utilities.mapRange;
|
||||
import static com.android.launcher3.Utilities.squaredHypot;
|
||||
import static com.android.launcher3.anim.AnimatedFloat.VALUE;
|
||||
import static com.android.launcher3.anim.AnimatorListeners.forEndCallback;
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_TASKBAR_NAVBAR_UNIFICATION;
|
||||
@@ -899,52 +898,11 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
|
||||
return mControllers.taskbarDragController::startDragOnLongClick;
|
||||
}
|
||||
|
||||
public View.OnLongClickListener getBackgroundOnLongClickListener() {
|
||||
return view -> mControllers.taskbarStashController
|
||||
.updateAndAnimateIsManuallyStashedInApp(true);
|
||||
}
|
||||
|
||||
/** Gets the hover listener for the provided icon view. */
|
||||
public View.OnHoverListener getIconOnHoverListener(View icon) {
|
||||
return new TaskbarHoverToolTipController(mActivity, mTaskbarView, icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first chance to handle TaskbarView#onTouchEvent, and return whether we want to
|
||||
* consume the touch so TaskbarView treats it as an ACTION_CANCEL.
|
||||
* TODO(b/270395798): We can remove this entirely once we remove the Transient Taskbar flag.
|
||||
*/
|
||||
public boolean onTouchEvent(MotionEvent motionEvent) {
|
||||
final float x = motionEvent.getRawX();
|
||||
final float y = motionEvent.getRawY();
|
||||
switch (motionEvent.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
mDownX = x;
|
||||
mDownY = y;
|
||||
mControllers.taskbarStashController.startStashHint(/* animateForward = */ true);
|
||||
mCanceledStashHint = false;
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
if (!mCanceledStashHint
|
||||
&& squaredHypot(mDownX - x, mDownY - y) > mSquaredTouchSlop) {
|
||||
mControllers.taskbarStashController.startStashHint(
|
||||
/* animateForward= */ false);
|
||||
mCanceledStashHint = true;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
if (!mCanceledStashHint) {
|
||||
mControllers.taskbarStashController.startStashHint(
|
||||
/* animateForward= */ false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies launcher to update icon alignment.
|
||||
*/
|
||||
|
||||
@@ -82,27 +82,11 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
|
||||
return response;
|
||||
}
|
||||
|
||||
case TestProtocol.REQUEST_ENABLE_MANUAL_TASKBAR_STASHING:
|
||||
runOnTISBinder(tisBinder -> {
|
||||
enableManualTaskbarStashing(tisBinder, true);
|
||||
});
|
||||
return response;
|
||||
|
||||
case TestProtocol.REQUEST_DISABLE_MANUAL_TASKBAR_STASHING:
|
||||
runOnTISBinder(tisBinder -> {
|
||||
enableManualTaskbarStashing(tisBinder, false);
|
||||
});
|
||||
return response;
|
||||
|
||||
case TestProtocol.REQUEST_UNSTASH_TASKBAR_IF_STASHED:
|
||||
runOnTISBinder(tisBinder -> {
|
||||
enableManualTaskbarStashing(tisBinder, true);
|
||||
|
||||
// Allow null-pointer to catch illegal states.
|
||||
tisBinder.getTaskbarManager().getCurrentActivityContext()
|
||||
.unstashTaskbarIfStashed();
|
||||
|
||||
enableManualTaskbarStashing(tisBinder, false);
|
||||
});
|
||||
return response;
|
||||
|
||||
@@ -187,13 +171,6 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
|
||||
return super.isLauncherInitialized() && TouchInteractionService.isInitialized();
|
||||
}
|
||||
|
||||
private void enableManualTaskbarStashing(
|
||||
TouchInteractionService.TISBinder tisBinder, boolean enable) {
|
||||
// Allow null-pointer to catch illegal states.
|
||||
tisBinder.getTaskbarManager().getCurrentActivityContext().enableManualStashingDuringTests(
|
||||
enable);
|
||||
}
|
||||
|
||||
private void enableBlockingTimeout(
|
||||
TouchInteractionService.TISBinder tisBinder, boolean enable) {
|
||||
TaskbarActivityContext context = tisBinder.getTaskbarManager().getCurrentActivityContext();
|
||||
|
||||
@@ -22,15 +22,12 @@ import static android.view.MotionEvent.INVALID_POINTER_ID;
|
||||
|
||||
import static com.android.launcher3.Flags.enableCursorHoverStates;
|
||||
import static com.android.launcher3.MotionEventsUtils.isTrackpadMotionEvent;
|
||||
import static com.android.launcher3.Utilities.squaredHypot;
|
||||
import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_TOUCHING;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.GestureDetector.SimpleOnGestureListener;
|
||||
import android.view.InputDevice;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.ViewConfiguration;
|
||||
@@ -39,7 +36,6 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.DeviceProfile;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.taskbar.TaskbarActivityContext;
|
||||
import com.android.launcher3.taskbar.TaskbarThresholdUtils;
|
||||
import com.android.launcher3.taskbar.TaskbarTranslationController.TransitionCallback;
|
||||
@@ -51,22 +47,13 @@ import com.android.quickstep.OverviewCommandHelper;
|
||||
import com.android.systemui.shared.system.InputMonitorCompat;
|
||||
|
||||
/**
|
||||
* Listens for touch and hover events to unstash the Taskbar.
|
||||
*
|
||||
* <p>Cancels the current gesture if the long press causes the Taskbar to be unstashed.
|
||||
* Listens for touch (swipe) and hover events to unstash the Taskbar.
|
||||
*/
|
||||
public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
|
||||
|
||||
private final TaskbarActivityContext mTaskbarActivityContext;
|
||||
private final OverviewCommandHelper mOverviewCommandHelper;
|
||||
private final GestureDetector mLongPressDetector;
|
||||
private final float mSquaredTouchSlop;
|
||||
|
||||
private float mLongPressDownX, mLongPressDownY;
|
||||
private boolean mCanceledUnstashHint;
|
||||
private final float mUnstashArea;
|
||||
private final float mScreenWidth;
|
||||
|
||||
private final int mTaskbarNavThreshold;
|
||||
private final int mTaskbarNavThresholdY;
|
||||
private final boolean mIsTaskbarAllAppsOpen;
|
||||
@@ -96,10 +83,7 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
|
||||
super(delegate, inputMonitor);
|
||||
mTaskbarActivityContext = taskbarActivityContext;
|
||||
mOverviewCommandHelper = overviewCommandHelper;
|
||||
// TODO(b/270395798): remove this when cleaning up old Persistent Taskbar code.
|
||||
mSquaredTouchSlop = Utilities.squaredTouchSlop(context);
|
||||
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
|
||||
mScreenWidth = taskbarActivityContext.getDeviceProfile().widthPx;
|
||||
|
||||
Resources res = context.getResources();
|
||||
mUnstashArea = res.getDimensionPixelSize(R.dimen.taskbar_unstash_input_area);
|
||||
@@ -111,13 +95,6 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
|
||||
|
||||
mIsTransientTaskbar = DisplayController.isTransientTaskbar(context);
|
||||
|
||||
mLongPressDetector = new GestureDetector(context, new SimpleOnGestureListener() {
|
||||
@Override
|
||||
public void onLongPress(MotionEvent motionEvent) {
|
||||
onLongPressDetected(motionEvent);
|
||||
}
|
||||
});
|
||||
|
||||
mBottomScreenEdge = res.getDimensionPixelSize(
|
||||
R.dimen.taskbar_stashed_screen_edge_hover_deadzone_height);
|
||||
mStashedTaskbarBottomEdge =
|
||||
@@ -135,7 +112,6 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
|
||||
|
||||
@Override
|
||||
public void onMotionEvent(MotionEvent ev) {
|
||||
mLongPressDetector.onTouchEvent(ev);
|
||||
if (mState != STATE_ACTIVE) {
|
||||
boolean isStashedTaskbarHovered = isMouseEvent(ev)
|
||||
&& isStashedTaskbarHovered((int) ev.getX(), (int) ev.getY());
|
||||
@@ -152,15 +128,6 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
|
||||
mHasPassedTaskbarNavThreshold = false;
|
||||
mTaskbarActivityContext.setAutohideSuspendFlag(
|
||||
FLAG_AUTOHIDE_SUSPEND_TOUCHING, true);
|
||||
if (isInTaskbarArea(x)) {
|
||||
if (!mIsTransientTaskbar) {
|
||||
mLongPressDownX = x;
|
||||
mLongPressDownY = y;
|
||||
mTaskbarActivityContext.startTaskbarUnstashHint(
|
||||
/* animateForward = */ true);
|
||||
mCanceledUnstashHint = false;
|
||||
}
|
||||
}
|
||||
if (mTransitionCallback != null && !mIsTaskbarAllAppsOpen) {
|
||||
mTransitionCallback.onActionDown();
|
||||
}
|
||||
@@ -181,15 +148,6 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
|
||||
}
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
if (!mIsTransientTaskbar
|
||||
&& !mCanceledUnstashHint
|
||||
&& squaredHypot(mLongPressDownX - x, mLongPressDownY - y)
|
||||
> mSquaredTouchSlop) {
|
||||
mTaskbarActivityContext.startTaskbarUnstashHint(
|
||||
/* animateForward = */ false);
|
||||
mCanceledUnstashHint = true;
|
||||
}
|
||||
|
||||
int pointerIndex = ev.findPointerIndex(mActivePointerId);
|
||||
if (pointerIndex == INVALID_POINTER_ID) {
|
||||
break;
|
||||
@@ -283,10 +241,6 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
|
||||
}
|
||||
|
||||
private void cleanupAfterMotionEvent() {
|
||||
if (!mIsTransientTaskbar && !mCanceledUnstashHint) {
|
||||
mTaskbarActivityContext.startTaskbarUnstashHint(
|
||||
/* animateForward = */ false);
|
||||
}
|
||||
mTaskbarActivityContext.setAutohideSuspendFlag(
|
||||
FLAG_AUTOHIDE_SUSPEND_TOUCHING, false);
|
||||
if (mTransitionCallback != null) {
|
||||
@@ -298,12 +252,6 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
|
||||
mIsPassedBubbleBarSlop = false;
|
||||
}
|
||||
|
||||
private boolean isInTaskbarArea(float x) {
|
||||
float areaFromMiddle = mUnstashArea / 2.0f;
|
||||
float distFromMiddle = Math.abs(mScreenWidth / 2.0f - x);
|
||||
return distFromMiddle < areaFromMiddle;
|
||||
}
|
||||
|
||||
private boolean isInBubbleBarArea(float x) {
|
||||
if (mTaskbarActivityContext == null || !mIsTransientTaskbar) {
|
||||
return false;
|
||||
@@ -320,17 +268,6 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
|
||||
}
|
||||
}
|
||||
|
||||
private void onLongPressDetected(MotionEvent motionEvent) {
|
||||
if (mTaskbarActivityContext != null
|
||||
&& isInTaskbarArea(motionEvent.getRawX())
|
||||
&& !mIsTransientTaskbar) {
|
||||
boolean taskBarPressed = mTaskbarActivityContext.onLongPressToUnstashTaskbar();
|
||||
if (taskBarPressed) {
|
||||
setActive(motionEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Listen for hover events for the stashed taskbar.
|
||||
*
|
||||
@@ -389,7 +326,7 @@ public class TaskbarUnstashInputConsumer extends DelegateInputConsumer {
|
||||
}
|
||||
|
||||
private void startStashedTaskbarHover(boolean isHovered) {
|
||||
mTaskbarActivityContext.startTaskbarUnstashHint(isHovered, /* forceUnstash = */ true);
|
||||
mTaskbarActivityContext.startTaskbarUnstashHint(isHovered);
|
||||
mIsStashedTaskbarHovered = isHovered;
|
||||
}
|
||||
|
||||
|
||||
@@ -219,9 +219,6 @@ public final class FeatureFlags {
|
||||
public static final BooleanFlag NOTIFY_CRASHES = getDebugFlag(270393108, "NOTIFY_CRASHES",
|
||||
TEAMFOOD, "Sends a notification whenever launcher encounters an uncaught exception.");
|
||||
|
||||
public static final BooleanFlag ENABLE_TRANSIENT_TASKBAR = getDebugFlag(270395798,
|
||||
"ENABLE_TRANSIENT_TASKBAR", ENABLED, "Enables transient taskbar.");
|
||||
|
||||
public static final boolean ENABLE_TASKBAR_NAVBAR_UNIFICATION =
|
||||
enableTaskbarNavbarUnification();
|
||||
|
||||
|
||||
@@ -549,12 +549,6 @@ public class StatsLogManager implements ResourceBasedOverride {
|
||||
@UiEvent(doc = "Launcher item drop failed since there was not enough room on the screen.")
|
||||
LAUNCHER_ITEM_DROP_FAILED_INSUFFICIENT_SPACE(872),
|
||||
|
||||
@UiEvent(doc = "User long pressed on the taskbar background to hide the taskbar")
|
||||
LAUNCHER_TASKBAR_LONGPRESS_HIDE(896),
|
||||
|
||||
@UiEvent(doc = "User long pressed on the taskbar gesture handle to show the taskbar")
|
||||
LAUNCHER_TASKBAR_LONGPRESS_SHOW(897),
|
||||
|
||||
@UiEvent(doc = "User clicks on the search icon on header to launch search in app.")
|
||||
LAUNCHER_ALLAPPS_SEARCHINAPP_LAUNCH(913),
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
|
||||
import static com.android.launcher3.LauncherPrefs.TASKBAR_PINNING;
|
||||
import static com.android.launcher3.LauncherPrefs.TASKBAR_PINNING_KEY;
|
||||
import static com.android.launcher3.Utilities.dpiFromPx;
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_TRANSIENT_TASKBAR;
|
||||
import static com.android.launcher3.config.FeatureFlags.enableTaskbarPinning;
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
import static com.android.launcher3.util.FlagDebugUtils.appendFlag;
|
||||
@@ -410,18 +409,19 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
|
||||
* Returns whether taskbar is transient.
|
||||
*/
|
||||
public boolean isTransientTaskbar() {
|
||||
// TODO(b/258604917): Once ENABLE_TASKBAR_PINNING is enabled, remove usage of
|
||||
// sTransientTaskbarStatusForTests and update test to directly
|
||||
// toggle shred preference to switch transient taskbar on/of
|
||||
if (!Utilities.isRunningInTestHarness()
|
||||
&& enableTaskbarPinning()
|
||||
&& mIsTaskbarPinned) {
|
||||
if (navigationMode != NavigationMode.NO_BUTTON) {
|
||||
return false;
|
||||
}
|
||||
return navigationMode == NavigationMode.NO_BUTTON
|
||||
&& (Utilities.isRunningInTestHarness()
|
||||
? sTransientTaskbarStatusForTests
|
||||
: ENABLE_TRANSIENT_TASKBAR.get() && !mIsTaskbarPinned);
|
||||
if (Utilities.isRunningInTestHarness()) {
|
||||
// TODO(b/258604917): Once ENABLE_TASKBAR_PINNING is enabled, remove usage of
|
||||
// sTransientTaskbarStatusForTests and update test to directly
|
||||
// toggle shared preference to switch transient taskbar on/off.
|
||||
return sTransientTaskbarStatusForTests;
|
||||
}
|
||||
if (enableTaskbarPinning()) {
|
||||
return !mIsTaskbarPinned;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -485,6 +485,7 @@ public class DisplayController implements ComponentCallbacks, SafeCloseable {
|
||||
pw.println(" currentSize=" + info.currentSize);
|
||||
info.mPerDisplayBounds.forEach((key, value) -> pw.println(
|
||||
" perDisplayBounds - " + key + ": " + value));
|
||||
pw.println(" isTransientTaskbar=" + info.isTransientTaskbar());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -92,8 +92,6 @@ public final class TestProtocol {
|
||||
"is-launcher-activity-started";
|
||||
public static final String REQUEST_FREEZE_APP_LIST = "freeze-app-list";
|
||||
public static final String REQUEST_UNFREEZE_APP_LIST = "unfreeze-app-list";
|
||||
public static final String REQUEST_ENABLE_MANUAL_TASKBAR_STASHING = "enable-taskbar-stashing";
|
||||
public static final String REQUEST_DISABLE_MANUAL_TASKBAR_STASHING = "disable-taskbar-stashing";
|
||||
public static final String REQUEST_ENABLE_BLOCK_TIMEOUT = "enable-block-timeout";
|
||||
public static final String REQUEST_DISABLE_BLOCK_TIMEOUT = "disable-block-timeout";
|
||||
public static final String REQUEST_ENABLE_TRANSIENT_TASKBAR = "enable-transient-taskbar";
|
||||
|
||||
Reference in New Issue
Block a user