Search in sources :

Example 1 with RecentsOrientedState

use of com.android.quickstep.util.RecentsOrientedState in project android_packages_apps_Launcher3 by crdroidandroid.

the class AbsSwipeUpHandler method createWindowAnimationToPip.

private SwipePipToHomeAnimator createWindowAnimationToPip(HomeAnimationFactory homeAnimFactory, RemoteAnimationTargetCompat runningTaskTarget, float startProgress) {
    // Directly animate the app to PiP (picture-in-picture) mode
    final ActivityManager.RunningTaskInfo taskInfo = mGestureState.getRunningTask();
    final RecentsOrientedState orientationState = mTaskViewSimulator.getOrientationState();
    final int windowRotation = orientationState.getDisplayRotation();
    final int homeRotation = orientationState.getRecentsActivityRotation();
    final Matrix homeToWindowPositionMap = new Matrix();
    final RectF startRect = updateProgressForStartRect(homeToWindowPositionMap, startProgress);
    // Move the startRect to Launcher space as floatingIconView runs in Launcher
    final Matrix windowToHomePositionMap = new Matrix();
    homeToWindowPositionMap.invert(windowToHomePositionMap);
    windowToHomePositionMap.mapRect(startRect);
    final Rect destinationBounds = SystemUiProxy.INSTANCE.get(mContext).startSwipePipToHome(taskInfo.topActivity, taskInfo.topActivityInfo, runningTaskTarget.taskInfo.pictureInPictureParams, homeRotation, mDp.hotseatBarSizePx);
    final SwipePipToHomeAnimator.Builder builder = new SwipePipToHomeAnimator.Builder().setContext(mContext).setTaskId(runningTaskTarget.taskId).setComponentName(taskInfo.topActivity).setLeash(runningTaskTarget.leash.getSurfaceControl()).setSourceRectHint(runningTaskTarget.taskInfo.pictureInPictureParams.getSourceRectHint()).setAppBounds(taskInfo.configuration.windowConfiguration.getBounds()).setHomeToWindowPositionMap(homeToWindowPositionMap).setStartBounds(startRect).setDestinationBounds(destinationBounds).setCornerRadius(mRecentsView.getPipCornerRadius()).setAttachedView(mRecentsView);
    // is not ROTATION_0 (which implies the rotation is turned on in launcher settings).
    if (homeRotation == ROTATION_0 && (windowRotation == ROTATION_90 || windowRotation == ROTATION_270)) {
        builder.setFromRotation(mTaskViewSimulator, windowRotation, taskInfo.displayCutoutInsets);
    }
    final SwipePipToHomeAnimator swipePipToHomeAnimator = builder.build();
    AnimatorPlaybackController activityAnimationToHome = homeAnimFactory.createActivityAnimationToHome();
    swipePipToHomeAnimator.addAnimatorListener(new AnimatorListenerAdapter() {

        private boolean mHasAnimationEnded;

        @Override
        public void onAnimationStart(Animator animation) {
            if (mHasAnimationEnded)
                return;
            // Ensure Launcher ends in NORMAL state
            activityAnimationToHome.dispatchOnStart();
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (mHasAnimationEnded)
                return;
            mHasAnimationEnded = true;
            activityAnimationToHome.getAnimationPlayer().end();
            if (mRecentsAnimationController == null) {
                // skip doing any future work here for the current gesture.
                return;
            }
            // Finalize the state and notify of the change
            mGestureState.setState(STATE_END_TARGET_ANIMATION_FINISHED);
        }
    });
    setupWindowAnimation(swipePipToHomeAnimator);
    return swipePipToHomeAnimator;
}
Also used : Rect(android.graphics.Rect) AnimatorPlaybackController(com.android.launcher3.anim.AnimatorPlaybackController) RecentsOrientedState(com.android.quickstep.util.RecentsOrientedState) ActivityManager(android.app.ActivityManager) RectF(android.graphics.RectF) Matrix(android.graphics.Matrix) SwipePipToHomeAnimator(com.android.quickstep.util.SwipePipToHomeAnimator) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) SwipePipToHomeAnimator(com.android.quickstep.util.SwipePipToHomeAnimator)

Example 2 with RecentsOrientedState

use of com.android.quickstep.util.RecentsOrientedState in project android_packages_apps_Launcher3 by crdroidandroid.

the class TaskOverlayFactory method getEnabledShortcuts.

public static List<SystemShortcut> getEnabledShortcuts(TaskView taskView, DeviceProfile deviceProfile) {
    final ArrayList<SystemShortcut> shortcuts = new ArrayList<>();
    final BaseDraggingActivity activity = BaseActivity.fromContext(taskView.getContext());
    for (TaskShortcutFactory menuOption : MENU_OPTIONS) {
        SystemShortcut shortcut = menuOption.getShortcut(activity, taskView);
        if (menuOption == TaskShortcutFactory.SPLIT_SCREEN && FeatureFlags.ENABLE_SPLIT_SELECT.get()) {
            addSplitOptions(shortcuts, activity, taskView, deviceProfile);
            continue;
        }
        if (shortcut != null) {
            shortcuts.add(shortcut);
        }
    }
    RecentsOrientedState orientedState = taskView.getRecentsView().getPagedViewOrientedState();
    boolean canLauncherRotate = orientedState.canRecentsActivityRotate();
    boolean isInLandscape = orientedState.getTouchRotation() != ROTATION_0;
    // Add overview actions to the menu when in in-place rotate landscape mode.
    if (!canLauncherRotate && isInLandscape) {
        // Add screenshot action to task menu.
        SystemShortcut screenshotShortcut = TaskShortcutFactory.SCREENSHOT.getShortcut(activity, taskView);
        if (screenshotShortcut != null) {
            screenshotShortcut.setHasFinishRecentsInAction(true);
            shortcuts.add(screenshotShortcut);
        }
        // Add modal action only if display orientation is the same as the device orientation.
        if (orientedState.getDisplayRotation() == ROTATION_0) {
            SystemShortcut modalShortcut = TaskShortcutFactory.MODAL.getShortcut(activity, taskView);
            if (modalShortcut != null) {
                modalShortcut.setHasFinishRecentsInAction(true);
                shortcuts.add(modalShortcut);
            }
        }
    }
    return shortcuts;
}
Also used : BaseDraggingActivity(com.android.launcher3.BaseDraggingActivity) SystemShortcut(com.android.launcher3.popup.SystemShortcut) SplitSelectSystemShortcut(com.android.quickstep.TaskShortcutFactory.SplitSelectSystemShortcut) ArrayList(java.util.ArrayList) RecentsOrientedState(com.android.quickstep.util.RecentsOrientedState)

Aggregations

RecentsOrientedState (com.android.quickstep.util.RecentsOrientedState)2 Animator (android.animation.Animator)1 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)1 ValueAnimator (android.animation.ValueAnimator)1 ActivityManager (android.app.ActivityManager)1 Matrix (android.graphics.Matrix)1 Rect (android.graphics.Rect)1 RectF (android.graphics.RectF)1 BaseDraggingActivity (com.android.launcher3.BaseDraggingActivity)1 AnimatorPlaybackController (com.android.launcher3.anim.AnimatorPlaybackController)1 SystemShortcut (com.android.launcher3.popup.SystemShortcut)1 SplitSelectSystemShortcut (com.android.quickstep.TaskShortcutFactory.SplitSelectSystemShortcut)1 SwipePipToHomeAnimator (com.android.quickstep.util.SwipePipToHomeAnimator)1 ArrayList (java.util.ArrayList)1