diff options
author | Jon Miranda <jonmiranda@google.com> | 2022-04-08 01:39:42 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2022-04-08 01:39:42 +0000 |
commit | 812feca9efc090b496510ae47f96754cdc10baaf (patch) | |
tree | b2f4ee25dcdc65ab638cfe193fecfd0e80034497 | |
parent | 342446d1052d2cd2c00c44f946c01b51f4363411 (diff) | |
parent | 27f9559203ce84e1eb9a24964ea8516c859a3f85 (diff) | |
download | Launcher3-812feca9efc090b496510ae47f96754cdc10baaf.tar.gz |
Merge "Revert "Revert "Sync hotseat/taskbar handoff""" into tm-dev
-rw-r--r-- | Android.bp | 3 | ||||
-rw-r--r-- | quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java | 35 | ||||
-rw-r--r-- | quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java | 14 |
3 files changed, 49 insertions, 3 deletions
diff --git a/Android.bp b/Android.bp index 5a153a7d12..b3027bc440 100644 --- a/Android.bp +++ b/Android.bp @@ -31,6 +31,7 @@ android_library { "androidx.test.uiautomator_uiautomator", "androidx.preference_preference", "SystemUISharedLib", + "SystemUIAnimationLib", ], srcs: [ "tests/tapl/**/*.java", @@ -196,6 +197,7 @@ android_library { "lottie", "SystemUISharedLib", "SystemUI-statsd", + "SystemUIAnimationLib", ], manifest: "quickstep/AndroidManifest.xml", min_sdk_version: "current", @@ -304,6 +306,7 @@ android_library { "SystemUISharedLib", "Launcher3CommonDepsLib", "QuickstepResLib", + "SystemUIAnimationLib", ], manifest: "quickstep/AndroidManifest.xml", platform_apis: true, diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java index ebe6a04611..235a156fb5 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java @@ -29,13 +29,16 @@ import androidx.annotation.NonNull; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.BaseQuickstepLauncher; +import com.android.launcher3.DeviceProfile; import com.android.launcher3.LauncherState; +import com.android.launcher3.Utilities; 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.animation.ViewRootSync; import com.android.systemui.shared.recents.model.ThumbnailData; import java.util.HashMap; @@ -76,6 +79,9 @@ import java.util.function.Supplier; private boolean mShouldDelayLauncherStateAnim; + // We skip any view synchronizations during init/destroy. + private boolean mCanSyncViews; + private final StateManager.StateListener<LauncherState> mStateListener = new StateManager.StateListener<LauncherState>() { @@ -102,6 +108,8 @@ import java.util.function.Supplier; }; public void init(TaskbarControllers controllers, BaseQuickstepLauncher launcher) { + mCanSyncViews = false; + mControllers = controllers; mLauncher = launcher; @@ -121,9 +129,13 @@ import java.util.function.Supplier; updateStateForFlag(FLAG_RESUMED, launcher.hasBeenResumed()); mLauncherState = launcher.getStateManager().getState(); applyState(0); + + mCanSyncViews = true; } public void onDestroy() { + mCanSyncViews = false; + mIconAlignmentForResumedState.finishAnimation(); mIconAlignmentForGestureState.finishAnimation(); mIconAlignmentForLauncherState.finishAnimation(); @@ -131,6 +143,8 @@ import java.util.function.Supplier; mIconAlphaForHome.setConsumer(null); mLauncher.getHotseat().setIconsAlpha(1f); mLauncher.getStateManager().removeStateListener(mStateListener); + + mCanSyncViews = true; } public Animator createAnimToLauncher(@NonNull LauncherState toState, @@ -380,6 +394,27 @@ import java.util.function.Supplier; return; } float alignment = alignmentSupplier.get(); + float currentValue = mIconAlphaForHome.getValue(); + boolean taskbarWillBeVisible = alignment < 1; + boolean firstFrameVisChanged = (taskbarWillBeVisible && Float.compare(currentValue, 1) != 0) + || (!taskbarWillBeVisible && Float.compare(currentValue, 0) != 0); + + // Sync the first frame where we swap taskbar and hotseat. + if (firstFrameVisChanged && mCanSyncViews && !Utilities.IS_RUNNING_IN_TEST_HARNESS) { + DeviceProfile dp = mLauncher.getDeviceProfile(); + + // Do all the heavy work before the sync. + mControllers.taskbarViewController.createIconAlignmentControllerIfNotExists(dp); + + ViewRootSync.synchronizeNextDraw(mLauncher.getHotseat(), + mControllers.taskbarActivityContext.getDragLayer(), + () -> updateIconAlignment(alignment)); + } else { + updateIconAlignment(alignment); + } + } + + private void updateIconAlignment(float alignment) { mControllers.taskbarViewController.setLauncherIconAlignment( alignment, mLauncher.getDeviceProfile()); diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java index f5c382df42..e1ce89815a 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java @@ -200,15 +200,23 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar } /** + * Creates the icon alignment controller if it does not already exist. + * @param launcherDp Launcher device profile. + */ + public void createIconAlignmentControllerIfNotExists(DeviceProfile launcherDp) { + if (mIconAlignControllerLazy == null) { + mIconAlignControllerLazy = createIconAlignmentController(launcherDp); + } + } + + /** * Sets the taskbar icon alignment relative to Launcher hotseat icons * @param alignmentRatio [0, 1] * 0 => not aligned * 1 => fully aligned */ public void setLauncherIconAlignment(float alignmentRatio, DeviceProfile launcherDp) { - if (mIconAlignControllerLazy == null) { - mIconAlignControllerLazy = createIconAlignmentController(launcherDp); - } + createIconAlignmentControllerIfNotExists(launcherDp); mIconAlignControllerLazy.setPlayFraction(alignmentRatio); if (alignmentRatio <= 0 || alignmentRatio >= 1) { // Cleanup lazy controller so that it is created again in next animation |