Search in sources :

Example 1 with RecentsConfiguration

use of com.android.systemui.recents.RecentsConfiguration in project platform_frameworks_base by android.

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();
    }
}
Also used : EnterRecentsWindowAnimationCompletedEvent(com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent) SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) Task(com.android.systemui.recents.model.Task) RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState) RecentsConfiguration(com.android.systemui.recents.RecentsConfiguration) RecentsVisibilityChangedEvent(com.android.systemui.recents.events.component.RecentsVisibilityChangedEvent) DeleteTaskDataEvent(com.android.systemui.recents.events.ui.DeleteTaskDataEvent) RecentsTvView(com.android.systemui.recents.tv.views.RecentsTvView) TaskCardView(com.android.systemui.recents.tv.views.TaskCardView) TaskStackHorizontalGridView(com.android.systemui.recents.tv.views.TaskStackHorizontalGridView) View(android.view.View)

Example 2 with RecentsConfiguration

use of com.android.systemui.recents.RecentsConfiguration in project platform_frameworks_base by android.

the class TaskView method updateViewPropertiesToTaskTransform.

void updateViewPropertiesToTaskTransform(TaskViewTransform toTransform, AnimationProps toAnimation, ValueAnimator.AnimatorUpdateListener updateCallback) {
    RecentsConfiguration config = Recents.getConfiguration();
    cancelTransformAnimation();
    // Compose the animations for the transform
    mTmpAnimators.clear();
    toTransform.applyToTaskView(this, mTmpAnimators, toAnimation, !config.fakeShadows);
    if (toAnimation.isImmediate()) {
        if (Float.compare(getDimAlpha(), toTransform.dimAlpha) != 0) {
            setDimAlpha(toTransform.dimAlpha);
        }
        if (Float.compare(mViewBounds.getAlpha(), toTransform.viewOutlineAlpha) != 0) {
            mViewBounds.setAlpha(toTransform.viewOutlineAlpha);
        }
        // Manually call back to the animator listener and update callback
        if (toAnimation.getListener() != null) {
            toAnimation.getListener().onAnimationEnd(null);
        }
        if (updateCallback != null) {
            updateCallback.onAnimationUpdate(null);
        }
    } else {
        // Both the progress and the update are a function of the bounds movement of the task
        if (Float.compare(getDimAlpha(), toTransform.dimAlpha) != 0) {
            mDimAnimator = ObjectAnimator.ofFloat(this, DIM_ALPHA, getDimAlpha(), toTransform.dimAlpha);
            mTmpAnimators.add(toAnimation.apply(AnimationProps.BOUNDS, mDimAnimator));
        }
        if (Float.compare(mViewBounds.getAlpha(), toTransform.viewOutlineAlpha) != 0) {
            mOutlineAnimator = ObjectAnimator.ofFloat(this, VIEW_OUTLINE_ALPHA, mViewBounds.getAlpha(), toTransform.viewOutlineAlpha);
            mTmpAnimators.add(toAnimation.apply(AnimationProps.BOUNDS, mOutlineAnimator));
        }
        if (updateCallback != null) {
            ValueAnimator updateCallbackAnim = ValueAnimator.ofInt(0, 1);
            updateCallbackAnim.addUpdateListener(updateCallback);
            mTmpAnimators.add(toAnimation.apply(AnimationProps.BOUNDS, updateCallbackAnim));
        }
        // Create the animator
        mTransformAnimation = toAnimation.createAnimator(mTmpAnimators);
        mTransformAnimation.start();
        mTargetAnimationTransform.copyFrom(toTransform);
    }
}
Also used : RecentsConfiguration(com.android.systemui.recents.RecentsConfiguration) ValueAnimator(android.animation.ValueAnimator)

Example 3 with RecentsConfiguration

use of com.android.systemui.recents.RecentsConfiguration in project platform_frameworks_base by android.

the class RecentsTaskLoader method getAndUpdateThumbnail.

/**
     * Returns the cached thumbnail if the task key is not expired, updating the cache if it is.
     */
Bitmap getAndUpdateThumbnail(Task.TaskKey taskKey, boolean loadIfNotCached) {
    SystemServicesProxy ssp = Recents.getSystemServices();
    // Return the cached thumbnail if it exists
    ThumbnailData thumbnailData = mThumbnailCache.getAndInvalidateIfModified(taskKey);
    if (thumbnailData != null) {
        return thumbnailData.thumbnail;
    }
    if (loadIfNotCached) {
        RecentsConfiguration config = Recents.getConfiguration();
        if (config.svelteLevel < RecentsConfiguration.SVELTE_DISABLE_LOADING) {
            // Load the thumbnail from the system
            thumbnailData = ssp.getTaskThumbnail(taskKey.id);
            if (thumbnailData.thumbnail != null) {
                mThumbnailCache.put(taskKey, thumbnailData);
                return thumbnailData.thumbnail;
            }
        }
    }
    // We couldn't load any thumbnail
    return null;
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) RecentsConfiguration(com.android.systemui.recents.RecentsConfiguration)

Example 4 with RecentsConfiguration

use of com.android.systemui.recents.RecentsConfiguration in project platform_frameworks_base by android.

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;
                        mLoadQueue.wait();
                        mWaitingOnLoadQueue = false;
                    } catch (InterruptedException ie) {
                        ie.printStackTrace();
                    }
                }
            }
        }
    }
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) ActivityInfo(android.content.pm.ActivityInfo) RecentsConfiguration(com.android.systemui.recents.RecentsConfiguration) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable)

Example 5 with RecentsConfiguration

use of com.android.systemui.recents.RecentsConfiguration in project platform_frameworks_base by android.

the class RecentsTvView method init.

/**
     * Initialize the view.
     */
public void init(TaskStack stack) {
    RecentsConfiguration config = Recents.getConfiguration();
    RecentsActivityLaunchState launchState = config.getLaunchState();
    mStack = stack;
    mTaskStackHorizontalView.init(stack);
    if (stack.getStackTaskCount() > 0) {
        hideEmptyView();
    } else {
        showEmptyView();
    }
    // Layout with the new stack
    requestLayout();
}
Also used : RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState) RecentsConfiguration(com.android.systemui.recents.RecentsConfiguration)

Aggregations

RecentsConfiguration (com.android.systemui.recents.RecentsConfiguration)86 RecentsActivityLaunchState (com.android.systemui.recents.RecentsActivityLaunchState)45 Resources (android.content.res.Resources)20 Task (com.android.systemui.recents.model.Task)20 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)15 TaskStack (com.android.systemui.recents.model.TaskStack)15 ValueAnimator (android.animation.ValueAnimator)10 RecentsVisibilityChangedEvent (com.android.systemui.recents.events.component.RecentsVisibilityChangedEvent)10 Animator (android.animation.Animator)5 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)5 ActivityOptions (android.app.ActivityOptions)5 Intent (android.content.Intent)5 ActivityInfo (android.content.pm.ActivityInfo)5 BitmapDrawable (android.graphics.drawable.BitmapDrawable)5 Drawable (android.graphics.drawable.Drawable)5 View (android.view.View)5 EnterRecentsWindowAnimationCompletedEvent (com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent)5 RecentsActivityStartingEvent (com.android.systemui.recents.events.activity.RecentsActivityStartingEvent)5 DeleteTaskDataEvent (com.android.systemui.recents.events.ui.DeleteTaskDataEvent)5 RecentsTaskLoadPlan (com.android.systemui.recents.model.RecentsTaskLoadPlan)5