2021-06-01 16:54:07 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2021 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.launcher3.taskbar;
|
|
|
|
|
|
|
|
|
|
import static android.view.HapticFeedbackConstants.LONG_PRESS;
|
|
|
|
|
|
2022-04-14 17:51:59 +01:00
|
|
|
import static com.android.launcher3.LauncherState.ALL_APPS;
|
2021-10-07 15:49:19 -07:00
|
|
|
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_HIDE;
|
|
|
|
|
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_LONGPRESS_SHOW;
|
2022-06-08 14:01:02 -07:00
|
|
|
import static com.android.launcher3.taskbar.TaskbarManager.isPhoneMode;
|
2022-03-31 15:35:20 -07:00
|
|
|
import static com.android.launcher3.taskbar.Utilities.appendFlag;
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_IME_SHOWING;
|
2022-06-24 10:51:10 -07:00
|
|
|
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_IME_SWITCHER_SHOWING;
|
2021-10-07 15:53:32 -07:00
|
|
|
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING;
|
2021-10-07 15:49:19 -07:00
|
|
|
|
2021-06-01 16:54:07 -07:00
|
|
|
import android.animation.Animator;
|
|
|
|
|
import android.animation.AnimatorListenerAdapter;
|
|
|
|
|
import android.animation.AnimatorSet;
|
|
|
|
|
import android.annotation.Nullable;
|
|
|
|
|
import android.content.SharedPreferences;
|
2022-06-08 14:01:02 -07:00
|
|
|
import android.content.res.Resources;
|
2022-04-06 14:24:20 -07:00
|
|
|
import android.util.Log;
|
2022-04-27 08:39:02 +00:00
|
|
|
import android.view.View;
|
2021-07-16 12:15:35 -10:00
|
|
|
import android.view.ViewConfiguration;
|
2021-06-01 16:54:07 -07:00
|
|
|
|
2022-04-27 08:39:02 +00:00
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
|
|
|
|
|
import com.android.internal.jank.InteractionJankMonitor;
|
2022-03-03 20:00:42 +00:00
|
|
|
import com.android.launcher3.DeviceProfile;
|
2022-06-08 14:01:02 -07:00
|
|
|
import com.android.launcher3.R;
|
2021-06-01 16:54:07 -07:00
|
|
|
import com.android.launcher3.Utilities;
|
2022-05-11 10:27:30 -07:00
|
|
|
import com.android.launcher3.anim.AnimatorListeners;
|
2022-07-26 13:54:31 -07:00
|
|
|
import com.android.launcher3.testing.shared.TestProtocol;
|
2021-06-01 16:54:07 -07:00
|
|
|
import com.android.launcher3.util.MultiValueAlpha.AlphaProperty;
|
|
|
|
|
import com.android.quickstep.AnimatedFloat;
|
2021-06-30 10:24:11 +00:00
|
|
|
import com.android.quickstep.SystemUiProxy;
|
2022-03-03 18:23:03 +00:00
|
|
|
import com.android.systemui.shared.system.WindowManagerWrapper;
|
2021-06-01 16:54:07 -07:00
|
|
|
|
2021-12-15 13:09:39 -08:00
|
|
|
import java.io.PrintWriter;
|
2022-04-27 08:39:02 +00:00
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Optional;
|
2021-12-15 13:09:39 -08:00
|
|
|
import java.util.StringJoiner;
|
2021-09-02 22:49:34 -07:00
|
|
|
import java.util.function.IntPredicate;
|
|
|
|
|
|
2021-06-01 16:54:07 -07:00
|
|
|
/**
|
|
|
|
|
* Coordinates between controllers such as TaskbarViewController and StashedHandleViewController to
|
|
|
|
|
* create a cohesive animation between stashed/unstashed states.
|
|
|
|
|
*/
|
2021-12-15 13:09:39 -08:00
|
|
|
public class TaskbarStashController implements TaskbarControllers.LoggableTaskbarController {
|
2021-06-01 16:54:07 -07:00
|
|
|
|
2022-04-27 08:39:02 +00:00
|
|
|
private static final String TAG = "TaskbarStashController";
|
|
|
|
|
|
2021-09-02 22:49:34 -07:00
|
|
|
public static final int FLAG_IN_APP = 1 << 0;
|
2021-10-07 15:49:19 -07:00
|
|
|
public static final int FLAG_STASHED_IN_APP_MANUAL = 1 << 1; // long press, persisted
|
2021-10-07 15:53:32 -07:00
|
|
|
public static final int FLAG_STASHED_IN_APP_PINNED = 1 << 2; // app pinning
|
|
|
|
|
public static final int FLAG_STASHED_IN_APP_EMPTY = 1 << 3; // no hotseat icons
|
2021-09-28 15:09:25 -07:00
|
|
|
public static final int FLAG_STASHED_IN_APP_SETUP = 1 << 4; // setup wizard and AllSetActivity
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
public static final int FLAG_STASHED_IN_APP_IME = 1 << 5; // IME is visible
|
|
|
|
|
public static final int FLAG_IN_STASHED_LAUNCHER_STATE = 1 << 6;
|
2022-02-07 22:22:09 -05:00
|
|
|
public static final int FLAG_STASHED_IN_APP_ALL_APPS = 1 << 7; // All apps is visible.
|
2022-03-09 10:38:25 -08:00
|
|
|
public static final int FLAG_IN_SETUP = 1 << 8; // In the Setup Wizard
|
2022-06-08 14:01:02 -07:00
|
|
|
public static final int FLAG_STASHED_SMALL_SCREEN = 1 << 9; // phone screen gesture nav, stashed
|
2022-03-09 10:38:25 -08:00
|
|
|
|
|
|
|
|
// If any of these flags are enabled, isInApp should return true.
|
|
|
|
|
private static final int FLAGS_IN_APP = FLAG_IN_APP | FLAG_IN_SETUP;
|
2021-09-02 22:49:34 -07:00
|
|
|
|
2021-10-07 15:49:19 -07:00
|
|
|
// If we're in an app and any of these flags are enabled, taskbar should be stashed.
|
2021-12-10 22:02:37 +00:00
|
|
|
private static final int FLAGS_STASHED_IN_APP = FLAG_STASHED_IN_APP_MANUAL
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
| FLAG_STASHED_IN_APP_PINNED | FLAG_STASHED_IN_APP_EMPTY | FLAG_STASHED_IN_APP_SETUP
|
2022-06-08 14:01:02 -07:00
|
|
|
| FLAG_STASHED_IN_APP_IME | FLAG_STASHED_IN_APP_ALL_APPS |
|
|
|
|
|
FLAG_STASHED_SMALL_SCREEN;
|
2021-10-07 15:49:19 -07:00
|
|
|
|
2022-03-25 15:53:34 +08:00
|
|
|
private static final int FLAGS_STASHED_IN_APP_IGNORING_IME =
|
|
|
|
|
FLAGS_STASHED_IN_APP & ~FLAG_STASHED_IN_APP_IME;
|
|
|
|
|
|
2021-12-10 22:02:37 +00:00
|
|
|
// 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.
|
2022-03-03 06:35:03 +00:00
|
|
|
// Currently any flag that causes us to stash in an app is included, except for IME or All Apps
|
|
|
|
|
// since those cover the underlying app anyway and thus the app shouldn't change insets.
|
2021-12-10 22:02:37 +00:00
|
|
|
private static final int FLAGS_REPORT_STASHED_INSETS_TO_APP = FLAGS_STASHED_IN_APP
|
2022-03-03 06:35:03 +00:00
|
|
|
& ~FLAG_STASHED_IN_APP_IME & ~FLAG_STASHED_IN_APP_ALL_APPS;
|
2021-12-10 22:02:37 +00:00
|
|
|
|
2021-06-01 16:54:07 -07:00
|
|
|
/**
|
|
|
|
|
* How long to stash/unstash when manually invoked via long press.
|
|
|
|
|
*/
|
2022-03-03 18:23:03 +00:00
|
|
|
public static final long TASKBAR_STASH_DURATION =
|
|
|
|
|
WindowManagerWrapper.ANIMATION_DURATION_RESIZE;
|
2021-06-01 16:54:07 -07:00
|
|
|
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
/**
|
|
|
|
|
* How long to stash/unstash when keyboard is appearing/disappearing.
|
|
|
|
|
*/
|
|
|
|
|
private static final long TASKBAR_STASH_DURATION_FOR_IME = 80;
|
|
|
|
|
|
2021-06-01 16:54:07 -07:00
|
|
|
/**
|
|
|
|
|
* The scale TaskbarView animates to when being stashed.
|
|
|
|
|
*/
|
|
|
|
|
private static final float STASHED_TASKBAR_SCALE = 0.5f;
|
|
|
|
|
|
2021-07-16 12:15:35 -10:00
|
|
|
/**
|
|
|
|
|
* How long the hint animation plays, starting on motion down.
|
|
|
|
|
*/
|
|
|
|
|
private static final long TASKBAR_HINT_STASH_DURATION =
|
|
|
|
|
ViewConfiguration.DEFAULT_LONG_PRESS_TIMEOUT;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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;
|
|
|
|
|
|
2021-06-01 16:54:07 -07:00
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
private static final boolean DEFAULT_STASHED_PREF = false;
|
|
|
|
|
|
|
|
|
|
private final TaskbarActivityContext mActivity;
|
|
|
|
|
private final SharedPreferences mPrefs;
|
|
|
|
|
private final int mStashedHeight;
|
|
|
|
|
private final int mUnstashedHeight;
|
2021-10-21 15:31:51 +01:00
|
|
|
private final SystemUiProxy mSystemUiProxy;
|
2021-06-01 16:54:07 -07:00
|
|
|
|
|
|
|
|
// Initialized in init.
|
|
|
|
|
private TaskbarControllers mControllers;
|
|
|
|
|
// Taskbar background properties.
|
|
|
|
|
private AnimatedFloat mTaskbarBackgroundOffset;
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
private AnimatedFloat mTaskbarImeBgAlpha;
|
2021-06-01 16:54:07 -07:00
|
|
|
// TaskbarView icon properties.
|
|
|
|
|
private AlphaProperty mIconAlphaForStash;
|
|
|
|
|
private AnimatedFloat mIconScaleForStash;
|
|
|
|
|
private AnimatedFloat mIconTranslationYForStash;
|
|
|
|
|
// Stashed handle properties.
|
2021-09-28 15:09:25 -07:00
|
|
|
private AlphaProperty mTaskbarStashedHandleAlpha;
|
2021-07-16 12:15:35 -10:00
|
|
|
private AnimatedFloat mTaskbarStashedHandleHintScale;
|
2021-06-01 16:54:07 -07:00
|
|
|
|
|
|
|
|
/** Whether we are currently visually stashed (might change based on launcher state). */
|
|
|
|
|
private boolean mIsStashed = false;
|
2021-09-02 22:49:34 -07:00
|
|
|
private int mState;
|
2021-06-01 16:54:07 -07:00
|
|
|
|
|
|
|
|
private @Nullable AnimatorSet mAnimator;
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
private boolean mIsSystemGestureInProgress;
|
|
|
|
|
private boolean mIsImeShowing;
|
2022-06-24 10:51:10 -07:00
|
|
|
private boolean mIsImeSwitcherShowing;
|
2021-06-01 16:54:07 -07:00
|
|
|
|
2022-02-10 11:10:21 -08:00
|
|
|
private boolean mEnableManualStashingForTests = false;
|
|
|
|
|
|
2021-09-09 21:18:25 -07:00
|
|
|
// Evaluate whether the handle should be stashed
|
|
|
|
|
private final StatePropertyHolder mStatePropertyHolder = new StatePropertyHolder(
|
|
|
|
|
flags -> {
|
2022-03-09 10:38:25 -08:00
|
|
|
boolean inApp = hasAnyFlag(flags, FLAGS_IN_APP);
|
2021-10-07 15:49:19 -07:00
|
|
|
boolean stashedInApp = hasAnyFlag(flags, FLAGS_STASHED_IN_APP);
|
|
|
|
|
boolean stashedLauncherState = hasAnyFlag(flags, FLAG_IN_STASHED_LAUNCHER_STATE);
|
2022-06-08 14:01:02 -07:00
|
|
|
boolean stashedForSmallScreen = hasAnyFlag(flags, FLAG_STASHED_SMALL_SCREEN);
|
|
|
|
|
return (inApp && stashedInApp) || (!inApp && stashedLauncherState)
|
|
|
|
|
|| stashedForSmallScreen;
|
2021-09-09 21:18:25 -07:00
|
|
|
});
|
|
|
|
|
|
2021-06-01 16:54:07 -07:00
|
|
|
public TaskbarStashController(TaskbarActivityContext activity) {
|
|
|
|
|
mActivity = activity;
|
|
|
|
|
mPrefs = Utilities.getPrefs(mActivity);
|
2021-10-21 15:31:51 +01:00
|
|
|
mSystemUiProxy = SystemUiProxy.INSTANCE.get(activity);
|
2022-06-08 14:01:02 -07:00
|
|
|
if (isPhoneMode(mActivity.getDeviceProfile())) {
|
|
|
|
|
// DeviceProfile's taskbar vars aren't initialized w/ the flag off
|
|
|
|
|
Resources resources = mActivity.getResources();
|
|
|
|
|
mUnstashedHeight = resources.getDimensionPixelSize(R.dimen.taskbar_size);
|
|
|
|
|
mStashedHeight = resources.getDimensionPixelOffset(R.dimen.taskbar_stashed_size);
|
|
|
|
|
} else {
|
|
|
|
|
mUnstashedHeight = mActivity.getDeviceProfile().taskbarSize;
|
|
|
|
|
mStashedHeight = mActivity.getDeviceProfile().stashedTaskbarSize;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-01 16:54:07 -07:00
|
|
|
}
|
|
|
|
|
|
2022-03-24 14:47:32 -07:00
|
|
|
public void init(TaskbarControllers controllers, boolean setupUIVisible) {
|
2021-06-01 16:54:07 -07:00
|
|
|
mControllers = controllers;
|
|
|
|
|
|
|
|
|
|
TaskbarDragLayerController dragLayerController = controllers.taskbarDragLayerController;
|
|
|
|
|
mTaskbarBackgroundOffset = dragLayerController.getTaskbarBackgroundOffset();
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
mTaskbarImeBgAlpha = dragLayerController.getImeBgTaskbar();
|
2021-06-01 16:54:07 -07:00
|
|
|
|
|
|
|
|
TaskbarViewController taskbarViewController = controllers.taskbarViewController;
|
|
|
|
|
mIconAlphaForStash = taskbarViewController.getTaskbarIconAlpha().getProperty(
|
|
|
|
|
TaskbarViewController.ALPHA_INDEX_STASH);
|
|
|
|
|
mIconScaleForStash = taskbarViewController.getTaskbarIconScaleForStash();
|
|
|
|
|
mIconTranslationYForStash = taskbarViewController.getTaskbarIconTranslationYForStash();
|
|
|
|
|
|
|
|
|
|
StashedHandleViewController stashedHandleController =
|
|
|
|
|
controllers.stashedHandleViewController;
|
2021-09-28 15:09:25 -07:00
|
|
|
mTaskbarStashedHandleAlpha = stashedHandleController.getStashedHandleAlpha().getProperty(
|
|
|
|
|
StashedHandleViewController.ALPHA_INDEX_STASHED);
|
2021-07-16 12:15:35 -10:00
|
|
|
mTaskbarStashedHandleHintScale = stashedHandleController.getStashedHandleHintScale();
|
2021-06-01 16:54:07 -07:00
|
|
|
|
2021-10-07 15:49:19 -07:00
|
|
|
boolean isManuallyStashedInApp = supportsManualStashing()
|
2021-06-01 16:54:07 -07:00
|
|
|
&& mPrefs.getBoolean(SHARED_PREFS_STASHED_KEY, DEFAULT_STASHED_PREF);
|
2022-03-24 14:47:32 -07:00
|
|
|
boolean isInSetup = !mActivity.isUserSetupComplete() || setupUIVisible;
|
2021-10-07 15:49:19 -07:00
|
|
|
updateStateForFlag(FLAG_STASHED_IN_APP_MANUAL, isManuallyStashedInApp);
|
2022-01-27 17:21:25 +00:00
|
|
|
updateStateForFlag(FLAG_STASHED_IN_APP_SETUP, isInSetup);
|
2022-03-09 10:38:25 -08:00
|
|
|
updateStateForFlag(FLAG_IN_SETUP, isInSetup);
|
2022-06-08 14:01:02 -07:00
|
|
|
updateStateForFlag(FLAG_STASHED_SMALL_SCREEN, isPhoneMode(mActivity.getDeviceProfile()));
|
2021-10-07 15:49:19 -07:00
|
|
|
applyState();
|
2021-06-30 10:24:11 +00:00
|
|
|
|
2021-10-21 15:31:51 +01:00
|
|
|
notifyStashChange(/* visible */ false, /* stashed */ isStashedInApp());
|
2021-06-01 16:54:07 -07:00
|
|
|
}
|
|
|
|
|
|
2021-09-22 13:58:10 -07:00
|
|
|
/**
|
|
|
|
|
* Returns whether the taskbar can visually stash into a handle based on the current device
|
|
|
|
|
* state.
|
|
|
|
|
*/
|
2022-03-03 06:35:03 +00:00
|
|
|
public boolean supportsVisualStashing() {
|
2022-06-08 14:01:02 -07:00
|
|
|
return mControllers.uiController.supportsVisualStashing() ||
|
|
|
|
|
isPhoneMode(mActivity.getDeviceProfile());
|
2021-09-22 13:58:10 -07:00
|
|
|
}
|
|
|
|
|
|
2021-06-01 16:54:07 -07:00
|
|
|
/**
|
|
|
|
|
* Returns whether the user can manually stash the taskbar based on the current device state.
|
|
|
|
|
*/
|
2021-12-01 14:51:51 +00:00
|
|
|
protected boolean supportsManualStashing() {
|
2021-09-22 13:58:10 -07:00
|
|
|
return supportsVisualStashing()
|
2022-02-10 11:10:21 -08:00
|
|
|
&& (!Utilities.IS_RUNNING_IN_TEST_HARNESS || mEnableManualStashingForTests);
|
2021-07-15 14:42:33 -10:00
|
|
|
}
|
|
|
|
|
|
2022-02-10 11:10:21 -08:00
|
|
|
/**
|
|
|
|
|
* Enables support for manual stashing. This should only be used to add this functionality
|
|
|
|
|
* to Launcher specific tests.
|
|
|
|
|
*/
|
|
|
|
|
public void enableManualStashingForTests(boolean enableManualStashing) {
|
|
|
|
|
mEnableManualStashingForTests = enableManualStashing;
|
2021-06-01 16:54:07 -07:00
|
|
|
}
|
|
|
|
|
|
2021-09-28 15:09:25 -07:00
|
|
|
/**
|
2021-10-01 11:31:45 -07:00
|
|
|
* Sets the flag indicating setup UI is visible
|
2021-09-28 15:09:25 -07:00
|
|
|
*/
|
2021-10-01 11:31:45 -07:00
|
|
|
protected void setSetupUIVisible(boolean isVisible) {
|
2022-03-09 10:38:25 -08:00
|
|
|
boolean hideTaskbar = isVisible || !mActivity.isUserSetupComplete();
|
|
|
|
|
updateStateForFlag(FLAG_IN_SETUP, hideTaskbar);
|
|
|
|
|
updateStateForFlag(FLAG_STASHED_IN_APP_SETUP, hideTaskbar);
|
|
|
|
|
applyState(hideTaskbar ? 0 : TASKBAR_STASH_DURATION);
|
2021-09-28 15:09:25 -07:00
|
|
|
}
|
|
|
|
|
|
2021-06-01 16:54:07 -07:00
|
|
|
/**
|
|
|
|
|
* Returns whether the taskbar is currently visually stashed.
|
|
|
|
|
*/
|
|
|
|
|
public boolean isStashed() {
|
|
|
|
|
return mIsStashed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-10-07 15:49:19 -07:00
|
|
|
* Returns whether the taskbar should be stashed in apps (e.g. user long pressed to stash).
|
2021-06-01 16:54:07 -07:00
|
|
|
*/
|
|
|
|
|
public boolean isStashedInApp() {
|
2021-10-07 15:49:19 -07:00
|
|
|
return hasAnyFlag(FLAGS_STASHED_IN_APP);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-25 15:53:34 +08:00
|
|
|
/**
|
|
|
|
|
* Returns whether the taskbar should be stashed in apps regardless of the IME visibility.
|
|
|
|
|
*/
|
|
|
|
|
public boolean isStashedInAppIgnoringIme() {
|
|
|
|
|
return hasAnyFlag(FLAGS_STASHED_IN_APP_IGNORING_IME);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-01 15:55:04 -08:00
|
|
|
/**
|
|
|
|
|
* Returns whether the taskbar should be stashed in the current LauncherState.
|
|
|
|
|
*/
|
|
|
|
|
public boolean isInStashedLauncherState() {
|
2022-06-08 14:01:02 -07:00
|
|
|
return (hasAnyFlag(FLAG_IN_STASHED_LAUNCHER_STATE) && supportsVisualStashing());
|
2021-12-01 15:55:04 -08:00
|
|
|
}
|
|
|
|
|
|
2021-10-07 15:49:19 -07:00
|
|
|
private boolean hasAnyFlag(int flagMask) {
|
|
|
|
|
return hasAnyFlag(mState, flagMask);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean hasAnyFlag(int flags, int flagMask) {
|
|
|
|
|
return (flags & flagMask) != 0;
|
2021-06-01 16:54:07 -07:00
|
|
|
}
|
|
|
|
|
|
2021-09-24 10:48:01 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns whether the taskbar is currently visible and in an app.
|
|
|
|
|
*/
|
|
|
|
|
public boolean isInAppAndNotStashed() {
|
2022-01-25 00:12:36 +00:00
|
|
|
return !mIsStashed && isInApp();
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-07 12:49:56 -08:00
|
|
|
public boolean isInApp() {
|
2022-03-09 10:38:25 -08:00
|
|
|
return hasAnyFlag(FLAGS_IN_APP);
|
2021-09-24 10:48:01 -07:00
|
|
|
}
|
|
|
|
|
|
2021-12-10 22:02:37 +00:00
|
|
|
/**
|
|
|
|
|
* Returns the height that taskbar will inset when inside apps.
|
2022-04-15 16:01:38 -07:00
|
|
|
* @see WindowInsets.Type#navigationBars()
|
|
|
|
|
* @see WindowInsets.Type#systemBars()
|
2021-12-10 22:02:37 +00:00
|
|
|
*/
|
|
|
|
|
public int getContentHeightToReportToApps() {
|
2022-06-08 14:01:02 -07:00
|
|
|
if (isPhoneMode(mActivity.getDeviceProfile())) {
|
|
|
|
|
return getStashedHeight();
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-03 06:35:03 +00:00
|
|
|
if (supportsVisualStashing() && hasAnyFlag(FLAGS_REPORT_STASHED_INSETS_TO_APP)) {
|
2022-03-03 20:00:42 +00:00
|
|
|
DeviceProfile dp = mActivity.getDeviceProfile();
|
|
|
|
|
if (hasAnyFlag(FLAG_STASHED_IN_APP_SETUP) && dp.isTaskbarPresent && !dp.isLandscape) {
|
|
|
|
|
// We always show the back button in SUW but in portrait the SUW layout may not
|
|
|
|
|
// be wide enough to support overlapping the nav bar with its content. For now,
|
|
|
|
|
// just inset by the bar height.
|
|
|
|
|
return mUnstashedHeight;
|
|
|
|
|
}
|
2021-09-28 15:09:25 -07:00
|
|
|
boolean isAnimating = mAnimator != null && mAnimator.isStarted();
|
2022-01-25 00:12:36 +00:00
|
|
|
if (!mControllers.stashedHandleViewController.isStashedHandleVisible()
|
|
|
|
|
&& isInApp()
|
|
|
|
|
&& !isAnimating) {
|
|
|
|
|
// We are in a settled state where we're not showing the handle even though taskbar
|
|
|
|
|
// is stashed. This can happen for example when home button is disabled (see
|
|
|
|
|
// StashedHandleViewController#setIsHomeButtonDisabled()).
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return mStashedHeight;
|
2021-09-28 15:09:25 -07:00
|
|
|
}
|
|
|
|
|
return mUnstashedHeight;
|
2021-06-01 16:54:07 -07:00
|
|
|
}
|
|
|
|
|
|
2022-04-15 16:01:38 -07:00
|
|
|
/**
|
|
|
|
|
* Returns the height that taskbar will inset when inside apps.
|
|
|
|
|
* @see WindowInsets.Type#tappableElement()
|
|
|
|
|
*/
|
|
|
|
|
public int getTappableHeightToReportToApps() {
|
|
|
|
|
int contentHeight = getContentHeightToReportToApps();
|
|
|
|
|
return contentHeight <= mStashedHeight ? 0 : contentHeight;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-01 16:54:07 -07:00
|
|
|
public int getStashedHeight() {
|
|
|
|
|
return mStashedHeight;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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;
|
|
|
|
|
}
|
2022-02-11 00:22:35 +00:00
|
|
|
if (!canCurrentlyManuallyUnstash()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2021-10-07 15:49:19 -07:00
|
|
|
if (updateAndAnimateIsManuallyStashedInApp(false)) {
|
2021-06-01 16:54:07 -07:00
|
|
|
mControllers.taskbarActivityContext.getDragLayer().performHapticFeedback(LONG_PRESS);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-11 00:22:35 +00:00
|
|
|
/**
|
|
|
|
|
* 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);
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-01 16:54:07 -07:00
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
2021-10-07 15:49:19 -07:00
|
|
|
public boolean updateAndAnimateIsManuallyStashedInApp(boolean isManuallyStashedInApp) {
|
2021-09-22 13:58:10 -07:00
|
|
|
if (!supportsManualStashing()) {
|
2021-06-01 16:54:07 -07:00
|
|
|
return false;
|
|
|
|
|
}
|
2021-10-07 15:49:19 -07:00
|
|
|
if (hasAnyFlag(FLAG_STASHED_IN_APP_MANUAL) != isManuallyStashedInApp) {
|
|
|
|
|
mPrefs.edit().putBoolean(SHARED_PREFS_STASHED_KEY, isManuallyStashedInApp).apply();
|
|
|
|
|
updateStateForFlag(FLAG_STASHED_IN_APP_MANUAL, isManuallyStashedInApp);
|
2021-09-02 22:49:34 -07:00
|
|
|
applyState();
|
|
|
|
|
return true;
|
2021-06-01 16:54:07 -07:00
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-11 10:27:30 -07:00
|
|
|
/**
|
|
|
|
|
* Adds the Taskbar unstash to Hotseat animator to the animator set.
|
|
|
|
|
*
|
|
|
|
|
* This should be used to run a Taskbar unstash to Hotseat animation whose progress matches a
|
|
|
|
|
* swipe progress.
|
|
|
|
|
*
|
|
|
|
|
* @param placeholderDuration a placeholder duration to be used to ensure all full-length
|
|
|
|
|
* sub-animations are properly coordinated. This duration should not
|
|
|
|
|
* actually be used since this animation tracks a swipe progress.
|
|
|
|
|
*/
|
|
|
|
|
protected void addUnstashToHotseatAnimation(AnimatorSet animation, int placeholderDuration) {
|
|
|
|
|
createAnimToIsStashed(
|
|
|
|
|
/* isStashed= */ false,
|
|
|
|
|
placeholderDuration,
|
|
|
|
|
/* startDelay= */ 0,
|
|
|
|
|
/* animateBg= */ false);
|
|
|
|
|
animation.play(mAnimator);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-30 10:14:34 -07:00
|
|
|
/**
|
|
|
|
|
* Create a stash animation and save to {@link #mAnimator}.
|
|
|
|
|
* @param isStashed whether it's a stash animation or an unstash animation
|
|
|
|
|
* @param duration duration of the animation
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
* @param startDelay how many milliseconds to delay the animation after starting it.
|
2022-05-11 10:27:30 -07:00
|
|
|
* @param animateBg whether the taskbar's background should be animated
|
2021-09-30 10:14:34 -07:00
|
|
|
*/
|
2022-05-11 10:27:30 -07:00
|
|
|
private void createAnimToIsStashed(
|
|
|
|
|
boolean isStashed, long duration, long startDelay, boolean animateBg) {
|
2021-10-07 18:33:43 -07:00
|
|
|
if (mAnimator != null) {
|
|
|
|
|
mAnimator.cancel();
|
|
|
|
|
}
|
|
|
|
|
mAnimator = new AnimatorSet();
|
2022-04-27 08:39:02 +00:00
|
|
|
addJankMonitorListener(mAnimator, /* appearing= */ !mIsStashed);
|
2022-06-08 14:01:02 -07:00
|
|
|
final float stashTranslation = isPhoneMode(mActivity.getDeviceProfile()) ? 0 :
|
|
|
|
|
(mUnstashedHeight - mStashedHeight) / 2f;
|
2021-10-07 18:33:43 -07:00
|
|
|
|
|
|
|
|
if (!supportsVisualStashing()) {
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
// Just hide/show the icons and background instead of stashing into a handle.
|
2021-10-07 18:33:43 -07:00
|
|
|
mAnimator.play(mIconAlphaForStash.animateToValue(isStashed ? 0 : 1)
|
|
|
|
|
.setDuration(duration));
|
2022-06-08 14:01:02 -07:00
|
|
|
mAnimator.playTogether(mTaskbarBackgroundOffset.animateToValue(isStashed ? 1 : 0)
|
|
|
|
|
.setDuration(duration));
|
|
|
|
|
mAnimator.playTogether(mIconTranslationYForStash.animateToValue(isStashed ?
|
|
|
|
|
stashTranslation : 0)
|
|
|
|
|
.setDuration(duration));
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
mAnimator.play(mTaskbarImeBgAlpha.animateToValue(
|
|
|
|
|
hasAnyFlag(FLAG_STASHED_IN_APP_IME) ? 0 : 1).setDuration(duration));
|
|
|
|
|
mAnimator.setStartDelay(startDelay);
|
2021-11-19 23:52:18 +00:00
|
|
|
mAnimator.addListener(new AnimatorListenerAdapter() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
|
mAnimator = null;
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-09-30 10:14:34 -07:00
|
|
|
return;
|
2021-10-07 18:33:43 -07:00
|
|
|
}
|
|
|
|
|
|
2021-06-01 16:54:07 -07:00
|
|
|
AnimatorSet fullLengthAnimatorSet = new AnimatorSet();
|
|
|
|
|
// Not exactly half and may overlap. See [first|second]HalfDurationScale below.
|
|
|
|
|
AnimatorSet firstHalfAnimatorSet = new AnimatorSet();
|
|
|
|
|
AnimatorSet secondHalfAnimatorSet = new AnimatorSet();
|
|
|
|
|
|
|
|
|
|
final float firstHalfDurationScale;
|
|
|
|
|
final float secondHalfDurationScale;
|
|
|
|
|
|
|
|
|
|
if (isStashed) {
|
|
|
|
|
firstHalfDurationScale = 0.75f;
|
|
|
|
|
secondHalfDurationScale = 0.5f;
|
|
|
|
|
|
2022-05-11 10:27:30 -07:00
|
|
|
fullLengthAnimatorSet.play(mIconTranslationYForStash.animateToValue(stashTranslation));
|
|
|
|
|
if (animateBg) {
|
|
|
|
|
fullLengthAnimatorSet.play(mTaskbarBackgroundOffset.animateToValue(1));
|
|
|
|
|
} else {
|
|
|
|
|
fullLengthAnimatorSet.addListener(AnimatorListeners.forEndCallback(
|
|
|
|
|
() -> mTaskbarBackgroundOffset.updateValue(1)));
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-01 16:54:07 -07:00
|
|
|
firstHalfAnimatorSet.playTogether(
|
|
|
|
|
mIconAlphaForStash.animateToValue(0),
|
2022-06-08 14:01:02 -07:00
|
|
|
mIconScaleForStash.animateToValue(isPhoneMode(mActivity.getDeviceProfile()) ?
|
|
|
|
|
0 : STASHED_TASKBAR_SCALE)
|
2021-06-01 16:54:07 -07:00
|
|
|
);
|
|
|
|
|
secondHalfAnimatorSet.playTogether(
|
|
|
|
|
mTaskbarStashedHandleAlpha.animateToValue(1)
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
firstHalfDurationScale = 0.5f;
|
|
|
|
|
secondHalfDurationScale = 0.75f;
|
|
|
|
|
|
|
|
|
|
fullLengthAnimatorSet.playTogether(
|
|
|
|
|
mIconScaleForStash.animateToValue(1),
|
2022-05-11 10:27:30 -07:00
|
|
|
mIconTranslationYForStash.animateToValue(0));
|
|
|
|
|
if (animateBg) {
|
|
|
|
|
fullLengthAnimatorSet.play(mTaskbarBackgroundOffset.animateToValue(0));
|
|
|
|
|
} else {
|
|
|
|
|
fullLengthAnimatorSet.addListener(AnimatorListeners.forEndCallback(
|
|
|
|
|
() -> mTaskbarBackgroundOffset.updateValue(0)));
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-01 16:54:07 -07:00
|
|
|
firstHalfAnimatorSet.playTogether(
|
|
|
|
|
mTaskbarStashedHandleAlpha.animateToValue(0)
|
|
|
|
|
);
|
|
|
|
|
secondHalfAnimatorSet.playTogether(
|
|
|
|
|
mIconAlphaForStash.animateToValue(1)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
fullLengthAnimatorSet.play(mControllers.stashedHandleViewController
|
|
|
|
|
.createRevealAnimToIsStashed(isStashed));
|
2021-07-16 12:15:35 -10:00
|
|
|
// Return the stashed handle to its default scale in case it was changed as part of the
|
|
|
|
|
// feedforward hint. Note that the reveal animation above also visually scales it.
|
|
|
|
|
fullLengthAnimatorSet.play(mTaskbarStashedHandleHintScale.animateToValue(1f));
|
2021-06-01 16:54:07 -07:00
|
|
|
|
|
|
|
|
fullLengthAnimatorSet.setDuration(duration);
|
|
|
|
|
firstHalfAnimatorSet.setDuration((long) (duration * firstHalfDurationScale));
|
|
|
|
|
secondHalfAnimatorSet.setDuration((long) (duration * secondHalfDurationScale));
|
|
|
|
|
secondHalfAnimatorSet.setStartDelay((long) (duration * (1 - secondHalfDurationScale)));
|
|
|
|
|
|
|
|
|
|
mAnimator.playTogether(fullLengthAnimatorSet, firstHalfAnimatorSet,
|
|
|
|
|
secondHalfAnimatorSet);
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
mAnimator.setStartDelay(startDelay);
|
2021-06-01 16:54:07 -07:00
|
|
|
mAnimator.addListener(new AnimatorListenerAdapter() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onAnimationStart(Animator animation) {
|
|
|
|
|
mIsStashed = isStashed;
|
2022-04-15 16:01:38 -07:00
|
|
|
onIsStashedChanged(mIsStashed);
|
2021-06-01 16:54:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
|
mAnimator = null;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-07-16 12:15:35 -10:00
|
|
|
|
2022-04-27 08:39:02 +00:00
|
|
|
private void addJankMonitorListener(AnimatorSet animator, boolean expanding) {
|
|
|
|
|
Optional<View> optionalView =
|
|
|
|
|
Arrays.stream(mControllers.taskbarViewController.getIconViews()).findFirst();
|
|
|
|
|
if (optionalView.isEmpty()) {
|
|
|
|
|
Log.wtf(TAG, "No views to start Interaction jank monitor with.", new Exception());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
View v = optionalView.get();
|
|
|
|
|
int action = expanding ? InteractionJankMonitor.CUJ_TASKBAR_EXPAND :
|
|
|
|
|
InteractionJankMonitor.CUJ_TASKBAR_COLLAPSE;
|
|
|
|
|
animator.addListener(new AnimatorListenerAdapter() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onAnimationStart(@NonNull Animator animation) {
|
|
|
|
|
InteractionJankMonitor.getInstance().begin(v, action);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onAnimationEnd(@NonNull Animator animation) {
|
|
|
|
|
InteractionJankMonitor.getInstance().end(action);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-07-16 12:15:35 -10:00
|
|
|
/**
|
|
|
|
|
* 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) {
|
2021-09-22 13:58:10 -07:00
|
|
|
if (isStashed() || !supportsManualStashing()) {
|
2021-07-16 12:15:35 -10:00
|
|
|
// 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
|
|
|
|
|
* when long press is detected.
|
|
|
|
|
* @param animateForward Whether we are going towards the new unstashed state or returning to
|
|
|
|
|
* the stashed state.
|
|
|
|
|
*/
|
|
|
|
|
public void startUnstashHint(boolean animateForward) {
|
|
|
|
|
if (!isStashed()) {
|
|
|
|
|
// Already unstashed, no need to hint in that direction.
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-02-11 00:22:35 +00:00
|
|
|
if (!canCurrentlyManuallyUnstash()) {
|
|
|
|
|
// 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;
|
|
|
|
|
}
|
2021-07-16 12:15:35 -10:00
|
|
|
mTaskbarStashedHandleHintScale.animateToValue(
|
|
|
|
|
animateForward ? UNSTASHED_TASKBAR_HANDLE_HINT_SCALE : 1)
|
|
|
|
|
.setDuration(TASKBAR_HINT_STASH_DURATION).start();
|
|
|
|
|
}
|
2021-08-17 16:07:22 -07:00
|
|
|
|
2022-04-15 16:01:38 -07:00
|
|
|
private void onIsStashedChanged(boolean isStashed) {
|
2022-04-22 17:23:03 -07:00
|
|
|
mControllers.runAfterInit(() -> {
|
|
|
|
|
mControllers.stashedHandleViewController.onIsStashedChanged(isStashed);
|
|
|
|
|
mControllers.taskbarInsetsController.onTaskbarWindowHeightOrInsetsChanged();
|
|
|
|
|
});
|
2021-08-17 16:07:22 -07:00
|
|
|
}
|
2021-09-02 22:49:34 -07:00
|
|
|
|
|
|
|
|
public void applyState() {
|
2022-03-09 10:38:25 -08:00
|
|
|
applyState(hasAnyFlag(FLAG_IN_SETUP) ? 0 : TASKBAR_STASH_DURATION);
|
2021-09-02 22:49:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void applyState(long duration) {
|
2021-09-09 21:18:25 -07:00
|
|
|
mStatePropertyHolder.setState(mState, duration, true);
|
|
|
|
|
}
|
|
|
|
|
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
public void applyState(long duration, long startDelay) {
|
|
|
|
|
mStatePropertyHolder.setState(mState, duration, startDelay, true);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-09 21:18:25 -07:00
|
|
|
public Animator applyStateWithoutStart() {
|
|
|
|
|
return applyStateWithoutStart(TASKBAR_STASH_DURATION);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Animator applyStateWithoutStart(long duration) {
|
|
|
|
|
return mStatePropertyHolder.setState(mState, duration, false);
|
2021-09-02 22:49:34 -07:00
|
|
|
}
|
|
|
|
|
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
/**
|
|
|
|
|
* Should be called when a system gesture starts and settles, so we can defer updating
|
|
|
|
|
* FLAG_STASHED_IN_APP_IME until after the gesture transition completes.
|
|
|
|
|
*/
|
|
|
|
|
public void setSystemGestureInProgress(boolean inProgress) {
|
|
|
|
|
mIsSystemGestureInProgress = inProgress;
|
2022-04-06 15:58:38 -07:00
|
|
|
if (mIsSystemGestureInProgress) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Only update the following flags when system gesture is not in progress.
|
2022-06-24 10:51:10 -07:00
|
|
|
boolean shouldStashForIme = shouldStashForIme();
|
|
|
|
|
maybeResetStashedInAppAllApps(
|
|
|
|
|
hasAnyFlag(FLAG_STASHED_IN_APP_IME) == shouldStashForIme);
|
|
|
|
|
if (hasAnyFlag(FLAG_STASHED_IN_APP_IME) != shouldStashForIme) {
|
|
|
|
|
updateStateForFlag(FLAG_STASHED_IN_APP_IME, shouldStashForIme);
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
applyState(TASKBAR_STASH_DURATION_FOR_IME, getTaskbarStashStartDelayForIme());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-06 15:58:38 -07:00
|
|
|
/**
|
|
|
|
|
* Reset stashed in all apps only if no system gesture is in progress.
|
|
|
|
|
* <p>
|
|
|
|
|
* Otherwise, the reset should be deferred until after the gesture is finished.
|
|
|
|
|
*
|
|
|
|
|
* @see #setSystemGestureInProgress
|
|
|
|
|
*/
|
|
|
|
|
public void maybeResetStashedInAppAllApps() {
|
|
|
|
|
maybeResetStashedInAppAllApps(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void maybeResetStashedInAppAllApps(boolean applyState) {
|
|
|
|
|
if (mIsSystemGestureInProgress) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateStateForFlag(FLAG_STASHED_IN_APP_ALL_APPS, false);
|
|
|
|
|
if (applyState) {
|
2022-04-14 17:51:59 +01:00
|
|
|
applyState(ALL_APPS.getTransitionDuration(
|
|
|
|
|
mControllers.taskbarActivityContext, false /* isToState */));
|
2022-04-06 15:58:38 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
/**
|
|
|
|
|
* When hiding the IME, delay the unstash animation to align with the end of the transition.
|
|
|
|
|
*/
|
|
|
|
|
private long getTaskbarStashStartDelayForIme() {
|
|
|
|
|
if (mIsImeShowing) {
|
|
|
|
|
// Only delay when IME is exiting, not entering.
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
// This duration is based on input_method_extract_exit.xml.
|
|
|
|
|
long imeExitDuration = mControllers.taskbarActivityContext.getResources()
|
|
|
|
|
.getInteger(android.R.integer.config_shortAnimTime);
|
|
|
|
|
return imeExitDuration - TASKBAR_STASH_DURATION_FOR_IME;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-07 15:53:32 -07:00
|
|
|
/** Called when some system ui state has changed. (See SYSUI_STATE_... in QuickstepContract) */
|
2021-10-28 16:39:32 -07:00
|
|
|
public void updateStateForSysuiFlags(int systemUiStateFlags, boolean skipAnim) {
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
long animDuration = TASKBAR_STASH_DURATION;
|
|
|
|
|
long startDelay = 0;
|
|
|
|
|
|
2021-10-07 15:53:32 -07:00
|
|
|
updateStateForFlag(FLAG_STASHED_IN_APP_PINNED,
|
|
|
|
|
hasAnyFlag(systemUiStateFlags, SYSUI_STATE_SCREEN_PINNING));
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
|
|
|
|
|
// Only update FLAG_STASHED_IN_APP_IME when system gesture is not in progress.
|
|
|
|
|
mIsImeShowing = hasAnyFlag(systemUiStateFlags, SYSUI_STATE_IME_SHOWING);
|
2022-06-24 10:51:10 -07:00
|
|
|
mIsImeSwitcherShowing = hasAnyFlag(systemUiStateFlags, SYSUI_STATE_IME_SWITCHER_SHOWING);
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
if (!mIsSystemGestureInProgress) {
|
2022-06-24 10:51:10 -07:00
|
|
|
updateStateForFlag(FLAG_STASHED_IN_APP_IME, shouldStashForIme());
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
animDuration = TASKBAR_STASH_DURATION_FOR_IME;
|
|
|
|
|
startDelay = getTaskbarStashStartDelayForIme();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
applyState(skipAnim ? 0 : animDuration, skipAnim ? 0 : startDelay);
|
2021-10-07 15:53:32 -07:00
|
|
|
}
|
|
|
|
|
|
2022-06-24 10:51:10 -07:00
|
|
|
private boolean shouldStashForIme() {
|
|
|
|
|
return mIsImeShowing || mIsImeSwitcherShowing;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-02 22:49:34 -07:00
|
|
|
/**
|
|
|
|
|
* Updates the proper flag to indicate whether the task bar should be stashed.
|
|
|
|
|
*
|
|
|
|
|
* Note that this only updates the flag. {@link #applyState()} needs to be called separately.
|
|
|
|
|
*
|
|
|
|
|
* @param flag The flag to update.
|
|
|
|
|
* @param enabled Whether to enable the flag: True will cause the task bar to be stashed /
|
|
|
|
|
* unstashed.
|
|
|
|
|
*/
|
|
|
|
|
public void updateStateForFlag(int flag, boolean enabled) {
|
2022-04-06 14:24:20 -07:00
|
|
|
if (flag == FLAG_IN_APP && TestProtocol.sDebugTracing) {
|
|
|
|
|
Log.d(TestProtocol.TASKBAR_IN_APP_STATE, String.format(
|
|
|
|
|
"setting flag FLAG_IN_APP to: %b", enabled), new Exception());
|
|
|
|
|
}
|
2021-09-02 22:49:34 -07:00
|
|
|
if (enabled) {
|
|
|
|
|
mState |= flag;
|
|
|
|
|
} else {
|
|
|
|
|
mState &= ~flag;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-07 15:49:19 -07:00
|
|
|
/**
|
|
|
|
|
* Called after updateStateForFlag() and applyState() have been called.
|
|
|
|
|
* @param changedFlags The flags that have changed.
|
|
|
|
|
*/
|
|
|
|
|
private void onStateChangeApplied(int changedFlags) {
|
|
|
|
|
if (hasAnyFlag(changedFlags, FLAGS_STASHED_IN_APP)) {
|
|
|
|
|
mControllers.uiController.onStashedInAppChanged();
|
|
|
|
|
}
|
2022-03-09 10:38:25 -08:00
|
|
|
if (hasAnyFlag(changedFlags, FLAGS_STASHED_IN_APP | FLAGS_IN_APP)) {
|
|
|
|
|
notifyStashChange(/* visible */ hasAnyFlag(FLAGS_IN_APP),
|
2021-10-07 15:49:19 -07:00
|
|
|
/* stashed */ isStashedInApp());
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-21 15:31:51 +01:00
|
|
|
private void notifyStashChange(boolean visible, boolean stashed) {
|
|
|
|
|
mSystemUiProxy.notifyTaskbarStatus(visible, stashed);
|
2022-03-25 15:53:34 +08:00
|
|
|
// If stashing taskbar is caused by IME visibility, we could just skip updating rounded
|
|
|
|
|
// corner insets since the rounded corners will be covered by IME during IME is showing and
|
|
|
|
|
// taskbar will be restored back to unstashed when IME is hidden.
|
|
|
|
|
mControllers.taskbarActivityContext.updateInsetRoundedCornerFrame(
|
|
|
|
|
visible && !isStashedInAppIgnoringIme());
|
2021-10-21 15:31:51 +01:00
|
|
|
mControllers.rotationButtonController.onTaskbarStateChange(visible, stashed);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-15 13:09:39 -08:00
|
|
|
@Override
|
|
|
|
|
public void dumpLogs(String prefix, PrintWriter pw) {
|
|
|
|
|
pw.println(prefix + "TaskbarStashController:");
|
|
|
|
|
|
2022-06-23 11:25:10 -07:00
|
|
|
pw.println(prefix + "\tmStashedHeight=" + mStashedHeight);
|
|
|
|
|
pw.println(prefix + "\tmUnstashedHeight=" + mUnstashedHeight);
|
|
|
|
|
pw.println(prefix + "\tmIsStashed=" + mIsStashed);
|
|
|
|
|
pw.println(prefix + "\tappliedState=" + getStateString(mStatePropertyHolder.mPrevFlags));
|
|
|
|
|
pw.println(prefix + "\tmState=" + getStateString(mState));
|
|
|
|
|
pw.println(prefix + "\tmIsSystemGestureInProgress=" + mIsSystemGestureInProgress);
|
|
|
|
|
pw.println(prefix + "\tmIsImeShowing=" + mIsImeShowing);
|
|
|
|
|
pw.println(prefix + "\tmIsImeSwitcherShowing=" + mIsImeSwitcherShowing);
|
2021-12-15 13:09:39 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static String getStateString(int flags) {
|
|
|
|
|
StringJoiner str = new StringJoiner("|");
|
2022-03-31 15:35:20 -07:00
|
|
|
appendFlag(str, flags, FLAGS_IN_APP, "FLAG_IN_APP");
|
|
|
|
|
appendFlag(str, flags, FLAG_STASHED_IN_APP_MANUAL, "FLAG_STASHED_IN_APP_MANUAL");
|
|
|
|
|
appendFlag(str, flags, FLAG_STASHED_IN_APP_PINNED, "FLAG_STASHED_IN_APP_PINNED");
|
|
|
|
|
appendFlag(str, flags, FLAG_STASHED_IN_APP_EMPTY, "FLAG_STASHED_IN_APP_EMPTY");
|
|
|
|
|
appendFlag(str, flags, FLAG_STASHED_IN_APP_SETUP, "FLAG_STASHED_IN_APP_SETUP");
|
|
|
|
|
appendFlag(str, flags, FLAG_STASHED_IN_APP_IME, "FLAG_STASHED_IN_APP_IME");
|
|
|
|
|
appendFlag(str, flags, FLAG_IN_STASHED_LAUNCHER_STATE, "FLAG_IN_STASHED_LAUNCHER_STATE");
|
|
|
|
|
appendFlag(str, flags, FLAG_STASHED_IN_APP_ALL_APPS, "FLAG_STASHED_IN_APP_ALL_APPS");
|
|
|
|
|
appendFlag(str, flags, FLAG_IN_SETUP, "FLAG_IN_SETUP");
|
2021-12-15 13:09:39 -08:00
|
|
|
return str.toString();
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-02 22:49:34 -07:00
|
|
|
private class StatePropertyHolder {
|
|
|
|
|
private final IntPredicate mStashCondition;
|
|
|
|
|
|
|
|
|
|
private boolean mIsStashed;
|
2021-10-07 15:49:19 -07:00
|
|
|
private int mPrevFlags;
|
2021-09-02 22:49:34 -07:00
|
|
|
|
|
|
|
|
StatePropertyHolder(IntPredicate stashCondition) {
|
|
|
|
|
mStashCondition = stashCondition;
|
|
|
|
|
}
|
|
|
|
|
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
/**
|
|
|
|
|
* @see #setState(int, long, long, boolean) with a default startDelay = 0.
|
|
|
|
|
*/
|
2021-09-09 21:18:25 -07:00
|
|
|
public Animator setState(int flags, long duration, boolean start) {
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
return setState(flags, duration, 0 /* startDelay */, start);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Applies the latest state, potentially calling onStateChangeApplied() and creating a new
|
|
|
|
|
* animation (stored in mAnimator) which is started if {@param start} is true.
|
|
|
|
|
* @param flags The latest flags to apply (see the top of this file).
|
|
|
|
|
* @param duration The length of the animation.
|
|
|
|
|
* @param startDelay How long to delay the animation after calling start().
|
|
|
|
|
* @param start Whether to start mAnimator immediately.
|
|
|
|
|
* @return mAnimator if mIsStashed changed, else null.
|
|
|
|
|
*/
|
|
|
|
|
public Animator setState(int flags, long duration, long startDelay, boolean start) {
|
|
|
|
|
int changedFlags = mPrevFlags ^ flags;
|
2021-10-07 15:49:19 -07:00
|
|
|
if (mPrevFlags != flags) {
|
|
|
|
|
onStateChangeApplied(changedFlags);
|
|
|
|
|
mPrevFlags = flags;
|
|
|
|
|
}
|
2021-09-02 22:49:34 -07:00
|
|
|
boolean isStashed = mStashCondition.test(flags);
|
|
|
|
|
if (mIsStashed != isStashed) {
|
2022-04-06 14:24:20 -07:00
|
|
|
if (TestProtocol.sDebugTracing) {
|
|
|
|
|
Log.d(TestProtocol.TASKBAR_IN_APP_STATE, String.format(
|
|
|
|
|
"setState: mIsStashed=%b, isStashed=%b, duration=%d, start=:%b",
|
|
|
|
|
mIsStashed,
|
|
|
|
|
isStashed,
|
|
|
|
|
duration,
|
|
|
|
|
start));
|
|
|
|
|
}
|
2021-09-02 22:49:34 -07:00
|
|
|
mIsStashed = isStashed;
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
|
|
|
|
|
// This sets mAnimator.
|
2022-05-11 10:27:30 -07:00
|
|
|
createAnimToIsStashed(mIsStashed, duration, startDelay, /* animateBg= */ true);
|
2021-09-09 21:18:25 -07:00
|
|
|
if (start) {
|
2021-09-30 10:14:34 -07:00
|
|
|
mAnimator.start();
|
2021-09-09 21:18:25 -07:00
|
|
|
}
|
2021-09-30 10:14:34 -07:00
|
|
|
return mAnimator;
|
2021-09-02 22:49:34 -07:00
|
|
|
}
|
2021-09-30 10:14:34 -07:00
|
|
|
return null;
|
2021-09-02 22:49:34 -07:00
|
|
|
}
|
|
|
|
|
}
|
2021-06-01 16:54:07 -07:00
|
|
|
}
|