diff options
23 files changed, 281 insertions, 96 deletions
diff --git a/go/quickstep/src/com/android/launcher3/uioverrides/RecentsUiFactory.java b/go/quickstep/src/com/android/launcher3/uioverrides/RecentsUiFactory.java index d9b968603..b5fefb46d 100644 --- a/go/quickstep/src/com/android/launcher3/uioverrides/RecentsUiFactory.java +++ b/go/quickstep/src/com/android/launcher3/uioverrides/RecentsUiFactory.java @@ -21,10 +21,12 @@ import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; import android.view.View; +import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherStateManager.StateHandler; import com.android.launcher3.Utilities; import com.android.launcher3.config.FeatureFlags; +import com.android.launcher3.graphics.RotationMode; import com.android.launcher3.uioverrides.touchcontrollers.LandscapeEdgeSwipeController; import com.android.launcher3.uioverrides.touchcontrollers.LandscapeStatesTouchController; import com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController; @@ -102,4 +104,8 @@ public abstract class RecentsUiFactory { * @param launcher the launcher activity */ public static void onLauncherStateOrResumeChanged(Launcher launcher) {} + + public static RotationMode getRotationMode(DeviceProfile dp) { + return RotationMode.NORMAL; + } } diff --git a/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java b/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java index fe10a7a21..fe159b5f0 100644 --- a/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java +++ b/go/quickstep/src/com/android/quickstep/AppToOverviewAnimationProvider.java @@ -15,6 +15,7 @@ */ package com.android.quickstep; +import static com.android.launcher3.Utilities.postAsyncCallback; import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN; import static com.android.quickstep.views.IconRecentsView.REMOTE_APP_TO_OVERVIEW_DURATION; import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME; @@ -23,12 +24,17 @@ import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.MOD import android.animation.AnimatorSet; import android.animation.ValueAnimator; +import android.app.ActivityOptions; +import android.os.Handler; import android.util.Log; import com.android.launcher3.BaseDraggingActivity; +import com.android.launcher3.LauncherAnimationRunner; import com.android.quickstep.util.RemoteAnimationProvider; import com.android.quickstep.util.RemoteAnimationTargetSet; import com.android.quickstep.views.IconRecentsView; +import com.android.systemui.shared.system.ActivityOptionsCompat; +import com.android.systemui.shared.system.RemoteAnimationAdapterCompat; import com.android.systemui.shared.system.RemoteAnimationTargetCompat; /** @@ -144,6 +150,29 @@ final class AppToOverviewAnimationProvider<T extends BaseDraggingActivity> imple return anim; } + @Override + public ActivityOptions toActivityOptions(Handler handler, long duration) { + LauncherAnimationRunner runner = new LauncherAnimationRunner(handler, + false /* startAtFrontOfQueue */) { + + @Override + public void onCreateAnimation(RemoteAnimationTargetCompat[] targetCompats, + AnimationResult result) { + IconRecentsView recentsView = mRecentsView; + if (!recentsView.isReadyForRemoteAnim()) { + recentsView.setOnReadyForRemoteAnimCallback(() -> postAsyncCallback(handler, + () -> onCreateAnimation(targetCompats, result)) + ); + return; + } + result.setAnimation(createWindowAnimation(targetCompats)); + } + }; + return ActivityOptionsCompat.makeRemoteAnimation( + new RemoteAnimationAdapterCompat(runner, duration, + 0 /* statusBarTransitionDelay */)); + } + /** * Get duration of animation from app to overview. * diff --git a/go/quickstep/src/com/android/quickstep/TouchInteractionService.java b/go/quickstep/src/com/android/quickstep/TouchInteractionService.java index da4c5e11b..39f8448d1 100644 --- a/go/quickstep/src/com/android/quickstep/TouchInteractionService.java +++ b/go/quickstep/src/com/android/quickstep/TouchInteractionService.java @@ -92,11 +92,6 @@ public class TouchInteractionService extends Service { // To be implemented } - @Override - public void onScrimColorsChanged(int color, int type) { - - } - /** Deprecated methods **/ public void onQuickStep(MotionEvent motionEvent) { } diff --git a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java index 7f9f5975b..bcb634393 100644 --- a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java +++ b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java @@ -235,12 +235,8 @@ public final class IconRecentsView extends FrameLayout implements Insettable { case ITEM_TYPE_CLEAR_ALL: outRect.top = (int) res.getDimension( R.dimen.clear_all_item_view_top_margin); - int desiredBottomMargin = (int) res.getDimension( + outRect.bottom = (int) res.getDimension( R.dimen.clear_all_item_view_bottom_margin); - // Only add bottom margin if insets aren't enough. - if (mInsets.bottom < desiredBottomMargin) { - outRect.bottom = desiredBottomMargin - mInsets.bottom; - } break; case ITEM_TYPE_TASK: int desiredTopMargin = (int) res.getDimension( diff --git a/quickstep/recents_ui_overrides/res/values/dimens.xml b/quickstep/recents_ui_overrides/res/values/dimens.xml index 61c576e82..b316edd73 100644 --- a/quickstep/recents_ui_overrides/res/values/dimens.xml +++ b/quickstep/recents_ui_overrides/res/values/dimens.xml @@ -23,4 +23,8 @@ <!-- Minimum distance to swipe to trigger accessibility gesture --> <dimen name="accessibility_gesture_min_swipe_distance">80dp</dimen> + + <!-- Swipe up to home related --> + <dimen name="swipe_up_fling_min_visible_change">18dp</dimen> + <dimen name="swipe_up_y_overshoot">10dp</dimen> </resources>
\ No newline at end of file diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/appprediction/PredictionUiStateManager.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/appprediction/PredictionUiStateManager.java index 48a163d87..6dad9afe5 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/appprediction/PredictionUiStateManager.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/appprediction/PredictionUiStateManager.java @@ -67,8 +67,8 @@ public class PredictionUiStateManager implements OnGlobalLayoutListener, ItemInf // TODO (b/129421797): Update the client constants public enum Client { - HOME("GEL"), - OVERVIEW("OVERVIEW_GEL"); + HOME("home"), + OVERVIEW("overview"); public final String id; diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java index 518a2a685..3a2958d54 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsUiFactory.java @@ -20,6 +20,11 @@ import static android.view.View.VISIBLE; import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.LauncherState.OVERVIEW; +import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON; + +import android.content.Context; +import android.graphics.Rect; +import android.view.Gravity; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; @@ -28,6 +33,7 @@ import com.android.launcher3.LauncherStateManager.StateHandler; import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.config.FeatureFlags; +import com.android.launcher3.graphics.RotationMode; import com.android.launcher3.uioverrides.touchcontrollers.FlingAndHoldTouchController; import com.android.launcher3.uioverrides.touchcontrollers.LandscapeEdgeSwipeController; import com.android.launcher3.uioverrides.touchcontrollers.NavBarToHomeTouchController; @@ -58,12 +64,83 @@ public abstract class RecentsUiFactory { // Scale recents takes before animating in private static final float RECENTS_PREPARE_SCALE = 1.33f; + public static RotationMode ROTATION_LANDSCAPE = new RotationMode(-90) { + @Override + public void mapRect(int left, int top, int right, int bottom, Rect out) { + out.left = top; + out.top = right; + out.right = bottom; + out.bottom = left; + } + + @Override + public void mapInsets(Context context, Rect insets, Rect out) { + if (SysUINavigationMode.getMode(context) == NO_BUTTON) { + out.set(insets); + } else { + out.top = Math.max(insets.top, insets.left); + out.bottom = insets.right; + out.left = insets.bottom; + out.right = 0; + } + } + }; + + public static RotationMode ROTATION_SEASCAPE = new RotationMode(90) { + @Override + public void mapRect(int left, int top, int right, int bottom, Rect out) { + out.left = bottom; + out.top = left; + out.right = top; + out.bottom = right; + } + + @Override + public void mapInsets(Context context, Rect insets, Rect out) { + if (SysUINavigationMode.getMode(context) == NO_BUTTON) { + out.set(insets); + } else { + out.top = Math.max(insets.top, insets.right); + out.bottom = insets.left; + out.right = insets.bottom; + out.left = 0; + } + } + + @Override + public int toNaturalGravity(int absoluteGravity) { + int horizontalGravity = absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK; + int verticalGravity = absoluteGravity & Gravity.VERTICAL_GRAVITY_MASK; + + if (horizontalGravity == Gravity.RIGHT) { + horizontalGravity = Gravity.LEFT; + } else if (horizontalGravity == Gravity.LEFT) { + horizontalGravity = Gravity.RIGHT; + } + + if (verticalGravity == Gravity.TOP) { + verticalGravity = Gravity.BOTTOM; + } else if (verticalGravity == Gravity.BOTTOM) { + verticalGravity = Gravity.TOP; + } + + return ((absoluteGravity & ~Gravity.HORIZONTAL_GRAVITY_MASK) + & ~Gravity.VERTICAL_GRAVITY_MASK) + | horizontalGravity | verticalGravity; + } + }; + + public static RotationMode getRotationMode(DeviceProfile dp) { + return !dp.isVerticalBarLayout() ? RotationMode.NORMAL + : (dp.isSeascape() ? ROTATION_SEASCAPE : ROTATION_LANDSCAPE); + } + public static TouchController[] createTouchControllers(Launcher launcher) { Mode mode = SysUINavigationMode.getMode(launcher); ArrayList<TouchController> list = new ArrayList<>(); list.add(launcher.getDragController()); - if (mode == Mode.NO_BUTTON) { + if (mode == NO_BUTTON) { list.add(new QuickSwitchTouchController(launcher)); list.add(new NavBarToHomeTouchController(launcher)); list.add(new FlingAndHoldTouchController(launcher)); @@ -106,7 +183,7 @@ public abstract class RecentsUiFactory { * @param launcher the launcher activity */ public static void prepareToShowOverview(Launcher launcher) { - if (SysUINavigationMode.getMode(launcher) == Mode.NO_BUTTON) { + if (SysUINavigationMode.getMode(launcher) == NO_BUTTON) { // Overview lives on the side, so doesn't scale in from above. return; } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java index f38ad0d83..128fd45fe 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java @@ -176,11 +176,6 @@ public class TouchInteractionService extends Service implements mSystemUiStateFlags = stateFlags; } - @Override - public void onScrimColorsChanged(int color, int type) { - - } - /** Deprecated methods **/ public void onQuickStep(MotionEvent motionEvent) { } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java index d927d8306..404cfe62f 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -1077,8 +1077,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> final View floatingView = homeAnimationFactory.getFloatingView(); final boolean isFloatingIconView = floatingView instanceof FloatingIconView; - - RectFSpringAnim anim = new RectFSpringAnim(startRect, targetRect); + RectFSpringAnim anim = new RectFSpringAnim(startRect, targetRect, mActivity.getResources()); if (isFloatingIconView) { FloatingIconView fiv = (FloatingIconView) floatingView; anim.addAnimatorListener(fiv); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java index e862fa6c8..35b96ccc1 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java @@ -22,6 +22,8 @@ import static android.view.MotionEvent.ACTION_POINTER_UP; import static android.view.MotionEvent.ACTION_UP; import static android.view.MotionEvent.INVALID_POINTER_ID; import static com.android.launcher3.Utilities.EDGE_NAV_BAR; +import static com.android.launcher3.uioverrides.RecentsUiFactory.ROTATION_LANDSCAPE; +import static com.android.launcher3.uioverrides.RecentsUiFactory.ROTATION_SEASCAPE; import static com.android.launcher3.util.RaceConditionTracker.ENTER; import static com.android.launcher3.util.RaceConditionTracker.EXIT; import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON; @@ -171,8 +173,8 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC && !mRecentsViewDispatcher.hasConsumer()) { mRecentsViewDispatcher.setConsumer(mInteractionHandler.getRecentsViewDispatcher( isNavBarOnLeft() - ? RotationMode.SEASCAPE - : (isNavBarOnRight() ? RotationMode.LANDSCAPE : RotationMode.NORMAL))); + ? ROTATION_SEASCAPE + : (isNavBarOnRight() ? ROTATION_LANDSCAPE : RotationMode.NORMAL))); } int edgeFlags = ev.getEdgeFlags(); ev.setEdgeFlags(edgeFlags | EDGE_NAV_BAR); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/RectFSpringAnim.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/RectFSpringAnim.java index 09db6952f..3f4ad58ab 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/RectFSpringAnim.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/RectFSpringAnim.java @@ -19,6 +19,7 @@ import android.animation.Animator; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.animation.ValueAnimator; +import android.content.res.Resources; import android.graphics.PointF; import android.graphics.RectF; import android.util.FloatProperty; @@ -26,6 +27,7 @@ import android.util.FloatProperty; import androidx.dynamicanimation.animation.DynamicAnimation.OnAnimationEndListener; import androidx.dynamicanimation.animation.FloatPropertyCompat; +import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimationSuccessListener; import com.android.launcher3.anim.FlingSpringAnim; @@ -63,16 +65,16 @@ public class RectFSpringAnim { } }; - private static final FloatPropertyCompat<RectFSpringAnim> RECT_CENTER_Y = - new FloatPropertyCompat<RectFSpringAnim>("rectCenterYSpring") { + private static final FloatPropertyCompat<RectFSpringAnim> RECT_Y = + new FloatPropertyCompat<RectFSpringAnim>("rectYSpring") { @Override public float getValue(RectFSpringAnim anim) { - return anim.mCurrentCenterY; + return anim.mCurrentY; } @Override - public void setValue(RectFSpringAnim anim, float currentCenterY) { - anim.mCurrentCenterY = currentCenterY; + public void setValue(RectFSpringAnim anim, float y) { + anim.mCurrentY = y; anim.onUpdate(); } }; @@ -98,7 +100,9 @@ public class RectFSpringAnim { private final List<Animator.AnimatorListener> mAnimatorListeners = new ArrayList<>(); private float mCurrentCenterX; - private float mCurrentCenterY; + private float mCurrentY; + // If true, tracking the bottom of the rects, else tracking the top. + private boolean mTrackingBottomY; private float mCurrentScaleProgress; private FlingSpringAnim mRectXAnim; private FlingSpringAnim mRectYAnim; @@ -108,19 +112,32 @@ public class RectFSpringAnim { private boolean mRectYAnimEnded; private boolean mRectScaleAnimEnded; - public RectFSpringAnim(RectF startRect, RectF targetRect) { + private float mMinVisChange; + private float mYOvershoot; + + public RectFSpringAnim(RectF startRect, RectF targetRect, Resources resources) { mStartRect = startRect; mTargetRect = targetRect; mCurrentCenterX = mStartRect.centerX(); - mCurrentCenterY = mStartRect.centerY(); + + mTrackingBottomY = startRect.bottom < targetRect.bottom; + mCurrentY = mTrackingBottomY ? mStartRect.bottom : mStartRect.top; + + mMinVisChange = resources.getDimensionPixelSize(R.dimen.swipe_up_fling_min_visible_change); + mYOvershoot = resources.getDimensionPixelSize(R.dimen.swipe_up_y_overshoot); } public void onTargetPositionChanged() { if (mRectXAnim != null && mRectXAnim.getTargetPosition() != mTargetRect.centerX()) { mRectXAnim.updatePosition(mCurrentCenterX, mTargetRect.centerX()); } - if (mRectYAnim != null && mRectYAnim.getTargetPosition() != mTargetRect.centerY()) { - mRectYAnim.updatePosition(mCurrentCenterY, mTargetRect.centerY()); + + if (mRectYAnim != null) { + if (mTrackingBottomY && mRectYAnim.getTargetPosition() != mTargetRect.bottom) { + mRectYAnim.updatePosition(mCurrentY, mTargetRect.bottom); + } else if (!mTrackingBottomY && mRectYAnim.getTargetPosition() != mTargetRect.top) { + mRectYAnim.updatePosition(mCurrentY, mTargetRect.top); + } } } @@ -142,10 +159,23 @@ public class RectFSpringAnim { mRectYAnimEnded = true; maybeOnEnd(); }); - mRectXAnim = new FlingSpringAnim(this, RECT_CENTER_X, mCurrentCenterX, - mTargetRect.centerX(), velocityPxPerMs.x * 1000, onXEndListener); - mRectYAnim = new FlingSpringAnim(this, RECT_CENTER_Y, mCurrentCenterY, - mTargetRect.centerY(), velocityPxPerMs.y * 1000, onYEndListener); + + float startX = mCurrentCenterX; + float endX = mTargetRect.centerX(); + float minXValue = Math.min(startX, endX); + float maxXValue = Math.max(startX, endX); + mRectXAnim = new FlingSpringAnim(this, RECT_CENTER_X, startX, endX, + velocityPxPerMs.x * 1000, mMinVisChange, minXValue, maxXValue, 1f, onXEndListener); + + float startVelocityY = velocityPxPerMs.y * 1000; + // Scale the Y velocity based on the initial velocity to tune the curves. + float springVelocityFactor = 0.1f + 0.9f * Math.abs(startVelocityY) / 20000.0f; + float startY = mCurrentY; + float endY = mTrackingBottomY ? mTargetRect.bottom : mTargetRect.top; + float minYValue = Math.min(startY, endY - mYOvershoot); + float maxYValue = Math.max(startY, endY); + mRectYAnim = new FlingSpringAnim(this, RECT_Y, startY, endY, startVelocityY, + mMinVisChange, minYValue, maxYValue, springVelocityFactor, onYEndListener); mRectScaleAnim = ObjectAnimator.ofPropertyValuesHolder(this, PropertyValuesHolder.ofFloat(RECT_SCALE_PROGRESS, 1)) @@ -182,8 +212,13 @@ public class RectFSpringAnim { mTargetRect.width()); float currentHeight = Utilities.mapRange(mCurrentScaleProgress, mStartRect.height(), mTargetRect.height()); - mCurrentRect.set(mCurrentCenterX - currentWidth / 2, mCurrentCenterY - currentHeight / 2, - mCurrentCenterX + currentWidth / 2, mCurrentCenterY + currentHeight / 2); + if (mTrackingBottomY) { + mCurrentRect.set(mCurrentCenterX - currentWidth / 2, mCurrentY - currentHeight, + mCurrentCenterX + currentWidth / 2, mCurrentY); + } else { + mCurrentRect.set(mCurrentCenterX - currentWidth / 2, mCurrentY, + mCurrentCenterX + currentWidth / 2, mCurrentY + currentHeight); + } for (OnUpdateListener onUpdateListener : mOnUpdateListeners) { onUpdateListener.onUpdate(mCurrentRect, mCurrentScaleProgress); } diff --git a/src/com/android/launcher3/AbstractFloatingView.java b/src/com/android/launcher3/AbstractFloatingView.java index d6f992f51..65f9d6bc0 100644 --- a/src/com/android/launcher3/AbstractFloatingView.java +++ b/src/com/android/launcher3/AbstractFloatingView.java @@ -90,7 +90,7 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch // Usually we show the back button when a floating view is open. Instead, hide for these types. public static final int TYPE_HIDE_BACK_BUTTON = TYPE_ON_BOARD_POPUP | TYPE_DISCOVERY_BOUNCE - | TYPE_SNACKBAR; + | TYPE_SNACKBAR | TYPE_WIDGET_RESIZE_FRAME | TYPE_LISTENER; public static final int TYPE_ACCESSIBLE = TYPE_ALL & ~TYPE_DISCOVERY_BOUNCE & ~TYPE_LISTENER; diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 417c5a29a..823fb6b0a 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -431,8 +431,8 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, @Override protected void reapplyUi() { if (FeatureFlags.FAKE_LANDSCAPE_UI.get()) { - mRotationMode = mStableDeviceProfile == null ? RotationMode.NORMAL : - (mDeviceProfile.isSeascape() ? RotationMode.SEASCAPE : RotationMode.LANDSCAPE); + mRotationMode = mStableDeviceProfile == null + ? RotationMode.NORMAL : UiFactory.getRotationMode(mDeviceProfile); } getRootView().dispatchInsets(); getStateManager().reapplyState(true /* cancelCurrentAnimation */); @@ -489,8 +489,7 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, if (FeatureFlags.FAKE_LANDSCAPE_UI.get() && mDeviceProfile.isVerticalBarLayout() && !mDeviceProfile.isMultiWindowMode) { mStableDeviceProfile = mDeviceProfile.inv.portraitProfile; - mRotationMode = mDeviceProfile.isSeascape() - ? RotationMode.SEASCAPE : RotationMode.LANDSCAPE; + mRotationMode = UiFactory.getRotationMode(mDeviceProfile); } else { mStableDeviceProfile = null; mRotationMode = RotationMode.NORMAL; @@ -503,7 +502,9 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, public void updateInsets(Rect insets) { mDeviceProfile.updateInsets(insets); if (mStableDeviceProfile != null) { - mStableDeviceProfile.updateInsets(insets); + Rect r = mStableDeviceProfile.getInsets(); + mRotationMode.mapInsets(this, insets, r); + mStableDeviceProfile.updateInsets(r); } } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 0f4c42d51..a508ce52b 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -302,7 +302,7 @@ public class Workspace extends PagedView<WorkspacePageIndicator> rotationMode.mapRect(padding, mTempRect); setPadding(mTempRect.left, mTempRect.top, mTempRect.right, mTempRect.bottom); - rotationMode.mapRect(insets, mInsets); + rotationMode.mapRect(stableGrid.getInsets(), mInsets); if (mWorkspaceFadeInAdjacentScreens) { // In landscape mode the page spacing is set to the default. diff --git a/src/com/android/launcher3/anim/FlingSpringAnim.java b/src/com/android/launcher3/anim/FlingSpringAnim.java index 3d981c136..f53ea5150 100644 --- a/src/com/android/launcher3/anim/FlingSpringAnim.java +++ b/src/com/android/launcher3/anim/FlingSpringAnim.java @@ -28,8 +28,6 @@ import androidx.dynamicanimation.animation.SpringForce; public class FlingSpringAnim { private static final float FLING_FRICTION = 1.5f; - // Have the spring pull towards the target if we've slowed down too much before reaching it. - private static final float FLING_END_THRESHOLD_PX = 50f; private static final float SPRING_STIFFNESS = 200; private static final float SPRING_DAMPING = 0.85f; @@ -39,23 +37,27 @@ public class FlingSpringAnim { private float mTargetPosition; public <K> FlingSpringAnim(K object, FloatPropertyCompat<K> property, float startPosition, - float targetPosition, float startVelocity, OnAnimationEndListener onEndListener) { + float targetPosition, float startVelocity, float minVisChange, float minValue, + float maxValue, float springVelocityFactor, OnAnimationEndListener onEndListener) { mFlingAnim = new FlingAnimation(object, property) .setFriction(FLING_FRICTION) - .setMinimumVisibleChange(FLING_END_THRESHOLD_PX) + // Have the spring pull towards the target if we've slowed down too much before + // reaching it. + .setMinimumVisibleChange(minVisChange) .setStartVelocity(startVelocity) - .setMinValue(Math.min(startPosition, targetPosition)) - .setMaxValue(Math.max(startPosition, targetPosition)); + .setMinValue(minValue) + .setMaxValue(maxValue); mTargetPosition = targetPosition; mFlingAnim.addEndListener(((animation, canceled, value, velocity) -> { mSpringAnim = new SpringAnimation(object, property) - .setStartVelocity(velocity) + .setStartValue(value) + .setStartVelocity(velocity * springVelocityFactor) .setSpring(new SpringForce(mTargetPosition) .setStiffness(SPRING_STIFFNESS) .setDampingRatio(SPRING_DAMPING)); mSpringAnim.addEndListener(onEndListener); - mSpringAnim.start(); + mSpringAnim.animateToFinalPosition(mTargetPosition); })); } diff --git a/src/com/android/launcher3/compat/LauncherAppsCompat.java b/src/com/android/launcher3/compat/LauncherAppsCompat.java index 4275f312b..58fc73d23 100644 --- a/src/com/android/launcher3/compat/LauncherAppsCompat.java +++ b/src/com/android/launcher3/compat/LauncherAppsCompat.java @@ -21,6 +21,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.LauncherActivityInfo; +import android.content.pm.PackageInstaller; import android.content.pm.ShortcutInfo; import android.graphics.Rect; import android.os.Bundle; @@ -56,7 +57,9 @@ public abstract class LauncherAppsCompat { public static LauncherAppsCompat getInstance(Context context) { synchronized (sInstanceLock) { if (sInstance == null) { - if (Utilities.ATLEAST_OREO) { + if (Utilities.ATLEAST_Q) { + sInstance = new LauncherAppsCompatVQ(context.getApplicationContext()); + } else if (Utilities.ATLEAST_OREO) { sInstance = new LauncherAppsCompatVO(context.getApplicationContext()); } else { sInstance = new LauncherAppsCompatVL(context.getApplicationContext()); @@ -83,4 +86,6 @@ public abstract class LauncherAppsCompat { UserHandle user); public abstract List<ShortcutConfigActivityInfo> getCustomShortcutActivityList( @Nullable PackageUserKey packageUser); + + public abstract List<PackageInstaller.SessionInfo> getAllPackageInstallerSessions(); } diff --git a/src/com/android/launcher3/compat/LauncherAppsCompatVL.java b/src/com/android/launcher3/compat/LauncherAppsCompatVL.java index fc48ba756..1d19b533a 100644 --- a/src/com/android/launcher3/compat/LauncherAppsCompatVL.java +++ b/src/com/android/launcher3/compat/LauncherAppsCompatVL.java @@ -22,6 +22,7 @@ import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.LauncherActivityInfo; import android.content.pm.LauncherApps; +import android.content.pm.PackageInstaller; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ShortcutInfo; @@ -199,5 +200,10 @@ public class LauncherAppsCompatVL extends LauncherAppsCompat { } return result; } + + @Override + public List<PackageInstaller.SessionInfo> getAllPackageInstallerSessions() { + return mContext.getPackageManager().getPackageInstaller().getAllSessions(); + } } diff --git a/src/com/android/launcher3/compat/LauncherAppsCompatVQ.java b/src/com/android/launcher3/compat/LauncherAppsCompatVQ.java new file mode 100644 index 000000000..0a1811e34 --- /dev/null +++ b/src/com/android/launcher3/compat/LauncherAppsCompatVQ.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2019 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.launcher3.compat; + +import android.annotation.TargetApi; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageInstaller; + +import java.util.List; + +@TargetApi(29) +public class LauncherAppsCompatVQ extends LauncherAppsCompatVO { + + LauncherAppsCompatVQ(Context context) { + super(context); + } + + public List<PackageInstaller.SessionInfo> getAllPackageInstallerSessions() { + return mLauncherApps.getAllPackageInstallerSessions(); + } +} diff --git a/src/com/android/launcher3/compat/PackageInstallerCompatVL.java b/src/com/android/launcher3/compat/PackageInstallerCompatVL.java index fe7b4e5d0..a34ca50eb 100644 --- a/src/com/android/launcher3/compat/PackageInstallerCompatVL.java +++ b/src/com/android/launcher3/compat/PackageInstallerCompatVL.java @@ -27,6 +27,7 @@ import android.os.UserHandle; import android.text.TextUtils; import android.util.SparseArray; +import com.android.launcher3.Utilities; import com.android.launcher3.icons.IconCache; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherModel; @@ -49,6 +50,7 @@ public class PackageInstallerCompatVL extends PackageInstallerCompat { private final Handler mWorker; private final Context mAppContext; private final HashMap<String,Boolean> mSessionVerifiedMap = new HashMap<>(); + private final LauncherAppsCompat mLauncherApps; PackageInstallerCompatVL(Context context) { mAppContext = context.getApplicationContext(); @@ -56,6 +58,7 @@ public class PackageInstallerCompatVL extends PackageInstallerCompat { mCache = LauncherAppState.getInstance(context).getIconCache(); mWorker = new Handler(LauncherModel.getWorkerLooper()); mInstaller.registerSessionCallback(mCallback, mWorker); + mLauncherApps = LauncherAppsCompat.getInstance(context); } @Override @@ -171,7 +174,9 @@ public class PackageInstallerCompatVL extends PackageInstallerCompat { @Override public List<SessionInfo> getAllVerifiedSessions() { - List<SessionInfo> list = new ArrayList<>(mInstaller.getAllSessions()); + List<SessionInfo> list = new ArrayList<>(Utilities.ATLEAST_Q + ? mLauncherApps.getAllPackageInstallerSessions() + : mInstaller.getAllSessions()); Iterator<SessionInfo> it = list.iterator(); while (it.hasNext()) { if (verify(it.next()) == null) { diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java index 8de2f57ee..b35e23ce9 100644 --- a/src/com/android/launcher3/dragndrop/DragLayer.java +++ b/src/com/android/launcher3/dragndrop/DragLayer.java @@ -638,25 +638,11 @@ public class DragLayer extends BaseDragLayer<Launcher> { final int layoutDirection = getLayoutDirection(); int absoluteGravity = Gravity.getAbsoluteGravity(gravity, layoutDirection); - int horizontalGravity = absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK; - int verticalGravity = absoluteGravity & Gravity.VERTICAL_GRAVITY_MASK; if (child instanceof Transposable) { - if (rotation == RotationMode.SEASCAPE) { - if (horizontalGravity == Gravity.RIGHT) { - horizontalGravity = Gravity.LEFT; - } else if (horizontalGravity == Gravity.LEFT) { - horizontalGravity = Gravity.RIGHT; - } - - if (verticalGravity == Gravity.TOP) { - verticalGravity = Gravity.BOTTOM; - } else if (verticalGravity == Gravity.BOTTOM) { - verticalGravity = Gravity.TOP; - } - } + absoluteGravity = rotation.toNaturalGravity(absoluteGravity); - switch (horizontalGravity) { + switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: childTop = (parentHeight - height) / 2 + lp.topMargin - lp.bottomMargin; @@ -669,7 +655,7 @@ public class DragLayer extends BaseDragLayer<Launcher> { childTop = parentHeight - lp.leftMargin - width / 2 - height / 2; } - switch (verticalGravity) { + switch (absoluteGravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.CENTER_VERTICAL: childLeft = (parentWidth - width) / 2 + lp.leftMargin - lp.rightMargin; @@ -682,7 +668,7 @@ public class DragLayer extends BaseDragLayer<Launcher> { childLeft = height / 2 - width / 2 + lp.topMargin; } } else { - switch (horizontalGravity) { + switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) { case Gravity.CENTER_HORIZONTAL: childLeft = (parentWidth - width) / 2 + lp.leftMargin - lp.rightMargin; @@ -695,7 +681,7 @@ public class DragLayer extends BaseDragLayer<Launcher> { childLeft = lp.leftMargin; } - switch (verticalGravity) { + switch (absoluteGravity & Gravity.VERTICAL_GRAVITY_MASK) { case Gravity.TOP: childTop = lp.topMargin; break; diff --git a/src/com/android/launcher3/graphics/RotationMode.java b/src/com/android/launcher3/graphics/RotationMode.java index 1b2cbdb9f..b06305fc2 100644 --- a/src/com/android/launcher3/graphics/RotationMode.java +++ b/src/com/android/launcher3/graphics/RotationMode.java @@ -15,14 +15,17 @@ */ package com.android.launcher3.graphics; +import android.content.Context; import android.graphics.Rect; public abstract class RotationMode { + public static RotationMode NORMAL = new RotationMode(0) { }; + public final float surfaceRotation; public final boolean isTransposed; - private RotationMode(float surfaceRotation) { + public RotationMode(float surfaceRotation) { this.surfaceRotation = surfaceRotation; isTransposed = surfaceRotation != 0; } @@ -35,25 +38,11 @@ public abstract class RotationMode { out.set(left, top, right, bottom); } - public static RotationMode NORMAL = new RotationMode(0) { }; + public void mapInsets(Context context, Rect insets, Rect out) { + out.set(insets); + } - public static RotationMode LANDSCAPE = new RotationMode(-90) { - @Override - public void mapRect(int left, int top, int right, int bottom, Rect out) { - out.left = top; - out.top = right; - out.right = bottom; - out.bottom = left; - } - }; - - public static RotationMode SEASCAPE = new RotationMode(90) { - @Override - public void mapRect(int left, int top, int right, int bottom, Rect out) { - out.left = bottom; - out.top = left; - out.right = top; - out.bottom = right; - } - }; + public int toNaturalGravity(int absoluteGravity) { + return absoluteGravity; + } } diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java index 73f11b22d..cd0ae3d72 100644 --- a/src/com/android/launcher3/views/FloatingIconView.java +++ b/src/com/android/launcher3/views/FloatingIconView.java @@ -568,6 +568,17 @@ public class FloatingIconView extends View implements } }); + if (originalView instanceof BubbleTextView) { + BubbleTextView btv = (BubbleTextView) originalView; + btv.forceHideDot(true); + fade.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + btv.forceHideDot(false); + } + }); + } + if (originalView instanceof FolderIcon) { FolderIcon folderIcon = (FolderIcon) originalView; folderIcon.setBackgroundVisible(false); diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java index c01b54a6d..6008d1450 100644 --- a/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java +++ b/src_ui_overrides/com/android/launcher3/uioverrides/UiFactory.java @@ -20,10 +20,12 @@ import android.app.Activity; import android.content.Context; import android.os.CancellationSignal; +import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState.ScaleAndTranslation; import com.android.launcher3.LauncherStateManager.StateHandler; import com.android.launcher3.dragndrop.DragLayer; +import com.android.launcher3.graphics.RotationMode; import com.android.launcher3.util.TouchController; import java.io.PrintWriter; @@ -73,4 +75,8 @@ public class UiFactory { public static ScaleAndTranslation getOverviewScaleAndTranslationForNormalState(Launcher l) { return new ScaleAndTranslation(1.1f, 0f, 0f); } + + public static RotationMode getRotationMode(DeviceProfile dp) { + return RotationMode.NORMAL; + } } |