Search in sources :

Example 6 with RecentsActivityLaunchState

use of com.android.systemui.recents.RecentsActivityLaunchState in project android_frameworks_base by DirtyUnicorns.

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;
            }
        }
    }
}
Also used : ActivityOptions(android.app.ActivityOptions) Task(com.android.systemui.recents.model.Task) RecentsTaskLoadPlan(com.android.systemui.recents.model.RecentsTaskLoadPlan) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader) HomeRecentsEnterExitAnimationHolder(com.android.systemui.recents.tv.animations.HomeRecentsEnterExitAnimationHolder) TaskStack(com.android.systemui.recents.model.TaskStack) RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState) RecentsConfiguration(com.android.systemui.recents.RecentsConfiguration) TaskStackHorizontalViewAdapter(com.android.systemui.recents.tv.views.TaskStackHorizontalViewAdapter) ArrayList(java.util.ArrayList) List(java.util.List)

Example 7 with RecentsActivityLaunchState

use of com.android.systemui.recents.RecentsActivityLaunchState in project android_frameworks_base by DirtyUnicorns.

the class TaskStackLayoutAlgorithm method update.

/**
     * Computes the minimum and maximum scroll progress values and the progress values for each task
     * in the stack.
     */
void update(TaskStack stack, ArraySet<Task.TaskKey> ignoreTasksSet) {
    SystemServicesProxy ssp = Recents.getSystemServices();
    RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
    // Clear the progress map
    mTaskIndexMap.clear();
    // Return early if we have no tasks
    ArrayList<Task> tasks = stack.getStackTasks();
    if (tasks.isEmpty()) {
        mFrontMostTaskP = 0;
        mMinScrollP = mMaxScrollP = mInitialScrollP = 0;
        mNumStackTasks = mNumFreeformTasks = 0;
        return;
    }
    // Filter the set of freeform and stack tasks
    ArrayList<Task> freeformTasks = new ArrayList<>();
    ArrayList<Task> stackTasks = new ArrayList<>();
    for (int i = 0; i < tasks.size(); i++) {
        Task task = tasks.get(i);
        if (ignoreTasksSet.contains(task.key)) {
            continue;
        }
        if (task.isFreeformTask()) {
            freeformTasks.add(task);
        } else {
            stackTasks.add(task);
        }
    }
    mNumStackTasks = stackTasks.size();
    mNumFreeformTasks = freeformTasks.size();
    // Put each of the tasks in the progress map at a fixed index (does not need to actually
    // map to a scroll position, just by index)
    int taskCount = stackTasks.size();
    for (int i = 0; i < taskCount; i++) {
        Task task = stackTasks.get(i);
        mTaskIndexMap.put(task.key.id, i);
    }
    // Update the freeform tasks
    if (!freeformTasks.isEmpty()) {
        mFreeformLayoutAlgorithm.update(freeformTasks, this);
    }
    // Calculate the min/max/initial scroll
    Task launchTask = stack.getLaunchTarget();
    int launchTaskIndex = launchTask != null ? stack.indexOfStackTask(launchTask) : mNumStackTasks - 1;
    if (getInitialFocusState() == STATE_FOCUSED) {
        int maxBottomOffset = mStackBottomOffset + mTaskRect.height();
        float maxBottomNormX = getNormalizedXFromFocusedY(maxBottomOffset, FROM_BOTTOM);
        mFocusedRange.offset(0f);
        mMinScrollP = 0;
        mMaxScrollP = Math.max(mMinScrollP, (mNumStackTasks - 1) - Math.max(0, mFocusedRange.getAbsoluteX(maxBottomNormX)));
        if (launchState.launchedFromHome) {
            mInitialScrollP = Utilities.clamp(launchTaskIndex, mMinScrollP, mMaxScrollP);
        } else {
            mInitialScrollP = Utilities.clamp(launchTaskIndex - 1, mMinScrollP, mMaxScrollP);
        }
    } else if (!ssp.hasFreeformWorkspaceSupport() && mNumStackTasks == 1) {
        // If there is one stack task, ignore the min/max/initial scroll positions
        mMinScrollP = 0;
        mMaxScrollP = 0;
        mInitialScrollP = 0;
    } else {
        // Set the max scroll to be the point where the front most task is visible with the
        // stack bottom offset
        int maxBottomOffset = mStackBottomOffset + mTaskRect.height();
        float maxBottomNormX = getNormalizedXFromUnfocusedY(maxBottomOffset, FROM_BOTTOM);
        mUnfocusedRange.offset(0f);
        mMinScrollP = 0;
        mMaxScrollP = Math.max(mMinScrollP, (mNumStackTasks - 1) - Math.max(0, mUnfocusedRange.getAbsoluteX(maxBottomNormX)));
        boolean scrollToFront = launchState.launchedFromHome || launchState.launchedViaDockGesture;
        if (launchState.launchedFromBlacklistedApp) {
            mInitialScrollP = mMaxScrollP;
        } else if (launchState.launchedWithAltTab) {
            mInitialScrollP = Utilities.clamp(launchTaskIndex, mMinScrollP, mMaxScrollP);
        } else if (scrollToFront) {
            mInitialScrollP = Utilities.clamp(launchTaskIndex, mMinScrollP, mMaxScrollP);
        } else {
            // We are overriding the initial two task positions, so set the initial scroll
            // position to match the second task (aka focused task) position
            float initialTopNormX = getNormalizedXFromUnfocusedY(mInitialTopOffset, FROM_TOP);
            mInitialScrollP = Math.max(mMinScrollP, Math.min(mMaxScrollP, (mNumStackTasks - 2)) - Math.max(0, mUnfocusedRange.getAbsoluteX(initialTopNormX)));
        }
    }
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) Task(com.android.systemui.recents.model.Task) RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState) ArrayList(java.util.ArrayList)

Example 8 with RecentsActivityLaunchState

use of com.android.systemui.recents.RecentsActivityLaunchState in project android_frameworks_base by DirtyUnicorns.

the class TaskStackLayoutAlgorithm method setTaskOverridesForInitialState.

/**
     * Creates task overrides to ensure the initial stack layout if necessary.
     */
public void setTaskOverridesForInitialState(TaskStack stack, boolean ignoreScrollToFront) {
    RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
    mTaskIndexOverrideMap.clear();
    boolean scrollToFront = launchState.launchedFromHome || launchState.launchedFromBlacklistedApp || launchState.launchedViaDockGesture;
    if (getInitialFocusState() == STATE_UNFOCUSED && mNumStackTasks > 1) {
        if (ignoreScrollToFront || (!launchState.launchedWithAltTab && !scrollToFront)) {
            // Set the initial scroll to the predefined state (which differs from the stack)
            float[] initialNormX = null;
            float minBottomTaskNormX = getNormalizedXFromUnfocusedY(mSystemInsets.bottom + mInitialBottomOffset, FROM_BOTTOM);
            float maxBottomTaskNormX = getNormalizedXFromUnfocusedY(mFocusedTopPeekHeight + mTaskRect.height() - mMinMargin, FROM_TOP);
            if (mNumStackTasks <= 2) {
                // For small stacks, position the tasks so that they are top aligned to under
                // the action button, but ensure that it is at least a certain offset from the
                // bottom of the stack
                initialNormX = new float[] { Math.min(maxBottomTaskNormX, minBottomTaskNormX), getNormalizedXFromUnfocusedY(mFocusedTopPeekHeight, FROM_TOP) };
            } else {
                initialNormX = new float[] { minBottomTaskNormX, getNormalizedXFromUnfocusedY(mInitialTopOffset, FROM_TOP) };
            }
            mUnfocusedRange.offset(0f);
            List<Task> tasks = stack.getStackTasks();
            int taskCount = tasks.size();
            for (int i = taskCount - 1; i >= 0; i--) {
                int indexFromFront = taskCount - i - 1;
                if (indexFromFront >= initialNormX.length) {
                    break;
                }
                float newTaskProgress = mInitialScrollP + mUnfocusedRange.getAbsoluteX(initialNormX[indexFromFront]);
                mTaskIndexOverrideMap.put(tasks.get(i).key.id, newTaskProgress);
            }
        }
    }
}
Also used : Task(com.android.systemui.recents.model.Task) RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState)

Example 9 with RecentsActivityLaunchState

use of com.android.systemui.recents.RecentsActivityLaunchState 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();
}
Also used : RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState) RecentsConfiguration(com.android.systemui.recents.RecentsConfiguration)

Example 10 with RecentsActivityLaunchState

use of com.android.systemui.recents.RecentsActivityLaunchState 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;
            }
        }
    }
}
Also used : ActivityOptions(android.app.ActivityOptions) Task(com.android.systemui.recents.model.Task) RecentsTaskLoadPlan(com.android.systemui.recents.model.RecentsTaskLoadPlan) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader) HomeRecentsEnterExitAnimationHolder(com.android.systemui.recents.tv.animations.HomeRecentsEnterExitAnimationHolder) TaskStack(com.android.systemui.recents.model.TaskStack) RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState) RecentsConfiguration(com.android.systemui.recents.RecentsConfiguration) TaskStackHorizontalViewAdapter(com.android.systemui.recents.tv.views.TaskStackHorizontalViewAdapter) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

RecentsActivityLaunchState (com.android.systemui.recents.RecentsActivityLaunchState)75 RecentsConfiguration (com.android.systemui.recents.RecentsConfiguration)45 Task (com.android.systemui.recents.model.Task)30 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)15 TaskStack (com.android.systemui.recents.model.TaskStack)15 Resources (android.content.res.Resources)10 RecentsVisibilityChangedEvent (com.android.systemui.recents.events.component.RecentsVisibilityChangedEvent)10 ArrayList (java.util.ArrayList)10 Animator (android.animation.Animator)5 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)5 ValueAnimator (android.animation.ValueAnimator)5 ActivityOptions (android.app.ActivityOptions)5 Intent (android.content.Intent)5 Rect (android.graphics.Rect)5 View (android.view.View)5 RecentsDebugFlags (com.android.systemui.recents.RecentsDebugFlags)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