Search in sources :

Example 1 with RecentsActivityLaunchState

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

the class RecentsView method onLayout.

/**
     * This is called with the full size of the window since we are handling our own insets.
     */
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    if (mTaskStackView.getVisibility() != GONE) {
        mTaskStackView.layout(left, top, left + getMeasuredWidth(), top + getMeasuredHeight());
    }
    // Layout the empty view
    if (mEmptyView.getVisibility() != GONE) {
        int leftRightInsets = mSystemInsets.left + mSystemInsets.right;
        int topBottomInsets = mSystemInsets.top + mSystemInsets.bottom;
        int childWidth = mEmptyView.getMeasuredWidth();
        int childHeight = mEmptyView.getMeasuredHeight();
        int childLeft = left + mSystemInsets.left + Math.max(0, (right - left - leftRightInsets - childWidth)) / 2;
        int childTop = top + mSystemInsets.top + Math.max(0, (bottom - top - topBottomInsets - childHeight)) / 2;
        mEmptyView.layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight);
    }
    if (RecentsDebugFlags.Static.EnableStackActionButton) {
        // Layout the stack action button such that its drawable is start-aligned with the
        // stack, vertically centered in the available space above the stack
        Rect buttonBounds = getStackActionButtonBoundsFromStackLayout();
        mStackActionButton.layout(buttonBounds.left, buttonBounds.top, buttonBounds.right, buttonBounds.bottom);
    }
    if (mAwaitingFirstLayout) {
        mAwaitingFirstLayout = false;
        // If launched via dragging from the nav bar, then we should translate the whole view
        // down offscreen
        RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
        if (launchState.launchedViaDragGesture) {
            setTranslationY(getMeasuredHeight());
        } else {
            setTranslationY(0f);
        }
    }
}
Also used : Rect(android.graphics.Rect) RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState)

Example 2 with RecentsActivityLaunchState

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

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

use of com.android.systemui.recents.RecentsActivityLaunchState 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 4 with RecentsActivityLaunchState

use of com.android.systemui.recents.RecentsActivityLaunchState 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)

Example 5 with RecentsActivityLaunchState

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

the class TaskStackView method onBusEvent.

public final void onBusEvent(final MultiWindowStateChangedEvent event) {
    if (event.inMultiWindow || !event.showDeferredAnimation) {
        setTasks(event.stack, true);
    } else {
        // Reset the launch state before handling the multiwindow change
        RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
        launchState.reset();
        // Defer until the next frame to ensure that we have received all the system insets, and
        // initial layout updates
        event.getAnimationTrigger().increment();
        post(new Runnable() {

            @Override
            public void run() {
                // Scroll the stack to the front to see the undocked task
                mAnimationHelper.startNewStackScrollAnimation(event.stack, event.getAnimationTrigger());
                event.getAnimationTrigger().decrement();
            }
        });
    }
}
Also used : RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState)

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