2021-11-08 00:48:53 -08: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 com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_APP;
|
|
|
|
|
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_STASHED_LAUNCHER_STATE;
|
|
|
|
|
import static com.android.launcher3.taskbar.TaskbarStashController.TASKBAR_STASH_DURATION;
|
|
|
|
|
import static com.android.launcher3.taskbar.TaskbarViewController.ALPHA_INDEX_HOME;
|
2022-06-09 15:09:26 +01:00
|
|
|
import static com.android.systemui.animation.Interpolators.EMPHASIZED;
|
2021-11-08 00:48:53 -08:00
|
|
|
|
|
|
|
|
import android.animation.Animator;
|
|
|
|
|
import android.animation.AnimatorListenerAdapter;
|
|
|
|
|
import android.animation.AnimatorSet;
|
|
|
|
|
import android.animation.ObjectAnimator;
|
2022-06-09 15:09:26 +01:00
|
|
|
import android.util.Log;
|
2021-11-08 00:48:53 -08:00
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
2022-03-28 23:58:36 -07:00
|
|
|
import androidx.annotation.Nullable;
|
2021-11-08 00:48:53 -08:00
|
|
|
|
2022-01-12 14:33:43 -08:00
|
|
|
import com.android.launcher3.AbstractFloatingView;
|
2022-08-05 17:29:22 +01:00
|
|
|
import com.android.launcher3.DeviceProfile;
|
2021-11-08 00:48:53 -08:00
|
|
|
import com.android.launcher3.LauncherState;
|
2022-06-09 15:09:26 +01:00
|
|
|
import com.android.launcher3.QuickstepTransitionManager;
|
2022-04-06 17:29:09 +00:00
|
|
|
import com.android.launcher3.Utilities;
|
2022-06-23 11:25:10 -07:00
|
|
|
import com.android.launcher3.anim.AnimatorListeners;
|
2021-11-08 00:48:53 -08:00
|
|
|
import com.android.launcher3.statemanager.StateManager;
|
2022-08-18 09:51:07 -07:00
|
|
|
import com.android.launcher3.uioverrides.QuickstepLauncher;
|
2022-10-21 11:25:07 -07:00
|
|
|
import com.android.launcher3.uioverrides.states.OverviewState;
|
2022-10-26 10:29:46 -07:00
|
|
|
import com.android.launcher3.util.MultiPropertyFactory.MultiProperty;
|
2021-11-08 00:48:53 -08:00
|
|
|
import com.android.quickstep.AnimatedFloat;
|
|
|
|
|
import com.android.quickstep.RecentsAnimationCallbacks;
|
|
|
|
|
import com.android.quickstep.RecentsAnimationController;
|
|
|
|
|
import com.android.quickstep.views.RecentsView;
|
2022-04-06 17:29:09 +00:00
|
|
|
import com.android.systemui.animation.ViewRootSync;
|
2021-11-08 00:48:53 -08:00
|
|
|
import com.android.systemui.shared.recents.model.ThumbnailData;
|
|
|
|
|
|
2022-03-07 12:49:56 -08:00
|
|
|
import java.io.PrintWriter;
|
2021-11-08 00:48:53 -08:00
|
|
|
import java.util.HashMap;
|
2022-03-07 12:49:56 -08:00
|
|
|
import java.util.StringJoiner;
|
2021-11-08 00:48:53 -08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Track LauncherState, RecentsAnimation, resumed state for task bar in one place here and animate
|
|
|
|
|
* the task bar accordingly.
|
|
|
|
|
*/
|
|
|
|
|
public class TaskbarLauncherStateController {
|
|
|
|
|
|
2022-06-09 15:09:26 +01:00
|
|
|
private static final String TAG = TaskbarLauncherStateController.class.getSimpleName();
|
|
|
|
|
private static final boolean DEBUG = false;
|
|
|
|
|
|
2021-11-08 00:48:53 -08:00
|
|
|
public static final int FLAG_RESUMED = 1 << 0;
|
|
|
|
|
public static final int FLAG_RECENTS_ANIMATION_RUNNING = 1 << 1;
|
2021-11-24 15:43:52 -08:00
|
|
|
public static final int FLAG_TRANSITION_STATE_RUNNING = 1 << 2;
|
2021-11-08 00:48:53 -08:00
|
|
|
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
private static final int FLAGS_LAUNCHER = FLAG_RESUMED | FLAG_RECENTS_ANIMATION_RUNNING;
|
2021-12-02 12:26:34 -08:00
|
|
|
/** Equivalent to an int with all 1s for binary operation purposes */
|
|
|
|
|
private static final int FLAGS_ALL = ~0;
|
|
|
|
|
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
private final AnimatedFloat mIconAlignment =
|
|
|
|
|
new AnimatedFloat(this::onIconAlignmentRatioChanged);
|
2021-11-08 00:48:53 -08:00
|
|
|
|
|
|
|
|
private TaskbarControllers mControllers;
|
|
|
|
|
private AnimatedFloat mTaskbarBackgroundAlpha;
|
2022-09-13 14:40:48 -07:00
|
|
|
private MultiProperty mIconAlphaForHome;
|
2022-08-18 09:51:07 -07:00
|
|
|
private QuickstepLauncher mLauncher;
|
2021-11-08 00:48:53 -08:00
|
|
|
|
2021-12-02 12:26:34 -08:00
|
|
|
private Integer mPrevState;
|
2021-11-08 00:48:53 -08:00
|
|
|
private int mState;
|
2021-11-24 15:43:52 -08:00
|
|
|
private LauncherState mLauncherState = LauncherState.NORMAL;
|
2021-11-08 00:48:53 -08:00
|
|
|
|
2022-03-28 23:58:36 -07:00
|
|
|
private @Nullable TaskBarRecentsAnimationListener mTaskBarRecentsAnimationListener;
|
|
|
|
|
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
private boolean mIsAnimatingToLauncher;
|
2021-11-08 00:48:53 -08:00
|
|
|
|
2021-12-12 11:16:29 +08:00
|
|
|
private boolean mShouldDelayLauncherStateAnim;
|
|
|
|
|
|
2022-04-06 17:29:09 +00:00
|
|
|
// We skip any view synchronizations during init/destroy.
|
|
|
|
|
private boolean mCanSyncViews;
|
|
|
|
|
|
2022-08-05 17:29:22 +01:00
|
|
|
private final DeviceProfile.OnDeviceProfileChangeListener mOnDeviceProfileChangeListener =
|
2022-09-13 14:40:48 -07:00
|
|
|
dp -> updateIconAlphaForHome(mIconAlphaForHome.getValue());
|
2022-08-05 17:29:22 +01:00
|
|
|
|
2021-11-08 00:48:53 -08:00
|
|
|
private final StateManager.StateListener<LauncherState> mStateListener =
|
|
|
|
|
new StateManager.StateListener<LauncherState>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onStateTransitionStart(LauncherState toState) {
|
2021-11-24 15:43:52 -08:00
|
|
|
if (toState != mLauncherState) {
|
|
|
|
|
// Treat FLAG_TRANSITION_STATE_RUNNING as a changed flag even if a previous
|
|
|
|
|
// state transition was already running, so we update the new target.
|
|
|
|
|
mPrevState &= ~FLAG_TRANSITION_STATE_RUNNING;
|
|
|
|
|
mLauncherState = toState;
|
|
|
|
|
}
|
|
|
|
|
updateStateForFlag(FLAG_TRANSITION_STATE_RUNNING, true);
|
2021-12-12 11:16:29 +08:00
|
|
|
if (!mShouldDelayLauncherStateAnim) {
|
2022-06-09 15:09:26 +01:00
|
|
|
if (toState == LauncherState.NORMAL) {
|
|
|
|
|
applyState(QuickstepTransitionManager.TASKBAR_TO_HOME_DURATION);
|
|
|
|
|
} else {
|
|
|
|
|
applyState();
|
|
|
|
|
}
|
2021-12-12 11:16:29 +08:00
|
|
|
}
|
2021-11-08 00:48:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onStateTransitionComplete(LauncherState finalState) {
|
2021-11-24 15:43:52 -08:00
|
|
|
mLauncherState = finalState;
|
|
|
|
|
updateStateForFlag(FLAG_TRANSITION_STATE_RUNNING, false);
|
2021-11-08 00:48:53 -08:00
|
|
|
applyState();
|
2022-10-21 11:25:07 -07:00
|
|
|
mControllers.taskbarDragController.setDisallowGlobalDrag(
|
|
|
|
|
(finalState instanceof OverviewState));
|
|
|
|
|
mControllers.taskbarDragController.setDisallowLongClick(
|
|
|
|
|
finalState == LauncherState.OVERVIEW_SPLIT_SELECT);
|
2021-11-08 00:48:53 -08:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2022-08-18 09:51:07 -07:00
|
|
|
public void init(TaskbarControllers controllers, QuickstepLauncher launcher) {
|
2022-04-06 17:29:09 +00:00
|
|
|
mCanSyncViews = false;
|
|
|
|
|
|
2021-11-08 00:48:53 -08:00
|
|
|
mControllers = controllers;
|
|
|
|
|
mLauncher = launcher;
|
|
|
|
|
|
|
|
|
|
mTaskbarBackgroundAlpha = mControllers.taskbarDragLayerController
|
|
|
|
|
.getTaskbarBackgroundAlpha();
|
2022-09-13 14:40:48 -07:00
|
|
|
mIconAlphaForHome = mControllers.taskbarViewController
|
|
|
|
|
.getTaskbarIconAlpha().get(ALPHA_INDEX_HOME);
|
2021-11-08 00:48:53 -08:00
|
|
|
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
mIconAlignment.finishAnimation();
|
|
|
|
|
onIconAlignmentRatioChanged();
|
2021-11-08 00:48:53 -08:00
|
|
|
|
|
|
|
|
mLauncher.getStateManager().addStateListener(mStateListener);
|
2021-12-14 19:08:55 +00:00
|
|
|
|
|
|
|
|
// Initialize to the current launcher state
|
|
|
|
|
updateStateForFlag(FLAG_RESUMED, launcher.hasBeenResumed());
|
|
|
|
|
mLauncherState = launcher.getStateManager().getState();
|
|
|
|
|
applyState(0);
|
2022-04-06 17:29:09 +00:00
|
|
|
|
|
|
|
|
mCanSyncViews = true;
|
2022-08-05 17:29:22 +01:00
|
|
|
mLauncher.addOnDeviceProfileChangeListener(mOnDeviceProfileChangeListener);
|
2021-11-08 00:48:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onDestroy() {
|
2022-04-06 17:29:09 +00:00
|
|
|
mCanSyncViews = false;
|
|
|
|
|
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
mIconAlignment.finishAnimation();
|
2021-11-08 00:48:53 -08:00
|
|
|
|
|
|
|
|
mLauncher.getHotseat().setIconsAlpha(1f);
|
|
|
|
|
mLauncher.getStateManager().removeStateListener(mStateListener);
|
2022-04-06 17:29:09 +00:00
|
|
|
|
|
|
|
|
mCanSyncViews = true;
|
2022-08-05 17:29:22 +01:00
|
|
|
mLauncher.removeOnDeviceProfileChangeListener(mOnDeviceProfileChangeListener);
|
2021-11-08 00:48:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Animator createAnimToLauncher(@NonNull LauncherState toState,
|
|
|
|
|
@NonNull RecentsAnimationCallbacks callbacks, long duration) {
|
|
|
|
|
// If going to overview, stash the task bar
|
|
|
|
|
// If going home, align the icons to hotseat
|
|
|
|
|
AnimatorSet animatorSet = new AnimatorSet();
|
|
|
|
|
|
2021-12-01 15:55:04 -08:00
|
|
|
// Update stashed flags first to ensure goingToUnstashedLauncherState() returns correctly.
|
2021-11-08 00:48:53 -08:00
|
|
|
TaskbarStashController stashController = mControllers.taskbarStashController;
|
|
|
|
|
stashController.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE,
|
2021-11-24 15:43:52 -08:00
|
|
|
toState.isTaskbarStashed(mLauncher));
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
if (DEBUG) {
|
|
|
|
|
Log.d(TAG, "createAnimToLauncher - FLAG_IN_APP: " + false);
|
|
|
|
|
}
|
2021-11-08 00:48:53 -08:00
|
|
|
stashController.updateStateForFlag(FLAG_IN_APP, false);
|
|
|
|
|
|
|
|
|
|
updateStateForFlag(FLAG_RECENTS_ANIMATION_RUNNING, true);
|
|
|
|
|
animatorSet.play(stashController.applyStateWithoutStart(duration));
|
|
|
|
|
animatorSet.play(applyState(duration, false));
|
|
|
|
|
|
2022-03-28 23:58:36 -07:00
|
|
|
mTaskBarRecentsAnimationListener = new TaskBarRecentsAnimationListener(callbacks);
|
|
|
|
|
callbacks.addListener(mTaskBarRecentsAnimationListener);
|
2022-06-13 12:09:35 -07:00
|
|
|
((RecentsView) mLauncher.getOverviewPanel()).setTaskLaunchListener(() ->
|
|
|
|
|
mTaskBarRecentsAnimationListener.endGestureStateOverride(true));
|
2021-11-08 00:48:53 -08:00
|
|
|
return animatorSet;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isAnimatingToLauncher() {
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
return mIsAnimatingToLauncher;
|
2021-11-08 00:48:53 -08:00
|
|
|
}
|
|
|
|
|
|
2021-12-12 11:16:29 +08:00
|
|
|
public void setShouldDelayLauncherStateAnim(boolean shouldDelayLauncherStateAnim) {
|
|
|
|
|
if (!shouldDelayLauncherStateAnim && mShouldDelayLauncherStateAnim) {
|
|
|
|
|
// Animate the animation we have delayed immediately. This is usually triggered when
|
|
|
|
|
// the user has released their finger.
|
|
|
|
|
applyState();
|
|
|
|
|
}
|
|
|
|
|
mShouldDelayLauncherStateAnim = shouldDelayLauncherStateAnim;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-08 00:48:53 -08:00
|
|
|
/**
|
|
|
|
|
* Updates the proper flag to change the state of the task bar.
|
|
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
|
|
|
|
public void updateStateForFlag(int flag, boolean enabled) {
|
|
|
|
|
if (enabled) {
|
|
|
|
|
mState |= flag;
|
|
|
|
|
} else {
|
|
|
|
|
mState &= ~flag;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean hasAnyFlag(int flagMask) {
|
|
|
|
|
return hasAnyFlag(mState, flagMask);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean hasAnyFlag(int flags, int flagMask) {
|
|
|
|
|
return (flags & flagMask) != 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void applyState() {
|
|
|
|
|
applyState(TASKBAR_STASH_DURATION);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void applyState(long duration) {
|
|
|
|
|
applyState(duration, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Animator applyState(boolean start) {
|
|
|
|
|
return applyState(TASKBAR_STASH_DURATION, start);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Animator applyState(long duration, boolean start) {
|
|
|
|
|
Animator animator = null;
|
2021-12-02 12:26:34 -08:00
|
|
|
if (mPrevState == null || mPrevState != mState) {
|
|
|
|
|
// If this is our initial state, treat all flags as changed.
|
|
|
|
|
int changedFlags = mPrevState == null ? FLAGS_ALL : mPrevState ^ mState;
|
2021-11-08 00:48:53 -08:00
|
|
|
mPrevState = mState;
|
2021-11-24 15:43:52 -08:00
|
|
|
animator = onStateChangeApplied(changedFlags, duration, start);
|
2021-11-08 00:48:53 -08:00
|
|
|
}
|
|
|
|
|
return animator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Animator onStateChangeApplied(int changedFlags, long duration, boolean start) {
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
boolean goingToLauncher = isInLauncher();
|
2022-10-26 10:29:46 -07:00
|
|
|
final float toAlignment = isIconAlignedWithHotseat() ? 1 : 0;
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
if (DEBUG) {
|
|
|
|
|
Log.d(TAG, "onStateChangeApplied - mState: " + getStateString(mState)
|
|
|
|
|
+ ", changedFlags: " + getStateString(changedFlags)
|
|
|
|
|
+ ", goingToLauncher: " + goingToLauncher
|
|
|
|
|
+ ", mLauncherState: " + mLauncherState
|
|
|
|
|
+ ", toAlignment: " + toAlignment);
|
|
|
|
|
}
|
2021-11-08 00:48:53 -08:00
|
|
|
AnimatorSet animatorSet = new AnimatorSet();
|
|
|
|
|
|
Update taskbar resume alignment anim if launcher state changes in the middle
One way to reproduce this issue is to run `adb shell input keyevent KEYCODE_HOME`, which happens to pause and immediately resume launcher. For example, let's say we run this while in All Apps. Because the isResumed=true comes before the state transition to Normal, we behave as if we are still going to All Apps, specifically goingToUnstashedState = false (since we stash in All Apps). To fix this, we now listen to state changes while the resume alignment animation is playing, and update it if necessary.
Also did the same correction for the gesture alignment animation, though I don't have a specific repo for that.
Finally, because there are now more triggers for alignment animations to play, we add a check to only play them if it's not animating to the same value it's already animating towards. One notable experience this improves is swiping down from All Apps to home; if you do it quick enough, the state animation ends before the taskbar unstash animation, and thus the unstash animation would cancel and start again with the full duration, making it look laggy/disjointed (this behavior existed before this change as well).
Test: TaplTestsQuickstep
Test: Go to All Apps, run `adb shell input keyevent KEYCODE_HOME`, open an app and ensure taskbar icons are visible
Test: Quick switch from home when taskbar is present in apps, but instead go to overview; ensure no jump when taskbar stashes
Test: Swipe down quickly from All Apps, ensure taskbar unstashing doesn't slow down when reaching the end of the state transition
Fixes: 214562370
Change-Id: Ie0c6140e14186e41c7e4748dc745f87349b084fe
2022-01-19 00:10:45 +00:00
|
|
|
// Add the state animation first to ensure FLAG_IN_STASHED_LAUNCHER_STATE is set and we can
|
|
|
|
|
// determine whether goingToUnstashedLauncherStateChanged.
|
|
|
|
|
if (hasAnyFlag(changedFlags, FLAG_TRANSITION_STATE_RUNNING)) {
|
|
|
|
|
boolean committed = !hasAnyFlag(FLAG_TRANSITION_STATE_RUNNING);
|
|
|
|
|
playStateTransitionAnim(animatorSet, duration, committed);
|
2021-11-08 00:48:53 -08:00
|
|
|
|
Update taskbar resume alignment anim if launcher state changes in the middle
One way to reproduce this issue is to run `adb shell input keyevent KEYCODE_HOME`, which happens to pause and immediately resume launcher. For example, let's say we run this while in All Apps. Because the isResumed=true comes before the state transition to Normal, we behave as if we are still going to All Apps, specifically goingToUnstashedState = false (since we stash in All Apps). To fix this, we now listen to state changes while the resume alignment animation is playing, and update it if necessary.
Also did the same correction for the gesture alignment animation, though I don't have a specific repo for that.
Finally, because there are now more triggers for alignment animations to play, we add a check to only play them if it's not animating to the same value it's already animating towards. One notable experience this improves is swiping down from All Apps to home; if you do it quick enough, the state animation ends before the taskbar unstash animation, and thus the unstash animation would cancel and start again with the full duration, making it look laggy/disjointed (this behavior existed before this change as well).
Test: TaplTestsQuickstep
Test: Go to All Apps, run `adb shell input keyevent KEYCODE_HOME`, open an app and ensure taskbar icons are visible
Test: Quick switch from home when taskbar is present in apps, but instead go to overview; ensure no jump when taskbar stashes
Test: Swipe down quickly from All Apps, ensure taskbar unstashing doesn't slow down when reaching the end of the state transition
Fixes: 214562370
Change-Id: Ie0c6140e14186e41c7e4748dc745f87349b084fe
2022-01-19 00:10:45 +00:00
|
|
|
if (committed && mLauncherState == LauncherState.QUICK_SWITCH) {
|
|
|
|
|
// We're about to be paused, set immediately to ensure seamless handoff.
|
|
|
|
|
updateStateForFlag(FLAG_RESUMED, false);
|
|
|
|
|
applyState(0 /* duration */);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
if (hasAnyFlag(changedFlags, FLAGS_LAUNCHER)) {
|
|
|
|
|
animatorSet.addListener(new AnimatorListenerAdapter() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
|
mIsAnimatingToLauncher = false;
|
|
|
|
|
}
|
Update taskbar resume alignment anim if launcher state changes in the middle
One way to reproduce this issue is to run `adb shell input keyevent KEYCODE_HOME`, which happens to pause and immediately resume launcher. For example, let's say we run this while in All Apps. Because the isResumed=true comes before the state transition to Normal, we behave as if we are still going to All Apps, specifically goingToUnstashedState = false (since we stash in All Apps). To fix this, we now listen to state changes while the resume alignment animation is playing, and update it if necessary.
Also did the same correction for the gesture alignment animation, though I don't have a specific repo for that.
Finally, because there are now more triggers for alignment animations to play, we add a check to only play them if it's not animating to the same value it's already animating towards. One notable experience this improves is swiping down from All Apps to home; if you do it quick enough, the state animation ends before the taskbar unstash animation, and thus the unstash animation would cancel and start again with the full duration, making it look laggy/disjointed (this behavior existed before this change as well).
Test: TaplTestsQuickstep
Test: Go to All Apps, run `adb shell input keyevent KEYCODE_HOME`, open an app and ensure taskbar icons are visible
Test: Quick switch from home when taskbar is present in apps, but instead go to overview; ensure no jump when taskbar stashes
Test: Swipe down quickly from All Apps, ensure taskbar unstashing doesn't slow down when reaching the end of the state transition
Fixes: 214562370
Change-Id: Ie0c6140e14186e41c7e4748dc745f87349b084fe
2022-01-19 00:10:45 +00:00
|
|
|
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
@Override
|
|
|
|
|
public void onAnimationStart(Animator animation) {
|
|
|
|
|
mIsAnimatingToLauncher = goingToLauncher;
|
Update taskbar resume alignment anim if launcher state changes in the middle
One way to reproduce this issue is to run `adb shell input keyevent KEYCODE_HOME`, which happens to pause and immediately resume launcher. For example, let's say we run this while in All Apps. Because the isResumed=true comes before the state transition to Normal, we behave as if we are still going to All Apps, specifically goingToUnstashedState = false (since we stash in All Apps). To fix this, we now listen to state changes while the resume alignment animation is playing, and update it if necessary.
Also did the same correction for the gesture alignment animation, though I don't have a specific repo for that.
Finally, because there are now more triggers for alignment animations to play, we add a check to only play them if it's not animating to the same value it's already animating towards. One notable experience this improves is swiping down from All Apps to home; if you do it quick enough, the state animation ends before the taskbar unstash animation, and thus the unstash animation would cancel and start again with the full duration, making it look laggy/disjointed (this behavior existed before this change as well).
Test: TaplTestsQuickstep
Test: Go to All Apps, run `adb shell input keyevent KEYCODE_HOME`, open an app and ensure taskbar icons are visible
Test: Quick switch from home when taskbar is present in apps, but instead go to overview; ensure no jump when taskbar stashes
Test: Swipe down quickly from All Apps, ensure taskbar unstashing doesn't slow down when reaching the end of the state transition
Fixes: 214562370
Change-Id: Ie0c6140e14186e41c7e4748dc745f87349b084fe
2022-01-19 00:10:45 +00:00
|
|
|
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
TaskbarStashController stashController =
|
|
|
|
|
mControllers.taskbarStashController;
|
|
|
|
|
if (DEBUG) {
|
|
|
|
|
Log.d(TAG, "onAnimationStart - FLAG_IN_APP: " + !goingToLauncher);
|
Update taskbar resume alignment anim if launcher state changes in the middle
One way to reproduce this issue is to run `adb shell input keyevent KEYCODE_HOME`, which happens to pause and immediately resume launcher. For example, let's say we run this while in All Apps. Because the isResumed=true comes before the state transition to Normal, we behave as if we are still going to All Apps, specifically goingToUnstashedState = false (since we stash in All Apps). To fix this, we now listen to state changes while the resume alignment animation is playing, and update it if necessary.
Also did the same correction for the gesture alignment animation, though I don't have a specific repo for that.
Finally, because there are now more triggers for alignment animations to play, we add a check to only play them if it's not animating to the same value it's already animating towards. One notable experience this improves is swiping down from All Apps to home; if you do it quick enough, the state animation ends before the taskbar unstash animation, and thus the unstash animation would cancel and start again with the full duration, making it look laggy/disjointed (this behavior existed before this change as well).
Test: TaplTestsQuickstep
Test: Go to All Apps, run `adb shell input keyevent KEYCODE_HOME`, open an app and ensure taskbar icons are visible
Test: Quick switch from home when taskbar is present in apps, but instead go to overview; ensure no jump when taskbar stashes
Test: Swipe down quickly from All Apps, ensure taskbar unstashing doesn't slow down when reaching the end of the state transition
Fixes: 214562370
Change-Id: Ie0c6140e14186e41c7e4748dc745f87349b084fe
2022-01-19 00:10:45 +00:00
|
|
|
}
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
stashController.updateStateForFlag(FLAG_IN_APP, !goingToLauncher);
|
|
|
|
|
stashController.applyState(duration);
|
2021-11-08 00:48:53 -08:00
|
|
|
}
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
});
|
2021-11-08 00:48:53 -08:00
|
|
|
|
2022-01-12 14:33:43 -08:00
|
|
|
if (goingToLauncher) {
|
|
|
|
|
// Handle closing open popups when going home/overview
|
|
|
|
|
AbstractFloatingView.closeAllOpenViews(mControllers.taskbarActivityContext);
|
|
|
|
|
}
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float backgroundAlpha =
|
|
|
|
|
goingToLauncher && mLauncherState.isTaskbarAlignedWithHotseat(mLauncher)
|
|
|
|
|
? 0 : 1;
|
|
|
|
|
// Don't animate if background has reached desired value.
|
|
|
|
|
if (mTaskbarBackgroundAlpha.isAnimating()
|
|
|
|
|
|| mTaskbarBackgroundAlpha.value != backgroundAlpha) {
|
|
|
|
|
mTaskbarBackgroundAlpha.cancelAnimation();
|
|
|
|
|
if (DEBUG) {
|
|
|
|
|
Log.d(TAG, "onStateChangeApplied - taskbarBackgroundAlpha - "
|
|
|
|
|
+ mTaskbarBackgroundAlpha.value
|
|
|
|
|
+ " -> " + backgroundAlpha + ": " + duration);
|
|
|
|
|
}
|
|
|
|
|
animatorSet.play(mTaskbarBackgroundAlpha.animateToValue(backgroundAlpha)
|
2021-12-02 12:26:34 -08:00
|
|
|
.setDuration(duration));
|
|
|
|
|
}
|
|
|
|
|
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
if (mIconAlignment.isAnimatingToValue(toAlignment)
|
|
|
|
|
|| mIconAlignment.isSettledOnValue(toAlignment)) {
|
|
|
|
|
// Already at desired value, but make sure we run the callback at the end.
|
|
|
|
|
animatorSet.addListener(AnimatorListeners.forEndCallback(
|
|
|
|
|
this::onIconAlignmentRatioChanged));
|
|
|
|
|
} else {
|
|
|
|
|
mIconAlignment.cancelAnimation();
|
|
|
|
|
ObjectAnimator iconAlignAnim = mIconAlignment
|
|
|
|
|
.animateToValue(toAlignment)
|
|
|
|
|
.setDuration(duration);
|
|
|
|
|
if (DEBUG) {
|
|
|
|
|
Log.d(TAG, "onStateChangeApplied - iconAlignment - "
|
|
|
|
|
+ mIconAlignment.value
|
|
|
|
|
+ " -> " + toAlignment + ": " + duration);
|
|
|
|
|
}
|
|
|
|
|
animatorSet.play(iconAlignAnim);
|
|
|
|
|
}
|
2022-06-09 15:09:26 +01:00
|
|
|
animatorSet.setInterpolator(EMPHASIZED);
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
|
2021-11-08 00:48:53 -08:00
|
|
|
if (start) {
|
|
|
|
|
animatorSet.start();
|
|
|
|
|
}
|
|
|
|
|
return animatorSet;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-01 15:55:04 -08:00
|
|
|
/** Returns whether we're going to a state where taskbar icons should align with launcher. */
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
public boolean goingToAlignedLauncherState() {
|
|
|
|
|
return mLauncherState.isTaskbarAlignedWithHotseat(mLauncher);
|
2021-12-01 15:55:04 -08:00
|
|
|
}
|
|
|
|
|
|
2022-10-26 10:29:46 -07:00
|
|
|
/**
|
|
|
|
|
* Returns if icons should be aligned to hotseat in the current transition
|
|
|
|
|
*/
|
|
|
|
|
public boolean isIconAlignedWithHotseat() {
|
|
|
|
|
if (isInLauncher()) {
|
|
|
|
|
boolean isInStashedState = mLauncherState.isTaskbarStashed(mLauncher);
|
|
|
|
|
boolean willStashVisually = isInStashedState
|
|
|
|
|
&& mControllers.taskbarStashController.supportsVisualStashing();
|
|
|
|
|
boolean isTaskbarAlignedWithHotseat =
|
|
|
|
|
mLauncherState.isTaskbarAlignedWithHotseat(mLauncher);
|
|
|
|
|
return isTaskbarAlignedWithHotseat && !willStashVisually;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-24 15:43:52 -08:00
|
|
|
private void playStateTransitionAnim(AnimatorSet animatorSet, long duration,
|
|
|
|
|
boolean committed) {
|
|
|
|
|
boolean isInStashedState = mLauncherState.isTaskbarStashed(mLauncher);
|
2022-06-23 11:25:10 -07:00
|
|
|
TaskbarStashController stashController = mControllers.taskbarStashController;
|
|
|
|
|
stashController.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE, isInStashedState);
|
|
|
|
|
Animator stashAnimator = stashController.applyStateWithoutStart(duration);
|
2021-11-08 00:48:53 -08:00
|
|
|
if (stashAnimator != null) {
|
|
|
|
|
stashAnimator.addListener(new AnimatorListenerAdapter() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
2021-11-24 15:43:52 -08:00
|
|
|
if (isInStashedState && committed) {
|
2021-11-08 00:48:53 -08:00
|
|
|
// Reset hotseat alpha to default
|
|
|
|
|
mLauncher.getHotseat().setIconsAlpha(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onAnimationStart(Animator animation) {
|
2021-12-02 12:26:34 -08:00
|
|
|
if (mLauncher.getHotseat().getIconsAlpha() > 0) {
|
2022-09-13 14:40:48 -07:00
|
|
|
updateIconAlphaForHome(mLauncher.getHotseat().getIconsAlpha());
|
2021-12-02 12:26:34 -08:00
|
|
|
}
|
2021-11-08 00:48:53 -08:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
animatorSet.play(stashAnimator);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
private boolean isInLauncher() {
|
|
|
|
|
return (mState & FLAGS_LAUNCHER) != 0;
|
2021-11-08 00:48:53 -08:00
|
|
|
}
|
|
|
|
|
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
private void onIconAlignmentRatioChanged() {
|
2022-04-06 17:29:09 +00:00
|
|
|
float currentValue = mIconAlphaForHome.getValue();
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
boolean taskbarWillBeVisible = mIconAlignment.value < 1;
|
2022-04-06 17:29:09 +00:00
|
|
|
boolean firstFrameVisChanged = (taskbarWillBeVisible && Float.compare(currentValue, 1) != 0)
|
|
|
|
|
|| (!taskbarWillBeVisible && Float.compare(currentValue, 0) != 0);
|
|
|
|
|
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
mControllers.taskbarViewController.setLauncherIconAlignment(
|
2022-10-26 10:29:46 -07:00
|
|
|
mIconAlignment.value, mLauncher.getDeviceProfile());
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
mControllers.navbarButtonsViewController.updateTaskbarAlignment(mIconAlignment.value);
|
|
|
|
|
// Switch taskbar and hotseat in last frame
|
2022-09-13 14:40:48 -07:00
|
|
|
updateIconAlphaForHome(taskbarWillBeVisible ? 1 : 0);
|
2022-05-20 13:32:10 +01:00
|
|
|
|
2022-04-06 17:29:09 +00:00
|
|
|
// Sync the first frame where we swap taskbar and hotseat.
|
|
|
|
|
if (firstFrameVisChanged && mCanSyncViews && !Utilities.IS_RUNNING_IN_TEST_HARNESS) {
|
|
|
|
|
ViewRootSync.synchronizeNextDraw(mLauncher.getHotseat(),
|
|
|
|
|
mControllers.taskbarActivityContext.getDragLayer(),
|
2022-05-20 13:32:10 +01:00
|
|
|
() -> {});
|
2022-04-06 17:29:09 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-13 14:40:48 -07:00
|
|
|
private void updateIconAlphaForHome(float alpha) {
|
|
|
|
|
mIconAlphaForHome.setValue(alpha);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Hide Launcher Hotseat icons when Taskbar icons have opacity. Both icon sets
|
|
|
|
|
* should not be visible at the same time.
|
|
|
|
|
*/
|
|
|
|
|
mLauncher.getHotseat().setIconsAlpha(alpha > 0 ? 0 : 1);
|
|
|
|
|
mLauncher.getHotseat().setQsbAlpha(
|
|
|
|
|
mLauncher.getDeviceProfile().isQsbInline && alpha > 0 ? 0 : 1);
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-08 00:48:53 -08:00
|
|
|
private final class TaskBarRecentsAnimationListener implements
|
|
|
|
|
RecentsAnimationCallbacks.RecentsAnimationListener {
|
|
|
|
|
private final RecentsAnimationCallbacks mCallbacks;
|
|
|
|
|
|
|
|
|
|
TaskBarRecentsAnimationListener(RecentsAnimationCallbacks callbacks) {
|
|
|
|
|
mCallbacks = callbacks;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onRecentsAnimationCanceled(HashMap<Integer, ThumbnailData> thumbnailDatas) {
|
2022-04-07 11:40:36 -07:00
|
|
|
boolean isInOverview = mLauncher.isInState(LauncherState.OVERVIEW);
|
|
|
|
|
endGestureStateOverride(!isInOverview);
|
2021-11-08 00:48:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onRecentsAnimationFinished(RecentsAnimationController controller) {
|
|
|
|
|
endGestureStateOverride(!controller.getFinishTargetIsLauncher());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void endGestureStateOverride(boolean finishedToApp) {
|
|
|
|
|
mCallbacks.removeListener(this);
|
2022-03-28 23:58:36 -07:00
|
|
|
mTaskBarRecentsAnimationListener = null;
|
2022-06-13 12:09:35 -07:00
|
|
|
((RecentsView) mLauncher.getOverviewPanel()).setTaskLaunchListener(null);
|
2021-12-01 15:08:23 -08:00
|
|
|
|
|
|
|
|
// Update the resumed state immediately to ensure a seamless handoff
|
|
|
|
|
boolean launcherResumed = !finishedToApp;
|
2021-11-08 00:48:53 -08:00
|
|
|
updateStateForFlag(FLAG_RECENTS_ANIMATION_RUNNING, false);
|
2021-12-01 15:08:23 -08:00
|
|
|
updateStateForFlag(FLAG_RESUMED, launcherResumed);
|
2021-11-08 00:48:53 -08:00
|
|
|
applyState();
|
2021-12-01 15:08:23 -08:00
|
|
|
|
2021-11-08 00:48:53 -08:00
|
|
|
TaskbarStashController controller = mControllers.taskbarStashController;
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
if (DEBUG) {
|
|
|
|
|
Log.d(TAG, "endGestureStateOverride - FLAG_IN_APP: " + finishedToApp);
|
|
|
|
|
}
|
2021-11-08 00:48:53 -08:00
|
|
|
controller.updateStateForFlag(FLAG_IN_APP, finishedToApp);
|
|
|
|
|
controller.applyState();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-03-07 12:49:56 -08:00
|
|
|
|
|
|
|
|
private static String getStateString(int flags) {
|
|
|
|
|
StringJoiner str = new StringJoiner("|");
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
if ((flags & FLAG_RESUMED) != 0) {
|
|
|
|
|
str.add("FLAG_RESUMED");
|
|
|
|
|
}
|
|
|
|
|
if ((flags & FLAG_RECENTS_ANIMATION_RUNNING) != 0) {
|
|
|
|
|
str.add("FLAG_RECENTS_ANIMATION_RUNNING");
|
|
|
|
|
}
|
|
|
|
|
if ((flags & FLAG_TRANSITION_STATE_RUNNING) != 0) {
|
|
|
|
|
str.add("FLAG_TRANSITION_STATE_RUNNING");
|
|
|
|
|
}
|
2022-03-07 12:49:56 -08:00
|
|
|
return str.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void dumpLogs(String prefix, PrintWriter pw) {
|
|
|
|
|
pw.println(prefix + "TaskbarLauncherStateController:");
|
|
|
|
|
pw.println(String.format(
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
"%s\tmIconAlignment=%.2f",
|
2022-03-07 12:49:56 -08:00
|
|
|
prefix,
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
mIconAlignment.value));
|
2022-03-07 12:49:56 -08:00
|
|
|
pw.println(String.format(
|
|
|
|
|
"%s\tmTaskbarBackgroundAlpha=%.2f", prefix, mTaskbarBackgroundAlpha.value));
|
|
|
|
|
pw.println(String.format(
|
|
|
|
|
"%s\tmIconAlphaForHome=%.2f", prefix, mIconAlphaForHome.getValue()));
|
|
|
|
|
pw.println(String.format("%s\tmPrevState=%s", prefix, getStateString(mPrevState)));
|
|
|
|
|
pw.println(String.format("%s\tmState=%s", prefix, getStateString(mState)));
|
|
|
|
|
pw.println(String.format("%s\tmLauncherState=%s", prefix, mLauncherState));
|
|
|
|
|
pw.println(String.format(
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
"%s\tmIsAnimatingToLauncher=%b",
|
2022-03-07 12:49:56 -08:00
|
|
|
prefix,
|
Refactor TaskbarLauncherStateController to use a single AnimatedFLoat
- Use a single iconAlignment animation
- Introduced isInLauncher/goingToLauncher/FLAGS_LAUNCHER as combined FLAG_RESUMED|FLAG_RECENTS_ANIMATION_RUNNING
- iconAlignment is now centralized in onStateChangeApplied with single source of truth
Bug: 245320601
Test: Home<->Overview, Home<->App, App<->Overview, Home->Overview->App->Home, Home->App->Overview->Home, Overview->Home->App->Overview, Overview->App->Home->Overview, App->Overview->Home->App, App->Home->Overview->App
Test: Go to AllApps, call KEYCODE_HOME, go to app and taskbar should be there
Test: App->Overview->Select->Home->App
Test: QuickSwitch -> App
Test: Repeat above with taskbarStashed on/off
Test: Repeat above with gesture and 3-button
Change-Id: Ie51b602394c155aca060a84585eb0e677e23425c
2022-09-30 18:14:33 +01:00
|
|
|
mIsAnimatingToLauncher));
|
2022-03-07 12:49:56 -08:00
|
|
|
pw.println(String.format(
|
|
|
|
|
"%s\tmShouldDelayLauncherStateAnim=%b", prefix, mShouldDelayLauncherStateAnim));
|
|
|
|
|
}
|
2021-11-08 00:48:53 -08:00
|
|
|
}
|