Search in sources :

Example 1 with HideRecentsEvent

use of com.android.systemui.recents.events.activity.HideRecentsEvent in project platform_frameworks_base by android.

the class RecentsImpl method hideRecents.

public void hideRecents(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) {
    if (triggeredFromAltTab && mFastAltTabTrigger.isDozing()) {
        // The user has released alt-tab before the trigger has run, so just show the next
        // task immediately
        showNextTask();
        // Cancel the fast alt-tab trigger
        mFastAltTabTrigger.stopDozing();
        return;
    }
    // Defer to the activity to handle hiding recents, if it handles it, then it must still
    // be visible
    EventBus.getDefault().post(new HideRecentsEvent(triggeredFromAltTab, triggeredFromHomeKey));
}
Also used : HideRecentsEvent(com.android.systemui.recents.events.activity.HideRecentsEvent)

Example 2 with HideRecentsEvent

use of com.android.systemui.recents.events.activity.HideRecentsEvent in project platform_frameworks_base by android.

the class TaskStackView method onBusEvent.

public final void onBusEvent(LaunchNextTaskRequestEvent event) {
    if (mAwaitingFirstLayout) {
        mLaunchNextAfterFirstMeasure = true;
        return;
    }
    int launchTaskIndex = mStack.indexOfStackTask(mStack.getLaunchTarget());
    if (launchTaskIndex != -1) {
        launchTaskIndex = Math.max(0, launchTaskIndex - 1);
    } else {
        launchTaskIndex = mStack.getTaskCount() - 1;
    }
    if (launchTaskIndex != -1) {
        // Stop all animations
        cancelAllTaskViewAnimations();
        final Task launchTask = mStack.getStackTasks().get(launchTaskIndex);
        float curScroll = mStackScroller.getStackScroll();
        float targetScroll = mLayoutAlgorithm.getStackScrollForTaskAtInitialOffset(launchTask);
        float absScrollDiff = Math.abs(targetScroll - curScroll);
        if (getChildViewForTask(launchTask) == null || absScrollDiff > 0.35f) {
            int duration = (int) (LAUNCH_NEXT_SCROLL_BASE_DURATION + absScrollDiff * LAUNCH_NEXT_SCROLL_INCR_DURATION);
            mStackScroller.animateScroll(targetScroll, duration, new Runnable() {

                @Override
                public void run() {
                    EventBus.getDefault().send(new LaunchTaskEvent(getChildViewForTask(launchTask), launchTask, null, INVALID_STACK_ID, false));
                }
            });
        } else {
            EventBus.getDefault().send(new LaunchTaskEvent(getChildViewForTask(launchTask), launchTask, null, INVALID_STACK_ID, false));
        }
        MetricsLogger.action(getContext(), MetricsEvent.OVERVIEW_LAUNCH_PREVIOUS_TASK, launchTask.key.getComponent().toString());
    } else if (mStack.getTaskCount() == 0) {
        // If there are no tasks, then just hide recents back to home.
        EventBus.getDefault().send(new HideRecentsEvent(false, true));
    }
}
Also used : Task(com.android.systemui.recents.model.Task) HideRecentsEvent(com.android.systemui.recents.events.activity.HideRecentsEvent) LaunchTaskEvent(com.android.systemui.recents.events.activity.LaunchTaskEvent)

Example 3 with HideRecentsEvent

use of com.android.systemui.recents.events.activity.HideRecentsEvent in project android_frameworks_base by ResurrectionRemix.

the class TaskStackViewTouchHandler method maybeHideRecentsFromBackgroundTap.

/** Hides recents if the up event at (x, y) is a tap on the background area. */
void maybeHideRecentsFromBackgroundTap(int x, int y) {
    // Ignore the up event if it's too far from its start position. The user might have been
    // trying to scroll or swipe.
    int dx = Math.abs(mDownX - x);
    int dy = Math.abs(mDownY - y);
    if (dx > mScrollTouchSlop || dy > mScrollTouchSlop) {
        return;
    }
    // Shift the tap position toward the center of the task stack and check to see if it would
    // have hit a view. The user might have tried to tap on a task and missed slightly.
    int shiftedX = x;
    if (x > (mSv.getRight() - mSv.getLeft()) / 2) {
        shiftedX -= mWindowTouchSlop;
    } else {
        shiftedX += mWindowTouchSlop;
    }
    if (findViewAtPoint(shiftedX, y) != null) {
        return;
    }
    // Disallow tapping above and below the stack to dismiss recents
    if (x > mSv.mLayoutAlgorithm.mStackRect.left && x < mSv.mLayoutAlgorithm.mStackRect.right) {
        return;
    }
    // If tapping on the freeform workspace background, just launch the first freeform task
    SystemServicesProxy ssp = Recents.getSystemServices();
    if (ssp.hasFreeformWorkspaceSupport()) {
        Rect freeformRect = mSv.mLayoutAlgorithm.mFreeformRect;
        if (freeformRect.top <= y && y <= freeformRect.bottom) {
            if (mSv.launchFreeformTasks()) {
                // TODO: Animate Recents away as we launch the freeform tasks
                return;
            }
        }
    }
    // The user intentionally tapped on the background, which is like a tap on the "desktop".
    // Hide recents and transition to the launcher.
    EventBus.getDefault().send(new HideRecentsEvent(false, true));
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) Rect(android.graphics.Rect) HideRecentsEvent(com.android.systemui.recents.events.activity.HideRecentsEvent)

Example 4 with HideRecentsEvent

use of com.android.systemui.recents.events.activity.HideRecentsEvent in project android_frameworks_base by ResurrectionRemix.

the class RecentsImpl method hideRecents.

public void hideRecents(boolean triggeredFromAltTab, boolean triggeredFromHomeKey) {
    if (triggeredFromAltTab && mFastAltTabTrigger.isDozing()) {
        // The user has released alt-tab before the trigger has run, so just show the next
        // task immediately
        showNextTask();
        // Cancel the fast alt-tab trigger
        mFastAltTabTrigger.stopDozing();
        return;
    }
    // Defer to the activity to handle hiding recents, if it handles it, then it must still
    // be visible
    EventBus.getDefault().post(new HideRecentsEvent(triggeredFromAltTab, triggeredFromHomeKey));
}
Also used : HideRecentsEvent(com.android.systemui.recents.events.activity.HideRecentsEvent)

Example 5 with HideRecentsEvent

use of com.android.systemui.recents.events.activity.HideRecentsEvent in project android_frameworks_base by DirtyUnicorns.

the class TaskStackView method onBusEvent.

public final void onBusEvent(LaunchNextTaskRequestEvent event) {
    if (mAwaitingFirstLayout) {
        mLaunchNextAfterFirstMeasure = true;
        return;
    }
    final Task launchTask = mStack.getNextLaunchTarget();
    if (launchTask != null) {
        launchTask(launchTask);
        MetricsLogger.action(getContext(), MetricsEvent.OVERVIEW_LAUNCH_PREVIOUS_TASK, launchTask.key.getComponent().toString());
    } else if (mStack.getTaskCount() == 0) {
        // If there are no tasks, then just hide recents back to home.
        EventBus.getDefault().send(new HideRecentsEvent(false, true));
    }
}
Also used : Task(com.android.systemui.recents.model.Task) HideRecentsEvent(com.android.systemui.recents.events.activity.HideRecentsEvent)

Aggregations

HideRecentsEvent (com.android.systemui.recents.events.activity.HideRecentsEvent)15 Rect (android.graphics.Rect)5 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)5 Task (com.android.systemui.recents.model.Task)5 LaunchTaskEvent (com.android.systemui.recents.events.activity.LaunchTaskEvent)1