summaryrefslogtreecommitdiff
path: root/quickstep/src/com/android/launcher3/taskbar/TaskbarStateHandler.java
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2020-12-23 16:12:18 -0600
committerTony Wickham <twickham@google.com>2021-01-29 21:22:00 +0000
commitd683d98b34ffa75111f556f3b6950e89ba1fd13c (patch)
tree3f6856fbff608c15bf2ba9ad26230a32ec812871 /quickstep/src/com/android/launcher3/taskbar/TaskbarStateHandler.java
parentd4629656980f3d8d3b62ca50c784c27b137060fc (diff)
Animate taskbar background alpha and visibility alpha
Setup codepath to animate the Taskbar when going to and from Launcher, primarily by listening for pause/resume signals but also hints from gesture nav and AppToOverviewAnimationProvider. Additionally, add TaskbarStateHandler to listen for Launcher state changes if Taskbar is enabled. Combined, the end behavior is: - Background alpha is 0 when Launcher is resumed, and 1 when Launcher is paused (we can make this animation more interesting later). - Taskbar is always visible when Launcher is paused, otherwise its visibility is determined by multiple factors: LauncherState and whether the IME is showing. Bug: 171917176 Change-Id: I7856fc979931c9d12d714dee11d179fd1b5a6968
Diffstat (limited to 'quickstep/src/com/android/launcher3/taskbar/TaskbarStateHandler.java')
-rw-r--r--quickstep/src/com/android/launcher3/taskbar/TaskbarStateHandler.java77
1 files changed, 77 insertions, 0 deletions
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStateHandler.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStateHandler.java
new file mode 100644
index 0000000000..b4b5d8b3fe
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStateHandler.java
@@ -0,0 +1,77 @@
+/*
+ * 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.LauncherState.TASKBAR;
+import static com.android.launcher3.states.StateAnimationConfig.ANIM_TASKBAR_FADE;
+import static com.android.launcher3.states.StateAnimationConfig.SKIP_TASKBAR;
+
+import androidx.annotation.Nullable;
+
+import com.android.launcher3.BaseQuickstepLauncher;
+import com.android.launcher3.LauncherState;
+import com.android.launcher3.anim.Interpolators;
+import com.android.launcher3.anim.PendingAnimation;
+import com.android.launcher3.statemanager.StateManager;
+import com.android.launcher3.states.StateAnimationConfig;
+import com.android.quickstep.AnimatedFloat;
+
+/**
+ * StateHandler to animate Taskbar according to Launcher's state machine. Does nothing if Taskbar
+ * isn't present (i.e. {@link #setTaskbarCallbacks} is never called).
+ */
+public class TaskbarStateHandler implements StateManager.StateHandler<LauncherState> {
+
+ private final BaseQuickstepLauncher mLauncher;
+
+ // Contains Taskbar-related methods and fields we should aniamte. If null, don't do anything.
+ private @Nullable TaskbarController.TaskbarStateHandlerCallbacks mTaskbarCallbacks = null;
+
+ public TaskbarStateHandler(BaseQuickstepLauncher launcher) {
+ mLauncher = launcher;
+ }
+
+ public void setTaskbarCallbacks(TaskbarController.TaskbarStateHandlerCallbacks callbacks) {
+ mTaskbarCallbacks = callbacks;
+ }
+
+ @Override
+ public void setState(LauncherState state) {
+ if (mTaskbarCallbacks == null) {
+ return;
+ }
+
+ AnimatedFloat alphaTarget = mTaskbarCallbacks.getAlphaTarget();
+ boolean isTaskbarVisible = (state.getVisibleElements(mLauncher) & TASKBAR) != 0;
+ alphaTarget.updateValue(isTaskbarVisible ? 1f : 0f);
+ }
+
+ @Override
+ public void setStateWithAnimation(LauncherState toState, StateAnimationConfig config,
+ PendingAnimation animation) {
+ if (mTaskbarCallbacks == null) {
+ return;
+ }
+ if (config.hasAnimationFlag(SKIP_TASKBAR)) {
+ return;
+ }
+
+ AnimatedFloat alphaTarget = mTaskbarCallbacks.getAlphaTarget();
+ boolean isTaskbarVisible = (toState.getVisibleElements(mLauncher) & TASKBAR) != 0;
+ animation.setFloat(alphaTarget, AnimatedFloat.VALUE, isTaskbarVisible ? 1f : 0f,
+ config.getInterpolator(ANIM_TASKBAR_FADE, Interpolators.LINEAR));
+ }
+}