Merge changes I2586b90d,I67111528,I9aeb191a into nyc-dev

am: 67533ee

* commit '67533eea19f58809c608fa28a3fedd092d06e5ef':
  Fix config change layout. (Part 2)
  Fixing issue with tasks being laid out with the wrong bounds.
  Launch state/config change audit. (Part 1)
This commit is contained in:
Winson
2016-03-26 02:01:21 +00:00
committed by android-build-merger
20 changed files with 344 additions and 256 deletions

View File

@@ -73,6 +73,7 @@ import com.android.systemui.recents.model.RecentsTaskLoadPlan;
import com.android.systemui.recents.model.RecentsTaskLoader; import com.android.systemui.recents.model.RecentsTaskLoader;
import com.android.systemui.recents.model.Task; import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.TaskStack; import com.android.systemui.recents.model.TaskStack;
import com.android.systemui.recents.views.AnimationProps;
import com.android.systemui.recents.views.RecentsView; import com.android.systemui.recents.views.RecentsView;
import com.android.systemui.recents.views.SystemBarScrimViews; import com.android.systemui.recents.views.SystemBarScrimViews;
import com.android.systemui.statusbar.BaseStatusBar; import com.android.systemui.statusbar.BaseStatusBar;
@@ -285,6 +286,9 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
registerReceiver(mSystemBroadcastReceiver, filter); registerReceiver(mSystemBroadcastReceiver, filter);
getWindow().addPrivateFlags(LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION); getWindow().addPrivateFlags(LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION);
// Reload the stack view
reloadStackView();
} }
@Override @Override
@@ -297,15 +301,17 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
} }
@Override @Override
public void onEnterAnimationComplete() { protected void onNewIntent(Intent intent) {
super.onEnterAnimationComplete(); super.onNewIntent(intent);
EventBus.getDefault().send(new EnterRecentsWindowAnimationCompletedEvent());
// Reload the stack view
reloadStackView();
} }
@Override /**
protected void onResume() { * Reloads the stack views upon launching Recents.
super.onResume(); */
private void reloadStackView() {
// If the Recents component has preloaded a load plan, then use that to prevent // If the Recents component has preloaded a load plan, then use that to prevent
// reconstructing the task stack // reconstructing the task stack
RecentsTaskLoader loader = Recents.getTaskLoader(); RecentsTaskLoader loader = Recents.getTaskLoader();
@@ -328,38 +334,21 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
loadOpts.numVisibleTaskThumbnails = launchState.launchedNumVisibleThumbnails; loadOpts.numVisibleTaskThumbnails = launchState.launchedNumVisibleThumbnails;
loader.loadTasks(this, loadPlan, loadOpts); loader.loadTasks(this, loadPlan, loadOpts);
TaskStack stack = loadPlan.getTaskStack(); TaskStack stack = loadPlan.getTaskStack();
mRecentsView.onResume(mIsVisible, false /* multiWindowChange */, stack); mRecentsView.onReload(mIsVisible, stack.getTaskCount() == 0);
mRecentsView.updateStack(stack);
// Animate the SystemUI scrims into view // Update the nav bar scrim, but defer the animation until the enter-window event
Task launchTarget = stack.getLaunchTarget();
int taskCount = stack.getTaskCount();
int launchTaskIndexInStack = launchTarget != null
? stack.indexOfStackTask(launchTarget)
: 0;
boolean hasNavBarScrim = (taskCount > 0) && !config.hasTransposedNavBar;
boolean animateNavBarScrim = !launchState.launchedWhileDocking; boolean animateNavBarScrim = !launchState.launchedWhileDocking;
mScrimViews.prepareEnterRecentsAnimation(hasNavBarScrim, animateNavBarScrim); updateNavBarScrim(animateNavBarScrim, null);
// If this is a new instance from a configuration change, then we have to manually trigger // If this is a new instance relaunched by AM, without going through the normal mechanisms,
// the enter animation state, or if recents was relaunched by AM, without going through // then we have to manually trigger the enter animation state
// the normal mechanisms
boolean wasLaunchedByAm = !launchState.launchedFromHome && boolean wasLaunchedByAm = !launchState.launchedFromHome &&
!launchState.launchedFromApp; !launchState.launchedFromApp;
if (launchState.launchedHasConfigurationChanged || wasLaunchedByAm) { if (wasLaunchedByAm) {
EventBus.getDefault().send(new EnterRecentsWindowAnimationCompletedEvent()); EventBus.getDefault().send(new EnterRecentsWindowAnimationCompletedEvent());
} }
mRecentsView.getViewTreeObserver().addOnPreDrawListener(
new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
mRecentsView.getViewTreeObserver().removeOnPreDrawListener(this);
EventBus.getDefault().post(new RecentsDrawnEvent());
return true;
}
});
// Keep track of whether we launched from the nav bar button or via alt-tab // Keep track of whether we launched from the nav bar button or via alt-tab
if (launchState.launchedWithAltTab) { if (launchState.launchedWithAltTab) {
MetricsLogger.count(this, "overview_trigger_alttab", 1); MetricsLogger.count(this, "overview_trigger_alttab", 1);
@@ -369,6 +358,10 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
// Keep track of whether we launched from an app or from home // Keep track of whether we launched from an app or from home
if (launchState.launchedFromApp) { if (launchState.launchedFromApp) {
Task launchTarget = stack.getLaunchTarget();
int launchTaskIndexInStack = launchTarget != null
? stack.indexOfStackTask(launchTarget)
: 0;
MetricsLogger.count(this, "overview_source_app", 1); MetricsLogger.count(this, "overview_source_app", 1);
// If from an app, track the stack index of the app in the stack (for affiliated tasks) // If from an app, track the stack index of the app in the stack (for affiliated tasks)
MetricsLogger.histogram(this, "overview_source_app_index", launchTaskIndexInStack); MetricsLogger.histogram(this, "overview_source_app_index", launchTaskIndexInStack);
@@ -377,12 +370,36 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
} }
// Keep track of the total stack task count // Keep track of the total stack task count
int taskCount = mRecentsView.getStack().getTaskCount();
MetricsLogger.histogram(this, "overview_task_count", taskCount); MetricsLogger.histogram(this, "overview_task_count", taskCount);
// After we have resumed, set the visible state until the next onStop() call // After we have resumed, set the visible state until the next onStop() call
mIsVisible = true; mIsVisible = true;
} }
@Override
public void onEnterAnimationComplete() {
super.onEnterAnimationComplete();
EventBus.getDefault().send(new EnterRecentsWindowAnimationCompletedEvent());
}
@Override
protected void onResume() {
super.onResume();
// Notify of the next draw
mRecentsView.getViewTreeObserver().addOnPreDrawListener(
new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
mRecentsView.getViewTreeObserver().removeOnPreDrawListener(this);
EventBus.getDefault().post(new RecentsDrawnEvent());
return true;
}
});
}
@Override @Override
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
@@ -395,7 +412,34 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
public void onConfigurationChanged(Configuration newConfig) { public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig); super.onConfigurationChanged(newConfig);
EventBus.getDefault().send(new ConfigurationChangedEvent()); // Update the nav bar for the current orientation
updateNavBarScrim(false /* animateNavBarScrim */, AnimationProps.IMMEDIATE);
EventBus.getDefault().send(new ConfigurationChangedEvent(false /* fromMultiWindow */));
}
@Override
public void onMultiWindowChanged(boolean inMultiWindow) {
super.onMultiWindowChanged(inMultiWindow);
EventBus.getDefault().send(new ConfigurationChangedEvent(true /* fromMultiWindow */));
if (mRecentsView != null) {
// Reload the task stack completely
RecentsConfiguration config = Recents.getConfiguration();
RecentsActivityLaunchState launchState = config.getLaunchState();
RecentsTaskLoader loader = Recents.getTaskLoader();
RecentsTaskLoadPlan loadPlan = loader.createLoadPlan(this);
loader.preloadTasks(loadPlan, -1 /* topTaskId */, false /* isTopTaskHome */);
RecentsTaskLoadPlan.Options loadOpts = new RecentsTaskLoadPlan.Options();
loadOpts.numVisibleTasks = launchState.launchedNumVisibleTasks;
loadOpts.numVisibleTaskThumbnails = launchState.launchedNumVisibleThumbnails;
loader.loadTasks(this, loadPlan, loadOpts);
mRecentsView.updateStack(loadPlan.getTaskStack());
}
EventBus.getDefault().send(new MultiWindowStateChangedEvent(inMultiWindow));
} }
@Override @Override
@@ -453,28 +497,6 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
} }
} }
@Override
public void onMultiWindowChanged(boolean inMultiWindow) {
super.onMultiWindowChanged(inMultiWindow);
EventBus.getDefault().send(new ConfigurationChangedEvent());
// Reload the task stack completely
RecentsConfiguration config = Recents.getConfiguration();
RecentsActivityLaunchState launchState = config.getLaunchState();
RecentsTaskLoader loader = Recents.getTaskLoader();
RecentsTaskLoadPlan loadPlan = loader.createLoadPlan(this);
loader.preloadTasks(loadPlan, -1 /* topTaskId */, false /* isTopTaskHome */);
RecentsTaskLoadPlan.Options loadOpts = new RecentsTaskLoadPlan.Options();
loadOpts.numVisibleTasks = launchState.launchedNumVisibleTasks;
loadOpts.numVisibleTaskThumbnails = launchState.launchedNumVisibleThumbnails;
loader.loadTasks(this, loadPlan, loadOpts);
mRecentsView.onResume(mIsVisible, true /* multiWindowChange */, loadPlan.getTaskStack());
EventBus.getDefault().send(new MultiWindowStateChangedEvent(inMultiWindow));
}
@Override @Override
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) { switch (keyCode) {
@@ -697,4 +719,18 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
}); });
return true; return true;
} }
/**
* Updates the nav bar scrim.
*/
private void updateNavBarScrim(boolean animateNavBarScrim, AnimationProps animation) {
// Animate the SystemUI scrims into view
SystemServicesProxy ssp = Recents.getSystemServices();
int taskCount = mRecentsView.getStack().getTaskCount();
boolean hasNavBarScrim = (taskCount > 0) && !ssp.hasTransposedNavBar();
mScrimViews.prepareEnterRecentsAnimation(hasNavBarScrim, animateNavBarScrim);
if (animateNavBarScrim && animation != null) {
mScrimViews.animateNavBarScrimVisibility(true, animation);
}
}
} }

View File

@@ -31,8 +31,6 @@ public class RecentsActivityLaunchState {
public boolean launchedFromApp; public boolean launchedFromApp;
public boolean launchedFromAppDocked; public boolean launchedFromAppDocked;
public boolean launchedFromHome; public boolean launchedFromHome;
public boolean launchedReuseTaskStackViews;
public boolean launchedHasConfigurationChanged;
public boolean launchedViaDragGesture; public boolean launchedViaDragGesture;
public boolean launchedWhileDocking; public boolean launchedWhileDocking;
public int launchedToTaskId; public int launchedToTaskId;
@@ -45,7 +43,6 @@ public class RecentsActivityLaunchState {
launchedFromAppDocked = false; launchedFromAppDocked = false;
launchedToTaskId = -1; launchedToTaskId = -1;
launchedWithAltTab = false; launchedWithAltTab = false;
launchedHasConfigurationChanged = false;
launchedViaDragGesture = false; launchedViaDragGesture = false;
launchedWhileDocking = false; launchedWhileDocking = false;
} }
@@ -53,10 +50,6 @@ public class RecentsActivityLaunchState {
/** Called when the configuration has changed, and we want to reset any configuration specific /** Called when the configuration has changed, and we want to reset any configuration specific
* members. */ * members. */
public void updateOnConfigurationChange() { public void updateOnConfigurationChange() {
// Reset this flag on configuration change to ensure that we recreate new task views
launchedReuseTaskStackViews = false;
// Set this flag to indicate that the configuration has changed since Recents last launched
launchedHasConfigurationChanged = true;
launchedViaDragGesture = false; launchedViaDragGesture = false;
launchedWhileDocking = false; launchedWhileDocking = false;
} }

View File

@@ -47,11 +47,6 @@ public class RecentsConfiguration {
// Launch states // Launch states
public RecentsActivityLaunchState mLaunchState = new RecentsActivityLaunchState(); public RecentsActivityLaunchState mLaunchState = new RecentsActivityLaunchState();
// TODO: Values determined by the current context, needs to be refactored into something that is
// agnostic of the activity context, but still calculable from the Recents component for
// the transition into recents
public boolean hasTransposedNavBar;
// Since the positions in Recents has to be calculated globally (before the RecentsActivity // Since the positions in Recents has to be calculated globally (before the RecentsActivity
// starts), we need to calculate some resource values ourselves, instead of relying on framework // starts), we need to calculate some resource values ourselves, instead of relying on framework
// resources. // resources.
@@ -78,13 +73,6 @@ public class RecentsConfiguration {
isXLargeScreen = smallestWidth >= (int) (screenDensity * XLARGE_SCREEN_MIN_DP); isXLargeScreen = smallestWidth >= (int) (screenDensity * XLARGE_SCREEN_MIN_DP);
} }
/**
* Updates the configuration based on the current state of the system
*/
void update(Rect systemInsets) {
hasTransposedNavBar = systemInsets.right > 0;
}
/** /**
* Returns the activity launch state. * Returns the activity launch state.
* TODO: This will be refactored out of RecentsConfiguration. * TODO: This will be refactored out of RecentsConfiguration.

View File

@@ -140,7 +140,6 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
protected Context mContext; protected Context mContext;
protected Handler mHandler; protected Handler mHandler;
TaskStackListenerImpl mTaskStackListener; TaskStackListenerImpl mTaskStackListener;
protected boolean mCanReuseTaskStackViews = true;
boolean mDraggingInRecents; boolean mDraggingInRecents;
boolean mLaunchedWhileDocking; boolean mLaunchedWhileDocking;
@@ -209,8 +208,6 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
public void onConfigurationChanged() { public void onConfigurationChanged() {
reloadHeaderBarLayout(); reloadHeaderBarLayout();
updateHeaderBarLayout(null /* stack */); updateHeaderBarLayout(null /* stack */);
// Don't reuse task stack views if the configuration changes
mCanReuseTaskStackViews = false;
Recents.getConfiguration().updateOnConfigurationChange(); Recents.getConfiguration().updateOnConfigurationChange();
} }
@@ -592,9 +589,6 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
calculateWindowStableInsets(systemInsets, windowRect); calculateWindowStableInsets(systemInsets, windowRect);
windowRect.offsetTo(0, 0); windowRect.offsetTo(0, 0);
// Update the configuration for the current state
Recents.getConfiguration().update(systemInsets);
TaskStackLayoutAlgorithm stackLayout = mDummyStackView.getStackAlgorithm(); TaskStackLayoutAlgorithm stackLayout = mDummyStackView.getStackAlgorithm();
stackLayout.getTaskStackBounds(windowRect, systemInsets.top, systemInsets.right, stackLayout.getTaskStackBounds(windowRect, systemInsets.top, systemInsets.right,
mTaskStackBounds); mTaskStackBounds);
@@ -605,8 +599,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
if (stack != null) { if (stack != null) {
stackLayout.initialize(windowRect, taskStackBounds, stackLayout.initialize(windowRect, taskStackBounds,
TaskStackLayoutAlgorithm.StackState.getStackStateForStack(stack)); TaskStackLayoutAlgorithm.StackState.getStackStateForStack(stack));
mDummyStackView.setTasks(stack, false /* notifyStackChanges */, mDummyStackView.setTasks(stack, false /* allowNotifyStackChanges */);
false /* relayoutTaskStack */, false /* multiWindowChange */);
} }
Rect taskViewBounds = stackLayout.getUntransformedTaskViewBounds(); Rect taskViewBounds = stackLayout.getUntransformedTaskViewBounds();
if (!taskViewBounds.equals(mLastTaskViewBounds)) { if (!taskViewBounds.equals(mLastTaskViewBounds)) {
@@ -715,7 +708,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
TaskStackViewScroller stackScroller = stackView.getScroller(); TaskStackViewScroller stackScroller = stackView.getScroller();
stackView.updateLayoutAlgorithm(true /* boundScroll */); stackView.updateLayoutAlgorithm(true /* boundScroll */);
stackView.updateToInitialState(); stackView.updateToInitialState(true /* scrollToInitialState */);
for (int i = tasks.size() - 1; i >= 0; i--) { for (int i = tasks.size() - 1; i >= 0; i--) {
Task task = tasks.get(i); Task task = tasks.get(i);
@@ -782,7 +775,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
// Get the transform for the running task // Get the transform for the running task
stackView.updateLayoutAlgorithm(true /* boundScroll */); stackView.updateLayoutAlgorithm(true /* boundScroll */);
stackView.updateToInitialState(); stackView.updateToInitialState(true /* scrollToInitialState */);
mTmpTransform = stackView.getStackAlgorithm().getStackTransformScreenCoordinates(launchTask, mTmpTransform = stackView.getStackAlgorithm().getStackTransformScreenCoordinates(launchTask,
stackView.getScroller().getStackScroll(), mTmpTransform, null); stackView.getScroller().getStackScroll(), mTmpTransform, null);
return mTmpTransform; return mTmpTransform;
@@ -862,10 +855,8 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
launchState.launchedToTaskId = (topTask != null) ? topTask.id : -1; launchState.launchedToTaskId = (topTask != null) ? topTask.id : -1;
launchState.launchedFromAppDocked = mLaunchedWhileDocking; launchState.launchedFromAppDocked = mLaunchedWhileDocking;
launchState.launchedWithAltTab = mTriggeredFromAltTab; launchState.launchedWithAltTab = mTriggeredFromAltTab;
launchState.launchedReuseTaskStackViews = mCanReuseTaskStackViews;
launchState.launchedNumVisibleTasks = stackVr.numVisibleTasks; launchState.launchedNumVisibleTasks = stackVr.numVisibleTasks;
launchState.launchedNumVisibleThumbnails = stackVr.numVisibleThumbnails; launchState.launchedNumVisibleThumbnails = stackVr.numVisibleThumbnails;
launchState.launchedHasConfigurationChanged = false;
launchState.launchedViaDragGesture = mDraggingInRecents; launchState.launchedViaDragGesture = mDraggingInRecents;
launchState.launchedWhileDocking = mLaunchedWhileDocking; launchState.launchedWhileDocking = mLaunchedWhileDocking;
@@ -915,7 +906,6 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
} else { } else {
mContext.startActivityAsUser(intent, UserHandle.CURRENT); mContext.startActivityAsUser(intent, UserHandle.CURRENT);
} }
mCanReuseTaskStackViews = true;
EventBus.getDefault().send(new RecentsActivityStartingEvent()); EventBus.getDefault().send(new RecentsActivityStartingEvent());
} }

View File

@@ -22,5 +22,10 @@ import com.android.systemui.recents.events.EventBus;
* This is sent when the Recents activity configuration has changed. * This is sent when the Recents activity configuration has changed.
*/ */
public class ConfigurationChangedEvent extends EventBus.AnimatedEvent { public class ConfigurationChangedEvent extends EventBus.AnimatedEvent {
// Simple event
public final boolean fromMultiWindow;
public ConfigurationChangedEvent(boolean fromMultiWindow) {
this.fromMultiWindow = fromMultiWindow;
}
} }

View File

@@ -1064,6 +1064,16 @@ public class SystemServicesProxy {
} }
} }
/**
* Returns whether the device has a transposed nav bar (on the right of the screen) in the
* current display orientation.
*/
public boolean hasTransposedNavBar() {
Rect insets = new Rect();
getStableInsets(insets);
return insets.right > 0;
}
private final class H extends Handler { private final class H extends Handler {
private static final int ON_TASK_STACK_CHANGED = 1; private static final int ON_TASK_STACK_CHANGED = 1;
private static final int ON_ACTIVITY_PINNED = 2; private static final int ON_ACTIVITY_PINNED = 2;

View File

@@ -274,7 +274,9 @@ public class RecentsTaskLoader {
new TaskKeyLruCache.EvictionCallback() { new TaskKeyLruCache.EvictionCallback() {
@Override @Override
public void onEntryEvicted(Task.TaskKey key) { public void onEntryEvicted(Task.TaskKey key) {
mActivityInfoCache.remove(key.getComponent()); if (key != null) {
mActivityInfoCache.remove(key.getComponent());
}
} }
}; };

View File

@@ -220,6 +220,11 @@ public class TaskStack {
*/ */
void onStackTaskRemoved(TaskStack stack, Task removedTask, boolean wasFrontMostTask, void onStackTaskRemoved(TaskStack stack, Task removedTask, boolean wasFrontMostTask,
Task newFrontMostTask, AnimationProps animation, boolean fromDockGesture); Task newFrontMostTask, AnimationProps animation, boolean fromDockGesture);
/**
* Notifies when tasks in the stack have been updated.
*/
void onStackTasksUpdated(TaskStack stack);
} }
/** /**
@@ -560,14 +565,19 @@ public class TaskStack {
mStackTaskList.set(allTasks); mStackTaskList.set(allTasks);
mRawTaskList = allTasks; mRawTaskList = allTasks;
// Update the affiliated groupings
createAffiliatedGroupings(context);
// Only callback for the newly added tasks after this stack has been updated // Only callback for the newly added tasks after this stack has been updated
int addedTaskCount = addedTasks.size(); int addedTaskCount = addedTasks.size();
for (int i = 0; i < addedTaskCount; i++) { for (int i = 0; i < addedTaskCount; i++) {
mCb.onStackTaskAdded(this, addedTasks.get(i)); mCb.onStackTaskAdded(this, addedTasks.get(i));
} }
// Update the affiliated groupings // Notify that the task stack has been updated
createAffiliatedGroupings(context); if (notifyStackChanges) {
mCb.onStackTasksUpdated(this);
}
} }
/** /**

View File

@@ -313,7 +313,7 @@ public class RecentsTvActivity extends Activity implements OnPreDrawListener {
RecentsActivityLaunchState launchState = config.getLaunchState(); RecentsActivityLaunchState launchState = config.getLaunchState();
boolean wasLaunchedByAm = !launchState.launchedFromHome && boolean wasLaunchedByAm = !launchState.launchedFromHome &&
!launchState.launchedFromApp; !launchState.launchedFromApp;
if (launchState.launchedHasConfigurationChanged || wasLaunchedByAm) { if (wasLaunchedByAm) {
EventBus.getDefault().send(new EnterRecentsWindowAnimationCompletedEvent()); EventBus.getDefault().send(new EnterRecentsWindowAnimationCompletedEvent());
} }

View File

@@ -24,10 +24,13 @@ import android.graphics.Bitmap;
import android.graphics.Rect; import android.graphics.Rect;
import android.os.SystemClock; import android.os.SystemClock;
import android.os.UserHandle; import android.os.UserHandle;
import com.android.systemui.recents.*;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.RecentsActivityLaunchState;
import com.android.systemui.recents.RecentsConfiguration;
import com.android.systemui.recents.RecentsImpl;
import com.android.systemui.recents.events.EventBus; import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.RecentsActivityStartingEvent; import com.android.systemui.recents.events.activity.RecentsActivityStartingEvent;
import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.model.RecentsTaskLoader; import com.android.systemui.recents.model.RecentsTaskLoader;
import com.android.systemui.recents.model.TaskStack; import com.android.systemui.recents.model.TaskStack;
import com.android.systemui.recents.tv.views.TaskCardView; import com.android.systemui.recents.tv.views.TaskCardView;
@@ -101,8 +104,6 @@ public class RecentsTvImpl extends RecentsImpl{
launchState.launchedFromApp = fromThumbnail; launchState.launchedFromApp = fromThumbnail;
launchState.launchedToTaskId = (topTask != null) ? topTask.id : -1; launchState.launchedToTaskId = (topTask != null) ? topTask.id : -1;
launchState.launchedWithAltTab = mTriggeredFromAltTab; launchState.launchedWithAltTab = mTriggeredFromAltTab;
launchState.launchedReuseTaskStackViews = mCanReuseTaskStackViews;
launchState.launchedHasConfigurationChanged = false;
Intent intent = new Intent(); Intent intent = new Intent();
intent.setClassName(RECENTS_PACKAGE, RECENTS_TV_ACTIVITY); intent.setClassName(RECENTS_PACKAGE, RECENTS_TV_ACTIVITY);
@@ -115,7 +116,6 @@ public class RecentsTvImpl extends RecentsImpl{
} else { } else {
mContext.startActivityAsUser(intent, UserHandle.CURRENT); mContext.startActivityAsUser(intent, UserHandle.CURRENT);
} }
mCanReuseTaskStackViews = true;
EventBus.getDefault().send(new RecentsActivityStartingEvent()); EventBus.getDefault().send(new RecentsActivityStartingEvent());
} }

View File

@@ -156,4 +156,9 @@ public class TaskStackHorizontalGridView extends HorizontalGridView implements T
} }
} }
} }
@Override
public void onStackTasksUpdated(TaskStack stack) {
// Do nothing
}
} }

View File

@@ -82,9 +82,9 @@ public class RecentsTransitionHelper {
} }
}; };
public RecentsTransitionHelper(Context context, Handler handler) { public RecentsTransitionHelper(Context context) {
mContext = context; mContext = context;
mHandler = handler; mHandler = new Handler();
} }
/** /**

View File

@@ -19,7 +19,6 @@ package com.android.systemui.recents.views;
import static android.app.ActivityManager.StackId.INVALID_STACK_ID; import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
import android.animation.Animator; import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.app.ActivityOptions.OnAnimationStartedListener; import android.app.ActivityOptions.OnAnimationStartedListener;
import android.content.Context; import android.content.Context;
@@ -29,10 +28,6 @@ import android.graphics.Outline;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.IRemoteCallback;
import android.os.RemoteException;
import android.util.ArraySet; import android.util.ArraySet;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.AppTransitionAnimationSpec; import android.view.AppTransitionAnimationSpec;
@@ -44,11 +39,9 @@ import android.view.ViewDebug;
import android.view.ViewOutlineProvider; import android.view.ViewOutlineProvider;
import android.view.ViewPropertyAnimator; import android.view.ViewPropertyAnimator;
import android.view.WindowInsets; import android.view.WindowInsets;
import android.view.WindowManagerGlobal;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.TextView; import android.widget.TextView;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsProto.MetricsEvent; import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.android.systemui.Interpolators; import com.android.systemui.Interpolators;
@@ -94,8 +87,6 @@ public class RecentsView extends FrameLayout {
private static final int DEFAULT_UPDATE_SCRIM_DURATION = 200; private static final int DEFAULT_UPDATE_SCRIM_DURATION = 200;
private static final float DEFAULT_SCRIM_ALPHA = 0.33f; private static final float DEFAULT_SCRIM_ALPHA = 0.33f;
private final Handler mHandler;
private TaskStack mStack; private TaskStack mStack;
private TaskStackView mTaskStackView; private TaskStackView mTaskStackView;
private TextView mStackActionButton; private TextView mStackActionButton;
@@ -133,18 +124,17 @@ public class RecentsView extends FrameLayout {
setWillNotDraw(false); setWillNotDraw(false);
SystemServicesProxy ssp = Recents.getSystemServices(); SystemServicesProxy ssp = Recents.getSystemServices();
mHandler = new Handler(); mTransitionHelper = new RecentsTransitionHelper(getContext());
mTransitionHelper = new RecentsTransitionHelper(getContext(), mHandler);
mDividerSize = ssp.getDockedDividerSize(context); mDividerSize = ssp.getDockedDividerSize(context);
mTouchHandler = new RecentsViewTouchHandler(this); mTouchHandler = new RecentsViewTouchHandler(this);
mFlingAnimationUtils = new FlingAnimationUtils(context, 0.3f); mFlingAnimationUtils = new FlingAnimationUtils(context, 0.3f);
final float cornerRadius = context.getResources().getDimensionPixelSize(
R.dimen.recents_task_view_rounded_corners_radius);
LayoutInflater inflater = LayoutInflater.from(context); LayoutInflater inflater = LayoutInflater.from(context);
if (RecentsDebugFlags.Static.EnableStackActionButton) { if (RecentsDebugFlags.Static.EnableStackActionButton) {
mStackActionButton = (TextView) inflater.inflate(R.layout.recents_stack_action_button, this, float cornerRadius = context.getResources().getDimensionPixelSize(
false); R.dimen.recents_task_view_rounded_corners_radius);
mStackActionButton = (TextView) inflater.inflate(R.layout.recents_stack_action_button,
this, false);
mStackActionButton.setOnClickListener(new View.OnClickListener() { mStackActionButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@@ -166,19 +156,17 @@ public class RecentsView extends FrameLayout {
setBackground(mBackgroundScrim); setBackground(mBackgroundScrim);
} }
/** Set/get the bsp root node */ /**
public void onResume(boolean isResumingFromVisible, boolean multiWindowChange, * Called from RecentsActivity when it is relaunched.
TaskStack stack) { */
public void onReload(boolean isResumingFromVisible, boolean isTaskStackEmpty) {
RecentsConfiguration config = Recents.getConfiguration(); RecentsConfiguration config = Recents.getConfiguration();
RecentsActivityLaunchState launchState = config.getLaunchState(); RecentsActivityLaunchState launchState = config.getLaunchState();
if (!multiWindowChange && if (mTaskStackView == null) {
(mTaskStackView == null || !launchState.launchedReuseTaskStackViews)) {
isResumingFromVisible = false; isResumingFromVisible = false;
removeView(mTaskStackView);
mTaskStackView = new TaskStackView(getContext()); mTaskStackView = new TaskStackView(getContext());
mTaskStackView.setSystemInsets(mSystemInsets); mTaskStackView.setSystemInsets(mSystemInsets);
mStack = mTaskStackView.getStack();
addView(mTaskStackView); addView(mTaskStackView);
} }
@@ -187,9 +175,7 @@ public class RecentsView extends FrameLayout {
mLastTaskLaunchedWasFreeform = false; mLastTaskLaunchedWasFreeform = false;
// Update the stack // Update the stack
mTaskStackView.onResume(isResumingFromVisible); mTaskStackView.onReload(isResumingFromVisible);
mTaskStackView.setTasks(stack, isResumingFromVisible /* notifyStackChanges */,
true /* relayoutTaskStack */, multiWindowChange);
if (isResumingFromVisible) { if (isResumingFromVisible) {
// If we are already visible, then restore the background scrim // If we are already visible, then restore the background scrim
@@ -199,12 +185,20 @@ public class RecentsView extends FrameLayout {
// Otherwise, defer until the enter animation completes to animate the scrim alpha with // Otherwise, defer until the enter animation completes to animate the scrim alpha with
// the tasks for the home animation. // the tasks for the home animation.
if (launchState.launchedWhileDocking || launchState.launchedFromApp if (launchState.launchedWhileDocking || launchState.launchedFromApp
|| mStack.getTaskCount() == 0) { || isTaskStackEmpty) {
mBackgroundScrim.setAlpha((int) (DEFAULT_SCRIM_ALPHA * 255)); mBackgroundScrim.setAlpha((int) (DEFAULT_SCRIM_ALPHA * 255));
} else { } else {
mBackgroundScrim.setAlpha(0); mBackgroundScrim.setAlpha(0);
} }
} }
}
/**
* Called from RecentsActivity when the task stack is updated.
*/
public void updateStack(TaskStack stack) {
mStack = stack;
mTaskStackView.setTasks(stack, true /* allowNotifyStackChanges */);
// Update the top level view's visibilities // Update the top level view's visibilities
if (stack.getTaskCount() > 0) { if (stack.getTaskCount() > 0) {
@@ -214,6 +208,13 @@ public class RecentsView extends FrameLayout {
} }
} }
/**
* Returns the current TaskStack.
*/
public TaskStack getStack() {
return mStack;
}
/** /**
* Returns whether the last task launched was in the freeform stack or not. * Returns whether the last task launched was in the freeform stack or not.
*/ */

View File

@@ -46,7 +46,7 @@ public class SystemBarScrimViews {
/** /**
* Prepares the scrim views for animating when entering Recents. This will be called before * Prepares the scrim views for animating when entering Recents. This will be called before
* the first draw. * the first draw, unless we are updating the scrim on configuration change.
*/ */
public void prepareEnterRecentsAnimation(boolean hasNavBarScrim, boolean animateNavBarScrim) { public void prepareEnterRecentsAnimation(boolean hasNavBarScrim, boolean animateNavBarScrim) {
mHasNavBarScrim = hasNavBarScrim; mHasNavBarScrim = hasNavBarScrim;

View File

@@ -152,8 +152,6 @@ public class TaskStackAnimationHelper {
if (hideTask) { if (hideTask) {
tv.setVisibility(View.INVISIBLE); tv.setVisibility(View.INVISIBLE);
} else if (launchState.launchedHasConfigurationChanged) {
// Just load the views as-is
} else if (launchState.launchedFromApp && !launchState.launchedWhileDocking) { } else if (launchState.launchedFromApp && !launchState.launchedWhileDocking) {
if (task.isLaunchTarget) { if (task.isLaunchTarget) {
tv.onPrepareLaunchTargetForEnterAnimation(); tv.onPrepareLaunchTargetForEnterAnimation();
@@ -354,6 +352,12 @@ public class TaskStackAnimationHelper {
if (tv == launchingTaskView) { if (tv == launchingTaskView) {
tv.setClipViewInStack(false); tv.setClipViewInStack(false);
postAnimationTrigger.addLastDecrementRunnable(new Runnable() {
@Override
public void run() {
tv.setClipViewInStack(true);
}
});
tv.onStartLaunchTargetLaunchAnimation(taskViewExitToAppDuration, tv.onStartLaunchTargetLaunchAnimation(taskViewExitToAppDuration,
screenPinningRequested, postAnimationTrigger); screenPinningRequested, postAnimationTrigger);
} else if (currentTaskOccludesLaunchTarget) { } else if (currentTaskOccludesLaunchTarget) {
@@ -386,7 +390,8 @@ public class TaskStackAnimationHelper {
int taskViewRemoveAnimTranslationXPx = res.getDimensionPixelSize( int taskViewRemoveAnimTranslationXPx = res.getDimensionPixelSize(
R.dimen.recents_task_view_remove_anim_translation_x); R.dimen.recents_task_view_remove_anim_translation_x);
// Disabling clipping with the stack while the view is animating away // Disabling clipping with the stack while the view is animating away, this will get
// restored when the task is next picked up from the view pool
deleteTaskView.setClipViewInStack(false); deleteTaskView.setClipViewInStack(false);
// Compose the new animation and transform and star the animation // Compose the new animation and transform and star the animation
@@ -395,9 +400,6 @@ public class TaskStackAnimationHelper {
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
postAnimationTrigger.decrement(); postAnimationTrigger.decrement();
// Re-enable clipping with the stack (we will reuse this view)
deleteTaskView.setClipViewInStack(true);
} }
}); });
postAnimationTrigger.increment(); postAnimationTrigger.increment();

View File

@@ -852,7 +852,7 @@ public class TaskStackLayoutAlgorithm {
// in screen space // in screen space
float tmpP = (mMinScrollP - stackScroll) / mNumStackTasks; float tmpP = (mMinScrollP - stackScroll) / mNumStackTasks;
int centerYOffset = (mStackRect.top - mTaskRect.top) + int centerYOffset = (mStackRect.top - mTaskRect.top) +
(mStackRect.height() - mTaskRect.height()) / 2; (mStackRect.height() - mSystemInsets.bottom - mTaskRect.height()) / 2;
y = centerYOffset + getYForDeltaP(tmpP, 0); y = centerYOffset + getYForDeltaP(tmpP, 0);
z = mMaxTranslationZ; z = mMaxTranslationZ;
dimAlpha = 0f; dimAlpha = 0f;
@@ -953,14 +953,8 @@ public class TaskStackLayoutAlgorithm {
*/ */
public void getTaskStackBounds(Rect windowRect, int topInset, int rightInset, public void getTaskStackBounds(Rect windowRect, int topInset, int rightInset,
Rect taskStackBounds) { Rect taskStackBounds) {
RecentsConfiguration config = Recents.getConfiguration(); taskStackBounds.set(windowRect.left, windowRect.top + topInset,
if (config.hasTransposedNavBar) { windowRect.right - rightInset, windowRect.bottom);
taskStackBounds.set(windowRect.left, windowRect.top + topInset,
windowRect.right - rightInset, windowRect.bottom);
} else {
taskStackBounds.set(windowRect.left, windowRect.top + topInset,
windowRect.right - rightInset, windowRect.bottom);
}
// Ensure that the new width is at most the smaller display edge size // Ensure that the new width is at most the smaller display edge size
SystemServicesProxy ssp = Recents.getSystemServices(); SystemServicesProxy ssp = Recents.getSystemServices();
@@ -1105,9 +1099,11 @@ public class TaskStackLayoutAlgorithm {
private int getScaleForExtent(Rect instance, Rect other, int value, int minValue, private int getScaleForExtent(Rect instance, Rect other, int value, int minValue,
@Extent int extent) { @Extent int extent) {
if (extent == WIDTH) { if (extent == WIDTH) {
return Math.max(minValue, (int) (((float) instance.width() / other.width()) * value)); float scale = Utilities.clamp01((float) instance.width() / other.width());
return Math.max(minValue, (int) (scale * value));
} else if (extent == HEIGHT) { } else if (extent == HEIGHT) {
return Math.max(minValue, (int) (((float) instance.height() / other.height()) * value)); float scale = Utilities.clamp01((float) instance.height() / other.height());
return Math.max(minValue, (int) (scale * value));
} }
return value; return value;
} }

View File

@@ -22,6 +22,7 @@ import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.annotation.IntDef;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
@@ -87,6 +88,8 @@ import com.android.systemui.recents.misc.Utilities;
import com.android.systemui.recents.model.Task; import com.android.systemui.recents.model.Task;
import com.android.systemui.recents.model.TaskStack; import com.android.systemui.recents.model.TaskStack;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -116,10 +119,23 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
private static final ArraySet<Task.TaskKey> EMPTY_TASK_SET = new ArraySet<>(); private static final ArraySet<Task.TaskKey> EMPTY_TASK_SET = new ArraySet<>();
// The actions to perform when resetting to initial state,
@Retention(RetentionPolicy.SOURCE)
@IntDef({INITIAL_STATE_UPDATE_NONE, INITIAL_STATE_UPDATE_ALL, INITIAL_STATE_UPDATE_LAYOUT_ONLY})
public @interface InitialStateAction {}
/** Do not update the stack and layout to the initial state. */
private static final int INITIAL_STATE_UPDATE_NONE = 0;
/** Update both the stack and layout to the initial state. */
private static final int INITIAL_STATE_UPDATE_ALL = 1;
/** Update only the layout to the initial state. */
private static final int INITIAL_STATE_UPDATE_LAYOUT_ONLY = 2;
LayoutInflater mInflater; LayoutInflater mInflater;
TaskStack mStack = new TaskStack(); TaskStack mStack = new TaskStack();
@ViewDebug.ExportedProperty(deepExport=true, prefix="layout_") @ViewDebug.ExportedProperty(deepExport=true, prefix="layout_")
TaskStackLayoutAlgorithm mLayoutAlgorithm; TaskStackLayoutAlgorithm mLayoutAlgorithm;
// The stable layout algorithm is only used to calculate the task rect with the stable bounds
TaskStackLayoutAlgorithm mStableLayoutAlgorithm;
@ViewDebug.ExportedProperty(deepExport=true, prefix="scroller_") @ViewDebug.ExportedProperty(deepExport=true, prefix="scroller_")
TaskStackViewScroller mStackScroller; TaskStackViewScroller mStackScroller;
@ViewDebug.ExportedProperty(deepExport=true, prefix="touch_") @ViewDebug.ExportedProperty(deepExport=true, prefix="touch_")
@@ -148,6 +164,9 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
@ViewDebug.ExportedProperty(category="recents") @ViewDebug.ExportedProperty(category="recents")
boolean mAwaitingFirstLayout = true; boolean mAwaitingFirstLayout = true;
@ViewDebug.ExportedProperty(category="recents") @ViewDebug.ExportedProperty(category="recents")
@InitialStateAction
int mInitialState = INITIAL_STATE_UPDATE_ALL;
@ViewDebug.ExportedProperty(category="recents")
boolean mInMeasureLayout = false; boolean mInMeasureLayout = false;
@ViewDebug.ExportedProperty(category="recents") @ViewDebug.ExportedProperty(category="recents")
boolean mEnterAnimationComplete = false; boolean mEnterAnimationComplete = false;
@@ -223,6 +242,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
mViewPool = new ViewPool<>(context, this); mViewPool = new ViewPool<>(context, this);
mInflater = LayoutInflater.from(context); mInflater = LayoutInflater.from(context);
mLayoutAlgorithm = new TaskStackLayoutAlgorithm(context, this); mLayoutAlgorithm = new TaskStackLayoutAlgorithm(context, this);
mStableLayoutAlgorithm = new TaskStackLayoutAlgorithm(context, null);
mStackScroller = new TaskStackViewScroller(context, this, mLayoutAlgorithm); mStackScroller = new TaskStackViewScroller(context, this, mLayoutAlgorithm);
mTouchHandler = new TaskStackViewTouchHandler(context, this, mStackScroller); mTouchHandler = new TaskStackViewTouchHandler(context, this, mStackScroller);
mAnimationHelper = new TaskStackAnimationHelper(context, this); mAnimationHelper = new TaskStackAnimationHelper(context, this);
@@ -255,41 +275,6 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
} }
} }
/**
* Called only if we are resuming Recents.
*/
void onResume(boolean isResumingFromVisible) {
if (!isResumingFromVisible) {
// Reset the focused task
resetFocusedTask(getFocusedTask());
}
// Reset the state of each of the task views
List<TaskView> taskViews = new ArrayList<>();
taskViews.addAll(getTaskViews());
taskViews.addAll(mViewPool.getViews());
for (int i = taskViews.size() - 1; i >= 0; i--) {
taskViews.get(i).onResume(isResumingFromVisible);
}
// Reset the stack state
readSystemFlags();
mTaskViewsClipDirty = true;
mEnterAnimationComplete = false;
mUIDozeTrigger.stopDozing();
if (isResumingFromVisible) {
// Animate in the freeform workspace
int ffBgAlpha = mLayoutAlgorithm.getStackState().freeformBackgroundAlpha;
animateFreeformWorkspaceBackgroundAlpha(ffBgAlpha, new AnimationProps(150,
Interpolators.FAST_OUT_SLOW_IN));
} else {
mStackScroller.reset();
mLayoutAlgorithm.reset();
mAwaitingFirstLayout = true;
requestLayout();
}
}
@Override @Override
protected void onAttachedToWindow() { protected void onAttachedToWindow() {
EventBus.getDefault().register(this, RecentsActivity.EVENT_BUS_PRIORITY + 1); EventBus.getDefault().register(this, RecentsActivity.EVENT_BUS_PRIORITY + 1);
@@ -303,35 +288,55 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
EventBus.getDefault().unregister(this); EventBus.getDefault().unregister(this);
} }
/**
* Called from RecentsActivity when it is relaunched.
*/
void onReload(boolean isResumingFromVisible) {
if (!isResumingFromVisible) {
// Reset the focused task
resetFocusedTask(getFocusedTask());
}
// Reset the state of each of the task views
List<TaskView> taskViews = new ArrayList<>();
taskViews.addAll(getTaskViews());
taskViews.addAll(mViewPool.getViews());
for (int i = taskViews.size() - 1; i >= 0; i--) {
taskViews.get(i).onReload(isResumingFromVisible);
}
// Reset the stack state
readSystemFlags();
mTaskViewsClipDirty = true;
mEnterAnimationComplete = false;
mUIDozeTrigger.stopDozing();
if (isResumingFromVisible) {
// Animate in the freeform workspace
int ffBgAlpha = mLayoutAlgorithm.getStackState().freeformBackgroundAlpha;
animateFreeformWorkspaceBackgroundAlpha(ffBgAlpha, new AnimationProps(150,
Interpolators.FAST_OUT_SLOW_IN));
} else {
mStackScroller.reset();
mStableLayoutAlgorithm.reset();
mLayoutAlgorithm.reset();
}
// Since we always animate to the same place in (the initial state), always reset the stack
// to the initial state when resuming
mAwaitingFirstLayout = true;
mInitialState = INITIAL_STATE_UPDATE_ALL;
requestLayout();
}
/** /**
* Sets the stack tasks of this TaskStackView from the given TaskStack. * Sets the stack tasks of this TaskStackView from the given TaskStack.
*/ */
public void setTasks(TaskStack stack, boolean notifyStackChanges, boolean relayoutTaskStack, public void setTasks(TaskStack stack, boolean allowNotifyStackChanges) {
boolean multiWindowChange) {
boolean isInitialized = mLayoutAlgorithm.isInitialized(); boolean isInitialized = mLayoutAlgorithm.isInitialized();
// Only notify if we are already initialized, otherwise, everything will pick up all the
// new and old tasks when we next layout
mStack.setTasks(getContext(), stack.computeAllTasksList(), mStack.setTasks(getContext(), stack.computeAllTasksList(),
notifyStackChanges && isInitialized); allowNotifyStackChanges && isInitialized);
if (isInitialized) {
// Only update the layout if we are notifying, otherwise, we will update it in the next
// measure/layout pass
updateLayoutAlgorithm(false /* boundScroll */, EMPTY_TASK_SET);
if (!multiWindowChange) {
updateToInitialState();
}
if (relayoutTaskStack) {
relayoutTaskViews(AnimationProps.IMMEDIATE);
// Rebind all the task views. This will not trigger new resources to be loaded
// unless they have actually changed
List<TaskView> taskViews = getTaskViews();
int taskViewCount = taskViews.size();
for (int i = 0; i < taskViewCount; i++) {
TaskView tv = taskViews.get(i);
bindTaskView(tv, tv.getTask());
}
}
}
} }
/** Returns the task stack. */ /** Returns the task stack. */
@@ -342,8 +347,10 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
/** /**
* Updates this TaskStackView to the initial state. * Updates this TaskStackView to the initial state.
*/ */
public void updateToInitialState() { public void updateToInitialState(boolean scrollToInitialState) {
mStackScroller.setStackScrollToInitialState(); if (scrollToInitialState) {
mStackScroller.setStackScrollToInitialState();
}
mLayoutAlgorithm.updateToInitialState(mStack.getStackTasks()); mLayoutAlgorithm.updateToInitialState(mStack.getStackTasks());
} }
@@ -771,8 +778,6 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
* Updates the clip for each of the task views from back to front. * Updates the clip for each of the task views from back to front.
*/ */
private void clipTaskViews() { private void clipTaskViews() {
RecentsConfiguration config = Recents.getConfiguration();
// Update the clip on each task child // Update the clip on each task child
List<TaskView> taskViews = getTaskViews(); List<TaskView> taskViews = getTaskViews();
TaskView tmpTv = null; TaskView tmpTv = null;
@@ -1177,6 +1182,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
*/ */
public void setSystemInsets(Rect systemInsets) { public void setSystemInsets(Rect systemInsets) {
if (!systemInsets.equals(mLayoutAlgorithm.mSystemInsets)) { if (!systemInsets.equals(mLayoutAlgorithm.mSystemInsets)) {
mStableLayoutAlgorithm.setSystemInsets(systemInsets);
mLayoutAlgorithm.setSystemInsets(systemInsets); mLayoutAlgorithm.setSystemInsets(systemInsets);
requestLayout(); requestLayout();
} }
@@ -1205,17 +1211,17 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
} }
// Compute the rects in the stack algorithm // Compute the rects in the stack algorithm
mStableLayoutAlgorithm.initialize(mStableWindowRect, mStableStackBounds,
TaskStackLayoutAlgorithm.StackState.getStackStateForStack(mStack));
mLayoutAlgorithm.initialize(mWindowRect, mStackBounds, mLayoutAlgorithm.initialize(mWindowRect, mStackBounds,
TaskStackLayoutAlgorithm.StackState.getStackStateForStack(mStack)); TaskStackLayoutAlgorithm.StackState.getStackStateForStack(mStack));
updateLayoutAlgorithm(false /* boundScroll */, EMPTY_TASK_SET); updateLayoutAlgorithm(false /* boundScroll */, EMPTY_TASK_SET);
// If this is the first layout, then scroll to the front of the stack, then update the // If this is the first layout, then scroll to the front of the stack, then update the
// TaskViews with the stack so that we can lay them out // TaskViews with the stack so that we can lay them out
// TODO: The second check is a workaround for wacky layouts that we get while docking via if (mAwaitingFirstLayout || mInitialState != INITIAL_STATE_UPDATE_NONE) {
// long pressing the recents button updateToInitialState(mInitialState != INITIAL_STATE_UPDATE_LAYOUT_ONLY);
if (mAwaitingFirstLayout || mInitialState = INITIAL_STATE_UPDATE_NONE;
(mStackScroller.getStackScroll() == mLayoutAlgorithm.mInitialScrollP)) {
updateToInitialState();
} }
// Rebind all the views, including the ignore ones // Rebind all the views, including the ignore ones
@@ -1244,12 +1250,11 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
} else { } else {
mTmpRect.setEmpty(); mTmpRect.setEmpty();
} }
Rect taskRect = mStableLayoutAlgorithm.mTaskRect;
tv.measure( tv.measure(
MeasureSpec.makeMeasureSpec( MeasureSpec.makeMeasureSpec(taskRect.width() + mTmpRect.left + mTmpRect.right,
mLayoutAlgorithm.mTaskRect.width() + mTmpRect.left + mTmpRect.right,
MeasureSpec.EXACTLY), MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec( MeasureSpec.makeMeasureSpec(taskRect.height() + mTmpRect.top + mTmpRect.bottom,
mLayoutAlgorithm.mTaskRect.height() + mTmpRect.top + mTmpRect.bottom,
MeasureSpec.EXACTLY)); MeasureSpec.EXACTLY));
} }
@@ -1288,7 +1293,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
} else { } else {
mTmpRect.setEmpty(); mTmpRect.setEmpty();
} }
Rect taskRect = mLayoutAlgorithm.mTaskRect; Rect taskRect = mStableLayoutAlgorithm.mTaskRect;
tv.cancelTransformAnimation(); tv.cancelTransformAnimation();
tv.layout(taskRect.left - mTmpRect.left, taskRect.top - mTmpRect.top, tv.layout(taskRect.left - mTmpRect.left, taskRect.top - mTmpRect.top,
taskRect.right + mTmpRect.right, taskRect.bottom + mTmpRect.bottom); taskRect.right + mTmpRect.right, taskRect.bottom + mTmpRect.bottom);
@@ -1439,6 +1444,22 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
} }
} }
@Override
public void onStackTasksUpdated(TaskStack stack) {
// Update the layout and immediately layout
updateLayoutAlgorithm(false /* boundScroll */);
relayoutTaskViews(AnimationProps.IMMEDIATE);
// Rebind all the task views. This will not trigger new resources to be loaded
// unless they have actually changed
List<TaskView> taskViews = getTaskViews();
int taskViewCount = taskViews.size();
for (int i = 0; i < taskViewCount; i++) {
TaskView tv = taskViews.get(i);
bindTaskView(tv, tv.getTask());
}
}
/**** ViewPoolConsumer Implementation ****/ /**** ViewPoolConsumer Implementation ****/
@Override @Override
@@ -1911,9 +1932,25 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
} }
public final void onBusEvent(ConfigurationChangedEvent event) { public final void onBusEvent(ConfigurationChangedEvent event) {
mStableLayoutAlgorithm.reloadOnConfigurationChange(getContext());
mLayoutAlgorithm.reloadOnConfigurationChange(getContext()); mLayoutAlgorithm.reloadOnConfigurationChange(getContext());
mLayoutAlgorithm.initialize(mWindowRect, mStackBounds,
TaskStackLayoutAlgorithm.StackState.getStackStateForStack(mStack)); // Notify the task views of the configuration change so they can reload their resources
if (!event.fromMultiWindow) {
mTmpTaskViews.clear();
mTmpTaskViews.addAll(getTaskViews());
mTmpTaskViews.addAll(mViewPool.getViews());
int taskViewCount = mTmpTaskViews.size();
for (int i = 0; i < taskViewCount; i++) {
mTmpTaskViews.get(i).onConfigurationChanged();
}
}
// Trigger a new layout and scroll to the initial state
mInitialState = event.fromMultiWindow
? INITIAL_STATE_UPDATE_ALL
: INITIAL_STATE_UPDATE_LAYOUT_ONLY;
requestLayout();
} }
/** /**

View File

@@ -24,6 +24,7 @@ import android.animation.ObjectAnimator;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Outline; import android.graphics.Outline;
import android.graphics.Paint; import android.graphics.Paint;
@@ -191,15 +192,15 @@ public class TaskView extends FixedSizeFrameLayout implements Task.TaskCallbacks
mCb = cb; mCb = cb;
} }
/** Resets this TaskView for reuse. */ /**
void onResume(boolean isResumingFromVisible) { * Called from RecentsActivity when it is relaunched.
*/
void onReload(boolean isResumingFromVisible) {
resetNoUserInteractionState(); resetNoUserInteractionState();
readSystemFlags(); readSystemFlags();
if (!isResumingFromVisible) { if (!isResumingFromVisible) {
resetViewProperties(); resetViewProperties();
setClipViewInStack(false);
} }
setCallbacks(null);
} }
/** Gets the task */ /** Gets the task */
@@ -237,6 +238,13 @@ public class TaskView extends FixedSizeFrameLayout implements Task.TaskCallbacks
mActionButtonTranslationZ = mActionButtonView.getTranslationZ(); mActionButtonTranslationZ = mActionButtonView.getTranslationZ();
} }
/**
* Update the task view when the configuration changes.
*/
void onConfigurationChanged() {
mHeaderView.onConfigurationChanged();
}
@Override @Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) { protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh); super.onSizeChanged(w, h, oldw, oldh);

View File

@@ -250,6 +250,44 @@ public class TaskViewHeader extends FrameLayout
mFocusTimerIndicatorStub = (ViewStub) findViewById(R.id.focus_timer_indicator_stub); mFocusTimerIndicatorStub = (ViewStub) findViewById(R.id.focus_timer_indicator_stub);
mAppOverlayViewStub = (ViewStub) findViewById(R.id.app_overlay_stub); mAppOverlayViewStub = (ViewStub) findViewById(R.id.app_overlay_stub);
onConfigurationChanged();
}
/**
* Programmatically sets the layout params for a header bar layout. This is necessary because
* we can't get resources based on the current configuration, but instead need to get them
* based on the device configuration.
*/
private void updateLayoutParams(View icon, View title, View secondaryButton, View button) {
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, mHeaderBarHeight, Gravity.TOP);
setLayoutParams(lp);
lp = new FrameLayout.LayoutParams(mHeaderBarHeight, mHeaderBarHeight, Gravity.START);
icon.setLayoutParams(lp);
lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL);
lp.setMarginStart(mHeaderBarHeight);
lp.rightMargin = mMoveTaskButton != null
? 2 * mHeaderBarHeight
: mHeaderBarHeight;
title.setLayoutParams(lp);
if (secondaryButton != null) {
lp = new FrameLayout.LayoutParams(mHeaderBarHeight, mHeaderBarHeight, Gravity.END);
lp.setMarginEnd(mHeaderBarHeight);
secondaryButton.setLayoutParams(lp);
secondaryButton.setPadding(mHeaderButtonPadding, mHeaderButtonPadding,
mHeaderButtonPadding, mHeaderButtonPadding);
}
lp = new FrameLayout.LayoutParams(mHeaderBarHeight, mHeaderBarHeight, Gravity.END);
button.setLayoutParams(lp);
button.setPadding(mHeaderButtonPadding, mHeaderButtonPadding, mHeaderButtonPadding,
mHeaderButtonPadding);
}
/**
* Update the header view when the configuration changes.
*/
void onConfigurationChanged() {
// Update the dimensions of everything in the header. We do this because we need to use // Update the dimensions of everything in the header. We do this because we need to use
// resources for the display, and not the current configuration. // resources for the display, and not the current configuration.
Resources res = getResources(); Resources res = getResources();
@@ -269,37 +307,9 @@ public class TaskViewHeader extends FrameLayout
R.dimen.recents_task_view_header_button_padding_tablet_land); R.dimen.recents_task_view_header_button_padding_tablet_land);
updateLayoutParams(mIconView, findViewById(R.id.title_container), mMoveTaskButton, updateLayoutParams(mIconView, findViewById(R.id.title_container), mMoveTaskButton,
mDismissButton); mDismissButton);
} if (mAppOverlayView != null) {
updateLayoutParams(mAppIconView, mAppTitleView, null, mAppInfoView);
/**
* Programmatically sets the layout params for a header bar layout. This is necessary because
* we can't get resources based on the current configuration, but instead need to get them
* based on the device configuration.
*/
private void updateLayoutParams(View icon, View title, View secondaryButton, View button) {
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, mHeaderBarHeight, Gravity.TOP);
setLayoutParams(lp);
lp = new FrameLayout.LayoutParams(mHeaderBarHeight, mHeaderBarHeight, Gravity.START);
icon.setLayoutParams(lp);
lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL);
lp.leftMargin = mHeaderBarHeight;
lp.rightMargin = mMoveTaskButton != null
? 2 * mHeaderBarHeight
: mHeaderBarHeight;
title.setLayoutParams(lp);
if (secondaryButton != null) {
lp = new FrameLayout.LayoutParams(mHeaderBarHeight, mHeaderBarHeight, Gravity.END);
lp.rightMargin = mHeaderBarHeight;
secondaryButton.setLayoutParams(lp);
secondaryButton.setPadding(mHeaderButtonPadding, mHeaderButtonPadding,
mHeaderButtonPadding, mHeaderButtonPadding);
} }
lp = new FrameLayout.LayoutParams(mHeaderBarHeight, mHeaderBarHeight, Gravity.END);
button.setLayoutParams(lp);
button.setPadding(mHeaderButtonPadding, mHeaderButtonPadding, mHeaderButtonPadding,
mHeaderButtonPadding);
} }
@Override @Override

View File

@@ -243,11 +243,6 @@ public class TaskViewThumbnail extends View {
public void updateThumbnailScale() { public void updateThumbnailScale() {
mThumbnailScale = 1f; mThumbnailScale = 1f;
if (mBitmapShader != null) { if (mBitmapShader != null) {
if (mThumbnailInfo != null) {
System.out.println(mTask.title + " bounds: " + mThumbnailInfo.taskWidth + "x" + mThumbnailInfo.taskHeight + ", " + mThumbnailInfo.screenOrientation);
}
// We consider this a stack task if it is not freeform (ie. has no bounds) or has been // We consider this a stack task if it is not freeform (ie. has no bounds) or has been
// dragged into the stack from the freeform workspace // dragged into the stack from the freeform workspace
boolean isStackTask = !mTask.isFreeformTask() || mTask.bounds == null; boolean isStackTask = !mTask.isFreeformTask() || mTask.bounds == null;