summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2014-04-09 15:17:43 -0700
committerWinson Chung <winsonc@google.com>2014-04-09 15:19:57 -0700
commitb44c24fb50845dfbc1f49e78085cf5e01a32067f (patch)
treec945b3fbac2713e00a21fac870b884219dc4f0a1 /packages/SystemUI
parent0d767551c55d9e594a0b944bd1926c21a344b5ae (diff)
downloadframeworks_base-b44c24fb50845dfbc1f49e78085cf5e01a32067f.zip
frameworks_base-b44c24fb50845dfbc1f49e78085cf5e01a32067f.tar.gz
frameworks_base-b44c24fb50845dfbc1f49e78085cf5e01a32067f.tar.bz2
Removing duplicated code in Recents
- Also disabling the animation on the first task view when animating from home - Fixing a case where filtered and non-filtered state can be exactly the same Change-Id: I01665391fc0b0745a89e404b12280d3d919aec83
Diffstat (limited to 'packages/SystemUI')
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java40
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/Constants.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java11
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/RecentsService.java25
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java5
8 files changed, 58 insertions, 39 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
index b72294b..4fb90cb 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/AlternateRecentsComponent.java
@@ -58,10 +58,10 @@ public class AlternateRecentsComponent {
Resources res = mContext.getResources();
float statusBarHeight = res.getDimensionPixelSize(
com.android.internal.R.dimen.status_bar_height);
- Bundle replyData = msg.getData().getParcelable("replyData");
- mSingleCountFirstTaskRect = replyData.getParcelable("singleCountTaskRect");
+ Bundle replyData = msg.getData().getParcelable(KEY_CONFIGURATION_DATA);
+ mSingleCountFirstTaskRect = replyData.getParcelable(KEY_SINGLE_TASK_STACK_RECT);
mSingleCountFirstTaskRect.offset(0, (int) statusBarHeight);
- mMultipleCountFirstTaskRect = replyData.getParcelable("multipleCountTaskRect");
+ mMultipleCountFirstTaskRect = replyData.getParcelable(KEY_MULTIPLE_TASK_STACK_RECT);
mMultipleCountFirstTaskRect.offset(0, (int) statusBarHeight);
}
}
@@ -93,12 +93,20 @@ public class AlternateRecentsComponent {
}
}
- final static int MSG_UPDATE_FOR_CONFIGURATION = 0;
- final static int MSG_UPDATE_TASK_THUMBNAIL = 1;
- final static int MSG_PRELOAD_TASKS = 2;
- final static int MSG_CANCEL_PRELOAD_TASKS = 3;
- final static int MSG_CLOSE_RECENTS = 4;
- final static int MSG_TOGGLE_RECENTS = 5;
+ final public static int MSG_UPDATE_FOR_CONFIGURATION = 0;
+ final public static int MSG_UPDATE_TASK_THUMBNAIL = 1;
+ final public static int MSG_PRELOAD_TASKS = 2;
+ final public static int MSG_CANCEL_PRELOAD_TASKS = 3;
+ final public static int MSG_CLOSE_RECENTS = 4;
+ final public static int MSG_TOGGLE_RECENTS = 5;
+
+ final public static String EXTRA_ANIMATING_WITH_THUMBNAIL = "recents.animatingWithThumbnail";
+ final public static String KEY_CONFIGURATION_DATA = "recents.data.updateForConfiguration";
+ final public static String KEY_WINDOW_RECT = "recents.windowRect";
+ final public static String KEY_SYSTEM_INSETS = "recents.systemInsets";
+ final public static String KEY_SINGLE_TASK_STACK_RECT = "recents.singleCountTaskRect";
+ final public static String KEY_MULTIPLE_TASK_STACK_RECT = "recents.multipleCountTaskRect";
+
final static int sMinToggleDelay = 425;
@@ -195,8 +203,8 @@ public class AlternateRecentsComponent {
// Try and update the recents configuration
try {
Bundle data = new Bundle();
- data.putParcelable("windowRect", rect);
- data.putParcelable("systemInsets", new Rect(0, statusBarHeight, 0, 0));
+ data.putParcelable(KEY_WINDOW_RECT, rect);
+ data.putParcelable(KEY_SYSTEM_INSETS, new Rect(0, statusBarHeight, 0, 0));
Message msg = Message.obtain(null, MSG_UPDATE_FOR_CONFIGURATION, 0, 0);
msg.setData(data);
msg.replyTo = mMessenger;
@@ -226,8 +234,7 @@ public class AlternateRecentsComponent {
return null;
}
- Bitmap thumbnail = ssp.getTaskThumbnail(t.persistentId);
- return thumbnail;
+ return ssp.getTaskThumbnail(t.persistentId);
}
return null;
}
@@ -365,12 +372,12 @@ public class AlternateRecentsComponent {
ActivityOptions opts = ActivityOptions.makeThumbnailScaleDownAnimation(mStatusBarView,
thumbnail, taskRect.left, taskRect.top, null);
- startAlternateRecentsActivity(opts);
+ startAlternateRecentsActivity(opts, true);
} else {
ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext,
R.anim.recents_from_launcher_enter,
R.anim.recents_from_launcher_exit);
- startAlternateRecentsActivity(opts);
+ startAlternateRecentsActivity(opts, false);
}
Console.logTraceTime(Constants.DebugFlags.App.TimeRecentsStartup,
@@ -379,11 +386,12 @@ public class AlternateRecentsComponent {
}
/** Starts the recents activity */
- void startAlternateRecentsActivity(ActivityOptions opts) {
+ void startAlternateRecentsActivity(ActivityOptions opts, boolean animatingWithThumbnail) {
Intent intent = new Intent(sToggleRecentsAction);
intent.setClassName(sRecentsPackage, sRecentsActivity);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
+ intent.putExtra(EXTRA_ANIMATING_WITH_THUMBNAIL, animatingWithThumbnail);
if (opts != null) {
mContext.startActivityAsUser(intent, opts.toBundle(), new UserHandle(
UserHandle.USER_CURRENT));
diff --git a/packages/SystemUI/src/com/android/systemui/recents/Constants.java b/packages/SystemUI/src/com/android/systemui/recents/Constants.java
index 26446cf..cde17f5 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/Constants.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/Constants.java
@@ -96,8 +96,8 @@ public class Constants {
}
public static class TaskView {
- public static final boolean AnimateFrontTaskIconOnEnterRecents = true;
- public static final boolean AnimateFrontTaskIconOnLeavingRecents = true;
+ public static final boolean AnimateFrontTaskBarOnEnterRecents = true;
+ public static final boolean AnimateFrontTaskBarOnLeavingRecents = true;
}
}
} \ No newline at end of file
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
index 64c67b1..f61c28c 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
@@ -73,7 +73,12 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
};
/** Updates the set of recent tasks */
- void updateRecentsTasks() {
+ void updateRecentsTasks(Intent launchIntent) {
+ // Update the configuration based on the launch intent
+ RecentsConfiguration config = RecentsConfiguration.getInstance();
+ config.launchedWithThumbnailAnimation = launchIntent.getBooleanExtra(
+ AlternateRecentsComponent.EXTRA_ANIMATING_WITH_THUMBNAIL, false);
+
RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
SpaceNode root = loader.reload(this, Constants.Values.RecentsTaskLoader.PreloadFirstTasksCount);
ArrayList<TaskStack> stacks = root.getStacks();
@@ -137,7 +142,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
setContentView(mContainerView);
// Update the recent tasks
- updateRecentsTasks();
+ updateRecentsTasks(getIntent());
}
@Override
@@ -157,7 +162,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
RecentsConfiguration.reinitialize(this);
// Update the recent tasks
- updateRecentsTasks();
+ updateRecentsTasks(intent);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
index 017581a..21460bb 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
@@ -41,6 +41,8 @@ public class RecentsConfiguration {
public int filteringNewViewsMinAnimDuration;
public int taskBarEnterAnimDuration;
+ public boolean launchedWithThumbnailAnimation;
+
/** Private constructor */
private RecentsConfiguration() {}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsService.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsService.java
index 96fbf30..f78a999 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsService.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsService.java
@@ -51,14 +51,14 @@ class SystemUIMessageHandler extends Handler {
Context context = mContext.get();
if (context == null) return;
- if (msg.what == RecentsService.MSG_UPDATE_RECENTS_FOR_CONFIGURATION) {
+ if (msg.what == AlternateRecentsComponent.MSG_UPDATE_FOR_CONFIGURATION) {
RecentsTaskLoader.initialize(context);
RecentsConfiguration.reinitialize(context);
try {
Bundle data = msg.getData();
- Rect windowRect = (Rect) data.getParcelable("windowRect");
- Rect systemInsets = (Rect) data.getParcelable("systemInsets");
+ Rect windowRect = data.getParcelable(AlternateRecentsComponent.KEY_WINDOW_RECT);
+ Rect systemInsets = data.getParcelable(AlternateRecentsComponent.KEY_SYSTEM_INSETS);
// Create a dummy task stack & compute the rect for the thumbnail to animate to
TaskStack stack = new TaskStack(context);
@@ -73,7 +73,8 @@ class SystemUIMessageHandler extends Handler {
tsv.computeRects(windowRect.width(), windowRect.height() - systemInsets.top, 0);
tsv.boundScroll();
transform = tsv.getStackTransform(0, tsv.getStackScroll());
- replyData.putParcelable("singleCountTaskRect", new Rect(transform.rect));
+ replyData.putParcelable(AlternateRecentsComponent.KEY_SINGLE_TASK_STACK_RECT,
+ new Rect(transform.rect));
// Also calculate the target task rect when there are multiple tasks
stack.addTask(new Task());
@@ -81,19 +82,20 @@ class SystemUIMessageHandler extends Handler {
tsv.setStackScrollRaw(Integer.MAX_VALUE);
tsv.boundScroll();
transform = tsv.getStackTransform(1, tsv.getStackScroll());
- replyData.putParcelable("multipleCountTaskRect", new Rect(transform.rect));
+ replyData.putParcelable(AlternateRecentsComponent.KEY_MULTIPLE_TASK_STACK_RECT,
+ new Rect(transform.rect));
- data.putParcelable("replyData", replyData);
+ data.putParcelable(AlternateRecentsComponent.KEY_CONFIGURATION_DATA, replyData);
Message reply = Message.obtain(null,
- RecentsService.MSG_UPDATE_RECENTS_FOR_CONFIGURATION, 0, 0);
+ AlternateRecentsComponent.MSG_UPDATE_FOR_CONFIGURATION, 0, 0);
reply.setData(data);
msg.replyTo.send(reply);
} catch (RemoteException re) {
re.printStackTrace();
}
- } else if (msg.what == RecentsService.MSG_CLOSE_RECENTS) {
+ } else if (msg.what == AlternateRecentsComponent.MSG_CLOSE_RECENTS) {
// Do nothing
- } else if (msg.what == RecentsService.MSG_TOGGLE_RECENTS) {
+ } else if (msg.what == AlternateRecentsComponent.MSG_TOGGLE_RECENTS) {
// Send a broadcast to toggle recents
Intent intent = new Intent(RecentsService.ACTION_TOGGLE_RECENTS_ACTIVITY);
intent.setPackage(context.getPackageName());
@@ -113,11 +115,6 @@ public class RecentsService extends Service {
final static String ACTION_FINISH_RECENTS_ACTIVITY = "action_finish_recents_activity";
final static String ACTION_TOGGLE_RECENTS_ACTIVITY = "action_toggle_recents_activity";
- // XXX: This should be getting the message from recents definition
- final static int MSG_UPDATE_RECENTS_FOR_CONFIGURATION = 0;
- final static int MSG_CLOSE_RECENTS = 4;
- final static int MSG_TOGGLE_RECENTS = 5;
-
Messenger mSystemUIMessenger = new Messenger(new SystemUIMessageHandler(this));
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
index a0e5b6a..21e2c1d 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/TaskStack.java
@@ -43,7 +43,13 @@ class FilteredTaskList {
ArrayList<Task> prevFilteredTasks = new ArrayList<Task>(mFilteredTasks);
mFilter = filter;
updateFilteredTasks();
- return !prevFilteredTasks.equals(mFilteredTasks);
+ if (!prevFilteredTasks.equals(mFilteredTasks)) {
+ return true;
+ } else {
+ // If the tasks are exactly the same pre/post filter, then just reset it
+ mFilter = null;
+ return false;
+ }
}
/** Removes the task filter and returns the previous touch state */
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 141d870..ec28379 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
@@ -277,7 +277,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
Constants.DebugFlags.App.TimeRecentsLaunchKey, "onTaskLaunched");
// Launch the app right away if there is no task view, otherwise, animate the icon out first
- if (tv == null || !Constants.Values.TaskView.AnimateFrontTaskIconOnLeavingRecents) {
+ if (tv == null || !Constants.Values.TaskView.AnimateFrontTaskBarOnLeavingRecents) {
post(launchRunnable);
} else {
tv.animateOnLeavingRecents(launchRunnable);
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 ce0d91f..728aaad 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
@@ -563,8 +563,9 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
requestSynchronizeStackViewsWithModel();
synchronizeStackViewsWithModel();
- // Animate the icon of the first task view
- if (Constants.Values.TaskView.AnimateFrontTaskIconOnEnterRecents) {
+ // Animate the task bar of the first task view
+ if (config.launchedWithThumbnailAnimation &&
+ Constants.Values.TaskView.AnimateFrontTaskBarOnEnterRecents) {
TaskView tv = (TaskView) getChildAt(getChildCount() - 1);
if (tv != null) {
tv.animateOnEnterRecents();