diff --git a/quickstep/res/values/config.xml b/quickstep/res/values/config.xml index 3b4a28b39c..198a6763ed 100644 --- a/quickstep/res/values/config.xml +++ b/quickstep/res/values/config.xml @@ -43,4 +43,9 @@ + + + + @*android:dimen/config_wallpaperMaxScale + diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index 00520ee356..a3f16029c2 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -42,7 +42,7 @@ import static com.android.launcher3.config.FeatureFlags.ENABLE_SCRIM_FOR_APP_LAU import static com.android.launcher3.config.FeatureFlags.KEYGUARD_ANIMATION; import static com.android.launcher3.config.FeatureFlags.SEPARATE_RECENTS_ACTIVITY; import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID; -import static com.android.launcher3.statehandlers.DepthController.DEPTH; +import static com.android.launcher3.statehandlers.DepthController.STATE_DEPTH; import static com.android.launcher3.util.window.RefreshRateTracker.getSingleFrameMs; import static com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION; import static com.android.launcher3.views.FloatingIconView.getFloatingIconView; @@ -58,6 +58,8 @@ import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.ValueAnimator; +import android.app.ActivityOptions; +import android.app.WindowConfiguration; import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; @@ -84,6 +86,7 @@ import android.view.SurfaceControl; import android.view.View; import android.view.ViewRootImpl; import android.view.ViewTreeObserver; +import android.view.WindowManager; import android.view.animation.AnimationUtils; import android.view.animation.Interpolator; import android.view.animation.PathInterpolator; @@ -124,8 +127,6 @@ import com.android.quickstep.util.SurfaceTransactionApplier; import com.android.quickstep.util.WorkspaceRevealAnim; import com.android.quickstep.views.FloatingWidgetView; import com.android.quickstep.views.RecentsView; -import com.android.systemui.shared.system.ActivityCompat; -import com.android.systemui.shared.system.ActivityOptionsCompat; import com.android.systemui.shared.system.BlurUtils; import com.android.systemui.shared.system.InteractionJankMonitorWrapper; import com.android.systemui.shared.system.QuickStepContract; @@ -135,7 +136,6 @@ 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; import com.android.wm.shell.startingsurface.IStartingWindowListener; import java.util.ArrayList; @@ -294,8 +294,10 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener RemoteAnimationAdapterCompat adapterCompat = new RemoteAnimationAdapterCompat(runner, duration, statusBarTransitionDelay, mLauncher.getIApplicationThread()); - return new ActivityOptionsWrapper( - ActivityOptionsCompat.makeRemoteAnimation(adapterCompat), onEndCallback); + ActivityOptions options = ActivityOptions.makeRemoteAnimation( + adapterCompat.getWrapped(), + adapterCompat.getRemoteTransition().getTransition()); + return new ActivityOptionsWrapper(options, onEndCallback); } /** @@ -385,7 +387,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener @Override public void onAnimationStart(Animator animation) { mLauncher.addOnResumeCallback(() -> - ObjectAnimator.ofFloat(mLauncher.getDepthController(), DEPTH, + ObjectAnimator.ofFloat(mLauncher.getDepthController(), STATE_DEPTH, mLauncher.getStateManager().getState().getDepth( mLauncher)).start()); } @@ -409,7 +411,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener @Override public void onAnimationStart(Animator animation) { mLauncher.addOnResumeCallback(() -> - ObjectAnimator.ofFloat(mLauncher.getDepthController(), DEPTH, + ObjectAnimator.ofFloat(mLauncher.getDepthController(), STATE_DEPTH, mLauncher.getStateManager().getState().getDepth( mLauncher)).start()); } @@ -1052,7 +1054,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener && BlurUtils.supportsBlursOnWindows(); MyDepthController depthController = new MyDepthController(mLauncher); - ObjectAnimator backgroundRadiusAnim = ObjectAnimator.ofFloat(depthController, DEPTH, + ObjectAnimator backgroundRadiusAnim = ObjectAnimator.ofFloat(depthController, STATE_DEPTH, BACKGROUND_APP.getDepth(mLauncher)) .setDuration(APP_LAUNCH_DURATION); @@ -1093,8 +1095,8 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener mWallpaperOpenRunner = createWallpaperOpenRunner(false /* fromUnlock */); RemoteAnimationDefinitionCompat definition = new RemoteAnimationDefinitionCompat(); - definition.addRemoteAnimation(WindowManagerWrapper.TRANSIT_WALLPAPER_OPEN, - WindowManagerWrapper.ACTIVITY_TYPE_STANDARD, + definition.addRemoteAnimation(WindowManager.TRANSIT_OLD_WALLPAPER_OPEN, + WindowConfiguration.ACTIVITY_TYPE_STANDARD, new RemoteAnimationAdapterCompat( new LauncherAnimationRunner(mHandler, mWallpaperOpenRunner, false /* startAtFrontOfQueue */), @@ -1104,7 +1106,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener if (KEYGUARD_ANIMATION.get()) { mKeyguardGoingAwayRunner = createWallpaperOpenRunner(true /* fromUnlock */); definition.addRemoteAnimation( - WindowManagerWrapper.TRANSIT_KEYGUARD_GOING_AWAY_ON_WALLPAPER, + WindowManager.TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER, new RemoteAnimationAdapterCompat( new LauncherAnimationRunner( mHandler, mKeyguardGoingAwayRunner, @@ -1113,7 +1115,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener mLauncher.getIApplicationThread())); } - new ActivityCompat(mLauncher).registerRemoteAnimations(definition); + mLauncher.registerRemoteAnimations(definition.getWrapped()); } } @@ -1152,7 +1154,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener return; } if (hasControlRemoteAppTransitionPermission()) { - new ActivityCompat(mLauncher).unregisterRemoteAnimations(); + mLauncher.unregisterRemoteAnimations(); // Also clear strong references to the runners registered with the remote animation // definition so we don't have to wait for the system gc @@ -1601,7 +1603,8 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener true /* animateOverviewScrim */, launcherView).getAnimators()); if (!areAllTargetsTranslucent(appTargets)) { - anim.play(ObjectAnimator.ofFloat(mLauncher.getDepthController(), DEPTH, + anim.play(ObjectAnimator.ofFloat(mLauncher.getDepthController(), + STATE_DEPTH, BACKGROUND_APP.getDepth(mLauncher), NORMAL.getDepth(mLauncher))); } diff --git a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java index 4b8b5f7d7c..e3fd3f9a06 100644 --- a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java +++ b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java @@ -165,7 +165,8 @@ public class DepthController extends BaseDepthController implements StateHandler float toDepth = toState.getDepth(mLauncher); if (Float.compare(mDepth, toDepth) != 0) { - animation.setFloat(this, DEPTH, toDepth, config.getInterpolator(ANIM_DEPTH, LINEAR)); + animation.setFloat(this, STATE_DEPTH, toDepth, + config.getInterpolator(ANIM_DEPTH, LINEAR)); } } @@ -179,7 +180,7 @@ public class DepthController extends BaseDepthController implements StateHandler public void onMultiWindowModeChanged(boolean isInMultiWindowMode) { mIgnoreStateChangesDuringMultiWindowAnimation = true; - ObjectAnimator mwAnimation = ObjectAnimator.ofFloat(this, DEPTH, + ObjectAnimator mwAnimation = ObjectAnimator.ofFloat(this, STATE_DEPTH, mLauncher.getStateManager().getState().getDepth(mLauncher, isInMultiWindowMode)) .setDuration(300); mwAnimation.addListener(new AnimatorListenerAdapter() { diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java index 520487e98a..a219ac6324 100644 --- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java +++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java @@ -15,9 +15,10 @@ */ package com.android.launcher3.taskbar; +import static android.view.InsetsState.ITYPE_EXTRA_NAVIGATION_BAR; + import static com.android.launcher3.taskbar.TaskbarLauncherStateController.FLAG_RESUMED; import static com.android.quickstep.TaskAnimationManager.ENABLE_SHELL_TRANSITIONS; -import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_EXTRA_NAVIGATION_BAR; import android.animation.Animator; import android.animation.AnimatorSet; diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java index dd19091a73..16f6d267d8 100644 --- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java @@ -17,6 +17,7 @@ package com.android.launcher3.taskbar; import static android.view.View.AccessibilityDelegate; import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; +import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION; import static com.android.launcher3.LauncherAnimUtils.VIEW_TRANSLATE_X; import static com.android.launcher3.Utilities.getDescendantCoordRelativeToAncestor; @@ -42,7 +43,6 @@ import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_O import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_QUICK_SETTINGS_EXPANDED; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_VOICE_INTERACTION_WINDOW_SHOWING; -import static com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo.TOUCHABLE_INSETS_REGION; import android.animation.ArgbEvaluator; import android.animation.ObjectAnimator; @@ -69,6 +69,7 @@ import android.view.View.OnAttachStateChangeListener; import android.view.View.OnClickListener; import android.view.View.OnHoverListener; import android.view.ViewGroup; +import android.view.ViewTreeObserver; import android.view.WindowManager; import android.widget.FrameLayout; import android.widget.ImageView; @@ -88,7 +89,6 @@ import com.android.systemui.shared.rotation.FloatingRotationButton; import com.android.systemui.shared.rotation.RotationButton; import com.android.systemui.shared.rotation.RotationButtonController; import com.android.systemui.shared.system.QuickStepContract; -import com.android.systemui.shared.system.ViewTreeObserverWrapper; import java.io.PrintWriter; import java.util.ArrayList; @@ -167,7 +167,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT // Variables for moving nav buttons to a separate window above IME private boolean mAreNavButtonsInSeparateWindow = false; private BaseDragLayer mSeparateWindowParent; // Initialized in init. - private final ViewTreeObserverWrapper.OnComputeInsetsListener mSeparateWindowInsetsComputer = + private final ViewTreeObserver.OnComputeInternalInsetsListener mSeparateWindowInsetsComputer = this::onComputeInsetsForSeparateWindow; private final RecentsHitboxExtender mHitboxExtender = new RecentsHitboxExtender(); @@ -833,14 +833,14 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT mSeparateWindowParent.addOnAttachStateChangeListener(new OnAttachStateChangeListener() { @Override public void onViewAttachedToWindow(View view) { - ViewTreeObserverWrapper.addOnComputeInsetsListener( - mSeparateWindowParent.getViewTreeObserver(), mSeparateWindowInsetsComputer); + mSeparateWindowParent.getViewTreeObserver().addOnComputeInternalInsetsListener( + mSeparateWindowInsetsComputer); } @Override public void onViewDetachedFromWindow(View view) { mSeparateWindowParent.removeOnAttachStateChangeListener(this); - ViewTreeObserverWrapper.removeOnComputeInsetsListener( + mSeparateWindowParent.getViewTreeObserver().removeOnComputeInternalInsetsListener( mSeparateWindowInsetsComputer); } }); @@ -868,7 +868,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT mContext.getDragLayer().addView(mNavButtonsView); } - private void onComputeInsetsForSeparateWindow(ViewTreeObserverWrapper.InsetsInfo insetsInfo) { + private void onComputeInsetsForSeparateWindow(ViewTreeObserver.InternalInsetsInfo insetsInfo) { addVisibleButtonsRegion(mSeparateWindowParent, insetsInfo.touchableRegion); insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION); } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayer.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayer.java index ee17ad0e1f..7e75779c62 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayer.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayer.java @@ -24,6 +24,7 @@ import android.util.AttributeSet; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; +import android.view.ViewTreeObserver; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -32,9 +33,6 @@ import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.testing.TestLogging; import com.android.launcher3.testing.shared.TestProtocol; import com.android.launcher3.views.BaseDragLayer; -import com.android.systemui.shared.system.ViewTreeObserverWrapper; -import com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo; -import com.android.systemui.shared.system.ViewTreeObserverWrapper.OnComputeInsetsListener; /** * Top-level ViewGroup that hosts the TaskbarView as well as Views created by it such as Folder. @@ -42,7 +40,8 @@ import com.android.systemui.shared.system.ViewTreeObserverWrapper.OnComputeInset public class TaskbarDragLayer extends BaseDragLayer { private final TaskbarBackgroundRenderer mBackgroundRenderer; - private final OnComputeInsetsListener mTaskbarInsetsComputer = this::onComputeTaskbarInsets; + private final ViewTreeObserver.OnComputeInternalInsetsListener mTaskbarInsetsComputer = + this::onComputeTaskbarInsets; // Initialized in init. private TaskbarDragLayerController.TaskbarDragLayerCallbacks mControllerCallbacks; @@ -80,7 +79,7 @@ public class TaskbarDragLayer extends BaseDragLayer { mControllers = mControllerCallbacks.getTouchControllers(); } - private void onComputeTaskbarInsets(InsetsInfo insetsInfo) { + private void onComputeTaskbarInsets(ViewTreeObserver.InternalInsetsInfo insetsInfo) { if (mControllerCallbacks != null) { mControllerCallbacks.updateInsetsTouchability(insetsInfo); } @@ -88,7 +87,7 @@ public class TaskbarDragLayer extends BaseDragLayer { protected void onDestroy(boolean forceDestroy) { if (forceDestroy) { - ViewTreeObserverWrapper.removeOnComputeInsetsListener(mTaskbarInsetsComputer); + getViewTreeObserver().removeOnComputeInternalInsetsListener(mTaskbarInsetsComputer); } } @@ -99,8 +98,7 @@ public class TaskbarDragLayer extends BaseDragLayer { @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); - ViewTreeObserverWrapper.addOnComputeInsetsListener(getViewTreeObserver(), - mTaskbarInsetsComputer); + getViewTreeObserver().addOnComputeInternalInsetsListener(mTaskbarInsetsComputer); } @Override diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java index ec9760c61f..025fe7a017 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java @@ -17,12 +17,12 @@ package com.android.launcher3.taskbar; import android.content.res.Resources; import android.graphics.Rect; +import android.view.ViewTreeObserver; import com.android.launcher3.DeviceProfile; import com.android.launcher3.R; import com.android.launcher3.util.TouchController; import com.android.quickstep.AnimatedFloat; -import com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo; import java.io.PrintWriter; @@ -157,9 +157,9 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa /** * Called to update the touchable insets. - * @see InsetsInfo#setTouchableInsets(int) + * @see ViewTreeObserver.InternalInsetsInfo#setTouchableInsets(int) */ - public void updateInsetsTouchability(InsetsInfo insetsInfo) { + public void updateInsetsTouchability(ViewTreeObserver.InternalInsetsInfo insetsInfo) { mControllers.taskbarInsetsController.updateInsetsTouchability(insetsInfo); } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt index 48fde8f26e..7b2b7eca7f 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt @@ -20,6 +20,11 @@ import android.graphics.Region import android.view.InsetsFrameProvider import android.view.InsetsState.ITYPE_BOTTOM_MANDATORY_GESTURES import android.view.InsetsState +import android.view.InsetsState.ITYPE_BOTTOM_TAPPABLE_ELEMENT +import android.view.InsetsState.ITYPE_EXTRA_NAVIGATION_BAR +import android.view.ViewTreeObserver +import android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME +import android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION import android.view.WindowManager import android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD import android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION @@ -29,9 +34,6 @@ import com.android.launcher3.DeviceProfile import com.android.launcher3.anim.AlphaUpdateListener import com.android.launcher3.taskbar.TaskbarControllers.LoggableTaskbarController import com.android.quickstep.KtR -import com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo -import com.android.systemui.shared.system.WindowManagerWrapper -import com.android.systemui.shared.system.WindowManagerWrapper.* import java.io.PrintWriter /** @@ -55,8 +57,7 @@ class TaskbarInsetsController(val context: TaskbarActivityContext): LoggableTask this.controllers = controllers windowLayoutParams = context.windowLayoutParams - val wmWrapper: WindowManagerWrapper = getInstance() - wmWrapper.setProvidesInsetsTypes( + setProvidesInsetsTypes( windowLayoutParams, intArrayOf( ITYPE_EXTRA_NAVIGATION_BAR, @@ -108,10 +109,22 @@ class TaskbarInsetsController(val context: TaskbarActivityContext): LoggableTask } /** - * Called to update the touchable insets. - * @see InsetsInfo.setTouchableInsets + * Sets {@param providesInsetsTypes} as the inset types provided by {@param params}. + * @param params The window layout params. + * @param providesInsetsTypes The inset types we would like this layout params to provide. */ - fun updateInsetsTouchability(insetsInfo: InsetsInfo) { + fun setProvidesInsetsTypes(params: WindowManager.LayoutParams, providesInsetsTypes: IntArray) { + params.providedInsets = arrayOfNulls(providesInsetsTypes.size); + for (i in providesInsetsTypes.indices) { + params.providedInsets[i] = InsetsFrameProvider(providesInsetsTypes[i]); + } + } + + /** + * Called to update the touchable insets. + * @see InternalInsetsInfo.setTouchableInsets + */ + fun updateInsetsTouchability(insetsInfo: ViewTreeObserver.InternalInsetsInfo) { insetsInfo.touchableRegion.setEmpty() // Always have nav buttons be touchable controllers.navbarButtonsViewController.addVisibleButtonsRegion( @@ -120,18 +133,18 @@ class TaskbarInsetsController(val context: TaskbarActivityContext): LoggableTask var insetsIsTouchableRegion = true if (context.dragLayer.alpha < AlphaUpdateListener.ALPHA_CUTOFF_THRESHOLD) { // Let touches pass through us. - insetsInfo.setTouchableInsets(InsetsInfo.TOUCHABLE_INSETS_REGION) + insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION) } else if (controllers.navbarButtonsViewController.isImeVisible) { - insetsInfo.setTouchableInsets(InsetsInfo.TOUCHABLE_INSETS_REGION) + insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION) } else if (!controllers.uiController.isTaskbarTouchable) { // Let touches pass through us. - insetsInfo.setTouchableInsets(InsetsInfo.TOUCHABLE_INSETS_REGION) + insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION) } else if (controllers.taskbarDragController.isSystemDragInProgress) { // Let touches pass through us. - insetsInfo.setTouchableInsets(InsetsInfo.TOUCHABLE_INSETS_REGION) + insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION) } else if (AbstractFloatingView.hasOpenView(context, TYPE_TASKBAR_ALL_APPS)) { // Let touches pass through us. - insetsInfo.setTouchableInsets(InsetsInfo.TOUCHABLE_INSETS_REGION) + insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION) } else if (controllers.taskbarViewController.areIconsVisible() || AbstractFloatingView.hasOpenView(context, AbstractFloatingView.TYPE_ALL) || context.isNavBarKidsModeActive @@ -139,15 +152,15 @@ class TaskbarInsetsController(val context: TaskbarActivityContext): LoggableTask // Taskbar has some touchable elements, take over the full taskbar area insetsInfo.setTouchableInsets( if (context.isTaskbarWindowFullscreen) { - InsetsInfo.TOUCHABLE_INSETS_FRAME + TOUCHABLE_INSETS_FRAME } else { insetsInfo.touchableRegion.set(contentRegion) - InsetsInfo.TOUCHABLE_INSETS_REGION + TOUCHABLE_INSETS_REGION } ) insetsIsTouchableRegion = false } else { - insetsInfo.setTouchableInsets(InsetsInfo.TOUCHABLE_INSETS_REGION) + insetsInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION) } context.excludeFromMagnificationRegion(insetsIsTouchableRegion) } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java index d9d55e765f..d60bf8c896 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java @@ -32,6 +32,7 @@ import android.annotation.Nullable; import android.content.SharedPreferences; import android.content.res.Resources; import android.util.Log; +import android.view.InsetsController; import android.view.View; import android.view.ViewConfiguration; @@ -46,7 +47,6 @@ import com.android.launcher3.testing.shared.TestProtocol; import com.android.launcher3.util.MultiValueAlpha.AlphaProperty; import com.android.quickstep.AnimatedFloat; import com.android.quickstep.SystemUiProxy; -import com.android.systemui.shared.system.WindowManagerWrapper; import java.io.PrintWriter; import java.util.Arrays; @@ -96,7 +96,7 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba * How long to stash/unstash when manually invoked via long press. */ public static final long TASKBAR_STASH_DURATION = - WindowManagerWrapper.ANIMATION_DURATION_RESIZE; + InsetsController.ANIMATION_DURATION_RESIZE; /** * How long to stash/unstash when keyboard is appearing/disappearing. diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java index c76180e6f0..a1385c45c6 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsContext.java @@ -17,15 +17,16 @@ package com.android.launcher3.taskbar.allapps; import static android.view.KeyEvent.ACTION_UP; import static android.view.KeyEvent.KEYCODE_BACK; +import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; -import static com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo.TOUCHABLE_INSETS_REGION; - import android.content.Context; import android.graphics.Insets; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; +import android.view.ViewTreeObserver; +import android.view.ViewTreeObserver.OnComputeInternalInsetsListener; import android.view.WindowInsets; import com.android.launcher3.AbstractFloatingView; @@ -47,9 +48,6 @@ import com.android.launcher3.testing.shared.TestProtocol; import com.android.launcher3.util.OnboardingPrefs; import com.android.launcher3.util.TouchController; import com.android.launcher3.views.BaseDragLayer; -import com.android.systemui.shared.system.ViewTreeObserverWrapper; -import com.android.systemui.shared.system.ViewTreeObserverWrapper.InsetsInfo; -import com.android.systemui.shared.system.ViewTreeObserverWrapper.OnComputeInsetsListener; /** * Window context for the taskbar all apps overlay. @@ -163,7 +161,7 @@ class TaskbarAllAppsContext extends BaseTaskbarContext { /** Root drag layer for this context. */ private static class TaskbarAllAppsDragLayer extends - BaseDragLayer implements OnComputeInsetsListener { + BaseDragLayer implements OnComputeInternalInsetsListener { private TaskbarAllAppsDragLayer(Context context) { super(context, null, 1); @@ -174,14 +172,13 @@ class TaskbarAllAppsContext extends BaseTaskbarContext { @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); - ViewTreeObserverWrapper.addOnComputeInsetsListener( - getViewTreeObserver(), this); + getViewTreeObserver().addOnComputeInternalInsetsListener(this); } @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); - ViewTreeObserverWrapper.removeOnComputeInsetsListener(this); + getViewTreeObserver().removeOnComputeInternalInsetsListener(this); } @Override @@ -207,7 +204,7 @@ class TaskbarAllAppsContext extends BaseTaskbarContext { } @Override - public void onComputeInsets(InsetsInfo inoutInfo) { + public void onComputeInternalInsets(ViewTreeObserver.InternalInsetsInfo inoutInfo) { if (mActivity.mDragController.isSystemDragInProgress()) { inoutInfo.touchableRegion.setEmpty(); inoutInfo.setTouchableInsets(TOUCHABLE_INSETS_REGION); diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index ad06d3e2d3..fea127a7ba 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -27,9 +27,11 @@ import static com.android.launcher3.LauncherState.NO_OFFSET; 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.anim.Interpolators.EMPHASIZED; import static com.android.launcher3.compat.AccessibilityManagerCompat.sendCustomAccessibilityEvent; import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.config.FeatureFlags.ENABLE_SPLIT_FROM_WORKSPACE; +import static com.android.launcher3.config.FeatureFlags.ENABLE_WIDGET_PICKER_DEPTH; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_TAP; import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID; import static com.android.launcher3.popup.QuickstepSystemShortcut.getSplitSelectShortcutByPosition; @@ -44,6 +46,7 @@ import static com.android.launcher3.util.DisplayController.CHANGE_ACTIVE_SCREEN; import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE; import static com.android.launcher3.util.Executors.THREAD_POOL_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; +import static com.android.quickstep.util.BaseDepthController.WIDGET_DEPTH; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_HOME_KEY; import android.animation.AnimatorSet; @@ -75,6 +78,7 @@ import com.android.launcher3.LauncherState; import com.android.launcher3.QuickstepAccessibilityDelegate; import com.android.launcher3.QuickstepTransitionManager; import com.android.launcher3.R; +import com.android.launcher3.Utilities; import com.android.launcher3.Workspace; import com.android.launcher3.accessibility.LauncherAccessibilityDelegate; import com.android.launcher3.anim.AnimatorPlaybackController; @@ -135,7 +139,6 @@ import com.android.quickstep.views.OverviewActionsView; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskView; import com.android.systemui.shared.system.ActivityManagerWrapper; -import com.android.systemui.shared.system.ActivityOptionsCompat; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; import com.android.systemui.unfold.UnfoldTransitionFactory; import com.android.systemui.unfold.UnfoldTransitionProgressProvider; @@ -583,6 +586,11 @@ public class QuickstepLauncher extends Launcher { public void onWidgetsTransition(float progress) { super.onWidgetsTransition(progress); onTaskbarInAppDisplayProgressUpdate(progress, WIDGETS_PAGE_PROGRESS_INDEX); + if (ENABLE_WIDGET_PICKER_DEPTH.get() && !Utilities.IS_RUNNING_IN_TEST_HARNESS) { + WIDGET_DEPTH.set(getDepthController(), + Utilities.mapToRange(progress, 0f, 1f, 0f, getDeviceProfile().bottomSheetDepth, + EMPHASIZED)); + } } private void onTaskbarInAppDisplayProgressUpdate(float progress, int flag) { @@ -791,8 +799,8 @@ public class QuickstepLauncher extends Launcher { ? mAppTransitionManager.getActivityLaunchOptions(v) : super.getActivityLaunchOptions(v, item); if (mLastTouchUpTime > 0) { - ActivityOptionsCompat.setLauncherSourceInfo( - activityOptions.options, mLastTouchUpTime); + activityOptions.options.setSourceInfo(ActivityOptions.SourceInfo.TYPE_LAUNCHER, + mLastTouchUpTime); } activityOptions.options.setSplashScreenStyle(SplashScreen.SPLASH_SCREEN_STYLE_ICON); activityOptions.options.setLaunchDisplayId( diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java index e21f14fa6c..fd184c63a4 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/AllAppsState.java @@ -16,7 +16,6 @@ package com.android.launcher3.uioverrides.states; import static com.android.launcher3.anim.Interpolators.DEACCEL_2; -import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_ALLAPPS; import android.content.Context; @@ -26,7 +25,6 @@ import com.android.launcher3.DeviceProfile.DeviceProfileListenable; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.R; -import com.android.launcher3.Utilities; import com.android.launcher3.util.Themes; /** @@ -44,9 +42,9 @@ public class AllAppsState extends LauncherState { @Override public int getTransitionDuration(DEVICE_PROFILE_CONTEXT context, boolean isToState) { - return context.getDeviceProfile().isTablet - ? 500 - : isToState ? 600 : 300; + return isToState + ? context.getDeviceProfile().allAppsOpenDuration + : context.getDeviceProfile().allAppsCloseDuration; } @Override @@ -83,15 +81,7 @@ public class AllAppsState extends LauncherState { protected float getDepthUnchecked(DEVICE_PROFILE_CONTEXT context) { if (context.getDeviceProfile().isTablet) { - // The goal is to set wallpaper to zoom at workspaceContentScale when in AllApps. - // When depth is 0, wallpaper zoom is set to maxWallpaperScale. - // When depth is 1, wallpaper zoom is set to 1. - // For depth to achieve zoom set to maxWallpaperScale * workspaceContentScale: - float maxWallpaperScale = context.getResources().getFloat( - com.android.internal.R.dimen.config_wallpaperMaxScale); - return Utilities.mapToRange( - maxWallpaperScale * context.getDeviceProfile().workspaceContentScale, - maxWallpaperScale, 1f, 0f, 1f, LINEAR); + return context.getDeviceProfile().bottomSheetDepth; } else { // The scrim fades in at approximately 50% of the swipe gesture. // This means that the depth should be greater than 1, in order to fully zoom out. diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 81a5c1cb9d..2b911e5c1e 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -87,6 +87,7 @@ import android.window.PictureInPictureSurfaceTransaction; import androidx.annotation.Nullable; import androidx.annotation.UiThread; +import com.android.internal.util.LatencyTracker; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.DeviceProfile; import com.android.launcher3.R; @@ -127,7 +128,6 @@ import com.android.systemui.shared.recents.model.ThumbnailData; import com.android.systemui.shared.system.ActivityManagerWrapper; import com.android.systemui.shared.system.InputConsumerController; import com.android.systemui.shared.system.InteractionJankMonitorWrapper; -import com.android.systemui.shared.system.LatencyTrackerCompat; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; import com.android.systemui.shared.system.TaskStackChangeListener; import com.android.systemui.shared.system.TaskStackChangeListeners; @@ -622,8 +622,8 @@ public abstract class AbsSwipeUpHandler, Object traceToken = TraceHelper.INSTANCE.beginSection("logToggleRecents", TraceHelper.FLAG_IGNORE_BINDERS); - LatencyTrackerCompat.logToggleRecents( - mContext, (int) (mLauncherFrameDrawnTime - mTouchTimeMs)); + LatencyTracker.getInstance(mContext).logAction(LatencyTracker.ACTION_TOGGLE_RECENTS, + (int) (mLauncherFrameDrawnTime - mTouchTimeMs)); TraceHelper.INSTANCE.endSection(traceToken); // This method is only called when STATE_GESTURE_STARTED is set, so we can enable the diff --git a/quickstep/src/com/android/quickstep/GestureState.java b/quickstep/src/com/android/quickstep/GestureState.java index 38bf1fd6d8..703db078c1 100644 --- a/quickstep/src/com/android/quickstep/GestureState.java +++ b/quickstep/src/com/android/quickstep/GestureState.java @@ -20,6 +20,7 @@ import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME; import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_OVERVIEW; import static com.android.quickstep.MultiStateCallback.DEBUG_STATES; import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.SET_END_TARGET; +import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.SET_END_TARGET_HOME; import android.annotation.Nullable; import android.annotation.TargetApi; @@ -330,6 +331,16 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL ActiveGestureLog.INSTANCE.addLog( /* event= */ "setEndTarget " + mEndTarget, /* gestureEvent= */ SET_END_TARGET); + switch (mEndTarget) { + case HOME: + ActiveGestureLog.INSTANCE.trackEvent(SET_END_TARGET_HOME); + break; + case RECENTS: + case NEW_TASK: + case LAST_TASK: + default: + // No-Op + } if (isAtomic) { mStateCallback.setState(STATE_END_TARGET_ANIMATION_FINISHED); } diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java index e84eb56759..57a26ee8ba 100644 --- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java +++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java @@ -193,7 +193,20 @@ public class OverviewCommandHelper { } } - if (activityInterface.switchToRecentsIfVisible(() -> scheduleNextTask(cmd))) { + final Runnable completeCallback = () -> { + if (cmd.type == TYPE_SHOW_NEXT_FOCUS) { + RecentsView rv = activityInterface.getVisibleRecentsView(); + // When the overview is launched via alt tab (cmd type is TYPE_SHOW_NEXT_FOCUS), + // the touch mode somehow is not change to false by the Android framework. + // The subsequent tab to go through tasks in overview can only be dispatched to + // focuses views, while focus can only be requested in + // {@link View#requestFocusNoSearch(int, Rect)} when touch mode is false. To note, + // here we launch overview from home. + rv.getViewRootImpl().touchModeChanged(false); + } + scheduleNextTask(cmd); + }; + if (activityInterface.switchToRecentsIfVisible(completeCallback)) { // If successfully switched, wait until animation finishes return false; } @@ -268,6 +281,13 @@ public class OverviewCommandHelper { RecentsView rv = mOverviewComponentObserver.getActivityInterface().getVisibleRecentsView(); if (rv != null) { + // When the overview is launched via alt tab (cmd type is TYPE_SHOW_NEXT_FOCUS), + // the touch mode somehow is not change to false by the Android framework. + // The subsequent tab to go through tasks in overview can only be dispatched to + // focuses views, while focus can only be requested in + // {@link View#requestFocusNoSearch(int, Rect)} when touch mode is false. To note, + // here we launch overview with live tile. + rv.getViewRootImpl().touchModeChanged(false); // Ensure that recents view has focus so that it receives the followup key inputs TaskView taskView = rv.getNextTaskView(); if (taskView == null) { diff --git a/quickstep/src/com/android/quickstep/RecentTasksList.java b/quickstep/src/com/android/quickstep/RecentTasksList.java index 5a9862ce0f..dea4e4884c 100644 --- a/quickstep/src/com/android/quickstep/RecentTasksList.java +++ b/quickstep/src/com/android/quickstep/RecentTasksList.java @@ -20,6 +20,7 @@ import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import android.annotation.TargetApi; import android.app.ActivityManager; +import android.app.KeyguardManager; import android.os.Build; import android.os.Process; import android.os.RemoteException; @@ -31,7 +32,6 @@ import com.android.launcher3.util.LooperExecutor; import com.android.launcher3.util.SplitConfigurationOptions; import com.android.quickstep.util.GroupTask; import com.android.systemui.shared.recents.model.Task; -import com.android.systemui.shared.system.KeyguardManagerCompat; import com.android.wm.shell.recents.IRecentTasksListener; import com.android.wm.shell.util.GroupedRecentTaskInfo; import com.android.wm.shell.util.SplitBounds; @@ -49,7 +49,7 @@ public class RecentTasksList { private static final TaskLoadResult INVALID_RESULT = new TaskLoadResult(-1, false, 0); - private final KeyguardManagerCompat mKeyguardManager; + private final KeyguardManager mKeyguardManager; private final LooperExecutor mMainThreadExecutor; private final SystemUiProxy mSysUiProxy; @@ -66,8 +66,8 @@ public class RecentTasksList { // Tasks are stored in order of least recently launched to most recently launched. private ArrayList mRunningTasks; - public RecentTasksList(LooperExecutor mainThreadExecutor, - KeyguardManagerCompat keyguardManager, SystemUiProxy sysUiProxy) { + public RecentTasksList(LooperExecutor mainThreadExecutor, KeyguardManager keyguardManager, + SystemUiProxy sysUiProxy) { mMainThreadExecutor = mainThreadExecutor; mKeyguardManager = keyguardManager; mChangeId = 1; diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java index 3e3a43178c..a2f19f18c3 100644 --- a/quickstep/src/com/android/quickstep/RecentsActivity.java +++ b/quickstep/src/com/android/quickstep/RecentsActivity.java @@ -30,6 +30,7 @@ import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MOD import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; +import android.app.ActivityOptions; import android.content.Intent; import android.content.res.Configuration; import android.os.Bundle; @@ -77,7 +78,6 @@ import com.android.quickstep.util.TISBindHelper; import com.android.quickstep.views.OverviewActionsView; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskView; -import com.android.systemui.shared.system.ActivityOptionsCompat; import com.android.systemui.shared.system.RemoteAnimationAdapterCompat; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; @@ -263,8 +263,10 @@ public final class RecentsActivity extends StatefulActivity { wrapper, RECENTS_LAUNCH_DURATION, RECENTS_LAUNCH_DURATION - STATUS_BAR_TRANSITION_DURATION - STATUS_BAR_TRANSITION_PRE_DELAY, getIApplicationThread()); - final ActivityOptionsWrapper activityOptions = new ActivityOptionsWrapper( - ActivityOptionsCompat.makeRemoteAnimation(adapterCompat), + final ActivityOptions options = ActivityOptions.makeRemoteAnimation( + adapterCompat.getWrapped(), + adapterCompat.getRemoteTransition().getTransition()); + final ActivityOptionsWrapper activityOptions = new ActivityOptionsWrapper(options, onEndCallback); activityOptions.options.setSplashScreenStyle(SplashScreen.SPLASH_SCREEN_STYLE_ICON); activityOptions.options.setLaunchDisplayId( @@ -406,8 +408,10 @@ public final class RecentsActivity extends StatefulActivity { RemoteAnimationAdapterCompat adapterCompat = new RemoteAnimationAdapterCompat(runner, HOME_APPEAR_DURATION, 0, getIApplicationThread()); - startHomeIntentSafely(this, - ActivityOptionsCompat.makeRemoteAnimation(adapterCompat).toBundle()); + ActivityOptions options = ActivityOptions.makeRemoteAnimation( + adapterCompat.getWrapped(), + adapterCompat.getRemoteTransition().getTransition()); + startHomeIntentSafely(this, options.toBundle()); } private final RemoteAnimationFactory mAnimationToHomeFactory = diff --git a/quickstep/src/com/android/quickstep/RecentsModel.java b/quickstep/src/com/android/quickstep/RecentsModel.java index 3074dbb0b2..305347414c 100644 --- a/quickstep/src/com/android/quickstep/RecentsModel.java +++ b/quickstep/src/com/android/quickstep/RecentsModel.java @@ -22,6 +22,7 @@ import static com.android.quickstep.TaskUtils.checkCurrentOrManagedUserId; import android.annotation.TargetApi; import android.app.ActivityManager; +import android.app.KeyguardManager; import android.content.ComponentCallbacks2; import android.content.Context; import android.content.Intent; @@ -40,7 +41,6 @@ import com.android.quickstep.util.TaskVisualsChangeListener; import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.recents.model.ThumbnailData; import com.android.systemui.shared.system.ActivityManagerWrapper; -import com.android.systemui.shared.system.KeyguardManagerCompat; import com.android.systemui.shared.system.TaskStackChangeListener; import com.android.systemui.shared.system.TaskStackChangeListeners; @@ -75,7 +75,8 @@ public class RecentsModel implements IconChangeListener, TaskStackChangeListener private RecentsModel(Context context) { mContext = context; mTaskList = new RecentTasksList(MAIN_EXECUTOR, - new KeyguardManagerCompat(context), SystemUiProxy.INSTANCE.get(context)); + context.getSystemService(KeyguardManager.class), + SystemUiProxy.INSTANCE.get(context)); IconProvider iconProvider = new IconProvider(context); mIconCache = new TaskIconCache(context, RECENTS_MODEL_EXECUTOR, iconProvider); diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java index 5fb806dacf..be82f76981 100644 --- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java +++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java @@ -41,7 +41,6 @@ import com.android.quickstep.util.ActiveGestureLog; import com.android.quickstep.views.RecentsView; import com.android.systemui.shared.recents.model.ThumbnailData; import com.android.systemui.shared.system.ActivityManagerWrapper; -import com.android.systemui.shared.system.ActivityOptionsCompat; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; import com.android.systemui.shared.system.RemoteTransitionCompat; import com.android.systemui.shared.system.TaskStackChangeListener; @@ -233,7 +232,8 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn RemoteTransitionCompat transition = new RemoteTransitionCompat(mCallbacks, mController != null ? mController.getController() : null, mCtx.getIApplicationThread()); - final ActivityOptions options = ActivityOptionsCompat.makeRemoteTransition(transition); + final ActivityOptions options = ActivityOptions.makeRemoteTransition( + transition.getTransition()); // Allowing to pause Home if Home is top activity and Recents is not Home. So when user // start home when recents animation is playing, the home activity can be resumed again // to let the transition controller collect Home activity. diff --git a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java index a0860eef8e..eae79dfa19 100644 --- a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java +++ b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java @@ -16,6 +16,8 @@ package com.android.quickstep; +import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; + import static com.android.launcher3.config.FeatureFlags.ENABLE_OVERVIEW_SELECTIONS; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_FREE_FORM_TAP; @@ -26,9 +28,12 @@ import android.graphics.Color; import android.graphics.Rect; import android.os.Handler; import android.os.Looper; +import android.os.RemoteException; import android.os.SystemProperties; +import android.util.Log; import android.view.View; import android.view.WindowInsets; +import android.view.WindowManagerGlobal; import android.window.SplashScreen; import androidx.annotation.Nullable; @@ -52,8 +57,6 @@ import com.android.systemui.shared.recents.view.AppTransitionAnimationSpecCompat import com.android.systemui.shared.recents.view.AppTransitionAnimationSpecsFuture; import com.android.systemui.shared.recents.view.RecentsTransition; import com.android.systemui.shared.system.ActivityManagerWrapper; -import com.android.systemui.shared.system.ActivityOptionsCompat; -import com.android.systemui.shared.system.WindowManagerWrapper; import java.util.Collections; import java.util.List; @@ -121,6 +124,7 @@ public interface TaskShortcutFactory { } class FreeformSystemShortcut extends SystemShortcut { + private static final String TAG = "FreeformSystemShortcut"; private Handler mHandler; @@ -193,7 +197,7 @@ public interface TaskShortcutFactory { taskId, thumbnail, taskBounds)); } }; - WindowManagerWrapper.getInstance().overridePendingAppTransitionMultiThumbFuture( + overridePendingAppTransitionMultiThumbFuture( future, animStartedListener, mHandler, true /* scaleUp */, taskKey.displayId); mTarget.getStatsLogManager().logger().withItemInfo(mTaskView.getItemInfo()) @@ -201,8 +205,27 @@ public interface TaskShortcutFactory { } } + /** + * Overrides a pending app transition. + */ + private void overridePendingAppTransitionMultiThumbFuture( + AppTransitionAnimationSpecsFuture animationSpecFuture, Runnable animStartedCallback, + Handler animStartedCallbackHandler, boolean scaleUp, int displayId) { + try { + WindowManagerGlobal.getWindowManagerService() + .overridePendingAppTransitionMultiThumbFuture( + animationSpecFuture.getFuture(), + RecentsTransition.wrapStartedListener(animStartedCallbackHandler, + animStartedCallback), scaleUp, displayId); + } catch (RemoteException e) { + Log.w(TAG, "Failed to override pending app transition (multi-thumbnail future): ", + e); + } + } + private ActivityOptions makeLaunchOptions(Activity activity) { - ActivityOptions activityOptions = ActivityOptionsCompat.makeFreeformOptions(); + ActivityOptions activityOptions = ActivityOptions.makeBasic(); + activityOptions.setLaunchWindowingMode(WINDOWING_MODE_FREEFORM); // Arbitrary bounds only because freeform is in dev mode right now final View decorView = activity.getWindow().getDecorView(); final WindowInsets insets = decorView.getRootWindowInsets(); diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java index 556b99ec16..cc7a3565ec 100644 --- a/quickstep/src/com/android/quickstep/TaskViewUtils.java +++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java @@ -36,7 +36,7 @@ import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.launcher3.anim.Interpolators.TOUCH_RESPONSE_INTERPOLATOR; import static com.android.launcher3.anim.Interpolators.clampToProgress; import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; -import static com.android.launcher3.statehandlers.DepthController.DEPTH; +import static com.android.launcher3.statehandlers.DepthController.STATE_DEPTH; import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING; import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_OPENING; @@ -367,7 +367,7 @@ public final class TaskViewUtils { }); if (depthController != null) { - out.setFloat(depthController, DEPTH, BACKGROUND_APP.getDepth(baseActivity), + out.setFloat(depthController, STATE_DEPTH, BACKGROUND_APP.getDepth(baseActivity), TOUCH_RESPONSE_INTERPOLATOR); } } diff --git a/quickstep/src/com/android/quickstep/util/ActiveGestureErrorDetector.java b/quickstep/src/com/android/quickstep/util/ActiveGestureErrorDetector.java index 693ef100b6..d2d123324a 100644 --- a/quickstep/src/com/android/quickstep/util/ActiveGestureErrorDetector.java +++ b/quickstep/src/com/android/quickstep/util/ActiveGestureErrorDetector.java @@ -33,9 +33,10 @@ public class ActiveGestureErrorDetector { * Enums associated to gesture navigation events. */ public enum GestureEvent { - MOTION_DOWN, MOTION_UP, SET_END_TARGET, ON_SETTLED_ON_END_TARGET, START_RECENTS_ANIMATION, - FINISH_RECENTS_ANIMATION, CANCEL_RECENTS_ANIMATION, SET_ON_PAGE_TRANSITION_END_CALLBACK, - CANCEL_CURRENT_ANIMATION, CLEANUP_SCREENSHOT, + MOTION_DOWN, MOTION_UP, SET_END_TARGET, SET_END_TARGET_HOME, ON_SETTLED_ON_END_TARGET, + START_RECENTS_ANIMATION, FINISH_RECENTS_ANIMATION, CANCEL_RECENTS_ANIMATION, + SET_ON_PAGE_TRANSITION_END_CALLBACK, CANCEL_CURRENT_ANIMATION, CLEANUP_SCREENSHOT, + SCROLLER_ANIMATION_ABORTED, /** * These GestureEvents are specifically associated to state flags that get set in @@ -123,6 +124,16 @@ public class ActiveGestureErrorDetector { + "being set.", writer); break; + case SCROLLER_ANIMATION_ABORTED: + errorDetected |= printErrorIfTrue( + encounteredEvents.contains(GestureEvent.SET_END_TARGET_HOME) + && !encounteredEvents.contains( + GestureEvent.ON_SETTLED_ON_END_TARGET), + /* errorMessage= */ prefix + "\t\trecents view scroller animation " + + "aborted after setting end target HOME, but before" + + " settling on end target.", + writer); + break; case STATE_GESTURE_COMPLETED: errorDetected |= printErrorIfTrue( !encounteredEvents.contains(GestureEvent.MOTION_UP), @@ -173,6 +184,7 @@ public class ActiveGestureErrorDetector { break; case MOTION_DOWN: case SET_END_TARGET: + case SET_END_TARGET_HOME: case START_RECENTS_ANIMATION: case SET_ON_PAGE_TRANSITION_END_CALLBACK: case CANCEL_CURRENT_ANIMATION: diff --git a/quickstep/src/com/android/quickstep/util/BaseDepthController.java b/quickstep/src/com/android/quickstep/util/BaseDepthController.java index 40306307a2..29ae9a13ca 100644 --- a/quickstep/src/com/android/quickstep/util/BaseDepthController.java +++ b/quickstep/src/com/android/quickstep/util/BaseDepthController.java @@ -24,6 +24,7 @@ import android.view.SurfaceControl; import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.Utilities; +import com.android.launcher3.util.MultiPropertyFactory; import com.android.systemui.shared.system.BlurUtils; /** @@ -31,7 +32,7 @@ import com.android.systemui.shared.system.BlurUtils; */ public class BaseDepthController { - public static final FloatProperty DEPTH = + private static final FloatProperty DEPTH = new FloatProperty("depth") { @Override public void setValue(BaseDepthController depthController, float depth) { @@ -44,6 +45,19 @@ public class BaseDepthController { } }; + private static final MultiPropertyFactory DEPTH_PROPERTY_FACTORY = + new MultiPropertyFactory<>("depthProperty", DEPTH, Float::max); + + private static final int DEPTH_INDEX_STATE_TRANSITION = 1; + private static final int DEPTH_INDEX_WIDGET = 2; + + /** Property to set the depth for state transition. */ + public static final FloatProperty STATE_DEPTH = + DEPTH_PROPERTY_FACTORY.get(DEPTH_INDEX_STATE_TRANSITION); + /** Property to set the depth for widget picker. */ + public static final FloatProperty WIDGET_DEPTH = + DEPTH_PROPERTY_FACTORY.get(DEPTH_INDEX_WIDGET); + protected final Launcher mLauncher; /** diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java index 0a49008225..1a026fc31d 100644 --- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java +++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java @@ -15,6 +15,8 @@ */ package com.android.quickstep.util; +import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; + import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; import static com.android.launcher3.states.RotationHelper.deltaRotation; import static com.android.launcher3.touch.PagedOrientationHandler.MATRIX_POST_TRANSLATE; @@ -25,7 +27,6 @@ import static com.android.launcher3.util.SplitConfigurationOptions.StagePosition import static com.android.quickstep.TaskAnimationManager.ENABLE_SHELL_TRANSITIONS; import static com.android.quickstep.util.RecentsOrientedState.postDisplayRotation; import static com.android.quickstep.util.RecentsOrientedState.preDisplayRotation; -import static com.android.systemui.shared.system.WindowManagerWrapper.WINDOWING_MODE_FULLSCREEN; import android.animation.TimeInterpolator; import android.content.Context; diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index ae0fa1dc97..ef13c538f2 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -43,7 +43,7 @@ import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TI import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_CLEAR_ALL; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_DISMISS_SWIPE_UP; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASK_LAUNCH_SWIPE_DOWN; -import static com.android.launcher3.statehandlers.DepthController.DEPTH; +import static com.android.launcher3.statehandlers.DepthController.STATE_DEPTH; import static com.android.launcher3.touch.PagedOrientationHandler.CANVAS_TRANSLATE; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; @@ -165,6 +165,8 @@ import com.android.quickstep.TaskThumbnailCache; import com.android.quickstep.TaskViewUtils; import com.android.quickstep.TopTaskTracker; import com.android.quickstep.ViewUtils; +import com.android.quickstep.util.ActiveGestureErrorDetector; +import com.android.quickstep.util.ActiveGestureLog; import com.android.quickstep.util.GroupTask; import com.android.quickstep.util.LayoutUtils; import com.android.quickstep.util.RecentsOrientedState; @@ -1236,6 +1238,8 @@ public abstract class RecentsView taskGroups) { if (mPendingAnimation != null) { mPendingAnimation.addEndListener(success -> applyLoadPlan(taskGroups)); @@ -4423,7 +4433,7 @@ public abstract class RecentsView callback.accept(true), MAIN_EXECUTOR.getHandler()); + ActivityOptions opts = makeCustomAnimation(getContext(), 0, 0, + () -> callback.accept(true), MAIN_EXECUTOR.getHandler()); opts.setLaunchDisplayId( getDisplay() == null ? DEFAULT_DISPLAY : getDisplay().getDisplayId()); if (freezeTaskList) { - ActivityOptionsCompat.setFreezeRecentTasksList(opts); + opts.setFreezeRecentTasksReordering(); } // TODO(b/202826469): Replace setSplashScreenStyle with setDisableStartingWindow. opts.setSplashScreenStyle(mSnapshotView.shouldShowSplashView() @@ -686,6 +686,20 @@ public class TaskView extends FrameLayout implements Reusable { } } + /** + * Returns ActivityOptions for overriding task transition animation. + */ + private ActivityOptions makeCustomAnimation(Context context, int enterResId, + int exitResId, final Runnable callback, final Handler callbackHandler) { + return ActivityOptions.makeCustomTaskAnimation(context, enterResId, exitResId, + callbackHandler, + elapsedRealTime -> { + if (callback != null) { + callbackHandler.post(callback); + } + }, null /* finishedListener */); + } + /** * Launch of the current task (both live and inactive tasks) with an animation. */ diff --git a/quickstep/tests/src/com/android/quickstep/RecentTasksListTest.java b/quickstep/tests/src/com/android/quickstep/RecentTasksListTest.java index 262dc37e75..ed5526f410 100644 --- a/quickstep/tests/src/com/android/quickstep/RecentTasksListTest.java +++ b/quickstep/tests/src/com/android/quickstep/RecentTasksListTest.java @@ -26,12 +26,12 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.ActivityManager; +import android.app.KeyguardManager; import androidx.test.filters.SmallTest; import com.android.launcher3.util.LooperExecutor; import com.android.quickstep.util.GroupTask; -import com.android.systemui.shared.system.KeyguardManagerCompat; import com.android.wm.shell.util.GroupedRecentTaskInfo; import org.junit.Before; @@ -56,8 +56,8 @@ public class RecentTasksListTest { public void setup() { MockitoAnnotations.initMocks(this); LooperExecutor mockMainThreadExecutor = mock(LooperExecutor.class); - KeyguardManagerCompat mockKeyguardManagerCompat = mock(KeyguardManagerCompat.class); - mRecentTasksList = new RecentTasksList(mockMainThreadExecutor, mockKeyguardManagerCompat, + KeyguardManager mockKeyguardManager = mock(KeyguardManager.class); + mRecentTasksList = new RecentTasksList(mockMainThreadExecutor, mockKeyguardManager, mockSystemUiProxy); } diff --git a/res/values-sw600dp/config.xml b/res/values-sw600dp/config.xml index 072b92d5f2..e718d9cea5 100644 --- a/res/values-sw600dp/config.xml +++ b/res/values-sw600dp/config.xml @@ -18,4 +18,11 @@ 550 + + 500 + 500 + + + @integer/config_bottomSheetOpenDuration + @integer/config_bottomSheetCloseDuration diff --git a/res/values/config.xml b/res/values/config.xml index d4c08d0742..d3f5033f0b 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -193,4 +193,15 @@ 10dp 160dp 40dp + + + 267 + 267 + + + 600 + 300 + + + 0 diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 0292e0402d..4cad919c3b 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -22,6 +22,7 @@ import static com.android.launcher3.InvariantDeviceProfile.INDEX_TWO_PANEL_LANDS import static com.android.launcher3.InvariantDeviceProfile.INDEX_TWO_PANEL_PORTRAIT; import static com.android.launcher3.Utilities.dpiFromPx; import static com.android.launcher3.Utilities.pxFromSp; +import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.ICON_OVERLAP_FACTOR; import static com.android.launcher3.icons.GraphicsUtils.getShapePath; import static com.android.launcher3.testing.shared.ResourceUtils.pxFromDp; @@ -181,11 +182,19 @@ public class DeviceProfile { private final int hotseatQsbShadowHeight; public int hotseatBorderSpace; + // Bottom sheets + public int bottomSheetTopPadding; + public int bottomSheetOpenDuration; + public int bottomSheetCloseDuration; + public float bottomSheetWorkspaceScale; + public float bottomSheetDepth; + // All apps public Point allAppsBorderSpacePx; public int allAppsShiftRange; public int allAppsTopPadding; - public int bottomSheetTopPadding; + public int allAppsOpenDuration; + public int allAppsCloseDuration; public int allAppsCellHeightPx; public int allAppsCellWidthPx; public int allAppsIconSizePx; @@ -316,6 +325,21 @@ public class DeviceProfile { bottomSheetTopPadding = mInsets.top // statusbar height + res.getDimensionPixelSize(R.dimen.bottom_sheet_extra_top_padding) + (isTablet ? 0 : edgeMarginPx); // phones need edgeMarginPx additional padding + bottomSheetOpenDuration = res.getInteger(R.integer.config_bottomSheetOpenDuration); + bottomSheetCloseDuration = res.getInteger(R.integer.config_bottomSheetCloseDuration); + if (isTablet) { + bottomSheetWorkspaceScale = workspaceContentScale; + // The goal is to set wallpaper to zoom at workspaceContentScale when in AllApps. + // When depth is 0, wallpaper zoom is set to maxWallpaperScale. + // When depth is 1, wallpaper zoom is set to 1. + // For depth to achieve zoom set to maxWallpaperScale * workspaceContentScale: + float maxWallpaperScale = res.getFloat(R.dimen.config_wallpaperMaxScale); + bottomSheetDepth = Utilities.mapToRange(maxWallpaperScale * workspaceContentScale, + maxWallpaperScale, 1f, 0f, 1f, LINEAR); + } else { + bottomSheetWorkspaceScale = 1f; + bottomSheetDepth = 0f; + } folderLabelTextScale = res.getFloat(R.dimen.folder_label_text_scale); folderContentPaddingLeftRight = @@ -474,6 +498,8 @@ public class DeviceProfile { allAppsShiftRange = res.getDimensionPixelSize(R.dimen.all_apps_starting_vertical_translate); } + allAppsOpenDuration = res.getInteger(R.integer.config_allAppsOpenDuration); + allAppsCloseDuration = res.getInteger(R.integer.config_allAppsCloseDuration); flingToDeleteThresholdVelocity = res.getDimensionPixelSize( R.dimen.drag_flingToDeleteMinVelocity); @@ -1434,9 +1460,15 @@ public class DeviceProfile { writer.println(prefix + pxToDpStr("folderTopPadding", folderContentPaddingTop)); writer.println(prefix + pxToDpStr("bottomSheetTopPadding", bottomSheetTopPadding)); + writer.println(prefix + "\tbottomSheetOpenDuration: " + bottomSheetOpenDuration); + writer.println(prefix + "\tbottomSheetCloseDuration: " + bottomSheetCloseDuration); + writer.println(prefix + "\tbottomSheetWorkspaceScale: " + bottomSheetWorkspaceScale); + writer.println(prefix + "\tbottomSheetDepth: " + bottomSheetDepth); writer.println(prefix + pxToDpStr("allAppsShiftRange", allAppsShiftRange)); writer.println(prefix + pxToDpStr("allAppsTopPadding", allAppsTopPadding)); + writer.println(prefix + "\tallAppsOpenDuration: " + allAppsOpenDuration); + writer.println(prefix + "\tallAppsCloseDuration: " + allAppsCloseDuration); writer.println(prefix + pxToDpStr("allAppsIconSizePx", allAppsIconSizePx)); writer.println(prefix + pxToDpStr("allAppsIconTextSizePx", allAppsIconTextSizePx)); writer.println(prefix + pxToDpStr("allAppsIconDrawablePaddingPx", diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 6bdfa1c8b0..ce95b159c0 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -42,6 +42,7 @@ import static com.android.launcher3.LauncherState.NO_SCALE; import static com.android.launcher3.LauncherState.SPRING_LOADED; import static com.android.launcher3.Utilities.postAsyncCallback; import static com.android.launcher3.accessibility.LauncherAccessibilityDelegate.getSupportedActions; +import static com.android.launcher3.anim.Interpolators.EMPHASIZED; import static com.android.launcher3.logging.StatsLogManager.EventEnum; import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_BACKGROUND; import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME; @@ -3234,12 +3235,10 @@ public class Launcher extends StatefulActivity * @param progress Transition progress from 0 to 1; where 0 => home and 1 => widgets. */ public void onWidgetsTransition(float progress) { - if (mDeviceProfile.isTablet) { - float scale = - Utilities.comp(Utilities.comp(mDeviceProfile.workspaceContentScale) * progress); - WORKSPACE_WIDGET_SCALE.set(getWorkspace(), scale); - HOTSEAT_WIDGET_SCALE.set(getHotseat(), scale); - } + float scale = Utilities.mapToRange(progress, 0f, 1f, 1f, + mDeviceProfile.bottomSheetWorkspaceScale, EMPHASIZED); + WORKSPACE_WIDGET_SCALE.set(getWorkspace(), scale); + HOTSEAT_WIDGET_SCALE.set(getHotseat(), scale); } private static class NonConfigInstance { diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index 135cc13a0c..377843cb3b 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -259,8 +259,13 @@ public abstract class PagedView extends ViewGrou abortScrollerAnimation(true); } + protected void onScrollerAnimationAborted() { + // No-Op + } + private void abortScrollerAnimation(boolean resetNextPage) { mScroller.abortAnimation(); + onScrollerAnimationAborted(); // We need to clean up the next page here to avoid computeScrollHelper from // updating current page on the pass. if (resetNextPage) { @@ -555,11 +560,11 @@ public abstract class PagedView extends ViewGrou if (mAllowOverScroll) { if (newPos < mMinScroll && oldPos >= mMinScroll) { mEdgeGlowLeft.onAbsorb((int) mScroller.getCurrVelocity()); - mScroller.abortAnimation(); + abortScrollerAnimation(false); onEdgeAbsorbingScroll(); } else if (newPos > mMaxScroll && oldPos <= mMaxScroll) { mEdgeGlowRight.onAbsorb((int) mScroller.getCurrVelocity()); - mScroller.abortAnimation(); + abortScrollerAnimation(false); onEdgeAbsorbingScroll(); } } @@ -569,7 +574,7 @@ public abstract class PagedView extends ViewGrou int finalPos = mOrientationHandler.getPrimaryValue(mScroller.getFinalX(), mScroller.getFinalY()); if (newPos == finalPos && mEdgeGlowLeft.isFinished() && mEdgeGlowRight.isFinished()) { - mScroller.abortAnimation(); + abortScrollerAnimation(false); } invalidate(); diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index 1cec9d0d94..22e8bcff49 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -42,7 +42,7 @@ import com.android.launcher3.anim.PropertySetter; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.statemanager.StateManager.StateHandler; import com.android.launcher3.states.StateAnimationConfig; -import com.android.launcher3.util.MultiAdditivePropertyFactory; +import com.android.launcher3.util.MultiPropertyFactory; import com.android.launcher3.util.MultiValueAlpha; import com.android.launcher3.views.ScrimView; @@ -141,9 +141,9 @@ public class AllAppsTransitionController private ScrimView mScrimView; - private final MultiAdditivePropertyFactory - mAppsViewTranslationYPropertyFactory = new MultiAdditivePropertyFactory<>( - "appsViewTranslationY", View.TRANSLATION_Y); + private final MultiPropertyFactory + mAppsViewTranslationYPropertyFactory = new MultiPropertyFactory<>( + "appsViewTranslationY", View.TRANSLATION_Y, Float::sum); private MultiValueAlpha mAppsViewAlpha; private boolean mIsTablet; diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 880180ac7a..25823d37bd 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -302,6 +302,11 @@ public final class FeatureFlags { "Enable option to log the keyboard latency for both atomic and controlled keyboard " + "animations on an EditText"); + // Change of wallpaper depth in widget picker is disabled for tests as it causes flakiness on + // very slow cuttlefish devices. + public static final BooleanFlag ENABLE_WIDGET_PICKER_DEPTH = new DeviceFlag( + "ENABLE_WIDGET_PICKER_DEPTH", true, "Enable changing depth in widget picker."); + public static void initialize(Context context) { synchronized (sDebugFlags) { for (DebugFlag flag : sDebugFlags) { diff --git a/src/com/android/launcher3/util/MultiAdditivePropertyFactory.java b/src/com/android/launcher3/util/MultiPropertyFactory.java similarity index 70% rename from src/com/android/launcher3/util/MultiAdditivePropertyFactory.java rename to src/com/android/launcher3/util/MultiPropertyFactory.java index 50f7027407..e7a7785323 100644 --- a/src/com/android/launcher3/util/MultiAdditivePropertyFactory.java +++ b/src/com/android/launcher3/util/MultiPropertyFactory.java @@ -20,7 +20,6 @@ import android.util.ArrayMap; import android.util.FloatProperty; import android.util.Log; import android.util.Property; -import android.view.View; /** * Allows to combine multiple values set by several sources. @@ -30,43 +29,55 @@ import android.view.View; * time. * * This class behaves similarly to [MultiValueAlpha], but is meant to be more abstract and reusable. - * It sets the addition of all values. + * It aggregate all values using the provided [aggregator]. * * @param Type where to apply the property. */ -public class MultiAdditivePropertyFactory { +public class MultiPropertyFactory { private static final boolean DEBUG = false; - private static final String TAG = "MultiAdditivePropertyFactory"; + private static final String TAG = "MultiPropertyFactory"; private final String mName; - private final ArrayMap mProperties = - new ArrayMap<>(); + private final ArrayMap mProperties = new ArrayMap<>(); // This is an optimization for cases when set is called repeatedly with the same setterIndex. private float mAggregationOfOthers = 0f; private Integer mLastIndexSet = -1; - private final Property mProperty; + private final Property mProperty; + private final FloatBiFunction mAggregator; - public MultiAdditivePropertyFactory(String name, Property property) { + /** + * Represents a function that accepts two float and produces a float. + */ + public interface FloatBiFunction { + /** + * Applies this function to the given arguments. + */ + float apply(float a, float b); + } + + public MultiPropertyFactory(String name, Property property, + FloatBiFunction aggregator) { mName = name; mProperty = property; + mAggregator = aggregator; } /** Returns the [MultiFloatProperty] associated with [inx], creating it if not present. */ - public MultiAdditiveProperty get(Integer index) { + public MultiProperty get(Integer index) { return mProperties.computeIfAbsent(index, - (k) -> new MultiAdditiveProperty(index, mName + "_" + index)); + (k) -> new MultiProperty(index, mName + "_" + index)); } /** * Each [setValue] will be aggregated with the other properties values created by the * corresponding factory. */ - class MultiAdditiveProperty extends FloatProperty { + class MultiProperty extends FloatProperty { private final int mInx; private float mValue = 0f; - MultiAdditiveProperty(int inx, String name) { + MultiProperty(int inx, String name) { super(name); mInx = inx; } @@ -77,12 +88,13 @@ public class MultiAdditivePropertyFactory { mAggregationOfOthers = 0f; mProperties.forEach((key, property) -> { if (key != mInx) { - mAggregationOfOthers += property.mValue; + mAggregationOfOthers = + mAggregator.apply(mAggregationOfOthers, property.mValue); } }); mLastIndexSet = mInx; } - float lastAggregatedValue = mAggregationOfOthers + newValue; + float lastAggregatedValue = mAggregator.apply(mAggregationOfOthers, newValue); mValue = newValue; apply(obj, lastAggregatedValue); @@ -94,13 +106,13 @@ public class MultiAdditivePropertyFactory { } @Override - public Float get(T view) { + public Float get(T object) { // The scale of the view should match mLastAggregatedValue. Still, if it has been // changed without using this property, it can differ. As this get method is usually // used to set the starting point on an animation, this would result in some jumps // when the view scale is different than the last aggregated value. To stay on the // safe side, let's return the real view scale. - return mProperty.get(view); + return mProperty.get(object); } @Override @@ -109,7 +121,7 @@ public class MultiAdditivePropertyFactory { } } - protected void apply(View view, float value) { - mProperty.set(view, value); + protected void apply(T object, float value) { + mProperty.set(object, value); } } diff --git a/src/com/android/launcher3/widget/BaseWidgetSheet.java b/src/com/android/launcher3/widget/BaseWidgetSheet.java index 5cffd48297..2ac1e9481b 100644 --- a/src/com/android/launcher3/widget/BaseWidgetSheet.java +++ b/src/com/android/launcher3/widget/BaseWidgetSheet.java @@ -15,6 +15,8 @@ */ package com.android.launcher3.widget; +import static com.android.launcher3.anim.Interpolators.EMPHASIZED; + import android.content.Context; import android.graphics.Canvas; import android.graphics.Paint; @@ -26,6 +28,7 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnLongClickListener; import android.view.WindowInsets; +import android.view.animation.Interpolator; import android.widget.Toast; import androidx.annotation.GuardedBy; @@ -246,6 +249,12 @@ public abstract class BaseWidgetSheet extends AbstractSlideInView return true; } + @Override + protected Interpolator getIdleInterpolator() { + return mActivityContext.getDeviceProfile().isTablet + ? EMPHASIZED : super.getIdleInterpolator(); + } + // // Drag related handling methods that implement {@link DragSource} interface. // diff --git a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java index 0d9198f292..da8e25c1f6 100644 --- a/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java +++ b/src/com/android/launcher3/widget/picker/WidgetsFullSheet.java @@ -85,7 +85,6 @@ public class WidgetsFullSheet extends BaseWidgetSheet implements ProviderChangedListener, OnActivePageChangedListener, WidgetsRecyclerView.HeaderViewDimensionsProvider, SearchModeListener { - private static final long DEFAULT_OPEN_DURATION = 267; private static final long FADE_IN_DURATION = 150; private static final long EDUCATION_TIP_DELAY_MS = 200; private static final long EDUCATION_DIALOG_DELAY_MS = 500; @@ -582,7 +581,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet mOpenCloseAnimator.setValues( PropertyValuesHolder.ofFloat(TRANSLATION_SHIFT, TRANSLATION_SHIFT_OPENED)); mOpenCloseAnimator - .setDuration(DEFAULT_OPEN_DURATION) + .setDuration(mActivityContext.getDeviceProfile().bottomSheetOpenDuration) .setInterpolator(AnimationUtils.loadInterpolator( getContext(), android.R.interpolator.linear_out_slow_in)); mOpenCloseAnimator.addListener(new AnimatorListenerAdapter() { @@ -603,7 +602,7 @@ public class WidgetsFullSheet extends BaseWidgetSheet @Override protected void handleClose(boolean animate) { - handleClose(animate, DEFAULT_OPEN_DURATION); + handleClose(animate, mActivityContext.getDeviceProfile().bottomSheetCloseDuration); } @Override diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java b/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java index 9daea940af..a581f91f74 100644 --- a/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java +++ b/src_ui_overrides/com/android/launcher3/uioverrides/states/AllAppsState.java @@ -42,9 +42,9 @@ public class AllAppsState extends LauncherState { @Override public int getTransitionDuration(DEVICE_PROFILE_CONTEXT context, boolean isToState) { - return !context.getDeviceProfile().isTablet && isToState - ? 600 - : isToState ? 500 : 300; + return isToState + ? context.getDeviceProfile().allAppsOpenDuration + : context.getDeviceProfile().allAppsCloseDuration; } @Override diff --git a/tests/src/com/android/launcher3/util/MultiAdditivePropertyTest.kt b/tests/src/com/android/launcher3/util/MultiPropertyFactoryTest.kt similarity index 75% rename from tests/src/com/android/launcher3/util/MultiAdditivePropertyTest.kt rename to tests/src/com/android/launcher3/util/MultiPropertyFactoryTest.kt index 309d055bad..a4f189c6b3 100644 --- a/tests/src/com/android/launcher3/util/MultiAdditivePropertyTest.kt +++ b/tests/src/com/android/launcher3/util/MultiPropertyFactoryTest.kt @@ -16,26 +16,32 @@ package com.android.launcher3.util -import android.view.View +import android.util.FloatProperty import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.google.common.truth.Truth.assertThat import org.junit.Test import org.junit.runner.RunWith -/** Unit tests for [MultiAdditivePropertyFactory] */ +/** Unit tests for [MultiPropertyFactory] */ @SmallTest @RunWith(AndroidJUnit4::class) -class MultiAdditivePropertyTest { +class MultiPropertyFactoryTest { private val received = mutableListOf() - private val factory = - object : MultiAdditivePropertyFactory("Test", View.TRANSLATION_X) { - override fun apply(obj: View?, value: Float) { - received.add(value) - } + private val receiveProperty: FloatProperty = object : FloatProperty("receive") { + override fun setValue(obj: Any?, value: Float) { + received.add(value) } + override fun get(o: Any): Float { + return 0f + } + } + + private val factory = MultiPropertyFactory("depth_property", receiveProperty) { + x: Float, y: Float -> x + y + } private val p1 = factory.get(1) private val p2 = factory.get(2) diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 1fecde5643..57315f96dc 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -68,7 +68,6 @@ import androidx.test.uiautomator.Until; import com.android.launcher3.testing.shared.ResourceUtils; import com.android.launcher3.testing.shared.TestInformationRequest; import com.android.launcher3.testing.shared.TestProtocol; -import com.android.systemui.shared.system.ContextUtils; import com.android.systemui.shared.system.QuickStepContract; import org.junit.Assert; @@ -264,7 +263,7 @@ public final class LauncherInstrumentation { SystemClock.sleep(5000); } else { try { - final int userId = ContextUtils.getUserId(getContext()); + final int userId = getContext().getUserId(); final String launcherPidCommand = "pidof " + pi.packageName; final String initialPid = mDevice.executeShellCommand(launcherPidCommand) .replaceAll("\\s", "");