Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4be0445c authored by Winson Chung's avatar Winson Chung
Browse files

Fixing issue where we were relaunching each activity from recents instead of...

Fixing issue where we were relaunching each activity from recents instead of bringing them to the front.
parent 37c8d8ef
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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));
                    }
                }
            }
+6 −3
Original line number Diff line number Diff line
@@ -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 */
+25 −10
Original line number Diff line number Diff line
@@ -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,6 +242,18 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
                            b, offsetX, offsetY);
                }


                if (task.isActive) {
                    // Bring an active task to the foreground
                    ActivityManager am = (ActivityManager)
                            stackView.getContext().getSystemService(Context.ACTIVITY_SERVICE);
                    if (opts != null) {
                        am.moveTaskToFront(task.key.id, ActivityManager.MOVE_TASK_WITH_HOME,
                                opts.toBundle());
                    } else {
                        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
@@ -248,13 +261,15 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
                            | Intent.FLAG_ACTIVITY_NEW_TASK);
                    try {
                        if (opts != null) {
                        getContext().startActivityAsUser(i, opts.toBundle(), UserHandle.CURRENT);
                            getContext().startActivityAsUser(i, opts.toBundle(),
                                    UserHandle.CURRENT);
                        } else {
                            getContext().startActivityAsUser(i, UserHandle.CURRENT);
                        }
                    } catch (ActivityNotFoundException anfe) {
                        Console.logError(getContext(), "Could not start Activity");
                    }
                }

                Console.logTraceTime(Constants.DebugFlags.App.TimeRecentsLaunchTask,
                        Constants.DebugFlags.App.TimeRecentsLaunchKey, "startActivity");