Search in sources :

Example 16 with TaskKey

use of com.android.systemui.shared.recents.model.Task.TaskKey in project android_packages_apps_Trebuchet by LineageOS.

the class FallbackRecentsView method applyLoadPlan.

@Override
protected void applyLoadPlan(ArrayList<Task> tasks) {
    // track the index of the next task appropriately, as if we are switching on any other app.
    if (mHomeTaskInfo != null && mHomeTaskInfo.taskId == mRunningTaskId && !tasks.isEmpty()) {
        // Check if the task list has running task
        boolean found = false;
        for (Task t : tasks) {
            if (t.key.id == mRunningTaskId) {
                found = true;
                break;
            }
        }
        if (!found) {
            ArrayList<Task> newList = new ArrayList<>(tasks.size() + 1);
            newList.addAll(tasks);
            newList.add(Task.from(new TaskKey(mHomeTaskInfo), mHomeTaskInfo, false));
            tasks = newList;
        }
    }
    super.applyLoadPlan(tasks);
}
Also used : Task(com.android.systemui.shared.recents.model.Task) ArrayList(java.util.ArrayList) TaskKey(com.android.systemui.shared.recents.model.Task.TaskKey)

Example 17 with TaskKey

use of com.android.systemui.shared.recents.model.Task.TaskKey in project android_packages_apps_Launcher3 by ArrowOS.

the class TaskIconCache method getCacheEntry.

@WorkerThread
private TaskCacheEntry getCacheEntry(Task task) {
    TaskCacheEntry entry = mIconCache.getAndInvalidateIfModified(task.key);
    if (entry != null) {
        return entry;
    }
    TaskDescription desc = task.taskDescription;
    TaskKey key = task.key;
    ActivityInfo activityInfo = null;
    // Create new cache entry
    entry = new TaskCacheEntry();
    // Load icon
    // TODO: Load icon resource (b/143363444)
    Bitmap icon = TaskDescriptionCompat.getIcon(desc, key.userId);
    if (icon != null) {
        /* isInstantApp */
        entry.icon = getBitmapInfo(new BitmapDrawable(mContext.getResources(), icon), key.userId, desc.getPrimaryColor(), false).newIcon(mContext);
    } else {
        activityInfo = PackageManagerWrapper.getInstance().getActivityInfo(key.getComponent(), key.userId);
        if (activityInfo != null) {
            BitmapInfo bitmapInfo = getBitmapInfo(mIconProvider.getIcon(activityInfo), key.userId, desc.getPrimaryColor(), activityInfo.applicationInfo.isInstantApp());
            entry.icon = bitmapInfo.newIcon(mContext);
        } else {
            entry.icon = getDefaultIcon(key.userId);
        }
    }
    // Loading content descriptions if accessibility or low RAM recents is enabled.
    if (GO_LOW_RAM_RECENTS_ENABLED || mAccessibilityManager.isEnabled()) {
        // Skip loading the content description if the activity no longer exists
        if (activityInfo == null) {
            activityInfo = PackageManagerWrapper.getInstance().getActivityInfo(key.getComponent(), key.userId);
        }
        if (activityInfo != null) {
            entry.contentDescription = getBadgedContentDescription(activityInfo, task.key.userId, task.taskDescription);
        }
    }
    mIconCache.put(task.key, entry);
    return entry;
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) Bitmap(android.graphics.Bitmap) TaskDescription(android.app.ActivityManager.TaskDescription) BitmapDrawable(android.graphics.drawable.BitmapDrawable) TaskKey(com.android.systemui.shared.recents.model.Task.TaskKey) BitmapInfo(com.android.launcher3.icons.BitmapInfo) WorkerThread(androidx.annotation.WorkerThread)

Aggregations

TaskKey (com.android.systemui.shared.recents.model.Task.TaskKey)17 TaskDescription (android.app.ActivityManager.TaskDescription)6 ActivityInfo (android.content.pm.ActivityInfo)6 Bitmap (android.graphics.Bitmap)6 BitmapDrawable (android.graphics.drawable.BitmapDrawable)6 WorkerThread (androidx.annotation.WorkerThread)6 BitmapInfo (com.android.launcher3.icons.BitmapInfo)6 ArrayList (java.util.ArrayList)6 Point (android.graphics.Point)5 TextPaint (android.text.TextPaint)5 RunningTaskInfo (android.app.ActivityManager.RunningTaskInfo)4 GroupTask (com.android.quickstep.util.GroupTask)4 Task (com.android.systemui.shared.recents.model.Task)2 FastBitmapDrawable (com.android.launcher3.FastBitmapDrawable)1