From 3d1190a5b5fd5dd8db19c1d479fb326719869dcd Mon Sep 17 00:00:00 2001 From: chaviw Date: Mon, 13 Jun 2022 21:48:42 -0500 Subject: [PATCH 01/10] Refactor SurfaceSyncer so it now returns a SurfaceSyncGroup Test: SurfaceSyncGroupContinuousTest Test: SurfaceSyncGroupTest Bug: 237804605 Change-Id: I4e7c1a1509cc64f2992fc07df0684d43fcf3dfc0 --- .../launcher3/taskbar/TaskbarDragController.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java index 04fcc44b55..8ca9dba7a4 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java @@ -37,7 +37,7 @@ import android.view.MotionEvent; import android.view.SurfaceControl; import android.view.View; import android.view.ViewRootImpl; -import android.window.SurfaceSyncer; +import android.window.SurfaceSyncGroup; import androidx.annotation.Nullable; @@ -505,11 +505,11 @@ public class TaskbarDragController extends DragController im // maybeOnDragEnd() SurfaceControl.Transaction transaction = new SurfaceControl.Transaction(); transaction.remove(dragSurface); - SurfaceSyncer syncer = new SurfaceSyncer(); - int syncId = syncer.setupSync(transaction::close); - syncer.addToSync(syncId, viewRoot.getView()); - syncer.addTransactionToSync(syncId, transaction); - syncer.markSyncReady(syncId); + SurfaceSyncGroup syncGroup = new SurfaceSyncGroup(); + syncGroup.addSyncCompleteCallback(mActivity.getMainExecutor(), transaction::close); + syncGroup.addToSync(viewRoot); + syncGroup.addTransactionToSync(transaction); + syncGroup.markSyncReady(); mReturnAnimator = null; } }); From 3f6c4731646184d1ccebe641e66e07a2831e0a4e Mon Sep 17 00:00:00 2001 From: Schneider Victor-tulias Date: Thu, 23 Jun 2022 11:25:10 -0700 Subject: [PATCH 02/10] Fade out the taskbar icons when animating to overview in 3 button nav. Bug: 231213105 Test: from home, opened recents, then went back home, then went back to recents, resumed an app, then went back to recents and resumed the same app (both in 3-button and gesture nav) Change-Id: I83b1b33cafb95353f36a126b93fcaf3b536d3bf4 --- .../taskbar/NavbarButtonsViewController.java | 17 +++++-------- .../taskbar/StashedHandleViewController.java | 7 +++--- .../TaskbarAutohideSuspendController.java | 3 +-- .../taskbar/TaskbarDragController.java | 14 +++++------ .../taskbar/TaskbarDragLayerController.java | 7 +++--- .../taskbar/TaskbarEduController.java | 10 ++++---- .../taskbar/TaskbarKeyguardController.java | 10 ++++---- .../TaskbarLauncherStateController.java | 20 +++++++++++----- .../taskbar/TaskbarNavButtonController.java | 7 +++--- .../taskbar/TaskbarScrimViewController.java | 2 +- .../taskbar/TaskbarStashController.java | 18 +++++++------- .../taskbar/TaskbarViewController.java | 13 ++++++++++ .../uioverrides/states/OverviewState.java | 10 +------- src/com/android/launcher3/LauncherState.java | 8 +++++-- .../launcher3/util/MultiValueAlpha.java | 24 +++++++++++++++++++ 15 files changed, 97 insertions(+), 73 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java index 17da0d944b..cb7319432c 100644 --- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java @@ -734,17 +734,12 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT public void dumpLogs(String prefix, PrintWriter pw) { pw.println(prefix + "NavbarButtonsViewController:"); - pw.println(String.format("%s\tmState=%s", prefix, getStateString(mState))); - pw.println(String.format( - "%s\tmLightIconColor=0x%s", prefix, Integer.toHexString(mLightIconColor))); - pw.println(String.format( - "%s\tmDarkIconColor=0x%s", prefix, Integer.toHexString(mDarkIconColor))); - pw.println(String.format( - "%s\tmFloatingRotationButtonBounds=%s", prefix, mFloatingRotationButtonBounds)); - pw.println(String.format( - "%s\tmSysuiStateFlags=%s", - prefix, - QuickStepContract.getSystemUiStateString(mSysuiStateFlags))); + pw.println(prefix + "\tmState=" + getStateString(mState)); + pw.println(prefix + "\tmLightIconColor=" + Integer.toHexString(mLightIconColor)); + pw.println(prefix + "\tmDarkIconColor=" + Integer.toHexString(mDarkIconColor)); + pw.println(prefix + "\tmFloatingRotationButtonBounds=" + mFloatingRotationButtonBounds); + pw.println(prefix + "\tmSysuiStateFlags=" + QuickStepContract.getSystemUiStateString( + mSysuiStateFlags)); } private static String getStateString(int flags) { diff --git a/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java b/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java index f472427520..800e1629f4 100644 --- a/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java @@ -209,10 +209,9 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT public void dumpLogs(String prefix, PrintWriter pw) { pw.println(prefix + "StashedHandleViewController:"); - pw.println(String.format( - "%s\tisStashedHandleVisible=%b", prefix, isStashedHandleVisible())); - pw.println(String.format("%s\tmStashedHandleWidth=%dpx", prefix, mStashedHandleWidth)); - pw.println(String.format("%s\tmStashedHandleHeight=%dpx", prefix, mStashedHandleHeight)); + pw.println(prefix + "\tisStashedHandleVisible=" + isStashedHandleVisible()); + pw.println(prefix + "\tmStashedHandleWidth=" + mStashedHandleWidth); + pw.println(prefix + "\tmStashedHandleHeight=" + mStashedHandleHeight); mRegionSamplingHelper.dump(prefix, pw); } } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarAutohideSuspendController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarAutohideSuspendController.java index c5615c7ba1..3cf9c997c9 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarAutohideSuspendController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarAutohideSuspendController.java @@ -71,8 +71,7 @@ public class TaskbarAutohideSuspendController implements public void dumpLogs(String prefix, PrintWriter pw) { pw.println(prefix + "TaskbarAutohideSuspendController:"); - pw.println(String.format( - "%s\tmAutohideSuspendFlags=%s", prefix, getStateString(mAutohideSuspendFlags))); + pw.println(prefix + "\tmAutohideSuspendFlags=" + getStateString(mAutohideSuspendFlags)); } private static String getStateString(int flags) { diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java index 04fcc44b55..3a0f3740a2 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java @@ -559,13 +559,11 @@ public class TaskbarDragController extends DragController im public void dumpLogs(String prefix, PrintWriter pw) { pw.println(prefix + "TaskbarDragController:"); - pw.println(String.format("%s\tmDragIconSize=%dpx", prefix, mDragIconSize)); - pw.println(String.format("%s\tmTempXY=%s", prefix, Arrays.toString(mTempXY))); - pw.println(String.format("%s\tmRegistrationX=%d", prefix, mRegistrationX)); - pw.println(String.format("%s\tmRegistrationY=%d", prefix, mRegistrationY)); - pw.println(String.format( - "%s\tmIsSystemDragInProgress=%b", prefix, mIsSystemDragInProgress)); - pw.println(String.format( - "%s\tisInternalDragInProgess=%b", prefix, super.isDragging())); + pw.println(prefix + "\tmDragIconSize=" + mDragIconSize); + pw.println(prefix + "\tmTempXY=" + Arrays.toString(mTempXY)); + pw.println(prefix + "\tmRegistrationX=" + mRegistrationX); + pw.println(prefix + "\tmRegistrationY=" + mRegistrationY); + pw.println(prefix + "\tmIsSystemDragInProgress=" + mIsSystemDragInProgress); + pw.println(prefix + "\tisInternalDragInProgess=" + super.isDragging()); } } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java index 99c59a8a98..77ef83cbe4 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayerController.java @@ -144,10 +144,9 @@ public class TaskbarDragLayerController implements TaskbarControllers.LoggableTa public void dumpLogs(String prefix, PrintWriter pw) { pw.println(prefix + "TaskbarDragLayerController:"); - pw.println(String.format("%s\tmBgOffset=%.2f", prefix, mBgOffset.value)); - pw.println(String.format("%s\tmFolderMargin=%dpx", prefix, mFolderMargin)); - pw.println(String.format( - "%s\tmLastSetBackgroundAlpha=%.2f", prefix, mLastSetBackgroundAlpha)); + pw.println(prefix + "\tmBgOffset=" + mBgOffset.value); + pw.println(prefix + "\tmFolderMargin=" + mFolderMargin); + pw.println(prefix + "\tmLastSetBackgroundAlpha=" + mLastSetBackgroundAlpha); } /** diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduController.java index e29b14b76f..32a3c10d87 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarEduController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarEduController.java @@ -191,12 +191,10 @@ public class TaskbarEduController implements TaskbarControllers.LoggableTaskbarC public void dumpLogs(String prefix, PrintWriter pw) { pw.println(prefix + "TaskbarEduController:"); - pw.println(String.format("%s\tisShowingEdu=%b", prefix, mTaskbarEduView != null)); - pw.println(String.format("%s\tmWaveAnimTranslationY=%.2f", prefix, mWaveAnimTranslationY)); - pw.println(String.format( - "%s\tmWaveAnimTranslationYReturnOvershoot=%.2f", - prefix, - mWaveAnimTranslationYReturnOvershoot)); + pw.println(prefix + "\tisShowingEdu=" + (mTaskbarEduView != null)); + pw.println(prefix + "\tmWaveAnimTranslationY=" + mWaveAnimTranslationY); + pw.println(prefix + "\tmWaveAnimTranslationYReturnOvershoot=" + + mWaveAnimTranslationYReturnOvershoot); } /** diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarKeyguardController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarKeyguardController.java index 56648eac38..0808faba1c 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarKeyguardController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarKeyguardController.java @@ -111,11 +111,9 @@ public class TaskbarKeyguardController implements TaskbarControllers.LoggableTas public void dumpLogs(String prefix, PrintWriter pw) { pw.println(prefix + "TaskbarKeyguardController:"); - pw.println(String.format( - "%s\tmKeyguardSysuiFlags=%s", - prefix, - QuickStepContract.getSystemUiStateString(mKeyguardSysuiFlags))); - pw.println(String.format("%s\tmBouncerShowing=%b", prefix, mBouncerShowing)); - pw.println(String.format("%s\tmIsScreenOff=%b", prefix, mIsScreenOff)); + pw.println(prefix + "\tmKeyguardSysuiFlags=" + QuickStepContract.getSystemUiStateString( + mKeyguardSysuiFlags)); + pw.println(prefix + "\tmBouncerShowing=" + mBouncerShowing); + pw.println(prefix + "\tmIsScreenOff=" + mIsScreenOff); } } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java index ff11f67b3e..85e76b26d4 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java @@ -35,6 +35,7 @@ import com.android.launcher3.BaseQuickstepLauncher; import com.android.launcher3.LauncherState; import com.android.launcher3.QuickstepTransitionManager; import com.android.launcher3.Utilities; +import com.android.launcher3.anim.AnimatorListeners; import com.android.launcher3.statemanager.StateManager; import com.android.launcher3.util.MultiValueAlpha; import com.android.quickstep.AnimatedFloat; @@ -367,11 +368,14 @@ import java.util.function.Supplier; private void playStateTransitionAnim(AnimatorSet animatorSet, long duration, boolean committed) { boolean isInStashedState = mLauncherState.isTaskbarStashed(mLauncher); - float toAlignment = mLauncherState.isTaskbarAlignedWithHotseat(mLauncher) ? 1 : 0; + boolean willStashVisually = + isInStashedState && mControllers.taskbarStashController.supportsVisualStashing(); + float toAlignment = + mLauncherState.isTaskbarAlignedWithHotseat(mLauncher) && !willStashVisually ? 1 : 0; - TaskbarStashController controller = mControllers.taskbarStashController; - controller.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE, isInStashedState); - Animator stashAnimator = controller.applyStateWithoutStart(duration); + TaskbarStashController stashController = mControllers.taskbarStashController; + stashController.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE, isInStashedState); + Animator stashAnimator = stashController.applyStateWithoutStart(duration); if (stashAnimator != null) { stashAnimator.addListener(new AnimatorListenerAdapter() { @Override @@ -391,9 +395,13 @@ import java.util.function.Supplier; }); animatorSet.play(stashAnimator); } - - // If we're already animating to the value, just leave it be instead of restarting it. + if (mIconAlignmentForLauncherState.value == toAlignment) { + // Already at expected value, but make sure we run the callback at the end. + animatorSet.addListener(AnimatorListeners.forEndCallback( + this::onIconAlignmentRatioChangedForStateTransition)); + } if (!mIconAlignmentForLauncherState.isAnimatingToValue(toAlignment)) { + // If we're already animating to the value, just leave it be instead of restarting it. mIconAlignmentForLauncherState.finishAnimation(); animatorSet.play(mIconAlignmentForLauncherState.animateToValue(toAlignment) .setDuration(duration)); diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java index 3392b6b887..60f50a9689 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java @@ -18,7 +18,6 @@ package com.android.launcher3.taskbar; import static com.android.internal.app.AssistUtils.INVOCATION_TYPE_HOME_BUTTON_LONG_PRESS; import static com.android.internal.app.AssistUtils.INVOCATION_TYPE_KEY; -import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_A11Y_BUTTON_LONGPRESS; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_A11Y_BUTTON_TAP; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_BACK_BUTTON_LONGPRESS; @@ -28,6 +27,7 @@ import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCH import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_IME_SWITCHER_BUTTON_TAP; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_OVERVIEW_BUTTON_LONGPRESS; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_TASKBAR_OVERVIEW_BUTTON_TAP; +import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_SCREEN_PINNING; import android.os.Bundle; @@ -72,9 +72,8 @@ public class TaskbarNavButtonController implements TaskbarControllers.LoggableTa public void dumpLogs(String prefix, PrintWriter pw) { pw.println(prefix + "TaskbarNavButtonController:"); - pw.println(String.format( - "%s\tmLastScreenPinLongPress=%dms", prefix, mLastScreenPinLongPress)); - pw.println(String.format("%s\tmScreenPinned=%b", prefix, mScreenPinned)); + pw.println(prefix + "\tmLastScreenPinLongPress=" + mLastScreenPinLongPress); + pw.println(prefix + "\tmScreenPinned=" + mScreenPinned); } @Retention(RetentionPolicy.SOURCE) diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarScrimViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarScrimViewController.java index 58ace17787..c3b0f57c2d 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarScrimViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarScrimViewController.java @@ -98,6 +98,6 @@ public class TaskbarScrimViewController implements TaskbarControllers.LoggableTa public void dumpLogs(String prefix, PrintWriter pw) { pw.println(prefix + "TaskbarScrimViewController:"); - pw.println(String.format("%s\tmScrimAlpha.value=%.2f", prefix, mScrimAlpha.value)); + pw.println(prefix + "\tmScrimAlpha.value=" + mScrimAlpha.value); } } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java index 2b8fdd102f..513f1bbed0 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java @@ -728,16 +728,14 @@ public class TaskbarStashController implements TaskbarControllers.LoggableTaskba public void dumpLogs(String prefix, PrintWriter pw) { pw.println(prefix + "TaskbarStashController:"); - pw.println(String.format("%s\tmStashedHeight=%dpx", prefix, mStashedHeight)); - pw.println(String.format("%s\tmUnstashedHeight=%dpx", prefix, mUnstashedHeight)); - pw.println(String.format("%s\tmIsStashed=%b", prefix, mIsStashed)); - pw.println(String.format( - "%s\tappliedState=%s", prefix, getStateString(mStatePropertyHolder.mPrevFlags))); - pw.println(String.format("%s\tmState=%s", prefix, getStateString(mState))); - pw.println(String.format( - "%s\tmIsSystemGestureInProgress=%b", prefix, mIsSystemGestureInProgress)); - pw.println(String.format("%s\tmIsImeShowing=%b", prefix, mIsImeShowing)); - pw.println(String.format("%s\tmIsImeSwitcherShowing=%b", prefix, mIsImeSwitcherShowing)); + pw.println(prefix + "\tmStashedHeight=" + mStashedHeight); + pw.println(prefix + "\tmUnstashedHeight=" + mUnstashedHeight); + pw.println(prefix + "\tmIsStashed=" + mIsStashed); + pw.println(prefix + "\tappliedState=" + getStateString(mStatePropertyHolder.mPrevFlags)); + pw.println(prefix + "\tmState=" + getStateString(mState)); + pw.println(prefix + "\tmIsSystemGestureInProgress=" + mIsSystemGestureInProgress); + pw.println(prefix + "\tmIsImeShowing=" + mIsImeShowing); + pw.println(prefix + "\tmIsImeSwitcherShowing=" + mIsImeSwitcherShowing); } private static String getStateString(int flags) { diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java index db7dc78f7b..6d45fd2d5c 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java @@ -373,6 +373,19 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar @Override public void dumpLogs(String prefix, PrintWriter pw) { pw.println(prefix + "TaskbarViewController:"); + + mTaskbarIconAlpha.dump( + prefix + "\t", + pw, + "mTaskbarIconAlpha", + "ALPHA_INDEX_HOME", + "ALPHA_INDEX_KEYGUARD", + "ALPHA_INDEX_STASH", + "ALPHA_INDEX_RECENTS_DISABLED", + "ALPHA_INDEX_NOTIFICATION_EXPANDED", + "ALPHA_INDEX_ASSISTANT_INVOKED", + "ALPHA_INDEX_IME_BUTTON_NAV"); + mModelCallbacks.dumpLogs(prefix + "\t", pw); } diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java index 6427e0981a..c4c903815e 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java @@ -22,12 +22,10 @@ import android.content.Context; import android.graphics.Rect; import android.os.SystemProperties; -import com.android.launcher3.BaseQuickstepLauncher; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; import com.android.launcher3.R; -import com.android.launcher3.taskbar.LauncherTaskbarUIController; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.Themes; import com.android.quickstep.util.LayoutUtils; @@ -95,13 +93,7 @@ public class OverviewState extends LauncherState { @Override public boolean isTaskbarStashed(Launcher launcher) { - if (launcher instanceof BaseQuickstepLauncher) { - LauncherTaskbarUIController uiController = - ((BaseQuickstepLauncher) launcher).getTaskbarUIController(); - - return uiController != null && uiController.supportsVisualStashing(); - } - return super.isTaskbarStashed(launcher); + return true; } @Override diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java index ea6a9199d7..8b5cdbd9e2 100644 --- a/src/com/android/launcher3/LauncherState.java +++ b/src/com/android/launcher3/LauncherState.java @@ -208,14 +208,18 @@ public abstract class LauncherState implements BaseState { return (getVisibleElements(launcher) & elements) == elements; } - /** Returns whether taskbar is stashed and thus should replace hotseat with a handle */ + /** + * Returns whether taskbar is stashed and thus should either: + * 1) replace hotseat or taskbar icons with a handle in gesture navigation mode or + * 2) fade out the hotseat or taskbar icons in 3-button navigation mode. + */ public boolean isTaskbarStashed(Launcher launcher) { return false; } /** Returns whether taskbar is aligned with the hotseat vs position inside apps */ public boolean isTaskbarAlignedWithHotseat(Launcher launcher) { - return !isTaskbarStashed(launcher); + return true; } /** diff --git a/src/com/android/launcher3/util/MultiValueAlpha.java b/src/com/android/launcher3/util/MultiValueAlpha.java index 11cd07c838..4b46a0a04c 100644 --- a/src/com/android/launcher3/util/MultiValueAlpha.java +++ b/src/com/android/launcher3/util/MultiValueAlpha.java @@ -23,6 +23,7 @@ import android.view.View; import com.android.launcher3.anim.AlphaUpdateListener; +import java.io.PrintWriter; import java.util.Arrays; import java.util.function.Consumer; @@ -78,6 +79,29 @@ public class MultiValueAlpha { mUpdateVisibility = updateVisibility; } + /** + * Dumps the alpha channel values to the given PrintWriter + * + * @param prefix String to be used before every line + * @param pw PrintWriter where the logs should be dumped + * @param label String used to help identify this object + * @param alphaIndexLabels Strings that represent each alpha channel, these should be entered + * in the order of the indexes they represent, starting from 0. + */ + public void dump(String prefix, PrintWriter pw, String label, String... alphaIndexLabels) { + pw.println(prefix + label); + + String innerPrefix = prefix + '\t'; + for (int i = 0; i < alphaIndexLabels.length; i++) { + if (i >= mMyProperties.length) { + pw.println(innerPrefix + alphaIndexLabels[i] + " given for alpha index " + i + + " however there are only " + mMyProperties.length + " alpha channels."); + continue; + } + pw.println(innerPrefix + alphaIndexLabels[i] + "=" + getProperty(i).getValue()); + } + } + public class AlphaProperty { private final int mMyMask; From 355b66d1ab4d5e0f66dd13f35fe4d0a8ef2db7e2 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Wed, 20 Jul 2022 15:29:24 -0700 Subject: [PATCH 03/10] Hide the task icon during quick switch from home Test: manual Fixes: 238753582 Change-Id: Ic1badf4479c5273fd4d182ef7da04797885a6a36 --- .../touchcontrollers/NoButtonQuickSwitchTouchController.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java index 53dc9dd873..f294986fa3 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java @@ -232,6 +232,7 @@ public class NoButtonQuickSwitchTouchController implements TouchController, mRecentsView.setFullscreenProgress(fromState.getOverviewFullscreenProgress()); mLauncher.getActionsView().getVisibilityAlpha().setValue( (fromState.getVisibleElements(mLauncher) & OVERVIEW_ACTIONS) != 0 ? 1f : 0f); + mRecentsView.setTaskIconScaledDown(true); float[] scaleAndOffset = toState.getOverviewScaleAndOffset(mLauncher); // As we drag right, animate the following properties: @@ -321,6 +322,7 @@ public class NoButtonQuickSwitchTouchController implements TouchController, boolean verticalFling = mSwipeDetector.isFling(velocity.y); boolean noFling = !horizontalFling && !verticalFling; if (mMotionPauseDetector.isPaused() && noFling) { + // Going to Overview. cancelAnimations(); StateAnimationConfig config = new StateAnimationConfig(); @@ -331,6 +333,8 @@ public class NoButtonQuickSwitchTouchController implements TouchController, @Override public void onAnimationEnd(Animator animation) { onAnimationToStateCompleted(OVERVIEW); + // Animate the icon after onAnimationToStateCompleted() so it doesn't clobber. + mRecentsView.animateUpTaskIconScale(); } }); overviewAnim.start(); From 8b0793f9ef0eb28e6f4f3cb745cd2de24bf3551a Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Fri, 22 Jul 2022 23:23:12 +0000 Subject: [PATCH 04/10] Prevent setting max layer above the input consumer - The leash is being set to max layer above the specified layer of the recents input consumer set by WM (in InputMonitor), revert this for legacy transitions Bug: 239042246 Test: Swipe up to overview and quickly swipe again Change-Id: I92ab2ae0917857b6b1154f6250e7fac6565a58f1 --- .../com/android/quickstep/util/TaskViewSimulator.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java index c626b0ac81..6f6474eefc 100644 --- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java +++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java @@ -22,6 +22,7 @@ import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITIO import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT; import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_UNDEFINED; 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; @@ -387,7 +388,14 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { .withCornerRadius(getCurrentCornerRadius()); if (ENABLE_QUICKSTEP_LIVE_TILE.get()) { - builder.withLayer(mDrawsBelowRecents ? Integer.MIN_VALUE + 1 : Integer.MAX_VALUE); + // In legacy transitions, the animation leashes remain in same hierarchy in the + // TaskDisplayArea, so we don't want to bump the layer too high otherwise it will + // conflict with layers that WM core positions (ie. the input consumers). For shell + // transitions, the animation leashes are reparented to an animation container so we + // can bump layers as needed. + builder.withLayer(mDrawsBelowRecents + ? Integer.MIN_VALUE + 1 + : ENABLE_SHELL_TRANSITIONS ? Integer.MAX_VALUE : 0); } } From 62572c04e20a27627c71da9e9d44e3196f52053e Mon Sep 17 00:00:00 2001 From: Alex Chau Date: Mon, 25 Jul 2022 18:36:37 +0000 Subject: [PATCH 05/10] Revert "Move BaseActivityInterface task size methods to DevicePr..." Revert "Move BaseActivityInterface task size methods to DevicePr..." Revert submission 19279487-baseactivityinterface Reason for revert: As per discussion in ag/19341332, make sure DeviceProfile can properly react to inset changes before moving task size calculations there Reverted Changes: I30324d34c:Move BaseActivityInterface task size methods to De... Ia9c1d0387:Move BaseActivityInterface task size methods to De... Bug: 238593212 Change-Id: I0d40fdd4a5d4468494e30cef32a284479ddd2feb --- .../launcher3/BaseQuickstepLauncher.java | 2 +- .../taskbar/TaskbarActivityContext.java | 2 +- .../states/BackgroundAppState.java | 3 +- .../states/OverviewModalTaskState.java | 11 +- .../uioverrides/states/OverviewState.java | 7 +- .../NoButtonQuickSwitchTouchController.java | 4 +- .../PortraitStatesTouchController.java | 4 +- .../android/quickstep/AbsSwipeUpHandler.java | 4 +- .../quickstep/BaseActivityInterface.java | 131 +++++++++++- .../quickstep/FallbackActivityInterface.java | 8 +- .../quickstep/LauncherActivityInterface.java | 8 +- .../QuickstepTestInformationHandler.java | 18 +- .../quickstep/SwipeUpAnimationLogic.java | 3 +- .../quickstep/TouchInteractionService.java | 2 +- .../AnimatorControllerWithResistance.java | 4 +- .../android/quickstep/util/LayoutUtils.java | 12 +- .../quickstep/util/RecentsOrientedState.java | 5 +- .../quickstep/util/TaskViewSimulator.java | 8 +- .../quickstep/views/OverviewActionsView.java | 8 +- .../android/quickstep/views/RecentsView.java | 119 +++++++---- .../com/android/quickstep/views/TaskView.java | 12 +- .../DeviceProfilePhone3ButtonTest.kt | 110 ---------- .../quickstep/DeviceProfilePhoneTest.kt | 110 ---------- ...DeviceProfileTabletLandscape3ButtonTest.kt | 110 ---------- .../DeviceProfileTabletLandscapeTest.kt | 110 ---------- .../DeviceProfileTabletPortrait3ButtonTest.kt | 110 ---------- .../DeviceProfileTabletPortraitTest.kt | 110 ---------- ...viceProfileTwoPanelLandscape3ButtonTest.kt | 110 ---------- .../DeviceProfileTwoPanelLandscapeTest.kt | 110 ---------- ...eviceProfileTwoPanelPortrait3ButtonTest.kt | 110 ---------- .../DeviceProfileTwoPanelPortraitTest.kt | 110 ---------- .../DeviceProfileVerticalBar3ButtonTest.kt | 110 ---------- .../quickstep/DeviceProfileVerticalBarTest.kt | 110 ---------- res/values/dimens.xml | 3 - src/com/android/launcher3/DeviceProfile.java | 202 ++---------------- src/com/android/launcher3/Launcher.java | 2 +- .../launcher3/DeviceProfileBaseTest.kt | 3 +- 37 files changed, 307 insertions(+), 1598 deletions(-) diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java index ec497ef1f9..e21dcbadf2 100644 --- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java @@ -337,7 +337,7 @@ public abstract class BaseQuickstepLauncher extends Launcher { new SplitSelectStateController(this, mHandler, getStateManager(), getDepthController()); overviewPanel.init(mActionsView, controller); - mActionsView.updateDimension(getDeviceProfile()); + mActionsView.updateDimension(getDeviceProfile(), overviewPanel.getLastComputedTaskSize()); mActionsView.updateVerticalMargin(DisplayController.getNavigationMode(this)); mAppTransitionManager = new QuickstepTransitionManager(this); diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 6b12e9c164..439490e00c 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -839,6 +839,6 @@ public class TaskbarActivityContext extends BaseTaskbarContext { pw.println(String.format( "%s\tmBindInProgress=%b", prefix, mBindingItems)); mControllers.dumpLogs(prefix + "\t", pw); - mDeviceProfile.dump(this, prefix, pw); + mDeviceProfile.dump(prefix, pw); } } diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java b/quickstep/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java index 297a61a38d..b7330072d4 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java @@ -50,7 +50,8 @@ public class BackgroundAppState extends OverviewState { return super.getVerticalProgress(launcher); } RecentsView recentsView = launcher.getOverviewPanel(); - int transitionLength = LayoutUtils.getShelfTrackingDistance(launcher.getDeviceProfile(), + int transitionLength = LayoutUtils.getShelfTrackingDistance(launcher, + launcher.getDeviceProfile(), recentsView.getPagedOrientationHandler()); AllAppsTransitionController controller = launcher.getAllAppsController(); float scrollRange = Math.max(controller.getShiftRange(), 1); diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewModalTaskState.java b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewModalTaskState.java index 0f02e2663e..0c49e5fc69 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewModalTaskState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewModalTaskState.java @@ -18,6 +18,8 @@ package com.android.launcher3.uioverrides.states; import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_OVERVIEW; import android.content.Context; +import android.graphics.Point; +import android.graphics.Rect; import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.Launcher; @@ -69,6 +71,13 @@ public class OverviewModalTaskState extends OverviewState { } public static float[] getOverviewScaleAndOffsetForModalState(BaseDraggingActivity activity) { - return new float[] {activity.getDeviceProfile().overviewModalTaskScale, NO_OFFSET}; + Point taskSize = activity.getOverviewPanel().getSelectedTaskSize(); + Rect modalTaskSize = new Rect(); + activity.getOverviewPanel().getModalTaskSize(modalTaskSize); + + float scale = Math.min((float) modalTaskSize.height() / taskSize.y, + (float) modalTaskSize.width() / taskSize.x); + + return new float[] {scale, NO_OFFSET}; } } diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java index c0810b929e..6427e0981a 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java @@ -65,9 +65,12 @@ public class OverviewState extends LauncherState { @Override public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) { + RecentsView recentsView = launcher.getOverviewPanel(); + float workspacePageHeight = launcher.getDeviceProfile().getCellLayoutHeight(); + recentsView.getTaskSize(sTempRect); + float scale = (float) sTempRect.height() / workspacePageHeight; float parallaxFactor = 0.5f; - return new ScaleAndTranslation(launcher.getDeviceProfile().overviewTaskWorkspaceScale, 0, - -getDefaultSwipeHeight(launcher) * parallaxFactor); + return new ScaleAndTranslation(scale, 0, -getDefaultSwipeHeight(launcher) * parallaxFactor); } @Override diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java index d06f64a1be..53dc9dd873 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonQuickSwitchTouchController.java @@ -120,8 +120,8 @@ public class NoButtonQuickSwitchTouchController implements TouchController, mSwipeDetector = new BothAxesSwipeDetector(mLauncher, this); mRecentsView = mLauncher.getOverviewPanel(); mXRange = mLauncher.getDeviceProfile().widthPx / 2f; - mYRange = LayoutUtils.getShelfTrackingDistance(mLauncher.getDeviceProfile(), - mRecentsView.getPagedOrientationHandler()); + mYRange = LayoutUtils.getShelfTrackingDistance( + mLauncher, mLauncher.getDeviceProfile(), mRecentsView.getPagedOrientationHandler()); mMaxYProgress = mLauncher.getDeviceProfile().heightPx / mYRange; mMotionPauseDetector = new MotionPauseDetector(mLauncher); mMotionPauseMinDisplacement = mLauncher.getResources().getDimension( diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java index 73949457b6..9efbc34a17 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java +++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java @@ -144,8 +144,8 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr .createPlaybackController(); mLauncher.getStateManager().setCurrentUserControlledAnimation(mCurrentAnimation); RecentsView recentsView = mLauncher.getOverviewPanel(); - totalShift = LayoutUtils.getShelfTrackingDistance(mLauncher.getDeviceProfile(), - recentsView.getPagedOrientationHandler()); + totalShift = LayoutUtils.getShelfTrackingDistance(mLauncher, + mLauncher.getDeviceProfile(), recentsView.getPagedOrientationHandler()); } else { mCurrentAnimation = mLauncher.getStateManager() .createAnimationToNewWorkspace(mToState, config); diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 1ec00a0ca9..d7fea371f3 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -2048,8 +2048,8 @@ public abstract class AbsSwipeUpHandler, float scrollOffset = Math.abs(mRecentsView.getScrollOffset(mRecentsView.getCurrentPage())); int maxScrollOffset = mRecentsView.getPagedOrientationHandler().getPrimaryValue( - mActivity.getDeviceProfile().overviewTaskRect.width(), - mActivity.getDeviceProfile().overviewTaskRect.height()); + mRecentsView.getLastComputedTaskSize().width(), + mRecentsView.getLastComputedTaskSize().height()); maxScrollOffset += mRecentsView.getPageSpacing(); float maxScaleProgress = diff --git a/quickstep/src/com/android/quickstep/BaseActivityInterface.java b/quickstep/src/com/android/quickstep/BaseActivityInterface.java index a922f58993..6354282d47 100644 --- a/quickstep/src/com/android/quickstep/BaseActivityInterface.java +++ b/quickstep/src/com/android/quickstep/BaseActivityInterface.java @@ -33,9 +33,12 @@ import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.annotation.TargetApi; import android.content.Context; +import android.content.res.Resources; import android.graphics.Color; +import android.graphics.PointF; import android.graphics.Rect; import android.os.Build; +import android.view.Gravity; import android.view.MotionEvent; import android.view.View; @@ -43,6 +46,7 @@ import androidx.annotation.Nullable; import androidx.annotation.UiThread; 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.statehandlers.DepthController; @@ -105,8 +109,8 @@ public abstract class BaseActivityInterface PendingAnimation createRecentsResistanceAnim( RecentsParams params) { - Rect startRect = new Rect(params.dp.overviewTaskRect); + Rect startRect = new Rect(); PagedOrientationHandler orientationHandler = params.recentsOrientedState .getOrientationHandler(); + LauncherActivityInterface.INSTANCE.calculateTaskSize(params.context, params.dp, startRect); long distanceToCover = startRect.bottom; PendingAnimation resistAnim = params.resistAnim != null ? params.resistAnim diff --git a/quickstep/src/com/android/quickstep/util/LayoutUtils.java b/quickstep/src/com/android/quickstep/util/LayoutUtils.java index d4eb880c61..d0856bed20 100644 --- a/quickstep/src/com/android/quickstep/util/LayoutUtils.java +++ b/quickstep/src/com/android/quickstep/util/LayoutUtils.java @@ -16,6 +16,7 @@ package com.android.quickstep.util; import android.content.Context; +import android.graphics.Rect; import android.view.View; import android.view.ViewGroup; @@ -23,6 +24,7 @@ import com.android.launcher3.DeviceProfile; import com.android.launcher3.touch.PagedOrientationHandler; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.DisplayController.NavigationMode; +import com.android.quickstep.LauncherActivityInterface; public class LayoutUtils { @@ -37,12 +39,12 @@ public class LayoutUtils { return swipeHeight; } - /** - * Returns the shelf tracking distance. - */ - public static int getShelfTrackingDistance(DeviceProfile dp, + public static int getShelfTrackingDistance(Context context, DeviceProfile dp, PagedOrientationHandler orientationHandler) { - return orientationHandler.getDistanceToBottomOfRect(dp, dp.overviewTaskRect); + // Track the bottom of the window. + Rect taskSize = new Rect(); + LauncherActivityInterface.INSTANCE.calculateTaskSize(context, dp, taskSize); + return orientationHandler.getDistanceToBottomOfRect(dp, taskSize); } /** diff --git a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java index 39e379771a..dec934a87b 100644 --- a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java +++ b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java @@ -25,6 +25,7 @@ import static android.view.Surface.ROTATION_90; import static com.android.launcher3.states.RotationHelper.ALLOW_ROTATION_PREFERENCE_KEY; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import static com.android.launcher3.util.SettingsCache.ROTATION_SETTING_URI; +import static com.android.quickstep.BaseActivityInterface.getTaskDimension; import static java.lang.annotation.RetentionPolicy.SOURCE; @@ -397,8 +398,8 @@ public class RecentsOrientedState implements * Returns the scale and pivot so that the provided taskRect can fit the provided full size */ public float getFullScreenScaleAndPivot(Rect taskView, DeviceProfile dp, PointF outPivot) { - float scale = Math.min(dp.taskDimension.x / taskView.width(), - dp.taskDimension.y / taskView.height()); + getTaskDimension(dp, outPivot); + float scale = Math.min(outPivot.x / taskView.width(), outPivot.y / taskView.height()); if (scale == 1) { outPivot.set(taskView.centerX(), taskView.centerY()); } else { diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java index c626b0ac81..8c48443ef3 100644 --- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java +++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java @@ -144,8 +144,12 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy { if (mDp == null) { return 1; } - mTaskRect.set( - mIsGridTask ? mDp.getOverviewGridTaskRect(mIsRecentsRtl) : mDp.overviewTaskRect); + if (mIsGridTask) { + mSizeStrategy.calculateGridTaskSize(mContext, mDp, mTaskRect, + mOrientationState.getOrientationHandler()); + } else { + mSizeStrategy.calculateTaskSize(mContext, mDp, mTaskRect); + } Rect fullTaskSize; if (mSplitBounds != null) { diff --git a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java index c9d6394fc8..9b585fcf8b 100644 --- a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java +++ b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java @@ -93,6 +93,7 @@ public class OverviewActionsView extends FrameLayo @Nullable protected DeviceProfile mDp; + private final Rect mTaskSize = new Rect(); public OverviewActionsView(Context context) { this(context, null); @@ -239,15 +240,16 @@ public class OverviewActionsView extends FrameLayo } // Align to bottom of task Rect. - return mDp.heightPx - mDp.overviewTaskRect.bottom - mDp.overviewActionsTopMarginPx + return mDp.heightPx - mTaskSize.bottom - mDp.overviewActionsTopMarginPx - mDp.overviewActionsHeight; } /** - * Updates device profile for this view to draw with. + * Updates device profile and task size for this view to draw with. */ - public void updateDimension(DeviceProfile dp) { + public void updateDimension(DeviceProfile dp, Rect taskSize) { mDp = dp; + mTaskSize.set(taskSize); updateVerticalMargin(DisplayController.getNavigationMode(getContext())); requestLayout(); diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index c657957ce9..583d0970a7 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -428,6 +428,9 @@ public abstract class RecentsView= 0) { taskView = getTaskViewAt(--targetPage); } - DeviceProfile dp = mActivity.getDeviceProfile(); - Rect gridTaskRect = dp.getOverviewGridTaskRect(mIsRtl); // Target a scroll where targetPage is on left of screen but still fully visible. - int lastTaskEnd = (mIsRtl ? dp.overviewGridRect.left : dp.overviewGridRect.right) + int lastTaskEnd = (mIsRtl + ? mLastComputedGridSize.left + : mLastComputedGridSize.right) + (mIsRtl ? mPageSpacing : -mPageSpacing); - int normalTaskEnd = mIsRtl ? gridTaskRect.left : gridTaskRect.right; + int normalTaskEnd = mIsRtl + ? mLastComputedGridTaskSize.left + : mLastComputedGridTaskSize.right; int targetScroll = getScrollForPage(targetPage) + normalTaskEnd - lastTaskEnd; // Find a page that is close to targetScroll while not over it. while (targetPage - 1 >= 0 diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java index d2b85f65c6..ded0ea620b 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/src/com/android/quickstep/views/TaskView.java @@ -1431,8 +1431,9 @@ public class TaskView extends FrameLayout implements Reusable { DeviceProfile deviceProfile = mActivity.getDeviceProfile(); if (deviceProfile.isTablet) { final int thumbnailPadding = deviceProfile.overviewTaskThumbnailTopMarginPx; - final int taskWidth = deviceProfile.overviewTaskRect.width(); - final int taskHeight = deviceProfile.overviewTaskRect.height(); + final Rect lastComputedTaskSize = getRecentsView().getLastComputedTaskSize(); + final int taskWidth = lastComputedTaskSize.width(); + final int taskHeight = lastComputedTaskSize.height(); int boxWidth; int boxHeight; @@ -1443,9 +1444,10 @@ public class TaskView extends FrameLayout implements Reusable { boxWidth = taskWidth; boxHeight = taskHeight; } else { - // Otherwise task is in grid. - boxWidth = deviceProfile.overviewGridTaskDimension.x; - boxHeight = deviceProfile.overviewGridTaskDimension.y; + // Otherwise task is in grid, and should use lastComputedGridTaskSize. + Rect lastComputedGridTaskSize = getRecentsView().getLastComputedGridTaskSize(); + boxWidth = lastComputedGridTaskSize.width(); + boxHeight = lastComputedGridTaskSize.height(); } // Bound width/height to the box size. diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfilePhone3ButtonTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfilePhone3ButtonTest.kt index 588e346a79..3daf81d8a6 100644 --- a/quickstep/tests/src/com/android/quickstep/DeviceProfilePhone3ButtonTest.kt +++ b/quickstep/tests/src/com/android/quickstep/DeviceProfilePhone3ButtonTest.kt @@ -483,114 +483,4 @@ class DeviceProfilePhone3ButtonTest : DeviceProfileBaseTest() { fun hotseatBarEndOffset() { assertThat(dp.hotseatBarEndOffset).isEqualTo(0) } - - @Test - fun overviewGridRectLeft() { - assertThat(dp.overviewGridRect.left).isEqualTo(0) - } - - @Test - fun overviewGridRectTop() { - assertThat(dp.overviewGridRect.top).isEqualTo(280) - } - - @Test - fun overviewGridRectRight() { - assertThat(dp.overviewGridRect.right).isEqualTo(1440) - } - - @Test - fun overviewGridRectBottom() { - assertThat(dp.overviewGridRect.bottom).isEqualTo(2768) - } - - @Test - fun taskDimensionX() { - assertThat(dp.taskDimension.x).isEqualTo(1440) - } - - @Test - fun taskDimensionY() { - assertThat(dp.taskDimension.y).isEqualTo(3120) - } - - @Test - fun overviewTaskRectLeft() { - assertThat(dp.overviewTaskRect.left).isEqualTo(231) - } - - @Test - fun overviewTaskRectTop() { - assertThat(dp.overviewTaskRect.top).isEqualTo(414) - } - - @Test - fun overviewTaskRectRight() { - assertThat(dp.overviewTaskRect.right).isEqualTo(1209) - } - - @Test - fun overviewTaskRectBottom() { - assertThat(dp.overviewTaskRect.bottom).isEqualTo(2533) - } - - @Test - fun overviewGridTaskDimensionX() { - assertThat(dp.overviewGridTaskDimension.x).isEqualTo(450) - } - - @Test - fun overviewGridTaskDimensionY() { - assertThat(dp.overviewGridTaskDimension.y).isEqualTo(976) - } - - @Test - fun overviewModalTaskRectLeft() { - assertThat(dp.overviewModalTaskRect.left).isEqualTo(182) - } - - @Test - fun overviewModalTaskRectTop() { - assertThat(dp.overviewModalTaskRect.top).isEqualTo(202) - } - - @Test - fun overviewModalTaskRectRight() { - assertThat(dp.overviewModalTaskRect.right).isEqualTo(1258) - } - - @Test - fun overviewModalTaskRectBottom() { - assertThat(dp.overviewModalTaskRect.bottom).isEqualTo(2533) - } - - @Test - fun getGridTaskRectLeft() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).left).isEqualTo(759) - } - - @Test - fun getGridTaskRectTop() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).top).isEqualTo(414) - } - - @Test - fun getGridTaskRectRight() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).right).isEqualTo(1209) - } - - @Test - fun getGridTaskRectBottom() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).bottom).isEqualTo(1390) - } - - @Test - fun overviewTaskScale() { - assertThat(dp.overviewTaskWorkspaceScale).isEqualTo(0.86595833f) - } - - @Test - fun overviewModalTaskScale() { - assertThat(dp.overviewModalTaskScale).isEqualTo(1.1000472f) - } } \ No newline at end of file diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfilePhoneTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfilePhoneTest.kt index f91d03d50c..e588c71277 100644 --- a/quickstep/tests/src/com/android/quickstep/DeviceProfilePhoneTest.kt +++ b/quickstep/tests/src/com/android/quickstep/DeviceProfilePhoneTest.kt @@ -483,114 +483,4 @@ class DeviceProfilePhoneTest : DeviceProfileBaseTest() { fun hotseatBarEndOffset() { assertThat(dp.hotseatBarEndOffset).isEqualTo(0) } - - @Test - fun overviewGridRectLeft() { - assertThat(dp.overviewGridRect.left).isEqualTo(0) - } - - @Test - fun overviewGridRectTop() { - assertThat(dp.overviewGridRect.top).isEqualTo(280) - } - - @Test - fun overviewGridRectRight() { - assertThat(dp.overviewGridRect.right).isEqualTo(1440) - } - - @Test - fun overviewGridRectBottom() { - assertThat(dp.overviewGridRect.bottom).isEqualTo(2768) - } - - @Test - fun taskDimensionX() { - assertThat(dp.taskDimension.x).isEqualTo(1440) - } - - @Test - fun taskDimensionY() { - assertThat(dp.taskDimension.y).isEqualTo(3120) - } - - @Test - fun overviewTaskRectLeft() { - assertThat(dp.overviewTaskRect.left).isEqualTo(231) - } - - @Test - fun overviewTaskRectTop() { - assertThat(dp.overviewTaskRect.top).isEqualTo(414) - } - - @Test - fun overviewTaskRectRight() { - assertThat(dp.overviewTaskRect.right).isEqualTo(1209) - } - - @Test - fun overviewTaskRectBottom() { - assertThat(dp.overviewTaskRect.bottom).isEqualTo(2533) - } - - @Test - fun overviewGridTaskDimensionX() { - assertThat(dp.overviewGridTaskDimension.x).isEqualTo(450) - } - - @Test - fun overviewGridTaskDimensionY() { - assertThat(dp.overviewGridTaskDimension.y).isEqualTo(976) - } - - @Test - fun overviewModalTaskRectLeft() { - assertThat(dp.overviewModalTaskRect.left).isEqualTo(182) - } - - @Test - fun overviewModalTaskRectTop() { - assertThat(dp.overviewModalTaskRect.top).isEqualTo(202) - } - - @Test - fun overviewModalTaskRectRight() { - assertThat(dp.overviewModalTaskRect.right).isEqualTo(1258) - } - - @Test - fun overviewModalTaskRectBottom() { - assertThat(dp.overviewModalTaskRect.bottom).isEqualTo(2533) - } - - @Test - fun getGridTaskRectLeft() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).left).isEqualTo(759) - } - - @Test - fun getGridTaskRectTop() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).top).isEqualTo(414) - } - - @Test - fun getGridTaskRectRight() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).right).isEqualTo(1209) - } - - @Test - fun getGridTaskRectBottom() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).bottom).isEqualTo(1390) - } - - @Test - fun overviewTaskScale() { - assertThat(dp.overviewTaskWorkspaceScale).isEqualTo(0.86595833f) - } - - @Test - fun overviewModalTaskScale() { - assertThat(dp.overviewModalTaskScale).isEqualTo(1.1000472f) - } } \ No newline at end of file diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscape3ButtonTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscape3ButtonTest.kt index 2d9e263a93..3f8d2fb13f 100644 --- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscape3ButtonTest.kt +++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscape3ButtonTest.kt @@ -483,114 +483,4 @@ class DeviceProfileTabletLandscape3ButtonTest : DeviceProfileBaseTest() { fun hotseatBarEndOffset() { assertThat(dp.hotseatBarEndOffset).isEqualTo(428) } - - @Test - fun overviewGridRectLeft() { - assertThat(dp.overviewGridRect.left).isEqualTo(128) - } - - @Test - fun overviewGridRectTop() { - assertThat(dp.overviewGridRect.top).isEqualTo(160) - } - - @Test - fun overviewGridRectRight() { - assertThat(dp.overviewGridRect.right).isEqualTo(2432) - } - - @Test - fun overviewGridRectBottom() { - assertThat(dp.overviewGridRect.bottom).isEqualTo(1340) - } - - @Test - fun taskDimensionX() { - assertThat(dp.taskDimension.x).isEqualTo(2560) - } - - @Test - fun taskDimensionY() { - assertThat(dp.taskDimension.y).isEqualTo(1480) - } - - @Test - fun overviewTaskRectLeft() { - assertThat(dp.overviewTaskRect.left).isEqualTo(384) - } - - @Test - fun overviewTaskRectTop() { - assertThat(dp.overviewTaskRect.top).isEqualTo(232) - } - - @Test - fun overviewTaskRectRight() { - assertThat(dp.overviewTaskRect.right).isEqualTo(2176) - } - - @Test - fun overviewTaskRectBottom() { - assertThat(dp.overviewTaskRect.bottom).isEqualTo(1268) - } - - @Test - fun overviewGridTaskDimensionX() { - assertThat(dp.overviewGridTaskDimension.x).isEqualTo(723) - } - - @Test - fun overviewGridTaskDimensionY() { - assertThat(dp.overviewGridTaskDimension.y).isEqualTo(418) - } - - @Test - fun overviewModalTaskRectLeft() { - assertThat(dp.overviewModalTaskRect.left).isEqualTo(294) - } - - @Test - fun overviewModalTaskRectTop() { - assertThat(dp.overviewModalTaskRect.top).isEqualTo(128) - } - - @Test - fun overviewModalTaskRectRight() { - assertThat(dp.overviewModalTaskRect.right).isEqualTo(2266) - } - - @Test - fun overviewModalTaskRectBottom() { - assertThat(dp.overviewModalTaskRect.bottom).isEqualTo(1268) - } - - @Test - fun getGridTaskRectLeft() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).left).isEqualTo(1453) - } - - @Test - fun getGridTaskRectTop() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).top).isEqualTo(232) - } - - @Test - fun getGridTaskRectRight() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).right).isEqualTo(2176) - } - - @Test - fun getGridTaskRectBottom() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).bottom).isEqualTo(650) - } - - @Test - fun overviewTaskScale() { - assertThat(dp.overviewTaskWorkspaceScale).isEqualTo(0.7363184f) - } - - @Test - fun overviewModalTaskScale() { - assertThat(dp.overviewModalTaskScale).isEqualTo(1.1003861f) - } } \ No newline at end of file diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscapeTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscapeTest.kt index 3add2c7269..456ed2cfc0 100644 --- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscapeTest.kt +++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscapeTest.kt @@ -483,114 +483,4 @@ class DeviceProfileTabletLandscapeTest : DeviceProfileBaseTest() { fun hotseatBarEndOffset() { assertThat(dp.hotseatBarEndOffset).isEqualTo(0) } - - @Test - fun overviewGridRectLeft() { - assertThat(dp.overviewGridRect.left).isEqualTo(128) - } - - @Test - fun overviewGridRectTop() { - assertThat(dp.overviewGridRect.top).isEqualTo(160) - } - - @Test - fun overviewGridRectRight() { - assertThat(dp.overviewGridRect.right).isEqualTo(2432) - } - - @Test - fun overviewGridRectBottom() { - assertThat(dp.overviewGridRect.bottom).isEqualTo(1416) - } - - @Test - fun taskDimensionX() { - assertThat(dp.taskDimension.x).isEqualTo(2560) - } - - @Test - fun taskDimensionY() { - assertThat(dp.taskDimension.y).isEqualTo(1480) - } - - @Test - fun overviewTaskRectLeft() { - assertThat(dp.overviewTaskRect.left).isEqualTo(384) - } - - @Test - fun overviewTaskRectTop() { - assertThat(dp.overviewTaskRect.top).isEqualTo(270) - } - - @Test - fun overviewTaskRectRight() { - assertThat(dp.overviewTaskRect.right).isEqualTo(2176) - } - - @Test - fun overviewTaskRectBottom() { - assertThat(dp.overviewTaskRect.bottom).isEqualTo(1306) - } - - @Test - fun overviewGridTaskDimensionX() { - assertThat(dp.overviewGridTaskDimension.x).isEqualTo(723) - } - - @Test - fun overviewGridTaskDimensionY() { - assertThat(dp.overviewGridTaskDimension.y).isEqualTo(418) - } - - @Test - fun overviewModalTaskRectLeft() { - assertThat(dp.overviewModalTaskRect.left).isEqualTo(294) - } - - @Test - fun overviewModalTaskRectTop() { - assertThat(dp.overviewModalTaskRect.top).isEqualTo(166) - } - - @Test - fun overviewModalTaskRectRight() { - assertThat(dp.overviewModalTaskRect.right).isEqualTo(2266) - } - - @Test - fun overviewModalTaskRectBottom() { - assertThat(dp.overviewModalTaskRect.bottom).isEqualTo(1306) - } - - @Test - fun getGridTaskRectLeft() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).left).isEqualTo(1453) - } - - @Test - fun getGridTaskRectTop() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).top).isEqualTo(270) - } - - @Test - fun getGridTaskRectRight() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).right).isEqualTo(2176) - } - - @Test - fun getGridTaskRectBottom() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).bottom).isEqualTo(688) - } - - @Test - fun overviewTaskScale() { - assertThat(dp.overviewTaskWorkspaceScale).isEqualTo(0.7363184f) - } - - @Test - fun overviewModalTaskScale() { - assertThat(dp.overviewModalTaskScale).isEqualTo(1.1003861f) - } } \ No newline at end of file diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortrait3ButtonTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortrait3ButtonTest.kt index 7f0d6ca022..b53b36a9d9 100644 --- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortrait3ButtonTest.kt +++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortrait3ButtonTest.kt @@ -483,114 +483,4 @@ class DeviceProfileTabletPortrait3ButtonTest : DeviceProfileBaseTest() { fun hotseatBarEndOffset() { assertThat(dp.hotseatBarEndOffset).isEqualTo(428) } - - @Test - fun overviewGridRectLeft() { - assertThat(dp.overviewGridRect.left).isEqualTo(128) - } - - @Test - fun overviewGridRectTop() { - assertThat(dp.overviewGridRect.top).isEqualTo(160) - } - - @Test - fun overviewGridRectRight() { - assertThat(dp.overviewGridRect.right).isEqualTo(1472) - } - - @Test - fun overviewGridRectBottom() { - assertThat(dp.overviewGridRect.bottom).isEqualTo(2292) - } - - @Test - fun taskDimensionX() { - assertThat(dp.taskDimension.x).isEqualTo(1600) - } - - @Test - fun taskDimensionY() { - assertThat(dp.taskDimension.y).isEqualTo(2440) - } - - @Test - fun overviewTaskRectLeft() { - assertThat(dp.overviewTaskRect.left).isEqualTo(240) - } - - @Test - fun overviewTaskRectTop() { - assertThat(dp.overviewTaskRect.top).isEqualTo(372) - } - - @Test - fun overviewTaskRectRight() { - assertThat(dp.overviewTaskRect.right).isEqualTo(1360) - } - - @Test - fun overviewTaskRectBottom() { - assertThat(dp.overviewTaskRect.bottom).isEqualTo(2080) - } - - @Test - fun overviewGridTaskDimensionX() { - assertThat(dp.overviewGridTaskDimension.x).isEqualTo(494) - } - - @Test - fun overviewGridTaskDimensionY() { - assertThat(dp.overviewGridTaskDimension.y).isEqualTo(754) - } - - @Test - fun overviewModalTaskRectLeft() { - assertThat(dp.overviewModalTaskRect.left).isEqualTo(184) - } - - @Test - fun overviewModalTaskRectTop() { - assertThat(dp.overviewModalTaskRect.top).isEqualTo(201) - } - - @Test - fun overviewModalTaskRectRight() { - assertThat(dp.overviewModalTaskRect.right).isEqualTo(1416) - } - - @Test - fun overviewModalTaskRectBottom() { - assertThat(dp.overviewModalTaskRect.bottom).isEqualTo(2080) - } - - @Test - fun getGridTaskRectLeft() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).left).isEqualTo(866) - } - - @Test - fun getGridTaskRectTop() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).top).isEqualTo(372) - } - - @Test - fun getGridTaskRectRight() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).right).isEqualTo(1360) - } - - @Test - fun getGridTaskRectBottom() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).bottom).isEqualTo(1126) - } - - @Test - fun overviewTaskScale() { - assertThat(dp.overviewTaskWorkspaceScale).isEqualTo(0.7686769f) - } - - @Test - fun overviewModalTaskScale() { - assertThat(dp.overviewModalTaskScale).isEqualTo(1.1f) - } } \ No newline at end of file diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortraitTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortraitTest.kt index 1a709e6f7a..4be3e45dce 100644 --- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortraitTest.kt +++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortraitTest.kt @@ -483,114 +483,4 @@ class DeviceProfileTabletPortraitTest : DeviceProfileBaseTest() { fun hotseatBarEndOffset() { assertThat(dp.hotseatBarEndOffset).isEqualTo(0) } - - @Test - fun overviewGridRectLeft() { - assertThat(dp.overviewGridRect.left).isEqualTo(128) - } - - @Test - fun overviewGridRectTop() { - assertThat(dp.overviewGridRect.top).isEqualTo(160) - } - - @Test - fun overviewGridRectRight() { - assertThat(dp.overviewGridRect.right).isEqualTo(1472) - } - - @Test - fun overviewGridRectBottom() { - assertThat(dp.overviewGridRect.bottom).isEqualTo(2368) - } - - @Test - fun taskDimensionX() { - assertThat(dp.taskDimension.x).isEqualTo(1600) - } - - @Test - fun taskDimensionY() { - assertThat(dp.taskDimension.y).isEqualTo(2440) - } - - @Test - fun overviewTaskRectLeft() { - assertThat(dp.overviewTaskRect.left).isEqualTo(240) - } - - @Test - fun overviewTaskRectTop() { - assertThat(dp.overviewTaskRect.top).isEqualTo(410) - } - - @Test - fun overviewTaskRectRight() { - assertThat(dp.overviewTaskRect.right).isEqualTo(1360) - } - - @Test - fun overviewTaskRectBottom() { - assertThat(dp.overviewTaskRect.bottom).isEqualTo(2118) - } - - @Test - fun overviewGridTaskDimensionX() { - assertThat(dp.overviewGridTaskDimension.x).isEqualTo(494) - } - - @Test - fun overviewGridTaskDimensionY() { - assertThat(dp.overviewGridTaskDimension.y).isEqualTo(754) - } - - @Test - fun overviewModalTaskRectLeft() { - assertThat(dp.overviewModalTaskRect.left).isEqualTo(184) - } - - @Test - fun overviewModalTaskRectTop() { - assertThat(dp.overviewModalTaskRect.top).isEqualTo(239) - } - - @Test - fun overviewModalTaskRectRight() { - assertThat(dp.overviewModalTaskRect.right).isEqualTo(1416) - } - - @Test - fun overviewModalTaskRectBottom() { - assertThat(dp.overviewModalTaskRect.bottom).isEqualTo(2118) - } - - @Test - fun getGridTaskRectLeft() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).left).isEqualTo(866) - } - - @Test - fun getGridTaskRectTop() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).top).isEqualTo(410) - } - - @Test - fun getGridTaskRectRight() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).right).isEqualTo(1360) - } - - @Test - fun getGridTaskRectBottom() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).bottom).isEqualTo(1164) - } - - @Test - fun overviewTaskScale() { - assertThat(dp.overviewTaskWorkspaceScale).isEqualTo(0.7686769f) - } - - @Test - fun overviewModalTaskScale() { - assertThat(dp.overviewModalTaskScale).isEqualTo(1.1f) - } } \ No newline at end of file diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscape3ButtonTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscape3ButtonTest.kt index 0eeb23dede..274ca95405 100644 --- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscape3ButtonTest.kt +++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscape3ButtonTest.kt @@ -483,114 +483,4 @@ class DeviceProfileTwoPanelLandscape3ButtonTest : DeviceProfileBaseTest() { fun hotseatBarEndOffset() { assertThat(dp.hotseatBarEndOffset).isEqualTo(428) } - - @Test - fun overviewGridRectLeft() { - assertThat(dp.overviewGridRect.left).isEqualTo(128) - } - - @Test - fun overviewGridRectTop() { - assertThat(dp.overviewGridRect.top).isEqualTo(160) - } - - @Test - fun overviewGridRectRight() { - assertThat(dp.overviewGridRect.right).isEqualTo(2432) - } - - @Test - fun overviewGridRectBottom() { - assertThat(dp.overviewGridRect.bottom).isEqualTo(1340) - } - - @Test - fun taskDimensionX() { - assertThat(dp.taskDimension.x).isEqualTo(2560) - } - - @Test - fun taskDimensionY() { - assertThat(dp.taskDimension.y).isEqualTo(1480) - } - - @Test - fun overviewTaskRectLeft() { - assertThat(dp.overviewTaskRect.left).isEqualTo(384) - } - - @Test - fun overviewTaskRectTop() { - assertThat(dp.overviewTaskRect.top).isEqualTo(232) - } - - @Test - fun overviewTaskRectRight() { - assertThat(dp.overviewTaskRect.right).isEqualTo(2176) - } - - @Test - fun overviewTaskRectBottom() { - assertThat(dp.overviewTaskRect.bottom).isEqualTo(1268) - } - - @Test - fun overviewGridTaskDimensionX() { - assertThat(dp.overviewGridTaskDimension.x).isEqualTo(723) - } - - @Test - fun overviewGridTaskDimensionY() { - assertThat(dp.overviewGridTaskDimension.y).isEqualTo(418) - } - - @Test - fun overviewModalTaskRectLeft() { - assertThat(dp.overviewModalTaskRect.left).isEqualTo(294) - } - - @Test - fun overviewModalTaskRectTop() { - assertThat(dp.overviewModalTaskRect.top).isEqualTo(128) - } - - @Test - fun overviewModalTaskRectRight() { - assertThat(dp.overviewModalTaskRect.right).isEqualTo(2266) - } - - @Test - fun overviewModalTaskRectBottom() { - assertThat(dp.overviewModalTaskRect.bottom).isEqualTo(1268) - } - - @Test - fun getGridTaskRectLeft() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).left).isEqualTo(1453) - } - - @Test - fun getGridTaskRectTop() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).top).isEqualTo(232) - } - - @Test - fun getGridTaskRectRight() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).right).isEqualTo(2176) - } - - @Test - fun getGridTaskRectBottom() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).bottom).isEqualTo(650) - } - - @Test - fun overviewTaskScale() { - assertThat(dp.overviewTaskWorkspaceScale).isEqualTo(0.8526749f) - } - - @Test - fun overviewModalTaskScale() { - assertThat(dp.overviewModalTaskScale).isEqualTo(1.1003861f) - } } \ No newline at end of file diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscapeTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscapeTest.kt index 7bf53d7453..ba3ef55e3c 100644 --- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscapeTest.kt +++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscapeTest.kt @@ -483,114 +483,4 @@ class DeviceProfileTwoPanelLandscapeTest : DeviceProfileBaseTest() { fun hotseatBarEndOffset() { assertThat(dp.hotseatBarEndOffset).isEqualTo(0) } - - @Test - fun overviewGridRectLeft() { - assertThat(dp.overviewGridRect.left).isEqualTo(128) - } - - @Test - fun overviewGridRectTop() { - assertThat(dp.overviewGridRect.top).isEqualTo(160) - } - - @Test - fun overviewGridRectRight() { - assertThat(dp.overviewGridRect.right).isEqualTo(2432) - } - - @Test - fun overviewGridRectBottom() { - assertThat(dp.overviewGridRect.bottom).isEqualTo(1416) - } - - @Test - fun taskDimensionX() { - assertThat(dp.taskDimension.x).isEqualTo(2560) - } - - @Test - fun taskDimensionY() { - assertThat(dp.taskDimension.y).isEqualTo(1480) - } - - @Test - fun overviewTaskRectLeft() { - assertThat(dp.overviewTaskRect.left).isEqualTo(384) - } - - @Test - fun overviewTaskRectTop() { - assertThat(dp.overviewTaskRect.top).isEqualTo(270) - } - - @Test - fun overviewTaskRectRight() { - assertThat(dp.overviewTaskRect.right).isEqualTo(2176) - } - - @Test - fun overviewTaskRectBottom() { - assertThat(dp.overviewTaskRect.bottom).isEqualTo(1306) - } - - @Test - fun overviewGridTaskDimensionX() { - assertThat(dp.overviewGridTaskDimension.x).isEqualTo(723) - } - - @Test - fun overviewGridTaskDimensionY() { - assertThat(dp.overviewGridTaskDimension.y).isEqualTo(418) - } - - @Test - fun overviewModalTaskRectLeft() { - assertThat(dp.overviewModalTaskRect.left).isEqualTo(294) - } - - @Test - fun overviewModalTaskRectTop() { - assertThat(dp.overviewModalTaskRect.top).isEqualTo(166) - } - - @Test - fun overviewModalTaskRectRight() { - assertThat(dp.overviewModalTaskRect.right).isEqualTo(2266) - } - - @Test - fun overviewModalTaskRectBottom() { - assertThat(dp.overviewModalTaskRect.bottom).isEqualTo(1306) - } - - @Test - fun getGridTaskRectLeft() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).left).isEqualTo(1453) - } - - @Test - fun getGridTaskRectTop() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).top).isEqualTo(270) - } - - @Test - fun getGridTaskRectRight() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).right).isEqualTo(2176) - } - - @Test - fun getGridTaskRectBottom() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).bottom).isEqualTo(688) - } - - @Test - fun overviewTaskScale() { - assertThat(dp.overviewTaskWorkspaceScale).isEqualTo(0.8526749f) - } - - @Test - fun overviewModalTaskScale() { - assertThat(dp.overviewModalTaskScale).isEqualTo(1.1003861f) - } } \ No newline at end of file diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortrait3ButtonTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortrait3ButtonTest.kt index 9b6d7d55f2..7dd95f99f6 100644 --- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortrait3ButtonTest.kt +++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortrait3ButtonTest.kt @@ -483,114 +483,4 @@ class DeviceProfileTwoPanelPortrait3ButtonTest : DeviceProfileBaseTest() { fun hotseatBarEndOffset() { assertThat(dp.hotseatBarEndOffset).isEqualTo(428) } - - @Test - fun overviewGridRectLeft() { - assertThat(dp.overviewGridRect.left).isEqualTo(128) - } - - @Test - fun overviewGridRectTop() { - assertThat(dp.overviewGridRect.top).isEqualTo(160) - } - - @Test - fun overviewGridRectRight() { - assertThat(dp.overviewGridRect.right).isEqualTo(1472) - } - - @Test - fun overviewGridRectBottom() { - assertThat(dp.overviewGridRect.bottom).isEqualTo(2292) - } - - @Test - fun taskDimensionX() { - assertThat(dp.taskDimension.x).isEqualTo(1600) - } - - @Test - fun taskDimensionY() { - assertThat(dp.taskDimension.y).isEqualTo(2440) - } - - @Test - fun overviewTaskRectLeft() { - assertThat(dp.overviewTaskRect.left).isEqualTo(240) - } - - @Test - fun overviewTaskRectTop() { - assertThat(dp.overviewTaskRect.top).isEqualTo(372) - } - - @Test - fun overviewTaskRectRight() { - assertThat(dp.overviewTaskRect.right).isEqualTo(1360) - } - - @Test - fun overviewTaskRectBottom() { - assertThat(dp.overviewTaskRect.bottom).isEqualTo(2080) - } - - @Test - fun overviewGridTaskDimensionX() { - assertThat(dp.overviewGridTaskDimension.x).isEqualTo(494) - } - - @Test - fun overviewGridTaskDimensionY() { - assertThat(dp.overviewGridTaskDimension.y).isEqualTo(754) - } - - @Test - fun overviewModalTaskRectLeft() { - assertThat(dp.overviewModalTaskRect.left).isEqualTo(184) - } - - @Test - fun overviewModalTaskRectTop() { - assertThat(dp.overviewModalTaskRect.top).isEqualTo(201) - } - - @Test - fun overviewModalTaskRectRight() { - assertThat(dp.overviewModalTaskRect.right).isEqualTo(1416) - } - - @Test - fun overviewModalTaskRectBottom() { - assertThat(dp.overviewModalTaskRect.bottom).isEqualTo(2080) - } - - @Test - fun getGridTaskRectLeft() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).left).isEqualTo(866) - } - - @Test - fun getGridTaskRectTop() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).top).isEqualTo(372) - } - - @Test - fun getGridTaskRectRight() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).right).isEqualTo(1360) - } - - @Test - fun getGridTaskRectBottom() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).bottom).isEqualTo(1126) - } - - @Test - fun overviewTaskScale() { - assertThat(dp.overviewTaskWorkspaceScale).isEqualTo(0.7874597f) - } - - @Test - fun overviewModalTaskScale() { - assertThat(dp.overviewModalTaskScale).isEqualTo(1.1f) - } } \ No newline at end of file diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortraitTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortraitTest.kt index 6702eb5d46..0c5968e1ef 100644 --- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortraitTest.kt +++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortraitTest.kt @@ -483,114 +483,4 @@ class DeviceProfileTwoPanelPortraitTest : DeviceProfileBaseTest() { fun hotseatBarEndOffset() { assertThat(dp.hotseatBarEndOffset).isEqualTo(0) } - - @Test - fun overviewGridRectLeft() { - assertThat(dp.overviewGridRect.left).isEqualTo(128) - } - - @Test - fun overviewGridRectTop() { - assertThat(dp.overviewGridRect.top).isEqualTo(160) - } - - @Test - fun overviewGridRectRight() { - assertThat(dp.overviewGridRect.right).isEqualTo(1472) - } - - @Test - fun overviewGridRectBottom() { - assertThat(dp.overviewGridRect.bottom).isEqualTo(2368) - } - - @Test - fun taskDimensionX() { - assertThat(dp.taskDimension.x).isEqualTo(1600) - } - - @Test - fun taskDimensionY() { - assertThat(dp.taskDimension.y).isEqualTo(2440) - } - - @Test - fun overviewTaskRectLeft() { - assertThat(dp.overviewTaskRect.left).isEqualTo(240) - } - - @Test - fun overviewTaskRectTop() { - assertThat(dp.overviewTaskRect.top).isEqualTo(410) - } - - @Test - fun overviewTaskRectRight() { - assertThat(dp.overviewTaskRect.right).isEqualTo(1360) - } - - @Test - fun overviewTaskRectBottom() { - assertThat(dp.overviewTaskRect.bottom).isEqualTo(2118) - } - - @Test - fun overviewGridTaskDimensionX() { - assertThat(dp.overviewGridTaskDimension.x).isEqualTo(494) - } - - @Test - fun overviewGridTaskDimensionY() { - assertThat(dp.overviewGridTaskDimension.y).isEqualTo(754) - } - - @Test - fun overviewModalTaskRectLeft() { - assertThat(dp.overviewModalTaskRect.left).isEqualTo(184) - } - - @Test - fun overviewModalTaskRectTop() { - assertThat(dp.overviewModalTaskRect.top).isEqualTo(239) - } - - @Test - fun overviewModalTaskRectRight() { - assertThat(dp.overviewModalTaskRect.right).isEqualTo(1416) - } - - @Test - fun overviewModalTaskRectBottom() { - assertThat(dp.overviewModalTaskRect.bottom).isEqualTo(2118) - } - - @Test - fun getGridTaskRectLeft() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).left).isEqualTo(866) - } - - @Test - fun getGridTaskRectTop() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).top).isEqualTo(410) - } - - @Test - fun getGridTaskRectRight() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).right).isEqualTo(1360) - } - - @Test - fun getGridTaskRectBottom() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).bottom).isEqualTo(1164) - } - - @Test - fun overviewTaskScale() { - assertThat(dp.overviewTaskWorkspaceScale).isEqualTo(0.7874597f) - } - - @Test - fun overviewModalTaskScale() { - assertThat(dp.overviewModalTaskScale).isEqualTo(1.1f) - } } \ No newline at end of file diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileVerticalBar3ButtonTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileVerticalBar3ButtonTest.kt index 7e0c5f3b9b..2bad6bb20b 100644 --- a/quickstep/tests/src/com/android/quickstep/DeviceProfileVerticalBar3ButtonTest.kt +++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileVerticalBar3ButtonTest.kt @@ -483,114 +483,4 @@ class DeviceProfileVerticalBar3ButtonTest : DeviceProfileBaseTest() { fun hotseatBarEndOffset() { assertThat(dp.hotseatBarEndOffset).isEqualTo(0) } - - @Test - fun overviewGridRectLeft() { - assertThat(dp.overviewGridRect.left).isEqualTo(0) - } - - @Test - fun overviewGridRectTop() { - assertThat(dp.overviewGridRect.top).isEqualTo(280) - } - - @Test - fun overviewGridRectRight() { - assertThat(dp.overviewGridRect.right).isEqualTo(3120) - } - - @Test - fun overviewGridRectBottom() { - assertThat(dp.overviewGridRect.bottom).isEqualTo(1130) - } - - @Test - fun taskDimensionX() { - assertThat(dp.taskDimension.x).isEqualTo(3120) - } - - @Test - fun taskDimensionY() { - assertThat(dp.taskDimension.y).isEqualTo(1440) - } - - @Test - fun overviewTaskRectLeft() { - assertThat(dp.overviewTaskRect.left).isEqualTo(747) - } - - @Test - fun overviewTaskRectTop() { - assertThat(dp.overviewTaskRect.top).isEqualTo(280) - } - - @Test - fun overviewTaskRectRight() { - assertThat(dp.overviewTaskRect.right).isEqualTo(2372) - } - - @Test - fun overviewTaskRectBottom() { - assertThat(dp.overviewTaskRect.bottom).isEqualTo(1030) - } - - @Test - fun overviewGridTaskDimensionX() { - assertThat(dp.overviewGridTaskDimension.x).isEqualTo(631) - } - - @Test - fun overviewGridTaskDimensionY() { - assertThat(dp.overviewGridTaskDimension.y).isEqualTo(291) - } - - @Test - fun overviewModalTaskRectLeft() { - assertThat(dp.overviewModalTaskRect.left).isEqualTo(666) - } - - @Test - fun overviewModalTaskRectTop() { - assertThat(dp.overviewModalTaskRect.top).isEqualTo(205) - } - - @Test - fun overviewModalTaskRectRight() { - assertThat(dp.overviewModalTaskRect.right).isEqualTo(2454) - } - - @Test - fun overviewModalTaskRectBottom() { - assertThat(dp.overviewModalTaskRect.bottom).isEqualTo(1030) - } - - @Test - fun getGridTaskRectLeft() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).left).isEqualTo(1741) - } - - @Test - fun getGridTaskRectTop() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).top).isEqualTo(280) - } - - @Test - fun getGridTaskRectRight() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).right).isEqualTo(2372) - } - - @Test - fun getGridTaskRectBottom() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).bottom).isEqualTo(571) - } - - @Test - fun overviewTaskScale() { - assertThat(dp.overviewTaskWorkspaceScale).isEqualTo(0.5597015f) - } - - @Test - fun overviewModalTaskScale() { - assertThat(dp.overviewModalTaskScale).isEqualTo(1.1f) - } } \ No newline at end of file diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileVerticalBarTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileVerticalBarTest.kt index 9580458a13..6256a43f75 100644 --- a/quickstep/tests/src/com/android/quickstep/DeviceProfileVerticalBarTest.kt +++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileVerticalBarTest.kt @@ -483,114 +483,4 @@ class DeviceProfileVerticalBarTest : DeviceProfileBaseTest() { fun hotseatBarEndOffset() { assertThat(dp.hotseatBarEndOffset).isEqualTo(0) } - - @Test - fun overviewGridRectLeft() { - assertThat(dp.overviewGridRect.left).isEqualTo(0) - } - - @Test - fun overviewGridRectTop() { - assertThat(dp.overviewGridRect.top).isEqualTo(280) - } - - @Test - fun overviewGridRectRight() { - assertThat(dp.overviewGridRect.right).isEqualTo(3120) - } - - @Test - fun overviewGridRectBottom() { - assertThat(dp.overviewGridRect.bottom).isEqualTo(1130) - } - - @Test - fun taskDimensionX() { - assertThat(dp.taskDimension.x).isEqualTo(3120) - } - - @Test - fun taskDimensionY() { - assertThat(dp.taskDimension.y).isEqualTo(1440) - } - - @Test - fun overviewTaskRectLeft() { - assertThat(dp.overviewTaskRect.left).isEqualTo(747) - } - - @Test - fun overviewTaskRectTop() { - assertThat(dp.overviewTaskRect.top).isEqualTo(280) - } - - @Test - fun overviewTaskRectRight() { - assertThat(dp.overviewTaskRect.right).isEqualTo(2372) - } - - @Test - fun overviewTaskRectBottom() { - assertThat(dp.overviewTaskRect.bottom).isEqualTo(1030) - } - - @Test - fun overviewGridTaskDimensionX() { - assertThat(dp.overviewGridTaskDimension.x).isEqualTo(631) - } - - @Test - fun overviewGridTaskDimensionY() { - assertThat(dp.overviewGridTaskDimension.y).isEqualTo(291) - } - - @Test - fun overviewModalTaskRectLeft() { - assertThat(dp.overviewModalTaskRect.left).isEqualTo(666) - } - - @Test - fun overviewModalTaskRectTop() { - assertThat(dp.overviewModalTaskRect.top).isEqualTo(205) - } - - @Test - fun overviewModalTaskRectRight() { - assertThat(dp.overviewModalTaskRect.right).isEqualTo(2454) - } - - @Test - fun overviewModalTaskRectBottom() { - assertThat(dp.overviewModalTaskRect.bottom).isEqualTo(1030) - } - - @Test - fun getGridTaskRectLeft() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).left).isEqualTo(1741) - } - - @Test - fun getGridTaskRectTop() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).top).isEqualTo(280) - } - - @Test - fun getGridTaskRectRight() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).right).isEqualTo(2372) - } - - @Test - fun getGridTaskRectBottom() { - assertThat(dp.getOverviewGridTaskRect(isRecentsRtl).bottom).isEqualTo(571) - } - - @Test - fun overviewTaskScale() { - assertThat(dp.overviewTaskWorkspaceScale).isEqualTo(0.5597015f) - } - - @Test - fun overviewModalTaskScale() { - assertThat(dp.overviewModalTaskScale).isEqualTo(1.1f) - } } \ No newline at end of file diff --git a/res/values/dimens.xml b/res/values/dimens.xml index caa7da0da3..d095ae3b4a 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -383,9 +383,6 @@ 0dp 0dp 0dp - 0dp - 0.0 - 0.0 72dp 16dp 44dp diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index d09642a225..adf621653f 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -34,7 +34,6 @@ import android.graphics.Point; import android.graphics.PointF; import android.graphics.Rect; import android.util.DisplayMetrics; -import android.view.Gravity; import android.view.Surface; import com.android.launcher3.CellLayout.ContainerType; @@ -42,7 +41,6 @@ import com.android.launcher3.DevicePaddings.DevicePadding; import com.android.launcher3.icons.DotRenderer; import com.android.launcher3.icons.GraphicsUtils; import com.android.launcher3.icons.IconNormalizer; -import com.android.launcher3.touch.PortraitPagedViewHandler; import com.android.launcher3.uioverrides.ApiWrapper; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.DisplayController.Info; @@ -204,12 +202,6 @@ public class DeviceProfile { public int overviewPageSpacing; public int overviewRowSpacing; public int overviewGridSideMargin; - public final Rect overviewGridRect = new Rect(); - public final Rect overviewTaskRect = new Rect(); - public final float overviewTaskWorkspaceScale; - public final Point overviewGridTaskDimension = new Point(); - public final Rect overviewModalTaskRect = new Rect(); - public final float overviewModalTaskScale; // Widgets public final PointF appWidgetScale = new PointF(1.0f, 1.0f); @@ -236,9 +228,6 @@ public class DeviceProfile { public DotRenderer mDotRendererWorkSpace; public DotRenderer mDotRendererAllApps; - // Tasks - public final PointF taskDimension = new PointF(); - // Taskbar public boolean isTaskbarPresent; // Whether Taskbar will inset the bottom of apps by taskbarSize. @@ -492,104 +481,6 @@ public class DeviceProfile { mDotRendererWorkSpace = new DotRenderer(iconSizePx, dotPath, DEFAULT_DOT_SIZE); mDotRendererAllApps = iconSizePx == allAppsIconSizePx ? mDotRendererWorkSpace : new DotRenderer(allAppsIconSizePx, dotPath, DEFAULT_DOT_SIZE); - - // Grid and Task size calculations - calculateGridSize(); - getTaskDimension(); - calculateTaskSize(res); - calculateGridTaskSize(); - calculateModalTaskSize(res); - overviewModalTaskScale = - Math.min(overviewModalTaskRect.height() / (float) overviewTaskRect.height(), - overviewModalTaskRect.width() / (float) overviewTaskRect.width()); - overviewTaskWorkspaceScale = (float) overviewTaskRect.height() / getCellLayoutHeight(); - } - - private void calculateGridSize() { - int topMargin = overviewTaskThumbnailTopMarginPx; - int bottomMargin = getOverviewActionsClaimedSpace(); - int sideMargin = overviewGridSideMargin; - - overviewGridRect.set(0, 0, widthPx, heightPx); - overviewGridRect.inset(Math.max(mInsets.left, sideMargin), mInsets.top + topMargin, - Math.max(mInsets.right, sideMargin), Math.max(mInsets.bottom, bottomMargin)); - } - - private void calculateTaskSize(Resources res) { - int overviewMinNextPrevSize = - res.getDimensionPixelSize(R.dimen.overview_minimum_next_prev_size); - float overviewMaxScale = res.getFloat(R.dimen.overview_max_scale); - Rect containerRect = new Rect(); - if (isTablet) { - containerRect.set(overviewGridRect); - } else { - int taskMargin = overviewTaskMarginPx; - containerRect.set(0, 0, widthPx, heightPx); - containerRect.inset(mInsets.left, mInsets.top, mInsets.right, mInsets.bottom); - int minimumHorizontalPadding = overviewMinNextPrevSize + taskMargin; - containerRect.inset(minimumHorizontalPadding, overviewTaskThumbnailTopMarginPx, - minimumHorizontalPadding, getOverviewActionsClaimedSpace()); - } - float scale = Math.min( - containerRect.width() / taskDimension.x, - containerRect.height() / taskDimension.y); - scale = Math.min(scale, overviewMaxScale); - int outWidth = Math.round(scale * taskDimension.x); - int outHeight = Math.round(scale * taskDimension.y); - Gravity.apply(Gravity.CENTER, outWidth, outHeight, containerRect, overviewTaskRect); - } - - private void calculateGridTaskSize() { - float rowHeight = - (overviewTaskRect.height() + overviewTaskThumbnailTopMarginPx - overviewRowSpacing) - / 2f; - - float scale = (rowHeight - overviewTaskThumbnailTopMarginPx) / taskDimension.y; - overviewGridTaskDimension.set( - Math.round(scale * taskDimension.x), Math.round(scale * taskDimension.y)); - } - - /** - * Returns a Rect the size of a grid task with the correct positioning within the screen. - * - * @param isRecentsRtl is true when device is in LTR, false when in RTL, as grid tasks are only - * supported on tablets, which use PortraitPagedViewHandler. - */ - public Rect getOverviewGridTaskRect(boolean isRecentsRtl) { - Rect outRect = new Rect(); - int gravity = Gravity.TOP; - gravity |= isRecentsRtl ? Gravity.RIGHT : Gravity.LEFT; - Gravity.apply(gravity, overviewGridTaskDimension.x, overviewGridTaskDimension.y, - overviewTaskRect, outRect); - return outRect; - } - - private void calculateModalTaskSize(Resources res) { - float overviewModalMaxScale = res.getFloat(R.dimen.overview_modal_max_scale); - Rect potentialTaskRect = new Rect(0, 0, widthPx, heightPx); - potentialTaskRect.inset(mInsets.left, mInsets.top, mInsets.right, mInsets.bottom); - int minimumHorizontalPadding = Math.round( - (availableWidthPx - overviewTaskRect.width() * overviewModalMaxScale) / 2); - potentialTaskRect.inset( - minimumHorizontalPadding, - overviewTaskMarginPx, - minimumHorizontalPadding, - heightPx - overviewTaskRect.bottom - mInsets.bottom); - float scale = Math.min( - potentialTaskRect.width() / taskDimension.x, - potentialTaskRect.height() / taskDimension.y); - int outWidth = Math.round(scale * taskDimension.x); - int outHeight = Math.round(scale * taskDimension.y); - Gravity.apply(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM, outWidth, outHeight, - potentialTaskRect, overviewModalTaskRect); - } - - private void getTaskDimension() { - float taskHeight = heightPx; - if (isTablet) { - taskHeight -= taskbarSize; - } - taskDimension.set(widthPx, taskHeight); } /** @@ -1354,8 +1245,7 @@ public class DeviceProfile { } // LINT.IfChange - /** Dumps various DeviceProfile variables to the specified writer. */ - public void dump(Context context, String prefix, PrintWriter writer) { + public void dump(String prefix, PrintWriter writer) { writer.println(prefix + "DeviceProfile:"); writer.println(prefix + "\t1 dp = " + mMetrics.density + " px"); @@ -1401,12 +1291,9 @@ public class DeviceProfile { cellLayoutBorderSpacePx.x)); writer.println(prefix + pxToDpStr("cellLayoutBorderSpacePx Vertical", cellLayoutBorderSpacePx.y)); - writer.println( - prefix + pxToDpStr("cellLayoutPaddingPx.left", cellLayoutPaddingPx.left)); - writer.println( - prefix + pxToDpStr("cellLayoutPaddingPx.top", cellLayoutPaddingPx.top)); - writer.println( - prefix + pxToDpStr("cellLayoutPaddingPx.right", cellLayoutPaddingPx.right)); + writer.println(prefix + pxToDpStr("cellLayoutPaddingPx.left", cellLayoutPaddingPx.left)); + writer.println(prefix + pxToDpStr("cellLayoutPaddingPx.top", cellLayoutPaddingPx.top)); + writer.println(prefix + pxToDpStr("cellLayoutPaddingPx.right", cellLayoutPaddingPx.right)); writer.println( prefix + pxToDpStr("cellLayoutPaddingPx.bottom", cellLayoutPaddingPx.bottom)); @@ -1440,15 +1327,13 @@ public class DeviceProfile { writer.println(prefix + pxToDpStr("allAppsBorderSpacePxX", allAppsBorderSpacePx.x)); writer.println(prefix + pxToDpStr("allAppsBorderSpacePxY", allAppsBorderSpacePx.y)); writer.println(prefix + "\tnumShownAllAppsColumns: " + numShownAllAppsColumns); - writer.println( - prefix + pxToDpStr("allAppsLeftRightPadding", allAppsLeftRightPadding)); + writer.println(prefix + pxToDpStr("allAppsLeftRightPadding", allAppsLeftRightPadding)); writer.println(prefix + pxToDpStr("allAppsLeftRightMargin", allAppsLeftRightMargin)); writer.println(prefix + pxToDpStr("hotseatBarSizePx", hotseatBarSizePx)); writer.println(prefix + "\tinv.hotseatColumnSpan: " + inv.hotseatColumnSpan[mTypeIndex]); writer.println(prefix + pxToDpStr("hotseatCellHeightPx", hotseatCellHeightPx)); - writer.println( - prefix + pxToDpStr("hotseatBarBottomSpacePx", hotseatBarBottomSpacePx)); + writer.println(prefix + pxToDpStr("hotseatBarBottomSpacePx", hotseatBarBottomSpacePx)); writer.println(prefix + pxToDpStr("hotseatBarSidePaddingStartPx", hotseatBarSidePaddingStartPx)); writer.println(prefix + pxToDpStr("hotseatBarSidePaddingEndPx", @@ -1459,12 +1344,9 @@ public class DeviceProfile { writer.println(prefix + pxToDpStr("springLoadedHotseatBarTopMarginPx", springLoadedHotseatBarTopMarginPx)); writer.println(prefix + pxToDpStr("mHotseatBarPadding.top", mHotseatBarPadding.top)); - writer.println( - prefix + pxToDpStr("mHotseatBarPadding.bottom", mHotseatBarPadding.bottom)); - writer.println( - prefix + pxToDpStr("mHotseatBarPadding.left", mHotseatBarPadding.left)); - writer.println( - prefix + pxToDpStr("mHotseatBarPadding.right", mHotseatBarPadding.right)); + writer.println(prefix + pxToDpStr("mHotseatBarPadding.bottom", mHotseatBarPadding.bottom)); + writer.println(prefix + pxToDpStr("mHotseatBarPadding.left", mHotseatBarPadding.left)); + writer.println(prefix + pxToDpStr("mHotseatBarPadding.right", mHotseatBarPadding.right)); writer.println(prefix + "\tnumShownHotseatIcons: " + numShownHotseatIcons); writer.println(prefix + pxToDpStr("hotseatBorderSpace", hotseatBorderSpace)); writer.println(prefix + "\tisQsbInline: " + isQsbInline); @@ -1479,14 +1361,12 @@ public class DeviceProfile { writer.println(prefix + pxToDpStr("workspacePadding.left", workspacePadding.left)); writer.println(prefix + pxToDpStr("workspacePadding.top", workspacePadding.top)); writer.println(prefix + pxToDpStr("workspacePadding.right", workspacePadding.right)); - writer.println( - prefix + pxToDpStr("workspacePadding.bottom", workspacePadding.bottom)); + writer.println(prefix + pxToDpStr("workspacePadding.bottom", workspacePadding.bottom)); writer.println(prefix + pxToDpStr("iconScale", iconScale)); writer.println(prefix + pxToDpStr("cellScaleToFit ", cellScaleToFit)); writer.println(prefix + pxToDpStr("extraSpace", extraSpace)); - writer.println( - prefix + pxToDpStr("unscaled extraSpace", extraSpace / iconScale)); + writer.println(prefix + pxToDpStr("unscaled extraSpace", extraSpace / iconScale)); if (inv.devicePaddings != null) { int unscaledExtraSpace = (int) (extraSpace / iconScale); @@ -1497,8 +1377,7 @@ public class DeviceProfile { writer.println(prefix + pxToDpStr("workspaceBottomPadding", workspaceBottomPadding)); writer.println(prefix + pxToDpStr("overviewTaskMarginPx", overviewTaskMarginPx)); - writer.println( - prefix + pxToDpStr("overviewTaskMarginGridPx", overviewTaskMarginGridPx)); + writer.println(prefix + pxToDpStr("overviewTaskMarginGridPx", overviewTaskMarginGridPx)); writer.println(prefix + pxToDpStr("overviewTaskIconSizePx", overviewTaskIconSizePx)); writer.println(prefix + pxToDpStr("overviewTaskIconDrawableSizePx", overviewTaskIconDrawableSizePx)); @@ -1516,64 +1395,21 @@ public class DeviceProfile { writer.println(prefix + pxToDpStr("overviewRowSpacing", overviewRowSpacing)); writer.println(prefix + pxToDpStr("overviewGridSideMargin", overviewGridSideMargin)); - writer.println( - prefix + pxToDpStr("dropTargetBarTopMarginPx", dropTargetBarTopMarginPx)); + writer.println(prefix + pxToDpStr("dropTargetBarTopMarginPx", dropTargetBarTopMarginPx)); writer.println(prefix + pxToDpStr("dropTargetBarSizePx", dropTargetBarSizePx)); - writer.println(prefix - + pxToDpStr("dropTargetBarBottomMarginPx", dropTargetBarBottomMarginPx)); + writer.println( + prefix + pxToDpStr("dropTargetBarBottomMarginPx", dropTargetBarBottomMarginPx)); - writer.println(prefix - + pxToDpStr("workspaceSpringLoadShrunkTop", mWorkspaceSpringLoadShrunkTop)); + writer.println( + prefix + pxToDpStr("workspaceSpringLoadShrunkTop", mWorkspaceSpringLoadShrunkTop)); writer.println(prefix + pxToDpStr("workspaceSpringLoadShrunkBottom", mWorkspaceSpringLoadShrunkBottom)); writer.println(prefix + pxToDpStr("workspaceSpringLoadedMinNextPageVisiblePx", workspaceSpringLoadedMinNextPageVisiblePx)); - writer.println(prefix - + pxToDpStr("getWorkspaceSpringLoadScale()", getWorkspaceSpringLoadScale())); + writer.println( + prefix + pxToDpStr("getWorkspaceSpringLoadScale()", getWorkspaceSpringLoadScale())); writer.println(prefix + pxToDpStr("getCellLayoutHeight()", getCellLayoutHeight())); writer.println(prefix + pxToDpStr("getCellLayoutWidth()", getCellLayoutWidth())); - - writer.println(prefix + pxToDpStr("overviewGridRect.left", overviewGridRect.left)); - writer.println(prefix + pxToDpStr("overviewGridRect.top", overviewGridRect.top)); - writer.println(prefix + pxToDpStr("overviewGridRect.right", overviewGridRect.right)); - writer.println(prefix - + pxToDpStr("overviewGridRect.bottom", overviewGridRect.bottom)); - writer.println(prefix + pxToDpStr("taskDimension.x", taskDimension.x)); - writer.println(prefix + pxToDpStr("taskDimension.y", taskDimension.y)); - writer.println(prefix + pxToDpStr("overviewTaskRect.left", overviewTaskRect.left)); - writer.println(prefix + pxToDpStr("overviewTaskRect.top", overviewTaskRect.top)); - writer.println(prefix + pxToDpStr("overviewTaskRect.right", overviewTaskRect.right)); - writer.println(prefix - + pxToDpStr("overviewTaskRect.bottom", overviewTaskRect.bottom)); - writer.println(prefix - + pxToDpStr("overviewGridTaskDimension.x", overviewGridTaskDimension.x)); - writer.println(prefix - + pxToDpStr("overviewGridTaskDimension.y", overviewGridTaskDimension.y)); - writer.println(prefix - + pxToDpStr("overviewModalTaskRect.left", overviewModalTaskRect.left)); - writer.println(prefix - + pxToDpStr("overviewModalTaskRect.top", overviewModalTaskRect.top)); - writer.println(prefix - + pxToDpStr("overviewModalTaskRect.right", overviewModalTaskRect.right)); - writer.println(prefix - + pxToDpStr("overviewModalTaskRect.bottom", overviewModalTaskRect.bottom)); - boolean isRecentsRtl = - PortraitPagedViewHandler.PORTRAIT.getRecentsRtlSetting(context.getResources()); - writer.println(prefix - + pxToDpStr("getOverviewGridTaskRect(" + isRecentsRtl + ").left", - getOverviewGridTaskRect(isRecentsRtl).left)); - writer.println(prefix - + pxToDpStr("getOverviewGridTaskRect(" + isRecentsRtl + ").top", - getOverviewGridTaskRect(isRecentsRtl).top)); - writer.println(prefix - + pxToDpStr("getOverviewGridTaskRect(" + isRecentsRtl + ").right", - getOverviewGridTaskRect(isRecentsRtl).right)); - writer.println(prefix - + pxToDpStr("getOverviewGridTaskRect(" + isRecentsRtl + ").bottom", - getOverviewGridTaskRect(isRecentsRtl).bottom)); - writer.println( - prefix + pxToDpStr("overviewTaskWorkspaceScale", overviewTaskWorkspaceScale)); - writer.println(prefix + pxToDpStr("overviewModalTaskScale", overviewModalTaskScale)); } // LINT.ThenChange( // packages/apps/Launcher3/quickstep/tests/src/com/android/quickstep/DeviceProfilePhoneTest.kt, diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 528613c032..9c622512a4 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -3024,7 +3024,7 @@ public class Launcher extends StatefulActivity mDragLayer.dump(prefix, writer); mStateManager.dump(prefix, writer); mPopupDataProvider.dump(prefix, writer); - mDeviceProfile.dump(this, prefix, writer); + mDeviceProfile.dump(prefix, writer); try { FileLog.flushAll(writer); diff --git a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt index ba813c0d4a..9a76336cd0 100644 --- a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt +++ b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt @@ -37,7 +37,6 @@ abstract class DeviceProfileBaseTest { protected var transposeLayoutWithOrientation: Boolean = false protected var useTwoPanels: Boolean = false protected var isGestureMode: Boolean = true - protected var isRecentsRtl: Boolean = true @Before fun setUp() { @@ -164,7 +163,7 @@ abstract class DeviceProfileBaseTest { fun dump(dp: DeviceProfile): StringWriter { val stringWriter = StringWriter() val printWriter = PrintWriter(stringWriter) - dp.dump(context, "", printWriter) + dp.dump("", printWriter) printWriter.flush() return stringWriter } From c7293179d0ecf870f75941455887b1eaad85eb30 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Mon, 18 Jul 2022 16:41:50 -0700 Subject: [PATCH 06/10] Space out 3 button nav on taskbar * Add additional margin on nav buttons if there's overlap w/ contextual button * End spacing is dependent on grid layout Bug: 223724516 Test: Tested on unfolded with different grid sizes. Change-Id: Ie814f35cd1f35629744050ee3f7242c5a8599883 --- quickstep/res/layout/taskbar.xml | 9 +-- quickstep/res/values-land/dimens.xml | 6 ++ quickstep/res/values/dimens.xml | 14 ++++- .../taskbar/NavbarButtonsViewController.java | 61 +++++++++++++++++-- ...DeviceProfileTabletLandscape3ButtonTest.kt | 6 +- .../DeviceProfileTabletPortrait3ButtonTest.kt | 2 +- ...viceProfileTwoPanelLandscape3ButtonTest.kt | 2 +- ...eviceProfileTwoPanelPortrait3ButtonTest.kt | 6 +- res/values/attrs.xml | 4 ++ res/values/dimens.xml | 6 ++ res/xml/device_profiles.xml | 5 +- src/com/android/launcher3/DeviceProfile.java | 4 +- .../launcher3/InvariantDeviceProfile.java | 7 +++ .../launcher3/uioverrides/ApiWrapper.java | 8 --- .../launcher3/DeviceProfileBaseTest.kt | 1 + 15 files changed, 108 insertions(+), 33 deletions(-) diff --git a/quickstep/res/layout/taskbar.xml b/quickstep/res/layout/taskbar.xml index 3b1d217ec5..94388b42ec 100644 --- a/quickstep/res/layout/taskbar.xml +++ b/quickstep/res/layout/taskbar.xml @@ -45,8 +45,8 @@ android:id="@+id/start_contextual_buttons" android:layout_width="wrap_content" android:layout_height="match_parent" - android:paddingLeft="@dimen/taskbar_nav_buttons_spacing" - android:paddingRight="@dimen/taskbar_nav_buttons_spacing" + android:paddingStart="@dimen/taskbar_contextual_button_padding" + android:paddingEnd="@dimen/taskbar_contextual_button_padding" android:paddingTop="@dimen/taskbar_contextual_padding_top" android:gravity="center_vertical" android:layout_gravity="start"/> @@ -56,9 +56,6 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:orientation="horizontal" - android:paddingLeft="@dimen/taskbar_nav_buttons_spacing" - android:paddingRight="@dimen/taskbar_nav_buttons_spacing" - android:layout_marginEnd="@dimen/taskbar_contextual_button_margin" android:gravity="center_vertical" android:layout_gravity="end"/> @@ -66,8 +63,6 @@ android:id="@+id/end_contextual_buttons" android:layout_width="wrap_content" android:layout_height="match_parent" - android:paddingLeft="@dimen/taskbar_nav_buttons_spacing" - android:paddingRight="@dimen/taskbar_nav_buttons_spacing" android:paddingTop="@dimen/taskbar_contextual_padding_top" android:gravity="center_vertical" android:layout_gravity="end"/> diff --git a/quickstep/res/values-land/dimens.xml b/quickstep/res/values-land/dimens.xml index 732f511367..83680696ad 100644 --- a/quickstep/res/values-land/dimens.xml +++ b/quickstep/res/values-land/dimens.xml @@ -74,4 +74,10 @@ 218dp + + + 94.5dp + 94.5dp + 84dp + 79dp \ No newline at end of file diff --git a/quickstep/res/values/dimens.xml b/quickstep/res/values/dimens.xml index fa4eaedc88..0232f8652c 100644 --- a/quickstep/res/values/dimens.xml +++ b/quickstep/res/values/dimens.xml @@ -250,11 +250,11 @@ 48dp 54dp 16dp - 16dp + 16dp 8dp 44dp - 40dp - 42dp + 47dp + 24dp 35dp 24dp 220dp @@ -268,4 +268,12 @@ 48dp 48dp 32dp + + + 24dp + 26dp + 26dp + 47dp + 47dp + 47dp diff --git a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java index 17da0d944b..400a3df517 100644 --- a/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/NavbarButtonsViewController.java @@ -46,6 +46,7 @@ import android.annotation.LayoutRes; import android.content.pm.ActivityInfo.Config; import android.content.res.ColorStateList; import android.content.res.Configuration; +import android.content.res.Resources; import android.graphics.Color; import android.graphics.Rect; import android.graphics.Region; @@ -67,6 +68,7 @@ import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; +import com.android.launcher3.DeviceProfile; import com.android.launcher3.LauncherAnimUtils; import com.android.launcher3.R; import com.android.launcher3.Utilities; @@ -94,7 +96,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT private final Rect mTempRect = new Rect(); - private static final int FLAG_SWITCHER_SUPPORTED = 1 << 0; + private static final int FLAG_SWITCHER_SHOWING = 1 << 0; private static final int FLAG_IME_VISIBLE = 1 << 1; private static final int FLAG_ROTATION_BUTTON_VISIBLE = 1 << 2; private static final int FLAG_A11Y_VISIBLE = 1 << 3; @@ -189,7 +191,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT isThreeButtonNav ? mStartContextualContainer : mEndContextualContainer, mControllers.navButtonController, R.id.ime_switcher); mPropertyHolders.add(new StatePropertyHolder(imeSwitcherButton, - flags -> ((flags & FLAG_SWITCHER_SUPPORTED) != 0) + flags -> ((flags & FLAG_SWITCHER_SHOWING) != 0) && ((flags & FLAG_ROTATION_BUTTON_VISIBLE) == 0))); } @@ -228,6 +230,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT if (alwaysShowButtons) { initButtons(mNavButtonContainer, mEndContextualContainer, mControllers.navButtonController); + updateButtonLayoutSpacing(); if (isInSetup) { // Since setup wizard only has back button enabled, it looks strange to be @@ -451,7 +454,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT // TODO(b/202218289) we're getting IME as not visible on lockscreen from system updateStateForFlag(FLAG_IME_VISIBLE, isImeVisible); - updateStateForFlag(FLAG_SWITCHER_SUPPORTED, isImeSwitcherShowing); + updateStateForFlag(FLAG_SWITCHER_SHOWING, isImeSwitcherShowing); updateStateForFlag(FLAG_A11Y_VISIBLE, a11yVisible); updateStateForFlag(FLAG_DISABLE_HOME, isHomeDisabled); updateStateForFlag(FLAG_DISABLE_RECENTS, isRecentsDisabled); @@ -465,6 +468,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT boolean a11yLongClickable = (sysUiStateFlags & SYSUI_STATE_A11Y_BUTTON_LONG_CLICKABLE) != 0; mA11yButton.setLongClickable(a11yLongClickable); + updateButtonLayoutSpacing(); } } @@ -479,6 +483,13 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT } } + /** + * @return {@code true} if A11y is showing in 3 button nav taskbar + */ + private boolean isContextualButtonShowing() { + return mContext.isThreeButtonNav() && (mState & FLAG_A11Y_VISIBLE) != 0; + } + /** * Should be called when we need to show back button for bouncer */ @@ -508,7 +519,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT * Returns true if IME switcher is visible */ public boolean isImeSwitcherVisible() { - return (mState & FLAG_SWITCHER_SUPPORTED) != 0; + return (mState & FLAG_SWITCHER_SHOWING) != 0; } /** @@ -662,6 +673,46 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT if (mFloatingRotationButton != null) { mFloatingRotationButton.onConfigurationChanged(configChanges); } + updateButtonLayoutSpacing(); + } + + /** Adds the correct spacing to 3 button nav container. No-op if using gesture nav */ + private void updateButtonLayoutSpacing() { + if (!mContext.isThreeButtonNav()) { + return; + } + DeviceProfile dp = mContext.getDeviceProfile(); + Resources res = mContext.getResources(); + + // Add spacing after the end of the last nav button + FrameLayout.LayoutParams navButtonParams = + (FrameLayout.LayoutParams) mNavButtonContainer.getLayoutParams(); + int navMarginEnd = (int) res.getDimension(dp.inv.inlineNavButtonsEndSpacing); + int contextualWidth = mEndContextualContainer.getWidth(); + // If contextual buttons are showing, we check if the end margin is enough for the + // contextual button to be showing - if not, move the nav buttons over a smidge + if (isContextualButtonShowing() && navMarginEnd < contextualWidth) { + // Additional spacing, eat up half of space between last icon and nav button + navMarginEnd += res.getDimensionPixelSize(R.dimen.taskbar_hotseat_nav_spacing) / 2; + } + navButtonParams.setMarginEnd(navMarginEnd); + mNavButtonContainer.setLayoutParams(navButtonParams); + + // Add the spaces in between the nav buttons + int spaceInBetween = res.getDimensionPixelSize(R.dimen.taskbar_button_space_inbetween); + for (int i = 0; i < mNavButtonContainer.getChildCount(); i++) { + View navButton = mNavButtonContainer.getChildAt(i); + LinearLayout.LayoutParams buttonLayoutParams = + (LinearLayout.LayoutParams) navButton.getLayoutParams(); + if (i == 0) { + buttonLayoutParams.setMarginEnd(spaceInBetween / 2); + } else if (i == mNavButtonContainer.getChildCount() - 1) { + buttonLayoutParams.setMarginStart(spaceInBetween / 2); + } else { + buttonLayoutParams.setMarginStart(spaceInBetween / 2); + buttonLayoutParams.setMarginEnd(spaceInBetween / 2); + } + } } public void onDestroy() { @@ -749,7 +800,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT private static String getStateString(int flags) { StringJoiner str = new StringJoiner("|"); - appendFlag(str, flags, FLAG_SWITCHER_SUPPORTED, "FLAG_SWITCHER_SUPPORTED"); + appendFlag(str, flags, FLAG_SWITCHER_SHOWING, "FLAG_SWITCHER_SHOWING"); appendFlag(str, flags, FLAG_IME_VISIBLE, "FLAG_IME_VISIBLE"); appendFlag(str, flags, FLAG_ROTATION_BUTTON_VISIBLE, "FLAG_ROTATION_BUTTON_VISIBLE"); appendFlag(str, flags, FLAG_A11Y_VISIBLE, "FLAG_A11Y_VISIBLE"); diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscape3ButtonTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscape3ButtonTest.kt index 2d9e263a93..e8be18f134 100644 --- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscape3ButtonTest.kt +++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscape3ButtonTest.kt @@ -461,7 +461,7 @@ class DeviceProfileTabletLandscape3ButtonTest : DeviceProfileBaseTest() { @Test fun getHotseatLayoutPaddingLeft() { - assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(1443) + assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(1305) } @Test @@ -471,7 +471,7 @@ class DeviceProfileTabletLandscape3ButtonTest : DeviceProfileBaseTest() { @Test fun getHotseatLayoutPaddingRight() { - assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(428) + assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(566) } @Test @@ -481,7 +481,7 @@ class DeviceProfileTabletLandscape3ButtonTest : DeviceProfileBaseTest() { @Test fun hotseatBarEndOffset() { - assertThat(dp.hotseatBarEndOffset).isEqualTo(428) + assertThat(dp.hotseatBarEndOffset).isEqualTo(566) } @Test diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortrait3ButtonTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortrait3ButtonTest.kt index 7f0d6ca022..fad993f0d3 100644 --- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortrait3ButtonTest.kt +++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortrait3ButtonTest.kt @@ -481,7 +481,7 @@ class DeviceProfileTabletPortrait3ButtonTest : DeviceProfileBaseTest() { @Test fun hotseatBarEndOffset() { - assertThat(dp.hotseatBarEndOffset).isEqualTo(428) + assertThat(dp.hotseatBarEndOffset).isEqualTo(502) } @Test diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscape3ButtonTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscape3ButtonTest.kt index 0eeb23dede..cb16974442 100644 --- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscape3ButtonTest.kt +++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscape3ButtonTest.kt @@ -481,7 +481,7 @@ class DeviceProfileTwoPanelLandscape3ButtonTest : DeviceProfileBaseTest() { @Test fun hotseatBarEndOffset() { - assertThat(dp.hotseatBarEndOffset).isEqualTo(428) + assertThat(dp.hotseatBarEndOffset).isEqualTo(566) } @Test diff --git a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortrait3ButtonTest.kt b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortrait3ButtonTest.kt index 9b6d7d55f2..2989fe0e41 100644 --- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortrait3ButtonTest.kt +++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortrait3ButtonTest.kt @@ -461,7 +461,7 @@ class DeviceProfileTwoPanelPortrait3ButtonTest : DeviceProfileBaseTest() { @Test fun getHotseatLayoutPaddingLeft() { - assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(340) + assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(266) } @Test @@ -471,7 +471,7 @@ class DeviceProfileTwoPanelPortrait3ButtonTest : DeviceProfileBaseTest() { @Test fun getHotseatLayoutPaddingRight() { - assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(428) + assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(502) } @Test @@ -481,7 +481,7 @@ class DeviceProfileTwoPanelPortrait3ButtonTest : DeviceProfileBaseTest() { @Test fun hotseatBarEndOffset() { - assertThat(dp.hotseatBarEndOffset).isEqualTo(428) + assertThat(dp.hotseatBarEndOffset).isEqualTo(502) } @Test diff --git a/res/values/attrs.xml b/res/values/attrs.xml index e5b588ccf8..3b7158547c 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -176,6 +176,10 @@ + + + diff --git a/res/values/dimens.xml b/res/values/dimens.xml index dc80bc3df0..3349cb1dd0 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -363,6 +363,12 @@ 0dp 0dp 0dp + 0dp + 0dp + 0dp + 0dp + 0dp + 0dp 16dp diff --git a/res/xml/device_profiles.xml b/res/xml/device_profiles.xml index 5ee291b08e..0238e7d972 100644 --- a/res/xml/device_profiles.xml +++ b/res/xml/device_profiles.xml @@ -26,7 +26,7 @@ launcher:numHotseatIcons="3" launcher:dbFile="launcher_3_by_3.db" launcher:defaultLayoutId="@xml/default_workspace_3x3" - launcher:deviceCategory="phone|multi_display" > + launcher:deviceCategory="phone" > @@ -121,6 +122,7 @@ launcher:numFolderColumns="4" launcher:numHotseatIcons="5" launcher:dbFile="launcher.db" + launcher:inlineNavButtonsEndSpacing="@dimen/taskbar_button_margin_5_5" launcher:defaultLayoutId="@xml/default_workspace_5x5" launcher:deviceCategory="phone|multi_display" > @@ -167,6 +169,7 @@ launcher:hotseatColumnSpanLandscape="4" launcher:numAllAppsColumns="6" launcher:isScalable="true" + launcher:inlineNavButtonsEndSpacing="@dimen/taskbar_button_margin_6_5" launcher:devicePaddingId="@xml/paddings_6x5" launcher:dbFile="launcher_6_by_5.db" launcher:defaultLayoutId="@xml/default_workspace_6x5" diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index d09642a225..561d4f1aee 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -424,11 +424,13 @@ public class DeviceProfile { if (areNavButtonsInline) { /* * 3 nav buttons + + * Spacing between nav buttons + * Little space at the end for contextual buttons + * Little space between icons and nav buttons */ hotseatBarEndOffset = 3 * res.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size) - + res.getDimensionPixelSize(R.dimen.taskbar_contextual_button_margin) + + 2 * res.getDimensionPixelSize(R.dimen.taskbar_button_space_inbetween) + + res.getDimensionPixelSize(inv.inlineNavButtonsEndSpacing) + res.getDimensionPixelSize(R.dimen.taskbar_hotseat_nav_spacing); } else { hotseatBarEndOffset = 0; diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 2085b84ac5..c051292512 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -127,6 +127,7 @@ public class InvariantDeviceProfile { public PointF[] borderSpaces; public float folderBorderSpace; public float[] hotseatBorderSpaces; + public int inlineNavButtonsEndSpacing; public float[] horizontalMargin; @@ -339,6 +340,8 @@ public class InvariantDeviceProfile { devicePaddingId = closestProfile.devicePaddingId; this.deviceType = deviceType; + inlineNavButtonsEndSpacing = closestProfile.inlineNavButtonsEndSpacing; + mExtraAttrs = closestProfile.extraAttrs; iconSize = displayOption.iconSizes; @@ -735,6 +738,7 @@ public class InvariantDeviceProfile { private final int[] hotseatColumnSpan = new int[COUNT_SIZES]; + private int inlineNavButtonsEndSpacing; private final String dbFile; private final int defaultLayoutId; @@ -785,6 +789,9 @@ public class InvariantDeviceProfile { R.styleable.GridDisplayOption_hotseatColumnSpanTwoPanelPortrait, numColumns); + inlineNavButtonsEndSpacing = + a.getResourceId(R.styleable.GridDisplayOption_inlineNavButtonsEndSpacing, + R.dimen.taskbar_button_margin_default); numFolderRows = a.getInt( R.styleable.GridDisplayOption_numFolderRows, numRows); numFolderColumns = a.getInt( diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/ApiWrapper.java b/src_ui_overrides/com/android/launcher3/uioverrides/ApiWrapper.java index 67157494d8..c8b5e2fa37 100644 --- a/src_ui_overrides/com/android/launcher3/uioverrides/ApiWrapper.java +++ b/src_ui_overrides/com/android/launcher3/uioverrides/ApiWrapper.java @@ -17,7 +17,6 @@ package com.android.launcher3.uioverrides; import android.app.Person; -import android.content.Context; import android.content.pm.ShortcutInfo; import com.android.launcher3.Utilities; @@ -29,11 +28,4 @@ public class ApiWrapper { public static Person[] getPersons(ShortcutInfo si) { return Utilities.EMPTY_PERSON_ARRAY; } - - /** - * Returns the minimum space that should be left empty at the end of hotseat - */ - public static int getHotseatEndOffset(Context context) { - return 0; - } } diff --git a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt index ba813c0d4a..779fa95f5b 100644 --- a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt +++ b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt @@ -136,6 +136,7 @@ abstract class DeviceProfileBaseTest { hotseatBorderSpaces = FloatArray(4) { 16f } hotseatColumnSpan = IntArray(4) { 4 } hotseatBarBottomSpace = FloatArray(4) { 48f } + inlineNavButtonsEndSpacing = R.dimen.taskbar_button_margin_4_4 hotseatQsbSpace = FloatArray(4) { 36f } iconSize = FloatArray(4) { 56f } allAppsIconSize = FloatArray(4) { 56f } From bc3fb936e1af2984cf3770ea2321f661f441af5f Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Thu, 21 Jul 2022 15:43:00 -0700 Subject: [PATCH 07/10] Fixing icon label not updated during bulk load The label was being updated to default in Loader cursor which prevented eventual final update of the label Bug: 220645719 Test: Verified on device Change-Id: I2559804eb885663387bd1f5afe9e3337130a9fe3 (cherry picked from commit 412f0d26fa15b1d5f14f13ff81937b4eb2f05f80) --- src/com/android/launcher3/model/LoaderCursor.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/com/android/launcher3/model/LoaderCursor.java b/src/com/android/launcher3/model/LoaderCursor.java index ae5b66ad88..87e8ebf1bb 100644 --- a/src/com/android/launcher3/model/LoaderCursor.java +++ b/src/com/android/launcher3/model/LoaderCursor.java @@ -291,12 +291,16 @@ public class LoaderCursor extends CursorWrapper { // from the db if (TextUtils.isEmpty(info.title)) { - info.title = getTitle(); - } + if (loadIcon) { + info.title = getTitle(); - // fall back to the class name of the activity - if (info.title == null) { - info.title = componentName.getClassName(); + // fall back to the class name of the activity + if (info.title == null) { + info.title = componentName.getClassName(); + } + } else { + info.title = ""; + } } info.contentDescription = mPM.getUserBadgedLabel(info.title, info.user); From 189554616c8d37430ca916d223d6987df4f015a4 Mon Sep 17 00:00:00 2001 From: Sukesh Ram Date: Mon, 11 Jul 2022 14:51:59 -0700 Subject: [PATCH 08/10] Drag from appDrawer & pin onto secondary display homescreen Bug: 239246505 Test: Manual Change-Id: I817d8ef700f2d7caec6fa63123935502f17f2d2f --- .../launcher3/config/FeatureFlags.java | 4 + .../secondarydisplay/PinnedAppsAdapter.java | 16 +- .../SecondaryDisplayLauncher.java | 151 +++++++++++++- .../SecondaryDragController.java | 194 ++++++++++++++++++ .../secondarydisplay/SecondaryDragLayer.java | 49 ++++- .../secondarydisplay/SecondaryDragView.java | 66 ++++++ 6 files changed, 472 insertions(+), 8 deletions(-) create mode 100644 src/com/android/launcher3/secondarydisplay/SecondaryDragController.java create mode 100644 src/com/android/launcher3/secondarydisplay/SecondaryDragView.java diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index 4fd13b2b39..c04f03d0ff 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -288,6 +288,10 @@ public final class FeatureFlags { public static final BooleanFlag CONTINUOUS_VIEW_TREE_CAPTURE = getDebugFlag( "CONTINUOUS_VIEW_TREE_CAPTURE", false, "Capture View tree every frame"); + public static final BooleanFlag SECONDARY_DRAG_N_DROP_TO_PIN = getDebugFlag( + "SECONDARY_DRAG_N_DROP_TO_PIN", false, + "Enable dragging and dropping to pin apps within secondary display"); + public static void initialize(Context context) { synchronized (sDebugFlags) { for (DebugFlag flag : sDebugFlags) { diff --git a/src/com/android/launcher3/secondarydisplay/PinnedAppsAdapter.java b/src/com/android/launcher3/secondarydisplay/PinnedAppsAdapter.java index a0ed77e38f..f03c62ac5c 100644 --- a/src/com/android/launcher3/secondarydisplay/PinnedAppsAdapter.java +++ b/src/com/android/launcher3/secondarydisplay/PinnedAppsAdapter.java @@ -168,15 +168,18 @@ public class PinnedAppsAdapter extends BaseAdapter implements OnSharedPreference mPrefs.unregisterOnSharedPreferenceChangeListener(this); } - private void update(ItemInfo info, Function op) { + /** + * Pins or unpins apps from home screen + */ + public void update(ItemInfo info, Function op) { ComponentKey key = new ComponentKey(info.getTargetComponent(), info.user); if (op.apply(key)) { createFilteredAppsList(); Set copy = new HashSet<>(mPinnedApps); Executors.MODEL_EXECUTOR.submit(() -> mPrefs.edit().putStringSet(PINNED_APPS_KEY, - copy.stream().map(this::encode).collect(Collectors.toSet())) - .apply()); + copy.stream().map(this::encode).collect(Collectors.toSet())) + .apply()); } } @@ -210,6 +213,13 @@ public class PinnedAppsAdapter extends BaseAdapter implements OnSharedPreference mPinnedApps.contains(new ComponentKey(info.getTargetComponent(), info.user))); } + /** + * Pins app to home screen + */ + public void addPinnedApp(ItemInfo info) { + update(info, mPinnedApps::add); + } + private class PinUnPinShortcut extends SystemShortcut { private final boolean mIsPinned; diff --git a/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java b/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java index a55f7e3b69..6ffeddabb0 100644 --- a/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java +++ b/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java @@ -18,6 +18,9 @@ package com.android.launcher3.secondarydisplay; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.content.Intent; +import android.graphics.Point; +import android.graphics.Rect; +import android.graphics.drawable.Drawable; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; @@ -26,6 +29,9 @@ import android.view.inputmethod.InputMethodManager; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.BaseDraggingActivity; +import com.android.launcher3.BubbleTextView; +import com.android.launcher3.DragSource; +import com.android.launcher3.DropTarget; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherModel; @@ -33,6 +39,11 @@ import com.android.launcher3.LauncherSettings; import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.allapps.ActivityAllAppsContainerView; +import com.android.launcher3.dragndrop.DragController; +import com.android.launcher3.dragndrop.DragOptions; +import com.android.launcher3.dragndrop.DraggableView; +import com.android.launcher3.graphics.DragPreviewProvider; +import com.android.launcher3.icons.FastBitmapDrawable; import com.android.launcher3.model.BgDataModel; import com.android.launcher3.model.StringCache; import com.android.launcher3.model.data.AppInfo; @@ -44,6 +55,7 @@ import com.android.launcher3.util.ComponentKey; import com.android.launcher3.util.IntSet; import com.android.launcher3.util.OnboardingPrefs; import com.android.launcher3.util.Themes; +import com.android.launcher3.util.UiThreadHelper; import com.android.launcher3.views.BaseDragLayer; import java.util.HashMap; @@ -52,11 +64,11 @@ import java.util.HashMap; * Launcher activity for secondary displays */ public class SecondaryDisplayLauncher extends BaseDraggingActivity - implements BgDataModel.Callbacks { + implements BgDataModel.Callbacks, DragController.DragListener { private LauncherModel mModel; - private BaseDragLayer mDragLayer; + private SecondaryDragController mDragController; private ActivityAllAppsContainerView mAppsView; private View mAppsButton; @@ -69,10 +81,13 @@ public class SecondaryDisplayLauncher extends BaseDraggingActivity private boolean mBindingItems = false; private SecondaryDisplayPredictions mSecondaryDisplayPredictions; + private final int[] mTempXY = new int[2]; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mModel = LauncherAppState.getInstance(this).getModel(); + mDragController = new SecondaryDragController(this); mOnboardingPrefs = new OnboardingPrefs<>(this, Utilities.getPrefs(this)); mSecondaryDisplayPredictions = SecondaryDisplayPredictions.newInstance(this); if (getWindow().getDecorView().isAttachedToWindow()) { @@ -86,6 +101,12 @@ public class SecondaryDisplayLauncher extends BaseDraggingActivity initUi(); } + @Override + public void onDetachedFromWindow() { + super.onDetachedFromWindow(); + this.getDragController().removeDragListener(this); + } + private void initUi() { if (mDragLayer != null) { return; @@ -106,12 +127,29 @@ public class SecondaryDisplayLauncher extends BaseDraggingActivity mAppsView = findViewById(R.id.apps_view); mAppsButton = findViewById(R.id.all_apps_button); + mDragController.addDragListener(this); mPopupDataProvider = new PopupDataProvider( mAppsView.getAppsStore()::updateNotificationDots); mModel.addCallbacksAndLoad(this); } + /** + * hides keyboard + */ + public void hideKeyboard() { + final View v = getWindow().peekDecorView(); + if (v != null && v.getWindowToken() != null) { + UiThreadHelper.hideKeyboardAsync(this, v.getWindowToken()); + } + } + + @Override + protected void onPause() { + super.onPause(); + mDragController.cancelDrag(); + } + @Override public void onNewIntent(Intent intent) { super.onNewIntent(intent); @@ -129,12 +167,21 @@ public class SecondaryDisplayLauncher extends BaseDraggingActivity showAppDrawer(false); } + public DragController getDragController() { + return mDragController; + } + @Override public void onBackPressed() { if (finishAutoCancelActionMode()) { return; } + if (mDragController.isDragging()) { + mDragController.cancelDrag(); + return; + } + // Note: There should be at most one log per method call. This is enforced implicitly // by using if-else statements. AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(this); @@ -202,7 +249,7 @@ public class SecondaryDisplayLauncher extends BaseDraggingActivity float closeR = Themes.getDialogCornerRadius(this); float startR = mAppsButton.getWidth() / 2f; - float[] buttonPos = new float[] { startR, startR}; + float[] buttonPos = new float[]{startR, startR}; mDragLayer.getDescendantCoordRelativeToSelf(mAppsButton, buttonPos); mDragLayer.mapCoordInSelfToDescendant(mAppsView, buttonPos); final Animator animator = ViewAnimationUtils.createCircularReveal(mAppsView, @@ -236,6 +283,7 @@ public class SecondaryDisplayLauncher extends BaseDraggingActivity @Override public void startBinding() { mBindingItems = true; + mDragController.cancelDrag(); } @Override @@ -308,4 +356,101 @@ public class SecondaryDisplayLauncher extends BaseDraggingActivity startActivitySafely(v, intent, item); } } + + /** + * Core functionality for beginning a drag operation for an item that will be dropped within + * the secondary display grid home screen + */ + public void beginDragShared(View child, DragSource source, DragOptions options) { + Object dragObject = child.getTag(); + if (!(dragObject instanceof ItemInfo)) { + String msg = "Drag started with a view that has no tag set. This " + + "will cause a crash (issue 11627249) down the line. " + + "View: " + child + " tag: " + child.getTag(); + throw new IllegalStateException(msg); + } + beginDragShared(child, source, (ItemInfo) dragObject, + new DragPreviewProvider(child), options); + } + + private void beginDragShared(View child, DragSource source, + ItemInfo dragObject, DragPreviewProvider previewProvider, DragOptions options) { + + float iconScale = 1f; + if (child instanceof BubbleTextView) { + FastBitmapDrawable icon = ((BubbleTextView) child).getIcon(); + if (icon != null) { + iconScale = icon.getAnimatedScale(); + } + } + + // clear pressed state if necessary + child.clearFocus(); + child.setPressed(false); + if (child instanceof BubbleTextView) { + BubbleTextView icon = (BubbleTextView) child; + icon.clearPressedBackground(); + } + + DraggableView draggableView = null; + if (child instanceof DraggableView) { + draggableView = (DraggableView) child; + } + + final View contentView = previewProvider.getContentView(); + final float scale; + // The draggable drawable follows the touch point around on the screen + final Drawable drawable; + if (contentView == null) { + drawable = previewProvider.createDrawable(); + scale = previewProvider.getScaleAndPosition(drawable, mTempXY); + } else { + drawable = null; + scale = previewProvider.getScaleAndPosition(contentView, mTempXY); + } + int halfPadding = previewProvider.previewPadding / 2; + int dragLayerX = mTempXY[0]; + int dragLayerY = mTempXY[1]; + + Point dragVisualizeOffset = null; + Rect dragRect = new Rect(); + if (draggableView != null) { + draggableView.getSourceVisualDragBounds(dragRect); + dragLayerY += dragRect.top; + dragVisualizeOffset = new Point(-halfPadding, halfPadding); + } + if (contentView != null) { + mDragController.startDrag( + contentView, + draggableView, + dragLayerX, + dragLayerY, + source, + dragObject, + dragVisualizeOffset, + dragRect, + scale * iconScale, + scale, + options); + } else { + mDragController.startDrag( + drawable, + draggableView, + dragLayerX, + dragLayerY, + source, + dragObject, + dragVisualizeOffset, + dragRect, + scale * iconScale, + scale, + options); + } + } + + @Override + public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) { } + + @Override + public void onDragEnd() { } } diff --git a/src/com/android/launcher3/secondarydisplay/SecondaryDragController.java b/src/com/android/launcher3/secondarydisplay/SecondaryDragController.java new file mode 100644 index 0000000000..a3fc208b8a --- /dev/null +++ b/src/com/android/launcher3/secondarydisplay/SecondaryDragController.java @@ -0,0 +1,194 @@ +/* + * Copyright (C) 2022 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.secondarydisplay; + +import android.content.res.Resources; +import android.graphics.Point; +import android.graphics.Rect; +import android.graphics.drawable.Drawable; +import android.util.Log; +import android.view.HapticFeedbackConstants; +import android.view.View; + +import androidx.annotation.Nullable; + +import com.android.launcher3.AbstractFloatingView; +import com.android.launcher3.DragSource; +import com.android.launcher3.DropTarget; +import com.android.launcher3.R; +import com.android.launcher3.accessibility.DragViewStateAnnouncer; +import com.android.launcher3.dragndrop.DragController; +import com.android.launcher3.dragndrop.DragDriver; +import com.android.launcher3.dragndrop.DragOptions; +import com.android.launcher3.dragndrop.DragView; +import com.android.launcher3.dragndrop.DraggableView; +import com.android.launcher3.model.data.ItemInfo; +import com.android.launcher3.testing.TestProtocol; + +/** + * Drag controller for Secondary Launcher activity + */ +public class SecondaryDragController extends DragController { + + private static final boolean PROFILE_DRAWING_DURING_DRAG = false; + + public SecondaryDragController(SecondaryDisplayLauncher secondaryLauncher) { + super(secondaryLauncher); + } + + @Override + protected DragView startDrag(@Nullable Drawable drawable, @Nullable View view, + DraggableView originalView, int dragLayerX, int dragLayerY, DragSource source, + ItemInfo dragInfo, Point dragOffset, Rect dragRegion, float initialDragViewScale, + float dragViewScaleOnDrop, DragOptions options) { + + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.NO_DROP_TARGET, "5"); + } + + if (PROFILE_DRAWING_DURING_DRAG) { + android.os.Debug.startMethodTracing("Launcher"); + } + mActivity.hideKeyboard(); + + mOptions = options; + if (mOptions.simulatedDndStartPoint != null) { + mLastTouch.x = mMotionDown.x = mOptions.simulatedDndStartPoint.x; + mLastTouch.y = mMotionDown.y = mOptions.simulatedDndStartPoint.y; + } + + final int registrationX = mMotionDown.x - dragLayerX; + final int registrationY = mMotionDown.y - dragLayerY; + + final int dragRegionLeft = dragRegion == null ? 0 : dragRegion.left; + final int dragRegionTop = dragRegion == null ? 0 : dragRegion.top; + + mLastDropTarget = null; + + mDragObject = new DropTarget.DragObject(mActivity.getApplicationContext()); + mDragObject.originalView = originalView; + + mIsInPreDrag = mOptions.preDragCondition != null + && !mOptions.preDragCondition.shouldStartDrag(0); + + final Resources res = mActivity.getResources(); + final float scaleDps = mIsInPreDrag + ? res.getDimensionPixelSize(R.dimen.pre_drag_view_scale) : 0f; + + final DragView dragView = mDragObject.dragView = drawable != null + ? new SecondaryDragView( + mActivity, + drawable, + registrationX, + registrationY, + initialDragViewScale, + dragViewScaleOnDrop, + scaleDps) + : new SecondaryDragView( + mActivity, + view, + view.getMeasuredWidth(), + view.getMeasuredHeight(), + registrationX, + registrationY, + initialDragViewScale, + dragViewScaleOnDrop, + scaleDps); + dragView.setItemInfo(dragInfo); + mDragObject.dragComplete = false; + + mDragObject.xOffset = mMotionDown.x - (dragLayerX + dragRegionLeft); + mDragObject.yOffset = mMotionDown.y - (dragLayerY + dragRegionTop); + + mDragDriver = DragDriver.create(this, mOptions, ev -> { + }); + if (!mOptions.isAccessibleDrag) { + mDragObject.stateAnnouncer = DragViewStateAnnouncer.createFor(dragView); + } + + mDragObject.dragSource = source; + mDragObject.dragInfo = dragInfo; + mDragObject.originalDragInfo = mDragObject.dragInfo.makeShallowCopy(); + + if (dragOffset != null) { + dragView.setDragVisualizeOffset(new Point(dragOffset)); + } + if (dragRegion != null) { + dragView.setDragRegion(new Rect(dragRegion)); + } + + mActivity.getDragLayer().performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + dragView.show(mLastTouch.x, mLastTouch.y); + mDistanceSinceScroll = 0; + + if (!mIsInPreDrag) { + callOnDragStart(); + } else if (mOptions.preDragCondition != null) { + mOptions.preDragCondition.onPreDragStart(mDragObject); + } + + handleMoveEvent(mLastTouch.x, mLastTouch.y); + return dragView; + } + + @Override + protected void exitDrag() { } + + @Override + protected DropTarget getDefaultDropTarget(int[] dropCoordinates) { + DropTarget target = new DropTarget() { + @Override + public boolean isDropEnabled() { + return true; + } + + @Override + public void onDrop(DragObject dragObject, DragOptions options) { + ((SecondaryDragLayer) mActivity.getDragLayer()).getPinnedAppsAdapter().addPinnedApp( + dragObject.dragInfo); + dragObject.dragView.remove(); + } + + @Override + public void onDragEnter(DragObject dragObject) { + if (getDistanceDragged() > mActivity.getResources().getDimensionPixelSize( + R.dimen.drag_distanceThreshold)) { + mActivity.showAppDrawer(false); + AbstractFloatingView.closeAllOpenViews(mActivity); + } + } + + @Override + public void onDragOver(DragObject dragObject) { } + + @Override + public void onDragExit(DragObject dragObject) { } + + @Override + public boolean acceptDrop(DragObject dragObject) { + return true; + } + + @Override + public void prepareAccessibilityDrop() { } + + @Override + public void getHitRectRelativeToDragLayer(Rect outRect) { } + }; + return target; + } +} diff --git a/src/com/android/launcher3/secondarydisplay/SecondaryDragLayer.java b/src/com/android/launcher3/secondarydisplay/SecondaryDragLayer.java index c79d70dacc..42d597044e 100644 --- a/src/com/android/launcher3/secondarydisplay/SecondaryDragLayer.java +++ b/src/com/android/launcher3/secondarydisplay/SecondaryDragLayer.java @@ -29,8 +29,12 @@ import android.widget.GridView; import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.BubbleTextView; import com.android.launcher3.DeviceProfile; +import com.android.launcher3.DropTarget; import com.android.launcher3.R; import com.android.launcher3.allapps.ActivityAllAppsContainerView; +import com.android.launcher3.config.FeatureFlags; +import com.android.launcher3.dragndrop.DragOptions; +import com.android.launcher3.dragndrop.DragView; import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.popup.PopupContainerWithArrow; import com.android.launcher3.popup.PopupDataProvider; @@ -59,7 +63,8 @@ public class SecondaryDragLayer extends BaseDragLayer @Override public void recreateControllers() { - mControllers = new TouchController[] {new CloseAllAppsTouchController()}; + mControllers = new TouchController[]{new CloseAllAppsTouchController(), + mActivity.getDragController()}; } /** @@ -166,6 +171,10 @@ public class SecondaryDragLayer extends BaseDragLayer } } + public PinnedAppsAdapter getPinnedAppsAdapter() { + return mPinnedAppsAdapter; + } + private boolean onIconLongClicked(View v) { if (!(v instanceof BubbleTextView)) { return false; @@ -183,6 +192,7 @@ public class SecondaryDragLayer extends BaseDragLayer if (popupDataProvider == null) { return false; } + final PopupContainerWithArrow container = (PopupContainerWithArrow) mActivity.getLayoutInflater().inflate( R.layout.popup_container, mActivity.getDragLayer(), false); @@ -192,7 +202,42 @@ public class SecondaryDragLayer extends BaseDragLayer Collections.emptyList(), Arrays.asList(mPinnedAppsAdapter.getSystemShortcut(item, v), APP_INFO.getShortcut(mActivity, item, v))); - v.getParent().requestDisallowInterceptTouchEvent(true); + container.requestFocus(); + + if (!FeatureFlags.SECONDARY_DRAG_N_DROP_TO_PIN.get() || !mActivity.isAppDrawerShown()) { + return true; + } + + DragOptions options = new DragOptions(); + DeviceProfile grid = mActivity.getDeviceProfile(); + options.intrinsicIconScaleFactor = (float) grid.allAppsIconSizePx / grid.iconSizePx; + options.preDragCondition = container.createPreDragCondition(false); + if (options.preDragCondition == null) { + options.preDragCondition = new DragOptions.PreDragCondition() { + private DragView mDragView; + + @Override + public boolean shouldStartDrag(double distanceDragged) { + return mDragView != null && mDragView.isAnimationFinished(); + } + + @Override + public void onPreDragStart(DropTarget.DragObject dragObject) { + mDragView = dragObject.dragView; + if (!shouldStartDrag(0)) { + mDragView.setOnAnimationEndCallback(() -> { + mActivity.beginDragShared(v, mActivity.getAppsView(), options); + }); + } + } + + @Override + public void onPreDragEnd(DropTarget.DragObject dragObject, boolean dragStarted) { + mDragView = null; + } + }; + } + mActivity.beginDragShared(v, mActivity.getAppsView(), options); return true; } } diff --git a/src/com/android/launcher3/secondarydisplay/SecondaryDragView.java b/src/com/android/launcher3/secondarydisplay/SecondaryDragView.java new file mode 100644 index 0000000000..0168b8fc0d --- /dev/null +++ b/src/com/android/launcher3/secondarydisplay/SecondaryDragView.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2022 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.secondarydisplay; + +import android.graphics.drawable.Drawable; +import android.view.View; + +import com.android.launcher3.R; +import com.android.launcher3.dragndrop.DragView; + +/** + * A DragView drawn/used by the Secondary Launcher activity. + */ +public class SecondaryDragView extends DragView { + + public SecondaryDragView(SecondaryDisplayLauncher launcher, + Drawable drawable, + int registrationX, int registrationY, float initialScale, float scaleOnDrop, + float finalScaleDps) { + super(launcher, drawable, registrationX, registrationY, initialScale, scaleOnDrop, + finalScaleDps); + } + + public SecondaryDragView(SecondaryDisplayLauncher launcher, View content, int width, int height, + int registrationX, int registrationY, float initialScale, float scaleOnDrop, + float finalScaleDps) { + super(launcher, content, width, height, registrationX, registrationY, initialScale, + scaleOnDrop, finalScaleDps); + } + + @Override + public void animateTo(int toTouchX, int toTouchY, Runnable onCompleteRunnable, int duration) { + Runnable onAnimationEnd = () -> { + if (onCompleteRunnable != null) { + onCompleteRunnable.run(); + } + mActivity.getDragLayer().removeView(this); + }; + + duration = Math.max(duration, + getResources().getInteger(R.integer.config_dropAnimMinDuration)); + + animate() + .translationX(toTouchX - mRegistrationX) + .translationY(toTouchY - mRegistrationY) + .scaleX(mScaleOnDrop) + .scaleY(mScaleOnDrop) + .withEndAction(onAnimationEnd) + .setDuration(duration) + .start(); + } +} From d2e978c54f3384bb5e29135fa5f0abe0d19f7770 Mon Sep 17 00:00:00 2001 From: Nataniel Borges Date: Tue, 12 Jul 2022 15:59:04 +0000 Subject: [PATCH 09/10] Allow disabling orientation changes check on TAPL This is necessary when a command intentionally changes the device orientation. For example, when triggering `goHome` from an app that is in landscape mode, without enabling launcher rotation Bug: 238757607 Test: testDisableRotationCheck Change-Id: Ia00d85d3263b6524b4806f54f729a0749684b92a --- .../android/launcher3/ui/TaplTestsLauncher3.java | 16 ++++++++++++++++ .../launcher3/tapl/LauncherInstrumentation.java | 11 +++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java index 03bf4af3de..c3839977cb 100644 --- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java +++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java @@ -431,6 +431,22 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest { waitForState("Launcher internal state didn't switch to Home", () -> LauncherState.NORMAL); } + @Test + public void testDisableRotationCheck() throws Exception { + try { + mLauncher.setExpectedRotationCheckEnabled(false); + mLauncher.setEnableRotation(false); + final AllApps allApps = mLauncher.getWorkspace().switchToAllApps(); + final AppIcon app = allApps.getAppIcon("TestActivity7"); + mLauncher.getDevice().setOrientationLeft(); + mLauncher.goHome(); + } finally { + mLauncher.setExpectedRotationCheckEnabled(true); + mLauncher.setEnableRotation(true); + mLauncher.getDevice().setOrientationNatural(); + } + } + @Test @PortraitLandscape public void testDeleteFromWorkspace() throws Exception { diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index 5f920972ca..0d0905a2eb 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -178,6 +178,7 @@ public final class LauncherInstrumentation { private final UiDevice mDevice; private final Instrumentation mInstrumentation; private int mExpectedRotation = Surface.ROTATION_0; + private boolean mExpectedRotationCheckEnabled = true; private final Uri mTestProviderUri; private final Deque mDiagnosticContext = new LinkedList<>(); private Function mSystemHealthSupplier; @@ -667,6 +668,10 @@ public final class LauncherInstrumentation { mExpectedRotation = expectedRotation; } + public void setExpectedRotationCheckEnabled(boolean expectedRotationCheckEnabled) { + mExpectedRotationCheckEnabled = expectedRotationCheckEnabled; + } + public String getNavigationModeMismatchError(boolean waitForCorrectState) { final int waitTime = waitForCorrectState ? WAIT_TIME_MS : 0; final NavigationModel navigationModel = getNavigationModel(); @@ -700,8 +705,10 @@ public final class LauncherInstrumentation { private UiObject2 verifyContainerType(ContainerType containerType) { waitForLauncherInitialized(); - assertEquals("Unexpected display rotation", - mExpectedRotation, mDevice.getDisplayRotation()); + if (mExpectedRotationCheckEnabled) { + assertEquals("Unexpected display rotation", + mExpectedRotation, mDevice.getDisplayRotation()); + } final String error = getNavigationModeMismatchError(true); assertTrue(error, error == null); From 96431570d4e87155bb5d928f609f8f8b0490265f Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Fri, 22 Jul 2022 14:00:28 -0700 Subject: [PATCH 10/10] Have All Set aniamted background extend edge-to-edge There's already a separate ConstraintLayout for the content that needs to have fitsSystemWindows="true", but the drawing can extend past system insets. Test: Run AllSetActivity, manually inspect layout/drawing Fixes: 237052706 Change-Id: I8ff1e3a036fb5c6bfa8586b041c9e5eae55c321d --- quickstep/res/layout/activity_allset.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstep/res/layout/activity_allset.xml b/quickstep/res/layout/activity_allset.xml index 0cae733dbe..56e1d16281 100644 --- a/quickstep/res/layout/activity_allset.xml +++ b/quickstep/res/layout/activity_allset.xml @@ -26,7 +26,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/content_view" - android:fitsSystemWindows="true"> + android:fitsSystemWindows="false">