From b66675a36d5daec4aea4470cb5c804c54edb06cd Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Fri, 15 May 2020 16:16:17 -0700 Subject: [PATCH 01/37] Delegate horizontal scrolls from the Hotseat to the Workspace => Before this change, scrolling horizontally on the the hotseat area was a no-op => This is a mild usability issue (or arguably WAI) for the default grid, but for larger grids it feels really broken as you have to reach very high just to scroll to another page. issue 156507399 Test: manual. Also verified that swipe up still works and goes through the same code path. Change-Id: I760aca473dd36bc8cfb906cb58e897e2ab7fd1d9 --- src/com/android/launcher3/Hotseat.java | 29 +++++++++++++++++++++++++ src/com/android/launcher3/Launcher.java | 1 + 2 files changed, 30 insertions(+) diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java index be941f2e56..1c157c26d2 100644 --- a/src/com/android/launcher3/Hotseat.java +++ b/src/com/android/launcher3/Hotseat.java @@ -38,6 +38,8 @@ public class Hotseat extends CellLayout implements LogContainerProvider, Insetta @ViewDebug.ExportedProperty(category = "launcher") private boolean mHasVerticalHotseat; + private Workspace mWorkspace; + private boolean mSendTouchToWorkspace; public Hotseat(Context context) { this(context, null); @@ -112,8 +114,35 @@ public class Hotseat extends CellLayout implements LogContainerProvider, Insetta InsettableFrameLayout.dispatchInsets(this, insets); } + public void setWorkspace(Workspace w) { + mWorkspace = w; + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + // We allow horizontal workspace scrolling from within the Hotseat. We do this by delegating + // touch intercept the Workspace, and if it intercepts, delegating touch to the Workspace + // for the remainder of the this input stream. + int yThreshold = getMeasuredHeight() - getPaddingBottom(); + if (mWorkspace != null && ev.getY() <= yThreshold) { + mSendTouchToWorkspace = mWorkspace.onInterceptTouchEvent(ev); + return mSendTouchToWorkspace; + } + return false; + } + @Override public boolean onTouchEvent(MotionEvent event) { + // See comment in #onInterceptTouchEvent + if (mSendTouchToWorkspace) { + final int action = event.getAction(); + switch (action & MotionEvent.ACTION_MASK) { + case MotionEvent.ACTION_UP: + case MotionEvent.ACTION_CANCEL: + mSendTouchToWorkspace = false; + } + return mWorkspace.onTouchEvent(event); + } return event.getY() > getCellHeight(); } } diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 59476dd5a1..1f84c42f22 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1116,6 +1116,7 @@ public class Launcher extends StatefulActivity implements Launche mWorkspace.initParentViews(mDragLayer); mOverviewPanel = findViewById(R.id.overview_panel); mHotseat = findViewById(R.id.hotseat); + mHotseat.setWorkspace(mWorkspace); mLauncherView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION From 5efa076daea25d32436d987124281c75abbfe9e4 Mon Sep 17 00:00:00 2001 From: Jon Spivack Date: Mon, 11 May 2020 15:03:45 -0700 Subject: [PATCH 02/37] Re-enable app long-press menu on Go devices Deep shortcuts and the home-screen Widgets menu were removed from Go in b/112904271. Subsequently removing the entire app long-press menu, however, may have been unintended behavior. This re-enables that menu, which currently houses the App Info system shortcut. Bug: 156120551 Test: Manual Change-Id: Ifa0befe1896315b5ed905271c2cf4805f70c39c0 --- src/com/android/launcher3/util/ShortcutUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/com/android/launcher3/util/ShortcutUtil.java b/src/com/android/launcher3/util/ShortcutUtil.java index 1ec0690401..91cf835287 100644 --- a/src/com/android/launcher3/util/ShortcutUtil.java +++ b/src/com/android/launcher3/util/ShortcutUtil.java @@ -34,7 +34,7 @@ public class ShortcutUtil { * Returns true when we should show depp shortcuts in shortcut menu for the item. */ public static boolean supportsDeepShortcuts(ItemInfo info) { - return isActive(info) && isApp(info); + return isActive(info) && isApp(info) && !WidgetsModel.GO_DISABLE_WIDGETS; } /** @@ -64,7 +64,7 @@ public class ShortcutUtil { private static boolean isActive(ItemInfo info) { boolean isLoading = info instanceof WorkspaceItemInfo && ((WorkspaceItemInfo) info).hasPromiseIconUi(); - return !isLoading && !info.isDisabled() && !WidgetsModel.GO_DISABLE_WIDGETS; + return !isLoading && !info.isDisabled(); } private static boolean isApp(ItemInfo info) { From ce7eec0bbdfad1444665cd04b8393d2926b542c5 Mon Sep 17 00:00:00 2001 From: Ming-Shin Lu Date: Mon, 18 May 2020 10:36:35 +0800 Subject: [PATCH 03/37] Fix weird split-screen secondary task animation As CL[1] corrects the screenBounds of remote animation target, and we are now using RemoteAnimationTarget#localBounds to offect the position. Remove the offset logics in AppWindowAnimationHelper#updateSourceStack, and TaskViewSimulator#setPreview, then refine computeSurfaceParams with offseting the position of HOME task by localBounds. [1]: I793f01fb290fe65af1bbf8e29e429fbca63ac255 Fix: 153581126 Test: manual as below steps: 1) Launch a app, swipe up to overview screen. 2) Tap app icon and pressing "Split screen" item. 3) After entered split-screen mode, taps the task view. 4) Make sure the secondary task animation the movement is correct and smoothly. Change-Id: I0e4ed1465e80f48336908813ac694fb3aaa3c347 --- .../quickstep/util/AppWindowAnimationHelper.java | 13 +++++-------- .../android/quickstep/util/TaskViewSimulator.java | 2 -- .../android/quickstep/views/TaskThumbnailView.java | 1 - 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/AppWindowAnimationHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/AppWindowAnimationHelper.java index d22755e727..b743d3fa0b 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/AppWindowAnimationHelper.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/AppWindowAnimationHelper.java @@ -99,9 +99,6 @@ public class AppWindowAnimationHelper implements TransformParams.BuilderProxy { private void updateSourceStack(RemoteAnimationTargetCompat target) { mSourceInsets.set(target.contentInsets); mSourceStackBounds.set(target.screenSpaceBounds); - - // TODO: Should sourceContainerBounds already have this offset? - mSourceStackBounds.offsetTo(target.position.x, target.position.y); } public void updateTargetRect(Rect targetRect) { @@ -169,14 +166,14 @@ public class AppWindowAnimationHelper implements TransformParams.BuilderProxy { crop.offsetTo(0, 0); float cornerRadius = 0f; float scale = Math.max(mCurrentRect.width(), mTargetRect.width()) / crop.width(); + mTmpMatrix.setTranslate(0, 0); + if (app.activityType == RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME) { + mTmpMatrix.setTranslate(app.localBounds.left, app.localBounds.top); + } if (app.mode == targetMode && app.activityType != RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME) { mTmpMatrix.setRectToRect(mSourceRect, mCurrentRect, ScaleToFit.FILL); - if (app.localBounds != null) { - mTmpMatrix.postTranslate(app.localBounds.left, app.localBounds.top); - } else { - mTmpMatrix.postTranslate(app.position.x, app.position.y); - } + mTmpMatrix.postTranslate(app.localBounds.left, app.localBounds.top); mCurrentClipRectF.roundOut(crop); if (mSupportsRoundedCornersOnWindows) { if (params.getCornerRadius() > -1) { diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/TaskViewSimulator.java index f4f7e9c957..d7a7e4c25e 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/TaskViewSimulator.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/TaskViewSimulator.java @@ -131,8 +131,6 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { mThumbnailData.windowingMode = WINDOWING_MODE_FULLSCREEN; mThumbnailPosition.set(runningTarget.screenSpaceBounds); - // TODO: Should sourceContainerBounds already have this offset? - mThumbnailPosition.offset(-mRunningTarget.position.x, -mRunningTarget.position.y); mLayoutValid = false; } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskThumbnailView.java index a3e360fa22..e3c1b42b71 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskThumbnailView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskThumbnailView.java @@ -472,7 +472,6 @@ public class TaskThumbnailView extends View implements PluginListener Date: Fri, 15 May 2020 14:42:28 -0700 Subject: [PATCH 04/37] Increase overview thumbnail size for 2 button landscape. With shelf hidden in 2 button landscape, need to fill in the extra space w/ larger thumbnail. Fixes: 156442623 Test: Larger thumbnail shows up in 2 button landscape Change-Id: Ie2856c8d248b28ae7c06cbe40c7417a827c2bd96 --- .../states/BackgroundAppState.java | 8 ++++++-- .../uioverrides/states/OverviewState.java | 7 ++----- .../NoButtonQuickSwitchTouchController.java | 2 +- .../android/quickstep/BaseSwipeUpHandler.java | 5 +++-- .../quickstep/FallbackActivityInterface.java | 12 +++++++---- .../quickstep/LauncherActivityInterface.java | 19 ++++++++++-------- .../QuickstepTestInformationHandler.java | 4 +++- .../quickstep/util/TaskViewSimulator.java | 3 ++- .../android/quickstep/views/RecentsView.java | 8 +++++++- .../PortraitStatesTouchController.java | 4 +++- .../quickstep/BaseActivityInterface.java | 20 +++++++++++++------ .../quickstep/SysUINavigationMode.java | 7 +++++++ .../android/quickstep/util/LayoutUtils.java | 7 +++++-- 13 files changed, 72 insertions(+), 34 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java index fa0d3f347b..8ff05f2aaa 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java @@ -45,8 +45,10 @@ public class BackgroundAppState extends OverviewState { if (launcher.getDeviceProfile().isVerticalBarLayout()) { return super.getVerticalProgress(launcher); } + RecentsView recentsView = launcher.getOverviewPanel(); int transitionLength = LayoutUtils.getShelfTrackingDistance(launcher, - launcher.getDeviceProfile()); + launcher.getDeviceProfile(), + recentsView.getPagedOrientationHandler()); AllAppsTransitionController controller = launcher.getAllAppsController(); float scrollRange = Math.max(controller.getShiftRange(), 1); float progressDelta = (transitionLength / scrollRange); @@ -73,9 +75,11 @@ public class BackgroundAppState extends OverviewState { public ScaleAndTranslation getHotseatScaleAndTranslation(Launcher launcher) { if ((getVisibleElements(launcher) & HOTSEAT_ICONS) != 0) { // Translate hotseat offscreen if we show it in overview. + RecentsView recentsView = launcher.getOverviewPanel(); ScaleAndTranslation scaleAndTranslation = super.getHotseatScaleAndTranslation(launcher); scaleAndTranslation.translationY += LayoutUtils.getShelfTrackingDistance(launcher, - launcher.getDeviceProfile()); + launcher.getDeviceProfile(), + recentsView.getPagedOrientationHandler()); return scaleAndTranslation; } return super.getHotseatScaleAndTranslation(launcher); diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java index 9b4e8906a1..d174bfd2d9 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/OverviewState.java @@ -19,8 +19,7 @@ import static com.android.launcher3.anim.Interpolators.DEACCEL_2; import static com.android.launcher3.config.FeatureFlags.ENABLE_OVERVIEW_ACTIONS; import static com.android.launcher3.logging.LoggerUtils.newContainerTarget; import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON; -import static com.android.quickstep.SysUINavigationMode.Mode.TWO_BUTTONS; -import static com.android.quickstep.SysUINavigationMode.getMode; +import static com.android.quickstep.SysUINavigationMode.hideShelfInTwoButtonLandscape; import static com.android.quickstep.SysUINavigationMode.removeShelfFromOverview; import android.content.Context; @@ -130,10 +129,8 @@ public class OverviewState extends LauncherState { @Override public int getVisibleElements(Launcher launcher) { RecentsView recentsView = launcher.getOverviewPanel(); - boolean hideShelfTwoButtonLandscape = getMode(launcher) == TWO_BUTTONS && - !recentsView.getPagedOrientationHandler().isLayoutNaturalToLauncher(); if (ENABLE_OVERVIEW_ACTIONS.get() && removeShelfFromOverview(launcher) || - hideShelfTwoButtonLandscape) { + hideShelfInTwoButtonLandscape(launcher, recentsView.getPagedOrientationHandler())) { return OVERVIEW_BUTTONS; } else if (launcher.getDeviceProfile().isVerticalBarLayout()) { return VERTICAL_SWIPE_INDICATOR | OVERVIEW_BUTTONS; diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java index 7385658976..c1b68aba6b 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java @@ -116,7 +116,7 @@ public class NoButtonQuickSwitchTouchController implements TouchController, mRecentsView = mLauncher.getOverviewPanel(); mXRange = mLauncher.getDeviceProfile().widthPx / 2f; mYRange = LayoutUtils.getShelfTrackingDistance( - mLauncher, mLauncher.getDeviceProfile()); + mLauncher, mLauncher.getDeviceProfile(), mRecentsView.getPagedOrientationHandler()); mMotionPauseDetector = new MotionPauseDetector(mLauncher); mMotionPauseMinDisplacement = mLauncher.getResources().getDimension( R.dimen.motion_pause_detector_min_displacement_from_app); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java index 614ba46503..66fefbe5ef 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java @@ -357,12 +357,13 @@ public abstract class BaseSwipeUpHandler, Q extend protected void initTransitionEndpoints(DeviceProfile dp) { mDp = dp; - mTransitionDragLength = mActivityInterface.getSwipeUpDestinationAndLength( - dp, mContext, TEMP_RECT); mTaskViewSimulator.setDp(dp); mTaskViewSimulator.setLayoutRotation( mDeviceState.getCurrentActiveRotation(), mDeviceState.getDisplayRotation()); + mTransitionDragLength = mActivityInterface.getSwipeUpDestinationAndLength( + dp, mContext, TEMP_RECT, + mTaskViewSimulator.getOrientationState().getOrientationHandler()); if (mDeviceState.isFullyGesturalNavMode()) { // We can drag all the way to the top of the screen. diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityInterface.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityInterface.java index 4b3af31f38..8dfe75ef24 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityInterface.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/FallbackActivityInterface.java @@ -33,6 +33,7 @@ import com.android.launcher3.DeviceProfile; import com.android.launcher3.R; import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.anim.PendingAnimation; +import com.android.launcher3.touch.PagedOrientationHandler; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.quickstep.fallback.FallbackRecentsView; import com.android.quickstep.fallback.RecentsState; @@ -58,8 +59,9 @@ public final class FallbackActivityInterface extends } @Override - public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect) { - calculateTaskSize(context, dp, outRect); + public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect, + PagedOrientationHandler orientationHandler) { + calculateTaskSize(context, dp, outRect, orientationHandler); if (dp.isVerticalBarLayout() && SysUINavigationMode.INSTANCE.get(context).getMode() != NO_BUTTON) { Rect targetInsets = dp.getInsets(); @@ -100,7 +102,8 @@ public final class FallbackActivityInterface extends rv.setContentAlpha(1); } createActivityInterface(getSwipeUpDestinationAndLength( - activity.getDeviceProfile(), activity, new Rect())); + activity.getDeviceProfile(), activity, new Rect(), + rv.getPagedOrientationHandler())); } @Override @@ -193,7 +196,8 @@ public final class FallbackActivityInterface extends } @Override - protected float getExtraSpace(Context context, DeviceProfile dp) { + protected float getExtraSpace(Context context, DeviceProfile dp, + PagedOrientationHandler orientationHandler) { return showOverviewActions(context) ? context.getResources().getDimensionPixelSize(R.dimen.overview_actions_height) : 0; diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java index 5dbf199599..317d4da92d 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityInterface.java @@ -21,13 +21,12 @@ import static com.android.launcher3.LauncherState.OVERVIEW; import static com.android.launcher3.anim.Interpolators.ACCEL_2; import static com.android.launcher3.anim.Interpolators.INSTANT; import static com.android.launcher3.anim.Interpolators.LINEAR; -import static com.android.launcher3.config.FeatureFlags.ENABLE_OVERVIEW_ACTIONS; import static com.android.launcher3.uioverrides.states.QuickstepAtomicAnimationFactory.INDEX_RECENTS_FADE_ANIM; import static com.android.launcher3.uioverrides.states.QuickstepAtomicAnimationFactory.INDEX_RECENTS_TRANSLATE_X_ANIM; import static com.android.launcher3.uioverrides.states.QuickstepAtomicAnimationFactory.INDEX_SHELF_ANIM; import static com.android.quickstep.LauncherSwipeHandler.RECENTS_ATTACH_DURATION; import static com.android.quickstep.SysUINavigationMode.getMode; -import static com.android.quickstep.SysUINavigationMode.removeShelfFromOverview; +import static com.android.quickstep.SysUINavigationMode.hideShelfInTwoButtonLandscape; import static com.android.quickstep.util.LayoutUtils.getDefaultSwipeHeight; import static com.android.quickstep.views.RecentsView.ADJACENT_PAGE_OFFSET; import static com.android.quickstep.views.RecentsView.FULLSCREEN_PROGRESS; @@ -57,6 +56,7 @@ import com.android.launcher3.appprediction.PredictionUiStateManager; import com.android.launcher3.statehandlers.DepthController; import com.android.launcher3.statehandlers.DepthController.ClampedDepthProperty; import com.android.launcher3.testing.TestProtocol; +import com.android.launcher3.touch.PagedOrientationHandler; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.quickstep.SysUINavigationMode.Mode; import com.android.quickstep.util.ActivityInitListener; @@ -84,14 +84,15 @@ public final class LauncherActivityInterface extends } @Override - public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect) { - calculateTaskSize(context, dp, outRect); + public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect, + PagedOrientationHandler orientationHandler) { + calculateTaskSize(context, dp, outRect, orientationHandler); if (dp.isVerticalBarLayout() && SysUINavigationMode.getMode(context) != Mode.NO_BUTTON) { Rect targetInsets = dp.getInsets(); int hotseatInset = dp.isSeascape() ? targetInsets.left : targetInsets.right; return dp.hotseatBarSizePx + hotseatInset; } else { - return LayoutUtils.getShelfTrackingDistance(context, dp); + return LayoutUtils.getShelfTrackingDistance(context, dp, orientationHandler); } } @@ -395,9 +396,11 @@ public final class LauncherActivityInterface extends } @Override - protected float getExtraSpace(Context context, DeviceProfile dp) { - if (dp.isVerticalBarLayout()) { - return 0; + protected float getExtraSpace(Context context, DeviceProfile dp, + PagedOrientationHandler orientationHandler) { + if (dp.isVerticalBarLayout() || + hideShelfInTwoButtonLandscape(context, orientationHandler)) { + return 0; } else { Resources res = context.getResources(); if (showOverviewActions(context)) { diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/QuickstepTestInformationHandler.java index d4c746f8c6..0d49b2b500 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/QuickstepTestInformationHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/QuickstepTestInformationHandler.java @@ -7,6 +7,7 @@ import android.os.Bundle; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.testing.TestInformationHandler; import com.android.launcher3.testing.TestProtocol; +import com.android.launcher3.touch.PagedOrientationHandler; import com.android.launcher3.uioverrides.touchcontrollers.PortraitStatesTouchController; import com.android.quickstep.util.LayoutUtils; import com.android.systemui.shared.recents.model.Task; @@ -35,7 +36,8 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { case TestProtocol.REQUEST_BACKGROUND_TO_OVERVIEW_SWIPE_HEIGHT: { final float swipeHeight = - LayoutUtils.getShelfTrackingDistance(mContext, mDeviceProfile); + LayoutUtils.getShelfTrackingDistance(mContext, mDeviceProfile, + PagedOrientationHandler.HOME_ROTATED); response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight); return response; } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/TaskViewSimulator.java index f4f7e9c957..178c53e0ff 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/TaskViewSimulator.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/TaskViewSimulator.java @@ -116,7 +116,8 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { if (mDp == null) { return 1; } - mSizeStrategy.calculateTaskSize(mContext, mDp, mTaskRect); + mSizeStrategy.calculateTaskSize(mContext, mDp, mTaskRect, + mOrientationState.getOrientationHandler()); return mOrientationState.getFullScreenScaleAndPivot(mTaskRect, mDp, mPivot); } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java index 3fc235c2f0..aee86db86b 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java @@ -827,6 +827,10 @@ public abstract class RecentsView extends PagedView impl @Override public void setInsets(Rect insets) { mInsets.set(insets); + resetPaddingFromTaskSize(); + } + + private void resetPaddingFromTaskSize() { DeviceProfile dp = mActivity.getDeviceProfile(); mOrientationState.setMultiWindowMode(dp.isMultiWindowMode); getTaskSize(mTempRect); @@ -840,7 +844,8 @@ public abstract class RecentsView extends PagedView impl } public void getTaskSize(Rect outRect) { - mSizeStrategy.calculateTaskSize(mActivity, mActivity.getDeviceProfile(), outRect); + mSizeStrategy.calculateTaskSize(mActivity, mActivity.getDeviceProfile(), outRect, + mOrientationHandler); } /** Gets the task size for modal state. */ @@ -1618,6 +1623,7 @@ public abstract class RecentsView extends PagedView impl mActivity.getDragLayer().recreateControllers(); mActionsView.updateHiddenFlags(HIDDEN_NON_ZERO_ROTATION, touchRotation != 0 || mOrientationState.getLauncherRotation() != ROTATION_0); + resetPaddingFromTaskSize(); requestLayout(); } } diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java index e5c9fc96ad..f77b60b977 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java @@ -51,6 +51,7 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.quickstep.SystemUiProxy; import com.android.quickstep.TouchInteractionService; import com.android.quickstep.util.LayoutUtils; +import com.android.quickstep.views.RecentsView; /** * Touch controller for handling various state transitions in portrait UI. @@ -244,8 +245,9 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr mCurrentAnimation = mPendingAnimation.createPlaybackController() .setOnCancelRunnable(onCancelRunnable); mLauncher.getStateManager().setCurrentUserControlledAnimation(mCurrentAnimation); + RecentsView recentsView = mLauncher.getOverviewPanel(); totalShift = LayoutUtils.getShelfTrackingDistance(mLauncher, - mLauncher.getDeviceProfile()); + mLauncher.getDeviceProfile(), recentsView.getPagedOrientationHandler()); } else { mCurrentAnimation = mLauncher.getStateManager() .createAnimationToNewWorkspace(mToState, config) diff --git a/quickstep/src/com/android/quickstep/BaseActivityInterface.java b/quickstep/src/com/android/quickstep/BaseActivityInterface.java index f29f0ffe30..19932cb4b3 100644 --- a/quickstep/src/com/android/quickstep/BaseActivityInterface.java +++ b/quickstep/src/com/android/quickstep/BaseActivityInterface.java @@ -17,6 +17,7 @@ package com.android.quickstep; import static com.android.launcher3.config.FeatureFlags.ENABLE_OVERVIEW_ACTIONS; import static com.android.quickstep.SysUINavigationMode.getMode; +import static com.android.quickstep.SysUINavigationMode.hideShelfInTwoButtonLandscape; import static com.android.quickstep.SysUINavigationMode.removeShelfFromOverview; import android.annotation.TargetApi; @@ -37,6 +38,7 @@ import com.android.launcher3.anim.AnimatorPlaybackController; import com.android.launcher3.statehandlers.DepthController; import com.android.launcher3.statemanager.BaseState; import com.android.launcher3.statemanager.StatefulActivity; +import com.android.launcher3.touch.PagedOrientationHandler; import com.android.launcher3.util.WindowBounds; import com.android.quickstep.SysUINavigationMode.Mode; import com.android.quickstep.util.ActivityInitListener; @@ -73,7 +75,8 @@ public abstract class BaseActivityInterface Date: Wed, 13 May 2020 09:28:25 -0700 Subject: [PATCH 06/37] Unifying swipe handling for fallback launcher Previosuly we had a different swipe handler for 3P Launcher which started either recents or Launcher based on the initial interaction (horizontal or vertical). This was primarily because we had to wait for recents transition to finish before starting another activity which could delay going to home. Now we always start recents transition to recentsActivity. This allows us to use the same swipe handling logic as QuickstepLauncher. Home activity can be started while recents transition is running and can be controlled using onTaskAppeared callback. Bug: 156924169 Bug: 156398988 Bug: 156295255 Change-Id: Ib9f02e0281e8d674bde2f4a81eca5fc8a5962144 --- .../res/layout/fallback_recents_activity.xml | 1 + .../QuickstepAtomicAnimationFactory.java | 69 +-- .../AppToOverviewAnimationProvider.java | 1 - .../android/quickstep/BaseSwipeUpHandler.java | 5 +- ...Handler.java => BaseSwipeUpHandlerV2.java} | 119 +--- .../quickstep/FallbackActivityInterface.java | 78 +-- .../quickstep/FallbackSwipeHandler.java | 582 +++--------------- .../quickstep/LauncherActivityInterface.java | 237 ++----- .../quickstep/LauncherSwipeHandlerV2.java | 121 ++++ .../android/quickstep/RecentsActivity.java | 7 + .../quickstep/TouchInteractionService.java | 15 +- .../fallback/FallbackRecentsView.java | 51 +- .../DeviceLockedInputConsumer.java | 2 +- .../OtherActivityInputConsumer.java | 10 +- .../util/RecentsAtomicAnimationFactory.java | 67 ++ .../quickstep/views/ClearAllButton.java | 15 +- .../android/quickstep/views/RecentsView.java | 12 +- .../quickstep/BaseActivityInterface.java | 128 +++- .../launcher3/statemanager/StateManager.java | 2 + 19 files changed, 603 insertions(+), 919 deletions(-) rename quickstep/recents_ui_overrides/src/com/android/quickstep/{LauncherSwipeHandler.java => BaseSwipeUpHandlerV2.java} (92%) create mode 100644 quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandlerV2.java create mode 100644 quickstep/recents_ui_overrides/src/com/android/quickstep/util/RecentsAtomicAnimationFactory.java diff --git a/quickstep/recents_ui_overrides/res/layout/fallback_recents_activity.xml b/quickstep/recents_ui_overrides/res/layout/fallback_recents_activity.xml index ffe906c179..7b3e37835f 100644 --- a/quickstep/recents_ui_overrides/res/layout/fallback_recents_activity.xml +++ b/quickstep/recents_ui_overrides/res/layout/fallback_recents_activity.xml @@ -18,6 +18,7 @@ android:id="@+id/drag_layer" android:layout_width="match_parent" android:layout_height="match_parent" + android:clipChildren="false" android:fitsSystemWindows="true"> { +public class QuickstepAtomicAnimationFactory extends + RecentsAtomicAnimationFactory { // Scale recents takes before animating in private static final float RECENTS_PREPARE_SCALE = 1.33f; - public static final int INDEX_SHELF_ANIM = 0; - public static final int INDEX_RECENTS_FADE_ANIM = 1; - public static final int INDEX_RECENTS_TRANSLATE_X_ANIM = 2; - public static final int INDEX_PAUSE_TO_OVERVIEW_ANIM = 3; - private static final int ANIM_COUNT = 4; + public static final int INDEX_SHELF_ANIM = RecentsAtomicAnimationFactory.NEXT_INDEX + 0; + public static final int INDEX_PAUSE_TO_OVERVIEW_ANIM = + RecentsAtomicAnimationFactory.NEXT_INDEX + 1; + + private static final int MY_ANIM_COUNT = 2; + protected static final int NEXT_INDEX = RecentsAtomicAnimationFactory.NEXT_INDEX + + MY_ANIM_COUNT; public static final long ATOMIC_DURATION_FROM_PAUSED_TO_OVERVIEW = 300; - private final QuickstepLauncher mLauncher; - - public QuickstepAtomicAnimationFactory(QuickstepLauncher launcher) { - super(ANIM_COUNT); - mLauncher = launcher; + public QuickstepAtomicAnimationFactory(QuickstepLauncher activity) { + super(activity, MY_ANIM_COUNT); } @Override public Animator createStateElementAnimation(int index, float... values) { switch (index) { case INDEX_SHELF_ANIM: { - AllAppsTransitionController aatc = mLauncher.getAllAppsController(); + AllAppsTransitionController aatc = mActivity.getAllAppsController(); Animator springAnim = aatc.createSpringAnimation(values); - if ((OVERVIEW.getVisibleElements(mLauncher) & HOTSEAT_ICONS) != 0) { + if ((OVERVIEW.getVisibleElements(mActivity) & HOTSEAT_ICONS) != 0) { // Translate hotseat with the shelf until reaching overview. - float overviewProgress = OVERVIEW.getVerticalProgress(mLauncher); - ScaleAndTranslation sat = OVERVIEW.getHotseatScaleAndTranslation(mLauncher); + float overviewProgress = OVERVIEW.getVerticalProgress(mActivity); + ScaleAndTranslation sat = OVERVIEW.getHotseatScaleAndTranslation(mActivity); float shiftRange = aatc.getShiftRange(); if (values.length == 1) { values = new float[] {aatc.getProgress(), values[0]}; @@ -114,9 +112,9 @@ public class QuickstepAtomicAnimationFactory extends AtomicAnimationFactory { float progress = (Float) anim.getAnimatedValue(); - if (progress >= overviewProgress || mLauncher.isInState(BACKGROUND_APP)) { + if (progress >= overviewProgress || mActivity.isInState(BACKGROUND_APP)) { float hotseatShift = (progress - overviewProgress) * shiftRange; - mLauncher.getHotseat().setTranslationY(hotseatShift + sat.translationY); + mActivity.getHotseat().setTranslationY(hotseatShift + sat.translationY); } }); hotseatAnim.setInterpolator(LINEAR); @@ -130,34 +128,21 @@ public class QuickstepAtomicAnimationFactory extends AtomicAnimationFactory stateManager = mLauncher.getStateManager(); + StateManager stateManager = mActivity.getStateManager(); return stateManager.createAtomicAnimation( stateManager.getCurrentStableState(), OVERVIEW, config); } - default: return super.createStateElementAnimation(index, values); } @@ -172,7 +157,7 @@ public class QuickstepAtomicAnimationFactory extends AtomicAnimationFactory 0; if (!isHotseatVisible) { hotseat.setScaleX(0.92f); hotseat.setScaleY(0.92f); if (ENABLE_OVERVIEW_ACTIONS.get()) { - AllAppsContainerView qsbContainer = mLauncher.getAppsView(); + AllAppsContainerView qsbContainer = mActivity.getAppsView(); View qsb = qsbContainer.getSearchView(); boolean qsbVisible = qsb.getVisibility() == VISIBLE && qsb.getAlpha() > 0; if (!qsbVisible) { @@ -209,7 +194,7 @@ public class QuickstepAtomicAnimationFactory extends AtomicAnimationFactory> extend controller.dispatchOnStart(); controller.getAnimationPlayer().end(); }); - factory.onRemoteAnimationReceived(null); factory.createActivityInterface(RECENTS_LAUNCH_DURATION); factory.setRecentsAttachedToAppWindow(true, false); mActivity = activity; diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java index 66fefbe5ef..d9574184f7 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java @@ -55,7 +55,6 @@ import com.android.launcher3.views.FloatingIconView; import com.android.quickstep.RecentsAnimationCallbacks.RecentsAnimationListener; import com.android.quickstep.util.ActiveGestureLog; import com.android.quickstep.util.ActivityInitListener; -import com.android.quickstep.util.AppWindowAnimationHelper; import com.android.quickstep.util.RectFSpringAnim; import com.android.quickstep.util.TaskViewSimulator; import com.android.quickstep.util.TransformParams; @@ -511,8 +510,8 @@ public abstract class BaseSwipeUpHandler, Q extend public interface Factory { - BaseSwipeUpHandler newHandler(GestureState gestureState, long touchTimeMs, - boolean continuingLastGesture, boolean isLikelyToStartNewTask); + BaseSwipeUpHandler newHandler( + GestureState gestureState, long touchTimeMs, boolean continuingLastGesture); } protected interface RunningWindowAnim { diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java similarity index 92% rename from quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java rename to quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java index a8fa630b7b..343f28ac3d 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherSwipeHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java @@ -17,7 +17,6 @@ package com.android.quickstep; import static com.android.launcher3.BaseActivity.INVISIBLE_BY_STATE_HANDLER; import static com.android.launcher3.BaseActivity.STATE_HANDLER_INVISIBILITY_FLAGS; -import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.anim.Interpolators.DEACCEL; import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2; @@ -38,29 +37,24 @@ import static com.android.quickstep.util.ShelfPeekAnim.ShelfAnimState.PEEK; import static com.android.quickstep.views.RecentsView.UPDATE_SYSUI_FLAGS_THRESHOLD; import android.animation.Animator; -import android.animation.AnimatorSet; import android.animation.TimeInterpolator; import android.animation.ValueAnimator; import android.annotation.TargetApi; import android.content.Context; import android.content.Intent; import android.graphics.PointF; -import android.graphics.RectF; import android.os.Build; import android.os.SystemClock; -import android.os.UserHandle; import android.view.View; import android.view.View.OnApplyWindowInsetsListener; import android.view.ViewTreeObserver.OnDrawListener; import android.view.WindowInsets; import android.view.animation.Interpolator; -import androidx.annotation.NonNull; import androidx.annotation.UiThread; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.DeviceProfile; -import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimationSuccessListener; @@ -72,7 +66,6 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch; import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; import com.android.launcher3.util.TraceHelper; -import com.android.launcher3.views.FloatingIconView; import com.android.quickstep.BaseActivityInterface.AnimationFactory; import com.android.quickstep.GestureState.GestureEndTarget; import com.android.quickstep.inputconsumers.OverviewInputConsumer; @@ -80,7 +73,6 @@ import com.android.quickstep.util.ActiveGestureLog; import com.android.quickstep.util.RectFSpringAnim; import com.android.quickstep.util.ShelfPeekAnim; import com.android.quickstep.util.ShelfPeekAnim.ShelfAnimState; -import com.android.quickstep.util.StaggeredWorkspaceAnim; import com.android.quickstep.util.TransformParams.TargetAlphaProvider; import com.android.quickstep.views.LiveTileOverlay; import com.android.quickstep.views.RecentsView; @@ -92,11 +84,12 @@ import com.android.systemui.shared.system.RemoteAnimationTargetCompat; /** * Handles the navigation gestures when Launcher is the default home activity. + * TODO: Merge this with BaseSwipeUpHandler */ @TargetApi(Build.VERSION_CODES.O) -public class LauncherSwipeHandler extends BaseSwipeUpHandler - implements OnApplyWindowInsetsListener { - private static final String TAG = LauncherSwipeHandler.class.getSimpleName(); +public abstract class BaseSwipeUpHandlerV2, Q extends RecentsView> + extends BaseSwipeUpHandler implements OnApplyWindowInsetsListener { + private static final String TAG = BaseSwipeUpHandlerV2.class.getSimpleName(); private static final String[] STATE_NAMES = DEBUG_STATES ? new String[16] : null; @@ -108,9 +101,11 @@ public class LauncherSwipeHandler extends BaseSwipeUpHandler