2020-04-01 20:13:12 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2020 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.quickstep.util;
|
|
|
|
|
|
2022-09-09 23:23:35 +00:00
|
|
|
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
|
|
|
|
|
|
2020-04-21 13:50:08 -07:00
|
|
|
import static com.android.launcher3.states.RotationHelper.deltaRotation;
|
2020-04-01 20:13:12 -07:00
|
|
|
import static com.android.launcher3.touch.PagedOrientationHandler.MATRIX_POST_TRANSLATE;
|
2021-09-24 15:37:30 -07:00
|
|
|
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT;
|
|
|
|
|
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT;
|
|
|
|
|
import static com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_UNDEFINED;
|
|
|
|
|
import static com.android.launcher3.util.SplitConfigurationOptions.StagePosition;
|
2022-07-22 23:23:12 +00:00
|
|
|
import static com.android.quickstep.TaskAnimationManager.ENABLE_SHELL_TRANSITIONS;
|
2020-04-01 20:13:12 -07:00
|
|
|
import static com.android.quickstep.util.RecentsOrientedState.postDisplayRotation;
|
2020-12-11 14:39:50 -08:00
|
|
|
import static com.android.quickstep.util.RecentsOrientedState.preDisplayRotation;
|
2020-04-01 20:13:12 -07:00
|
|
|
|
2020-05-12 15:18:49 -07:00
|
|
|
import android.animation.TimeInterpolator;
|
2020-04-01 20:13:12 -07:00
|
|
|
import android.content.Context;
|
2021-02-03 18:00:30 +00:00
|
|
|
import android.content.res.Resources;
|
2020-04-01 20:13:12 -07:00
|
|
|
import android.graphics.Matrix;
|
|
|
|
|
import android.graphics.PointF;
|
|
|
|
|
import android.graphics.Rect;
|
|
|
|
|
import android.graphics.RectF;
|
2021-08-05 12:54:58 -07:00
|
|
|
import android.util.Log;
|
2022-10-19 16:16:10 -07:00
|
|
|
import android.view.RemoteAnimationTarget;
|
2020-04-01 20:13:12 -07:00
|
|
|
|
2020-11-05 13:00:56 -08:00
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
|
2020-04-01 20:13:12 -07:00
|
|
|
import com.android.launcher3.DeviceProfile;
|
|
|
|
|
import com.android.launcher3.Utilities;
|
2022-12-08 13:00:21 -08:00
|
|
|
import com.android.launcher3.anim.AnimatedFloat;
|
2020-05-12 15:18:49 -07:00
|
|
|
import com.android.launcher3.anim.PendingAnimation;
|
2022-05-27 15:59:40 -07:00
|
|
|
import com.android.launcher3.util.SplitConfigurationOptions.SplitBounds;
|
2021-05-03 22:26:52 -07:00
|
|
|
import com.android.launcher3.util.TraceHelper;
|
2020-05-13 10:29:47 -07:00
|
|
|
import com.android.quickstep.BaseActivityInterface;
|
2021-12-03 05:20:24 +00:00
|
|
|
import com.android.quickstep.TaskAnimationManager;
|
2022-10-17 22:48:03 +00:00
|
|
|
import com.android.quickstep.util.SurfaceTransaction.SurfaceProperties;
|
2020-04-01 20:13:12 -07:00
|
|
|
import com.android.quickstep.views.TaskView.FullscreenDrawParams;
|
|
|
|
|
import com.android.systemui.shared.recents.model.ThumbnailData;
|
2022-09-23 12:04:18 +01:00
|
|
|
import com.android.systemui.shared.recents.utilities.PreviewPositionHelper;
|
2020-04-01 20:13:12 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A utility class which emulates the layout behavior of TaskView and RecentsView
|
|
|
|
|
*/
|
2020-05-07 14:59:51 -07:00
|
|
|
public class TaskViewSimulator implements TransformParams.BuilderProxy {
|
2020-04-01 20:13:12 -07:00
|
|
|
|
2021-09-03 16:31:29 -07:00
|
|
|
private static final String TAG = "TaskViewSimulator";
|
|
|
|
|
private static final boolean DEBUG = false;
|
2021-08-05 12:54:58 -07:00
|
|
|
|
2020-04-01 20:13:12 -07:00
|
|
|
private final Rect mTmpCropRect = new Rect();
|
|
|
|
|
private final RectF mTempRectF = new RectF();
|
2020-04-27 09:58:01 -07:00
|
|
|
private final float[] mTempPoint = new float[2];
|
2020-04-01 20:13:12 -07:00
|
|
|
|
|
|
|
|
private final Context mContext;
|
2020-05-13 10:29:47 -07:00
|
|
|
private final BaseActivityInterface mSizeStrategy;
|
2020-04-01 20:13:12 -07:00
|
|
|
|
2020-11-05 13:00:56 -08:00
|
|
|
@NonNull
|
|
|
|
|
private RecentsOrientedState mOrientationState;
|
2021-02-03 18:00:30 +00:00
|
|
|
private final boolean mIsRecentsRtl;
|
2020-11-05 13:00:56 -08:00
|
|
|
|
2020-04-01 20:13:12 -07:00
|
|
|
private final Rect mTaskRect = new Rect();
|
|
|
|
|
private final PointF mPivot = new PointF();
|
|
|
|
|
private DeviceProfile mDp;
|
2021-08-05 12:54:58 -07:00
|
|
|
@StagePosition
|
|
|
|
|
private int mStagePosition = STAGE_POSITION_UNDEFINED;
|
2020-04-01 20:13:12 -07:00
|
|
|
|
|
|
|
|
private final Matrix mMatrix = new Matrix();
|
2020-12-11 14:39:50 -08:00
|
|
|
private final Matrix mMatrixTmp = new Matrix();
|
2020-04-01 20:13:12 -07:00
|
|
|
|
|
|
|
|
// Thumbnail view properties
|
|
|
|
|
private final Rect mThumbnailPosition = new Rect();
|
|
|
|
|
private final ThumbnailData mThumbnailData = new ThumbnailData();
|
2020-05-08 08:47:14 -07:00
|
|
|
private final PreviewPositionHelper mPositionHelper = new PreviewPositionHelper();
|
2020-04-01 20:13:12 -07:00
|
|
|
private final Matrix mInversePositionMatrix = new Matrix();
|
|
|
|
|
|
|
|
|
|
// TaskView properties
|
|
|
|
|
private final FullscreenDrawParams mCurrentFullscreenParams;
|
2020-10-23 22:37:51 -07:00
|
|
|
public final AnimatedFloat taskPrimaryTranslation = new AnimatedFloat();
|
|
|
|
|
public final AnimatedFloat taskSecondaryTranslation = new AnimatedFloat();
|
2023-10-03 23:30:41 +02:00
|
|
|
public final AnimatedFloat scrollScale = new AnimatedFloat();
|
2020-04-01 20:13:12 -07:00
|
|
|
|
|
|
|
|
// RecentsView properties
|
2020-05-20 20:34:04 -07:00
|
|
|
public final AnimatedFloat recentsViewScale = new AnimatedFloat();
|
|
|
|
|
public final AnimatedFloat fullScreenProgress = new AnimatedFloat();
|
2020-07-01 17:25:28 -07:00
|
|
|
public final AnimatedFloat recentsViewSecondaryTranslation = new AnimatedFloat();
|
2021-02-22 14:49:27 -08:00
|
|
|
public final AnimatedFloat recentsViewPrimaryTranslation = new AnimatedFloat();
|
2021-04-06 13:03:54 -07:00
|
|
|
public final AnimatedFloat recentsViewScroll = new AnimatedFloat();
|
2020-04-01 20:13:12 -07:00
|
|
|
|
|
|
|
|
// Cached calculations
|
|
|
|
|
private boolean mLayoutValid = false;
|
2020-11-05 13:00:56 -08:00
|
|
|
private int mOrientationStateId;
|
2022-05-27 15:59:40 -07:00
|
|
|
private SplitBounds mSplitBounds;
|
2022-08-31 19:52:24 -07:00
|
|
|
private Boolean mDrawsBelowRecents = null;
|
2021-11-11 17:54:39 +00:00
|
|
|
private boolean mIsGridTask;
|
2023-01-17 09:41:10 -08:00
|
|
|
private boolean mIsDesktopTask;
|
2021-11-19 14:35:46 +00:00
|
|
|
private int mTaskRectTranslationX;
|
|
|
|
|
private int mTaskRectTranslationY;
|
2020-04-01 20:13:12 -07:00
|
|
|
|
2020-05-13 10:29:47 -07:00
|
|
|
public TaskViewSimulator(Context context, BaseActivityInterface sizeStrategy) {
|
2020-04-01 20:13:12 -07:00
|
|
|
mContext = context;
|
2020-04-28 14:17:35 -07:00
|
|
|
mSizeStrategy = sizeStrategy;
|
2020-04-21 13:50:08 -07:00
|
|
|
|
2023-12-14 15:26:43 +08:00
|
|
|
mOrientationState = TraceHelper.allowIpcs("TaskViewSimulator.init",
|
2021-05-03 22:26:52 -07:00
|
|
|
() -> new RecentsOrientedState(context, sizeStrategy, i -> { }));
|
2020-06-30 12:03:48 -07:00
|
|
|
mOrientationState.setGestureActive(true);
|
2020-04-01 20:13:12 -07:00
|
|
|
mCurrentFullscreenParams = new FullscreenDrawParams(context);
|
2020-11-05 13:00:56 -08:00
|
|
|
mOrientationStateId = mOrientationState.getStateId();
|
2021-02-03 18:00:30 +00:00
|
|
|
Resources resources = context.getResources();
|
|
|
|
|
mIsRecentsRtl = mOrientationState.getOrientationHandler().getRecentsRtlSetting(resources);
|
2023-10-03 23:30:41 +02:00
|
|
|
//nick@lmo-20231004 this does belong here to avoid flicker in animation due to race of setting
|
|
|
|
|
// value to 1. other code assumes it starts with 1 anyway, so let's just do it here
|
|
|
|
|
this.scrollScale.value = 1;
|
2020-04-01 20:13:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the device profile for the current state
|
|
|
|
|
*/
|
2020-05-06 02:39:46 -07:00
|
|
|
public void setDp(DeviceProfile dp) {
|
2020-04-01 20:13:12 -07:00
|
|
|
mDp = dp;
|
|
|
|
|
mLayoutValid = false;
|
2021-04-29 00:36:06 +01:00
|
|
|
mOrientationState.setDeviceProfile(dp);
|
2020-04-01 20:13:12 -07:00
|
|
|
}
|
|
|
|
|
|
2020-06-19 16:30:33 -07:00
|
|
|
/**
|
2020-11-05 13:00:56 -08:00
|
|
|
* Sets the orientation state used for this animation
|
2020-06-19 16:30:33 -07:00
|
|
|
*/
|
2020-11-05 13:00:56 -08:00
|
|
|
public void setOrientationState(@NonNull RecentsOrientedState orientationState) {
|
|
|
|
|
mOrientationState = orientationState;
|
2020-06-19 16:30:33 -07:00
|
|
|
mLayoutValid = false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 20:13:12 -07:00
|
|
|
/**
|
|
|
|
|
* @see com.android.quickstep.views.RecentsView#FULLSCREEN_PROGRESS
|
|
|
|
|
*/
|
|
|
|
|
public float getFullScreenScale() {
|
|
|
|
|
if (mDp == null) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2023-01-17 09:41:10 -08:00
|
|
|
|
|
|
|
|
if (mIsDesktopTask) {
|
|
|
|
|
mTaskRect.set(mThumbnailPosition);
|
|
|
|
|
mPivot.set(mTaskRect.centerX(), mTaskRect.centerY());
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-25 18:36:37 +00:00
|
|
|
if (mIsGridTask) {
|
|
|
|
|
mSizeStrategy.calculateGridTaskSize(mContext, mDp, mTaskRect,
|
|
|
|
|
mOrientationState.getOrientationHandler());
|
|
|
|
|
} else {
|
2023-01-16 15:51:13 +00:00
|
|
|
mSizeStrategy.calculateTaskSize(mContext, mDp, mTaskRect,
|
|
|
|
|
mOrientationState.getOrientationHandler());
|
2022-07-25 18:36:37 +00:00
|
|
|
}
|
2021-08-05 12:54:58 -07:00
|
|
|
|
2021-11-11 17:54:39 +00:00
|
|
|
Rect fullTaskSize;
|
2022-05-27 15:59:40 -07:00
|
|
|
if (mSplitBounds != null) {
|
2021-08-05 12:54:58 -07:00
|
|
|
// The task rect changes according to the staged split task sizes, but recents
|
|
|
|
|
// fullscreen scale and pivot remains the same since the task fits into the existing
|
|
|
|
|
// sized task space bounds
|
2021-11-11 17:54:39 +00:00
|
|
|
fullTaskSize = new Rect(mTaskRect);
|
2021-08-24 17:24:49 -07:00
|
|
|
mOrientationState.getOrientationHandler()
|
2022-05-27 15:59:40 -07:00
|
|
|
.setSplitTaskSwipeRect(mDp, mTaskRect, mSplitBounds, mStagePosition);
|
2021-11-19 14:35:46 +00:00
|
|
|
mTaskRect.offset(mTaskRectTranslationX, mTaskRectTranslationY);
|
2021-08-05 12:54:58 -07:00
|
|
|
} else {
|
2021-11-11 17:54:39 +00:00
|
|
|
fullTaskSize = mTaskRect;
|
2021-08-05 12:54:58 -07:00
|
|
|
}
|
2021-11-19 14:35:46 +00:00
|
|
|
fullTaskSize.offset(mTaskRectTranslationX, mTaskRectTranslationY);
|
2021-08-05 12:54:58 -07:00
|
|
|
return mOrientationState.getFullScreenScaleAndPivot(fullTaskSize, mDp, mPivot);
|
2020-04-01 20:13:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the targets which the simulator will control
|
|
|
|
|
*/
|
2022-10-19 16:16:10 -07:00
|
|
|
public void setPreview(RemoteAnimationTarget runningTarget) {
|
|
|
|
|
setPreviewBounds(
|
|
|
|
|
runningTarget.startBounds == null
|
2024-01-26 05:59:47 +08:00
|
|
|
? (Utilities.ATLEAST_R ? runningTarget.screenSpaceBounds : runningTarget.sourceContainerBounds) : runningTarget.startBounds,
|
2022-10-19 16:16:10 -07:00
|
|
|
runningTarget.contentInsets);
|
2020-05-21 18:04:18 -07:00
|
|
|
}
|
2020-04-01 20:13:12 -07:00
|
|
|
|
2021-08-05 12:54:58 -07:00
|
|
|
/**
|
|
|
|
|
* Sets the targets which the simulator will control specifically for targets to animate when
|
|
|
|
|
* in split screen
|
|
|
|
|
*
|
|
|
|
|
* @param splitInfo set to {@code null} when not in staged split mode
|
|
|
|
|
*/
|
2022-10-19 16:16:10 -07:00
|
|
|
public void setPreview(RemoteAnimationTarget runningTarget, SplitBounds splitInfo) {
|
2021-08-05 12:54:58 -07:00
|
|
|
setPreview(runningTarget);
|
2022-05-27 15:59:40 -07:00
|
|
|
mSplitBounds = splitInfo;
|
|
|
|
|
if (mSplitBounds == null) {
|
2021-08-05 12:54:58 -07:00
|
|
|
mStagePosition = STAGE_POSITION_UNDEFINED;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-08-25 11:59:43 -07:00
|
|
|
mStagePosition = mThumbnailPosition.equals(splitInfo.leftTopBounds) ?
|
2021-08-05 12:54:58 -07:00
|
|
|
STAGE_POSITION_TOP_OR_LEFT :
|
|
|
|
|
STAGE_POSITION_BOTTOM_OR_RIGHT;
|
2022-10-18 21:11:51 -07:00
|
|
|
mPositionHelper.setSplitBounds(convertSplitBounds(mSplitBounds), mStagePosition);
|
2021-08-05 12:54:58 -07:00
|
|
|
}
|
|
|
|
|
|
2020-05-21 18:04:18 -07:00
|
|
|
/**
|
|
|
|
|
* Sets the targets which the simulator will control
|
|
|
|
|
*/
|
|
|
|
|
public void setPreviewBounds(Rect bounds, Rect insets) {
|
|
|
|
|
mThumbnailData.insets.set(insets);
|
2020-04-01 20:13:12 -07:00
|
|
|
// TODO: What is this?
|
|
|
|
|
mThumbnailData.windowingMode = WINDOWING_MODE_FULLSCREEN;
|
|
|
|
|
|
2020-05-21 18:04:18 -07:00
|
|
|
mThumbnailPosition.set(bounds);
|
2020-04-01 20:13:12 -07:00
|
|
|
mLayoutValid = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates the scroll for RecentsView
|
|
|
|
|
*/
|
2021-04-06 13:03:54 -07:00
|
|
|
public void setScroll(float scroll) {
|
|
|
|
|
recentsViewScroll.value = scroll;
|
2020-04-01 20:13:12 -07:00
|
|
|
}
|
|
|
|
|
|
2021-11-02 01:50:13 +00:00
|
|
|
public void setDrawsBelowRecents(boolean drawsBelowRecents) {
|
|
|
|
|
mDrawsBelowRecents = drawsBelowRecents;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-11 17:54:39 +00:00
|
|
|
/**
|
|
|
|
|
* Sets whether the task is part of overview grid and not being focused.
|
|
|
|
|
*/
|
|
|
|
|
public void setIsGridTask(boolean isGridTask) {
|
|
|
|
|
mIsGridTask = isGridTask;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-17 09:41:10 -08:00
|
|
|
/**
|
|
|
|
|
* Sets whether this task is part of desktop tasks in overview.
|
|
|
|
|
*/
|
|
|
|
|
public void setIsDesktopTask(boolean desktop) {
|
|
|
|
|
mIsDesktopTask = desktop;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-15 20:02:43 +00:00
|
|
|
/**
|
2021-11-19 14:35:46 +00:00
|
|
|
* Apply translations on TaskRect's starting location.
|
2021-11-15 20:02:43 +00:00
|
|
|
*/
|
2021-11-19 14:35:46 +00:00
|
|
|
public void setTaskRectTranslation(int taskRectTranslationX, int taskRectTranslationY) {
|
|
|
|
|
mTaskRectTranslationX = taskRectTranslationX;
|
|
|
|
|
mTaskRectTranslationY = taskRectTranslationY;
|
2021-11-15 20:02:43 +00:00
|
|
|
}
|
|
|
|
|
|
2020-05-12 15:18:49 -07:00
|
|
|
/**
|
2020-07-27 22:26:53 -07:00
|
|
|
* Adds animation for all the components corresponding to transition from an app to overview.
|
2020-05-12 15:18:49 -07:00
|
|
|
*/
|
|
|
|
|
public void addAppToOverviewAnim(PendingAnimation pa, TimeInterpolator interpolator) {
|
|
|
|
|
pa.addFloat(fullScreenProgress, AnimatedFloat.VALUE, 1, 0, interpolator);
|
|
|
|
|
pa.addFloat(recentsViewScale, AnimatedFloat.VALUE, getFullScreenScale(), 1, interpolator);
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-27 22:26:53 -07:00
|
|
|
/**
|
|
|
|
|
* Adds animation for all the components corresponding to transition from overview to the app.
|
|
|
|
|
*/
|
|
|
|
|
public void addOverviewToAppAnim(PendingAnimation pa, TimeInterpolator interpolator) {
|
|
|
|
|
pa.addFloat(fullScreenProgress, AnimatedFloat.VALUE, 0, 1, interpolator);
|
|
|
|
|
pa.addFloat(recentsViewScale, AnimatedFloat.VALUE, 1, getFullScreenScale(), interpolator);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-07 02:15:56 -07:00
|
|
|
/**
|
|
|
|
|
* Returns the current clipped/visible window bounds in the window coordinate space
|
|
|
|
|
*/
|
|
|
|
|
public RectF getCurrentCropRect() {
|
|
|
|
|
// Crop rect is the inverse of thumbnail matrix
|
2023-02-23 16:33:18 +00:00
|
|
|
mTempRectF.set(0, 0, mTaskRect.width(), mTaskRect.height());
|
2020-05-07 02:15:56 -07:00
|
|
|
mInversePositionMatrix.mapRect(mTempRectF);
|
|
|
|
|
return mTempRectF;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-09 15:35:49 -07:00
|
|
|
/**
|
|
|
|
|
* Returns the current task bounds in the Launcher coordinate space.
|
|
|
|
|
*/
|
|
|
|
|
public RectF getCurrentRect() {
|
|
|
|
|
RectF result = getCurrentCropRect();
|
2020-12-11 14:39:50 -08:00
|
|
|
mMatrixTmp.set(mMatrix);
|
|
|
|
|
preDisplayRotation(mOrientationState.getDisplayRotation(), mDp.widthPx, mDp.heightPx,
|
|
|
|
|
mMatrixTmp);
|
|
|
|
|
mMatrixTmp.mapRect(result);
|
2020-07-09 15:35:49 -07:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-07 02:15:56 -07:00
|
|
|
public RecentsOrientedState getOrientationState() {
|
|
|
|
|
return mOrientationState;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the current transform applied to the window
|
|
|
|
|
*/
|
|
|
|
|
public Matrix getCurrentMatrix() {
|
|
|
|
|
return mMatrix;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Applies the rotation on the matrix to so that it maps from launcher coordinate space to
|
|
|
|
|
* window coordinate space.
|
|
|
|
|
*/
|
|
|
|
|
public void applyWindowToHomeRotation(Matrix matrix) {
|
2021-09-23 16:10:20 -07:00
|
|
|
matrix.postTranslate(mDp.windowX, mDp.windowY);
|
2020-05-07 02:15:56 -07:00
|
|
|
postDisplayRotation(deltaRotation(
|
2020-06-19 16:30:33 -07:00
|
|
|
mOrientationState.getRecentsActivityRotation(),
|
|
|
|
|
mOrientationState.getDisplayRotation()),
|
2020-05-07 02:15:56 -07:00
|
|
|
mDp.widthPx, mDp.heightPx, matrix);
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 20:13:12 -07:00
|
|
|
/**
|
|
|
|
|
* Applies the target to the previously set parameters
|
|
|
|
|
*/
|
|
|
|
|
public void apply(TransformParams params) {
|
2020-05-21 18:04:18 -07:00
|
|
|
if (mDp == null || mThumbnailPosition.isEmpty()) {
|
2020-04-01 20:13:12 -07:00
|
|
|
return;
|
|
|
|
|
}
|
2020-11-05 13:00:56 -08:00
|
|
|
if (!mLayoutValid || mOrientationStateId != mOrientationState.getStateId()) {
|
2020-04-01 20:13:12 -07:00
|
|
|
mLayoutValid = true;
|
2020-11-05 13:00:56 -08:00
|
|
|
mOrientationStateId = mOrientationState.getStateId();
|
2020-04-01 20:13:12 -07:00
|
|
|
|
|
|
|
|
getFullScreenScale();
|
2022-02-01 18:33:52 -08:00
|
|
|
if (TaskAnimationManager.SHELL_TRANSITIONS_ROTATION) {
|
2021-12-03 05:20:24 +00:00
|
|
|
// With shell transitions, the display is rotated early so we need to actually use
|
|
|
|
|
// the rotation when the gesture starts
|
|
|
|
|
mThumbnailData.rotation = mOrientationState.getTouchRotation();
|
|
|
|
|
} else {
|
|
|
|
|
mThumbnailData.rotation = mOrientationState.getDisplayRotation();
|
|
|
|
|
}
|
2020-04-01 20:13:12 -07:00
|
|
|
|
2021-03-09 13:08:06 +00:00
|
|
|
// mIsRecentsRtl is the inverse of TaskView RTL.
|
|
|
|
|
boolean isRtlEnabled = !mIsRecentsRtl;
|
2020-05-08 08:47:14 -07:00
|
|
|
mPositionHelper.updateThumbnailMatrix(
|
2022-09-23 12:04:18 +01:00
|
|
|
mThumbnailPosition, mThumbnailData, mTaskRect.width(), mTaskRect.height(),
|
2023-03-23 21:38:49 -07:00
|
|
|
mDp.widthPx, mDp.heightPx, mDp.taskbarHeight, mDp.isTablet,
|
2022-09-23 12:04:18 +01:00
|
|
|
mOrientationState.getRecentsActivityRotation(), isRtlEnabled);
|
2020-04-01 20:13:12 -07:00
|
|
|
mPositionHelper.getMatrix().invert(mInversePositionMatrix);
|
2021-08-05 12:54:58 -07:00
|
|
|
if (DEBUG) {
|
2021-09-24 15:37:30 -07:00
|
|
|
Log.d(TAG, " taskRect: " + mTaskRect);
|
2021-08-05 12:54:58 -07:00
|
|
|
}
|
2020-04-01 20:13:12 -07:00
|
|
|
}
|
|
|
|
|
|
2021-02-03 18:00:30 +00:00
|
|
|
float fullScreenProgress = Utilities.boundToRange(this.fullScreenProgress.value, 0, 1);
|
2023-10-03 23:30:41 +02:00
|
|
|
float scrollScale = this.scrollScale.value * (1f - fullScreenProgress) + fullScreenProgress;
|
2021-09-08 13:57:41 +00:00
|
|
|
mCurrentFullscreenParams.setProgress(fullScreenProgress, recentsViewScale.value,
|
|
|
|
|
/* taskViewScale= */1f, mTaskRect.width(), mDp, mPositionHelper);
|
2020-04-01 20:13:12 -07:00
|
|
|
|
|
|
|
|
// Apply thumbnail matrix
|
|
|
|
|
float taskWidth = mTaskRect.width();
|
|
|
|
|
float taskHeight = mTaskRect.height();
|
|
|
|
|
|
|
|
|
|
mMatrix.set(mPositionHelper.getMatrix());
|
|
|
|
|
|
2021-11-15 20:02:43 +00:00
|
|
|
// Apply TaskView matrix: taskRect, translate
|
2020-10-23 22:37:51 -07:00
|
|
|
mMatrix.postTranslate(mTaskRect.left, mTaskRect.top);
|
2023-10-03 23:30:41 +02:00
|
|
|
mMatrix.postScale(scrollScale, scrollScale, mTaskRect.left + (mTaskRect.width() / 2),
|
|
|
|
|
mTaskRect.top + (mTaskRect.height() / 2));
|
2021-11-19 14:35:46 +00:00
|
|
|
mOrientationState.getOrientationHandler().setPrimary(mMatrix, MATRIX_POST_TRANSLATE,
|
2020-10-23 22:37:51 -07:00
|
|
|
taskPrimaryTranslation.value);
|
|
|
|
|
mOrientationState.getOrientationHandler().setSecondary(mMatrix, MATRIX_POST_TRANSLATE,
|
|
|
|
|
taskSecondaryTranslation.value);
|
2021-11-19 14:35:46 +00:00
|
|
|
mOrientationState.getOrientationHandler().setPrimary(
|
|
|
|
|
mMatrix, MATRIX_POST_TRANSLATE, recentsViewScroll.value);
|
2020-04-01 20:13:12 -07:00
|
|
|
|
2020-07-01 17:25:28 -07:00
|
|
|
// Apply RecentsView matrix
|
2020-04-01 20:13:12 -07:00
|
|
|
mMatrix.postScale(recentsViewScale.value, recentsViewScale.value, mPivot.x, mPivot.y);
|
2020-07-01 17:25:28 -07:00
|
|
|
mOrientationState.getOrientationHandler().setSecondary(mMatrix, MATRIX_POST_TRANSLATE,
|
|
|
|
|
recentsViewSecondaryTranslation.value);
|
2021-11-19 14:35:46 +00:00
|
|
|
mOrientationState.getOrientationHandler().setPrimary(mMatrix, MATRIX_POST_TRANSLATE,
|
2021-02-22 14:49:27 -08:00
|
|
|
recentsViewPrimaryTranslation.value);
|
2020-05-07 02:15:56 -07:00
|
|
|
applyWindowToHomeRotation(mMatrix);
|
2020-04-01 20:13:12 -07:00
|
|
|
|
|
|
|
|
// Crop rect is the inverse of thumbnail matrix
|
2023-02-23 16:33:18 +00:00
|
|
|
mTempRectF.set(0, 0, taskWidth, taskHeight);
|
2020-04-01 20:13:12 -07:00
|
|
|
mInversePositionMatrix.mapRect(mTempRectF);
|
|
|
|
|
mTempRectF.roundOut(mTmpCropRect);
|
|
|
|
|
|
2023-12-14 15:26:43 +08:00
|
|
|
params.setProgress(1f - fullScreenProgress);
|
2020-05-07 14:59:51 -07:00
|
|
|
params.applySurfaceParams(params.createSurfaceParams(this));
|
2021-08-05 12:54:58 -07:00
|
|
|
|
|
|
|
|
if (!DEBUG) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Log.d(TAG, "progress: " + fullScreenProgress
|
|
|
|
|
+ " recentsViewScale: " + recentsViewScale.value
|
|
|
|
|
+ " crop: " + mTmpCropRect
|
|
|
|
|
+ " radius: " + getCurrentCornerRadius()
|
|
|
|
|
+ " taskW: " + taskWidth + " H: " + taskHeight
|
|
|
|
|
+ " taskRect: " + mTaskRect
|
|
|
|
|
+ " taskPrimaryT: " + taskPrimaryTranslation.value
|
|
|
|
|
+ " recentsPrimaryT: " + recentsViewPrimaryTranslation.value
|
|
|
|
|
+ " recentsSecondaryT: " + recentsViewSecondaryTranslation.value
|
|
|
|
|
+ " taskSecondaryT: " + taskSecondaryTranslation.value
|
|
|
|
|
+ " recentsScroll: " + recentsViewScroll.value
|
2023-10-03 23:30:41 +02:00
|
|
|
+ " scrollScale: " + scrollScale
|
|
|
|
|
+ " this.scrollScale.value: " + this.scrollScale.value
|
2021-08-05 12:54:58 -07:00
|
|
|
+ " pivot: " + mPivot
|
|
|
|
|
);
|
2020-05-07 14:59:51 -07:00
|
|
|
}
|
2020-04-01 20:13:12 -07:00
|
|
|
|
2020-05-07 14:59:51 -07:00
|
|
|
@Override
|
2020-05-12 15:18:49 -07:00
|
|
|
public void onBuildTargetParams(
|
2022-10-19 16:16:10 -07:00
|
|
|
SurfaceProperties builder, RemoteAnimationTarget app, TransformParams params) {
|
2022-10-17 22:48:03 +00:00
|
|
|
builder.setMatrix(mMatrix)
|
|
|
|
|
.setWindowCrop(mTmpCropRect)
|
|
|
|
|
.setCornerRadius(getCurrentCornerRadius());
|
2021-11-02 01:50:13 +00:00
|
|
|
|
2022-08-31 19:52:24 -07:00
|
|
|
// If mDrawsBelowRecents is unset, no reordering will be enforced.
|
2022-09-28 18:56:42 -07:00
|
|
|
if (mDrawsBelowRecents != null) {
|
2022-07-22 23:23:12 +00:00
|
|
|
// In legacy transitions, the animation leashes remain in same hierarchy in the
|
|
|
|
|
// TaskDisplayArea, so we don't want to bump the layer too high otherwise it will
|
|
|
|
|
// conflict with layers that WM core positions (ie. the input consumers). For shell
|
|
|
|
|
// transitions, the animation leashes are reparented to an animation container so we
|
|
|
|
|
// can bump layers as needed.
|
2023-08-23 18:29:52 +02:00
|
|
|
builder.setLayer(0);
|
2021-11-02 01:50:13 +00:00
|
|
|
}
|
2020-04-01 20:13:12 -07:00
|
|
|
}
|
|
|
|
|
|
2020-04-27 09:58:01 -07:00
|
|
|
/**
|
|
|
|
|
* Returns the corner radius that should be applied to the target so that it matches the
|
|
|
|
|
* TaskView
|
|
|
|
|
*/
|
|
|
|
|
public float getCurrentCornerRadius() {
|
|
|
|
|
float visibleRadius = mCurrentFullscreenParams.mCurrentDrawnCornerRadius;
|
|
|
|
|
mTempPoint[0] = visibleRadius;
|
|
|
|
|
mTempPoint[1] = 0;
|
|
|
|
|
mInversePositionMatrix.mapVectors(mTempPoint);
|
|
|
|
|
|
|
|
|
|
// Ideally we should use square-root. This is an optimization as one of the dimension is 0.
|
|
|
|
|
return Math.max(Math.abs(mTempPoint[0]), Math.abs(mTempPoint[1]));
|
|
|
|
|
}
|
2020-05-18 14:02:49 -07:00
|
|
|
|
2022-10-18 21:11:51 -07:00
|
|
|
/**
|
|
|
|
|
* TODO(b/254378592): Remove this after consolidation of classes
|
|
|
|
|
*/
|
|
|
|
|
public static com.android.wm.shell.util.SplitBounds convertSplitBounds(SplitBounds bounds) {
|
|
|
|
|
return new com.android.wm.shell.util.SplitBounds(
|
|
|
|
|
bounds.leftTopBounds,
|
|
|
|
|
bounds.rightBottomBounds,
|
|
|
|
|
bounds.leftTopTaskId,
|
|
|
|
|
bounds.rightBottomTaskId
|
|
|
|
|
);
|
|
|
|
|
}
|
2020-04-01 20:13:12 -07:00
|
|
|
}
|