Search in sources :

Example 21 with AppTransitionAnimationSpec

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

the class ActivityRecord method applyOptionsLocked.

void applyOptionsLocked() {
    if (pendingOptions != null && pendingOptions.getAnimationType() != ActivityOptions.ANIM_SCENE_TRANSITION) {
        final int animationType = pendingOptions.getAnimationType();
        switch(animationType) {
            case ActivityOptions.ANIM_CUSTOM:
                service.mWindowManager.overridePendingAppTransition(pendingOptions.getPackageName(), pendingOptions.getCustomEnterResId(), pendingOptions.getCustomExitResId(), pendingOptions.getOnAnimationStartListener());
                break;
            case ActivityOptions.ANIM_CLIP_REVEAL:
                service.mWindowManager.overridePendingAppTransitionClipReveal(pendingOptions.getStartX(), pendingOptions.getStartY(), pendingOptions.getWidth(), pendingOptions.getHeight());
                if (intent.getSourceBounds() == null) {
                    intent.setSourceBounds(new Rect(pendingOptions.getStartX(), pendingOptions.getStartY(), pendingOptions.getStartX() + pendingOptions.getWidth(), pendingOptions.getStartY() + pendingOptions.getHeight()));
                }
                break;
            case ActivityOptions.ANIM_SCALE_UP:
                service.mWindowManager.overridePendingAppTransitionScaleUp(pendingOptions.getStartX(), pendingOptions.getStartY(), pendingOptions.getWidth(), pendingOptions.getHeight());
                if (intent.getSourceBounds() == null) {
                    intent.setSourceBounds(new Rect(pendingOptions.getStartX(), pendingOptions.getStartY(), pendingOptions.getStartX() + pendingOptions.getWidth(), pendingOptions.getStartY() + pendingOptions.getHeight()));
                }
                break;
            case ActivityOptions.ANIM_THUMBNAIL_SCALE_UP:
            case ActivityOptions.ANIM_THUMBNAIL_SCALE_DOWN:
                boolean scaleUp = (animationType == ActivityOptions.ANIM_THUMBNAIL_SCALE_UP);
                service.mWindowManager.overridePendingAppTransitionThumb(pendingOptions.getThumbnail(), pendingOptions.getStartX(), pendingOptions.getStartY(), pendingOptions.getOnAnimationStartListener(), scaleUp);
                if (intent.getSourceBounds() == null) {
                    intent.setSourceBounds(new Rect(pendingOptions.getStartX(), pendingOptions.getStartY(), pendingOptions.getStartX() + pendingOptions.getThumbnail().getWidth(), pendingOptions.getStartY() + pendingOptions.getThumbnail().getHeight()));
                }
                break;
            case ActivityOptions.ANIM_THUMBNAIL_ASPECT_SCALE_UP:
            case ActivityOptions.ANIM_THUMBNAIL_ASPECT_SCALE_DOWN:
                final AppTransitionAnimationSpec[] specs = pendingOptions.getAnimSpecs();
                if (animationType == ActivityOptions.ANIM_THUMBNAIL_ASPECT_SCALE_DOWN && specs != null) {
                    service.mWindowManager.overridePendingAppTransitionMultiThumb(specs, pendingOptions.getOnAnimationStartListener(), pendingOptions.getAnimationFinishedListener(), false);
                } else {
                    service.mWindowManager.overridePendingAppTransitionAspectScaledThumb(pendingOptions.getThumbnail(), pendingOptions.getStartX(), pendingOptions.getStartY(), pendingOptions.getWidth(), pendingOptions.getHeight(), pendingOptions.getOnAnimationStartListener(), (animationType == ActivityOptions.ANIM_THUMBNAIL_ASPECT_SCALE_UP));
                    if (intent.getSourceBounds() == null) {
                        intent.setSourceBounds(new Rect(pendingOptions.getStartX(), pendingOptions.getStartY(), pendingOptions.getStartX() + pendingOptions.getWidth(), pendingOptions.getStartY() + pendingOptions.getHeight()));
                    }
                }
                break;
            default:
                Slog.e(TAG, "applyOptionsLocked: Unknown animationType=" + animationType);
                break;
        }
        pendingOptions = null;
    }
}
Also used : Rect(android.graphics.Rect) AppTransitionAnimationSpec(android.view.AppTransitionAnimationSpec)

Example 22 with AppTransitionAnimationSpec

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

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 23 with AppTransitionAnimationSpec

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

the class AppTransition method overridePendingAppTransitionMultiThumb.

public void overridePendingAppTransitionMultiThumb(AppTransitionAnimationSpec[] specs, IRemoteCallback onAnimationStartedCallback, IRemoteCallback onAnimationFinishedCallback, boolean scaleUp) {
    if (isTransitionSet()) {
        clear();
        mNextAppTransitionType = scaleUp ? NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_UP : NEXT_TRANSIT_TYPE_THUMBNAIL_ASPECT_SCALE_DOWN;
        mNextAppTransitionScaleUp = scaleUp;
        if (specs != null) {
            for (int i = 0; i < specs.length; i++) {
                AppTransitionAnimationSpec spec = specs[i];
                if (spec != null) {
                    mNextAppTransitionAnimationsSpecs.put(spec.taskId, spec);
                    if (i == 0) {
                        // In full screen mode, the transition code depends on the default spec
                        // to be set.
                        Rect rect = spec.rect;
                        putDefaultNextAppTransitionCoordinates(rect.left, rect.top, rect.width(), rect.height(), spec.bitmap);
                    }
                }
            }
        }
        postAnimationCallback();
        mNextAppTransitionCallback = onAnimationStartedCallback;
        mAnimationFinishedCallback = onAnimationFinishedCallback;
    } else {
        postAnimationCallback();
    }
}
Also used : Rect(android.graphics.Rect) AppTransitionAnimationSpec(android.view.AppTransitionAnimationSpec)

Example 24 with AppTransitionAnimationSpec

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

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 25 with AppTransitionAnimationSpec

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

the class ActivityRecord method applyOptionsLocked.

void applyOptionsLocked() {
    if (pendingOptions != null && pendingOptions.getAnimationType() != ActivityOptions.ANIM_SCENE_TRANSITION) {
        final int animationType = pendingOptions.getAnimationType();
        switch(animationType) {
            case ActivityOptions.ANIM_CUSTOM:
                service.mWindowManager.overridePendingAppTransition(pendingOptions.getPackageName(), pendingOptions.getCustomEnterResId(), pendingOptions.getCustomExitResId(), pendingOptions.getOnAnimationStartListener());
                break;
            case ActivityOptions.ANIM_CLIP_REVEAL:
                service.mWindowManager.overridePendingAppTransitionClipReveal(pendingOptions.getStartX(), pendingOptions.getStartY(), pendingOptions.getWidth(), pendingOptions.getHeight());
                if (intent.getSourceBounds() == null) {
                    intent.setSourceBounds(new Rect(pendingOptions.getStartX(), pendingOptions.getStartY(), pendingOptions.getStartX() + pendingOptions.getWidth(), pendingOptions.getStartY() + pendingOptions.getHeight()));
                }
                break;
            case ActivityOptions.ANIM_SCALE_UP:
                service.mWindowManager.overridePendingAppTransitionScaleUp(pendingOptions.getStartX(), pendingOptions.getStartY(), pendingOptions.getWidth(), pendingOptions.getHeight());
                if (intent.getSourceBounds() == null) {
                    intent.setSourceBounds(new Rect(pendingOptions.getStartX(), pendingOptions.getStartY(), pendingOptions.getStartX() + pendingOptions.getWidth(), pendingOptions.getStartY() + pendingOptions.getHeight()));
                }
                break;
            case ActivityOptions.ANIM_THUMBNAIL_SCALE_UP:
            case ActivityOptions.ANIM_THUMBNAIL_SCALE_DOWN:
                boolean scaleUp = (animationType == ActivityOptions.ANIM_THUMBNAIL_SCALE_UP);
                service.mWindowManager.overridePendingAppTransitionThumb(pendingOptions.getThumbnail(), pendingOptions.getStartX(), pendingOptions.getStartY(), pendingOptions.getOnAnimationStartListener(), scaleUp);
                if (intent.getSourceBounds() == null) {
                    intent.setSourceBounds(new Rect(pendingOptions.getStartX(), pendingOptions.getStartY(), pendingOptions.getStartX() + pendingOptions.getThumbnail().getWidth(), pendingOptions.getStartY() + pendingOptions.getThumbnail().getHeight()));
                }
                break;
            case ActivityOptions.ANIM_THUMBNAIL_ASPECT_SCALE_UP:
            case ActivityOptions.ANIM_THUMBNAIL_ASPECT_SCALE_DOWN:
                final AppTransitionAnimationSpec[] specs = pendingOptions.getAnimSpecs();
                if (animationType == ActivityOptions.ANIM_THUMBNAIL_ASPECT_SCALE_DOWN && specs != null) {
                    service.mWindowManager.overridePendingAppTransitionMultiThumb(specs, pendingOptions.getOnAnimationStartListener(), pendingOptions.getAnimationFinishedListener(), false);
                } else {
                    service.mWindowManager.overridePendingAppTransitionAspectScaledThumb(pendingOptions.getThumbnail(), pendingOptions.getStartX(), pendingOptions.getStartY(), pendingOptions.getWidth(), pendingOptions.getHeight(), pendingOptions.getOnAnimationStartListener(), (animationType == ActivityOptions.ANIM_THUMBNAIL_ASPECT_SCALE_UP));
                    if (intent.getSourceBounds() == null) {
                        intent.setSourceBounds(new Rect(pendingOptions.getStartX(), pendingOptions.getStartY(), pendingOptions.getStartX() + pendingOptions.getWidth(), pendingOptions.getStartY() + pendingOptions.getHeight()));
                    }
                }
                break;
            default:
                Slog.e(TAG, "applyOptionsLocked: Unknown animationType=" + animationType);
                break;
        }
        pendingOptions = null;
    }
}
Also used : Rect(android.graphics.Rect) AppTransitionAnimationSpec(android.view.AppTransitionAnimationSpec)

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