use of com.android.systemui.recents.RecentsConfiguration in project android_frameworks_base by crdroidandroid.
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();
}
}
}
}
}
}
use of com.android.systemui.recents.RecentsConfiguration in project android_frameworks_base by crdroidandroid.
the class RecentsViewTouchHandler method getDockStatesForCurrentOrientation.
/**
* Returns the preferred dock states for the current orientation.
*/
public TaskStack.DockState[] getDockStatesForCurrentOrientation() {
boolean isLandscape = mRv.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
RecentsConfiguration config = Recents.getConfiguration();
if (config.isLargeScreen) {
return isLandscape ? DockRegion.TABLET_LANDSCAPE : DockRegion.TABLET_PORTRAIT;
} else {
return isLandscape ? DockRegion.PHONE_LANDSCAPE : DockRegion.PHONE_PORTRAIT;
}
}
use of com.android.systemui.recents.RecentsConfiguration in project android_frameworks_base by crdroidandroid.
the class TaskStackAnimationHelper method prepareForEnterAnimation.
/**
* Prepares the stack views and puts them in their initial animation state while visible, before
* the in-app enter animations start (after the window-transition completes).
*/
public void prepareForEnterAnimation() {
RecentsConfiguration config = Recents.getConfiguration();
RecentsActivityLaunchState launchState = config.getLaunchState();
Resources res = mStackView.getResources();
Resources appResources = mStackView.getContext().getApplicationContext().getResources();
TaskStackLayoutAlgorithm stackLayout = mStackView.getStackAlgorithm();
TaskStackViewScroller stackScroller = mStackView.getScroller();
TaskStack stack = mStackView.getStack();
Task launchTargetTask = stack.getLaunchTarget();
// Break early if there are no tasks
if (stack.getTaskCount() == 0) {
return;
}
int offscreenYOffset = stackLayout.mStackRect.height();
int taskViewAffiliateGroupEnterOffset = res.getDimensionPixelSize(R.dimen.recents_task_stack_animation_affiliate_enter_offset);
int launchedWhileDockingOffset = res.getDimensionPixelSize(R.dimen.recents_task_stack_animation_launched_while_docking_offset);
boolean isLandscape = appResources.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
// Prepare each of the task views for their enter animation from front to back
List<TaskView> taskViews = mStackView.getTaskViews();
for (int i = taskViews.size() - 1; i >= 0; i--) {
TaskView tv = taskViews.get(i);
Task task = tv.getTask();
boolean currentTaskOccludesLaunchTarget = launchTargetTask != null && launchTargetTask.group != null && launchTargetTask.group.isTaskAboveTask(task, launchTargetTask);
boolean hideTask = launchTargetTask != null && launchTargetTask.isFreeformTask() && task.isFreeformTask();
// Get the current transform for the task, which will be used to position it offscreen
stackLayout.getStackTransform(task, stackScroller.getStackScroll(), mTmpTransform, null);
if (hideTask) {
tv.setVisibility(View.INVISIBLE);
} else if (launchState.launchedFromApp && !launchState.launchedViaDockGesture) {
if (task.isLaunchTarget) {
tv.onPrepareLaunchTargetForEnterAnimation();
} else if (currentTaskOccludesLaunchTarget) {
// Move the task view slightly lower so we can animate it in
mTmpTransform.rect.offset(0, taskViewAffiliateGroupEnterOffset);
mTmpTransform.alpha = 0f;
mStackView.updateTaskViewToTransform(tv, mTmpTransform, AnimationProps.IMMEDIATE);
tv.setClipViewInStack(false);
}
} else if (launchState.launchedFromHome) {
// Move the task view off screen (below) so we can animate it in
mTmpTransform.rect.offset(0, offscreenYOffset);
mTmpTransform.alpha = 0f;
mStackView.updateTaskViewToTransform(tv, mTmpTransform, AnimationProps.IMMEDIATE);
} else if (launchState.launchedViaDockGesture) {
int offset = isLandscape ? launchedWhileDockingOffset : (int) (offscreenYOffset * 0.9f);
mTmpTransform.rect.offset(0, offset);
mTmpTransform.alpha = 0f;
mStackView.updateTaskViewToTransform(tv, mTmpTransform, AnimationProps.IMMEDIATE);
}
}
}
use of com.android.systemui.recents.RecentsConfiguration in project android_frameworks_base by crdroidandroid.
the class TaskStackAnimationHelper method startEnterAnimation.
/**
* Starts the in-app enter animation, which animates the {@link TaskView}s to their final places
* depending on how Recents was triggered.
*/
public void startEnterAnimation(final ReferenceCountedTrigger postAnimationTrigger) {
RecentsConfiguration config = Recents.getConfiguration();
RecentsActivityLaunchState launchState = config.getLaunchState();
Resources res = mStackView.getResources();
Resources appRes = mStackView.getContext().getApplicationContext().getResources();
TaskStackLayoutAlgorithm stackLayout = mStackView.getStackAlgorithm();
TaskStackViewScroller stackScroller = mStackView.getScroller();
TaskStack stack = mStackView.getStack();
Task launchTargetTask = stack.getLaunchTarget();
// Break early if there are no tasks
if (stack.getTaskCount() == 0) {
return;
}
int taskViewEnterFromAppDuration = res.getInteger(R.integer.recents_task_enter_from_app_duration);
int taskViewEnterFromAffiliatedAppDuration = res.getInteger(R.integer.recents_task_enter_from_affiliated_app_duration);
int dockGestureAnimDuration = appRes.getInteger(R.integer.long_press_dock_anim_duration);
// Create enter animations for each of the views from front to back
List<TaskView> taskViews = mStackView.getTaskViews();
int taskViewCount = taskViews.size();
for (int i = taskViewCount - 1; i >= 0; i--) {
int taskIndexFromFront = taskViewCount - i - 1;
int taskIndexFromBack = i;
final TaskView tv = taskViews.get(i);
Task task = tv.getTask();
boolean currentTaskOccludesLaunchTarget = launchTargetTask != null && launchTargetTask.group != null && launchTargetTask.group.isTaskAboveTask(task, launchTargetTask);
// Get the current transform for the task, which will be updated to the final transform
// to animate to depending on how recents was invoked
stackLayout.getStackTransform(task, stackScroller.getStackScroll(), mTmpTransform, null);
if (launchState.launchedFromApp && !launchState.launchedViaDockGesture) {
if (task.isLaunchTarget) {
tv.onStartLaunchTargetEnterAnimation(mTmpTransform, taskViewEnterFromAppDuration, mStackView.mScreenPinningEnabled, postAnimationTrigger);
} else {
// Animate the task up if it was occluding the launch target
if (currentTaskOccludesLaunchTarget) {
AnimationProps taskAnimation = new AnimationProps(taskViewEnterFromAffiliatedAppDuration, Interpolators.ALPHA_IN, new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
postAnimationTrigger.decrement();
tv.setClipViewInStack(true);
}
});
postAnimationTrigger.increment();
mStackView.updateTaskViewToTransform(tv, mTmpTransform, taskAnimation);
}
}
} else if (launchState.launchedFromHome) {
// Animate the tasks up, but offset the animations to be relative to the front-most
// task animation
AnimationProps taskAnimation = new AnimationProps().setInitialPlayTime(AnimationProps.BOUNDS, Math.min(ENTER_EXIT_NUM_ANIMATING_TASKS, taskIndexFromFront) * mEnterAndExitFromHomeTranslationOffset).setStartDelay(AnimationProps.ALPHA, Math.min(ENTER_EXIT_NUM_ANIMATING_TASKS, taskIndexFromFront) * FRAME_OFFSET_MS).setDuration(AnimationProps.BOUNDS, ENTER_FROM_HOME_TRANSLATION_DURATION).setDuration(AnimationProps.ALPHA, ENTER_FROM_HOME_ALPHA_DURATION).setInterpolator(AnimationProps.BOUNDS, ENTER_FROM_HOME_TRANSLATION_INTERPOLATOR).setInterpolator(AnimationProps.ALPHA, ENTER_FROM_HOME_ALPHA_INTERPOLATOR).setListener(postAnimationTrigger.decrementOnAnimationEnd());
postAnimationTrigger.increment();
mStackView.updateTaskViewToTransform(tv, mTmpTransform, taskAnimation);
if (i == taskViewCount - 1) {
tv.onStartFrontTaskEnterAnimation(mStackView.mScreenPinningEnabled);
}
} else if (launchState.launchedViaDockGesture) {
// Animate the tasks up - add some delay to match the divider animation
AnimationProps taskAnimation = new AnimationProps().setDuration(AnimationProps.BOUNDS, dockGestureAnimDuration + (taskIndexFromBack * DOUBLE_FRAME_OFFSET_MS)).setInterpolator(AnimationProps.BOUNDS, ENTER_WHILE_DOCKING_INTERPOLATOR).setStartDelay(AnimationProps.BOUNDS, 48).setListener(postAnimationTrigger.decrementOnAnimationEnd());
postAnimationTrigger.increment();
mStackView.updateTaskViewToTransform(tv, mTmpTransform, taskAnimation);
}
}
}
use of com.android.systemui.recents.RecentsConfiguration in project android_frameworks_base by crdroidandroid.
the class RecentsView method endFABanimation.
public void endFABanimation() {
RecentsConfiguration config = Recents.getConfiguration();
// Animate the action button away
mFloatingButton = ((View) getParent()).findViewById(R.id.floating_action_button);
mFloatingButton.animate().alpha(0f).setStartDelay(0).setDuration(config.fabExitAnimDuration).setInterpolator(Interpolators.ALPHA_OUT).withLayer().start();
}
Aggregations