mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-02 17:06:49 +00:00
Merge "Make LauncherAnimationRunner compatible with RemoteAnimationRunner." into tm-qpr-dev am: d23cd42875
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/20836635 Change-Id: I8ce7a076dc78912445c56a2d39369ad611631e5d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -28,12 +28,15 @@ import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.RemoteException;
|
||||
import android.view.IRemoteAnimationFinishedCallback;
|
||||
import android.view.RemoteAnimationTarget;
|
||||
|
||||
import androidx.annotation.BinderThread;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.UiThread;
|
||||
|
||||
import com.android.systemui.animation.RemoteAnimationDelegate;
|
||||
import com.android.systemui.shared.system.RemoteAnimationRunnerCompat;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
@@ -89,7 +92,7 @@ public class LauncherAnimationRunner extends RemoteAnimationRunnerCompat {
|
||||
Runnable r = () -> {
|
||||
finishExistingAnimation();
|
||||
mAnimationResult = new AnimationResult(() -> mAnimationResult = null, runnable);
|
||||
getFactory().onCreateAnimation(transit, appTargets, wallpaperTargets, nonAppTargets,
|
||||
getFactory().onAnimationStart(transit, appTargets, wallpaperTargets, nonAppTargets,
|
||||
mAnimationResult);
|
||||
};
|
||||
if (mStartAtFrontOfQueue) {
|
||||
@@ -124,7 +127,11 @@ public class LauncherAnimationRunner extends RemoteAnimationRunnerCompat {
|
||||
});
|
||||
}
|
||||
|
||||
public static final class AnimationResult {
|
||||
/**
|
||||
* Used by RemoteAnimationFactory implementations to run the actual animation and its lifecycle
|
||||
* callbacks.
|
||||
*/
|
||||
public static final class AnimationResult extends IRemoteAnimationFinishedCallback.Stub {
|
||||
|
||||
private final Runnable mSyncFinishRunnable;
|
||||
private final Runnable mASyncFinishRunnable;
|
||||
@@ -199,25 +206,41 @@ public class LauncherAnimationRunner extends RemoteAnimationRunnerCompat {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When used as a simple IRemoteAnimationFinishedCallback, this method is used to run the
|
||||
* animation finished runnable.
|
||||
*/
|
||||
@Override
|
||||
public void onAnimationFinished() throws RemoteException {
|
||||
mASyncFinishRunnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used with LauncherAnimationRunner as an interface for the runner to call back to the
|
||||
* implementation.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface RemoteAnimationFactory {
|
||||
public interface RemoteAnimationFactory extends RemoteAnimationDelegate<AnimationResult> {
|
||||
|
||||
/**
|
||||
* Called on the UI thread when the animation targets are received. The implementation must
|
||||
* call {@link AnimationResult#setAnimation} with the target animation to be run.
|
||||
*/
|
||||
void onCreateAnimation(int transit,
|
||||
@Override
|
||||
@UiThread
|
||||
void onAnimationStart(int transit,
|
||||
RemoteAnimationTarget[] appTargets,
|
||||
RemoteAnimationTarget[] wallpaperTargets,
|
||||
RemoteAnimationTarget[] nonAppTargets,
|
||||
LauncherAnimationRunner.AnimationResult result);
|
||||
|
||||
@Override
|
||||
@UiThread
|
||||
default void onAnimationCancelled(boolean isKeyguardOccluded) {
|
||||
onAnimationCancelled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the animation is cancelled. This can happen with or without
|
||||
* the create being called.
|
||||
|
||||
@@ -1665,7 +1665,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateAnimation(int transit,
|
||||
public void onAnimationStart(int transit,
|
||||
RemoteAnimationTarget[] appTargets,
|
||||
RemoteAnimationTarget[] wallpaperTargets,
|
||||
RemoteAnimationTarget[] nonAppTargets,
|
||||
@@ -1707,7 +1707,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateAnimation(int transit,
|
||||
public void onAnimationStart(int transit,
|
||||
RemoteAnimationTarget[] appTargets,
|
||||
RemoteAnimationTarget[] wallpaperTargets,
|
||||
RemoteAnimationTarget[] nonAppTargets,
|
||||
|
||||
@@ -240,7 +240,7 @@ public final class RecentsActivity extends StatefulActivity<RecentsState> {
|
||||
|
||||
mActivityLaunchAnimationRunner = new RemoteAnimationFactory() {
|
||||
@Override
|
||||
public void onCreateAnimation(int transit, RemoteAnimationTarget[] appTargets,
|
||||
public void onAnimationStart(int transit, RemoteAnimationTarget[] appTargets,
|
||||
RemoteAnimationTarget[] wallpaperTargets,
|
||||
RemoteAnimationTarget[] nonAppTargets, AnimationResult result) {
|
||||
mHandler.removeCallbacks(mAnimationStartTimeoutRunnable);
|
||||
@@ -407,28 +407,24 @@ public final class RecentsActivity extends StatefulActivity<RecentsState> {
|
||||
}
|
||||
|
||||
private final RemoteAnimationFactory mAnimationToHomeFactory =
|
||||
new RemoteAnimationFactory() {
|
||||
@Override
|
||||
public void onCreateAnimation(int transit, RemoteAnimationTarget[] appTargets,
|
||||
RemoteAnimationTarget[] wallpaperTargets,
|
||||
RemoteAnimationTarget[] nonAppTargets, AnimationResult result) {
|
||||
AnimatorPlaybackController controller = getStateManager()
|
||||
.createAnimationToNewWorkspace(RecentsState.BG_LAUNCHER, HOME_APPEAR_DURATION);
|
||||
controller.dispatchOnStart();
|
||||
(transit, appTargets, wallpaperTargets, nonAppTargets, result) -> {
|
||||
AnimatorPlaybackController controller =
|
||||
getStateManager().createAnimationToNewWorkspace(
|
||||
RecentsState.BG_LAUNCHER, HOME_APPEAR_DURATION);
|
||||
controller.dispatchOnStart();
|
||||
|
||||
RemoteAnimationTargets targets = new RemoteAnimationTargets(
|
||||
appTargets, wallpaperTargets, nonAppTargets, MODE_OPENING);
|
||||
for (RemoteAnimationTarget app : targets.apps) {
|
||||
new Transaction().setAlpha(app.leash, 1).apply();
|
||||
}
|
||||
AnimatorSet anim = new AnimatorSet();
|
||||
anim.play(controller.getAnimationPlayer());
|
||||
anim.setDuration(HOME_APPEAR_DURATION);
|
||||
result.setAnimation(anim, RecentsActivity.this,
|
||||
() -> getStateManager().goToState(RecentsState.HOME, false),
|
||||
true /* skipFirstFrame */);
|
||||
}
|
||||
};
|
||||
RemoteAnimationTargets targets = new RemoteAnimationTargets(
|
||||
appTargets, wallpaperTargets, nonAppTargets, MODE_OPENING);
|
||||
for (RemoteAnimationTarget app : targets.apps) {
|
||||
new Transaction().setAlpha(app.leash, 1).apply();
|
||||
}
|
||||
AnimatorSet anim = new AnimatorSet();
|
||||
anim.play(controller.getAnimationPlayer());
|
||||
anim.setDuration(HOME_APPEAR_DURATION);
|
||||
result.setAnimation(anim, RecentsActivity.this,
|
||||
() -> getStateManager().goToState(RecentsState.HOME, false),
|
||||
true /* skipFirstFrame */);
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void collectStateHandlers(List<StateHandler> out) {
|
||||
|
||||
Reference in New Issue
Block a user