Multi-window optimizations #3
- Make sure divider is pushing frames only if necessary - When starting recents while docking, make sure no unnecessary animations are played to reduce system load. Change-Id: I536f009aef7282ed85dde79b853aeae62644f3e3
This commit is contained in:
@@ -205,7 +205,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
|
||||
? stack.indexOfStackTask(launchTarget)
|
||||
: 0;
|
||||
boolean hasNavBarScrim = (taskCount > 0) && !config.hasTransposedNavBar;
|
||||
boolean animateNavBarScrim = true;
|
||||
boolean animateNavBarScrim = !launchState.launchedWhileDocking;
|
||||
mScrimViews.prepareEnterRecentsAnimation(hasNavBarScrim, animateNavBarScrim);
|
||||
|
||||
// Keep track of whether we launched from the nav bar button or via alt-tab
|
||||
@@ -460,13 +460,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
|
||||
// wait on the system to send a signal that was never queued.
|
||||
RecentsConfiguration config = Recents.getConfiguration();
|
||||
RecentsActivityLaunchState launchState = config.getLaunchState();
|
||||
launchState.launchedFromHome = false;
|
||||
launchState.launchedFromSearchHome = false;
|
||||
launchState.launchedFromAppWithThumbnail = false;
|
||||
launchState.launchedToTaskId = -1;
|
||||
launchState.launchedWithAltTab = false;
|
||||
launchState.launchedHasConfigurationChanged = false;
|
||||
launchState.launchedViaDragGesture = false;
|
||||
launchState.reset();
|
||||
|
||||
MetricsLogger.hidden(this, MetricsEvent.OVERVIEW_ACTIVITY);
|
||||
}
|
||||
|
||||
@@ -34,10 +34,22 @@ public class RecentsActivityLaunchState {
|
||||
public boolean launchedReuseTaskStackViews;
|
||||
public boolean launchedHasConfigurationChanged;
|
||||
public boolean launchedViaDragGesture;
|
||||
public boolean launchedWhileDocking;
|
||||
public int launchedToTaskId;
|
||||
public int launchedNumVisibleTasks;
|
||||
public int launchedNumVisibleThumbnails;
|
||||
|
||||
public void reset() {
|
||||
launchedFromHome = false;
|
||||
launchedFromSearchHome = false;
|
||||
launchedFromAppWithThumbnail = false;
|
||||
launchedToTaskId = -1;
|
||||
launchedWithAltTab = false;
|
||||
launchedHasConfigurationChanged = false;
|
||||
launchedViaDragGesture = false;
|
||||
launchedWhileDocking = false;
|
||||
}
|
||||
|
||||
/** Called when the configuration has changed, and we want to reset any configuration specific
|
||||
* members. */
|
||||
public void updateOnConfigurationChange() {
|
||||
@@ -46,6 +58,7 @@ public class RecentsActivityLaunchState {
|
||||
// Set this flag to indicate that the configuration has changed since Recents last launched
|
||||
launchedHasConfigurationChanged = true;
|
||||
launchedViaDragGesture = false;
|
||||
launchedWhileDocking = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -161,6 +161,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
|
||||
boolean mCanReuseTaskStackViews = true;
|
||||
boolean mDraggingInRecents;
|
||||
boolean mReloadTasks;
|
||||
boolean mLaunchedWhileDocking;
|
||||
|
||||
// Task launching
|
||||
Rect mSearchBarBounds = new Rect();
|
||||
@@ -270,10 +271,10 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
|
||||
}
|
||||
|
||||
public void showRecents(boolean triggeredFromAltTab, boolean draggingInRecents,
|
||||
boolean animate, boolean reloadTasks) {
|
||||
boolean animate, boolean launchedWhileDockingTask) {
|
||||
mTriggeredFromAltTab = triggeredFromAltTab;
|
||||
mDraggingInRecents = draggingInRecents;
|
||||
mReloadTasks = reloadTasks;
|
||||
mLaunchedWhileDocking = launchedWhileDockingTask;
|
||||
if (mFastAltTabTrigger.hasTriggered()) {
|
||||
// We are calling this from the doze trigger, so just fall through to show Recents
|
||||
mFastAltTabTrigger.resetTrigger();
|
||||
@@ -338,6 +339,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
|
||||
}
|
||||
|
||||
mDraggingInRecents = false;
|
||||
mLaunchedWhileDocking = false;
|
||||
mTriggeredFromAltTab = false;
|
||||
|
||||
try {
|
||||
@@ -865,11 +867,11 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
|
||||
// In the case where alt-tab is triggered, we never get a preloadRecents() call, so we
|
||||
// should always preload the tasks now. If we are dragging in recents, reload them as
|
||||
// the stacks might have changed.
|
||||
if (mReloadTasks || mTriggeredFromAltTab ||sInstanceLoadPlan == null) {
|
||||
if (mLaunchedWhileDocking || mTriggeredFromAltTab ||sInstanceLoadPlan == null) {
|
||||
// Create a new load plan if preloadRecents() was never triggered
|
||||
sInstanceLoadPlan = loader.createLoadPlan(mContext);
|
||||
}
|
||||
if (mReloadTasks || mTriggeredFromAltTab || !sInstanceLoadPlan.hasTasks()) {
|
||||
if (mLaunchedWhileDocking || mTriggeredFromAltTab || !sInstanceLoadPlan.hasTasks()) {
|
||||
loader.preloadTasks(sInstanceLoadPlan, topTask.id, isTopTaskHome);
|
||||
}
|
||||
TaskStack stack = sInstanceLoadPlan.getTaskStack();
|
||||
@@ -957,6 +959,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
|
||||
launchState.launchedNumVisibleThumbnails = vr.numVisibleThumbnails;
|
||||
launchState.launchedHasConfigurationChanged = false;
|
||||
launchState.launchedViaDragGesture = mDraggingInRecents;
|
||||
launchState.launchedWhileDocking = mLaunchedWhileDocking;
|
||||
|
||||
Intent intent = new Intent();
|
||||
intent.setClassName(RECENTS_PACKAGE, mRecentsIntentActivityName);
|
||||
|
||||
@@ -287,13 +287,7 @@ public class RecentsTvActivity extends Activity implements OnPreDrawListener {
|
||||
// wait on the system to send a signal that was never queued.
|
||||
RecentsConfiguration config = Recents.getConfiguration();
|
||||
RecentsActivityLaunchState launchState = config.getLaunchState();
|
||||
launchState.launchedFromHome = false;
|
||||
launchState.launchedFromSearchHome = false;
|
||||
launchState.launchedFromAppWithThumbnail = false;
|
||||
launchState.launchedToTaskId = -1;
|
||||
launchState.launchedWithAltTab = false;
|
||||
launchState.launchedHasConfigurationChanged = false;
|
||||
launchState.launchedViaDragGesture = false;
|
||||
launchState.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -185,7 +185,8 @@ public class RecentsView extends FrameLayout {
|
||||
// If we are already occluded by the app, then just set the default background scrim now.
|
||||
// Otherwise, defer until the enter animation completes to animate the scrim with the
|
||||
// tasks for the home animation.
|
||||
if (launchState.launchedFromAppWithThumbnail || mStack.getTaskCount() == 0) {
|
||||
if (launchState.launchedWhileDocking || launchState.launchedFromAppWithThumbnail
|
||||
|| mStack.getTaskCount() == 0) {
|
||||
mBackgroundScrim.setAlpha((int) (DEFAULT_SCRIM_ALPHA * 255));
|
||||
} else {
|
||||
mBackgroundScrim.setAlpha(0);
|
||||
@@ -645,7 +646,8 @@ public class RecentsView extends FrameLayout {
|
||||
|
||||
public final void onBusEvent(EnterRecentsWindowAnimationCompletedEvent event) {
|
||||
RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
|
||||
if (!launchState.launchedFromAppWithThumbnail && mStack.getTaskCount() > 0) {
|
||||
if (!launchState.launchedWhileDocking && !launchState.launchedFromAppWithThumbnail
|
||||
&& mStack.getTaskCount() > 0) {
|
||||
animateBackgroundScrim(DEFAULT_SCRIM_ALPHA,
|
||||
TaskStackAnimationHelper.ENTER_FROM_HOME_TRANSLATION_DURATION);
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ public class DividerHandleView extends ImageButton {
|
||||
private int mCurrentWidth;
|
||||
private int mCurrentHeight;
|
||||
private AnimatorSet mAnimator;
|
||||
private boolean mTouching;
|
||||
|
||||
public DividerHandleView(Context context, @Nullable AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@@ -86,6 +87,9 @@ public class DividerHandleView extends ImageButton {
|
||||
}
|
||||
|
||||
public void setTouching(boolean touching, boolean animate) {
|
||||
if (touching == mTouching) {
|
||||
return;
|
||||
}
|
||||
if (mAnimator != null) {
|
||||
mAnimator.cancel();
|
||||
mAnimator = null;
|
||||
@@ -103,6 +107,7 @@ public class DividerHandleView extends ImageButton {
|
||||
animateToTarget(touching ? mCircleDiameter : mWidth,
|
||||
touching ? mCircleDiameter : mHeight, touching);
|
||||
}
|
||||
mTouching = touching;
|
||||
}
|
||||
|
||||
private void animateToTarget(int targetWidth, int targetHeight, boolean touching) {
|
||||
|
||||
@@ -100,6 +100,7 @@ public class DividerView extends FrameLayout implements OnTouchListener,
|
||||
private final int[] mTempInt2 = new int[2];
|
||||
private boolean mMoving;
|
||||
private int mTouchSlop;
|
||||
private boolean mBackgroundLifted;
|
||||
|
||||
private int mDividerInsets;
|
||||
private int mDisplayWidth;
|
||||
@@ -210,8 +211,8 @@ public class DividerView extends FrameLayout implements OnTouchListener,
|
||||
mDockSide = mWindowManagerProxy.getDockSide();
|
||||
initializeSnapAlgorithm();
|
||||
mWindowManagerProxy.setResizing(true);
|
||||
mWindowManager.setSlippery(false);
|
||||
if (touching) {
|
||||
mWindowManager.setSlippery(false);
|
||||
liftBackground();
|
||||
}
|
||||
return mDockSide != WindowManager.DOCKED_INVALID;
|
||||
@@ -389,6 +390,9 @@ public class DividerView extends FrameLayout implements OnTouchListener,
|
||||
}
|
||||
|
||||
private void liftBackground() {
|
||||
if (mBackgroundLifted) {
|
||||
return;
|
||||
}
|
||||
if (isHorizontalDivision()) {
|
||||
mBackground.animate().scaleY(1.4f);
|
||||
} else {
|
||||
@@ -407,9 +411,13 @@ public class DividerView extends FrameLayout implements OnTouchListener,
|
||||
.setDuration(TOUCH_ANIMATION_DURATION)
|
||||
.translationZ(mTouchElevation)
|
||||
.start();
|
||||
mBackgroundLifted = true;
|
||||
}
|
||||
|
||||
private void releaseBackground() {
|
||||
if (!mBackgroundLifted) {
|
||||
return;
|
||||
}
|
||||
mBackground.animate()
|
||||
.setInterpolator(Interpolators.FAST_OUT_SLOW_IN)
|
||||
.setDuration(TOUCH_RELEASE_ANIMATION_DURATION)
|
||||
@@ -422,6 +430,7 @@ public class DividerView extends FrameLayout implements OnTouchListener,
|
||||
.setDuration(TOUCH_RELEASE_ANIMATION_DURATION)
|
||||
.translationZ(0)
|
||||
.start();
|
||||
mBackgroundLifted = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -485,7 +494,9 @@ public class DividerView extends FrameLayout implements OnTouchListener,
|
||||
}
|
||||
|
||||
// Make sure shadows are updated
|
||||
mBackground.invalidate();
|
||||
if (mBackground.getZ() > 0f) {
|
||||
mBackground.invalidate();
|
||||
}
|
||||
|
||||
mLastResizeRect.set(mDockedRect);
|
||||
if (taskPosition != TASK_POSITION_SAME) {
|
||||
|
||||
Reference in New Issue
Block a user