Search in sources :

Example 6 with TaskKey

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

the class FallbackRecentsView method applyLoadPlan.

@Override
protected void applyLoadPlan(ArrayList<GroupTask> taskGroups) {
    // When quick-switching on 3p-launcher, we add a "stub" tile corresponding to Launcher
    // as well. This tile is never shown as we have setCurrentTaskHidden, but allows use to
    // track the index of the next task appropriately, as if we are switching on any other app.
    // TODO(b/195607777) Confirm home task info is front-most task and not mixed in with others
    int runningTaskId = getTaskIdsForRunningTaskView()[0];
    if (mHomeTaskInfo != null && mHomeTaskInfo.taskId == runningTaskId && !taskGroups.isEmpty()) {
        // Check if the task list has running task
        boolean found = false;
        for (GroupTask group : taskGroups) {
            if (group.containsTask(runningTaskId)) {
                found = true;
                break;
            }
        }
        if (!found) {
            ArrayList<GroupTask> newList = new ArrayList<>(taskGroups.size() + 1);
            newList.addAll(taskGroups);
            newList.add(new GroupTask(Task.from(new TaskKey(mHomeTaskInfo), mHomeTaskInfo, false), null, null));
            taskGroups = newList;
        }
    }
    super.applyLoadPlan(taskGroups);
}
Also used : ArrayList(java.util.ArrayList) GroupTask(com.android.quickstep.util.GroupTask) TaskKey(com.android.systemui.shared.recents.model.Task.TaskKey)

Example 7 with TaskKey

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

the class RecentsView method showCurrentTask.

/**
 * Creates a task view (if necessary) to represent the task with the {@param runningTaskId}.
 *
 * All subsequent calls to reload will keep the task as the first item until {@link #reset()}
 * is called.  Also scrolls the view to this task.
 */
private void showCurrentTask(RunningTaskInfo[] runningTaskInfo) {
    int runningTaskViewId = -1;
    boolean needGroupTaskView = runningTaskInfo.length > 1;
    RunningTaskInfo taskInfo = runningTaskInfo[0];
    if (shouldAddStubTaskView(runningTaskInfo)) {
        boolean wasEmpty = getChildCount() == 0;
        // Add an empty view for now until the task plan is loaded and applied
        final TaskView taskView;
        if (needGroupTaskView) {
            taskView = getTaskViewFromPool(true);
            RunningTaskInfo secondaryTaskInfo = runningTaskInfo[1];
            mTmpRunningTasks = new Task[] { Task.from(new TaskKey(taskInfo), taskInfo, false), Task.from(new TaskKey(secondaryTaskInfo), secondaryTaskInfo, false) };
            addView(taskView, 0);
            // When we create a placeholder task view mSplitBoundsConfig will be null, but with
            // the actual app running we won't need to show the thumbnail until all the tasks
            // load later anyways
            ((GroupedTaskView) taskView).bind(mTmpRunningTasks[0], mTmpRunningTasks[1], mOrientationState, mSplitBoundsConfig);
        } else {
            taskView = getTaskViewFromPool(false);
            addView(taskView, 0);
            // The temporary running task is only used for the duration between the start of the
            // gesture and the task list is loaded and applied
            mTmpRunningTasks = new Task[] { Task.from(new TaskKey(taskInfo), taskInfo, false) };
            taskView.bind(mTmpRunningTasks[0], mOrientationState);
        }
        runningTaskViewId = taskView.getTaskViewId();
        if (wasEmpty) {
            addView(mClearAllButton);
        }
        // Measure and layout immediately so that the scroll values is updated instantly
        // as the user might be quick-switching
        measure(makeMeasureSpec(getMeasuredWidth(), EXACTLY), makeMeasureSpec(getMeasuredHeight(), EXACTLY));
        layout(getLeft(), getTop(), getRight(), getBottom());
    } else if (getTaskViewByTaskId(taskInfo.taskId) != null) {
        runningTaskViewId = getTaskViewByTaskId(taskInfo.taskId).getTaskViewId();
    }
    boolean runningTaskTileHidden = mRunningTaskTileHidden;
    setCurrentTask(runningTaskViewId);
    mFocusedTaskViewId = runningTaskViewId;
    setCurrentPage(getRunningTaskIndex());
    setRunningTaskViewShowScreenshot(false);
    setRunningTaskHidden(runningTaskTileHidden);
    // Update task size after setting current task.
    updateTaskSize();
    updateChildTaskOrientations();
    // Reload the task list
    reloadIfNeeded();
}
Also used : RunningTaskInfo(android.app.ActivityManager.RunningTaskInfo) TaskKey(com.android.systemui.shared.recents.model.Task.TaskKey) TextPaint(android.text.TextPaint) Point(android.graphics.Point)

Example 8 with TaskKey

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

the class RecentsView method showCurrentTask.

/**
 * Creates a task view (if necessary) to represent the task with the {@param runningTaskId}.
 *
 * All subsequent calls to reload will keep the task as the first item until {@link #reset()}
 * is called.  Also scrolls the view to this task.
 */
private void showCurrentTask(RunningTaskInfo[] runningTaskInfo) {
    int runningTaskViewId = -1;
    boolean needGroupTaskView = runningTaskInfo.length > 1;
    RunningTaskInfo taskInfo = runningTaskInfo[0];
    if (shouldAddStubTaskView(runningTaskInfo)) {
        boolean wasEmpty = getChildCount() == 0;
        // Add an empty view for now until the task plan is loaded and applied
        final TaskView taskView;
        if (needGroupTaskView) {
            taskView = getTaskViewFromPool(true);
            RunningTaskInfo secondaryTaskInfo = runningTaskInfo[1];
            mTmpRunningTasks = new Task[] { Task.from(new TaskKey(taskInfo), taskInfo, false), Task.from(new TaskKey(secondaryTaskInfo), secondaryTaskInfo, false) };
            addView(taskView, 0);
            // When we create a placeholder task view mSplitBoundsConfig will be null, but with
            // the actual app running we won't need to show the thumbnail until all the tasks
            // load later anyways
            ((GroupedTaskView) taskView).bind(mTmpRunningTasks[0], mTmpRunningTasks[1], mOrientationState, mSplitBoundsConfig);
        } else {
            taskView = getTaskViewFromPool(false);
            addView(taskView, 0);
            // The temporary running task is only used for the duration between the start of the
            // gesture and the task list is loaded and applied
            mTmpRunningTasks = new Task[] { Task.from(new TaskKey(taskInfo), taskInfo, false) };
            taskView.bind(mTmpRunningTasks[0], mOrientationState);
        }
        runningTaskViewId = taskView.getTaskViewId();
        if (wasEmpty) {
            addView(mClearAllButton);
        }
        // Measure and layout immediately so that the scroll values is updated instantly
        // as the user might be quick-switching
        measure(makeMeasureSpec(getMeasuredWidth(), EXACTLY), makeMeasureSpec(getMeasuredHeight(), EXACTLY));
        layout(getLeft(), getTop(), getRight(), getBottom());
    } else if (getTaskViewByTaskId(taskInfo.taskId) != null) {
        runningTaskViewId = getTaskViewByTaskId(taskInfo.taskId).getTaskViewId();
    }
    boolean runningTaskTileHidden = mRunningTaskTileHidden;
    setCurrentTask(runningTaskViewId);
    mFocusedTaskViewId = runningTaskViewId;
    setCurrentPage(getRunningTaskIndex());
    setRunningTaskViewShowScreenshot(false);
    setRunningTaskHidden(runningTaskTileHidden);
    // Update task size after setting current task.
    updateTaskSize();
    updateChildTaskOrientations();
    // Reload the task list
    reloadIfNeeded();
}
Also used : RunningTaskInfo(android.app.ActivityManager.RunningTaskInfo) TaskKey(com.android.systemui.shared.recents.model.Task.TaskKey) TextPaint(android.text.TextPaint) Point(android.graphics.Point)

Example 9 with TaskKey

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

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)

Example 10 with TaskKey

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

the class FallbackRecentsView method applyLoadPlan.

@Override
protected void applyLoadPlan(ArrayList<GroupTask> taskGroups) {
    // When quick-switching on 3p-launcher, we add a "stub" tile corresponding to Launcher
    // as well. This tile is never shown as we have setCurrentTaskHidden, but allows use to
    // track the index of the next task appropriately, as if we are switching on any other app.
    // TODO(b/195607777) Confirm home task info is front-most task and not mixed in with others
    int runningTaskId = getTaskIdsForRunningTaskView()[0];
    if (mHomeTaskInfo != null && mHomeTaskInfo.taskId == runningTaskId && !taskGroups.isEmpty()) {
        // Check if the task list has running task
        boolean found = false;
        for (GroupTask group : taskGroups) {
            if (group.containsTask(runningTaskId)) {
                found = true;
                break;
            }
        }
        if (!found) {
            ArrayList<GroupTask> newList = new ArrayList<>(taskGroups.size() + 1);
            newList.addAll(taskGroups);
            newList.add(new GroupTask(Task.from(new TaskKey(mHomeTaskInfo), mHomeTaskInfo, false), null, null));
            taskGroups = newList;
        }
    }
    super.applyLoadPlan(taskGroups);
}
Also used : ArrayList(java.util.ArrayList) GroupTask(com.android.quickstep.util.GroupTask) TaskKey(com.android.systemui.shared.recents.model.Task.TaskKey)

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