Merge changes Ia9df40ae,Ieeaa5b66 into ub-launcher3-master

* changes:
  Move params for ClipAnimationHelper#applyTransform into TransformParams
  TaskView has fullscreen progress instead of boolean
This commit is contained in:
Tony Wickham 2018-12-22 00:15:09 +00:00 committed by Android (Google) Code Review
commit 79e70c3a82
8 changed files with 138 additions and 61 deletions

View File

@ -343,14 +343,15 @@ public class OverviewCommandHelper {
clipHelper.updateTargetRect(targetRect);
clipHelper.prepareAnimation(false /* isOpening */);
SyncRtSurfaceTransactionApplier syncTransactionApplier =
new SyncRtSurfaceTransactionApplier(rootView);
ClipAnimationHelper.TransformParams params = new ClipAnimationHelper.TransformParams()
.setSyncTransactionApplier(new SyncRtSurfaceTransactionApplier(rootView));
ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1);
valueAnimator.setDuration(RECENTS_LAUNCH_DURATION);
valueAnimator.setInterpolator(TOUCH_RESPONSE_INTERPOLATOR);
valueAnimator.addUpdateListener((v) ->
clipHelper.applyTransform(targetSet, (float) v.getAnimatedValue(),
syncTransactionApplier));
valueAnimator.addUpdateListener((v) -> {
params.setProgress((float) v.getAnimatedValue());
clipHelper.applyTransform(targetSet, params);
});
if (targetSet.isAnimatingHome()) {
// If we are animating home, fade in the opening targets

View File

@ -126,11 +126,13 @@ public class QuickScrubController implements OnAlarmListener {
if (mIsQuickSwitch) {
mShouldSwitchToNext = true;
mPrevProgressDelta = 0;
if (mRecentsView.getTaskViewCount() > 0) {
mRecentsView.getTaskViewAt(0).setFullscreen(true);
TaskView runningTaskView = mRecentsView.getRunningTaskView();
TaskView nextTaskView = mRecentsView.getNextTaskView();
if (runningTaskView != null) {
runningTaskView.setFullscreenProgress(1);
}
if (mRecentsView.getTaskViewCount() > 1) {
mRecentsView.getTaskViewAt(1).setFullscreen(true);
if (nextTaskView != null) {
nextTaskView.setFullscreenProgress(1);
}
}
@ -161,11 +163,13 @@ public class QuickScrubController implements OnAlarmListener {
mWaitingForTaskLaunch = false;
if (mIsQuickSwitch) {
mIsQuickSwitch = false;
if (mRecentsView.getTaskViewCount() > 0) {
mRecentsView.getTaskViewAt(0).setFullscreen(false);
TaskView runningTaskView = mRecentsView.getRunningTaskView();
TaskView nextTaskView = mRecentsView.getNextTaskView();
if (runningTaskView != null) {
runningTaskView.setFullscreenProgress(0);
}
if (mRecentsView.getTaskViewCount() > 1) {
mRecentsView.getTaskViewAt(1).setFullscreen(false);
if (nextTaskView != null) {
nextTaskView.setFullscreenProgress(0);
}
}
@ -267,12 +271,12 @@ public class QuickScrubController implements OnAlarmListener {
public void onQuickScrubProgress(float progress) {
if (mIsQuickSwitch) {
TaskView currentPage = mRecentsView.getTaskViewAt(0);
TaskView nextPage = mRecentsView.getTaskViewAt(1);
TaskView currentPage = mRecentsView.getRunningTaskView();
TaskView nextPage = mRecentsView.getNextTaskView();
if (currentPage == null || nextPage == null) {
return;
}
if (!mFinishedTransitionToQuickScrub) {
if (!mFinishedTransitionToQuickScrub || mStartProgress <= 0) {
mStartProgress = mEndProgress = progress;
} else {
float progressDelta = progress - mEndProgress;

View File

@ -145,8 +145,8 @@ public class TaskUtils {
*/
public static ValueAnimator getRecentsWindowAnimator(TaskView v, boolean skipViewChanges,
RemoteAnimationTargetCompat[] targets, final ClipAnimationHelper inOutHelper) {
SyncRtSurfaceTransactionApplier syncTransactionApplier =
new SyncRtSurfaceTransactionApplier(v);
ClipAnimationHelper.TransformParams params = new ClipAnimationHelper.TransformParams()
.setSyncTransactionApplier(new SyncRtSurfaceTransactionApplier(v));
final ValueAnimator appAnimator = ValueAnimator.ofFloat(0, 1);
appAnimator.setInterpolator(TOUCH_RESPONSE_INTERPOLATOR);
appAnimator.addUpdateListener(new MultiValueUpdateListener() {
@ -174,8 +174,8 @@ public class TaskUtils {
@Override
public void onUpdate(float percent) {
RectF taskBounds = inOutHelper.applyTransform(mTargetSet, 1 - percent,
syncTransactionApplier);
params.setProgress(1 - percent);
RectF taskBounds = inOutHelper.applyTransform(mTargetSet, params);
if (!skipViewChanges) {
float scale = taskBounds.width() / mThumbnailRect.width();
v.setScaleX(scale);

View File

@ -52,6 +52,7 @@ import android.view.animation.Interpolator;
import androidx.annotation.AnyThread;
import androidx.annotation.UiThread;
import androidx.annotation.WorkerThread;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.DeviceProfile;
@ -176,6 +177,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
Math.min(1 / MIN_PROGRESS_FOR_OVERVIEW, 1 / (1 - MIN_PROGRESS_FOR_OVERVIEW));
private final ClipAnimationHelper mClipAnimationHelper;
private final ClipAnimationHelper.TransformParams mTransformParams;
protected Runnable mGestureEndCallback;
protected boolean mIsGoingToHome;
@ -256,6 +258,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
mRecentsAnimationWrapper = new RecentsAnimationWrapper(inputConsumer,
this::createNewTouchProxyHandler);
mClipAnimationHelper = new ClipAnimationHelper(context);
mTransformParams = new ClipAnimationHelper.TransformParams();
initStateCallbacks();
}
@ -584,11 +587,13 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
RecentsAnimationControllerCompat controller = mRecentsAnimationWrapper.getController();
if (controller != null) {
mClipAnimationHelper.applyTransform(mRecentsAnimationWrapper.targetSet, shift,
Looper.myLooper() == mMainThreadHandler.getLooper()
SyncRtSurfaceTransactionApplier syncTransactionApplier
= Looper.myLooper() == mMainThreadHandler.getLooper()
? mSyncTransactionApplier
: null);
: null;
mTransformParams.setProgress(shift).setSyncTransactionApplier(syncTransactionApplier);
mClipAnimationHelper.applyTransform(mRecentsAnimationWrapper.targetSet,
mTransformParams);
boolean passedThreshold = shift > 1 - UPDATE_SYSUI_FLAGS_THRESHOLD;
mRecentsAnimationWrapper.setAnimationTargetsBehindSystemBars(!passedThreshold);
@ -615,6 +620,11 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
}
}
// Update insets of the next previous task, as we might switch to it.
TaskView nextTaskView = mRecentsView == null ? null : mRecentsView.getNextTaskView();
if (mInteractionType == INTERACTION_NORMAL && nextTaskView != null) {
nextTaskView.setFullscreenProgress(1 - mCurrentShift.value);
}
if (mLauncherTransitionController == null || mLauncherTransitionController
.getAnimationPlayer().isStarted()) {

View File

@ -151,14 +151,13 @@ public class ClipAnimationHelper {
mBoostModeTargetLayers = isOpening ? MODE_OPENING : MODE_CLOSING;
}
public RectF applyTransform(RemoteAnimationTargetSet targetSet, float progress,
@Nullable SyncRtSurfaceTransactionApplier syncTransactionApplier) {
public RectF applyTransform(RemoteAnimationTargetSet targetSet, TransformParams params) {
RectF currentRect;
mTmpRectF.set(mTargetRect);
Utilities.scaleRectFAboutCenter(mTmpRectF, mTargetScale);
float offsetYProgress = mOffsetYInterpolator.getInterpolation(progress);
progress = mInterpolator.getInterpolation(progress);
currentRect = mRectFEvaluator.evaluate(progress, mSourceRect, mTmpRectF);
float offsetYProgress = mOffsetYInterpolator.getInterpolation(params.progress);
float progress = mInterpolator.getInterpolation(params.progress);
currentRect = mRectFEvaluator.evaluate(progress, mSourceRect, mTmpRectF);
synchronized (mTargetOffset) {
// Stay lined up with the center of the target, since it moves for quick scrub.
@ -173,7 +172,7 @@ public class ClipAnimationHelper {
mClipRectF.bottom =
mSourceStackBounds.height() - (mSourceWindowClipInsets.bottom * progress);
SurfaceParams[] params = new SurfaceParams[targetSet.unfilteredApps.length];
SurfaceParams[] surfaceParams = new SurfaceParams[targetSet.unfilteredApps.length];
for (int i = 0; i < targetSet.unfilteredApps.length; i++) {
RemoteAnimationTargetCompat app = targetSet.unfilteredApps[i];
mTmpMatrix.setTranslate(app.position.x, app.position.y);
@ -206,10 +205,10 @@ public class ClipAnimationHelper {
// Since radius is in Surface space, but we draw the rounded corners in screen space, we
// have to undo the scale.
params[i] = new SurfaceParams(app.leash, alpha, mTmpMatrix, crop, layer,
surfaceParams[i] = new SurfaceParams(app.leash, alpha, mTmpMatrix, crop, layer,
cornerRadius / scale);
}
applyParams(syncTransactionApplier, params);
applySurfaceParams(params.syncTransactionApplier, surfaceParams);
return currentRect;
}
@ -218,8 +217,8 @@ public class ClipAnimationHelper {
return mCurrentRectWithInsets;
}
private void applyParams(@Nullable SyncRtSurfaceTransactionApplier syncTransactionApplier,
SurfaceParams[] params) {
private void applySurfaceParams(@Nullable SyncRtSurfaceTransactionApplier
syncTransactionApplier, SurfaceParams[] params) {
if (syncTransactionApplier != null) {
syncTransactionApplier.scheduleApply(params);
} else {
@ -350,4 +349,23 @@ public class ClipAnimationHelper {
public float getCurrentCornerRadius() {
return mCurrentCornerRadius;
}
public static class TransformParams {
float progress;
SyncRtSurfaceTransactionApplier syncTransactionApplier;
public TransformParams() {
progress = 0;
}
public TransformParams setProgress(float progress) {
this.progress = progress;
return this;
}
public TransformParams setSyncTransactionApplier(SyncRtSurfaceTransactionApplier applier) {
this.syncTransactionApplier = applier;
return this;
}
}
}

View File

@ -760,14 +760,14 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
if (runningTaskView == null) {
// Launch the first task
if (getTaskViewCount() > 0) {
((TaskView) getChildAt(0)).launchTask(true /* animate */);
getTaskViewAt(0).launchTask(true /* animate */);
}
} else {
// Get the next launch task
int runningTaskIndex = indexOfChild(runningTaskView);
int nextTaskIndex = Math.max(0, Math.min(getTaskViewCount() - 1, runningTaskIndex + 1));
if (nextTaskIndex < getTaskViewCount()) {
((TaskView) getChildAt(nextTaskIndex)).launchTask(true /* animate */);
TaskView nextTaskView = getNextTaskView();
if (nextTaskView != null) {
nextTaskView.launchTask(true /* animate */);
} else {
runningTaskView.launchTask(true /* animate */);
}
}
}
@ -1140,6 +1140,19 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
child.setAlpha(mContentAlpha);
}
/**
* @return The most recent task that is older than the currently running task. If there is
* currently no running task or there is no task older than it, then return null.
*/
@Nullable
public TaskView getNextTaskView() {
TaskView runningTaskView = getRunningTaskView();
if (runningTaskView == null) {
return null;
}
return getTaskViewAt(indexOfChild(runningTaskView) + 1);
}
public TaskView getTaskViewAt(int index) {
View child = getChildAt(index);
return child == mClearAllButton ? null : (TaskView) child;
@ -1261,12 +1274,14 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
toScale, toTranslationY);
scaleAndTranslation[1] = -scaleAndTranslation[1];
anim.play(createAnimForChild(adjacentTask, scaleAndTranslation));
anim.play(ObjectAnimator.ofFloat(adjacentTask, TaskView.FULLSCREEN_PROGRESS, 1));
}
if (taskIndex + 1 < getTaskViewCount()) {
TaskView adjacentTask = getTaskViewAt(taskIndex + 1);
float[] scaleAndTranslation = getAdjacentScaleAndTranslation(centerTask,
toScale, toTranslationY);
anim.play(createAnimForChild(adjacentTask, scaleAndTranslation));
anim.play(ObjectAnimator.ofFloat(adjacentTask, TaskView.FULLSCREEN_PROGRESS, 1));
}
} else {
// We are launching an adjacent task, so parallax the center and other adjacent task.

View File

@ -81,6 +81,7 @@ public class TaskThumbnailView extends View {
private float mClipBottom = -1;
private Rect mScaledInsets = new Rect();
private boolean mIsRotated;
private Task mTask;
private ThumbnailData mThumbnailData;
@ -144,7 +145,7 @@ public class TaskThumbnailView extends View {
/**
* Sets the alpha of the dim layer on top of this view.
*
* <p>
* If dimAlpha is 0, no dimming is applied; if dimAlpha is 1, the thumbnail will be black.
*/
public void setDimAlpha(float dimAlpha) {
@ -188,13 +189,18 @@ public class TaskThumbnailView extends View {
@Override
protected void onDraw(Canvas canvas) {
if (((TaskView) getParent()).isFullscreen()) {
float fullscreenProgress = ((TaskView) getParent()).getFullscreenProgress();
if (mIsRotated) {
// Don't show insets in the wrong orientation.
fullscreenProgress = 0;
}
if (fullscreenProgress > 0) {
// Draw the insets if we're being drawn fullscreen (we do this for quick switch).
drawOnCanvas(canvas,
-mScaledInsets.left,
-mScaledInsets.top,
getMeasuredWidth() + mScaledInsets.right,
getMeasuredHeight() + mScaledInsets.bottom,
-mScaledInsets.left * fullscreenProgress,
-mScaledInsets.top * fullscreenProgress,
getMeasuredWidth() + mScaledInsets.right * fullscreenProgress,
getMeasuredHeight() + mScaledInsets.bottom * fullscreenProgress,
mCornerRadius);
} else {
drawOnCanvas(canvas, 0, 0, getMeasuredWidth(), getMeasuredHeight(), mCornerRadius);
@ -241,11 +247,11 @@ public class TaskThumbnailView extends View {
}
private void updateThumbnailMatrix() {
boolean rotate = false;
mIsRotated = false;
mClipBottom = -1;
if (mBitmapShader != null && mThumbnailData != null) {
float scale = mThumbnailData.scale;
Rect thumbnailInsets = mThumbnailData.insets;
Rect thumbnailInsets = mThumbnailData.insets;
final float thumbnailWidth = mThumbnailData.thumbnail.getWidth() -
(thumbnailInsets.left + thumbnailInsets.right) * scale;
final float thumbnailHeight = mThumbnailData.thumbnail.getHeight() -
@ -262,12 +268,12 @@ public class TaskThumbnailView extends View {
final Configuration configuration =
getContext().getResources().getConfiguration();
// Rotate the screenshot if not in multi-window mode
rotate = FeatureFlags.OVERVIEW_USE_SCREENSHOT_ORIENTATION &&
mIsRotated = FeatureFlags.OVERVIEW_USE_SCREENSHOT_ORIENTATION &&
configuration.orientation != mThumbnailData.orientation &&
!mActivity.isInMultiWindowModeCompat() &&
mThumbnailData.windowingMode == WINDOWING_MODE_FULLSCREEN;
// Scale the screenshot to always fit the width of the card.
thumbnailScale = rotate
thumbnailScale = mIsRotated
? getMeasuredWidth() / thumbnailHeight
: getMeasuredWidth() / thumbnailWidth;
}
@ -275,7 +281,7 @@ public class TaskThumbnailView extends View {
mScaledInsets.set(thumbnailInsets);
Utilities.scaleRect(mScaledInsets, thumbnailScale);
if (rotate) {
if (mIsRotated) {
int rotationDir = profile.isVerticalBarLayout() && !profile.isSeascape() ? -1 : 1;
mMatrix.setRotate(90 * rotationDir);
int newLeftInset = rotationDir == 1 ? thumbnailInsets.bottom : thumbnailInsets.top;
@ -299,7 +305,7 @@ public class TaskThumbnailView extends View {
mMatrix.postScale(thumbnailScale, thumbnailScale);
mBitmapShader.setLocalMatrix(mMatrix);
float bitmapHeight = Math.max((rotate ? thumbnailWidth : thumbnailHeight)
float bitmapHeight = Math.max((mIsRotated ? thumbnailWidth : thumbnailHeight)
* thumbnailScale, 0);
if (Math.round(bitmapHeight) < getMeasuredHeight()) {
mClipBottom = bitmapHeight;
@ -307,7 +313,7 @@ public class TaskThumbnailView extends View {
mPaint.setShader(mBitmapShader);
}
if (rotate) {
if (mIsRotated) {
// The overlay doesn't really work when the screenshot is rotated, so don't add it.
mOverlay.reset();
} else {

View File

@ -102,6 +102,19 @@ public class TaskView extends FrameLayout implements PageCallbacks {
}
};
public static final FloatProperty<TaskView> FULLSCREEN_PROGRESS =
new FloatProperty<TaskView>("fullscreenProgress") {
@Override
public void setValue(TaskView taskView, float v) {
taskView.setFullscreenProgress(v);
}
@Override
public Float get(TaskView taskView) {
return taskView.mFullscreenProgress;
}
};
private static final FloatProperty<TaskView> FOCUS_TRANSITION =
new FloatProperty<TaskView>("focusTransition") {
@Override
@ -140,7 +153,7 @@ public class TaskView extends FrameLayout implements PageCallbacks {
private DigitalWellBeingToast mDigitalWellBeingToast;
private float mCurveScale;
private float mZoomScale;
private boolean mIsFullscreen;
private float mFullscreenProgress;
private Animator mIconAndDimAnimator;
private float mFocusTransitionProgress = 1;
@ -341,6 +354,10 @@ public class TaskView extends FrameLayout implements PageCallbacks {
setTranslationZ(0);
setAlpha(1f);
setIconScaleAndDim(1);
if (!getRecentsView().getQuickScrubController().isQuickSwitch()) {
// Reset full screen progress unless we are doing back to back quick switch.
setFullscreenProgress(0);
}
}
@Override
@ -499,15 +516,21 @@ public class TaskView extends FrameLayout implements PageCallbacks {
/**
* Hides the icon and shows insets when this TaskView is about to be shown fullscreen.
* @param progress: 0 = show icon and no insets; 1 = don't show icon and show full insets.
*/
public void setFullscreen(boolean isFullscreen) {
mIsFullscreen = isFullscreen;
mIconView.setVisibility(mIsFullscreen ? INVISIBLE : VISIBLE);
setClipChildren(!mIsFullscreen);
setClipToPadding(!mIsFullscreen);
public void setFullscreenProgress(float progress) {
if (progress == mFullscreenProgress) {
return;
}
mFullscreenProgress = progress;
boolean isFullscreen = mFullscreenProgress > 0;
mIconView.setVisibility(isFullscreen ? INVISIBLE : VISIBLE);
setClipChildren(!isFullscreen);
setClipToPadding(!isFullscreen);
getThumbnail().invalidate();
}
public boolean isFullscreen() {
return mIsFullscreen;
public float getFullscreenProgress() {
return mFullscreenProgress;
}
}