Search in sources :

Example 1 with SystemServicesProxy

use of com.android.systemui.recents.misc.SystemServicesProxy in project android_frameworks_base by ResurrectionRemix.

the class RecentsView method onBusEvent.

public final void onBusEvent(final DragEndEvent event) {
    // Handle the case where we drop onto a dock region
    if (event.dropTarget instanceof TaskStack.DockState) {
        final TaskStack.DockState dockState = (TaskStack.DockState) event.dropTarget;
        // Hide the dock region
        updateVisibleDockRegions(null, false, /* isDefaultDockState */
        -1, -1, false, /* animateAlpha */
        false);
        // We translated the view but we need to animate it back from the current layout-space
        // rect to its final layout-space rect
        Utilities.setViewFrameFromTranslation(event.taskView);
        // Dock the task and launch it
        SystemServicesProxy ssp = Recents.getSystemServices();
        if (ssp.startTaskInDockedMode(event.task.key.id, dockState.createMode)) {
            final OnAnimationStartedListener startedListener = new OnAnimationStartedListener() {

                @Override
                public void onAnimationStarted() {
                    EventBus.getDefault().send(new DockedFirstAnimationFrameEvent());
                    // Remove the task and don't bother relaying out, as all the tasks will be
                    // relaid out when the stack changes on the multiwindow change event
                    getStack().removeTask(event.task, null, true);
                }
            };
            final Rect taskRect = getTaskRect(event.taskView);
            IAppTransitionAnimationSpecsFuture future = mTransitionHelper.getAppTransitionFuture(new AnimationSpecComposer() {

                @Override
                public List<AppTransitionAnimationSpec> composeSpecs() {
                    return mTransitionHelper.composeDockAnimationSpec(event.taskView, taskRect);
                }
            });
            ssp.overridePendingAppTransitionMultiThumbFuture(future, mTransitionHelper.wrapStartedListener(startedListener), true);
            MetricsLogger.action(mContext, MetricsEvent.ACTION_WINDOW_DOCK_DRAG_DROP, event.task.getTopComponent().flattenToShortString());
        } else {
            EventBus.getDefault().send(new DragEndCancelledEvent(getStack(), event.task, event.taskView));
        }
    } else {
        // Animate the overlay alpha back to 0
        updateVisibleDockRegions(null, true, /* isDefaultDockState */
        -1, -1, true, /* animateAlpha */
        false);
    }
    // Show the stack action button again without changing visibility
    if (mStackActionButton != null) {
        mStackActionButton.animate().alpha(1f).setDuration(SHOW_STACK_ACTION_BUTTON_DURATION).setInterpolator(Interpolators.ALPHA_IN).start();
    }
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) TaskStack(com.android.systemui.recents.model.TaskStack) OnAnimationStartedListener(android.app.ActivityOptions.OnAnimationStartedListener) Rect(android.graphics.Rect) IAppTransitionAnimationSpecsFuture(android.view.IAppTransitionAnimationSpecsFuture) List(java.util.List) ArrayList(java.util.ArrayList) DragEndCancelledEvent(com.android.systemui.recents.events.ui.dragndrop.DragEndCancelledEvent) AnimationSpecComposer(com.android.systemui.recents.views.RecentsTransitionHelper.AnimationSpecComposer) DockedFirstAnimationFrameEvent(com.android.systemui.recents.events.activity.DockedFirstAnimationFrameEvent)

Example 2 with SystemServicesProxy

use of com.android.systemui.recents.misc.SystemServicesProxy in project android_frameworks_base by ResurrectionRemix.

the class RecentsTransitionHelper method startTaskActivity.

/**
     * Starts the activity for the launch task.
     *
     * @param taskView this is the {@link TaskView} that we are launching from. This can be null if
     *                 we are toggling recents and the launch-to task is now offscreen.
     */
private void startTaskActivity(TaskStack stack, Task task, @Nullable TaskView taskView, ActivityOptions opts, IAppTransitionAnimationSpecsFuture transitionFuture, final ActivityOptions.OnAnimationStartedListener animStartedListener) {
    SystemServicesProxy ssp = Recents.getSystemServices();
    if (ssp.startActivityFromRecents(mContext, task.key, task.title, opts)) {
        // Keep track of the index of the task launch
        int taskIndexFromFront = 0;
        int taskIndex = stack.indexOfStackTask(task);
        if (taskIndex > -1) {
            taskIndexFromFront = stack.getTaskCount() - taskIndex - 1;
        }
        EventBus.getDefault().send(new LaunchTaskSucceededEvent(taskIndexFromFront));
    } else {
        // Dismiss the task if we fail to launch it
        if (taskView != null) {
            taskView.dismissTask();
        }
        // Keep track of failed launches
        EventBus.getDefault().send(new LaunchTaskFailedEvent());
    }
    if (transitionFuture != null) {
        ssp.overridePendingAppTransitionMultiThumbFuture(transitionFuture, wrapStartedListener(animStartedListener), true);
    }
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) LaunchTaskSucceededEvent(com.android.systemui.recents.events.activity.LaunchTaskSucceededEvent) LaunchTaskFailedEvent(com.android.systemui.recents.events.activity.LaunchTaskFailedEvent)

Example 3 with SystemServicesProxy

use of com.android.systemui.recents.misc.SystemServicesProxy in project android_frameworks_base by ResurrectionRemix.

the class RecentsView method onBusEvent.

public final void onBusEvent(DismissAllTaskViewsEvent event) {
    SystemServicesProxy ssp = Recents.getSystemServices();
    if (!ssp.hasDockedTask()) {
        // Animate the background away only if we are dismissing Recents to home
        animateBackgroundScrim(0f, DEFAULT_UPDATE_SCRIM_DURATION);
    }
    updateMemoryStatus();
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy)

Example 4 with SystemServicesProxy

use of com.android.systemui.recents.misc.SystemServicesProxy 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 5 with SystemServicesProxy

use of com.android.systemui.recents.misc.SystemServicesProxy in project android_frameworks_base by ResurrectionRemix.

the class TaskView method onLongClick.

/**** View.OnLongClickListener Implementation ****/
@Override
public boolean onLongClick(View v) {
    SystemServicesProxy ssp = Recents.getSystemServices();
    boolean inBounds = false;
    Rect clipBounds = new Rect(mViewBounds.mClipBounds);
    if (!clipBounds.isEmpty()) {
        // If we are clipping the view to the bounds, manually do the hit test.
        clipBounds.scale(getScaleX());
        inBounds = clipBounds.contains(mDownTouchPos.x, mDownTouchPos.y);
    } else {
        // Otherwise just make sure we're within the view's bounds.
        inBounds = mDownTouchPos.x <= getWidth() && mDownTouchPos.y <= getHeight();
    }
    if (v == this && inBounds && !ssp.hasDockedTask()) {
        // Start listening for drag events
        setClipViewInStack(false);
        mDownTouchPos.x += ((1f - getScaleX()) * getWidth()) / 2;
        mDownTouchPos.y += ((1f - getScaleY()) * getHeight()) / 2;
        EventBus.getDefault().register(this, RecentsActivity.EVENT_BUS_PRIORITY + 1);
        EventBus.getDefault().send(new DragStartEvent(mTask, this, mDownTouchPos));
        return true;
    }
    return false;
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) Rect(android.graphics.Rect) DragStartEvent(com.android.systemui.recents.events.ui.dragndrop.DragStartEvent)

Aggregations

SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)243 Rect (android.graphics.Rect)45 ActivityManager (android.app.ActivityManager)35 ActivityInfo (android.content.pm.ActivityInfo)34 RecentsTaskLoader (com.android.systemui.recents.model.RecentsTaskLoader)30 TaskStack (com.android.systemui.recents.model.TaskStack)30 Task (com.android.systemui.recents.model.Task)25 Drawable (android.graphics.drawable.Drawable)19 Point (android.graphics.Point)16 ActivityOptions (android.app.ActivityOptions)15 ComponentName (android.content.ComponentName)15 RemoteException (android.os.RemoteException)15 MutableBoolean (android.util.MutableBoolean)15 RecentsActivityLaunchState (com.android.systemui.recents.RecentsActivityLaunchState)15 RecentsConfiguration (com.android.systemui.recents.RecentsConfiguration)15 Bitmap (android.graphics.Bitmap)14 ArrayList (java.util.ArrayList)14 BitmapDrawable (android.graphics.drawable.BitmapDrawable)12 ActivityNotFoundException (android.content.ActivityNotFoundException)10 Intent (android.content.Intent)10