Support Live Tile in Quickstep (Pt1) - Z ordering

- Place Launcher above app surface.
- Use LauncherLayoutListener to clear the area where the current task is in order to punch a hole and reveal the app view underneath

Bug: 111697218
Test: Manual test

Change-Id: I4d4e0f1113a8e60566257c030ae9b591789eb3b3
This commit is contained in:
Tracy Zhou 2018-10-16 14:49:55 -07:00
parent e3f664db79
commit d43e7c2fd4
7 changed files with 75 additions and 22 deletions

View File

@ -15,6 +15,7 @@
*/
package com.android.launcher3.uioverrides;
import static com.android.launcher3.AbstractFloatingView.TYPE_QUICKSTEP_PREVIEW;
import static com.android.launcher3.LauncherAnimUtils.ALL_APPS_TRANSITION_MS;
import static com.android.launcher3.anim.Interpolators.DEACCEL_2;
@ -44,7 +45,7 @@ public class AllAppsState extends LauncherState {
@Override
public void onStateEnabled(Launcher launcher) {
AbstractFloatingView.closeAllOpenViews(launcher);
AbstractFloatingView.closeAllOpenViewsExcept(launcher, TYPE_QUICKSTEP_PREVIEW);
dispatchWindowStateChanged(launcher);
}

View File

@ -15,6 +15,7 @@
*/
package com.android.launcher3.uioverrides;
import static com.android.launcher3.AbstractFloatingView.TYPE_QUICKSTEP_PREVIEW;
import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
import static com.android.launcher3.anim.Interpolators.DEACCEL_2;
import static com.android.launcher3.states.RotationHelper.REQUEST_ROTATE;
@ -74,7 +75,7 @@ public class OverviewState extends LauncherState {
public void onStateEnabled(Launcher launcher) {
RecentsView rv = launcher.getOverviewPanel();
rv.setOverviewStateEnabled(true);
AbstractFloatingView.closeAllOpenViews(launcher);
AbstractFloatingView.closeAllOpenViewsExcept(launcher, TYPE_QUICKSTEP_PREVIEW);
}
@Override

View File

@ -40,6 +40,7 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
@ -537,6 +538,9 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {
@Override
public void finish() { }
@Override
public void update(boolean shouldFinish, boolean isLongSwipe, RectF currentRect) { }
};
}
@ -613,6 +617,8 @@ public interface ActivityControlHelper<T extends BaseDraggingActivity> {
void setHandler(WindowTransformSwipeHandler handler);
void finish();
void update(boolean shouldFinish, boolean isLongSwipe, RectF currentRect);
}
interface ActivityInitListener {

View File

@ -597,6 +597,11 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
}
private void updateFinalShiftUi() {
if (mRecentsAnimationWrapper.getController() != null && mLayoutListener != null) {
mLayoutListener.update(mCurrentShift.value > 1, mUiLongSwipeMode,
mClipAnimationHelper.getCurrentRectWithInsets());
}
final boolean passed = mCurrentShift.value >= MIN_PROGRESS_FOR_OVERVIEW;
if (passed != mPassedOverviewThreshold) {
mPassedOverviewThreshold = passed;
@ -874,7 +879,6 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
mLayoutListener.finish();
mActivityControlHelper.getAlphaProperty(mActivity).setValue(1);
mRecentsView.setRunningTaskHidden(false);
mRecentsView.setRunningTaskIconScaledDown(false);
mQuickScrubController.cancelActiveQuickscrub();
}
@ -895,6 +899,7 @@ public class WindowTransformSwipeHandler<T extends BaseDraggingActivity> {
if (mWasLauncherAlreadyVisible && mLauncherTransitionController != null) {
mLauncherTransitionController.setPlayFraction(1);
}
mRecentsView.setRunningTaskHidden(false);
}
private void switchToScreenshot() {

View File

@ -77,10 +77,11 @@ public class ClipAnimationHelper {
public final Rect mHomeStackBounds = new Rect();
// The clip rect in source app window coordinates
private final Rect mClipRect = new Rect();
private final RectF mClipRectF = new RectF();
private final RectFEvaluator mRectFEvaluator = new RectFEvaluator();
private final Matrix mTmpMatrix = new Matrix();
private final RectF mTmpRectF = new RectF();
private final RectF mCurrentRectWithInsets = new RectF();
private float mTargetScale = 1f;
private float mOffsetScale = 1f;
@ -153,12 +154,12 @@ public class ClipAnimationHelper {
mTargetOffset.y * offsetYProgress);
}
mClipRect.left = (int) (mSourceWindowClipInsets.left * progress);
mClipRect.top = (int) (mSourceWindowClipInsets.top * progress);
mClipRect.right = (int)
(mSourceStackBounds.width() - (mSourceWindowClipInsets.right * progress));
mClipRect.bottom = (int)
(mSourceStackBounds.height() - (mSourceWindowClipInsets.bottom * progress));
mClipRectF.left = mSourceWindowClipInsets.left * progress;
mClipRectF.top = mSourceWindowClipInsets.top * progress;
mClipRectF.right =
mSourceStackBounds.width() - (mSourceWindowClipInsets.right * progress);
mClipRectF.bottom =
mSourceStackBounds.height() - (mSourceWindowClipInsets.bottom * progress);
SurfaceParams[] params = new SurfaceParams[targetSet.unfilteredApps.length];
for (int i = 0; i < targetSet.unfilteredApps.length; i++) {
@ -166,11 +167,12 @@ public class ClipAnimationHelper {
mTmpMatrix.setTranslate(app.position.x, app.position.y);
Rect crop = app.sourceContainerBounds;
float alpha = 1f;
int layer;
if (app.mode == targetSet.targetMode) {
if (app.activityType != RemoteAnimationTargetCompat.ACTIVITY_TYPE_HOME) {
mTmpMatrix.setRectToRect(mSourceRect, currentRect, ScaleToFit.FILL);
mTmpMatrix.postTranslate(app.position.x, app.position.y);
crop = mClipRect;
mClipRectF.roundOut(crop);
}
if (app.isNotInRecents
@ -179,17 +181,22 @@ public class ClipAnimationHelper {
}
alpha = mTaskAlphaCallback.apply(app, alpha);
layer = RemoteAnimationProvider.getLayer(app, mBoostModeTargetLayers);
} else {
crop = null;
layer = Integer.MAX_VALUE;
}
params[i] = new SurfaceParams(app.leash, alpha, mTmpMatrix, crop,
RemoteAnimationProvider.getLayer(app, mBoostModeTargetLayers));
params[i] = new SurfaceParams(app.leash, alpha, mTmpMatrix, crop, layer);
}
applyParams(syncTransactionApplier, params);
return currentRect;
}
public RectF getCurrentRectWithInsets() {
mTmpMatrix.mapRect(mCurrentRectWithInsets, mClipRectF);
return mCurrentRectWithInsets;
}
private void applyParams(@Nullable SyncRtSurfaceTransactionApplier syncTransactionApplier,
SurfaceParams[] params) {
if (syncTransactionApplier != null) {

View File

@ -15,11 +15,17 @@
*/
package com.android.quickstep.views;
import static com.android.launcher3.states.RotationHelper.REQUEST_LOCK;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static com.android.launcher3.states.RotationHelper.REQUEST_NONE;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.view.MotionEvent;
import android.widget.FrameLayout;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.Insettable;
@ -34,12 +40,28 @@ public class LauncherLayoutListener extends AbstractFloatingView
implements Insettable, LayoutListener {
private final Launcher mLauncher;
private final Paint mPaint = new Paint();
private WindowTransformSwipeHandler mHandler;
private RectF mCurrentRect;
public LauncherLayoutListener(Launcher launcher) {
super(launcher, null);
mLauncher = launcher;
setVisibility(INVISIBLE);
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
setLayoutParams(new FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
}
@Override
public void update(boolean shouldFinish, boolean isLongSwipe, RectF currentRect) {
if (shouldFinish) {
finish();
return;
}
mCurrentRect = currentRect;
setWillNotDraw(mCurrentRect == null || isLongSwipe);
invalidate();
}
@Override
@ -80,11 +102,6 @@ public class LauncherLayoutListener extends AbstractFloatingView
}
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
setMeasuredDimension(1, 1);
}
@Override
public void logActionCommand(int command) {
// We should probably log the weather
@ -97,8 +114,13 @@ public class LauncherLayoutListener extends AbstractFloatingView
@Override
public void finish() {
setHandler(null);
close(false);
setHandler(null);
mLauncher.getRotationHelper().setStateHandlerRequest(REQUEST_NONE);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawRect(mCurrentRect, mPaint);
}
}

View File

@ -219,6 +219,17 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
closeAllOpenViews(activity, true);
}
public static void closeAllOpenViewsExcept(ActivityContext activity, boolean animate,
@FloatingViewType int type) {
closeOpenViews(activity, animate, TYPE_ALL & ~type);
activity.finishAutoCancelActionMode();
}
public static void closeAllOpenViewsExcept(ActivityContext activity,
@FloatingViewType int type) {
closeAllOpenViewsExcept(activity, true, type);
}
public static AbstractFloatingView getTopOpenView(ActivityContext activity) {
return getTopOpenViewWithType(activity, TYPE_ALL);
}