mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 11:18:21 +00:00
Merge "Removing some unused overrides in Launcher" into udc-qpr-dev
This commit is contained in:
@@ -15,23 +15,16 @@
|
||||
*/
|
||||
package com.android.launcher3;
|
||||
|
||||
import android.animation.AnimatorSet;
|
||||
import android.annotation.TargetApi;
|
||||
import android.os.Build;
|
||||
import android.os.CancellationSignal;
|
||||
import android.view.RemoteAnimationTarget;
|
||||
|
||||
import com.android.launcher3.uioverrides.QuickstepLauncher;
|
||||
import com.android.quickstep.util.ActivityInitListener;
|
||||
import com.android.quickstep.util.RemoteAnimationProvider;
|
||||
|
||||
import java.util.function.BiPredicate;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.P)
|
||||
public class LauncherInitListener extends ActivityInitListener<Launcher> {
|
||||
|
||||
private RemoteAnimationProvider mRemoteAnimationProvider;
|
||||
|
||||
/**
|
||||
* @param onInitListener a callback made when the activity is initialized. The callback should
|
||||
* return true to continue receiving callbacks (ie. for if the activity is
|
||||
@@ -43,37 +36,7 @@ public class LauncherInitListener extends ActivityInitListener<Launcher> {
|
||||
|
||||
@Override
|
||||
public boolean handleInit(Launcher launcher, boolean alreadyOnHome) {
|
||||
if (mRemoteAnimationProvider != null) {
|
||||
QuickstepTransitionManager appTransitionManager =
|
||||
((QuickstepLauncher) launcher).getAppTransitionManager();
|
||||
|
||||
// Set a one-time animation provider. After the first call, this will get cleared.
|
||||
// TODO: Probably also check the intended target id.
|
||||
CancellationSignal cancellationSignal = new CancellationSignal();
|
||||
appTransitionManager.setRemoteAnimationProvider(new RemoteAnimationProvider() {
|
||||
@Override
|
||||
public AnimatorSet createWindowAnimation(RemoteAnimationTarget[] appTargets,
|
||||
RemoteAnimationTarget[] wallpaperTargets) {
|
||||
|
||||
// On the first call clear the reference.
|
||||
cancellationSignal.cancel();
|
||||
RemoteAnimationProvider provider = mRemoteAnimationProvider;
|
||||
mRemoteAnimationProvider = null;
|
||||
|
||||
if (provider != null && launcher.getStateManager().getState().overviewUi) {
|
||||
return provider.createWindowAnimation(appTargets, wallpaperTargets);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}, cancellationSignal);
|
||||
}
|
||||
launcher.deferOverlayCallbacksUntilNextResumeOrStop();
|
||||
return super.handleInit(launcher, alreadyOnHome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister() {
|
||||
mRemoteAnimationProvider = null;
|
||||
super.unregister();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,6 @@ import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
@@ -140,7 +139,6 @@ import com.android.quickstep.util.MultiValueUpdateListener;
|
||||
import com.android.quickstep.util.RectFSpringAnim;
|
||||
import com.android.quickstep.util.RectFSpringAnim.DefaultSpringConfig;
|
||||
import com.android.quickstep.util.RectFSpringAnim.TaskbarHotseatSpringConfig;
|
||||
import com.android.quickstep.util.RemoteAnimationProvider;
|
||||
import com.android.quickstep.util.StaggeredWorkspaceAnim;
|
||||
import com.android.quickstep.util.SurfaceTransaction;
|
||||
import com.android.quickstep.util.SurfaceTransaction.SurfaceProperties;
|
||||
@@ -229,7 +227,6 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
|
||||
private DeviceProfile mDeviceProfile;
|
||||
|
||||
private RemoteAnimationProvider mRemoteAnimationProvider;
|
||||
// Strong refs to runners which are cleared when the launcher activity is destroyed
|
||||
private RemoteAnimationFactory mWallpaperOpenRunner;
|
||||
private RemoteAnimationFactory mAppLaunchRunner;
|
||||
@@ -468,16 +465,6 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
return bounds;
|
||||
}
|
||||
|
||||
public void setRemoteAnimationProvider(final RemoteAnimationProvider animationProvider,
|
||||
CancellationSignal cancellationSignal) {
|
||||
mRemoteAnimationProvider = animationProvider;
|
||||
cancellationSignal.setOnCancelListener(() -> {
|
||||
if (animationProvider == mRemoteAnimationProvider) {
|
||||
mRemoteAnimationProvider = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Dump debug logs to bug report. */
|
||||
public void dump(@NonNull String prefix, @NonNull PrintWriter printWriter) {}
|
||||
|
||||
@@ -1234,7 +1221,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
* ie. pressing home, swiping up from nav bar.
|
||||
*/
|
||||
RemoteAnimationFactory createWallpaperOpenRunner(boolean fromUnlock) {
|
||||
return new WallpaperOpenLauncherAnimationRunner(mHandler, fromUnlock);
|
||||
return new WallpaperOpenLauncherAnimationRunner(fromUnlock);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1352,7 +1339,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
/**
|
||||
* Closing animator that animates the window into its final location on the workspace.
|
||||
*/
|
||||
private RectFSpringAnim getClosingWindowAnimators(AnimatorSet animation,
|
||||
protected RectFSpringAnim getClosingWindowAnimators(AnimatorSet animation,
|
||||
RemoteAnimationTarget[] targets, View launcherView, PointF velocityPxPerS,
|
||||
RectF closingWindowStartRect, float startWindowCornerRadius) {
|
||||
FloatingIconView floatingIconView = null;
|
||||
@@ -1592,89 +1579,80 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
RectF startRect,
|
||||
float startWindowCornerRadius,
|
||||
boolean fromPredictiveBack) {
|
||||
AnimatorSet anim = null;
|
||||
AnimatorSet anim = new AnimatorSet();
|
||||
RectFSpringAnim rectFSpringAnim = null;
|
||||
|
||||
RemoteAnimationProvider provider = mRemoteAnimationProvider;
|
||||
if (provider != null) {
|
||||
anim = provider.createWindowAnimation(appTargets, wallpaperTargets);
|
||||
final boolean launcherIsForceInvisibleOrOpening = mLauncher.isForceInvisible()
|
||||
|| launcherIsATargetWithMode(appTargets, MODE_OPENING);
|
||||
|
||||
View launcherView = findLauncherView(appTargets);
|
||||
boolean playFallBackAnimation = (launcherView == null
|
||||
&& launcherIsForceInvisibleOrOpening)
|
||||
|| mLauncher.getWorkspace().isOverlayShown()
|
||||
|| shouldPlayFallbackClosingAnimation(appTargets);
|
||||
|
||||
boolean playWorkspaceReveal = true;
|
||||
boolean skipAllAppsScale = false;
|
||||
if (fromUnlock) {
|
||||
anim.play(getUnlockWindowAnimator(appTargets, wallpaperTargets));
|
||||
} else if (ENABLE_BACK_SWIPE_HOME_ANIMATION.get()
|
||||
&& !playFallBackAnimation) {
|
||||
// Use a fixed velocity to start the animation.
|
||||
float velocityPxPerS = DynamicResource.provider(mLauncher)
|
||||
.getDimension(R.dimen.unlock_staggered_velocity_dp_per_s);
|
||||
PointF velocity = new PointF(0, -velocityPxPerS);
|
||||
rectFSpringAnim = getClosingWindowAnimators(
|
||||
anim, appTargets, launcherView, velocity, startRect,
|
||||
startWindowCornerRadius);
|
||||
if (mLauncher.isInState(LauncherState.ALL_APPS)) {
|
||||
// Skip scaling all apps, otherwise FloatingIconView will get wrong
|
||||
// layout bounds.
|
||||
skipAllAppsScale = true;
|
||||
} else if (!fromPredictiveBack) {
|
||||
anim.play(new StaggeredWorkspaceAnim(mLauncher, velocity.y,
|
||||
true /* animateOverviewScrim */, launcherView).getAnimators());
|
||||
|
||||
if (!areAllTargetsTranslucent(appTargets)) {
|
||||
anim.play(ObjectAnimator.ofFloat(mLauncher.getDepthController().stateDepth,
|
||||
MULTI_PROPERTY_VALUE,
|
||||
BACKGROUND_APP.getDepth(mLauncher), NORMAL.getDepth(mLauncher)));
|
||||
}
|
||||
|
||||
// We play StaggeredWorkspaceAnim as a part of the closing window animation.
|
||||
playWorkspaceReveal = false;
|
||||
}
|
||||
} else {
|
||||
anim.play(getFallbackClosingWindowAnimators(appTargets));
|
||||
}
|
||||
|
||||
if (anim == null) {
|
||||
anim = new AnimatorSet();
|
||||
// Normally, we run the launcher content animation when we are transitioning
|
||||
// home, but if home is already visible, then we don't want to animate the
|
||||
// contents of launcher unless we know that we are animating home as a result
|
||||
// of the home button press with quickstep, which will result in launcher being
|
||||
// started on touch down, prior to the animation home (and won't be in the
|
||||
// targets list because it is already visible). In that case, we force
|
||||
// invisibility on touch down, and only reset it after the animation to home
|
||||
// is initialized.
|
||||
if (launcherIsForceInvisibleOrOpening) {
|
||||
addCujInstrumentation(
|
||||
anim, InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME);
|
||||
// Only register the content animation for cancellation when state changes
|
||||
mLauncher.getStateManager().setCurrentAnimation(anim);
|
||||
|
||||
final boolean launcherIsForceInvisibleOrOpening = mLauncher.isForceInvisible()
|
||||
|| launcherIsATargetWithMode(appTargets, MODE_OPENING);
|
||||
|
||||
View launcherView = findLauncherView(appTargets);
|
||||
boolean playFallBackAnimation = (launcherView == null
|
||||
&& launcherIsForceInvisibleOrOpening)
|
||||
|| mLauncher.getWorkspace().isOverlayShown()
|
||||
|| shouldPlayFallbackClosingAnimation(appTargets);
|
||||
|
||||
boolean playWorkspaceReveal = true;
|
||||
boolean skipAllAppsScale = false;
|
||||
if (fromUnlock) {
|
||||
anim.play(getUnlockWindowAnimator(appTargets, wallpaperTargets));
|
||||
} else if (ENABLE_BACK_SWIPE_HOME_ANIMATION.get()
|
||||
&& !playFallBackAnimation) {
|
||||
// Use a fixed velocity to start the animation.
|
||||
float velocityPxPerS = DynamicResource.provider(mLauncher)
|
||||
.getDimension(R.dimen.unlock_staggered_velocity_dp_per_s);
|
||||
PointF velocity = new PointF(0, -velocityPxPerS);
|
||||
rectFSpringAnim = getClosingWindowAnimators(
|
||||
anim, appTargets, launcherView, velocity, startRect,
|
||||
startWindowCornerRadius);
|
||||
if (mLauncher.isInState(LauncherState.ALL_APPS)) {
|
||||
// Skip scaling all apps, otherwise FloatingIconView will get wrong
|
||||
// layout bounds.
|
||||
skipAllAppsScale = true;
|
||||
} else if (!fromPredictiveBack) {
|
||||
anim.play(new StaggeredWorkspaceAnim(mLauncher, velocity.y,
|
||||
true /* animateOverviewScrim */, launcherView).getAnimators());
|
||||
|
||||
if (!areAllTargetsTranslucent(appTargets)) {
|
||||
anim.play(ObjectAnimator.ofFloat(mLauncher.getDepthController().stateDepth,
|
||||
MULTI_PROPERTY_VALUE,
|
||||
BACKGROUND_APP.getDepth(mLauncher), NORMAL.getDepth(mLauncher)));
|
||||
if (mLauncher.isInState(LauncherState.ALL_APPS)) {
|
||||
Pair<AnimatorSet, Runnable> contentAnimator =
|
||||
getLauncherContentAnimator(false, LAUNCHER_RESUME_START_DELAY,
|
||||
skipAllAppsScale);
|
||||
anim.play(contentAnimator.first);
|
||||
anim.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
contentAnimator.second.run();
|
||||
}
|
||||
|
||||
// We play StaggeredWorkspaceAnim as a part of the closing window animation.
|
||||
playWorkspaceReveal = false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
anim.play(getFallbackClosingWindowAnimators(appTargets));
|
||||
}
|
||||
|
||||
// Normally, we run the launcher content animation when we are transitioning
|
||||
// home, but if home is already visible, then we don't want to animate the
|
||||
// contents of launcher unless we know that we are animating home as a result
|
||||
// of the home button press with quickstep, which will result in launcher being
|
||||
// started on touch down, prior to the animation home (and won't be in the
|
||||
// targets list because it is already visible). In that case, we force
|
||||
// invisibility on touch down, and only reset it after the animation to home
|
||||
// is initialized.
|
||||
if (launcherIsForceInvisibleOrOpening) {
|
||||
addCujInstrumentation(
|
||||
anim, InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME);
|
||||
// Only register the content animation for cancellation when state changes
|
||||
mLauncher.getStateManager().setCurrentAnimation(anim);
|
||||
|
||||
if (mLauncher.isInState(LauncherState.ALL_APPS)) {
|
||||
Pair<AnimatorSet, Runnable> contentAnimator =
|
||||
getLauncherContentAnimator(false, LAUNCHER_RESUME_START_DELAY,
|
||||
skipAllAppsScale);
|
||||
anim.play(contentAnimator.first);
|
||||
anim.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
contentAnimator.second.run();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (playWorkspaceReveal) {
|
||||
anim.play(new WorkspaceRevealAnim(mLauncher, false).getAnimators());
|
||||
}
|
||||
if (playWorkspaceReveal) {
|
||||
anim.play(new WorkspaceRevealAnim(mLauncher, false).getAnimators());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1687,11 +1665,9 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener
|
||||
*/
|
||||
protected class WallpaperOpenLauncherAnimationRunner implements RemoteAnimationFactory {
|
||||
|
||||
private final Handler mHandler;
|
||||
private final boolean mFromUnlock;
|
||||
|
||||
public WallpaperOpenLauncherAnimationRunner(Handler handler, boolean fromUnlock) {
|
||||
mHandler = handler;
|
||||
public WallpaperOpenLauncherAnimationRunner(boolean fromUnlock) {
|
||||
mFromUnlock = fromUnlock;
|
||||
}
|
||||
|
||||
|
||||
@@ -114,8 +114,7 @@ public class HotseatPredictionController implements DragController.DragListener,
|
||||
WorkspaceItemInfo dragItem = new WorkspaceItemInfo((WorkspaceItemInfo) v.getTag());
|
||||
v.setVisibility(View.INVISIBLE);
|
||||
mLauncher.getWorkspace().beginDragShared(
|
||||
v, null, this, dragItem, new DragPreviewProvider(v),
|
||||
mLauncher.getDefaultWorkspaceDragOptions());
|
||||
v, null, this, dragItem, new DragPreviewProvider(v), new DragOptions());
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
@@ -16,13 +16,16 @@
|
||||
|
||||
package com.android.launcher3.uioverrides;
|
||||
|
||||
import android.app.ActivityOptions;
|
||||
import android.app.Person;
|
||||
import android.content.Context;
|
||||
import android.content.pm.LauncherActivityInfo;
|
||||
import android.content.pm.LauncherApps;
|
||||
import android.content.pm.ShortcutInfo;
|
||||
import android.window.RemoteTransition;
|
||||
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.quickstep.util.FadeOutRemoteTransition;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -41,4 +44,13 @@ public class ApiWrapper {
|
||||
public static Map<String, LauncherActivityInfo> getActivityOverrides(Context context) {
|
||||
return context.getSystemService(LauncherApps.class).getActivityOverrides();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ActivityOptions to play fade-out animation on closing targets
|
||||
*/
|
||||
public static ActivityOptions createFadeOutAnimOptions(Context context) {
|
||||
ActivityOptions options = ActivityOptions.makeBasic();
|
||||
options.setRemoteTransition(new RemoteTransition(new FadeOutRemoteTransition()));
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ import static com.android.launcher3.LauncherState.OVERVIEW;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW_MODAL_TASK;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW_SPLIT_SELECT;
|
||||
import static com.android.launcher3.compat.AccessibilityManagerCompat.sendCustomAccessibilityEvent;
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_SPLIT_FROM_DESKTOP_TO_WORKSPACE;
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_SPLIT_FROM_WORKSPACE_TO_WORKSPACE;
|
||||
import static com.android.launcher3.config.FeatureFlags.RECEIVE_UNFOLD_EVENTS_FROM_SYSUI;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_TAP;
|
||||
@@ -59,7 +58,6 @@ import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SY
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityOptions;
|
||||
import android.content.Context;
|
||||
@@ -76,13 +74,11 @@ import android.hardware.display.DisplayManager;
|
||||
import android.media.permission.SafeCloseable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.IBinder;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.Trace;
|
||||
import android.view.Display;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.RemoteAnimationTarget;
|
||||
import android.view.View;
|
||||
import android.window.BackEvent;
|
||||
import android.window.OnBackAnimationCallback;
|
||||
@@ -110,7 +106,6 @@ import com.android.launcher3.anim.AnimatorPlaybackController;
|
||||
import com.android.launcher3.anim.PendingAnimation;
|
||||
import com.android.launcher3.appprediction.PredictionRowView;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.dragndrop.DragOptions;
|
||||
import com.android.launcher3.hybridhotseat.HotseatPredictionController;
|
||||
import com.android.launcher3.logging.InstanceId;
|
||||
import com.android.launcher3.logging.StatsLogManager;
|
||||
@@ -164,8 +159,6 @@ import com.android.quickstep.util.GroupTask;
|
||||
import com.android.quickstep.util.LauncherUnfoldAnimationController;
|
||||
import com.android.quickstep.util.ProxyScreenStatusProvider;
|
||||
import com.android.quickstep.util.QuickstepOnboardingPrefs;
|
||||
import com.android.quickstep.util.RemoteAnimationProvider;
|
||||
import com.android.quickstep.util.RemoteFadeOutAnimationListener;
|
||||
import com.android.quickstep.util.SplitSelectStateController;
|
||||
import com.android.quickstep.util.SplitToWorkspaceController;
|
||||
import com.android.quickstep.util.SplitWithKeyboardShortcutController;
|
||||
@@ -221,7 +214,6 @@ public class QuickstepLauncher extends Launcher {
|
||||
private TISBindHelper mTISBindHelper;
|
||||
private @Nullable LauncherTaskbarUIController mTaskbarUIController;
|
||||
// Will be updated when dragging from taskbar.
|
||||
private @Nullable DragOptions mNextWorkspaceDragOptions = null;
|
||||
private @Nullable UnfoldTransitionProgressProvider mUnfoldTransitionProgressProvider;
|
||||
private @Nullable LauncherUnfoldAnimationController mLauncherUnfoldAnimationController;
|
||||
|
||||
@@ -1048,41 +1040,6 @@ public class QuickstepLauncher extends Launcher {
|
||||
return mAppTransitionManager.hasControlRemoteAppTransitionPermission();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DragOptions getDefaultWorkspaceDragOptions() {
|
||||
if (mNextWorkspaceDragOptions != null) {
|
||||
DragOptions options = mNextWorkspaceDragOptions;
|
||||
mNextWorkspaceDragOptions = null;
|
||||
return options;
|
||||
}
|
||||
return super.getDefaultWorkspaceDragOptions();
|
||||
}
|
||||
|
||||
public void setNextWorkspaceDragOptions(DragOptions dragOptions) {
|
||||
mNextWorkspaceDragOptions = dragOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void useFadeOutAnimationForLauncherStart(CancellationSignal signal) {
|
||||
QuickstepTransitionManager appTransitionManager = getAppTransitionManager();
|
||||
appTransitionManager.setRemoteAnimationProvider(new RemoteAnimationProvider() {
|
||||
@Override
|
||||
public AnimatorSet createWindowAnimation(RemoteAnimationTarget[] appTargets,
|
||||
RemoteAnimationTarget[] wallpaperTargets) {
|
||||
|
||||
// On the first call clear the reference.
|
||||
signal.cancel();
|
||||
|
||||
ValueAnimator fadeAnimation = ValueAnimator.ofFloat(1, 0);
|
||||
fadeAnimation.addUpdateListener(new RemoteFadeOutAnimationListener(appTargets,
|
||||
wallpaperTargets));
|
||||
AnimatorSet anim = new AnimatorSet();
|
||||
anim.play(fadeAnimation);
|
||||
return anim;
|
||||
}
|
||||
}, signal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float[] getNormalOverviewScaleAndOffset() {
|
||||
return DisplayController.getNavigationMode(this).hasGestures
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (C) 2023 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.quickstep.util
|
||||
|
||||
import android.animation.ValueAnimator
|
||||
import android.os.IBinder
|
||||
import android.os.RemoteException
|
||||
import android.view.SurfaceControl
|
||||
import android.view.SurfaceControl.Transaction
|
||||
import android.window.IRemoteTransition
|
||||
import android.window.IRemoteTransitionFinishedCallback
|
||||
import android.window.TransitionInfo
|
||||
import com.android.launcher3.anim.AnimatorListeners.forEndCallback
|
||||
import com.android.launcher3.util.Executors
|
||||
import com.android.wm.shell.util.TransitionUtil
|
||||
|
||||
/** Remote animation which fades out the closing targets */
|
||||
class FadeOutRemoteTransition : IRemoteTransition.Stub() {
|
||||
|
||||
override fun mergeAnimation(
|
||||
iBinder: IBinder,
|
||||
transitionInfo: TransitionInfo,
|
||||
transaction: Transaction,
|
||||
mergeTarget: IBinder,
|
||||
finishCB: IRemoteTransitionFinishedCallback
|
||||
) {
|
||||
|
||||
try {
|
||||
finishCB.onTransitionFinished(null, Transaction())
|
||||
} catch (e: RemoteException) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
|
||||
override fun startAnimation(
|
||||
transition: IBinder,
|
||||
info: TransitionInfo,
|
||||
startT: Transaction,
|
||||
finishCB: IRemoteTransitionFinishedCallback
|
||||
) {
|
||||
val anim = ValueAnimator.ofFloat(1f, 0f)
|
||||
|
||||
val closingControls: MutableList<SurfaceControl> = mutableListOf()
|
||||
for (chg in info.changes) {
|
||||
startT.show(chg.leash)
|
||||
if (TransitionUtil.isClosingType(chg.mode)) {
|
||||
closingControls.add(chg.leash)
|
||||
}
|
||||
}
|
||||
startT.apply()
|
||||
|
||||
anim.addUpdateListener {
|
||||
val t = Transaction()
|
||||
closingControls.forEach { t.setAlpha(it, anim.animatedValue as Float) }
|
||||
t.apply()
|
||||
}
|
||||
anim.addListener(
|
||||
forEndCallback(
|
||||
Runnable {
|
||||
val t = Transaction()
|
||||
closingControls.forEach { t.hide(it) }
|
||||
try {
|
||||
finishCB.onTransitionFinished(null, t)
|
||||
} catch (e: RemoteException) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
Executors.MAIN_EXECUTOR.execute { anim.start() }
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.quickstep.util;
|
||||
|
||||
import android.animation.AnimatorSet;
|
||||
import android.view.RemoteAnimationTarget;
|
||||
|
||||
public abstract class RemoteAnimationProvider {
|
||||
|
||||
public abstract AnimatorSet createWindowAnimation(RemoteAnimationTarget[] appTargets,
|
||||
RemoteAnimationTarget[] wallpaperTargets);
|
||||
|
||||
/**
|
||||
* @return the target with the lowest opaque layer for a certain app animation, or null.
|
||||
*/
|
||||
public static RemoteAnimationTarget findLowestOpaqueLayerTarget(
|
||||
RemoteAnimationTarget[] appTargets, int mode) {
|
||||
int lowestLayer = Integer.MAX_VALUE;
|
||||
int lowestLayerIndex = -1;
|
||||
for (int i = appTargets.length - 1; i >= 0; i--) {
|
||||
RemoteAnimationTarget target = appTargets[i];
|
||||
if (target.mode == mode && !target.isTranslucent) {
|
||||
int layer = target.prefixOrderIndex;
|
||||
if (layer < lowestLayer) {
|
||||
lowestLayer = layer;
|
||||
lowestLayerIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return lowestLayerIndex != -1
|
||||
? appTargets[lowestLayerIndex]
|
||||
: null;
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.quickstep.util;
|
||||
|
||||
import static android.view.RemoteAnimationTarget.MODE_CLOSING;
|
||||
|
||||
import android.animation.ValueAnimator;
|
||||
import android.animation.ValueAnimator.AnimatorUpdateListener;
|
||||
import android.view.RemoteAnimationTarget;
|
||||
import android.view.SurfaceControl.Transaction;
|
||||
|
||||
import com.android.quickstep.RemoteAnimationTargets;
|
||||
|
||||
/**
|
||||
* Animation listener which fades out the closing targets
|
||||
*/
|
||||
public class RemoteFadeOutAnimationListener implements AnimatorUpdateListener {
|
||||
|
||||
private final RemoteAnimationTargets mTarget;
|
||||
private boolean mFirstFrame = true;
|
||||
|
||||
public RemoteFadeOutAnimationListener(RemoteAnimationTarget[] appTargets,
|
||||
RemoteAnimationTarget[] wallpaperTargets) {
|
||||
mTarget = new RemoteAnimationTargets(appTargets, wallpaperTargets,
|
||||
new RemoteAnimationTarget[0], MODE_CLOSING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator valueAnimator) {
|
||||
Transaction t = new Transaction();
|
||||
if (mFirstFrame) {
|
||||
for (RemoteAnimationTarget target : mTarget.unfilteredApps) {
|
||||
t.show(target.leash);
|
||||
}
|
||||
mFirstFrame = false;
|
||||
}
|
||||
|
||||
float alpha = 1 - valueAnimator.getAnimatedFraction();
|
||||
for (RemoteAnimationTarget app : mTarget.apps) {
|
||||
t.setAlpha(app.leash, alpha);
|
||||
}
|
||||
t.apply();
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,6 @@ import android.graphics.Rect;
|
||||
import android.graphics.RectF;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.Parcelable;
|
||||
import android.os.StrictMode;
|
||||
import android.os.SystemClock;
|
||||
@@ -155,7 +154,6 @@ import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.dot.DotInfo;
|
||||
import com.android.launcher3.dragndrop.DragController;
|
||||
import com.android.launcher3.dragndrop.DragLayer;
|
||||
import com.android.launcher3.dragndrop.DragOptions;
|
||||
import com.android.launcher3.dragndrop.DragView;
|
||||
import com.android.launcher3.dragndrop.LauncherDragController;
|
||||
import com.android.launcher3.folder.Folder;
|
||||
@@ -3250,8 +3248,6 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
return new TouchController[] {getDragController(), new AllAppsSwipeController(this)};
|
||||
}
|
||||
|
||||
public void useFadeOutAnimationForLauncherStart(CancellationSignal signal) { }
|
||||
|
||||
public void onDragLayerHierarchyChanged() {
|
||||
updateDisallowBack();
|
||||
}
|
||||
@@ -3317,10 +3313,6 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
return false;
|
||||
}
|
||||
|
||||
public DragOptions getDefaultWorkspaceDragOptions() {
|
||||
return new DragOptions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Animates Launcher elements during a transition to the All Apps page.
|
||||
*
|
||||
|
||||
@@ -26,7 +26,6 @@ import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
|
||||
import static com.android.launcher3.widget.WidgetSections.NO_CATEGORY;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.ActivityOptions;
|
||||
import android.appwidget.AppWidgetManager;
|
||||
import android.appwidget.AppWidgetProviderInfo;
|
||||
import android.content.ClipData;
|
||||
@@ -68,6 +67,7 @@ import com.android.launcher3.model.WidgetsModel;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.PackageItemInfo;
|
||||
import com.android.launcher3.pm.PinRequestHelper;
|
||||
import com.android.launcher3.uioverrides.ApiWrapper;
|
||||
import com.android.launcher3.util.PackageManagerHelper;
|
||||
import com.android.launcher3.util.SystemUiController;
|
||||
import com.android.launcher3.views.AbstractSlideInView;
|
||||
@@ -259,9 +259,7 @@ public class AddItemActivity extends BaseActivity
|
||||
.setPackage(getPackageName())
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
Launcher.ACTIVITY_TRACKER.registerCallback(listener);
|
||||
startActivity(homeIntent,
|
||||
ActivityOptions.makeCustomAnimation(this, 0, android.R.anim.fade_out)
|
||||
.toBundle());
|
||||
startActivity(homeIntent, ApiWrapper.createFadeOutAnimOptions(this).toBundle());
|
||||
logCommand(LAUNCHER_ADD_EXTERNAL_ITEM_DRAGGED);
|
||||
mFinishOnPause = true;
|
||||
return false;
|
||||
|
||||
@@ -31,7 +31,6 @@ import android.view.View;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
import com.android.launcher3.DragSource;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.PendingAddItemInfo;
|
||||
import com.android.launcher3.widget.LauncherAppWidgetProviderInfo;
|
||||
import com.android.launcher3.widget.PendingAddShortcutInfo;
|
||||
@@ -71,15 +70,6 @@ public class PinItemDragListener extends BaseItemDragListener {
|
||||
return super.onDragStart(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean init(Launcher launcher, boolean alreadyOnHome) {
|
||||
super.init(launcher, alreadyOnHome);
|
||||
if (!alreadyOnHome) {
|
||||
launcher.useFadeOutAnimationForLauncherStart(mCancelSignal);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PendingItemDragHelper createDragHelper() {
|
||||
final PendingAddItemInfo item;
|
||||
|
||||
@@ -67,7 +67,7 @@ public class ItemLongClickListener {
|
||||
if (!(v.getTag() instanceof ItemInfo)) return false;
|
||||
|
||||
launcher.setWaitingForResult(null);
|
||||
beginDrag(v, launcher, (ItemInfo) v.getTag(), launcher.getDefaultWorkspaceDragOptions());
|
||||
beginDrag(v, launcher, (ItemInfo) v.getTag(), new DragOptions());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.launcher3.uioverrides;
|
||||
|
||||
import android.app.ActivityOptions;
|
||||
import android.app.Person;
|
||||
import android.content.Context;
|
||||
import android.content.pm.LauncherActivityInfo;
|
||||
@@ -40,4 +41,11 @@ public class ApiWrapper {
|
||||
public static Map<String, LauncherActivityInfo> getActivityOverrides(Context context) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ActivityOptions to play fade-out animation on closing targets
|
||||
*/
|
||||
public static ActivityOptions createFadeOutAnimOptions(Context context) {
|
||||
return ActivityOptions.makeCustomAnimation(context, 0, android.R.anim.fade_out);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user