Search in sources :

Example 31 with AppTransitionAnimationSpec

use of android.view.AppTransitionAnimationSpec in project android_frameworks_base by ResurrectionRemix.

the class RecentsTransitionHelper method composeAnimationSpec.

/**
     * Composes a single animation spec for the given {@link TaskView}
     */
private static AppTransitionAnimationSpec composeAnimationSpec(TaskStackView stackView, TaskView taskView, TaskViewTransform transform, boolean addHeaderBitmap) {
    Bitmap b = null;
    if (addHeaderBitmap) {
        b = composeHeaderBitmap(taskView, transform);
        if (b == null) {
            return null;
        }
    }
    Rect taskRect = new Rect();
    transform.rect.round(taskRect);
    if (stackView.getStack().getStackFrontMostTask(false) != taskView.getTask()) {
        taskRect.bottom = taskRect.top + stackView.getMeasuredHeight();
    }
    return new AppTransitionAnimationSpec(taskView.getTask().key.id, b, taskRect);
}
Also used : Bitmap(android.graphics.Bitmap) Rect(android.graphics.Rect) AppTransitionAnimationSpec(android.view.AppTransitionAnimationSpec)

Example 32 with AppTransitionAnimationSpec

use of android.view.AppTransitionAnimationSpec in project android_frameworks_base by ResurrectionRemix.

the class AppTransition method getNextAppTransitionStartRect.

void getNextAppTransitionStartRect(int taskId, Rect rect) {
    AppTransitionAnimationSpec spec = mNextAppTransitionAnimationsSpecs.get(taskId);
    if (spec == null) {
        spec = mDefaultNextAppTransitionAnimationSpec;
    }
    if (spec == null || spec.rect == null) {
        Slog.wtf(TAG, "Starting rect for task: " + taskId + " requested, but not available", new Throwable());
        rect.setEmpty();
    } else {
        rect.set(spec.rect);
    }
}
Also used : AppTransitionAnimationSpec(android.view.AppTransitionAnimationSpec)

Example 33 with AppTransitionAnimationSpec

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

the class RecentsImpl method getThumbnailTransitionActivityOptions.

/**
     * Creates the activity options for an app->recents transition.
     */
private ActivityOptions getThumbnailTransitionActivityOptions(ActivityManager.RunningTaskInfo runningTask, TaskStackView stackView, Rect windowOverrideRect) {
    if (runningTask != null && runningTask.stackId == FREEFORM_WORKSPACE_STACK_ID) {
        ArrayList<AppTransitionAnimationSpec> specs = new ArrayList<>();
        ArrayList<Task> tasks = stackView.getStack().getStackTasks();
        TaskStackLayoutAlgorithm stackLayout = stackView.getStackAlgorithm();
        TaskStackViewScroller stackScroller = stackView.getScroller();
        stackView.updateLayoutAlgorithm(true);
        stackView.updateToInitialState();
        for (int i = tasks.size() - 1; i >= 0; i--) {
            Task task = tasks.get(i);
            if (task.isFreeformTask()) {
                mTmpTransform = stackLayout.getStackTransformScreenCoordinates(task, stackScroller.getStackScroll(), mTmpTransform, null, windowOverrideRect);
                Bitmap thumbnail = drawThumbnailTransitionBitmap(task, mTmpTransform, mThumbTransitionBitmapCache);
                Rect toTaskRect = new Rect();
                mTmpTransform.rect.round(toTaskRect);
                specs.add(new AppTransitionAnimationSpec(task.key.id, thumbnail, toTaskRect));
            }
        }
        AppTransitionAnimationSpec[] specsArray = new AppTransitionAnimationSpec[specs.size()];
        specs.toArray(specsArray);
        return ActivityOptions.makeThumbnailAspectScaleDownAnimation(mDummyStackView, specsArray, mHandler, null, this);
    } else {
        // Update the destination rect
        Task toTask = new Task();
        TaskViewTransform toTransform = getThumbnailTransitionTransform(stackView, toTask, windowOverrideRect);
        Bitmap thumbnail = drawThumbnailTransitionBitmap(toTask, toTransform, mThumbTransitionBitmapCache);
        if (thumbnail != null) {
            RectF toTaskRect = toTransform.rect;
            return ActivityOptions.makeThumbnailAspectScaleDownAnimation(mDummyStackView, thumbnail, (int) toTaskRect.left, (int) toTaskRect.top, (int) toTaskRect.width(), (int) toTaskRect.height(), mHandler, null);
        }
        // If both the screenshot and thumbnail fails, then just fall back to the default transition
        return getUnknownTransitionActivityOptions();
    }
}
Also used : TaskStackViewScroller(com.android.systemui.recents.views.TaskStackViewScroller) Task(com.android.systemui.recents.model.Task) Rect(android.graphics.Rect) ArrayList(java.util.ArrayList) RectF(android.graphics.RectF) Bitmap(android.graphics.Bitmap) AppTransitionAnimationSpec(android.view.AppTransitionAnimationSpec) TaskViewTransform(com.android.systemui.recents.views.TaskViewTransform) TaskStackLayoutAlgorithm(com.android.systemui.recents.views.TaskStackLayoutAlgorithm)

Example 34 with AppTransitionAnimationSpec

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

the class RecentsTransitionHelper method composeDockAnimationSpec.

/**
     * Composes the transition spec when docking a task, which includes a full task bitmap.
     */
public List<AppTransitionAnimationSpec> composeDockAnimationSpec(TaskView taskView, Rect bounds) {
    mTmpTransform.fillIn(taskView);
    Task task = taskView.getTask();
    Bitmap thumbnail = RecentsTransitionHelper.composeTaskBitmap(taskView, mTmpTransform);
    return Collections.singletonList(new AppTransitionAnimationSpec(task.key.id, thumbnail, bounds));
}
Also used : Task(com.android.systemui.recents.model.Task) Bitmap(android.graphics.Bitmap) AppTransitionAnimationSpec(android.view.AppTransitionAnimationSpec)

Example 35 with AppTransitionAnimationSpec

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

the class RecentsTransitionHelper method composeAnimationSpecs.

/**
     * Composes the animation specs for all the tasks in the target stack.
     */
private List<AppTransitionAnimationSpec> composeAnimationSpecs(final Task task, final TaskStackView stackView, final int destinationStack) {
    // Ensure we have a valid target stack id
    final int targetStackId = destinationStack != INVALID_STACK_ID ? destinationStack : task.key.stackId;
    if (!StackId.useAnimationSpecForAppTransition(targetStackId)) {
        return null;
    }
    // Calculate the offscreen task rect (for tasks that are not backed by views)
    TaskView taskView = stackView.getChildViewForTask(task);
    TaskStackLayoutAlgorithm stackLayout = stackView.getStackAlgorithm();
    Rect offscreenTaskRect = new Rect();
    stackLayout.getFrontOfStackTransform().rect.round(offscreenTaskRect);
    // If this is a full screen stack, the transition will be towards the single, full screen
    // task. We only need the transition spec for this task.
    List<AppTransitionAnimationSpec> specs = new ArrayList<>();
    // check for INVALID_STACK_ID
    if (targetStackId == FULLSCREEN_WORKSPACE_STACK_ID || targetStackId == DOCKED_STACK_ID || targetStackId == INVALID_STACK_ID) {
        if (taskView == null) {
            specs.add(composeOffscreenAnimationSpec(task, offscreenTaskRect));
        } else {
            mTmpTransform.fillIn(taskView);
            stackLayout.transformToScreenCoordinates(mTmpTransform, null);
            AppTransitionAnimationSpec spec = composeAnimationSpec(stackView, taskView, mTmpTransform, true);
            if (spec != null) {
                specs.add(spec);
            }
        }
        return specs;
    }
    // Otherwise, for freeform tasks, create a new animation spec for each task we have to
    // launch
    TaskStack stack = stackView.getStack();
    ArrayList<Task> tasks = stack.getStackTasks();
    int taskCount = tasks.size();
    for (int i = taskCount - 1; i >= 0; i--) {
        Task t = tasks.get(i);
        if (t.isFreeformTask() || targetStackId == FREEFORM_WORKSPACE_STACK_ID) {
            TaskView tv = stackView.getChildViewForTask(t);
            if (tv == null) {
                // TODO: Create a different animation task rect for this case (though it should
                //       never happen)
                specs.add(composeOffscreenAnimationSpec(t, offscreenTaskRect));
            } else {
                mTmpTransform.fillIn(taskView);
                stackLayout.transformToScreenCoordinates(mTmpTransform, null);
                AppTransitionAnimationSpec spec = composeAnimationSpec(stackView, tv, mTmpTransform, true);
                if (spec != null) {
                    specs.add(spec);
                }
            }
        }
    }
    return specs;
}
Also used : Rect(android.graphics.Rect) TaskStack(com.android.systemui.recents.model.TaskStack) Task(com.android.systemui.recents.model.Task) AppTransitionAnimationSpec(android.view.AppTransitionAnimationSpec) ArrayList(java.util.ArrayList)

Aggregations

AppTransitionAnimationSpec (android.view.AppTransitionAnimationSpec)38 Rect (android.graphics.Rect)24 Bitmap (android.graphics.Bitmap)15 Task (com.android.systemui.recents.model.Task)15 ArrayList (java.util.ArrayList)10 ActivityOptions (android.app.ActivityOptions)5 OnAnimationStartedListener (android.app.ActivityOptions.OnAnimationStartedListener)5 RectF (android.graphics.RectF)5 IAppTransitionAnimationSpecsFuture (android.view.IAppTransitionAnimationSpecsFuture)5 CancelEnterRecentsWindowAnimationEvent (com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent)5 ExitRecentsWindowFirstAnimationFrameEvent (com.android.systemui.recents.events.activity.ExitRecentsWindowFirstAnimationFrameEvent)5 LaunchTaskStartedEvent (com.android.systemui.recents.events.activity.LaunchTaskStartedEvent)5 TaskStack (com.android.systemui.recents.model.TaskStack)5 TaskStackLayoutAlgorithm (com.android.systemui.recents.views.TaskStackLayoutAlgorithm)5 TaskStackViewScroller (com.android.systemui.recents.views.TaskStackViewScroller)5 TaskViewTransform (com.android.systemui.recents.views.TaskViewTransform)5