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
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -41,6 +41,8 @@ public class RecentsConfiguration {
|
||||
public int filteringNewViewsMinAnimDuration;
|
||||
public int taskBarEnterAnimDuration;
|
||||
|
||||
public boolean launchedWithThumbnailAnimation;
|
||||
|
||||
/** Private constructor */
|
||||
private RecentsConfiguration() {}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user