Merge "Implement spring animations for running state changes." into main

This commit is contained in:
Treehugger Robot authored and Android (Google) Code Review committed 2025-03-26 21:06:14 -07:00
commit b932dea54e
8 files changed
+517 -126

No files matched your search

@@ -25,7 +25,6 @@ import static android.window.DesktopModeFlags.ENABLE_TASKBAR_RECENTS_LAYOUT_TRAN
import static com.android.app.animation.Interpolators.EMPHASIZED;
import static com.android.app.animation.Interpolators.FINAL_FRAME;
import static com.android.app.animation.Interpolators.LINEAR;
import static com.android.launcher3.BubbleTextView.LINE_INDICATOR_ANIM_DURATION;
import static com.android.launcher3.Flags.enableScalingRevealHomeAnimation;
import static com.android.launcher3.Flags.taskbarOverflow;
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
@@ -137,11 +136,9 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
private static final float ERROR_POSITION_IN_HOTSEAT_NOT_FOUND = -100;
private static final int TRANSITION_DELAY = 50;
private static final int TRANSITION_DEFAULT_DURATION = 500;
static final int TRANSITION_DEFAULT_DURATION = 500;
private static final int TRANSITION_FADE_IN_DURATION = 167;
private static final int TRANSITION_FADE_OUT_DURATION = 83;
private static final int APPEARING_LINE_INDICATOR_ANIM_DELAY =
TRANSITION_DEFAULT_DURATION - LINE_INDICATOR_ANIM_DURATION;
private final TaskbarActivityContext mActivity;
private @Nullable TaskbarDragLayerController mDragLayerController;
@@ -225,6 +222,8 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
private final float mTaskbarLeftRightMargin;
private final TaskbarRunningAppStateAnimationController mRunningStateController;
public TaskbarViewController(TaskbarActivityContext activity, TaskbarView taskbarView) {
mActivity = activity;
mTransientTaskbarDp = mActivity.getTransientTaskbarDeviceProfile();
@@ -243,6 +242,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
mIsRtl = Utilities.isRtl(mTaskbarView.getResources());
mTaskbarLeftRightMargin = mActivity.getResources().getDimensionPixelSize(
R.dimen.transient_taskbar_padding);
mRunningStateController = new TaskbarRunningAppStateAnimationController(mActivity);
}
/**
@@ -396,6 +396,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
}
LauncherAppState.getInstance(mActivity).getModel().removeCallbacks(mModelCallbacks);
mActivity.removeOnDeviceProfileChangeListener(mDeviceProfileChangeListener);
mRunningStateController.onDestroy();
}
/**
@@ -781,7 +782,10 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
}
private void updateRunningState(BubbleTextView btv) {
btv.updateRunningState(getRunningAppState(btv), mTaskbarView.getLayoutTransition() != null);
mRunningStateController.updateRunningState(
btv,
getRunningAppState(btv),
/* animate = */ mTaskbarView.getLayoutTransition() != null);
}
private BubbleTextView.RunningAppState getRunningAppState(BubbleTextView btv) {
@@ -1241,10 +1245,6 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
view.setAlpha(0f);
view.setScaleX(0f);
view.setScaleY(0f);
if (view instanceof BubbleTextView btv) {
// Defer so that app is mostly scaled in before showing indicator.
btv.setLineIndicatorAnimStartDelay(APPEARING_LINE_INDICATOR_ANIM_DELAY);
}
} else if (type == DISAPPEARING && view instanceof BubbleTextView btv) {
// Running state updates happen after removing this view, so update it here.
updateRunningState(btv);
@@ -1254,9 +1254,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar
@Override
public void endTransition(
LayoutTransition transition, ViewGroup container, View view, int type) {
if (type == APPEARING && view instanceof BubbleTextView btv) {
btv.setLineIndicatorAnimStartDelay(0);
}
// Do nothing.
}
});