Fix TaskView cropping for transient taskbar
TaskView clipping is not necessary anymore because task in Overview will always be the same aspect ratio as the app when in fullscreen. Fix: 268211636 Test: manual trigger of Overview (landscape, portrait, split screen) Change-Id: Ib4faeda6f0cccef3b23fcbacb89c6d2832c0df59 Merged-In: Ib4faeda6f0cccef3b23fcbacb89c6d2832c0df59
This commit is contained in:
1 parent
b915b989df
commit
3a6193517d
9 files changed
+73
-209
No files matched your search
@@ -244,6 +244,7 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
|
||||
float maxScale = res.getFloat(R.dimen.overview_max_scale);
|
||||
int taskMargin = dp.overviewTaskMarginPx;
|
||||
calculateTaskSizeInternal(
|
||||
context,
|
||||
dp,
|
||||
dp.overviewTaskThumbnailTopMarginPx,
|
||||
dp.getOverviewActionsClaimedSpace(),
|
||||
@@ -259,10 +260,10 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
|
||||
float maxScale = res.getFloat(R.dimen.overview_max_scale);
|
||||
Rect gridRect = new Rect();
|
||||
calculateGridSize(dp, gridRect);
|
||||
calculateTaskSizeInternal(dp, gridRect, maxScale, Gravity.CENTER, outRect);
|
||||
calculateTaskSizeInternal(context, dp, gridRect, maxScale, Gravity.CENTER, outRect);
|
||||
}
|
||||
|
||||
private void calculateTaskSizeInternal(DeviceProfile dp, int claimedSpaceAbove,
|
||||
private void calculateTaskSizeInternal(Context context, DeviceProfile dp, int claimedSpaceAbove,
|
||||
int claimedSpaceBelow, int minimumHorizontalPadding, float maxScale, int gravity,
|
||||
Rect outRect) {
|
||||
Rect insets = dp.getInsets();
|
||||
@@ -275,12 +276,12 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
|
||||
minimumHorizontalPadding,
|
||||
claimedSpaceBelow);
|
||||
|
||||
calculateTaskSizeInternal(dp, potentialTaskRect, maxScale, gravity, outRect);
|
||||
calculateTaskSizeInternal(context, dp, potentialTaskRect, maxScale, gravity, outRect);
|
||||
}
|
||||
|
||||
private void calculateTaskSizeInternal(DeviceProfile dp,
|
||||
private void calculateTaskSizeInternal(Context context, DeviceProfile dp,
|
||||
Rect potentialTaskRect, float maxScale, int gravity, Rect outRect) {
|
||||
PointF taskDimension = getTaskDimension(dp);
|
||||
PointF taskDimension = getTaskDimension(context, dp);
|
||||
|
||||
float scale = Math.min(
|
||||
potentialTaskRect.width() / taskDimension.x,
|
||||
@@ -292,19 +293,19 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
|
||||
Gravity.apply(gravity, outWidth, outHeight, potentialTaskRect, outRect);
|
||||
}
|
||||
|
||||
private static PointF getTaskDimension(DeviceProfile dp) {
|
||||
private static PointF getTaskDimension(Context context, DeviceProfile dp) {
|
||||
PointF dimension = new PointF();
|
||||
getTaskDimension(dp, dimension);
|
||||
getTaskDimension(context, dp, dimension);
|
||||
return dimension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the dimension of the task in the current system state.
|
||||
*/
|
||||
public static void getTaskDimension(DeviceProfile dp, PointF out) {
|
||||
public static void getTaskDimension(Context context, DeviceProfile dp, PointF out) {
|
||||
out.x = dp.widthPx;
|
||||
out.y = dp.heightPx;
|
||||
if (dp.isTablet) {
|
||||
if (dp.isTablet && !DisplayController.isTransientTaskbar(context)) {
|
||||
out.y -= dp.taskbarSize;
|
||||
}
|
||||
}
|
||||
@@ -339,7 +340,7 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
|
||||
float rowHeight = (potentialTaskRect.height() + dp.overviewTaskThumbnailTopMarginPx
|
||||
- dp.overviewRowSpacing) / 2f;
|
||||
|
||||
PointF taskDimension = getTaskDimension(dp);
|
||||
PointF taskDimension = getTaskDimension(context, dp);
|
||||
float scale = (rowHeight - dp.overviewTaskThumbnailTopMarginPx) / taskDimension.y;
|
||||
int outWidth = Math.round(scale * taskDimension.x);
|
||||
int outHeight = Math.round(scale * taskDimension.y);
|
||||
@@ -373,6 +374,7 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
|
||||
Math.round((dp.availableWidthPx - outRect.width() * maxScale) / 2);
|
||||
}
|
||||
calculateTaskSizeInternal(
|
||||
context,
|
||||
dp,
|
||||
dp.overviewTaskMarginPx,
|
||||
claimedSpaceBelow,
|
||||
|
||||
@@ -396,7 +396,7 @@ 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);
|
||||
getTaskDimension(mContext, dp, outPivot);
|
||||
float scale = Math.min(outPivot.x / taskView.width(), outPivot.y / taskView.height());
|
||||
if (scale == 1) {
|
||||
outPivot.set(taskView.centerX(), taskView.centerY());
|
||||
|
||||
@@ -272,9 +272,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
|
||||
*/
|
||||
public RectF getCurrentCropRect() {
|
||||
// Crop rect is the inverse of thumbnail matrix
|
||||
RectF insets = mCurrentFullscreenParams.mCurrentDrawnInsets;
|
||||
mTempRectF.set(-insets.left, -insets.top,
|
||||
mTaskRect.width() + insets.right, mTaskRect.height() + insets.bottom);
|
||||
mTempRectF.set(0, 0, mTaskRect.width(), mTaskRect.height());
|
||||
mInversePositionMatrix.mapRect(mTempRectF);
|
||||
return mTempRectF;
|
||||
}
|
||||
@@ -351,14 +349,10 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
|
||||
/* taskViewScale= */1f, mTaskRect.width(), mDp, mPositionHelper);
|
||||
|
||||
// Apply thumbnail matrix
|
||||
RectF insets = mCurrentFullscreenParams.mCurrentDrawnInsets;
|
||||
float scale = mCurrentFullscreenParams.mScale;
|
||||
float taskWidth = mTaskRect.width();
|
||||
float taskHeight = mTaskRect.height();
|
||||
|
||||
mMatrix.set(mPositionHelper.getMatrix());
|
||||
mMatrix.postTranslate(insets.left, insets.top);
|
||||
mMatrix.postScale(scale, scale);
|
||||
|
||||
// Apply TaskView matrix: taskRect, translate
|
||||
mMatrix.postTranslate(mTaskRect.left, mTaskRect.top);
|
||||
@@ -378,8 +372,7 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
|
||||
applyWindowToHomeRotation(mMatrix);
|
||||
|
||||
// Crop rect is the inverse of thumbnail matrix
|
||||
mTempRectF.set(-insets.left, -insets.top,
|
||||
taskWidth + insets.right, taskHeight + insets.bottom);
|
||||
mTempRectF.set(0, 0, taskWidth, taskHeight);
|
||||
mInversePositionMatrix.mapRect(mTempRectF);
|
||||
mTempRectF.roundOut(mTmpCropRect);
|
||||
|
||||
@@ -389,7 +382,6 @@ public class TaskViewSimulator implements TransformParams.BuilderProxy {
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "progress: " + fullScreenProgress
|
||||
+ " scale: " + scale
|
||||
+ " recentsViewScale: " + recentsViewScale.value
|
||||
+ " crop: " + mTmpCropRect
|
||||
+ " radius: " + getCurrentCornerRadius()
|
||||
|
||||
@@ -97,11 +97,6 @@ public final class DigitalWellBeingToast {
|
||||
private View mBanner;
|
||||
private ViewOutlineProvider mOldBannerOutlineProvider;
|
||||
private float mBannerOffsetPercentage;
|
||||
/**
|
||||
* Clips rect provided by {@link #mOldBannerOutlineProvider} when in the model state to
|
||||
* hide this banner as the taskView scales up and down
|
||||
*/
|
||||
private float mModalOffset = 0f;
|
||||
@Nullable
|
||||
private SplitBounds mSplitBounds;
|
||||
private int mSplitBannerConfig = SPLIT_BANNER_FULLSCREEN;
|
||||
@@ -336,17 +331,15 @@ public final class DigitalWellBeingToast {
|
||||
@Override
|
||||
public void getOutline(View view, Outline outline) {
|
||||
mOldBannerOutlineProvider.getOutline(view, outline);
|
||||
float verticalTranslation = -view.getTranslationY() + mModalOffset
|
||||
+ mSplitOffsetTranslationY;
|
||||
float verticalTranslation = -view.getTranslationY() + mSplitOffsetTranslationY;
|
||||
outline.offset(0, Math.round(verticalTranslation));
|
||||
}
|
||||
});
|
||||
mBanner.setClipToOutline(true);
|
||||
}
|
||||
|
||||
void updateBannerOffset(float offsetPercentage, float verticalOffset) {
|
||||
void updateBannerOffset(float offsetPercentage) {
|
||||
if (mBanner != null && mBannerOffsetPercentage != offsetPercentage) {
|
||||
mModalOffset = verticalOffset;
|
||||
mBannerOffsetPercentage = offsetPercentage;
|
||||
updateTranslationY();
|
||||
mBanner.invalidateOutline();
|
||||
@@ -359,10 +352,7 @@ public final class DigitalWellBeingToast {
|
||||
}
|
||||
|
||||
mBanner.setTranslationY(
|
||||
(mBannerOffsetPercentage * mBanner.getHeight()) +
|
||||
mModalOffset +
|
||||
mSplitOffsetTranslationY
|
||||
);
|
||||
(mBannerOffsetPercentage * mBanner.getHeight()) + mSplitOffsetTranslationY);
|
||||
}
|
||||
|
||||
private void updateTranslationX() {
|
||||
|
||||
@@ -354,9 +354,7 @@ public class GroupedTaskView extends TaskView {
|
||||
// Value set by super call
|
||||
float scale = mIconView.getAlpha();
|
||||
mIconView2.setAlpha(scale);
|
||||
mDigitalWellBeingToast2.updateBannerOffset(1f - scale,
|
||||
mCurrentFullscreenParams.mCurrentDrawnInsets.top
|
||||
+ mCurrentFullscreenParams.mCurrentDrawnInsets.bottom);
|
||||
mDigitalWellBeingToast2.updateBannerOffset(1f - scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -293,16 +293,9 @@ public class TaskThumbnailView extends View {
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
RectF currentDrawnInsets = mFullscreenParams.mCurrentDrawnInsets;
|
||||
canvas.save();
|
||||
canvas.scale(mFullscreenParams.mScale, mFullscreenParams.mScale);
|
||||
canvas.translate(currentDrawnInsets.left, currentDrawnInsets.top);
|
||||
// Draw the insets if we're being drawn fullscreen (we do this for quick switch).
|
||||
drawOnCanvas(canvas,
|
||||
-currentDrawnInsets.left,
|
||||
-currentDrawnInsets.top,
|
||||
getMeasuredWidth() + currentDrawnInsets.right,
|
||||
getMeasuredHeight() + currentDrawnInsets.bottom,
|
||||
drawOnCanvas(canvas, 0, 0, getMeasuredWidth(), getMeasuredHeight(),
|
||||
mFullscreenParams.mCurrentDrawnCornerRadius);
|
||||
canvas.restore();
|
||||
}
|
||||
@@ -424,9 +417,7 @@ public class TaskThumbnailView extends View {
|
||||
return false;
|
||||
}
|
||||
|
||||
RectF insets = mPreviewPositionHelper.getClippedInsets();
|
||||
float thumbnailViewAspect = (getWidth() + insets.left + insets.right)
|
||||
/ (getHeight() + insets.top + insets.bottom);
|
||||
float thumbnailViewAspect = getWidth() / (float) getHeight();
|
||||
float thumbnailDataAspect =
|
||||
mThumbnailData.thumbnail.getWidth() / (float) mThumbnailData.thumbnail.getHeight();
|
||||
|
||||
|
||||
@@ -82,7 +82,6 @@ import com.android.launcher3.testing.shared.TestProtocol;
|
||||
import com.android.launcher3.touch.PagedOrientationHandler;
|
||||
import com.android.launcher3.util.ActivityOptionsWrapper;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
import com.android.launcher3.util.DisplayController;
|
||||
import com.android.launcher3.util.RunnableList;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions;
|
||||
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
|
||||
@@ -559,9 +558,7 @@ public class TaskView extends FrameLayout implements Reusable {
|
||||
}
|
||||
mModalness = modalness;
|
||||
mIconView.setAlpha(1 - modalness);
|
||||
mDigitalWellBeingToast.updateBannerOffset(modalness,
|
||||
mCurrentFullscreenParams.mCurrentDrawnInsets.top
|
||||
+ mCurrentFullscreenParams.mCurrentDrawnInsets.bottom);
|
||||
mDigitalWellBeingToast.updateBannerOffset(modalness);
|
||||
}
|
||||
|
||||
public DigitalWellBeingToast getDigitalWellBeingToast() {
|
||||
@@ -1120,9 +1117,7 @@ public class TaskView extends FrameLayout implements Reusable {
|
||||
float scale = Interpolators.clampToProgress(FAST_OUT_SLOW_IN, lowerClamp, upperClamp)
|
||||
.getInterpolation(progress);
|
||||
mIconView.setAlpha(scale);
|
||||
mDigitalWellBeingToast.updateBannerOffset(1f - scale,
|
||||
mCurrentFullscreenParams.mCurrentDrawnInsets.top
|
||||
+ mCurrentFullscreenParams.mCurrentDrawnInsets.bottom);
|
||||
mDigitalWellBeingToast.updateBannerOffset(1f - scale);
|
||||
}
|
||||
|
||||
public void setIconScaleAnimStartProgress(float startProgress) {
|
||||
@@ -1740,17 +1735,11 @@ public class TaskView extends FrameLayout implements Reusable {
|
||||
private final float mCornerRadius;
|
||||
private final float mWindowCornerRadius;
|
||||
|
||||
public RectF mCurrentDrawnInsets = new RectF();
|
||||
public float mCurrentDrawnCornerRadius;
|
||||
/** The current scale we apply to the thumbnail to adjust for new left/right insets. */
|
||||
public float mScale = 1;
|
||||
|
||||
private boolean mIsTaskbarTransient;
|
||||
|
||||
public FullscreenDrawParams(Context context) {
|
||||
mCornerRadius = TaskCornerRadius.get(context);
|
||||
mWindowCornerRadius = QuickStepContract.getWindowCornerRadius(context);
|
||||
mIsTaskbarTransient = DisplayController.isTransientTaskbar(context);
|
||||
|
||||
mCurrentDrawnCornerRadius = mCornerRadius;
|
||||
}
|
||||
@@ -1760,36 +1749,9 @@ public class TaskView extends FrameLayout implements Reusable {
|
||||
*/
|
||||
public void setProgress(float fullscreenProgress, float parentScale, float taskViewScale,
|
||||
int previewWidth, DeviceProfile dp, PreviewPositionHelper pph) {
|
||||
RectF insets = getInsetsToDrawInFullscreen(pph, dp, mIsTaskbarTransient);
|
||||
|
||||
float currentInsetsLeft = insets.left * fullscreenProgress;
|
||||
float currentInsetsTop = insets.top * fullscreenProgress;
|
||||
float currentInsetsRight = insets.right * fullscreenProgress;
|
||||
float currentInsetsBottom = insets.bottom * fullscreenProgress;
|
||||
mCurrentDrawnInsets.set(
|
||||
currentInsetsLeft, currentInsetsTop, currentInsetsRight, currentInsetsBottom);
|
||||
|
||||
mCurrentDrawnCornerRadius =
|
||||
Utilities.mapRange(fullscreenProgress, mCornerRadius, mWindowCornerRadius)
|
||||
/ parentScale / taskViewScale;
|
||||
|
||||
// We scaled the thumbnail to fit the content (excluding insets) within task view width.
|
||||
// Now that we are drawing left/right insets again, we need to scale down to fit them.
|
||||
if (previewWidth > 0) {
|
||||
mScale = previewWidth / (previewWidth + currentInsetsLeft + currentInsetsRight);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Insets to used for clipping the thumbnail (in case it is drawing outside its own space)
|
||||
*/
|
||||
private static RectF getInsetsToDrawInFullscreen(PreviewPositionHelper pph,
|
||||
DeviceProfile dp, boolean isTaskbarTransient) {
|
||||
if (dp.isTaskbarPresent && isTaskbarTransient) {
|
||||
return pph.getClippedInsets();
|
||||
}
|
||||
return dp.isTaskbarPresent && !dp.isTaskbarPresentInApps
|
||||
? pph.getClippedInsets() : EMPTY_RECT_F;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user