Using the RecentsService connection to toggle recents
- Adding over scroll snap back when flinging stack
Change-Id: Ife9692ece95e0a40649d0b4b72ec4ea99ffabc16
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 c85c14b..9133f7d 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
@@ -40,14 +40,27 @@
* to their SpaceNode bounds.
*/
public class RecentsView extends FrameLayout implements TaskStackView.TaskStackViewCallbacks {
+
+ /** The RecentsView callbacks */
+ public interface RecentsViewCallbacks {
+ public void onTaskLaunching();
+ }
+
// The space partitioning root of this container
SpaceNode mBSP;
+ // Recents view callbacks
+ RecentsViewCallbacks mCb;
public RecentsView(Context context) {
super(context);
setWillNotDraw(false);
}
+ /** Sets the callbacks */
+ public void setCallbacks(RecentsViewCallbacks cb) {
+ mCb = cb;
+ }
+
/** Set/get the bsp root node */
public void setBSP(SpaceNode n) {
mBSP = n;
@@ -64,14 +77,19 @@
/** Launches the first task from the first stack if possible */
public boolean launchFirstTask() {
+ // Get the first stack view
int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
TaskStackView stackView = (TaskStackView) getChildAt(i);
TaskStack stack = stackView.mStack;
ArrayList<Task> tasks = stack.getTasks();
+
+ // Get the first task in the stack
if (!tasks.isEmpty()) {
Task task = tasks.get(tasks.size() - 1);
TaskView tv = null;
+
+ // Try and use the first child task view as the source of the launch animation
if (stackView.getChildCount() > 0) {
TaskView stv = (TaskView) stackView.getChildAt(stackView.getChildCount() - 1);
if (stv.getTask() == task) {
@@ -133,13 +151,15 @@
@Override
protected void dispatchDraw(Canvas canvas) {
- Console.log(Constants.DebugFlags.UI.Draw, "[RecentsView|dispatchDraw]", "", Console.AnsiPurple);
+ Console.log(Constants.DebugFlags.UI.Draw, "[RecentsView|dispatchDraw]", "",
+ Console.AnsiPurple);
super.dispatchDraw(canvas);
}
@Override
protected boolean fitSystemWindows(Rect insets) {
- Console.log(Constants.DebugFlags.UI.MeasureAndLayout, "[RecentsView|fitSystemWindows]", "insets: " + insets, Console.AnsiGreen);
+ Console.log(Constants.DebugFlags.UI.MeasureAndLayout,
+ "[RecentsView|fitSystemWindows]", "insets: " + insets, Console.AnsiGreen);
// Update the configuration with the latest system insets and trigger a relayout
RecentsConfiguration config = RecentsConfiguration.getInstance();
@@ -166,11 +186,16 @@
return false;
}
- /**** View.OnClickListener Implementation ****/
+ /**** TaskStackView.TaskStackCallbacks Implementation ****/
@Override
public void onTaskLaunched(final TaskStackView stackView, final TaskView tv,
final TaskStack stack, final Task task) {
+ // Notify any callbacks of the launching of a new task
+ if (mCb != null) {
+ mCb.onTaskLaunching();
+ }
+
final Runnable launchRunnable = new Runnable() {
@Override
public void run() {
@@ -221,7 +246,7 @@
// Launch the app right away if there is no task view, otherwise, animate the icon out first
if (tv == null || !Constants.Values.TaskView.AnimateFrontTaskIconOnLeavingRecents) {
- launchRunnable.run();
+ post(launchRunnable);
} else {
tv.animateOnLeavingRecents(launchRunnable);
}