diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index 806f39e3bb..c57c323177 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -80,7 +80,6 @@ import android.app.ActivityOptions; import android.app.WindowConfiguration; import android.app.role.RoleManager; import android.content.ComponentName; -import android.content.Context; import android.content.res.Resources; import android.graphics.Color; import android.graphics.Matrix; @@ -180,6 +179,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; +import java.util.Map.Entry; /** * Manages the opening and closing app transitions from Launcher @@ -286,8 +286,8 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener private final SystemUiProxy mSystemUiProxy; - public QuickstepTransitionManager(Context context) { - mLauncher = Launcher.cast(Launcher.getLauncher(context)); + public QuickstepTransitionManager(QuickstepLauncher launcher) { + mLauncher = launcher; mDragLayer = mLauncher.getDragLayer(); mHandler = new Handler(Looper.getMainLooper()); mDeviceProfile = mLauncher.getDeviceProfile(); @@ -313,11 +313,12 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener mSystemUiProxy.setStartingWindowListener(mStartingWindowListener); } - mOpeningXInterpolator = AnimationUtils.loadInterpolator(context, R.interpolator.app_open_x); - mOpeningInterpolator = AnimationUtils.loadInterpolator(context, - R.interpolator.emphasized_interpolator); + mOpeningXInterpolator = AnimationUtils.loadInterpolator( + launcher, R.interpolator.app_open_x); + mOpeningInterpolator = AnimationUtils.loadInterpolator( + launcher, R.interpolator.emphasized_interpolator); mCoordinateTransfer = new RemoteAnimationCoordinateTransfer(mLauncher); - mLatencyTracker = LatencyTracker.getInstance(context); + mLatencyTracker = LatencyTracker.getInstance(launcher); } @Override diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index c6f1d77a44..0933ca02c0 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -295,10 +295,6 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer, } }; - public static QuickstepLauncher getLauncher(Context context) { - return fromContext(context); - } - @Override protected void setupViews() { getTheme().applyStyle(getOverviewBlurStyleResId(), true); diff --git a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt index a96707eefd..d6d265b89d 100644 --- a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt +++ b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt @@ -60,10 +60,10 @@ import com.android.launcher3.model.data.WorkspaceItemInfo import com.android.launcher3.statehandlers.DepthController import com.android.launcher3.statemanager.StateManager import com.android.launcher3.taskbar.TaskbarActivityContext -import com.android.launcher3.uioverrides.QuickstepLauncher import com.android.launcher3.util.MultiPropertyFactory.MULTI_PROPERTY_VALUE import com.android.launcher3.util.OverviewReleaseFlags.enableOverviewIconMenu import com.android.launcher3.util.SplitConfigurationOptions.SplitSelectSource +import com.android.launcher3.views.ActivityContext import com.android.launcher3.views.BaseDragLayer import com.android.quickstep.TaskViewUtils import com.android.quickstep.util.SplitScreenUtils.Companion.extractTopParentAndChildren @@ -735,7 +735,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC } // Else we are in Launcher and can launch with the full icon stretch-and-split animation. - val launcher = QuickstepLauncher.getLauncher(launchingIconView.context) + val launcher: ActivityContext = ActivityContext.lookupContext(launchingIconView.context) val dp = launcher.deviceProfile // Create an AnimatorSet that will run both shell and launcher transitions together @@ -827,7 +827,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC } // Else we are in Launcher and can launch with the full icon stretch-and-split animation. - val launcher = QuickstepLauncher.getLauncher(launchingIconView.context) + val launcher: ActivityContext = ActivityContext.lookupContext(launchingIconView.context) val dp = launcher.deviceProfile // Create an AnimatorSet that will run both shell and launcher transitions together @@ -884,9 +884,9 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC private fun getIconLaunchValueAnimator( t: Transaction, - dp: com.android.launcher3.DeviceProfile, + dp: DeviceProfile, finishCallback: Runnable, - launcher: QuickstepLauncher, + launcher: ActivityContext, floatingView: FloatingAppPairView, rootCandidate: Change, ): ValueAnimator { @@ -1184,7 +1184,7 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC animator.start() } - private fun safeRemoveViewFromDragLayer(container: RecentsViewContainer, view: View?) { + private fun safeRemoveViewFromDragLayer(container: ActivityContext, view: View?) { if (view != null) { container.dragLayer.removeView(view) } diff --git a/quickstep/src/com/android/quickstep/views/FloatingAppPairView.kt b/quickstep/src/com/android/quickstep/views/FloatingAppPairView.kt index e8d1cc1e36..668413817a 100644 --- a/quickstep/src/com/android/quickstep/views/FloatingAppPairView.kt +++ b/quickstep/src/com/android/quickstep/views/FloatingAppPairView.kt @@ -27,7 +27,7 @@ import android.view.ViewGroup import android.widget.FrameLayout import com.android.launcher3.R import com.android.launcher3.Utilities -import com.android.launcher3.statemanager.StatefulActivity +import com.android.launcher3.views.ActivityContext import com.android.launcher3.views.BaseDragLayer /** @@ -38,11 +38,11 @@ class FloatingAppPairView @JvmOverloads constructor(context: Context, attrs: Att FrameLayout(context, attrs) { companion object { fun getFloatingAppPairView( - launcher: StatefulActivity<*>, + launcher: ActivityContext, originalView: View, appIcon1: Drawable?, appIcon2: Drawable?, - dividerPos: Int + dividerPos: Int, ): FloatingAppPairView { val dragLayer: ViewGroup = launcher.getDragLayer() val floatingView = @@ -62,11 +62,11 @@ class FloatingAppPairView @JvmOverloads constructor(context: Context, attrs: Att /** Initializes the view, copying the bounds and location of the original icon view. */ fun init( - launcher: StatefulActivity<*>, + launcher: ActivityContext, originalView: View, appIcon1: Drawable?, appIcon2: Drawable?, - dividerPos: Int + dividerPos: Int, ) { val viewBounds = Rect(0, 0, originalView.width, originalView.height) Utilities.getBoundsForViewInDragLayer( @@ -75,12 +75,12 @@ class FloatingAppPairView @JvmOverloads constructor(context: Context, attrs: Att viewBounds, false /* ignoreTransform */, null /* recycle */, - startingPosition + startingPosition, ) val lp = BaseDragLayer.LayoutParams( Math.round(startingPosition.width()), - Math.round(startingPosition.height()) + Math.round(startingPosition.height()), ) lp.ignoreInsets = true @@ -92,14 +92,14 @@ class FloatingAppPairView @JvmOverloads constructor(context: Context, attrs: Att layoutParams = lp // Prepare to draw app pair icon background - background = if (appIcon1 == null || appIcon2 == null) { - val iconToAnimate = appIcon1 ?: appIcon2 - checkNotNull(iconToAnimate) - FloatingFullscreenAppPairBackground(context, this, iconToAnimate, - dividerPos) - } else { - FloatingAppPairBackground(context, this, appIcon1, appIcon2, dividerPos) - } + background = + if (appIcon1 == null || appIcon2 == null) { + val iconToAnimate = appIcon1 ?: appIcon2 + checkNotNull(iconToAnimate) + FloatingFullscreenAppPairBackground(context, this, iconToAnimate, dividerPos) + } else { + FloatingAppPairBackground(context, this, appIcon1, appIcon2, dividerPos) + } background.setBounds(0, 0, lp.width, lp.height) } diff --git a/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java b/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java index b719ee5b73..7bddc23231 100644 --- a/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java +++ b/quickstep/src/com/android/quickstep/views/FloatingWidgetView.java @@ -50,7 +50,6 @@ public class FloatingWidgetView extends FrameLayout implements AnimatorListener, OnGlobalLayoutListener, FloatingView { private static final Matrix sTmpMatrix = new Matrix(); - private final QuickstepLauncher mLauncher; private final ListenerView mListenerView; private final FloatingWidgetBackgroundView mBackgroundView; private final RectF mBackgroundOffset = new RectF(); @@ -81,7 +80,6 @@ public class FloatingWidgetView extends FrameLayout implements AnimatorListener, public FloatingWidgetView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - mLauncher = QuickstepLauncher.getLauncher(context); mListenerView = new ListenerView(context, attrs); mBackgroundView = new FloatingWidgetBackgroundView(context, attrs, defStyleAttr); addView(mBackgroundView); @@ -155,7 +153,8 @@ public class FloatingWidgetView extends FrameLayout implements AnimatorListener, } } - private void init(DragLayer dragLayer, LauncherAppWidgetHostView originalView, + private void init(QuickstepLauncher launcher, DragLayer dragLayer, + LauncherAppWidgetHostView originalView, RectF widgetBackgroundPosition, Size windowSize, float windowCornerRadius, boolean appTargetIsTranslucent, int fallbackBackgroundColor) { mAppWidgetView = originalView; @@ -163,7 +162,7 @@ public class FloatingWidgetView extends FrameLayout implements AnimatorListener, mAppWidgetView.beginDeferringUpdates(); mBackgroundPosition = widgetBackgroundPosition; mAppTargetIsTranslucent = appTargetIsTranslucent; - mEndRunnable = () -> finish(dragLayer); + mEndRunnable = () -> finish(launcher, dragLayer); mAppWidgetBackgroundView = RoundedCornerEnforcement.findBackground(mAppWidgetView); if (mAppWidgetBackgroundView == null) { @@ -271,7 +270,7 @@ public class FloatingWidgetView extends FrameLayout implements AnimatorListener, return positionsChanged; } - private void finish(DragLayer dragLayer) { + private void finish(QuickstepLauncher launcher, DragLayer dragLayer) { mAppWidgetView.setAlpha(1f); GhostView.removeGhost(mAppWidgetView); ((ViewGroup) dragLayer.getParent()).removeView(this); @@ -280,7 +279,7 @@ public class FloatingWidgetView extends FrameLayout implements AnimatorListener, // Removing GhostView must occur before ending deferrals. See b/190818220 mAppWidgetView.endDeferringUpdates(); recycle(); - mLauncher.getViewCache().recycleView(R.layout.floating_widget_view, this); + launcher.getViewCache().recycleView(R.layout.floating_widget_view, this); } public float getInitialCornerRadius() { @@ -323,7 +322,7 @@ public class FloatingWidgetView extends FrameLayout implements AnimatorListener, launcher.getViewCache().getView(R.layout.floating_widget_view, launcher, parent); floatingView.recycle(); - floatingView.init(dragLayer, originalView, widgetBackgroundPosition, windowSize, + floatingView.init(launcher, dragLayer, originalView, widgetBackgroundPosition, windowSize, windowCornerRadius, appTargetsAreTranslucent, fallbackBackgroundColor); parent.addView(floatingView); return floatingView; diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 927c93b1fb..1ecee82789 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -239,7 +239,6 @@ import com.android.launcher3.util.Themes; import com.android.launcher3.util.Thunk; import com.android.launcher3.util.TouchController; import com.android.launcher3.util.TraceHelper; -import com.android.launcher3.views.ActivityContext; import com.android.launcher3.views.FloatingIconView; import com.android.launcher3.views.FloatingSurfaceView; import com.android.launcher3.views.OptionsPopupView; @@ -2655,14 +2654,6 @@ public class Launcher extends StatefulActivity @VisibleForTesting public void enableHotseatEdu(boolean enable) {} - - /** - * Just a wrapper around the type cast to allow easier tracking of calls. - */ - public static T cast(ActivityContext activityContext) { - return (T) activityContext; - } - public boolean supportsAdaptiveIconAnimation(View clickedView) { return false; }