summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/model/Task.java9
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java35
3 files changed, 34 insertions, 15 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java
index 4601b0b4b64e..b497b69ce53e 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsTaskLoader.java
@@ -422,7 +422,7 @@ public class RecentsTaskLoader {
if (t.activityIcon != null) {
bd = new BitmapDrawable(res, t.activityIcon);
}
- Task task = new Task(t.persistentId, t.baseIntent, label, bd);
+ Task task = new Task(t.persistentId, (t.id > -1), t.baseIntent, label, bd);
// Load the icon (if possible and not the foremost task, from the cache)
if (task.icon != null) {
@@ -477,7 +477,8 @@ public class RecentsTaskLoader {
for (int j = 0; j < Constants.Values.RecentsTaskLoader.TaskEntryMultiplier; j++) {
Console.log(Constants.DebugFlags.App.TaskDataLoader,
" [RecentsTaskLoader|task]", t.baseIntent.getComponent().getPackageName());
- stack.addTask(new Task(t.persistentId, t.baseIntent, title, null, null));
+ stack.addTask(new Task(t.persistentId, (t.id > -1), t.baseIntent, title,
+ null, null));
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
index 7b335af1a547..cda4ab2feedd 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/Task.java
@@ -64,18 +64,21 @@ public class Task {
public String title;
public Drawable icon;
public Bitmap thumbnail;
+ public boolean isActive;
TaskCallbacks mCb;
- public Task(int id, Intent intent, String activityTitle, Drawable icon) {
- this(id, intent, activityTitle, icon, null);
+ public Task(int id, boolean isActive, Intent intent, String activityTitle, Drawable icon) {
+ this(id, isActive, intent, activityTitle, icon, null);
}
- public Task(int id, Intent intent, String activityTitle, Drawable icon, Bitmap thumbnail) {
+ public Task(int id, boolean isActive, Intent intent, String activityTitle, Drawable icon,
+ Bitmap thumbnail) {
this.key = new TaskKey(id, intent);
this.title = activityTitle;
this.icon = icon;
this.thumbnail = thumbnail;
+ this.isActive = isActive;
}
/** Set the callbacks */
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 d997222dc427..cc85439ed127 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
@@ -16,6 +16,7 @@
package com.android.systemui.recents.views;
+import android.app.ActivityManager;
import android.app.ActivityOptions;
import android.content.ActivityNotFoundException;
import android.content.Context;
@@ -241,19 +242,33 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
b, offsetX, offsetY);
}
- // Launch the activity with the desired animation
- Intent i = new Intent(task.key.intent);
- i.setFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
- | Intent.FLAG_ACTIVITY_TASK_ON_HOME
- | Intent.FLAG_ACTIVITY_NEW_TASK);
- try {
+
+ if (task.isActive) {
+ // Bring an active task to the foreground
+ ActivityManager am = (ActivityManager)
+ stackView.getContext().getSystemService(Context.ACTIVITY_SERVICE);
if (opts != null) {
- getContext().startActivityAsUser(i, opts.toBundle(), UserHandle.CURRENT);
+ am.moveTaskToFront(task.key.id, ActivityManager.MOVE_TASK_WITH_HOME,
+ opts.toBundle());
} else {
- getContext().startActivityAsUser(i, UserHandle.CURRENT);
+ am.moveTaskToFront(task.key.id, ActivityManager.MOVE_TASK_WITH_HOME);
+ }
+ } else {
+ // Launch the activity with the desired animation
+ Intent i = new Intent(task.key.intent);
+ i.setFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
+ | Intent.FLAG_ACTIVITY_TASK_ON_HOME
+ | Intent.FLAG_ACTIVITY_NEW_TASK);
+ try {
+ if (opts != null) {
+ getContext().startActivityAsUser(i, opts.toBundle(),
+ UserHandle.CURRENT);
+ } else {
+ getContext().startActivityAsUser(i, UserHandle.CURRENT);
+ }
+ } catch (ActivityNotFoundException anfe) {
+ Console.logError(getContext(), "Could not start Activity");
}
- } catch (ActivityNotFoundException anfe) {
- Console.logError(getContext(), "Could not start Activity");
}
Console.logTraceTime(Constants.DebugFlags.App.TimeRecentsLaunchTask,