summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Winson Chung <winsonc@google.com> 2015-09-29 22:58:01 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2015-09-29 22:58:01 +0000
commit8aefdb4881caefed5cb10c2fe6d7bb1281ef3c9e (patch)
treeb61dee6c7b93ae9d5cb2eaaccb646c6b7055e6d9
parent2c53a0759742eeec8f123ad81b7a26aef222c378 (diff)
parentec417e4cc082e1734e7184c51762d21a430c0b38 (diff)
Merge "Update task bounds for recents enter animation."
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/Recents.java144
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java15
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewLayoutAlgorithm.java8
5 files changed, 85 insertions, 96 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/Recents.java b/packages/SystemUI/src/com/android/systemui/recents/Recents.java
index 3e23ed8029cf..23cc8f067d83 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/Recents.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/Recents.java
@@ -163,7 +163,6 @@ public class Recents extends SystemUI
static RecentsTaskLoadPlan sInstanceLoadPlan;
static Recents sInstance;
- LayoutInflater mInflater;
SystemServicesProxy mSystemServicesProxy;
Handler mHandler;
TaskStackListenerImpl mTaskStackListener;
@@ -175,12 +174,14 @@ public class Recents extends SystemUI
// Task launching
RecentsConfiguration mConfig;
+ Rect mSearchBarBounds = new Rect();
Rect mTaskStackBounds = new Rect();
- Rect mSystemInsets = new Rect();
+ Rect mLastTaskViewBounds = new Rect();
TaskViewTransform mTmpTransform = new TaskViewTransform();
int mStatusBarHeight;
int mNavBarHeight;
int mNavBarWidth;
+ int mTaskBarHeight;
// Header (for transition)
TaskViewHeader mHeaderBar;
@@ -228,11 +229,11 @@ public class Recents extends SystemUI
if (sInstance == null) {
sInstance = this;
}
+ Resources res = mContext.getResources();
RecentsTaskLoader.initialize(mContext);
- mInflater = LayoutInflater.from(mContext);
+ LayoutInflater inflater = LayoutInflater.from(mContext);
mSystemServicesProxy = new SystemServicesProxy(mContext);
mHandler = new Handler();
- mTaskStackBounds = new Rect();
mAppWidgetHost = new RecentsAppWidgetHost(mContext, Constants.Values.App.AppWidgetHostId);
// Register the task stack listener
@@ -240,7 +241,7 @@ public class Recents extends SystemUI
mSystemServicesProxy.registerTaskStackListener(mTaskStackListener);
// Only the owner has the callback to update the SysUI visibility flags, so all non-owner
- // instances of AlternateRecentsComponent needs to notify the owner when the visibility
+ // instances of RecentsComponent needs to notify the owner when the visibility
// changes.
if (mSystemServicesProxy.isForegroundUserSystem()) {
mProxyBroadcastReceiver = new RecentsOwnerEventProxyReceiver();
@@ -253,8 +254,16 @@ public class Recents extends SystemUI
// Initialize some static datastructures
TaskStackViewLayoutAlgorithm.initializeCurve();
- // Load the header bar layout
- reloadHeaderBarLayout();
+ // Initialize the static configuration resources
+ mConfig = RecentsConfiguration.initialize(mContext, mSystemServicesProxy);
+ mStatusBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
+ mNavBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height);
+ mNavBarWidth = res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width);
+ mTaskBarHeight = res.getDimensionPixelSize(R.dimen.recents_task_bar_height);
+ mDummyStackView = new TaskStackView(mContext, new TaskStack());
+ mHeaderBar = (TaskViewHeader) inflater.inflate(R.layout.recents_task_view_header,
+ null, false);
+ reloadHeaderBarLayout(true /* tryAndBindSearchWidget */);
// When we start, preload the data associated with the previous recent tasks.
// We can use a new plan since the caches will be the same.
@@ -272,6 +281,7 @@ public class Recents extends SystemUI
@Override
public void onBootCompleted() {
mBootCompleted = true;
+ reloadHeaderBarLayout(true /* tryAndBindSearchWidget */);
}
/** Shows the Recents. */
@@ -292,7 +302,7 @@ public class Recents extends SystemUI
mTriggeredFromAltTab = triggeredFromAltTab;
try {
- startRecentsActivity();
+ showRecentsActivity();
} catch (ActivityNotFoundException e) {
Console.logRawError("Failed to launch RecentAppsIntent", e);
}
@@ -487,55 +497,52 @@ public class Recents extends SystemUI
void configurationChanged() {
// Don't reuse task stack views if the configuration changes
mCanReuseTaskStackViews = false;
- // Reload the header bar layout
- reloadHeaderBarLayout();
+ mConfig.updateOnConfigurationChange();
}
- /** Prepares the header bar layout. */
- void reloadHeaderBarLayout() {
- Resources res = mContext.getResources();
+ /**
+ * Prepares the header bar layout for the next transition, if the task view bounds has changed
+ * since the last call, it will attempt to re-measure and layout the header bar to the new size.
+ *
+ * @param tryAndBindSearchWidget if set, will attempt to fetch and bind the search widget if one
+ * is not already bound (can be expensive)
+ */
+ void reloadHeaderBarLayout(boolean tryAndBindSearchWidget) {
Rect windowRect = mSystemServicesProxy.getWindowRect();
- mStatusBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
- mNavBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height);
- mNavBarWidth = res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width);
- mConfig = RecentsConfiguration.initialize(mContext, mSystemServicesProxy);
+ // Update the configuration for the current state
mConfig.update(mContext, mSystemServicesProxy, mSystemServicesProxy.getWindowRect());
- mConfig.updateOnConfigurationChange();
- Rect searchBarBounds = new Rect();
- // Try and pre-emptively bind the search widget on startup to ensure that we
- // have the right thumbnail bounds to animate to.
- // Note: We have to reload the widget id before we get the task stack bounds below
- if (mSystemServicesProxy.getOrBindSearchAppWidget(mContext, mAppWidgetHost) != null) {
- mConfig.getSearchBarBounds(windowRect,
- mStatusBarHeight, searchBarBounds);
+
+ if (tryAndBindSearchWidget) {
+ // Try and pre-emptively bind the search widget on startup to ensure that we
+ // have the right thumbnail bounds to animate to.
+ // Note: We have to reload the widget id before we get the task stack bounds below
+ if (mSystemServicesProxy.getOrBindSearchAppWidget(mContext, mAppWidgetHost) != null) {
+ mConfig.getSearchBarBounds(windowRect,
+ mStatusBarHeight, mSearchBarBounds);
+ }
}
mConfig.getAvailableTaskStackBounds(windowRect,
- mStatusBarHeight, (mConfig.hasTransposedNavBar ? mNavBarWidth : 0), searchBarBounds,
- mTaskStackBounds);
- if (mConfig.hasTransposedNavBar) {
- mSystemInsets.set(0, mStatusBarHeight, mNavBarWidth, 0);
- } else {
- mSystemInsets.set(0, mStatusBarHeight, 0, mNavBarHeight);
- }
+ mStatusBarHeight, (mConfig.hasTransposedNavBar ? mNavBarWidth : 0),
+ mSearchBarBounds, mTaskStackBounds);
+ int systemBarBottomInset = mConfig.hasTransposedNavBar ? 0 : mNavBarHeight;
- // Inflate the header bar layout so that we can rebind and draw it for the transition
- TaskStack stack = new TaskStack();
- mDummyStackView = new TaskStackView(mContext, stack);
+ // Rebind the header bar and draw it for the transition
TaskStackViewLayoutAlgorithm algo = mDummyStackView.getStackAlgorithm();
Rect taskStackBounds = new Rect(mTaskStackBounds);
- taskStackBounds.bottom -= mSystemInsets.bottom;
+ taskStackBounds.bottom -= systemBarBottomInset;
algo.computeRects(windowRect.width(), windowRect.height(), taskStackBounds);
- Rect taskViewSize = algo.getUntransformedTaskViewSize();
- int taskBarHeight = res.getDimensionPixelSize(R.dimen.recents_task_bar_height);
- synchronized (mHeaderBarLock) {
- mHeaderBar = (TaskViewHeader) mInflater.inflate(R.layout.recents_task_view_header, null,
- false);
- mHeaderBar.measure(
- View.MeasureSpec.makeMeasureSpec(taskViewSize.width(), View.MeasureSpec.EXACTLY),
- View.MeasureSpec.makeMeasureSpec(taskBarHeight, View.MeasureSpec.EXACTLY));
- // TODO: may not be needed
- mHeaderBar.layout(0, 0, taskViewSize.width(), taskBarHeight);
+ Rect taskViewBounds = algo.getUntransformedTaskViewBounds();
+ if (!taskViewBounds.equals(mLastTaskViewBounds)) {
+ mLastTaskViewBounds.set(taskViewBounds);
+
+ int taskViewWidth = taskViewBounds.width();
+ synchronized (mHeaderBarLock) {
+ mHeaderBar.measure(
+ View.MeasureSpec.makeMeasureSpec(taskViewWidth, View.MeasureSpec.EXACTLY),
+ View.MeasureSpec.makeMeasureSpec(mTaskBarHeight, View.MeasureSpec.EXACTLY));
+ mHeaderBar.layout(0, 0, taskViewWidth, mTaskBarHeight);
+ }
}
}
@@ -560,17 +567,17 @@ public class Recents extends SystemUI
return;
} else {
// Otherwise, start the recents activity
- startRecentsActivity(topTask, isTopTaskHome.value);
+ showRecentsActivity(topTask, isTopTaskHome.value);
}
}
- /** Starts the recents activity if it is not already running */
- void startRecentsActivity() {
+ /** Shows the recents activity if it is not already running */
+ void showRecentsActivity() {
// Check if the top task is in the home stack, and start the recents activity
ActivityManager.RunningTaskInfo topTask = mSystemServicesProxy.getTopMostTask();
MutableBoolean isTopTaskHome = new MutableBoolean(true);
if (topTask == null || !mSystemServicesProxy.isRecentsTopMost(topTask, isTopTaskHome)) {
- startRecentsActivity(topTask, isTopTaskHome.value);
+ showRecentsActivity(topTask, isTopTaskHome.value);
}
}
@@ -732,33 +739,18 @@ public class Recents extends SystemUI
return mTmpTransform;
}
- /** Starts the recents activity */
- void startRecentsActivity(ActivityManager.RunningTaskInfo topTask, boolean isTopTaskHome) {
+ /** Shows the recents activity */
+ void showRecentsActivity(ActivityManager.RunningTaskInfo topTask, boolean isTopTaskHome) {
RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
- // Don't reinitialize the configuration completely here, since it has the wrong context,
- // only update the parts that we can get from any context
- RecentsConfiguration config = RecentsConfiguration.getInstance();
- config.update(mContext, mSystemServicesProxy, mSystemServicesProxy.getWindowRect());
+
+ // Update the header bar if necessary
+ reloadHeaderBarLayout(false /* tryAndBindSearchWidget */);
if (sInstanceLoadPlan == null) {
// Create a new load plan if onPreloadRecents() was never triggered
sInstanceLoadPlan = loader.createLoadPlan(mContext);
}
- // Temporarily skip the transition (use a dummy fade) if multi stack is enabled.
- // For multi-stack we need to figure out where each of the tasks are going.
- if (mConfig.multiWindowEnabled) {
- loader.preloadTasks(sInstanceLoadPlan, true);
- TaskStack stack = sInstanceLoadPlan.getTaskStack();
- mDummyStackView.updateMinMaxScrollForStack(stack, mTriggeredFromAltTab, true);
- TaskStackViewLayoutAlgorithm.VisibilityReport stackVr =
- mDummyStackView.computeStackVisibilityReport();
- ActivityOptions opts = getUnknownTransitionActivityOptions();
- startAlternateRecentsActivity(topTask, opts, true /* fromHome */,
- false /* fromSearchHome */, false /* fromThumbnail */, stackVr);
- return;
- }
-
if (!sInstanceLoadPlan.hasTasks()) {
loader.preloadTasks(sInstanceLoadPlan, isTopTaskHome);
}
@@ -777,7 +769,7 @@ public class Recents extends SystemUI
ActivityOptions opts = getThumbnailTransitionActivityOptions(topTask, stack,
mDummyStackView);
if (opts != null) {
- startAlternateRecentsActivity(topTask, opts, false /* fromHome */,
+ startRecentsActivity(topTask, opts, false /* fromHome */,
false /* fromSearchHome */, true /* fromThumbnail */, stackVr);
} else {
// Fall through below to the non-thumbnail transition
@@ -797,12 +789,12 @@ public class Recents extends SystemUI
boolean fromSearchHome = (homeActivityPackage != null) &&
homeActivityPackage.equals(searchWidgetPackage);
ActivityOptions opts = getHomeTransitionActivityOptions(fromSearchHome);
- startAlternateRecentsActivity(topTask, opts, true /* fromHome */, fromSearchHome,
+ startRecentsActivity(topTask, opts, true /* fromHome */, fromSearchHome,
false /* fromThumbnail */, stackVr);
} else {
// Otherwise we do the normal fade from an unknown source
ActivityOptions opts = getUnknownTransitionActivityOptions();
- startAlternateRecentsActivity(topTask, opts, true /* fromHome */,
+ startRecentsActivity(topTask, opts, true /* fromHome */,
false /* fromSearchHome */, false /* fromThumbnail */, stackVr);
}
}
@@ -810,9 +802,9 @@ public class Recents extends SystemUI
}
/** Starts the recents activity */
- void startAlternateRecentsActivity(ActivityManager.RunningTaskInfo topTask,
- ActivityOptions opts, boolean fromHome, boolean fromSearchHome, boolean fromThumbnail,
- TaskStackViewLayoutAlgorithm.VisibilityReport vr) {
+ void startRecentsActivity(ActivityManager.RunningTaskInfo topTask,
+ ActivityOptions opts, boolean fromHome, boolean fromSearchHome, boolean fromThumbnail,
+ TaskStackViewLayoutAlgorithm.VisibilityReport vr) {
// Update the configuration based on the launch options
RecentsActivityLaunchState launchState = mConfig.getLaunchState();
launchState.launchedFromHome = fromSearchHome || fromHome;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
index b6d25f507cb9..472303e64043 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
@@ -697,6 +697,14 @@ public class SystemServicesProxy {
ActivityManager.StackInfo stackInfo = mIam.getStackInfo(ActivityManager.HOME_STACK_ID);
if (stackInfo != null) {
windowRect.set(stackInfo.bounds);
+ // Temporary workaround, if we query this too early, occasionally, the home stack
+ // bounds are offset incorrectly
+ if (windowRect.left < 0) {
+ windowRect.offset(-windowRect.left, 0);
+ }
+ if (windowRect.top < 0) {
+ windowRect.offset(0, -windowRect.top);
+ }
}
} catch (RemoteException e) {
e.printStackTrace();
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
index 92ed0f1b1731..73c9be94eeae 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
@@ -584,17 +584,10 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
}
postDrawHeaderThumbnailTransitionRunnable(stackView, tv, offsetX, offsetY, stackScroll,
animStartedListener);
- if (mConfig.multiWindowEnabled) {
- opts = ActivityOptions.makeCustomAnimation(sourceView.getContext(),
- R.anim.recents_from_unknown_enter,
- R.anim.recents_from_unknown_exit,
- sourceView.getHandler(), animStartedListener);
- } else {
- opts = ActivityOptions.makeThumbnailAspectScaleUpAnimation(sourceView,
- Bitmap.createBitmap(1, 1, Bitmap.Config.ALPHA_8).createAshmemBitmap(),
- offsetX, offsetY, transform.rect.width(), transform.rect.height(),
- sourceView.getHandler(), animStartedListener);
- }
+ opts = ActivityOptions.makeThumbnailAspectScaleUpAnimation(sourceView,
+ Bitmap.createBitmap(1, 1, Bitmap.Config.ALPHA_8).createAshmemBitmap(),
+ offsetX, offsetY, transform.rect.width(), transform.rect.height(),
+ sourceView.getHandler(), animStartedListener);
} else {
opts = ActivityOptions.makeBasic();
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
index b5ad112098e3..b5f29a01c2b0 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
@@ -865,9 +865,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
}
// Start dozing
- if (!mConfig.multiWindowEnabled) {
- mUIDozeTrigger.startDozing();
- }
+ mUIDozeTrigger.startDozing();
}
/** Requests this task stacks to start it's enter-recents animation */
@@ -1293,7 +1291,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
RecentsTaskLoader.getInstance().loadTaskData(task);
// If the doze trigger has already fired, then update the state for this task view
- if (mConfig.multiWindowEnabled || mUIDozeTrigger.hasTriggered()) {
+ if (mUIDozeTrigger.hasTriggered()) {
tv.setNoUserInteractionState();
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewLayoutAlgorithm.java
index 8128cac66c1c..7f4c0a5f7cb4 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewLayoutAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewLayoutAlgorithm.java
@@ -275,11 +275,9 @@ public class TaskStackViewLayoutAlgorithm {
return transformOut;
}
- /** Returns the untransformed task view size. */
- public Rect getUntransformedTaskViewSize() {
- Rect tvSize = new Rect(mTaskRect);
- tvSize.offsetTo(0, 0);
- return tvSize;
+ /** Returns the untransformed task view bounds. */
+ public Rect getUntransformedTaskViewBounds() {
+ return new Rect(mTaskRect);
}
/** Returns the scroll to such task top = 1f; */