Search in sources :

Example 41 with RecentsActivityLaunchState

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

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();
    int focusedTaskIndex = launchState.getInitialFocusTaskIndex(mStack.getTaskCount());
    if (focusedTaskIndex != -1) {
        setFocusedTask(focusedTaskIndex, false, /* scrollToTask */
        false);
    }
    // Update the stack action button visibility
    if (mStackScroller.getStackScroll() < SHOW_STACK_ACTION_BUTTON_SCROLL_THRESHOLD && mStack.getTaskCount() > 0) {
        EventBus.getDefault().send(new ShowStackActionButtonEvent(false));
    } else {
        EventBus.getDefault().send(new HideStackActionButtonEvent());
    }
}
Also used : RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState) RecentsConfiguration(com.android.systemui.recents.RecentsConfiguration) HideStackActionButtonEvent(com.android.systemui.recents.events.activity.HideStackActionButtonEvent) ShowStackActionButtonEvent(com.android.systemui.recents.events.activity.ShowStackActionButtonEvent)

Example 42 with RecentsActivityLaunchState

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

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 43 with RecentsActivityLaunchState

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

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

Example 44 with RecentsActivityLaunchState

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

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 45 with RecentsActivityLaunchState

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

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);
        }
    }
}
Also used : Task(com.android.systemui.recents.model.Task) TaskStack(com.android.systemui.recents.model.TaskStack) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState) RecentsConfiguration(com.android.systemui.recents.RecentsConfiguration) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Resources(android.content.res.Resources)

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