use of com.android.systemui.recents.RecentsConfiguration in project android_frameworks_base by DirtyUnicorns.
the class TaskStackView method onFirstLayout.
/** Handler for the first layout. */
void onFirstLayout() {
// Setup the view for the enter animation
mAnimationHelper.prepareForEnterAnimation();
// Animate in the freeform workspace
int ffBgAlpha = mLayoutAlgorithm.getStackState().freeformBackgroundAlpha;
animateFreeformWorkspaceBackgroundAlpha(ffBgAlpha, new AnimationProps(150, Interpolators.FAST_OUT_SLOW_IN));
// Set the task focused state without requesting view focus, and leave the focus animations
// until after the enter-animation
RecentsConfiguration config = Recents.getConfiguration();
RecentsActivityLaunchState launchState = config.getLaunchState();
// We set the initial focused task view iff the following conditions are satisfied:
// 1. Recents is showing task views in stack layout.
// 2. Recents is launched with ALT + TAB.
boolean setFocusOnFirstLayout = !useGridLayout() || Recents.getConfiguration().getLaunchState().launchedWithAltTab;
if (setFocusOnFirstLayout) {
int focusedTaskIndex = launchState.getInitialFocusTaskIndex(mStack.getTaskCount(), useGridLayout());
if (focusedTaskIndex != -1) {
setFocusedTask(focusedTaskIndex, false, /* scrollToTask */
false);
}
}
updateStackActionButtonVisibility();
}
use of com.android.systemui.recents.RecentsConfiguration in project android_frameworks_base by AOSPA.
the class RecentsTvActivity method updateRecentsTasks.
private void updateRecentsTasks() {
RecentsTaskLoader loader = Recents.getTaskLoader();
RecentsTaskLoadPlan plan = RecentsImpl.consumeInstanceLoadPlan();
if (plan == null) {
plan = loader.createLoadPlan(this);
}
RecentsConfiguration config = Recents.getConfiguration();
RecentsActivityLaunchState launchState = config.getLaunchState();
if (!plan.hasTasks()) {
loader.preloadTasks(plan, -1, !launchState.launchedFromHome);
}
int numVisibleTasks = TaskCardView.getNumberOfVisibleTasks(getApplicationContext());
mLaunchedFromHome = launchState.launchedFromHome;
TaskStack stack = plan.getTaskStack();
RecentsTaskLoadPlan.Options loadOpts = new RecentsTaskLoadPlan.Options();
loadOpts.runningTaskId = launchState.launchedToTaskId;
loadOpts.numVisibleTasks = numVisibleTasks;
loadOpts.numVisibleTaskThumbnails = numVisibleTasks;
loader.loadTasks(this, plan, loadOpts);
List stackTasks = stack.getStackTasks();
Collections.reverse(stackTasks);
if (mTaskStackViewAdapter == null) {
mTaskStackViewAdapter = new TaskStackHorizontalViewAdapter(stackTasks);
mTaskStackHorizontalGridView = mRecentsView.setTaskStackViewAdapter(mTaskStackViewAdapter);
mHomeRecentsEnterExitAnimationHolder = new HomeRecentsEnterExitAnimationHolder(getApplicationContext(), mTaskStackHorizontalGridView);
} else {
mTaskStackViewAdapter.setNewStackTasks(stackTasks);
}
mRecentsView.init(stack);
if (launchState.launchedToTaskId != -1) {
ArrayList<Task> tasks = stack.getStackTasks();
int taskCount = tasks.size();
for (int i = 0; i < taskCount; i++) {
Task t = tasks.get(i);
if (t.key.id == launchState.launchedToTaskId) {
t.isLaunchTarget = true;
break;
}
}
}
}
use of com.android.systemui.recents.RecentsConfiguration in project android_frameworks_base by AOSPA.
the class RecentsTvActivity method onResume.
@Override
public void onResume() {
super.onResume();
mPipRecentsOverlayManager.onRecentsResumed();
// Update the recent tasks
updateRecentsTasks();
// If this is a new instance from a configuration change, then we have to manually trigger
// the enter animation state, or if recents was relaunched by AM, without going through
// the normal mechanisms
RecentsConfiguration config = Recents.getConfiguration();
RecentsActivityLaunchState launchState = config.getLaunchState();
boolean wasLaunchedByAm = !launchState.launchedFromHome && !launchState.launchedFromApp;
if (wasLaunchedByAm) {
EventBus.getDefault().send(new EnterRecentsWindowAnimationCompletedEvent());
}
// Notify that recents is now visible
SystemServicesProxy ssp = Recents.getSystemServices();
EventBus.getDefault().send(new RecentsVisibilityChangedEvent(this, true));
if (mTaskStackHorizontalGridView.getStack().getTaskCount() > 1 && !mLaunchedFromHome) {
// If there are 2 or more tasks, and we are not launching from home
// set the selected position to the 2nd task to allow for faster app switching
mTaskStackHorizontalGridView.setSelectedPosition(1);
} else {
mTaskStackHorizontalGridView.setSelectedPosition(0);
}
mRecentsView.getViewTreeObserver().addOnPreDrawListener(this);
View dismissPlaceholder = findViewById(R.id.dismiss_placeholder);
mTalkBackEnabled = ssp.isTouchExplorationEnabled();
if (mTalkBackEnabled) {
dismissPlaceholder.setAccessibilityTraversalBefore(R.id.task_list);
dismissPlaceholder.setAccessibilityTraversalAfter(R.id.dismiss_placeholder);
mTaskStackHorizontalGridView.setAccessibilityTraversalAfter(R.id.dismiss_placeholder);
mTaskStackHorizontalGridView.setAccessibilityTraversalBefore(R.id.pip);
dismissPlaceholder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mTaskStackHorizontalGridView.requestFocus();
mTaskStackHorizontalGridView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
Task focusedTask = mTaskStackHorizontalGridView.getFocusedTask();
if (focusedTask != null) {
mTaskStackViewAdapter.removeTask(focusedTask);
EventBus.getDefault().send(new DeleteTaskDataEvent(focusedTask));
}
}
});
}
// Initialize PIP UI
if (mPipManager.isPipShown()) {
if (mTalkBackEnabled) {
// If talkback is on, use the mPipView to handle focus changes
// between recents row and PIP controls.
mPipView.setVisibility(View.VISIBLE);
} else {
mPipView.setVisibility(View.GONE);
}
// When PIP view has focus, recents overlay view will takes the focus
// as if it's the part of the Recents UI.
mPipRecentsOverlayManager.requestFocus(mTaskStackViewAdapter.getItemCount() > 0);
} else {
mPipView.setVisibility(View.GONE);
mPipRecentsOverlayManager.removePipRecentsOverlayView();
}
}
use of com.android.systemui.recents.RecentsConfiguration in project android_frameworks_base by AOSPA.
the class RecentsTvActivity method onStop.
@Override
protected void onStop() {
super.onStop();
mIgnoreAltTabRelease = false;
// Notify that recents is now hidden
EventBus.getDefault().send(new RecentsVisibilityChangedEvent(this, false));
// Workaround for b/22542869, if the RecentsActivity is started again, but without going
// through SystemUI, we need to reset the config launch flags to ensure that we do not
// wait on the system to send a signal that was never queued.
RecentsConfiguration config = Recents.getConfiguration();
RecentsActivityLaunchState launchState = config.getLaunchState();
launchState.reset();
// Workaround for b/28333917.
finish();
}
use of com.android.systemui.recents.RecentsConfiguration in project android_frameworks_base by AOSPA.
the class RecentsTaskLoader method run.
@Override
public void run() {
while (true) {
if (mCancelled) {
// We have to unset the context here, since the background thread may be using it
// when we call stop()
mContext = null;
// If we are cancelled, then wait until we are started again
synchronized (mLoadThread) {
try {
mLoadThread.wait();
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
} else {
RecentsConfiguration config = Recents.getConfiguration();
SystemServicesProxy ssp = Recents.getSystemServices();
// the load thread
if (ssp != null) {
// Load the next item from the queue
final Task t = mLoadQueue.nextTask();
if (t != null) {
Drawable cachedIcon = mIconCache.get(t.key);
ThumbnailData cachedThumbnailData = mThumbnailCache.get(t.key);
// Load the icon if it is stale or we haven't cached one yet
if (cachedIcon == null) {
cachedIcon = ssp.getBadgedTaskDescriptionIcon(t.taskDescription, t.key.userId, mContext.getResources());
if (cachedIcon == null) {
ActivityInfo info = ssp.getActivityInfo(t.key.getComponent(), t.key.userId);
if (info != null) {
if (DEBUG)
Log.d(TAG, "Loading icon: " + t.key);
cachedIcon = ssp.getBadgedActivityIcon(info, t.key.userId);
}
}
if (cachedIcon == null) {
cachedIcon = mDefaultIcon;
}
// At this point, even if we can't load the icon, we will set the
// default icon.
mIconCache.put(t.key, cachedIcon);
}
// Load the thumbnail if it is stale or we haven't cached one yet
if (cachedThumbnailData == null) {
if (config.svelteLevel < RecentsConfiguration.SVELTE_DISABLE_LOADING) {
if (DEBUG)
Log.d(TAG, "Loading thumbnail: " + t.key);
cachedThumbnailData = ssp.getTaskThumbnail(t.key.id);
}
if (cachedThumbnailData.thumbnail == null) {
cachedThumbnailData.thumbnail = mDefaultThumbnail;
} else {
// Kick off an early upload of the bitmap to GL so
// that this won't jank the first frame it's drawn in.
cachedThumbnailData.thumbnail.prepareToDraw();
}
// them from scratch each time)
if (config.svelteLevel < RecentsConfiguration.SVELTE_LIMIT_CACHE) {
mThumbnailCache.put(t.key, cachedThumbnailData);
}
}
if (!mCancelled) {
// Notify that the task data has changed
final Drawable newIcon = cachedIcon;
final ThumbnailData newThumbnailData = cachedThumbnailData;
mMainThreadHandler.post(new Runnable() {
@Override
public void run() {
t.notifyTaskDataLoaded(newThumbnailData.thumbnail, newIcon, newThumbnailData.thumbnailInfo);
}
});
}
}
}
// If there are no other items in the list, then just wait until something is added
if (!mCancelled && mLoadQueue.isEmpty()) {
synchronized (mLoadQueue) {
try {
mWaitingOnLoadQueue = true;
while (mLoadQueue.isEmpty()) {
mLoadQueue.wait();
}
mWaitingOnLoadQueue = false;
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
}
}
}
}
Aggregations