Merge "Adding test for the Widgets reordering." into tm-qpr-dev
diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java
index e21dcba..ec497ef 100644
--- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java
+++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java
@@ -337,7 +337,7 @@
new SplitSelectStateController(this, mHandler, getStateManager(),
getDepthController());
overviewPanel.init(mActionsView, controller);
- mActionsView.updateDimension(getDeviceProfile(), overviewPanel.getLastComputedTaskSize());
+ mActionsView.updateDimension(getDeviceProfile());
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 439490e..6b12e9c 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -839,6 +839,6 @@
pw.println(String.format(
"%s\tmBindInProgress=%b", prefix, mBindingItems));
mControllers.dumpLogs(prefix + "\t", pw);
- mDeviceProfile.dump(prefix, pw);
+ mDeviceProfile.dump(this, 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 b733007..297a61a 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java
@@ -50,8 +50,7 @@
return super.getVerticalProgress(launcher);
}
RecentsView recentsView = launcher.getOverviewPanel();
- int transitionLength = LayoutUtils.getShelfTrackingDistance(launcher,
- launcher.getDeviceProfile(),
+ int transitionLength = LayoutUtils.getShelfTrackingDistance(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 0c49e5f..0f02e26 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewModalTaskState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewModalTaskState.java
@@ -18,8 +18,6 @@
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;
@@ -71,13 +69,6 @@
}
public static float[] getOverviewScaleAndOffsetForModalState(BaseDraggingActivity activity) {
- Point taskSize = activity.<RecentsView>getOverviewPanel().getSelectedTaskSize();
- Rect modalTaskSize = new Rect();
- activity.<RecentsView>getOverviewPanel().getModalTaskSize(modalTaskSize);
-
- float scale = Math.min((float) modalTaskSize.height() / taskSize.y,
- (float) modalTaskSize.width() / taskSize.x);
-
- return new float[] {scale, NO_OFFSET};
+ return new float[] {activity.getDeviceProfile().overviewModalTaskScale, 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 6427e09..c0810b9 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
@@ -65,12 +65,9 @@
@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(scale, 0, -getDefaultSwipeHeight(launcher) * parallaxFactor);
+ return new ScaleAndTranslation(launcher.getDeviceProfile().overviewTaskWorkspaceScale, 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 53dc9dd..d06f64a 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 @@
mSwipeDetector = new BothAxesSwipeDetector(mLauncher, this);
mRecentsView = mLauncher.getOverviewPanel();
mXRange = mLauncher.getDeviceProfile().widthPx / 2f;
- mYRange = LayoutUtils.getShelfTrackingDistance(
- mLauncher, mLauncher.getDeviceProfile(), mRecentsView.getPagedOrientationHandler());
+ mYRange = LayoutUtils.getShelfTrackingDistance(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 9efbc34..7394945 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 @@
.createPlaybackController();
mLauncher.getStateManager().setCurrentUserControlledAnimation(mCurrentAnimation);
RecentsView recentsView = mLauncher.getOverviewPanel();
- totalShift = LayoutUtils.getShelfTrackingDistance(mLauncher,
- mLauncher.getDeviceProfile(), recentsView.getPagedOrientationHandler());
+ totalShift = LayoutUtils.getShelfTrackingDistance(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 8f1872b..045530c 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -2049,8 +2049,8 @@
float scrollOffset = Math.abs(mRecentsView.getScrollOffset(mRecentsView.getCurrentPage()));
int maxScrollOffset = mRecentsView.getPagedOrientationHandler().getPrimaryValue(
- mRecentsView.getLastComputedTaskSize().width(),
- mRecentsView.getLastComputedTaskSize().height());
+ mActivity.getDeviceProfile().overviewTaskRect.width(),
+ mActivity.getDeviceProfile().overviewTaskRect.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 6354282..a922f58 100644
--- a/quickstep/src/com/android/quickstep/BaseActivityInterface.java
+++ b/quickstep/src/com/android/quickstep/BaseActivityInterface.java
@@ -33,12 +33,9 @@
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;
@@ -46,7 +43,6 @@
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;
@@ -109,8 +105,8 @@
activity.getStateManager().goToState(startState, activityVisible);
}
- public abstract int getSwipeUpDestinationAndLength(
- DeviceProfile dp, Context context, Rect outRect,
+ /** Gets swipe-up destination and length. */
+ public abstract int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context,
PagedOrientationHandler orientationHandler);
/** Called when the animation to home has fully settled. */
@@ -215,129 +211,6 @@
}
/**
- * Calculates the taskView size for the provided device configuration.
- */
- public final void calculateTaskSize(Context context, DeviceProfile dp, Rect outRect) {
- Resources res = context.getResources();
- float maxScale = res.getFloat(R.dimen.overview_max_scale);
- if (dp.isTablet) {
- Rect gridRect = new Rect();
- calculateGridSize(dp, gridRect);
-
- calculateTaskSizeInternal(context, dp, gridRect, maxScale, Gravity.CENTER, outRect);
- } else {
- int taskMargin = dp.overviewTaskMarginPx;
- calculateTaskSizeInternal(context, dp,
- dp.overviewTaskThumbnailTopMarginPx,
- dp.getOverviewActionsClaimedSpace(),
- res.getDimensionPixelSize(R.dimen.overview_minimum_next_prev_size) + taskMargin,
- maxScale,
- Gravity.CENTER,
- outRect);
- }
- }
-
- private void calculateTaskSizeInternal(Context context, DeviceProfile dp, int claimedSpaceAbove,
- int claimedSpaceBelow, int minimumHorizontalPadding, float maxScale, int gravity,
- Rect outRect) {
- Rect insets = dp.getInsets();
-
- Rect potentialTaskRect = new Rect(0, 0, dp.widthPx, dp.heightPx);
- potentialTaskRect.inset(insets.left, insets.top, insets.right, insets.bottom);
- potentialTaskRect.inset(
- minimumHorizontalPadding,
- claimedSpaceAbove,
- minimumHorizontalPadding,
- claimedSpaceBelow);
-
- calculateTaskSizeInternal(context, dp, potentialTaskRect, maxScale, gravity, outRect);
- }
-
- private void calculateTaskSizeInternal(Context context, DeviceProfile dp,
- Rect potentialTaskRect, float maxScale, int gravity, Rect outRect) {
- PointF taskDimension = getTaskDimension(dp);
-
- float scale = Math.min(
- potentialTaskRect.width() / taskDimension.x,
- potentialTaskRect.height() / taskDimension.y);
- scale = Math.min(scale, maxScale);
- int outWidth = Math.round(scale * taskDimension.x);
- int outHeight = Math.round(scale * taskDimension.y);
-
- Gravity.apply(gravity, outWidth, outHeight, potentialTaskRect, outRect);
- }
-
- private static PointF getTaskDimension(DeviceProfile dp) {
- PointF dimension = new PointF();
- getTaskDimension(dp, dimension);
- return dimension;
- }
-
- /**
- * Gets the dimension of the task in the current system state.
- */
- public static void getTaskDimension(DeviceProfile dp, PointF out) {
- out.x = dp.widthPx;
- out.y = dp.heightPx;
- if (dp.isTablet) {
- out.y -= dp.taskbarSize;
- }
- }
-
- /**
- * Calculates the overview grid size for the provided device configuration.
- */
- public final void calculateGridSize(DeviceProfile dp, Rect outRect) {
- Rect insets = dp.getInsets();
- int topMargin = dp.overviewTaskThumbnailTopMarginPx;
- int bottomMargin = dp.getOverviewActionsClaimedSpace();
- int sideMargin = dp.overviewGridSideMargin;
-
- outRect.set(0, 0, dp.widthPx, dp.heightPx);
- outRect.inset(Math.max(insets.left, sideMargin), insets.top + topMargin,
- Math.max(insets.right, sideMargin), Math.max(insets.bottom, bottomMargin));
- }
-
- /**
- * Calculates the overview grid non-focused task size for the provided device configuration.
- */
- public final void calculateGridTaskSize(Context context, DeviceProfile dp, Rect outRect,
- PagedOrientationHandler orientedState) {
- Resources res = context.getResources();
- Rect taskRect = new Rect();
- calculateTaskSize(context, dp, taskRect);
-
- float rowHeight =
- (taskRect.height() + dp.overviewTaskThumbnailTopMarginPx - dp.overviewRowSpacing)
- / 2f;
-
- PointF taskDimension = getTaskDimension(dp);
- float scale = (rowHeight - dp.overviewTaskThumbnailTopMarginPx) / taskDimension.y;
- int outWidth = Math.round(scale * taskDimension.x);
- int outHeight = Math.round(scale * taskDimension.y);
-
- int gravity = Gravity.TOP;
- gravity |= orientedState.getRecentsRtlSetting(res) ? Gravity.RIGHT : Gravity.LEFT;
- Gravity.apply(gravity, outWidth, outHeight, taskRect, outRect);
- }
-
- /**
- * Calculates the modal taskView size for the provided device configuration
- */
- public final void calculateModalTaskSize(Context context, DeviceProfile dp, Rect outRect) {
- calculateTaskSize(context, dp, outRect);
- float maxScale = context.getResources().getFloat(R.dimen.overview_modal_max_scale);
- calculateTaskSizeInternal(
- context, dp,
- dp.overviewTaskMarginPx,
- dp.heightPx - outRect.bottom - dp.getInsets().bottom,
- Math.round((dp.availableWidthPx - outRect.width() * maxScale) / 2),
- 1f /*maxScale*/,
- Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM,
- outRect);
- }
-
- /**
* Called when the gesture ends and the animation starts towards the given target. Used to add
* an optional additional animation with the same duration.
*/
diff --git a/quickstep/src/com/android/quickstep/FallbackActivityInterface.java b/quickstep/src/com/android/quickstep/FallbackActivityInterface.java
index ba61574..2ca5a2e 100644
--- a/quickstep/src/com/android/quickstep/FallbackActivityInterface.java
+++ b/quickstep/src/com/android/quickstep/FallbackActivityInterface.java
@@ -60,13 +60,13 @@
/** 2 */
@Override
- public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect,
+ public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context,
PagedOrientationHandler orientationHandler) {
- calculateTaskSize(context, dp, outRect);
if (dp.isVerticalBarLayout() && DisplayController.getNavigationMode(context) != NO_BUTTON) {
- return dp.isSeascape() ? outRect.left : (dp.widthPx - outRect.right);
+ return dp.isSeascape()
+ ? dp.overviewTaskRect.left : (dp.widthPx - dp.overviewTaskRect.right);
} else {
- return dp.heightPx - outRect.bottom;
+ return dp.heightPx - dp.overviewTaskRect.bottom;
}
}
diff --git a/quickstep/src/com/android/quickstep/LauncherActivityInterface.java b/quickstep/src/com/android/quickstep/LauncherActivityInterface.java
index c13b95f..d3065bd 100644
--- a/quickstep/src/com/android/quickstep/LauncherActivityInterface.java
+++ b/quickstep/src/com/android/quickstep/LauncherActivityInterface.java
@@ -70,14 +70,14 @@
}
@Override
- public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context, Rect outRect,
+ public int getSwipeUpDestinationAndLength(DeviceProfile dp, Context context,
PagedOrientationHandler orientationHandler) {
- calculateTaskSize(context, dp, outRect);
if (dp.isVerticalBarLayout()
&& DisplayController.getNavigationMode(context) != NavigationMode.NO_BUTTON) {
- return dp.isSeascape() ? outRect.left : (dp.widthPx - outRect.right);
+ return dp.isSeascape()
+ ? dp.overviewTaskRect.left : (dp.widthPx - dp.overviewTaskRect.right);
} else {
- return LayoutUtils.getShelfTrackingDistance(context, dp, orientationHandler);
+ return LayoutUtils.getShelfTrackingDistance(dp, orientationHandler);
}
}
diff --git a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java
index 528fb97..d216a6a 100644
--- a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java
+++ b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java
@@ -2,7 +2,6 @@
import android.app.Activity;
import android.content.Context;
-import android.graphics.Rect;
import android.os.Bundle;
import androidx.annotation.Nullable;
@@ -32,8 +31,7 @@
}
case TestProtocol.REQUEST_BACKGROUND_TO_OVERVIEW_SWIPE_HEIGHT: {
- final float swipeHeight =
- LayoutUtils.getShelfTrackingDistance(mContext, mDeviceProfile,
+ final float swipeHeight = LayoutUtils.getShelfTrackingDistance(mDeviceProfile,
PagedOrientationHandler.PORTRAIT);
response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, (int) swipeHeight);
return response;
@@ -43,10 +41,8 @@
if (!mDeviceProfile.isTablet) {
return null;
}
- Rect focusedTaskRect = new Rect();
- LauncherActivityInterface.INSTANCE.calculateTaskSize(mContext, mDeviceProfile,
- focusedTaskRect);
- response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD, focusedTaskRect.height());
+ response.putInt(TestProtocol.TEST_INFO_RESPONSE_FIELD,
+ mDeviceProfile.overviewTaskRect.height());
return response;
}
@@ -54,10 +50,10 @@
if (!mDeviceProfile.isTablet) {
return null;
}
- Rect gridTaskRect = new Rect();
- LauncherActivityInterface.INSTANCE.calculateGridTaskSize(mContext, mDeviceProfile,
- gridTaskRect, PagedOrientationHandler.PORTRAIT);
- response.putParcelable(TestProtocol.TEST_INFO_RESPONSE_FIELD, gridTaskRect);
+ boolean isRecentsRtl = PagedOrientationHandler.PORTRAIT.getRecentsRtlSetting(
+ mContext.getResources());
+ response.putParcelable(TestProtocol.TEST_INFO_RESPONSE_FIELD,
+ mDeviceProfile.getOverviewGridTaskRect(isRecentsRtl));
return response;
}
diff --git a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java
index baeb514..3c15d0f 100644
--- a/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java
+++ b/quickstep/src/com/android/quickstep/SwipeUpAnimationLogic.java
@@ -49,7 +49,6 @@
public abstract class SwipeUpAnimationLogic implements
RecentsAnimationCallbacks.RecentsAnimationListener{
- protected static final Rect TEMP_RECT = new Rect();
protected final RemoteTargetGluer mTargetGluer;
protected DeviceProfile mDp;
@@ -92,7 +91,7 @@
protected void initTransitionEndpoints(DeviceProfile dp) {
mDp = dp;
mTransitionDragLength = mGestureState.getActivityInterface().getSwipeUpDestinationAndLength(
- dp, mContext, TEMP_RECT, mRemoteTargetHandles[0].getTaskViewSimulator()
+ dp, mContext, mRemoteTargetHandles[0].getTaskViewSimulator()
.getOrientationState().getOrientationHandler());
mDragLengthFactor = (float) dp.heightPx / mTransitionDragLength;
diff --git a/quickstep/src/com/android/quickstep/TouchInteractionService.java b/quickstep/src/com/android/quickstep/TouchInteractionService.java
index bf1c998..149af98 100644
--- a/quickstep/src/com/android/quickstep/TouchInteractionService.java
+++ b/quickstep/src/com/android/quickstep/TouchInteractionService.java
@@ -1015,7 +1015,7 @@
pw.println("ProtoTrace:");
pw.println(" file=" + ProtoTracer.INSTANCE.get(this).getTraceFile());
if (createdOverviewActivity != null) {
- createdOverviewActivity.getDeviceProfile().dump("", pw);
+ createdOverviewActivity.getDeviceProfile().dump(this, "", pw);
}
mTaskbarManager.dumpLogs("", pw);
}
diff --git a/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java b/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java
index 7c83833..ded4fb0 100644
--- a/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java
+++ b/quickstep/src/com/android/quickstep/util/AnimatorControllerWithResistance.java
@@ -36,7 +36,6 @@
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.touch.PagedOrientationHandler;
-import com.android.quickstep.LauncherActivityInterface;
import com.android.quickstep.views.RecentsView;
/**
@@ -155,10 +154,9 @@
*/
public static <SCALE, TRANSLATION> PendingAnimation createRecentsResistanceAnim(
RecentsParams<SCALE, TRANSLATION> params) {
- Rect startRect = new Rect();
+ Rect startRect = new Rect(params.dp.overviewTaskRect);
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 d0856be..d4eb880 100644
--- a/quickstep/src/com/android/quickstep/util/LayoutUtils.java
+++ b/quickstep/src/com/android/quickstep/util/LayoutUtils.java
@@ -16,7 +16,6 @@
package com.android.quickstep.util;
import android.content.Context;
-import android.graphics.Rect;
import android.view.View;
import android.view.ViewGroup;
@@ -24,7 +23,6 @@
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 {
@@ -39,12 +37,12 @@
return swipeHeight;
}
- public static int getShelfTrackingDistance(Context context, DeviceProfile dp,
+ /**
+ * Returns the shelf tracking distance.
+ */
+ public static int getShelfTrackingDistance(DeviceProfile dp,
PagedOrientationHandler orientationHandler) {
- // Track the bottom of the window.
- Rect taskSize = new Rect();
- LauncherActivityInterface.INSTANCE.calculateTaskSize(context, dp, taskSize);
- return orientationHandler.getDistanceToBottomOfRect(dp, taskSize);
+ return orientationHandler.getDistanceToBottomOfRect(dp, dp.overviewTaskRect);
}
/**
diff --git a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
index dec934a..39e3797 100644
--- a/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
+++ b/quickstep/src/com/android/quickstep/util/RecentsOrientedState.java
@@ -25,7 +25,6 @@
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;
@@ -398,8 +397,8 @@
* 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) {
- getTaskDimension(dp, outPivot);
- float scale = Math.min(outPivot.x / taskView.width(), outPivot.y / taskView.height());
+ float scale = Math.min(dp.taskDimension.x / taskView.width(),
+ dp.taskDimension.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 8c48443..c626b0a 100644
--- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java
+++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java
@@ -144,12 +144,8 @@
if (mDp == null) {
return 1;
}
- if (mIsGridTask) {
- mSizeStrategy.calculateGridTaskSize(mContext, mDp, mTaskRect,
- mOrientationState.getOrientationHandler());
- } else {
- mSizeStrategy.calculateTaskSize(mContext, mDp, mTaskRect);
- }
+ mTaskRect.set(
+ mIsGridTask ? mDp.getOverviewGridTaskRect(mIsRecentsRtl) : mDp.overviewTaskRect);
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 9b585fc..c9d6394 100644
--- a/quickstep/src/com/android/quickstep/views/OverviewActionsView.java
+++ b/quickstep/src/com/android/quickstep/views/OverviewActionsView.java
@@ -93,7 +93,6 @@
@Nullable
protected DeviceProfile mDp;
- private final Rect mTaskSize = new Rect();
public OverviewActionsView(Context context) {
this(context, null);
@@ -240,16 +239,15 @@
}
// Align to bottom of task Rect.
- return mDp.heightPx - mTaskSize.bottom - mDp.overviewActionsTopMarginPx
+ return mDp.heightPx - mDp.overviewTaskRect.bottom - mDp.overviewActionsTopMarginPx
- mDp.overviewActionsHeight;
}
/**
- * Updates device profile and task size for this view to draw with.
+ * Updates device profile for this view to draw with.
*/
- public void updateDimension(DeviceProfile dp, Rect taskSize) {
+ public void updateDimension(DeviceProfile dp) {
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 cf93857..dc886f6 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -428,9 +428,6 @@
@Nullable
protected RemoteTargetHandle[] mRemoteTargetHandles;
- protected final Rect mLastComputedTaskSize = new Rect();
- protected final Rect mLastComputedGridSize = new Rect();
- protected final Rect mLastComputedGridTaskSize = new Rect();
// How much a task that is directly offscreen will be pushed out due to RecentsView scale/pivot.
@Nullable
protected Float mLastComputedTaskStartPushOutDistance = null;
@@ -1139,7 +1136,8 @@
int targetScroll = getScrollForPage(indexOfChild(getFocusedTaskView()));
if (!isClearAllHidden) {
int clearAllWidth = mOrientationHandler.getPrimarySize(mClearAllButton);
- int taskGridHorizontalDiff = mLastComputedTaskSize.right - mLastComputedGridSize.right;
+ int taskGridHorizontalDiff = mActivity.getDeviceProfile().overviewTaskRect.right
+ - mActivity.getDeviceProfile().overviewGridRect.right;
int clearAllFocusScrollDiff = taskGridHorizontalDiff - clearAllWidth;
targetScroll += mIsRtl ? clearAllFocusScrollDiff : -clearAllFocusScrollDiff;
}
@@ -1678,7 +1676,7 @@
// Update RecentsView and TaskView's DeviceProfile dependent layout.
updateOrientationHandler();
- mActionsView.updateDimension(dp, mLastComputedTaskSize);
+ mActionsView.updateDimension(dp);
}
private void updateOrientationHandler() {
@@ -1734,7 +1732,7 @@
// Update task size and padding that are dependent on DeviceProfile and insets.
private void updateSizeAndPadding() {
DeviceProfile dp = mActivity.getDeviceProfile();
- getTaskSize(mTempRect);
+ mTempRect.set(dp.overviewTaskRect);
mTaskWidth = mTempRect.width();
mTaskHeight = mTempRect.height();
@@ -1743,14 +1741,9 @@
dp.widthPx - mInsets.right - mTempRect.right,
dp.heightPx - mInsets.bottom - mTempRect.bottom);
- mSizeStrategy.calculateGridSize(mActivity.getDeviceProfile(),
- mLastComputedGridSize);
- mSizeStrategy.calculateGridTaskSize(mActivity, mActivity.getDeviceProfile(),
- mLastComputedGridTaskSize, mOrientationHandler);
-
- mTaskGridVerticalDiff = mLastComputedGridTaskSize.top - mLastComputedTaskSize.top;
+ mTaskGridVerticalDiff = dp.getOverviewGridTaskRect(mIsRtl).top - dp.overviewTaskRect.top;
mTopBottomRowHeightDiff =
- mLastComputedGridTaskSize.height() + dp.overviewTaskThumbnailTopMarginPx
+ dp.overviewGridTaskDimension.y + dp.overviewTaskThumbnailTopMarginPx
+ dp.overviewRowSpacing;
// Force TaskView to update size from thumbnail
@@ -1792,34 +1785,6 @@
updateGridProperties(isTaskDismissal);
}
- public void getTaskSize(Rect outRect) {
- mSizeStrategy.calculateTaskSize(mActivity, mActivity.getDeviceProfile(), outRect);
- mLastComputedTaskSize.set(outRect);
- }
-
- /**
- * Returns the size of task selected to enter modal state.
- */
- public Point getSelectedTaskSize() {
- mSizeStrategy.calculateTaskSize(mActivity, mActivity.getDeviceProfile(),
- mTempRect);
- return new Point(mTempRect.width(), mTempRect.height());
- }
-
- /** Gets the last computed task size */
- public Rect getLastComputedTaskSize() {
- return mLastComputedTaskSize;
- }
-
- public Rect getLastComputedGridTaskSize() {
- return mLastComputedGridTaskSize;
- }
-
- /** Gets the task size for modal state. */
- public void getModalTaskSize(Rect outRect) {
- mSizeStrategy.calculateModalTaskSize(mActivity, mActivity.getDeviceProfile(), outRect);
- }
-
@Override
protected boolean computeScrollHelper() {
boolean scrolling = super.computeScrollHelper();
@@ -2452,7 +2417,8 @@
return;
}
- int taskTopMargin = mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx;
+ DeviceProfile dp = mActivity.getDeviceProfile();
+ int taskTopMargin = dp.overviewTaskThumbnailTopMarginPx;
int topRowWidth = 0;
int bottomRowWidth = 0;
@@ -2495,7 +2461,7 @@
gridTranslations[i] += mIsRtl ? taskWidthAndSpacing : -taskWidthAndSpacing;
// Center view vertically in case it's from different orientation.
- taskView.setGridTranslationY((mLastComputedTaskSize.height() + taskTopMargin
+ taskView.setGridTranslationY((dp.overviewTaskRect.height() + taskTopMargin
- taskView.getLayoutParams().height) / 2f);
if (taskView == snappedTaskView) {
@@ -2611,11 +2577,11 @@
// accordingly. Update longRowWidth if ClearAllButton has been moved.
float clearAllShortTotalCompensation = 0;
int longRowWidth = Math.max(topRowWidth, bottomRowWidth);
- if (longRowWidth < mLastComputedGridSize.width()) {
- float shortTotalCompensation = mLastComputedGridSize.width() - longRowWidth;
+ if (longRowWidth < dp.overviewGridRect.width()) {
+ float shortTotalCompensation = dp.overviewGridRect.width() - longRowWidth;
clearAllShortTotalCompensation =
mIsRtl ? -shortTotalCompensation : shortTotalCompensation;
- longRowWidth = mLastComputedGridSize.width();
+ longRowWidth = dp.overviewGridRect.width();
}
float clearAllTotalTranslationX =
@@ -2632,9 +2598,8 @@
if (snappedTaskView != null) {
int distanceFromClearAll = longRowWidth - snappedTaskRowWidth + mPageSpacing;
// ClearAllButton should be off screen when snapped task is in its snapped position.
- int minimumDistance =
- mTaskWidth - snappedTaskView.getLayoutParams().width
- + (mLastComputedGridSize.width() - mTaskWidth) / 2;
+ int minimumDistance = mTaskWidth - snappedTaskView.getLayoutParams().width
+ + (dp.overviewGridRect.width() - mTaskWidth) / 2;
if (distanceFromClearAll < minimumDistance) {
int distanceDifference = minimumDistance - distanceFromClearAll;
snappedTaskGridTranslationX += mIsRtl ? distanceDifference : -distanceDifference;
@@ -2649,9 +2614,9 @@
mClearAllButton.setGridTranslationPrimary(
clearAllTotalTranslationX - snappedTaskGridTranslationX);
- mClearAllButton.setGridScrollOffset(
- mIsRtl ? mLastComputedTaskSize.left - mLastComputedGridSize.left
- : mLastComputedTaskSize.right - mLastComputedGridSize.right);
+ mClearAllButton.setGridScrollOffset(mIsRtl
+ ? dp.overviewTaskRect.left - dp.overviewGridRect.left
+ : dp.overviewTaskRect.right - dp.overviewGridRect.right);
setGridProgress(mGridProgress);
}
@@ -2904,8 +2869,8 @@
boolean closeGapBetweenClearAll = false;
boolean isClearAllHidden = isClearAllHidden();
boolean snapToLastTask = false;
- boolean isLandscapeSplit =
- mActivity.getDeviceProfile().isLandscape && isSplitSelectionActive();
+ DeviceProfile dp = mActivity.getDeviceProfile();
+ boolean isLandscapeSplit = dp.isLandscape && isSplitSelectionActive();
boolean isSplitPlaceholderFirstInGrid = isSplitPlaceholderFirstInGrid();
boolean isSplitPlaceholderLastInGrid = isSplitPlaceholderLastInGrid();
TaskView lastGridTaskView = showAsGrid ? getLastGridTaskView() : null;
@@ -3096,7 +3061,7 @@
dismissTranslationInterpolationEnd);
if (taskView == nextFocusedTaskView) {
// Enlarge the task to be focused next, and translate into focus position.
- float scale = mTaskWidth / (float) mLastComputedGridTaskSize.width();
+ float scale = mTaskWidth / (float) dp.overviewGridTaskDimension.x;
anim.setFloat(taskView, TaskView.SNAPSHOT_SCALE, scale,
clampToProgress(LINEAR, animationStartProgress,
dismissTranslationInterpolationEnd));
@@ -3352,7 +3317,7 @@
// Update various scroll-dependent UI.
dispatchScrollChanged();
updateActionsViewFocusedScroll();
- if (isClearAllHidden() && !mActivity.getDeviceProfile().isTablet) {
+ if (isClearAllHidden() && !dp.isTablet) {
mActionsView.updateDisabledFlags(OverviewActionsView.DISABLED_SCROLLING,
false);
}
@@ -3750,7 +3715,6 @@
updateEmptyStateUi(changed);
// Update the pivots such that when the task is scaled, it fills the full page
- getTaskSize(mTempRect);
updatePivots();
setTaskModalness(mTaskModalness);
mLastComputedTaskStartPushOutDistance = null;
@@ -3764,12 +3728,13 @@
}
private void updatePivots() {
+ DeviceProfile dp = mActivity.getDeviceProfile();
if (mOverviewSelectEnabled) {
- setPivotX(mLastComputedTaskSize.centerX());
- setPivotY(mLastComputedTaskSize.bottom);
+ setPivotX(dp.overviewTaskRect.centerX());
+ setPivotY(dp.overviewTaskRect.bottom);
} else {
- getPagedViewOrientedState().getFullScreenScaleAndPivot(mTempRect,
- mActivity.getDeviceProfile(), mTempPointF);
+ getPagedViewOrientedState().getFullScreenScaleAndPivot(dp.overviewTaskRect, dp,
+ mTempPointF);
setPivotX(mTempPointF.x);
setPivotY(mTempPointF.y);
}
@@ -4042,8 +4007,8 @@
}
public void initiateSplitSelect(TaskView taskView) {
- int defaultSplitPosition = mOrientationHandler
- .getDefaultSplitPosition(mActivity.getDeviceProfile());
+ int defaultSplitPosition =
+ mOrientationHandler.getDefaultSplitPosition(mActivity.getDeviceProfile());
initiateSplitSelect(taskView, defaultSplitPosition);
}
@@ -4348,9 +4313,9 @@
* Returns the scale up required on the view, so that it coves the screen completely
*/
public float getMaxScaleForFullScreen() {
- getTaskSize(mTempRect);
- return getPagedViewOrientedState().getFullScreenScaleAndPivot(
- mTempRect, mActivity.getDeviceProfile(), mTempPointF);
+ DeviceProfile dp = mActivity.getDeviceProfile();
+ return getPagedViewOrientedState().getFullScreenScaleAndPivot(dp.overviewTaskRect,
+ dp, mTempPointF);
}
public PendingAnimation createTaskLaunchAnimation(
@@ -4857,17 +4822,15 @@
int lastGridTaskViewPosition =
getPositionInRow(lastGridTaskView, topRowIdArray, bottomRowIdArray);
int taskViewPosition = getPositionInRow(taskView, topRowIdArray, bottomRowIdArray);
- int gridTaskSizeAndSpacing = mLastComputedGridTaskSize.width() + mPageSpacing;
+ DeviceProfile dp = mActivity.getDeviceProfile();
+ Rect gridTaskRect = dp.getOverviewGridTaskRect(mIsRtl);
+ int gridTaskSizeAndSpacing = gridTaskRect.width() + mPageSpacing;
int positionDiff = gridTaskSizeAndSpacing * (lastGridTaskViewPosition - taskViewPosition);
- int lastTaskEnd = (mIsRtl
- ? mLastComputedGridSize.left
- : mLastComputedGridSize.right)
+ int lastTaskEnd = (mIsRtl ? dp.overviewGridRect.left : dp.overviewGridRect.right)
+ (mIsRtl ? mPageSpacing : -mPageSpacing);
int taskEnd = lastTaskEnd + (mIsRtl ? positionDiff : -positionDiff);
- int normalTaskEnd = mIsRtl
- ? mLastComputedGridTaskSize.left
- : mLastComputedGridTaskSize.right;
+ int normalTaskEnd = mIsRtl ? gridTaskRect.left : gridTaskRect.right;
return taskEnd - normalTaskEnd;
}
@@ -5173,14 +5136,12 @@
while ((taskView == null || isTaskViewFullyVisible(taskView)) && targetPage - 1 >= 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
- ? mLastComputedGridSize.left
- : mLastComputedGridSize.right)
+ int lastTaskEnd = (mIsRtl ? dp.overviewGridRect.left : dp.overviewGridRect.right)
+ (mIsRtl ? mPageSpacing : -mPageSpacing);
- int normalTaskEnd = mIsRtl
- ? mLastComputedGridTaskSize.left
- : mLastComputedGridTaskSize.right;
+ int normalTaskEnd = mIsRtl ? gridTaskRect.left : gridTaskRect.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 ded0ea6..d2b85f6 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -1431,9 +1431,8 @@
DeviceProfile deviceProfile = mActivity.getDeviceProfile();
if (deviceProfile.isTablet) {
final int thumbnailPadding = deviceProfile.overviewTaskThumbnailTopMarginPx;
- final Rect lastComputedTaskSize = getRecentsView().getLastComputedTaskSize();
- final int taskWidth = lastComputedTaskSize.width();
- final int taskHeight = lastComputedTaskSize.height();
+ final int taskWidth = deviceProfile.overviewTaskRect.width();
+ final int taskHeight = deviceProfile.overviewTaskRect.height();
int boxWidth;
int boxHeight;
@@ -1444,10 +1443,9 @@
boxWidth = taskWidth;
boxHeight = taskHeight;
} else {
- // Otherwise task is in grid, and should use lastComputedGridTaskSize.
- Rect lastComputedGridTaskSize = getRecentsView().getLastComputedGridTaskSize();
- boxWidth = lastComputedGridTaskSize.width();
- boxHeight = lastComputedGridTaskSize.height();
+ // Otherwise task is in grid.
+ boxWidth = deviceProfile.overviewGridTaskDimension.x;
+ boxHeight = deviceProfile.overviewGridTaskDimension.y;
}
// 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 3daf81d..588e346 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfilePhone3ButtonTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfilePhone3ButtonTest.kt
@@ -483,4 +483,114 @@
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 e588c71..f91d03d 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfilePhoneTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfilePhoneTest.kt
@@ -483,4 +483,114 @@
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 3f8d2fb..2d9e263 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscape3ButtonTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscape3ButtonTest.kt
@@ -483,4 +483,114 @@
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 456ed2c..3add2c7 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscapeTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletLandscapeTest.kt
@@ -483,4 +483,114 @@
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 b53b36a..7f0d6ca 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortrait3ButtonTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortrait3ButtonTest.kt
@@ -483,4 +483,114 @@
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 4be3e45..1a709e6 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortraitTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTabletPortraitTest.kt
@@ -483,4 +483,114 @@
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 274ca95..0eeb23d 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscape3ButtonTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscape3ButtonTest.kt
@@ -483,4 +483,114 @@
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 ba3ef55..7bf53d7 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscapeTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelLandscapeTest.kt
@@ -483,4 +483,114 @@
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 7dd95f9..9b6d7d5 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortrait3ButtonTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortrait3ButtonTest.kt
@@ -483,4 +483,114 @@
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 0c5968e..6702eb5 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortraitTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileTwoPanelPortraitTest.kt
@@ -483,4 +483,114 @@
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 2bad6bb..7e0c5f3 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfileVerticalBar3ButtonTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileVerticalBar3ButtonTest.kt
@@ -483,4 +483,114 @@
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 6256a43..9580458 100644
--- a/quickstep/tests/src/com/android/quickstep/DeviceProfileVerticalBarTest.kt
+++ b/quickstep/tests/src/com/android/quickstep/DeviceProfileVerticalBarTest.kt
@@ -483,4 +483,114 @@
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/layout/all_apps_bottom_sheet_background.xml b/res/layout/all_apps_bottom_sheet_background.xml
index 12b6b7b..3e47690 100644
--- a/res/layout/all_apps_bottom_sheet_background.xml
+++ b/res/layout/all_apps_bottom_sheet_background.xml
@@ -22,7 +22,7 @@
<View
android:id="@+id/bottom_sheet_handle_area"
android:layout_width="match_parent"
- android:layout_height="36dp" />
+ android:layout_height="@dimen/bottom_sheet_handle_area_height" />
<View
android:id="@+id/bottom_sheet_handle"
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index d095ae3..dc80bc3 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -383,6 +383,9 @@
<dimen name="overview_grid_side_margin">0dp</dimen>
<dimen name="overview_grid_row_spacing">0dp</dimen>
<dimen name="overview_page_spacing">0dp</dimen>
+ <dimen name="overview_minimum_next_prev_size">0dp</dimen>
+ <item name="overview_max_scale" format="float" type="dimen">0.0</item>
+ <item name="overview_modal_max_scale" format="float" type="dimen">0.0</item>
<dimen name="split_placeholder_size">72dp</dimen>
<dimen name="split_placeholder_inset">16dp</dimen>
<dimen name="split_placeholder_icon_size">44dp</dimen>
@@ -410,6 +413,7 @@
<!-- Bottom sheet related parameters -->
<dimen name="bottom_sheet_extra_top_padding">0dp</dimen>
+ <dimen name="bottom_sheet_handle_area_height">36dp</dimen>
<dimen name="bottom_sheet_handle_width">32dp</dimen>
<dimen name="bottom_sheet_handle_height">4dp</dimen>
<dimen name="bottom_sheet_handle_margin">16dp</dimen>
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index adf6216..d09642a 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -34,6 +34,7 @@
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;
@@ -41,6 +42,7 @@
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;
@@ -202,6 +204,12 @@
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);
@@ -228,6 +236,9 @@
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.
@@ -481,6 +492,104 @@
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);
}
/**
@@ -1245,7 +1354,8 @@
}
// LINT.IfChange
- public void dump(String prefix, PrintWriter writer) {
+ /** Dumps various DeviceProfile variables to the specified writer. */
+ public void dump(Context context, String prefix, PrintWriter writer) {
writer.println(prefix + "DeviceProfile:");
writer.println(prefix + "\t1 dp = " + mMetrics.density + " px");
@@ -1291,9 +1401,12 @@
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));
@@ -1327,13 +1440,15 @@
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",
@@ -1344,9 +1459,12 @@
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);
@@ -1361,12 +1479,14 @@
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);
@@ -1377,7 +1497,8 @@
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));
@@ -1395,21 +1516,64 @@
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 9c62251..528613c 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -3024,7 +3024,7 @@
mDragLayer.dump(prefix, writer);
mStateManager.dump(prefix, writer);
mPopupDataProvider.dump(prefix, writer);
- mDeviceProfile.dump(prefix, writer);
+ mDeviceProfile.dump(this, prefix, writer);
try {
FileLog.flushAll(writer);
diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
index 45a567d..8bbe216 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -50,7 +50,7 @@
public static final String TAG = "AlphabeticalAppsList";
- private final WorkAdapterProvider mWorkAdapterProvider;
+ private final WorkProfileManager mWorkProviderManager;
/**
* Info about a fast scroller section, depending if sections are merged, the fast scroller
@@ -92,11 +92,11 @@
private Predicate<ItemInfo> mItemFilter;
public AlphabeticalAppsList(Context context, @Nullable AllAppsStore appsStore,
- WorkAdapterProvider adapterProvider) {
+ WorkProfileManager workProfileManager) {
mAllAppsStore = appsStore;
mActivityContext = ActivityContext.lookupContext(context);
mAppNameComparator = new AppInfoComparator(context);
- mWorkAdapterProvider = adapterProvider;
+ mWorkProviderManager = workProfileManager;
mNumAppsPerRowAllApps = mActivityContext.getDeviceProfile().inv.numAllAppsColumns;
if (mAllAppsStore != null) {
mAllAppsStore.addUpdateListener(this);
@@ -260,9 +260,9 @@
}
} else {
int position = 0;
- if (mWorkAdapterProvider != null) {
- position += mWorkAdapterProvider.addWorkItems(mAdapterItems);
- if (!mWorkAdapterProvider.shouldShowWorkApps()) {
+ if (mWorkProviderManager != null) {
+ position += mWorkProviderManager.addWorkItems(mAdapterItems);
+ if (!mWorkProviderManager.shouldShowWorkApps()) {
return;
}
}
diff --git a/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java b/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java
index fcba246..459fa88 100644
--- a/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java
+++ b/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java
@@ -63,6 +63,11 @@
// A divider that separates the apps list and the search market button
public static final int VIEW_TYPE_ALL_APPS_DIVIDER = 1 << 4;
+ public static final int VIEW_TYPE_WORK_EDU_CARD = 1 << 5;
+ public static final int VIEW_TYPE_WORK_DISABLED_CARD = 1 << 6;
+
+ public static final int NEXT_ID = 7;
+
// Common view type masks
public static final int VIEW_TYPE_MASK_DIVIDER = VIEW_TYPE_ALL_APPS_DIVIDER;
public static final int VIEW_TYPE_MASK_ICON = VIEW_TYPE_ICON;
@@ -225,6 +230,12 @@
case VIEW_TYPE_ALL_APPS_DIVIDER:
return new ViewHolder(mLayoutInflater.inflate(
R.layout.all_apps_divider, parent, false));
+ case VIEW_TYPE_WORK_EDU_CARD:
+ return new ViewHolder(mLayoutInflater.inflate(
+ R.layout.work_apps_edu, parent, false));
+ case VIEW_TYPE_WORK_DISABLED_CARD:
+ return new ViewHolder(mLayoutInflater.inflate(
+ R.layout.work_apps_paused, parent, false));
default:
BaseAdapterProvider adapterProvider = getAdapterProvider(viewType);
if (adapterProvider != null) {
@@ -258,8 +269,12 @@
}
break;
case VIEW_TYPE_ALL_APPS_DIVIDER:
+ case VIEW_TYPE_WORK_DISABLED_CARD:
// nothing to do
break;
+ case VIEW_TYPE_WORK_EDU_CARD:
+ ((WorkEduCard) holder.itemView).setPosition(position);
+ break;
default:
BaseAdapterProvider adapterProvider = getAdapterProvider(holder.getItemViewType());
if (adapterProvider != null) {
diff --git a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
index 72a9b14..6faedc0 100644
--- a/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/BaseAllAppsContainerView.java
@@ -147,8 +147,7 @@
mWorkManager = new WorkProfileManager(
mActivityContext.getSystemService(UserManager.class),
- this,
- Utilities.getPrefs(mActivityContext), mActivityContext.getDeviceProfile());
+ this, Utilities.getPrefs(mActivityContext));
mAH = Arrays.asList(null, null, null);
mAH.set(AdapterHolder.MAIN, new AdapterHolder(AdapterHolder.MAIN));
mAH.set(AdapterHolder.WORK, new AdapterHolder(AdapterHolder.WORK));
@@ -800,12 +799,9 @@
mType = type;
mAppsList = new AlphabeticalAppsList<>(mActivityContext,
isSearch() ? null : mAllAppsStore,
- isWork() ? mWorkManager.getAdapterProvider() : null);
-
+ isWork() ? mWorkManager : null);
BaseAdapterProvider[] adapterProviders =
- isWork() ? new BaseAdapterProvider[]{mMainAdapterProvider,
- mWorkManager.getAdapterProvider()}
- : new BaseAdapterProvider[]{mMainAdapterProvider};
+ new BaseAdapterProvider[]{mMainAdapterProvider};
mAdapter = createAdapter(mAppsList, adapterProviders);
mAppsList.setAdapter(mAdapter);
diff --git a/src/com/android/launcher3/allapps/WorkAdapterProvider.java b/src/com/android/launcher3/allapps/WorkAdapterProvider.java
deleted file mode 100644
index 76d08c8..0000000
--- a/src/com/android/launcher3/allapps/WorkAdapterProvider.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2021 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.allapps;
-
-import android.content.SharedPreferences;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-import com.android.launcher3.R;
-import com.android.launcher3.allapps.BaseAllAppsAdapter.AdapterItem;
-import com.android.launcher3.model.StringCache;
-import com.android.launcher3.views.ActivityContext;
-
-import java.util.ArrayList;
-
-/**
- * A UI expansion wrapper providing for providing work profile specific views
- */
-public class WorkAdapterProvider extends BaseAdapterProvider {
-
- public static final String KEY_WORK_EDU_STEP = "showed_work_profile_edu";
-
- private static final int VIEW_TYPE_WORK_EDU_CARD = 1 << 20;
- private static final int VIEW_TYPE_WORK_DISABLED_CARD = 1 << 21;
-
- @WorkProfileManager.WorkProfileState
- private int mState;
- private ActivityContext mActivityContext;
- private SharedPreferences mPreferences;
-
- WorkAdapterProvider(ActivityContext activityContext, SharedPreferences prefs) {
- mActivityContext = activityContext;
- mPreferences = prefs;
- }
-
- @Override
- public void onBindView(AllAppsGridAdapter.ViewHolder holder, int position) {
- if (holder.itemView instanceof WorkEduCard) {
- ((WorkEduCard) holder.itemView).setPosition(position);
- }
- }
-
- @Override
- public AllAppsGridAdapter.ViewHolder onCreateViewHolder(LayoutInflater layoutInflater,
- ViewGroup parent, int viewType) {
- int viewId = viewType == VIEW_TYPE_WORK_DISABLED_CARD ? R.layout.work_apps_paused
- : R.layout.work_apps_edu;
- View view = layoutInflater.inflate(viewId, parent, false);
- setDeviceManagementResources(view, viewType);
- return new AllAppsGridAdapter.ViewHolder(view);
- }
-
- private void setDeviceManagementResources(View view, int viewType) {
- StringCache cache = mActivityContext.getStringCache();
- if (cache == null) {
- return;
- }
- if (viewType == VIEW_TYPE_WORK_DISABLED_CARD) {
- setWorkProfilePausedResources(view, cache);
- } else {
- setWorkProfileEduResources(view, cache);
- }
- }
-
- private void setWorkProfilePausedResources(View view, StringCache cache) {
- TextView title = view.findViewById(R.id.work_apps_paused_title);
- title.setText(cache.workProfilePausedTitle);
-
- TextView body = view.findViewById(R.id.work_apps_paused_content);
- body.setText(cache.workProfilePausedDescription);
-
- TextView button = view.findViewById(R.id.enable_work_apps);
- button.setText(cache.workProfileEnableButton);
- }
-
- private void setWorkProfileEduResources(View view, StringCache cache) {
- TextView title = view.findViewById(R.id.work_apps_paused_title);
- title.setText(cache.workProfileEdu);
-
- }
-
- /**
- * returns whether or not work apps should be visible in work tab.
- */
- public boolean shouldShowWorkApps() {
- return mState != WorkProfileManager.STATE_DISABLED;
- }
-
- /**
- * Adds work profile specific adapter items to adapterItems and returns number of items added
- */
- public int addWorkItems(ArrayList<AllAppsGridAdapter.AdapterItem> adapterItems) {
- if (mState == WorkProfileManager.STATE_DISABLED) {
- //add disabled card here.
- adapterItems.add(new AdapterItem(VIEW_TYPE_WORK_DISABLED_CARD));
- } else if (mState == WorkProfileManager.STATE_ENABLED && !isEduSeen()) {
- adapterItems.add(new AdapterItem(VIEW_TYPE_WORK_EDU_CARD));
- }
-
- return adapterItems.size();
- }
-
- /**
- * Sets the current state of work profile
- */
- public void updateCurrentState(@WorkProfileManager.WorkProfileState int state) {
- mState = state;
- }
-
- @Override
- public boolean isViewSupported(int viewType) {
- return viewType == VIEW_TYPE_WORK_DISABLED_CARD || viewType == VIEW_TYPE_WORK_EDU_CARD;
- }
-
- @Override
- public int getItemsPerRow(int viewType, int appsPerRow) {
- return 1;
- }
-
- private boolean isEduSeen() {
- return mPreferences.getInt(KEY_WORK_EDU_STEP, 0) != 0;
- }
-}
diff --git a/src/com/android/launcher3/allapps/WorkEduCard.java b/src/com/android/launcher3/allapps/WorkEduCard.java
index 539cff1..968a556 100644
--- a/src/com/android/launcher3/allapps/WorkEduCard.java
+++ b/src/com/android/launcher3/allapps/WorkEduCard.java
@@ -24,9 +24,11 @@
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.FrameLayout;
+import android.widget.TextView;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
+import com.android.launcher3.model.StringCache;
import com.android.launcher3.views.ActivityContext;
/**
@@ -72,12 +74,18 @@
protected void onFinishInflate() {
super.onFinishInflate();
findViewById(R.id.action_btn).setOnClickListener(this);
+
+ StringCache cache = mActivityContext.getStringCache();
+ if (cache != null) {
+ TextView title = findViewById(R.id.work_apps_paused_title);
+ title.setText(cache.workProfileEdu);
+ }
}
@Override
public void onClick(View view) {
startAnimation(mDismissAnim);
- Utilities.getPrefs(getContext()).edit().putInt(WorkAdapterProvider.KEY_WORK_EDU_STEP,
+ Utilities.getPrefs(getContext()).edit().putInt(WorkProfileManager.KEY_WORK_EDU_STEP,
1).apply();
}
diff --git a/src/com/android/launcher3/allapps/WorkPausedCard.java b/src/com/android/launcher3/allapps/WorkPausedCard.java
index 729622f..26a7803 100644
--- a/src/com/android/launcher3/allapps/WorkPausedCard.java
+++ b/src/com/android/launcher3/allapps/WorkPausedCard.java
@@ -23,9 +23,11 @@
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
+import android.widget.TextView;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
+import com.android.launcher3.model.StringCache;
import com.android.launcher3.views.ActivityContext;
/**
@@ -49,12 +51,27 @@
mActivityContext = ActivityContext.lookupContext(getContext());
}
-
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mBtn = findViewById(R.id.enable_work_apps);
mBtn.setOnClickListener(this);
+
+ StringCache cache = mActivityContext.getStringCache();
+ if (cache != null) {
+ setWorkProfilePausedResources(cache);
+ }
+ }
+
+ private void setWorkProfilePausedResources(StringCache cache) {
+ TextView title = findViewById(R.id.work_apps_paused_title);
+ title.setText(cache.workProfilePausedTitle);
+
+ TextView body = findViewById(R.id.work_apps_paused_content);
+ body.setText(cache.workProfilePausedDescription);
+
+ TextView button = findViewById(R.id.enable_work_apps);
+ button.setText(cache.workProfileEnableButton);
}
@Override
diff --git a/src/com/android/launcher3/allapps/WorkProfileManager.java b/src/com/android/launcher3/allapps/WorkProfileManager.java
index 2f5b7a2..cfac985 100644
--- a/src/com/android/launcher3/allapps/WorkProfileManager.java
+++ b/src/com/android/launcher3/allapps/WorkProfileManager.java
@@ -15,6 +15,8 @@
*/
package com.android.launcher3.allapps;
+import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_WORK_DISABLED_CARD;
+import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_WORK_EDU_CARD;
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_HAS_SHORTCUT_PERMISSION;
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_QUIET_MODE_CHANGE_PERMISSION;
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_QUIET_MODE_ENABLED;
@@ -31,13 +33,14 @@
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
-import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
+import com.android.launcher3.allapps.BaseAllAppsAdapter.AdapterItem;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.workprofile.PersonalWorkSlidingTabStrip;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.util.ArrayList;
import java.util.function.Predicate;
/**
@@ -48,13 +51,12 @@
public class WorkProfileManager implements PersonalWorkSlidingTabStrip.OnActivePageChangedListener {
private static final String TAG = "WorkProfileManager";
+ public static final String KEY_WORK_EDU_STEP = "showed_work_profile_edu";
public static final int STATE_ENABLED = 1;
public static final int STATE_DISABLED = 2;
public static final int STATE_TRANSITION = 3;
- private final UserManager mUserManager;
-
/**
* Work profile manager states
*/
@@ -64,26 +66,23 @@
STATE_TRANSITION
})
@Retention(RetentionPolicy.SOURCE)
- public @interface WorkProfileState {
- }
+ public @interface WorkProfileState { }
+ private final UserManager mUserManager;
private final BaseAllAppsContainerView<?> mAllApps;
- private final WorkAdapterProvider mAdapterProvider;
private final Predicate<ItemInfo> mMatcher;
private WorkModeSwitch mWorkModeSwitch;
- private final DeviceProfile mDeviceProfile;
@WorkProfileState
private int mCurrentState;
+ private SharedPreferences mPreferences;
-
- public WorkProfileManager(UserManager userManager, BaseAllAppsContainerView<?> allApps,
- SharedPreferences preferences, DeviceProfile deviceProfile) {
+ public WorkProfileManager(
+ UserManager userManager, BaseAllAppsContainerView<?> allApps, SharedPreferences prefs) {
mUserManager = userManager;
mAllApps = allApps;
- mDeviceProfile = deviceProfile;
- mAdapterProvider = new WorkAdapterProvider(allApps.mActivityContext, preferences);
+ mPreferences = prefs;
mMatcher = mAllApps.mPersonalMatcher.negate();
}
@@ -120,7 +119,6 @@
private void updateCurrentState(@WorkProfileState int currentState) {
mCurrentState = currentState;
- mAdapterProvider.updateCurrentState(currentState);
if (getAH() != null) {
getAH().mAppsList.updateAdapterItems();
}
@@ -161,10 +159,6 @@
mWorkModeSwitch = null;
}
- public WorkAdapterProvider getAdapterProvider() {
- return mAdapterProvider;
- }
-
public Predicate<ItemInfo> getMatcher() {
return mMatcher;
}
@@ -181,4 +175,28 @@
public int getCurrentState() {
return mCurrentState;
}
+
+ /**
+ * returns whether or not work apps should be visible in work tab.
+ */
+ public boolean shouldShowWorkApps() {
+ return mCurrentState != WorkProfileManager.STATE_DISABLED;
+ }
+
+ /**
+ * Adds work profile specific adapter items to adapterItems and returns number of items added
+ */
+ public int addWorkItems(ArrayList<AdapterItem> adapterItems) {
+ if (mCurrentState == WorkProfileManager.STATE_DISABLED) {
+ //add disabled card here.
+ adapterItems.add(new AdapterItem(VIEW_TYPE_WORK_DISABLED_CARD));
+ } else if (mCurrentState == WorkProfileManager.STATE_ENABLED && !isEduSeen()) {
+ adapterItems.add(new AdapterItem(VIEW_TYPE_WORK_EDU_CARD));
+ }
+ return adapterItems.size();
+ }
+
+ private boolean isEduSeen() {
+ return mPreferences.getInt(KEY_WORK_EDU_STEP, 0) != 0;
+ }
}
diff --git a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
index 9a76336..ba813c0 100644
--- a/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
+++ b/tests/src/com/android/launcher3/DeviceProfileBaseTest.kt
@@ -37,6 +37,7 @@
protected var transposeLayoutWithOrientation: Boolean = false
protected var useTwoPanels: Boolean = false
protected var isGestureMode: Boolean = true
+ protected var isRecentsRtl: Boolean = true
@Before
fun setUp() {
@@ -163,7 +164,7 @@
fun dump(dp: DeviceProfile): StringWriter {
val stringWriter = StringWriter()
val printWriter = PrintWriter(stringWriter)
- dp.dump("", printWriter)
+ dp.dump(context, "", printWriter)
printWriter.flush()
return stringWriter
}
diff --git a/tests/src/com/android/launcher3/ui/WorkProfileTest.java b/tests/src/com/android/launcher3/ui/WorkProfileTest.java
index 35b4ca6..a7a17b1 100644
--- a/tests/src/com/android/launcher3/ui/WorkProfileTest.java
+++ b/tests/src/com/android/launcher3/ui/WorkProfileTest.java
@@ -30,7 +30,6 @@
import com.android.launcher3.R;
import com.android.launcher3.allapps.ActivityAllAppsContainerView;
import com.android.launcher3.allapps.AllAppsPagedView;
-import com.android.launcher3.allapps.WorkAdapterProvider;
import com.android.launcher3.allapps.WorkEduCard;
import com.android.launcher3.allapps.WorkPausedCard;
import com.android.launcher3.allapps.WorkProfileManager;
@@ -155,7 +154,7 @@
public void testEdu() {
waitForWorkTabSetup();
executeOnLauncher(l -> {
- l.getSharedPrefs().edit().putInt(WorkAdapterProvider.KEY_WORK_EDU_STEP, 0).commit();
+ l.getSharedPrefs().edit().putInt(WorkProfileManager.KEY_WORK_EDU_STEP, 0).commit();
((AllAppsPagedView) l.getAppsView().getContentView()).setCurrentPage(WORK_PAGE);
l.getAppsView().getWorkManager().reset();
});