use of com.android.systemui.shared.recents.model.Task.TaskKey in project android_packages_apps_Launcher3 by crdroidandroid.
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;
}
use of com.android.systemui.shared.recents.model.Task.TaskKey in project android_packages_apps_Launcher3 by AOSPA.
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();
}
use of com.android.systemui.shared.recents.model.Task.TaskKey in project android_packages_apps_Launcher3 by AOSPA.
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;
}
use of com.android.systemui.shared.recents.model.Task.TaskKey in project android_packages_apps_Launcher3 by AOSPA.
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);
}
use of com.android.systemui.shared.recents.model.Task.TaskKey in project android_packages_apps_Trebuchet by LineageOS.
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) {
entry.icon = new FastBitmapDrawable(getBitmapInfo(new BitmapDrawable(mContext.getResources(), icon), key.userId, desc.getPrimaryColor(), false));
} else {
activityInfo = PackageManagerWrapper.getInstance().getActivityInfo(key.getComponent(), key.userId);
if (activityInfo != null) {
BitmapInfo bitmapInfo = getBitmapInfo(mIconProvider.getIcon(activityInfo, UserHandle.of(key.userId)), key.userId, desc.getPrimaryColor(), activityInfo.applicationInfo.isInstantApp());
entry.icon = newIcon(mContext, bitmapInfo);
} 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 = ActivityManagerWrapper.getInstance().getBadgedContentDescription(activityInfo, task.key.userId, task.taskDescription);
}
}
mIconCache.put(task.key, entry);
return entry;
}
Aggregations