Search in sources :

Example 6 with IAppTransitionAnimationSpecsFuture

use of android.view.IAppTransitionAnimationSpecsFuture in project android_frameworks_base by DirtyUnicorns.

the class AppTransition method fetchAppTransitionSpecsFromFuture.

/**
     * If a future is set for the app transition specs, fetch it in another thread.
     */
private void fetchAppTransitionSpecsFromFuture() {
    if (mNextAppTransitionAnimationsSpecsFuture != null) {
        mNextAppTransitionAnimationsSpecsPending = true;
        final IAppTransitionAnimationSpecsFuture future = mNextAppTransitionAnimationsSpecsFuture;
        mNextAppTransitionAnimationsSpecsFuture = null;
        mDefaultExecutor.execute(new Runnable() {

            @Override
            public void run() {
                AppTransitionAnimationSpec[] specs = null;
                try {
                    specs = future.get();
                } catch (RemoteException e) {
                    Slog.w(TAG, "Failed to fetch app transition specs: " + e);
                }
                synchronized (mService.mWindowMap) {
                    mNextAppTransitionAnimationsSpecsPending = false;
                    overridePendingAppTransitionMultiThumb(specs, mNextAppTransitionFutureCallback, null, /* finishedCallback */
                    mNextAppTransitionScaleUp);
                    mNextAppTransitionFutureCallback = null;
                    if (specs != null) {
                        mService.prolongAnimationsFromSpecs(specs, mNextAppTransitionScaleUp);
                    }
                }
                mService.requestTraversal();
            }
        });
    }
}
Also used : IAppTransitionAnimationSpecsFuture(android.view.IAppTransitionAnimationSpecsFuture) RemoteException(android.os.RemoteException)

Example 7 with IAppTransitionAnimationSpecsFuture

use of android.view.IAppTransitionAnimationSpecsFuture in project android_frameworks_base by DirtyUnicorns.

the class RecentsTransitionHelper method launchTaskFromRecents.

/**
     * Launches the specified {@link Task}.
     */
public void launchTaskFromRecents(final TaskStack stack, @Nullable final Task task, final TaskStackView stackView, final TaskView taskView, final boolean screenPinningRequested, final Rect bounds, final int destinationStack) {
    final ActivityOptions opts = ActivityOptions.makeBasic();
    if (bounds != null) {
        opts.setLaunchBounds(bounds.isEmpty() ? null : bounds);
    }
    final ActivityOptions.OnAnimationStartedListener animStartedListener;
    final IAppTransitionAnimationSpecsFuture transitionFuture;
    if (taskView != null) {
        transitionFuture = getAppTransitionFuture(new AnimationSpecComposer() {

            @Override
            public List<AppTransitionAnimationSpec> composeSpecs() {
                return composeAnimationSpecs(task, stackView, destinationStack);
            }
        });
        animStartedListener = new ActivityOptions.OnAnimationStartedListener() {

            @Override
            public void onAnimationStarted() {
                // If we are launching into another task, cancel the previous task's
                // window transition
                EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task));
                EventBus.getDefault().send(new ExitRecentsWindowFirstAnimationFrameEvent());
                stackView.cancelAllTaskViewAnimations();
                if (screenPinningRequested) {
                    // Request screen pinning after the animation runs
                    mStartScreenPinningRunnable.taskId = task.key.id;
                    mHandler.postDelayed(mStartScreenPinningRunnable, 350);
                }
            }
        };
    } else {
        // This is only the case if the task is not on screen (scrolled offscreen for example)
        transitionFuture = null;
        animStartedListener = new ActivityOptions.OnAnimationStartedListener() {

            @Override
            public void onAnimationStarted() {
                // If we are launching into another task, cancel the previous task's
                // window transition
                EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task));
                EventBus.getDefault().send(new ExitRecentsWindowFirstAnimationFrameEvent());
                stackView.cancelAllTaskViewAnimations();
            }
        };
    }
    if (taskView == null) {
        // If there is no task view, then we do not need to worry about animating out occluding
        // task views, and we can launch immediately
        startTaskActivity(stack, task, taskView, opts, transitionFuture, animStartedListener);
    } else {
        LaunchTaskStartedEvent launchStartedEvent = new LaunchTaskStartedEvent(taskView, screenPinningRequested);
        if (task.group != null && !task.group.isFrontMostTask(task)) {
            launchStartedEvent.addPostAnimationCallback(new Runnable() {

                @Override
                public void run() {
                    startTaskActivity(stack, task, taskView, opts, transitionFuture, animStartedListener);
                }
            });
            EventBus.getDefault().send(launchStartedEvent);
        } else {
            EventBus.getDefault().send(launchStartedEvent);
            startTaskActivity(stack, task, taskView, opts, transitionFuture, animStartedListener);
        }
    }
    Recents.getSystemServices().sendCloseSystemWindows(BaseStatusBar.SYSTEM_DIALOG_REASON_HOME_KEY);
}
Also used : OnAnimationStartedListener(android.app.ActivityOptions.OnAnimationStartedListener) IAppTransitionAnimationSpecsFuture(android.view.IAppTransitionAnimationSpecsFuture) AppTransitionAnimationSpec(android.view.AppTransitionAnimationSpec) LaunchTaskStartedEvent(com.android.systemui.recents.events.activity.LaunchTaskStartedEvent) ExitRecentsWindowFirstAnimationFrameEvent(com.android.systemui.recents.events.activity.ExitRecentsWindowFirstAnimationFrameEvent) CancelEnterRecentsWindowAnimationEvent(com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent) ActivityOptions(android.app.ActivityOptions)

Example 8 with IAppTransitionAnimationSpecsFuture

use of android.view.IAppTransitionAnimationSpecsFuture in project android_frameworks_base by crdroidandroid.

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 9 with IAppTransitionAnimationSpecsFuture

use of android.view.IAppTransitionAnimationSpecsFuture in project android_frameworks_base by crdroidandroid.

the class AppTransition method fetchAppTransitionSpecsFromFuture.

/**
     * If a future is set for the app transition specs, fetch it in another thread.
     */
private void fetchAppTransitionSpecsFromFuture() {
    if (mNextAppTransitionAnimationsSpecsFuture != null) {
        mNextAppTransitionAnimationsSpecsPending = true;
        final IAppTransitionAnimationSpecsFuture future = mNextAppTransitionAnimationsSpecsFuture;
        mNextAppTransitionAnimationsSpecsFuture = null;
        mDefaultExecutor.execute(new Runnable() {

            @Override
            public void run() {
                AppTransitionAnimationSpec[] specs = null;
                try {
                    specs = future.get();
                } catch (RemoteException e) {
                    Slog.w(TAG, "Failed to fetch app transition specs: " + e);
                }
                synchronized (mService.mWindowMap) {
                    mNextAppTransitionAnimationsSpecsPending = false;
                    overridePendingAppTransitionMultiThumb(specs, mNextAppTransitionFutureCallback, null, /* finishedCallback */
                    mNextAppTransitionScaleUp);
                    mNextAppTransitionFutureCallback = null;
                    if (specs != null) {
                        mService.prolongAnimationsFromSpecs(specs, mNextAppTransitionScaleUp);
                    }
                }
                mService.requestTraversal();
            }
        });
    }
}
Also used : IAppTransitionAnimationSpecsFuture(android.view.IAppTransitionAnimationSpecsFuture) RemoteException(android.os.RemoteException)

Example 10 with IAppTransitionAnimationSpecsFuture

use of android.view.IAppTransitionAnimationSpecsFuture in project android_frameworks_base by AOSPA.

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)

Aggregations

IAppTransitionAnimationSpecsFuture (android.view.IAppTransitionAnimationSpecsFuture)14 OnAnimationStartedListener (android.app.ActivityOptions.OnAnimationStartedListener)10 ActivityOptions (android.app.ActivityOptions)5 Rect (android.graphics.Rect)5 AppTransitionAnimationSpec (android.view.AppTransitionAnimationSpec)5 CancelEnterRecentsWindowAnimationEvent (com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent)5 DockedFirstAnimationFrameEvent (com.android.systemui.recents.events.activity.DockedFirstAnimationFrameEvent)5 ExitRecentsWindowFirstAnimationFrameEvent (com.android.systemui.recents.events.activity.ExitRecentsWindowFirstAnimationFrameEvent)5 LaunchTaskStartedEvent (com.android.systemui.recents.events.activity.LaunchTaskStartedEvent)5 DragEndCancelledEvent (com.android.systemui.recents.events.ui.dragndrop.DragEndCancelledEvent)5 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)5 TaskStack (com.android.systemui.recents.model.TaskStack)5 AnimationSpecComposer (com.android.systemui.recents.views.RecentsTransitionHelper.AnimationSpecComposer)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 RemoteException (android.os.RemoteException)4