Move BaseActivityInterface task size methods to DeviceProfile.

Fix: 238593212
Test: DeviceProfilePhoneTest.kt
Test: DeviceProfileVerticalBarTest.kt
Test: DeviceProfilePhone3ButtonTest.kt
Test: DeviceProfileVerticalBar3ButtonTest.kt
Test: DeviceProfileTabletLandscapeTest.kt
Test: DeviceProfileTabletPortraitTest.kt
Test: DeviceProfileTabletLandscape3ButtonTest.kt
Test: DeviceProfileTabletPortrait3ButtonTest.kt
Test: DeviceProfileTwoPanelLandscapeTest.kt
Test: DeviceProfileTwoPanelPortraitTest.kt
Test: DeviceProfileTwoPanelLandscape3ButtonTest.kt
Test: DeviceProfileTwoPanelPortrait3ButtonTest.kt
Change-Id: I30324d34ca119a467f530b590949743c2ba7b91a
This commit is contained in:
Pat Manning
2022-07-13 14:02:08 +01:00
parent 68c6b81d2a
commit 4e73e5e352
37 changed files with 1598 additions and 307 deletions
@@ -337,7 +337,7 @@ public abstract class BaseQuickstepLauncher extends Launcher {
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);
@@ -839,6 +839,6 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
pw.println(String.format(
"%s\tmBindInProgress=%b", prefix, mBindingItems));
mControllers.dumpLogs(prefix + "\t", pw);
mDeviceProfile.dump(prefix, pw);
mDeviceProfile.dump(this, prefix, pw);
}
}
@@ -50,8 +50,7 @@ public class BackgroundAppState extends OverviewState {
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);
@@ -18,8 +18,6 @@ package com.android.launcher3.uioverrides.states;
import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_OVERVIEW;
import android.content.Context;
import android.graphics.Point;
import android.graphics.Rect;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.Launcher;
@@ -71,13 +69,6 @@ public class OverviewModalTaskState extends OverviewState {
}
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};
}
}
@@ -65,12 +65,9 @@ public class OverviewState extends LauncherState {
@Override
public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) {
RecentsView recentsView = launcher.getOverviewPanel();
float workspacePageHeight = launcher.getDeviceProfile().getCellLayoutHeight();
recentsView.getTaskSize(sTempRect);
float scale = (float) sTempRect.height() / workspacePageHeight;
float parallaxFactor = 0.5f;
return new ScaleAndTranslation(scale, 0, -getDefaultSwipeHeight(launcher) * parallaxFactor);
return new ScaleAndTranslation(launcher.getDeviceProfile().overviewTaskWorkspaceScale, 0,
-getDefaultSwipeHeight(launcher) * parallaxFactor);
}
@Override
@@ -120,8 +120,8 @@ public class NoButtonQuickSwitchTouchController implements TouchController,
mSwipeDetector = new BothAxesSwipeDetector(mLauncher, this);
mRecentsView = mLauncher.getOverviewPanel();
mXRange = mLauncher.getDeviceProfile().widthPx / 2f;
mYRange = LayoutUtils.getShelfTrackingDistance(
mLauncher, mLauncher.getDeviceProfile(), mRecentsView.getPagedOrientationHandler());
mYRange = LayoutUtils.getShelfTrackingDistance(mLauncher.getDeviceProfile(),
mRecentsView.getPagedOrientationHandler());
mMaxYProgress = mLauncher.getDeviceProfile().heightPx / mYRange;
mMotionPauseDetector = new MotionPauseDetector(mLauncher);
mMotionPauseMinDisplacement = mLauncher.getResources().getDimension(
@@ -144,8 +144,8 @@ public class PortraitStatesTouchController extends AbstractStateChangeTouchContr
.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);
@@ -2048,8 +2048,8 @@ public abstract class AbsSwipeUpHandler<T extends StatefulActivity<S>,
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 =
@@ -33,12 +33,9 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.PointF;
import android.graphics.Rect;
import android.os.Build;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
@@ -46,7 +43,6 @@ import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.R;
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.statehandlers.DepthController;
@@ -109,8 +105,8 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
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. */
@@ -214,129 +210,6 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
recentsView.switchToScreenshot(thumbnailDatas, runnable);
}
/**
* 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.
@@ -60,13 +60,13 @@ public final class FallbackActivityInterface extends
/** 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;
}
}
@@ -70,14 +70,14 @@ public final class LauncherActivityInterface extends
}
@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);
}
}
@@ -2,7 +2,6 @@ package com.android.quickstep;
import android.app.Activity;
import android.content.Context;
import android.graphics.Rect;
import android.os.Bundle;
import androidx.annotation.Nullable;
@@ -32,8 +31,7 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
}
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 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
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 @@ public class QuickstepTestInformationHandler extends TestInformationHandler {
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;
}
@@ -49,7 +49,6 @@ import java.util.function.Consumer;
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 @@ public abstract class SwipeUpAnimationLogic implements
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;
@@ -1015,7 +1015,7 @@ public class TouchInteractionService extends Service
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);
}
@@ -36,7 +36,6 @@ import com.android.launcher3.Utilities;
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 class AnimatorControllerWithResistance {
*/
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
@@ -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.DeviceProfile;
import com.android.launcher3.touch.PagedOrientationHandler;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.DisplayController.NavigationMode;
import com.android.quickstep.LauncherActivityInterface;
public class LayoutUtils {
@@ -39,12 +37,12 @@ public class LayoutUtils {
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);
}
/**
@@ -25,7 +25,6 @@ import static android.view.Surface.ROTATION_90;
import static com.android.launcher3.states.RotationHelper.ALLOW_ROTATION_PREFERENCE_KEY;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import static com.android.launcher3.util.SettingsCache.ROTATION_SETTING_URI;
import static com.android.quickstep.BaseActivityInterface.getTaskDimension;
import static java.lang.annotation.RetentionPolicy.SOURCE;
@@ -398,8 +397,8 @@ public class RecentsOrientedState implements
* Returns the scale and pivot so that the provided taskRect can fit the provided full size
*/
public float getFullScreenScaleAndPivot(Rect taskView, DeviceProfile dp, PointF outPivot) {
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 {
@@ -144,12 +144,8 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
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) {
@@ -93,7 +93,6 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
@Nullable
protected DeviceProfile mDp;
private final Rect mTaskSize = new Rect();
public OverviewActionsView(Context context) {
this(context, null);
@@ -240,16 +239,15 @@ public class OverviewActionsView<T extends OverlayUICallbacks> extends FrameLayo
}
// 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();
@@ -428,9 +428,6 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
@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 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
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 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
// Update RecentsView and TaskView's DeviceProfile dependent layout.
updateOrientationHandler();
mActionsView.updateDimension(dp, mLastComputedTaskSize);
mActionsView.updateDimension(dp);
}
private void updateOrientationHandler() {
@@ -1734,7 +1732,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
// 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 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
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 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
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();
@@ -2447,7 +2412,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
return;
}
int taskTopMargin = mActivity.getDeviceProfile().overviewTaskThumbnailTopMarginPx;
DeviceProfile dp = mActivity.getDeviceProfile();
int taskTopMargin = dp.overviewTaskThumbnailTopMarginPx;
int topRowWidth = 0;
int bottomRowWidth = 0;
@@ -2490,7 +2456,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
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) {
@@ -2606,11 +2572,11 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
// 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 =
@@ -2627,9 +2593,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
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;
@@ -2644,9 +2609,9 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
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);
}
@@ -2899,8 +2864,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
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;
@@ -3091,7 +3056,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
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));
@@ -3347,7 +3312,7 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
// Update various scroll-dependent UI.
dispatchScrollChanged();
updateActionsViewFocusedScroll();
if (isClearAllHidden() && !mActivity.getDeviceProfile().isTablet) {
if (isClearAllHidden() && !dp.isTablet) {
mActionsView.updateDisabledFlags(OverviewActionsView.DISABLED_SCROLLING,
false);
}
@@ -3745,7 +3710,6 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
updateEmptyStateUi(changed);
// Update the pivots such that when the task is scaled, it fills the full page
getTaskSize(mTempRect);
updatePivots();
setTaskModalness(mTaskModalness);
mLastComputedTaskStartPushOutDistance = null;
@@ -3759,12 +3723,13 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
}
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);
}
@@ -4037,8 +4002,8 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
}
public void initiateSplitSelect(TaskView taskView) {
int defaultSplitPosition = mOrientationHandler
.getDefaultSplitPosition(mActivity.getDeviceProfile());
int defaultSplitPosition =
mOrientationHandler.getDefaultSplitPosition(mActivity.getDeviceProfile());
initiateSplitSelect(taskView, defaultSplitPosition);
}
@@ -4343,9 +4308,9 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
* 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(
@@ -4852,17 +4817,15 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
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;
}
@@ -5168,14 +5131,12 @@ public abstract class RecentsView<ACTIVITY_TYPE extends StatefulActivity<STATE_T
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
@@ -1431,9 +1431,8 @@ public class TaskView extends FrameLayout implements Reusable {
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 @@ public class TaskView extends FrameLayout implements Reusable {
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.