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;
|
|
|
|
|
|
|
|
|
|
import android.animation.Animator;
|
|
|
|
|
import android.animation.AnimatorListenerAdapter;
|
|
|
|
|
import android.animation.AnimatorSet;
|
|
|
|
|
import android.animation.ObjectAnimator;
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
|
2022-01-12 14:33:43 -08:00
|
|
|
import com.android.launcher3.AbstractFloatingView;
|
2021-11-08 00:48:53 -08:00
|
|
|
import com.android.launcher3.BaseQuickstepLauncher;
|
|
|
|
|
import com.android.launcher3.LauncherState;
|
|
|
|
|
import com.android.launcher3.statemanager.StateManager;
|
|
|
|
|
import com.android.launcher3.util.MultiValueAlpha;
|
|
|
|
|
import com.android.quickstep.AnimatedFloat;
|
|
|
|
|
import com.android.quickstep.RecentsAnimationCallbacks;
|
|
|
|
|
import com.android.quickstep.RecentsAnimationController;
|
|
|
|
|
import com.android.quickstep.views.RecentsView;
|
|
|
|
|
import com.android.systemui.shared.recents.model.ThumbnailData;
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.function.Consumer;
|
|
|
|
|
import java.util.function.Supplier;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Track LauncherState, RecentsAnimation, resumed state for task bar in one place here and animate
|
|
|
|
|
* the task bar accordingly.
|
|
|
|
|
*/
|
|
|
|
|
public class TaskbarLauncherStateController {
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
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;
|
|
|
|
|
|
2021-11-08 00:48:53 -08:00
|
|
|
private final AnimatedFloat mIconAlignmentForResumedState =
|
2021-12-02 12:26:34 -08:00
|
|
|
new AnimatedFloat(this::onIconAlignmentRatioChangedForAppAndHomeTransition);
|
2021-11-08 00:48:53 -08:00
|
|
|
private final AnimatedFloat mIconAlignmentForGestureState =
|
2021-12-02 12:26:34 -08:00
|
|
|
new AnimatedFloat(this::onIconAlignmentRatioChangedForAppAndHomeTransition);
|
2021-11-08 00:48:53 -08:00
|
|
|
private final AnimatedFloat mIconAlignmentForLauncherState =
|
|
|
|
|
new AnimatedFloat(this::onIconAlignmentRatioChangedForStateTransition);
|
|
|
|
|
|
|
|
|
|
private TaskbarControllers mControllers;
|
|
|
|
|
private AnimatedFloat mTaskbarBackgroundAlpha;
|
|
|
|
|
private MultiValueAlpha.AlphaProperty mIconAlphaForHome;
|
|
|
|
|
private BaseQuickstepLauncher mLauncher;
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
private boolean mIsAnimatingToLauncherViaGesture;
|
|
|
|
|
private boolean mIsAnimatingToLauncherViaResume;
|
|
|
|
|
|
2021-12-12 11:16:29 +08:00
|
|
|
private boolean mShouldDelayLauncherStateAnim;
|
|
|
|
|
|
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) {
|
|
|
|
|
applyState();
|
|
|
|
|
}
|
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();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public void init(TaskbarControllers controllers, BaseQuickstepLauncher launcher) {
|
|
|
|
|
mControllers = controllers;
|
|
|
|
|
mLauncher = launcher;
|
|
|
|
|
|
|
|
|
|
mTaskbarBackgroundAlpha = mControllers.taskbarDragLayerController
|
|
|
|
|
.getTaskbarBackgroundAlpha();
|
|
|
|
|
MultiValueAlpha taskbarIconAlpha = mControllers.taskbarViewController.getTaskbarIconAlpha();
|
|
|
|
|
mIconAlphaForHome = taskbarIconAlpha.getProperty(ALPHA_INDEX_HOME);
|
|
|
|
|
mIconAlphaForHome.setConsumer(
|
|
|
|
|
(Consumer<Float>) alpha -> mLauncher.getHotseat().setIconsAlpha(alpha > 0 ? 0 : 1));
|
|
|
|
|
|
|
|
|
|
mIconAlignmentForResumedState.finishAnimation();
|
2021-12-02 12:26:34 -08:00
|
|
|
onIconAlignmentRatioChangedForAppAndHomeTransition();
|
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);
|
2021-11-08 00:48:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onDestroy() {
|
|
|
|
|
mIconAlignmentForResumedState.finishAnimation();
|
|
|
|
|
mIconAlignmentForGestureState.finishAnimation();
|
|
|
|
|
mIconAlignmentForLauncherState.finishAnimation();
|
|
|
|
|
|
2021-11-16 11:07:37 -08:00
|
|
|
mIconAlphaForHome.setConsumer(null);
|
2021-11-08 00:48:53 -08:00
|
|
|
mLauncher.getHotseat().setIconsAlpha(1f);
|
|
|
|
|
mLauncher.getStateManager().removeStateListener(mStateListener);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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));
|
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));
|
|
|
|
|
|
|
|
|
|
TaskBarRecentsAnimationListener listener = new TaskBarRecentsAnimationListener(callbacks);
|
|
|
|
|
callbacks.addListener(listener);
|
|
|
|
|
RecentsView recentsView = mLauncher.getOverviewPanel();
|
|
|
|
|
recentsView.setTaskLaunchListener(() -> {
|
|
|
|
|
listener.endGestureStateOverride(true);
|
|
|
|
|
callbacks.removeListener(listener);
|
|
|
|
|
});
|
|
|
|
|
return animatorSet;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isAnimatingToLauncher() {
|
|
|
|
|
return mIsAnimatingToLauncherViaResume || mIsAnimatingToLauncherViaGesture;
|
|
|
|
|
}
|
|
|
|
|
|
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) {
|
|
|
|
|
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.
|
|
|
|
|
boolean wasGoingToUnstashedLauncherState = goingToUnstashedLauncherState();
|
|
|
|
|
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 */);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
boolean goingToUnstashedLauncherStateChanged = wasGoingToUnstashedLauncherState
|
|
|
|
|
!= goingToUnstashedLauncherState();
|
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
|
|
|
boolean launcherStateChangedDuringAnimToResumeAlignment =
|
|
|
|
|
mIconAlignmentForResumedState.isAnimating() && goingToUnstashedLauncherStateChanged;
|
|
|
|
|
if (hasAnyFlag(changedFlags, FLAG_RESUMED)
|
|
|
|
|
|| launcherStateChangedDuringAnimToResumeAlignment) {
|
|
|
|
|
boolean isResumed = isResumed();
|
|
|
|
|
float toAlignmentForResumedState = isResumed && goingToUnstashedLauncherState() ? 1 : 0;
|
|
|
|
|
// If we're already animating to the value, just leave it be instead of restarting it.
|
|
|
|
|
if (!mIconAlignmentForResumedState.isAnimatingToValue(toAlignmentForResumedState)) {
|
|
|
|
|
ObjectAnimator resumeAlignAnim = mIconAlignmentForResumedState
|
|
|
|
|
.animateToValue(toAlignmentForResumedState)
|
|
|
|
|
.setDuration(duration);
|
|
|
|
|
|
|
|
|
|
resumeAlignAnim.addListener(new AnimatorListenerAdapter() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
|
mIsAnimatingToLauncherViaResume = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onAnimationStart(Animator animation) {
|
|
|
|
|
mIsAnimatingToLauncherViaResume = isResumed;
|
|
|
|
|
|
|
|
|
|
TaskbarStashController stashController =
|
|
|
|
|
mControllers.taskbarStashController;
|
|
|
|
|
stashController.updateStateForFlag(FLAG_IN_APP, !isResumed);
|
|
|
|
|
stashController.applyState(duration);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
animatorSet.play(resumeAlignAnim);
|
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
boolean launcherStateChangedDuringAnimToGestureAlignment =
|
|
|
|
|
mIconAlignmentForGestureState.isAnimating() && goingToUnstashedLauncherStateChanged;
|
|
|
|
|
if (hasAnyFlag(changedFlags, FLAG_RECENTS_ANIMATION_RUNNING)
|
|
|
|
|
|| launcherStateChangedDuringAnimToGestureAlignment) {
|
2021-11-08 00:48:53 -08:00
|
|
|
boolean isRecentsAnimationRunning = isRecentsAnimationRunning();
|
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
|
|
|
float toAlignmentForGestureState = isRecentsAnimationRunning
|
|
|
|
|
&& goingToUnstashedLauncherState() ? 1 : 0;
|
|
|
|
|
// If we're already animating to the value, just leave it be instead of restarting it.
|
|
|
|
|
if (!mIconAlignmentForGestureState.isAnimatingToValue(toAlignmentForGestureState)) {
|
|
|
|
|
Animator gestureAlignAnim = mIconAlignmentForGestureState
|
|
|
|
|
.animateToValue(toAlignmentForGestureState);
|
|
|
|
|
if (isRecentsAnimationRunning) {
|
|
|
|
|
gestureAlignAnim.setDuration(duration);
|
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
|
|
|
gestureAlignAnim.addListener(new AnimatorListenerAdapter() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
|
mIsAnimatingToLauncherViaGesture = false;
|
|
|
|
|
}
|
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
|
|
|
@Override
|
|
|
|
|
public void onAnimationStart(Animator animation) {
|
|
|
|
|
mIsAnimatingToLauncherViaGesture = isRecentsAnimationRunning();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
animatorSet.play(gestureAlignAnim);
|
|
|
|
|
}
|
2021-11-08 00:48:53 -08:00
|
|
|
}
|
|
|
|
|
|
2021-12-02 12:26:34 -08:00
|
|
|
if (hasAnyFlag(changedFlags, FLAG_RESUMED | FLAG_RECENTS_ANIMATION_RUNNING)) {
|
|
|
|
|
boolean goingToLauncher = hasAnyFlag(FLAG_RESUMED | FLAG_RECENTS_ANIMATION_RUNNING);
|
2022-01-12 14:33:43 -08:00
|
|
|
if (goingToLauncher) {
|
|
|
|
|
// Handle closing open popups when going home/overview
|
|
|
|
|
AbstractFloatingView.closeAllOpenViews(mControllers.taskbarActivityContext);
|
|
|
|
|
}
|
2021-12-02 12:26:34 -08:00
|
|
|
animatorSet.play(mTaskbarBackgroundAlpha.animateToValue(goingToLauncher ? 0 : 1)
|
|
|
|
|
.setDuration(duration));
|
|
|
|
|
}
|
|
|
|
|
|
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. */
|
|
|
|
|
private boolean goingToUnstashedLauncherState() {
|
|
|
|
|
return !mControllers.taskbarStashController.isInStashedLauncherState();
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-24 15:43:52 -08:00
|
|
|
private void playStateTransitionAnim(AnimatorSet animatorSet, long duration,
|
|
|
|
|
boolean committed) {
|
|
|
|
|
boolean isInStashedState = mLauncherState.isTaskbarStashed(mLauncher);
|
|
|
|
|
float toAlignment = mLauncherState.isTaskbarAlignedWithHotseat(mLauncher) ? 1 : 0;
|
|
|
|
|
|
2021-11-08 00:48:53 -08:00
|
|
|
TaskbarStashController controller = mControllers.taskbarStashController;
|
2021-11-24 15:43:52 -08:00
|
|
|
controller.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE, isInStashedState);
|
2021-11-08 00:48:53 -08:00
|
|
|
Animator stashAnimator = controller.applyStateWithoutStart(duration);
|
|
|
|
|
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) {
|
|
|
|
|
mIconAlphaForHome.setValue(mLauncher.getHotseat().getIconsAlpha());
|
|
|
|
|
}
|
2021-11-08 00:48:53 -08:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
animatorSet.play(stashAnimator);
|
|
|
|
|
}
|
2021-11-24 15:43:52 -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 we're already animating to the value, just leave it be instead of restarting it.
|
|
|
|
|
if (!mIconAlignmentForLauncherState.isAnimatingToValue(toAlignment)) {
|
|
|
|
|
animatorSet.play(mIconAlignmentForLauncherState.animateToValue(toAlignment)
|
|
|
|
|
.setDuration(duration));
|
|
|
|
|
}
|
2021-11-08 00:48:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean isResumed() {
|
|
|
|
|
return (mState & FLAG_RESUMED) != 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean isRecentsAnimationRunning() {
|
|
|
|
|
return (mState & FLAG_RECENTS_ANIMATION_RUNNING) != 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onIconAlignmentRatioChangedForStateTransition() {
|
2021-12-02 12:26:34 -08:00
|
|
|
if (!isResumed()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-11-24 15:40:40 -08:00
|
|
|
onIconAlignmentRatioChanged(this::getCurrentIconAlignmentRatioForLauncherState);
|
2021-11-08 00:48:53 -08:00
|
|
|
}
|
|
|
|
|
|
2021-12-02 12:26:34 -08:00
|
|
|
private void onIconAlignmentRatioChangedForAppAndHomeTransition() {
|
|
|
|
|
onIconAlignmentRatioChanged(this::getCurrentIconAlignmentRatioBetweenAppAndHome);
|
2021-11-08 00:48:53 -08:00
|
|
|
}
|
|
|
|
|
|
2021-11-24 15:40:40 -08:00
|
|
|
private void onIconAlignmentRatioChanged(Supplier<Float> alignmentSupplier) {
|
2021-11-08 00:48:53 -08:00
|
|
|
if (mControllers == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
float alignment = alignmentSupplier.get();
|
|
|
|
|
mControllers.taskbarViewController.setLauncherIconAlignment(
|
|
|
|
|
alignment, mLauncher.getDeviceProfile());
|
|
|
|
|
|
2021-11-24 15:40:40 -08:00
|
|
|
// Switch taskbar and hotseat in last frame
|
|
|
|
|
setTaskbarViewVisible(alignment < 1);
|
2021-11-08 00:48:53 -08:00
|
|
|
}
|
|
|
|
|
|
2021-12-02 12:26:34 -08:00
|
|
|
private float getCurrentIconAlignmentRatioBetweenAppAndHome() {
|
2021-11-08 00:48:53 -08:00
|
|
|
return Math.max(mIconAlignmentForResumedState.value, mIconAlignmentForGestureState.value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private float getCurrentIconAlignmentRatioForLauncherState() {
|
|
|
|
|
return mIconAlignmentForLauncherState.value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setTaskbarViewVisible(boolean isVisible) {
|
|
|
|
|
mIconAlphaForHome.setValue(isVisible ? 1 : 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private final class TaskBarRecentsAnimationListener implements
|
|
|
|
|
RecentsAnimationCallbacks.RecentsAnimationListener {
|
|
|
|
|
private final RecentsAnimationCallbacks mCallbacks;
|
|
|
|
|
|
|
|
|
|
TaskBarRecentsAnimationListener(RecentsAnimationCallbacks callbacks) {
|
|
|
|
|
mCallbacks = callbacks;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onRecentsAnimationCanceled(HashMap<Integer, ThumbnailData> thumbnailDatas) {
|
|
|
|
|
endGestureStateOverride(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onRecentsAnimationFinished(RecentsAnimationController controller) {
|
|
|
|
|
endGestureStateOverride(!controller.getFinishTargetIsLauncher());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void endGestureStateOverride(boolean finishedToApp) {
|
|
|
|
|
mCallbacks.removeListener(this);
|
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-10 18:20:13 +00:00
|
|
|
// Set this last because applyState() might also animate it.
|
|
|
|
|
mIconAlignmentForResumedState.cancelAnimation();
|
|
|
|
|
mIconAlignmentForResumedState.updateValue(launcherResumed ? 1 : 0);
|
2021-12-01 15:08:23 -08:00
|
|
|
|
2021-11-08 00:48:53 -08:00
|
|
|
TaskbarStashController controller = mControllers.taskbarStashController;
|
|
|
|
|
controller.updateStateForFlag(FLAG_IN_APP, finishedToApp);
|
|
|
|
|
controller.applyState();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|