From d9abb1767db0c005a17779272e1448a9d9e1a9ff Mon Sep 17 00:00:00 2001 From: "[1;3C" Date: Mon, 30 Nov 2020 13:32:22 -0800 Subject: [PATCH] Support launcher animations in new transition system Hook up the shell-transitions RemoteTransition to launcher. Bug: 169035082 Test: Launch an app from a launcher icon and observe Change-Id: Ie327c11bbc59f19fb969f159f8380c10e4a84e50 --- proguard.flags | 5 ++- .../QuickstepAppTransitionManagerImpl.java | 43 ++++++++++++++++++- .../quickstep/BaseActivityInterface.java | 5 +++ .../quickstep/LauncherActivityInterface.java | 9 +++- .../com/android/quickstep/SystemUiProxy.java | 23 ++++++++++ .../quickstep/TouchInteractionService.java | 6 +++ src/com/android/launcher3/Launcher.java | 1 + .../LauncherAppTransitionManager.java | 14 ++++++ 8 files changed, 101 insertions(+), 5 deletions(-) diff --git a/proguard.flags b/proguard.flags index 37b80938fa..a45018346a 100644 --- a/proguard.flags +++ b/proguard.flags @@ -45,9 +45,10 @@ # BUG(70852369): Surpress additional warnings after changing from Proguard to R8 -dontwarn android.app.** --dontwarn android.view.** --dontwarn android.os.** -dontwarn android.graphics.** +-dontwarn android.os.** +-dontwarn android.view.** +-dontwarn android.window.** # Ignore warnings for hidden utility classes referenced from the shared lib -dontwarn com.android.internal.util.** diff --git a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java index 99c4dbaaad..2d9d0920e5 100644 --- a/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java +++ b/quickstep/src/com/android/launcher3/QuickstepAppTransitionManagerImpl.java @@ -75,6 +75,7 @@ import com.android.launcher3.util.MultiValueAlpha; import com.android.launcher3.util.MultiValueAlpha.AlphaProperty; import com.android.launcher3.views.FloatingIconView; import com.android.quickstep.RemoteAnimationTargets; +import com.android.quickstep.SystemUiProxy; import com.android.quickstep.util.MultiValueUpdateListener; import com.android.quickstep.util.RemoteAnimationProvider; import com.android.quickstep.util.StaggeredWorkspaceAnim; @@ -87,6 +88,7 @@ import com.android.systemui.shared.system.RemoteAnimationAdapterCompat; import com.android.systemui.shared.system.RemoteAnimationDefinitionCompat; import com.android.systemui.shared.system.RemoteAnimationRunnerCompat; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; +import com.android.systemui.shared.system.RemoteTransitionCompat; import com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams; import com.android.systemui.shared.system.WindowManagerWrapper; @@ -163,6 +165,9 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans private WrappedAnimationRunnerImpl mAppLaunchRunner; private WrappedAnimationRunnerImpl mKeyguardGoingAwayRunner; + private WrappedAnimationRunnerImpl mWallpaperOpenTransitionRunner; + private RemoteTransitionCompat mLauncherOpenTransition; + private final AnimatorListenerAdapter mForceInvisibleListener = new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { @@ -582,10 +587,11 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans .withCornerRadius(mWindowRadius.value) .withShadowRadius(mShadowRadius.value); } else { - tmpPos.set(target.position.x, target.position.y); if (target.localBounds != null) { final Rect localBounds = target.localBounds; tmpPos.set(target.localBounds.left, target.localBounds.top); + } else { + tmpPos.set(target.position.x, target.position.y); } matrix.setTranslate(tmpPos.x, tmpPos.y); @@ -656,6 +662,24 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans } } + /** + * Registers remote animations used when closing apps to home screen. + */ + @Override + public void registerRemoteTransitions() { + if (SEPARATE_RECENTS_ACTIVITY.get()) { + return; + } + if (hasControlRemoteAppTransitionPermission()) { + mWallpaperOpenTransitionRunner = createWallpaperOpenRunner(false /* fromUnlock */); + mLauncherOpenTransition = RemoteAnimationAdapterCompat.buildRemoteTransition( + new WrappedLauncherAnimationRunner<>(mWallpaperOpenTransitionRunner, + false /* startAtFrontOfQueue */)); + mLauncherOpenTransition.addHomeOpenCheck(); + SystemUiProxy.INSTANCE.getNoCreate().registerRemoteTransition(mLauncherOpenTransition); + } + } + /** * Unregisters all remote animations. */ @@ -675,6 +699,20 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans } } + @Override + public void unregisterRemoteTransitions() { + if (SEPARATE_RECENTS_ACTIVITY.get()) { + return; + } + if (hasControlRemoteAppTransitionPermission()) { + if (mLauncherOpenTransition == null) return; + SystemUiProxy.INSTANCE.getNoCreate().unregisterRemoteTransition( + mLauncherOpenTransition); + mLauncherOpenTransition = null; + mWallpaperOpenTransitionRunner = null; + } + } + private boolean launcherIsATargetWithMode(RemoteAnimationTargetCompat[] targets, int mode) { return taskIsATargetWithMode(targets, mLauncher.getTaskId(), mode); } @@ -742,9 +780,10 @@ public abstract class QuickstepAppTransitionManagerImpl extends LauncherAppTrans RemoteAnimationTargetCompat target = appTargets[i]; SurfaceParams.Builder builder = new SurfaceParams.Builder(target.leash); - tmpPos.set(target.position.x, target.position.y); if (target.localBounds != null) { tmpPos.set(target.localBounds.left, target.localBounds.top); + } else { + tmpPos.set(target.position.x, target.position.y); } if (target.mode == MODE_CLOSING) { diff --git a/quickstep/src/com/android/quickstep/BaseActivityInterface.java b/quickstep/src/com/android/quickstep/BaseActivityInterface.java index b4f20d10d5..5bed929fb4 100644 --- a/quickstep/src/com/android/quickstep/BaseActivityInterface.java +++ b/quickstep/src/com/android/quickstep/BaseActivityInterface.java @@ -396,4 +396,9 @@ public abstract class BaseActivityInterface { + final BaseActivityInterface ai = + mOverviewComponentObserver.getActivityInterface(); + if (ai == null) return; + ai.onOverviewServiceBound(); + }); }); sIsInitialized = true; } diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 5b55c4b435..0274775244 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1596,6 +1596,7 @@ public class Launcher extends StatefulActivity implements Launche mOverlayManager.onActivityDestroyed(this); mAppTransitionManager.unregisterRemoteAnimations(); + mAppTransitionManager.unregisterRemoteTransitions(); mUserChangedCallbackCloseable.close(); mLifecycleRegistry.setCurrentState(Lifecycle.State.DESTROYED); mLiveSearchManager.stop(); diff --git a/src/com/android/launcher3/LauncherAppTransitionManager.java b/src/com/android/launcher3/LauncherAppTransitionManager.java index 24e0d14c9e..ac3ad9f8fd 100644 --- a/src/com/android/launcher3/LauncherAppTransitionManager.java +++ b/src/com/android/launcher3/LauncherAppTransitionManager.java @@ -67,4 +67,18 @@ public class LauncherAppTransitionManager implements ResourceBasedOverride { public void unregisterRemoteAnimations() { // Do nothing } + + /** + * Registers remote transitions for certain system transitions. + */ + public void registerRemoteTransitions() { + // Do nothing + } + + /** + * Unregisters all remote transitions. + */ + public void unregisterRemoteTransitions() { + // Do nothing + } }