Merge "Slightly improve Taskbar animations to launcher" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0a74a35a41
@@ -335,6 +335,14 @@ public abstract class BaseQuickstepLauncher extends Launcher
|
||||
? new float[] {1, 1} : new float[] {1.1f, 0};
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getNormalTaskbarScale() {
|
||||
if (mTaskbarController != null) {
|
||||
return mTaskbarController.getTaskbarScaleOnHome();
|
||||
}
|
||||
return super.getNormalTaskbarScale();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDragLayerHierarchyChanged() {
|
||||
onLauncherStateOrFocusChanged();
|
||||
|
||||
+25
-6
@@ -20,20 +20,21 @@ import static com.android.launcher3.LauncherState.TASKBAR;
|
||||
import android.animation.Animator;
|
||||
|
||||
import com.android.launcher3.BaseQuickstepLauncher;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.quickstep.AnimatedFloat;
|
||||
import com.android.quickstep.SystemUiProxy;
|
||||
import com.android.systemui.shared.system.QuickStepContract;
|
||||
|
||||
/**
|
||||
* Works with TaskbarController to update the TaskbarView's alpha based on LauncherState, whether
|
||||
* Launcher is in the foreground, etc.
|
||||
* Works with TaskbarController to update the TaskbarView's visual properties based on factors such
|
||||
* as LauncherState, whether Launcher is in the foreground, etc.
|
||||
*/
|
||||
public class TaskbarVisibilityController {
|
||||
public class TaskbarAnimationController {
|
||||
|
||||
private static final long IME_VISIBILITY_ALPHA_DURATION = 120;
|
||||
|
||||
private final BaseQuickstepLauncher mLauncher;
|
||||
private final TaskbarController.TaskbarVisibilityControllerCallbacks mTaskbarCallbacks;
|
||||
private final TaskbarController.TaskbarAnimationControllerCallbacks mTaskbarCallbacks;
|
||||
|
||||
// Background alpha.
|
||||
private final AnimatedFloat mTaskbarBackgroundAlpha = new AnimatedFloat(
|
||||
@@ -45,8 +46,12 @@ public class TaskbarVisibilityController {
|
||||
private final AnimatedFloat mTaskbarVisibilityAlphaForIme = new AnimatedFloat(
|
||||
this::updateVisibilityAlpha);
|
||||
|
||||
public TaskbarVisibilityController(BaseQuickstepLauncher launcher,
|
||||
TaskbarController.TaskbarVisibilityControllerCallbacks taskbarCallbacks) {
|
||||
// Scale.
|
||||
private final AnimatedFloat mTaskbarScaleForLauncherState = new AnimatedFloat(
|
||||
this::updateScale);
|
||||
|
||||
public TaskbarAnimationController(BaseQuickstepLauncher launcher,
|
||||
TaskbarController.TaskbarAnimationControllerCallbacks taskbarCallbacks) {
|
||||
mLauncher = launcher;
|
||||
mTaskbarCallbacks = taskbarCallbacks;
|
||||
}
|
||||
@@ -72,6 +77,10 @@ public class TaskbarVisibilityController {
|
||||
return mTaskbarVisibilityAlphaForLauncherState;
|
||||
}
|
||||
|
||||
protected AnimatedFloat getTaskbarScaleForLauncherState() {
|
||||
return mTaskbarScaleForLauncherState;
|
||||
}
|
||||
|
||||
protected Animator createAnimToBackgroundAlpha(float toAlpha, long duration) {
|
||||
return mTaskbarBackgroundAlpha.animateToValue(mTaskbarBackgroundAlpha.value, toAlpha)
|
||||
.setDuration(duration);
|
||||
@@ -85,6 +94,7 @@ public class TaskbarVisibilityController {
|
||||
private void onTaskbarBackgroundAlphaChanged() {
|
||||
mTaskbarCallbacks.updateTaskbarBackgroundAlpha(mTaskbarBackgroundAlpha.value);
|
||||
updateVisibilityAlpha();
|
||||
updateScale();
|
||||
}
|
||||
|
||||
private void updateVisibilityAlpha() {
|
||||
@@ -101,6 +111,15 @@ public class TaskbarVisibilityController {
|
||||
setNavBarButtonAlpha(1f - taskbarAlpha);
|
||||
}
|
||||
|
||||
private void updateScale() {
|
||||
// We use mTaskbarBackgroundAlpha as a proxy for whether Launcher is resumed/paused, the
|
||||
// assumption being that Taskbar should always be at scale 1f regardless of the current
|
||||
// LauncherState if Launcher is paused.
|
||||
float scale = mTaskbarScaleForLauncherState.value;
|
||||
scale = Utilities.mapRange(mTaskbarBackgroundAlpha.value, scale, 1f);
|
||||
mTaskbarCallbacks.updateTaskbarScale(scale);
|
||||
}
|
||||
|
||||
private void setNavBarButtonAlpha(float navBarAlpha) {
|
||||
SystemUiProxy.INSTANCE.get(mLauncher).setNavBarButtonAlpha(navBarAlpha, false);
|
||||
}
|
||||
@@ -19,8 +19,6 @@ import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
|
||||
|
||||
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
|
||||
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
||||
import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_BOTTOM_TAPPABLE_ELEMENT;
|
||||
import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_EXTRA_NAVIGATION_BAR;
|
||||
|
||||
@@ -75,7 +73,7 @@ public class TaskbarController {
|
||||
// Layout width and height of the Taskbar in the default state.
|
||||
private final Point mTaskbarSize;
|
||||
private final TaskbarStateHandler mTaskbarStateHandler;
|
||||
private final TaskbarVisibilityController mTaskbarVisibilityController;
|
||||
private final TaskbarAnimationController mTaskbarAnimationController;
|
||||
private final TaskbarHotseatController mHotseatController;
|
||||
private final TaskbarRecentsController mRecentsController;
|
||||
private final TaskbarDragController mDragController;
|
||||
@@ -104,8 +102,8 @@ public class TaskbarController {
|
||||
mWindowManager = mLauncher.getWindowManager();
|
||||
mTaskbarSize = new Point(MATCH_PARENT, mLauncher.getDeviceProfile().taskbarSize);
|
||||
mTaskbarStateHandler = mLauncher.getTaskbarStateHandler();
|
||||
mTaskbarVisibilityController = new TaskbarVisibilityController(mLauncher,
|
||||
createTaskbarVisibilityControllerCallbacks());
|
||||
mTaskbarAnimationController = new TaskbarAnimationController(mLauncher,
|
||||
createTaskbarAnimationControllerCallbacks());
|
||||
mHotseatController = new TaskbarHotseatController(mLauncher,
|
||||
createTaskbarHotseatControllerCallbacks());
|
||||
mRecentsController = new TaskbarRecentsController(mLauncher,
|
||||
@@ -113,8 +111,8 @@ public class TaskbarController {
|
||||
mDragController = new TaskbarDragController(mLauncher);
|
||||
}
|
||||
|
||||
private TaskbarVisibilityControllerCallbacks createTaskbarVisibilityControllerCallbacks() {
|
||||
return new TaskbarVisibilityControllerCallbacks() {
|
||||
private TaskbarAnimationControllerCallbacks createTaskbarAnimationControllerCallbacks() {
|
||||
return new TaskbarAnimationControllerCallbacks() {
|
||||
@Override
|
||||
public void updateTaskbarBackgroundAlpha(float alpha) {
|
||||
mTaskbarViewInApp.setBackgroundAlpha(alpha);
|
||||
@@ -125,6 +123,12 @@ public class TaskbarController {
|
||||
mTaskbarContainerView.setAlpha(alpha);
|
||||
mTaskbarViewOnHome.setAlpha(alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTaskbarScale(float scale) {
|
||||
mTaskbarViewInApp.setScaleX(scale);
|
||||
mTaskbarViewInApp.setScaleY(scale);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -242,12 +246,10 @@ public class TaskbarController {
|
||||
mTaskbarContainerView.init(mTaskbarViewInApp);
|
||||
addToWindowManager();
|
||||
mTaskbarStateHandler.setTaskbarCallbacks(createTaskbarStateHandlerCallbacks());
|
||||
mTaskbarVisibilityController.init();
|
||||
mTaskbarAnimationController.init();
|
||||
mHotseatController.init();
|
||||
mRecentsController.init();
|
||||
|
||||
SCALE_PROPERTY.set(mTaskbarViewInApp, mLauncher.hasBeenResumed()
|
||||
? getTaskbarScaleOnHome() : 1f);
|
||||
updateWhichTaskbarViewIsVisible();
|
||||
}
|
||||
|
||||
@@ -255,7 +257,12 @@ public class TaskbarController {
|
||||
return new TaskbarStateHandlerCallbacks() {
|
||||
@Override
|
||||
public AnimatedFloat getAlphaTarget() {
|
||||
return mTaskbarVisibilityController.getTaskbarVisibilityForLauncherState();
|
||||
return mTaskbarAnimationController.getTaskbarVisibilityForLauncherState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnimatedFloat getScaleTarget() {
|
||||
return mTaskbarAnimationController.getTaskbarScaleForLauncherState();
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -274,7 +281,7 @@ public class TaskbarController {
|
||||
mTaskbarContainerView.cleanup();
|
||||
removeFromWindowManager();
|
||||
mTaskbarStateHandler.setTaskbarCallbacks(null);
|
||||
mTaskbarVisibilityController.cleanup();
|
||||
mTaskbarAnimationController.cleanup();
|
||||
mHotseatController.cleanup();
|
||||
mRecentsController.cleanup();
|
||||
}
|
||||
@@ -342,12 +349,10 @@ public class TaskbarController {
|
||||
*/
|
||||
public Animator createAnimToLauncher(@Nullable LauncherState toState, long duration) {
|
||||
PendingAnimation anim = new PendingAnimation(duration);
|
||||
anim.add(mTaskbarVisibilityController.createAnimToBackgroundAlpha(0, duration));
|
||||
anim.add(mTaskbarAnimationController.createAnimToBackgroundAlpha(0, duration));
|
||||
if (toState != null) {
|
||||
mTaskbarStateHandler.setStateWithAnimation(toState, new StateAnimationConfig(), anim);
|
||||
}
|
||||
anim.addFloat(mTaskbarViewInApp, SCALE_PROPERTY, mTaskbarViewInApp.getScaleX(),
|
||||
getTaskbarScaleOnHome(), LINEAR);
|
||||
|
||||
anim.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
@@ -368,8 +373,7 @@ public class TaskbarController {
|
||||
|
||||
private Animator createAnimToApp(long duration) {
|
||||
PendingAnimation anim = new PendingAnimation(duration);
|
||||
anim.add(mTaskbarVisibilityController.createAnimToBackgroundAlpha(1, duration));
|
||||
anim.addFloat(mTaskbarViewInApp, SCALE_PROPERTY, mTaskbarViewInApp.getScaleX(), 1f, LINEAR);
|
||||
anim.add(mTaskbarAnimationController.createAnimToBackgroundAlpha(1, duration));
|
||||
anim.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
@@ -390,7 +394,7 @@ public class TaskbarController {
|
||||
* Should be called when the IME visibility changes, so we can hide/show Taskbar accordingly.
|
||||
*/
|
||||
public void setIsImeVisible(boolean isImeVisible) {
|
||||
mTaskbarVisibilityController.animateToVisibilityForIme(isImeVisible ? 0 : 1);
|
||||
mTaskbarAnimationController.animateToVisibilityForIme(isImeVisible ? 0 : 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -527,15 +531,17 @@ public class TaskbarController {
|
||||
*/
|
||||
protected interface TaskbarStateHandlerCallbacks {
|
||||
AnimatedFloat getAlphaTarget();
|
||||
AnimatedFloat getScaleTarget();
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains methods that TaskbarVisibilityController can call to interface with
|
||||
* Contains methods that TaskbarAnimationController can call to interface with
|
||||
* TaskbarController.
|
||||
*/
|
||||
protected interface TaskbarVisibilityControllerCallbacks {
|
||||
protected interface TaskbarAnimationControllerCallbacks {
|
||||
void updateTaskbarBackgroundAlpha(float alpha);
|
||||
void updateTaskbarVisibilityAlpha(float alpha);
|
||||
void updateTaskbarScale(float scale);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,8 +53,10 @@ public class TaskbarStateHandler implements StateManager.StateHandler<LauncherSt
|
||||
}
|
||||
|
||||
AnimatedFloat alphaTarget = mTaskbarCallbacks.getAlphaTarget();
|
||||
AnimatedFloat scaleTarget = mTaskbarCallbacks.getScaleTarget();
|
||||
boolean isTaskbarVisible = (state.getVisibleElements(mLauncher) & TASKBAR) != 0;
|
||||
alphaTarget.updateValue(isTaskbarVisible ? 1f : 0f);
|
||||
scaleTarget.updateValue(state.getTaskbarScale(mLauncher));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,7 +67,10 @@ public class TaskbarStateHandler implements StateManager.StateHandler<LauncherSt
|
||||
}
|
||||
|
||||
AnimatedFloat alphaTarget = mTaskbarCallbacks.getAlphaTarget();
|
||||
AnimatedFloat scaleTarget = mTaskbarCallbacks.getScaleTarget();
|
||||
boolean isTaskbarVisible = (toState.getVisibleElements(mLauncher) & TASKBAR) != 0;
|
||||
animation.setFloat(alphaTarget, AnimatedFloat.VALUE, isTaskbarVisible ? 1f : 0f, LINEAR);
|
||||
animation.setFloat(scaleTarget, AnimatedFloat.VALUE, toState.getTaskbarScale(mLauncher),
|
||||
LINEAR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +82,11 @@ public class OverviewState extends LauncherState {
|
||||
return new float[] {NO_SCALE, NO_OFFSET};
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTaskbarScale(Launcher launcher) {
|
||||
return 1f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) {
|
||||
return new PageAlphaProvider(DEACCEL_2) {
|
||||
|
||||
@@ -101,6 +101,7 @@ import com.android.quickstep.util.MotionPauseDetector;
|
||||
import com.android.quickstep.util.ProtoTracer;
|
||||
import com.android.quickstep.util.RecentsOrientedState;
|
||||
import com.android.quickstep.util.RectFSpringAnim;
|
||||
import com.android.quickstep.util.StaggeredWorkspaceAnim;
|
||||
import com.android.quickstep.util.SurfaceTransactionApplier;
|
||||
import com.android.quickstep.util.SwipePipToHomeAnimator;
|
||||
import com.android.quickstep.util.TransformParams;
|
||||
@@ -197,7 +198,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
|
||||
STATE_LAUNCHER_PRESENT | STATE_LAUNCHER_DRAWN | STATE_LAUNCHER_STARTED;
|
||||
|
||||
public static final long MAX_SWIPE_DURATION = 350;
|
||||
public static final long MIN_OVERSHOOT_DURATION = 120;
|
||||
public static final long HOME_DURATION = StaggeredWorkspaceAnim.DURATION_MS;
|
||||
|
||||
public static final float MIN_PROGRESS_FOR_OVERVIEW = 0.7f;
|
||||
private static final float SWIPE_DURATION_MULTIPLIER =
|
||||
@@ -947,7 +948,7 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
|
||||
mInputConsumerProxy.enable();
|
||||
}
|
||||
if (endTarget == HOME) {
|
||||
duration = Math.max(MIN_OVERSHOOT_DURATION, duration);
|
||||
duration = HOME_DURATION;
|
||||
} else if (endTarget == RECENTS) {
|
||||
if (mRecentsView != null) {
|
||||
int nearestPage = mRecentsView.getDestinationPage();
|
||||
|
||||
@@ -60,7 +60,10 @@ import com.android.systemui.plugins.ResourceProvider;
|
||||
public class StaggeredWorkspaceAnim {
|
||||
|
||||
private static final int APP_CLOSE_ROW_START_DELAY_MS = 10;
|
||||
// How long it takes to fade in each staggered row.
|
||||
private static final int ALPHA_DURATION_MS = 250;
|
||||
// Should be used for animations running alongside this StaggeredWorkspaceAnim.
|
||||
public static final int DURATION_MS = 250;
|
||||
|
||||
private static final float MAX_VELOCITY_PX_PER_S = 22f;
|
||||
|
||||
@@ -131,15 +134,15 @@ public class StaggeredWorkspaceAnim {
|
||||
}
|
||||
|
||||
if (animateOverviewScrim) {
|
||||
PendingAnimation pendingAnimation = new PendingAnimation(ALPHA_DURATION_MS);
|
||||
PendingAnimation pendingAnimation = new PendingAnimation(DURATION_MS);
|
||||
addScrimAnimationForState(launcher, NORMAL, pendingAnimation);
|
||||
mAnimators.play(pendingAnimation.buildAnim());
|
||||
}
|
||||
|
||||
addDepthAnimationForState(launcher, NORMAL, ALPHA_DURATION_MS);
|
||||
addDepthAnimationForState(launcher, NORMAL, DURATION_MS);
|
||||
|
||||
mAnimators.play(launcher.getDragLayer().getSysUiScrim().createSysuiMultiplierAnim(0f, 1f)
|
||||
.setDuration(ALPHA_DURATION_MS));
|
||||
.setDuration(DURATION_MS));
|
||||
mAnimators.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
|
||||
@@ -2763,6 +2763,13 @@ public class Launcher extends StatefulActivity<LauncherState> implements Launche
|
||||
return new float[] {NO_SCALE, NO_OFFSET};
|
||||
}
|
||||
|
||||
/**
|
||||
* @see LauncherState#getTaskbarScale(Launcher)
|
||||
*/
|
||||
public float getNormalTaskbarScale() {
|
||||
return 1f;
|
||||
}
|
||||
|
||||
public static Launcher getLauncher(Context context) {
|
||||
return fromContext(context);
|
||||
}
|
||||
|
||||
@@ -176,6 +176,10 @@ public abstract class LauncherState implements BaseState<LauncherState> {
|
||||
return launcher.getNormalOverviewScaleAndOffset();
|
||||
}
|
||||
|
||||
public float getTaskbarScale(Launcher launcher) {
|
||||
return launcher.getNormalTaskbarScale();
|
||||
}
|
||||
|
||||
public float getOverviewFullscreenProgress() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user