Search in sources :

Example 1 with LINEAR

use of com.android.launcher3.anim.Interpolators.LINEAR in project android_packages_apps_Launcher3 by crdroidandroid.

the class QuickstepTransitionManager method getLauncherContentAnimator.

/**
 * Content is everything on screen except the background and the floating view (if any).
 *
 * @param isAppOpening True when this is called when an app is opening.
 *                     False when this is called when an app is closing.
 * @param startDelay   Start delay duration.
 */
private Pair<AnimatorSet, Runnable> getLauncherContentAnimator(boolean isAppOpening, int startDelay) {
    AnimatorSet launcherAnimator = new AnimatorSet();
    Runnable endListener;
    float[] alphas = isAppOpening ? new float[] { 1, 0 } : new float[] { 0, 1 };
    float[] scales = isAppOpening ? new float[] { 1, mContentScale } : new float[] { mContentScale, 1 };
    if (mLauncher.isInState(ALL_APPS)) {
        // All Apps in portrait mode is full screen, so we only animate AllAppsContainerView.
        final View appsView = mLauncher.getAppsView();
        final float startAlpha = appsView.getAlpha();
        final float startScale = SCALE_PROPERTY.get(appsView);
        appsView.setAlpha(alphas[0]);
        SCALE_PROPERTY.set(appsView, scales[0]);
        ObjectAnimator alpha = ObjectAnimator.ofFloat(appsView, View.ALPHA, alphas);
        alpha.setDuration(CONTENT_ALPHA_DURATION);
        alpha.setInterpolator(LINEAR);
        appsView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        alpha.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationEnd(Animator animation) {
                appsView.setLayerType(View.LAYER_TYPE_NONE, null);
            }
        });
        ObjectAnimator scale = ObjectAnimator.ofFloat(appsView, SCALE_PROPERTY, scales);
        scale.setInterpolator(AGGRESSIVE_EASE);
        scale.setDuration(CONTENT_SCALE_DURATION);
        launcherAnimator.play(alpha);
        launcherAnimator.play(scale);
        endListener = () -> {
            appsView.setAlpha(startAlpha);
            SCALE_PROPERTY.set(appsView, startScale);
            appsView.setLayerType(View.LAYER_TYPE_NONE, null);
        };
    } else if (mLauncher.isInState(OVERVIEW)) {
        endListener = composeViewContentAnimator(launcherAnimator, alphas, scales);
    } else {
        List<View> viewsToAnimate = new ArrayList<>();
        Workspace workspace = mLauncher.getWorkspace();
        workspace.forEachVisiblePage(view -> viewsToAnimate.add(((CellLayout) view).getShortcutsAndWidgets()));
        viewsToAnimate.add(mLauncher.getHotseat());
        viewsToAnimate.forEach(view -> {
            view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            ObjectAnimator scaleAnim = ObjectAnimator.ofFloat(view, SCALE_PROPERTY, scales).setDuration(CONTENT_SCALE_DURATION);
            scaleAnim.setInterpolator(DEACCEL_1_5);
            launcherAnimator.play(scaleAnim);
        });
        final boolean scrimEnabled = ENABLE_SCRIM_FOR_APP_LAUNCH.get();
        if (scrimEnabled) {
            int scrimColor = Themes.getAttrColor(mLauncher, R.attr.overviewScrimColor);
            int scrimColorTrans = ColorUtils.setAlphaComponent(scrimColor, 0);
            int[] colors = isAppOpening ? new int[] { scrimColorTrans, scrimColor } : new int[] { scrimColor, scrimColorTrans };
            ScrimView scrimView = mLauncher.getScrimView();
            if (scrimView.getBackground() instanceof ColorDrawable) {
                scrimView.setBackgroundColor(colors[0]);
                ObjectAnimator scrim = ObjectAnimator.ofArgb(scrimView, VIEW_BACKGROUND_COLOR, colors);
                scrim.setDuration(CONTENT_SCRIM_DURATION);
                scrim.setInterpolator(DEACCEL_1_5);
                launcherAnimator.play(scrim);
            }
        }
        // Pause page indicator animations as they lead to layer trashing.
        mLauncher.getWorkspace().getPageIndicator().pauseAnimations();
        endListener = () -> {
            viewsToAnimate.forEach(view -> {
                SCALE_PROPERTY.set(view, 1f);
                view.setLayerType(View.LAYER_TYPE_NONE, null);
            });
            if (scrimEnabled) {
                mLauncher.getScrimView().setBackgroundColor(Color.TRANSPARENT);
            }
            mLauncher.getWorkspace().getPageIndicator().skipAnimationsToEnd();
        };
    }
    launcherAnimator.setStartDelay(startDelay);
    return new Pair<>(launcherAnimator, endListener);
}
Also used : BACKGROUND_APP(com.android.launcher3.LauncherState.BACKGROUND_APP) BlurUtils(com.android.systemui.shared.system.BlurUtils) NonNull(androidx.annotation.NonNull) ColorDrawable(android.graphics.drawable.ColorDrawable) OVERVIEW(com.android.launcher3.LauncherState.OVERVIEW) Drawable(android.graphics.drawable.Drawable) KEYGUARD_ANIMATION(com.android.launcher3.config.FeatureFlags.KEYGUARD_ANIMATION) DisplayController.getSingleFrameMs(com.android.launcher3.util.DisplayController.getSingleFrameMs) Handler(android.os.Handler) Looper(android.os.Looper) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener) InteractionJankMonitorWrapper(com.android.systemui.shared.system.InteractionJankMonitorWrapper) SCALE_PROPERTY(com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY) PathInterpolator(android.view.animation.PathInterpolator) MODE_CLOSING(com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_CLOSING) Interpolator(android.view.animation.Interpolator) AGGRESSIVE_EASE(com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE) STARTING_WINDOW_TYPE_SPLASH_SCREEN(android.window.StartingWindowInfo.STARTING_WINDOW_TYPE_SPLASH_SCREEN) ViewRootImpl(android.view.ViewRootImpl) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Nullable(androidx.annotation.Nullable) RemoteAnimationFactory(com.android.launcher3.LauncherAnimationRunner.RemoteAnimationFactory) ActivityCompat(com.android.systemui.shared.system.ActivityCompat) INVISIBLE_BY_APP_TRANSITIONS(com.android.launcher3.BaseActivity.INVISIBLE_BY_APP_TRANSITIONS) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) QuickStepContract.getWindowCornerRadius(com.android.systemui.shared.system.QuickStepContract.getWindowCornerRadius) RemoteAnimationDefinitionCompat(com.android.systemui.shared.system.RemoteAnimationDefinitionCompat) TaskUtils.taskIsATargetWithMode(com.android.quickstep.TaskUtils.taskIsATargetWithMode) DEACCEL_1_5(com.android.launcher3.anim.Interpolators.DEACCEL_1_5) SEPARATE_RECENTS_ACTIVITY(com.android.launcher3.config.FeatureFlags.SEPARATE_RECENTS_ACTIVITY) RemoteAnimationTargetCompat(com.android.systemui.shared.system.RemoteAnimationTargetCompat) QuickStepContract(com.android.systemui.shared.system.QuickStepContract) SystemUiProxy(com.android.quickstep.SystemUiProxy) DEACCEL_1_7(com.android.launcher3.anim.Interpolators.DEACCEL_1_7) RemoteAnimationTargets(com.android.quickstep.RemoteAnimationTargets) ArrayList(java.util.ArrayList) WorkspaceRevealAnim(com.android.quickstep.util.WorkspaceRevealAnim) LinkedHashMap(java.util.LinkedHashMap) FloatingIconView(com.android.launcher3.views.FloatingIconView) TaskViewUtils.findTaskViewToLaunch(com.android.quickstep.TaskViewUtils.findTaskViewToLaunch) RemoteAnimationProvider(com.android.quickstep.util.RemoteAnimationProvider) DEPTH(com.android.launcher3.statehandlers.DepthController.DEPTH) OnDeviceProfileChangeListener(com.android.launcher3.DeviceProfile.OnDeviceProfileChangeListener) FastBitmapDrawable(com.android.launcher3.icons.FastBitmapDrawable) VIEW_BACKGROUND_COLOR(com.android.launcher3.LauncherAnimUtils.VIEW_BACKGROUND_COLOR) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) ENABLE_SCRIM_FOR_APP_LAUNCH(com.android.launcher3.config.FeatureFlags.ENABLE_SCRIM_FOR_APP_LAUNCH) STARTING_WINDOW_TYPE_NONE(android.window.StartingWindowInfo.STARTING_WINDOW_TYPE_NONE) INVISIBLE_BY_PENDING_FLAGS(com.android.launcher3.BaseActivity.INVISIBLE_BY_PENDING_FLAGS) SystemProperties(android.os.SystemProperties) LINEAR(com.android.launcher3.anim.Interpolators.LINEAR) IStartingWindowListener(com.android.wm.shell.startingsurface.IStartingWindowListener) AlphaProperty(com.android.launcher3.util.MultiValueAlpha.AlphaProperty) ColorUtils(androidx.core.graphics.ColorUtils) RunnableList(com.android.launcher3.util.RunnableList) RemoteAnimationRunnerCompat(com.android.systemui.shared.system.RemoteAnimationRunnerCompat) ValueAnimator(android.animation.ValueAnimator) Rect(android.graphics.Rect) PackageManager(android.content.pm.PackageManager) Animator(android.animation.Animator) PENDING_INVISIBLE_BY_WALLPAPER_ANIMATION(com.android.launcher3.BaseActivity.PENDING_INVISIBLE_BY_WALLPAPER_ANIMATION) RemoteAnimationAdapterCompat(com.android.systemui.shared.system.RemoteAnimationAdapterCompat) WindowManagerWrapper(com.android.systemui.shared.system.WindowManagerWrapper) TaskViewUtils(com.android.quickstep.TaskViewUtils) View(android.view.View) Matrix(android.graphics.Matrix) RectF(android.graphics.RectF) DepthController(com.android.launcher3.statehandlers.DepthController) ObjectAnimator(android.animation.ObjectAnimator) CancellationSignal(android.os.CancellationSignal) ALPHA_INDEX_TRANSITIONS(com.android.launcher3.dragndrop.DragLayer.ALPHA_INDEX_TRANSITIONS) List(java.util.List) ALL_APPS(com.android.launcher3.LauncherState.ALL_APPS) Utilities.postAsyncCallback(com.android.launcher3.Utilities.postAsyncCallback) Themes(com.android.launcher3.util.Themes) SurfaceTransactionApplier(com.android.quickstep.util.SurfaceTransactionApplier) Size(android.util.Size) ActivityOptionsCompat(com.android.systemui.shared.system.ActivityOptionsCompat) Context(android.content.Context) Pair(android.util.Pair) AnimationUtils(android.view.animation.AnimationUtils) MODE_OPENING(com.android.systemui.shared.system.RemoteAnimationTargetCompat.MODE_OPENING) AnimatorSet(android.animation.AnimatorSet) DragLayer(com.android.launcher3.dragndrop.DragLayer) ActivityOptionsWrapper(com.android.launcher3.util.ActivityOptionsWrapper) SurfaceParams(com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams) INVISIBLE_ALL(com.android.launcher3.BaseActivity.INVISIBLE_ALL) MultiValueUpdateListener(com.android.quickstep.util.MultiValueUpdateListener) Point(android.graphics.Point) RemoteTransitionCompat(com.android.systemui.shared.system.RemoteTransitionCompat) Color(android.graphics.Color) SurfaceControl(android.view.SurfaceControl) QuickStepContract.supportsRoundedCornersOnWindows(com.android.systemui.shared.system.QuickStepContract.supportsRoundedCornersOnWindows) ViewTreeObserver(android.view.ViewTreeObserver) ScrimView(com.android.launcher3.views.ScrimView) RecentsView(com.android.quickstep.views.RecentsView) FloatingWidgetView(com.android.quickstep.views.FloatingWidgetView) Resources(android.content.res.Resources) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) ScrimView(com.android.launcher3.views.ScrimView) LauncherAppWidgetHostView(com.android.launcher3.widget.LauncherAppWidgetHostView) FloatingIconView(com.android.launcher3.views.FloatingIconView) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) View(android.view.View) ScrimView(com.android.launcher3.views.ScrimView) RecentsView(com.android.quickstep.views.RecentsView) FloatingWidgetView(com.android.quickstep.views.FloatingWidgetView) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ColorDrawable(android.graphics.drawable.ColorDrawable) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ArrayList(java.util.ArrayList) RunnableList(com.android.launcher3.util.RunnableList) List(java.util.List) Pair(android.util.Pair)

Example 2 with LINEAR

use of com.android.launcher3.anim.Interpolators.LINEAR in project android_packages_apps_Launcher3 by crdroidandroid.

the class QuickstepTransitionManager method getOpeningWindowAnimators.

/**
 * @return Animator that controls the window of the opening targets from app icons.
 */
private Animator getOpeningWindowAnimators(View v, RemoteAnimationTargetCompat[] appTargets, RemoteAnimationTargetCompat[] wallpaperTargets, RemoteAnimationTargetCompat[] nonAppTargets, Rect windowTargetBounds, boolean appTargetsAreTranslucent, int rotationChange) {
    RectF launcherIconBounds = new RectF();
    FloatingIconView floatingView = FloatingIconView.getFloatingIconView(mLauncher, v, !appTargetsAreTranslucent, launcherIconBounds, true);
    Rect crop = new Rect();
    Matrix matrix = new Matrix();
    RemoteAnimationTargets openingTargets = new RemoteAnimationTargets(appTargets, wallpaperTargets, nonAppTargets, MODE_OPENING);
    SurfaceTransactionApplier surfaceApplier = new SurfaceTransactionApplier(floatingView);
    openingTargets.addReleaseCheck(surfaceApplier);
    RemoteAnimationTargetCompat navBarTarget = openingTargets.getNavBarRemoteAnimationTarget();
    int[] dragLayerBounds = new int[2];
    mDragLayer.getLocationOnScreen(dragLayerBounds);
    final boolean hasSplashScreen;
    if (supportsSSplashScreen()) {
        int taskId = openingTargets.getFirstAppTargetTaskId();
        Pair<Integer, Integer> defaultParams = Pair.create(STARTING_WINDOW_TYPE_NONE, 0);
        Pair<Integer, Integer> taskParams = mTaskStartParams.getOrDefault(taskId, defaultParams);
        mTaskStartParams.remove(taskId);
        hasSplashScreen = taskParams.first == STARTING_WINDOW_TYPE_SPLASH_SCREEN;
    } else {
        hasSplashScreen = false;
    }
    AnimOpenProperties prop = new AnimOpenProperties(mLauncher.getResources(), mDeviceProfile, windowTargetBounds, launcherIconBounds, v, dragLayerBounds[0], dragLayerBounds[1], hasSplashScreen, floatingView.isDifferentFromAppIcon());
    int left = (int) (prop.cropCenterXStart - prop.cropWidthStart / 2);
    int top = (int) (prop.cropCenterYStart - prop.cropHeightStart / 2);
    int right = (int) (left + prop.cropWidthStart);
    int bottom = (int) (top + prop.cropHeightStart);
    // Set the crop here so we can calculate the corner radius below.
    crop.set(left, top, right, bottom);
    RectF floatingIconBounds = new RectF();
    RectF tmpRectF = new RectF();
    Point tmpPos = new Point();
    AnimatorSet animatorSet = new AnimatorSet();
    ValueAnimator appAnimator = ValueAnimator.ofFloat(0, 1);
    appAnimator.setDuration(APP_LAUNCH_DURATION);
    appAnimator.setInterpolator(LINEAR);
    appAnimator.addListener(floatingView);
    appAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            if (v instanceof BubbleTextView) {
                ((BubbleTextView) v).setStayPressed(false);
            }
            openingTargets.release();
        }
    });
    final float initialWindowRadius = supportsRoundedCornersOnWindows(mLauncher.getResources()) ? Math.max(crop.width(), crop.height()) / 2f : 0f;
    final float finalWindowRadius = mDeviceProfile.isMultiWindowMode ? 0 : getWindowCornerRadius(mLauncher.getResources());
    final float finalShadowRadius = appTargetsAreTranslucent ? 0 : mMaxShadowRadius;
    MultiValueUpdateListener listener = new MultiValueUpdateListener() {

        FloatProp mDx = new FloatProp(0, prop.dX, 0, APP_LAUNCH_DURATION, mOpeningXInterpolator);

        FloatProp mDy = new FloatProp(0, prop.dY, 0, APP_LAUNCH_DURATION, mOpeningInterpolator);

        FloatProp mIconScaleToFitScreen = new FloatProp(prop.initialAppIconScale, prop.finalAppIconScale, 0, APP_LAUNCH_DURATION, mOpeningInterpolator);

        FloatProp mIconAlpha = new FloatProp(prop.iconAlphaStart, 0f, APP_LAUNCH_ALPHA_START_DELAY, APP_LAUNCH_ALPHA_DURATION, LINEAR);

        FloatProp mWindowRadius = new FloatProp(initialWindowRadius, finalWindowRadius, 0, APP_LAUNCH_DURATION, mOpeningInterpolator);

        FloatProp mShadowRadius = new FloatProp(0, finalShadowRadius, 0, APP_LAUNCH_DURATION, mOpeningInterpolator);

        FloatProp mCropRectCenterX = new FloatProp(prop.cropCenterXStart, prop.cropCenterXEnd, 0, APP_LAUNCH_DURATION, mOpeningInterpolator);

        FloatProp mCropRectCenterY = new FloatProp(prop.cropCenterYStart, prop.cropCenterYEnd, 0, APP_LAUNCH_DURATION, mOpeningInterpolator);

        FloatProp mCropRectWidth = new FloatProp(prop.cropWidthStart, prop.cropWidthEnd, 0, APP_LAUNCH_DURATION, mOpeningInterpolator);

        FloatProp mCropRectHeight = new FloatProp(prop.cropHeightStart, prop.cropHeightEnd, 0, APP_LAUNCH_DURATION, mOpeningInterpolator);

        FloatProp mNavFadeOut = new FloatProp(1f, 0f, 0, ANIMATION_NAV_FADE_OUT_DURATION, NAV_FADE_OUT_INTERPOLATOR);

        FloatProp mNavFadeIn = new FloatProp(0f, 1f, ANIMATION_DELAY_NAV_FADE_IN, ANIMATION_NAV_FADE_IN_DURATION, NAV_FADE_IN_INTERPOLATOR);

        @Override
        public void onUpdate(float percent, boolean initOnly) {
            // Calculate the size of the scaled icon.
            float iconWidth = launcherIconBounds.width() * mIconScaleToFitScreen.value;
            float iconHeight = launcherIconBounds.height() * mIconScaleToFitScreen.value;
            int left = (int) (mCropRectCenterX.value - mCropRectWidth.value / 2);
            int top = (int) (mCropRectCenterY.value - mCropRectHeight.value / 2);
            int right = (int) (left + mCropRectWidth.value);
            int bottom = (int) (top + mCropRectHeight.value);
            crop.set(left, top, right, bottom);
            final int windowCropWidth = crop.width();
            final int windowCropHeight = crop.height();
            if (rotationChange != 0) {
                Utilities.rotateBounds(crop, mDeviceProfile.widthPx, mDeviceProfile.heightPx, rotationChange);
            }
            // Scale the size of the icon to match the size of the window crop.
            float scaleX = iconWidth / windowCropWidth;
            float scaleY = iconHeight / windowCropHeight;
            float scale = Math.min(1f, Math.max(scaleX, scaleY));
            float scaledCropWidth = windowCropWidth * scale;
            float scaledCropHeight = windowCropHeight * scale;
            float offsetX = (scaledCropWidth - iconWidth) / 2;
            float offsetY = (scaledCropHeight - iconHeight) / 2;
            // Calculate the window position to match the icon position.
            tmpRectF.set(launcherIconBounds);
            tmpRectF.offset(dragLayerBounds[0], dragLayerBounds[1]);
            tmpRectF.offset(mDx.value, mDy.value);
            Utilities.scaleRectFAboutCenter(tmpRectF, mIconScaleToFitScreen.value);
            float windowTransX0 = tmpRectF.left - offsetX - crop.left * scale;
            float windowTransY0 = tmpRectF.top - offsetY - crop.top * scale;
            // Calculate the icon position.
            floatingIconBounds.set(launcherIconBounds);
            floatingIconBounds.offset(mDx.value, mDy.value);
            Utilities.scaleRectFAboutCenter(floatingIconBounds, mIconScaleToFitScreen.value);
            floatingIconBounds.left -= offsetX;
            floatingIconBounds.top -= offsetY;
            floatingIconBounds.right += offsetX;
            floatingIconBounds.bottom += offsetY;
            if (initOnly) {
                // For the init pass, we want full alpha since the window is not yet ready.
                floatingView.update(1f, 255, floatingIconBounds, percent, 0f, mWindowRadius.value * scale, true);
                return;
            }
            ArrayList<SurfaceParams> params = new ArrayList<>();
            for (int i = appTargets.length - 1; i >= 0; i--) {
                RemoteAnimationTargetCompat target = appTargets[i];
                SurfaceParams.Builder builder = new SurfaceParams.Builder(target.leash);
                if (target.mode == MODE_OPENING) {
                    matrix.setScale(scale, scale);
                    if (rotationChange == 1) {
                        matrix.postTranslate(windowTransY0, mDeviceProfile.widthPx - (windowTransX0 + scaledCropWidth));
                    } else if (rotationChange == 2) {
                        matrix.postTranslate(mDeviceProfile.widthPx - (windowTransX0 + scaledCropWidth), mDeviceProfile.heightPx - (windowTransY0 + scaledCropHeight));
                    } else if (rotationChange == 3) {
                        matrix.postTranslate(mDeviceProfile.heightPx - (windowTransY0 + scaledCropHeight), windowTransX0);
                    } else {
                        matrix.postTranslate(windowTransX0, windowTransY0);
                    }
                    floatingView.update(mIconAlpha.value, 255, floatingIconBounds, percent, 0f, mWindowRadius.value * scale, true);
                    builder.withMatrix(matrix).withWindowCrop(crop).withAlpha(1f - mIconAlpha.value).withCornerRadius(mWindowRadius.value).withShadowRadius(mShadowRadius.value);
                } else if (target.mode == MODE_CLOSING) {
                    if (target.localBounds != null) {
                        final Rect localBounds = target.localBounds;
                        tmpPos.set(target.localBounds.left, target.localBounds.top);
                    } else {
                        tmpPos.set(target.position.x, target.position.y);
                    }
                    final Rect crop = new Rect(target.screenSpaceBounds);
                    crop.offsetTo(0, 0);
                    if ((rotationChange % 2) == 1) {
                        int tmp = crop.right;
                        crop.right = crop.bottom;
                        crop.bottom = tmp;
                        tmp = tmpPos.x;
                        tmpPos.x = tmpPos.y;
                        tmpPos.y = tmp;
                    }
                    matrix.setTranslate(tmpPos.x, tmpPos.y);
                    builder.withMatrix(matrix).withWindowCrop(crop).withAlpha(1f);
                }
                params.add(builder.build());
            }
            if (navBarTarget != null) {
                final SurfaceParams.Builder navBuilder = new SurfaceParams.Builder(navBarTarget.leash);
                if (mNavFadeIn.value > mNavFadeIn.getStartValue()) {
                    matrix.setScale(scale, scale);
                    matrix.postTranslate(windowTransX0, windowTransY0);
                    navBuilder.withMatrix(matrix).withWindowCrop(crop).withAlpha(mNavFadeIn.value);
                } else {
                    navBuilder.withAlpha(mNavFadeOut.value);
                }
                params.add(navBuilder.build());
            }
            surfaceApplier.scheduleApply(params.toArray(new SurfaceParams[params.size()]));
        }
    };
    appAnimator.addUpdateListener(listener);
    // Since we added a start delay, call update here to init the FloatingIconView properly.
    listener.onUpdate(0, true);
    animatorSet.playTogether(appAnimator, getBackgroundAnimator(appTargets));
    return animatorSet;
}
Also used : FloatingIconView(com.android.launcher3.views.FloatingIconView) ArrayList(java.util.ArrayList) RemoteAnimationTargets(com.android.quickstep.RemoteAnimationTargets) AnimatorSet(android.animation.AnimatorSet) ValueAnimator(android.animation.ValueAnimator) MultiValueUpdateListener(com.android.quickstep.util.MultiValueUpdateListener) Matrix(android.graphics.Matrix) SurfaceTransactionApplier(com.android.quickstep.util.SurfaceTransactionApplier) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) SurfaceParams(com.android.systemui.shared.system.SyncRtSurfaceTransactionApplierCompat.SurfaceParams) Rect(android.graphics.Rect) RemoteAnimationTargetCompat(com.android.systemui.shared.system.RemoteAnimationTargetCompat) Point(android.graphics.Point) Point(android.graphics.Point) RectF(android.graphics.RectF) ValueAnimator(android.animation.ValueAnimator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator)

Example 3 with LINEAR

use of com.android.launcher3.anim.Interpolators.LINEAR in project android_packages_apps_Launcher3 by crdroidandroid.

the class TaskViewUtils method composeRecentsSplitLaunchAnimatorLegacy.

/**
 * Legacy version (until shell transitions are enabled)
 */
public static void composeRecentsSplitLaunchAnimatorLegacy(@NonNull AnimatorSet anim, @NonNull TaskView v, @NonNull RemoteAnimationTargetCompat[] appTargets, @NonNull RemoteAnimationTargetCompat[] wallpaperTargets, @NonNull RemoteAnimationTargetCompat[] nonAppTargets, boolean launcherClosing, @NonNull StateManager stateManager, @NonNull DepthController depthController, int targetStage) {
    PendingAnimation out = new PendingAnimation(RECENTS_LAUNCH_DURATION);
    boolean isRunningTask = v.isRunningTask();
    TransformParams params = null;
    TaskViewSimulator tvs = null;
    RecentsView recentsView = v.getRecentsView();
    if (ENABLE_QUICKSTEP_LIVE_TILE.get() && isRunningTask) {
        params = recentsView.getLiveTileParams();
        tvs = recentsView.getLiveTileTaskViewSimulator();
    }
    boolean inLiveTileMode = ENABLE_QUICKSTEP_LIVE_TILE.get() && recentsView.getRunningTaskIndex() != -1;
    final RemoteAnimationTargets targets = new RemoteAnimationTargets(appTargets, wallpaperTargets, nonAppTargets, inLiveTileMode ? MODE_CLOSING : MODE_OPENING);
    if (params == null) {
        SurfaceTransactionApplier applier = new SurfaceTransactionApplier(v);
        targets.addReleaseCheck(applier);
        params = new TransformParams().setSyncTransactionApplier(applier).setTargetSet(targets);
    }
    Rect crop = new Rect();
    Context context = v.getContext();
    DeviceProfile dp = BaseActivity.fromContext(context).getDeviceProfile();
    if (tvs == null && targets.apps.length > 0) {
        tvs = new TaskViewSimulator(recentsView.getContext(), recentsView.getSizeStrategy());
        tvs.setDp(dp);
        // RecentsView never updates the display rotation until swipe-up so the value may
        // be stale. Use the display value instead.
        int displayRotation = DisplayController.INSTANCE.get(recentsView.getContext()).getInfo().rotation;
        tvs.getOrientationState().update(displayRotation, displayRotation);
        tvs.setPreview(targets.apps[targets.apps.length - 1]);
        tvs.fullScreenProgress.value = 0;
        tvs.recentsViewScale.value = 1;
        // tvs.setScroll(startScroll);
        // Fade in the task during the initial 20% of the animation
        out.addFloat(params, TransformParams.TARGET_ALPHA, 0, 1, clampToProgress(LINEAR, 0, 0.2f));
    }
    TaskViewSimulator topMostSimulator = null;
    if (tvs != null) {
        out.setFloat(tvs.fullScreenProgress, AnimatedFloat.VALUE, 1, TOUCH_RESPONSE_INTERPOLATOR);
        out.setFloat(tvs.recentsViewScale, AnimatedFloat.VALUE, tvs.getFullScreenScale(), TOUCH_RESPONSE_INTERPOLATOR);
        out.setFloat(tvs.recentsViewScroll, AnimatedFloat.VALUE, 0, TOUCH_RESPONSE_INTERPOLATOR);
        TaskViewSimulator finalTsv = tvs;
        TransformParams finalParams = params;
        out.addOnFrameCallback(() -> finalTsv.apply(finalParams));
        topMostSimulator = tvs;
    }
    anim.play(out.buildAnim());
}
Also used : Context(android.content.Context) PendingAnimation(com.android.launcher3.anim.PendingAnimation) DeviceProfile(com.android.launcher3.DeviceProfile) Rect(android.graphics.Rect) SurfaceTransactionApplier(com.android.quickstep.util.SurfaceTransactionApplier) TaskViewSimulator(com.android.quickstep.util.TaskViewSimulator) TransformParams(com.android.quickstep.util.TransformParams) RecentsView(com.android.quickstep.views.RecentsView)

Example 4 with LINEAR

use of com.android.launcher3.anim.Interpolators.LINEAR in project android_packages_apps_Launcher3 by crdroidandroid.

the class LauncherActivityInterface method prepareRecentsUI.

@Override
public AnimationFactory prepareRecentsUI(RecentsAnimationDeviceState deviceState, boolean activityVisible, Consumer<AnimatorControllerWithResistance> callback) {
    notifyRecentsOfOrientation(deviceState.getRotationTouchHelper());
    DefaultAnimationFactory factory = new DefaultAnimationFactory(callback) {

        @Override
        protected void createBackgroundToOverviewAnim(BaseQuickstepLauncher activity, PendingAnimation pa) {
            super.createBackgroundToOverviewAnim(activity, pa);
            // Animate the blur and wallpaper zoom
            float fromDepthRatio = BACKGROUND_APP.getDepth(activity);
            float toDepthRatio = OVERVIEW.getDepth(activity);
            pa.addFloat(getDepthController(), new ClampedDepthProperty(fromDepthRatio, toDepthRatio), fromDepthRatio, toDepthRatio, LINEAR);
        }
    };
    BaseQuickstepLauncher launcher = factory.initUI();
    // Since all apps is not visible, we can safely reset the scroll position.
    // This ensures then the next swipe up to all-apps starts from scroll 0.
    launcher.getAppsView().reset(false);
    return factory;
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) BaseQuickstepLauncher(com.android.launcher3.BaseQuickstepLauncher) ClampedDepthProperty(com.android.launcher3.statehandlers.DepthController.ClampedDepthProperty)

Example 5 with LINEAR

use of com.android.launcher3.anim.Interpolators.LINEAR in project android_packages_apps_Launcher3 by crdroidandroid.

the class RecentsView method createTaskDismissAnimation.

public PendingAnimation createTaskDismissAnimation(TaskView taskView, boolean animateTaskView, boolean shouldRemoveTask, long duration) {
    if (mPendingAnimation != null) {
        mPendingAnimation.createPlaybackController().dispatchOnCancel().dispatchOnEnd();
    }
    PendingAnimation anim = new PendingAnimation(duration);
    int count = getPageCount();
    if (count == 0) {
        return anim;
    }
    int[] oldScroll = new int[count];
    int[] newScroll = new int[count];
    getPageScrolls(oldScroll, false, SIMPLE_SCROLL_LOGIC);
    getPageScrolls(newScroll, false, (v) -> v.getVisibility() != GONE && v != taskView);
    int taskCount = getTaskViewCount();
    int scrollDiffPerPage = 0;
    if (count > 1) {
        scrollDiffPerPage = Math.abs(oldScroll[1] - oldScroll[0]);
    }
    int draggedIndex = indexOfChild(taskView);
    boolean isFocusedTaskDismissed = taskView.getTask().key.id == mFocusedTaskId;
    if (isFocusedTaskDismissed && showAsGrid()) {
        anim.setFloat(mActionsView, VIEW_ALPHA, 0, clampToProgress(ACCEL_0_5, 0, 0.5f));
    }
    float dismissedTaskWidth = taskView.getLayoutParams().width + mPageSpacing;
    boolean needsCurveUpdates = false;
    for (int i = 0; i < count; i++) {
        View child = getChildAt(i);
        if (child == taskView) {
            if (animateTaskView) {
                addDismissedTaskAnimations(taskView, duration, anim);
            }
        } else if (!showAsGrid()) {
            // Compute scroll offsets from task dismissal for animation.
            // If we just take newScroll - oldScroll, everything to the right of dragged task
            // translates to the left. We need to offset this in some cases:
            // - In RTL, add page offset to all pages, since we want pages to move to the right
            // Additionally, add a page offset if:
            // - Current page is rightmost page (leftmost for RTL)
            // - Dragging an adjacent page on the left side (right side for RTL)
            int offset = mIsRtl ? scrollDiffPerPage : 0;
            if (mCurrentPage == draggedIndex) {
                int lastPage = taskCount - 1;
                if (mCurrentPage == lastPage) {
                    offset += mIsRtl ? -scrollDiffPerPage : scrollDiffPerPage;
                }
            } else {
                // Dragging an adjacent page.
                // (Right in RTL, left in LTR)
                int negativeAdjacent = mCurrentPage - 1;
                if (draggedIndex == negativeAdjacent) {
                    offset += mIsRtl ? -scrollDiffPerPage : scrollDiffPerPage;
                }
            }
            int scrollDiff = newScroll[i] - oldScroll[i] + offset;
            if (scrollDiff != 0) {
                FloatProperty translationProperty = child instanceof TaskView ? ((TaskView) child).getPrimaryDismissTranslationProperty() : mOrientationHandler.getPrimaryViewTranslate();
                float additionalDismissDuration = ADDITIONAL_DISMISS_TRANSLATION_INTERPOLATION_OFFSET * Math.abs(i - draggedIndex);
                anim.setFloat(child, translationProperty, scrollDiff, clampToProgress(LINEAR, Utilities.boundToRange(INITIAL_DISMISS_TRANSLATION_INTERPOLATION_OFFSET + additionalDismissDuration, 0f, 1f), 1));
                if (ENABLE_QUICKSTEP_LIVE_TILE.get() && mEnableDrawingLiveTile && child instanceof TaskView && ((TaskView) child).isRunningTask()) {
                    anim.addOnFrameCallback(() -> {
                        mLiveTileTaskViewSimulator.taskPrimaryTranslation.value = mOrientationHandler.getPrimaryValue(child.getTranslationX(), child.getTranslationY());
                        redrawLiveTile();
                    });
                }
                needsCurveUpdates = true;
            }
        } else if (child instanceof TaskView) {
            // successive task dismissal durations for a staggered effect.
            if (isFocusedTaskDismissed || (i >= draggedIndex && isSameGridRow((TaskView) child, taskView))) {
                FloatProperty translationProperty = ((TaskView) child).getPrimaryDismissTranslationProperty();
                float additionalDismissDuration = ADDITIONAL_DISMISS_TRANSLATION_INTERPOLATION_OFFSET * Math.abs(i - draggedIndex);
                anim.setFloat(child, translationProperty, !mIsRtl ? -dismissedTaskWidth : dismissedTaskWidth, clampToProgress(LINEAR, Utilities.boundToRange(INITIAL_DISMISS_TRANSLATION_INTERPOLATION_OFFSET + additionalDismissDuration, 0f, 1f), 1));
            }
        }
    }
    if (needsCurveUpdates) {
        anim.addOnFrameCallback(this::updateCurveProperties);
    }
    // Add a tiny bit of translation Z, so that it draws on top of other views
    if (animateTaskView) {
        taskView.setTranslationZ(0.1f);
    }
    mPendingAnimation = anim;
    mPendingAnimation.addEndListener(new Consumer<Boolean>() {

        @Override
        public void accept(Boolean success) {
            if (ENABLE_QUICKSTEP_LIVE_TILE.get() && mEnableDrawingLiveTile && taskView.isRunningTask() && success) {
                finishRecentsAnimation(true, /* toRecents */
                false, /* shouldPip */
                () -> onEnd(success));
            } else {
                onEnd(success);
            }
        }

        @SuppressWarnings("WrongCall")
        private void onEnd(boolean success) {
            if (success) {
                if (shouldRemoveTask) {
                    if (taskView.getTask() != null) {
                        if (ENABLE_QUICKSTEP_LIVE_TILE.get() && taskView.isRunningTask()) {
                            finishRecentsAnimation(true, /* toRecents */
                            false, /* shouldPip */
                            () -> removeTaskInternal(taskView));
                        } else {
                            removeTaskInternal(taskView);
                        }
                        mActivity.getStatsLogManager().logger().withItemInfo(taskView.getItemInfo()).log(LAUNCHER_TASK_DISMISS_SWIPE_UP);
                    }
                }
                // Reset task translations as they may have updated via animations in
                // createTaskDismissAnimation
                resetTaskVisuals();
                int pageToSnapTo = mCurrentPage;
                // be at any page but the focused task always displays at the start.
                if (taskView.getTask().key.id == mFocusedTaskId) {
                    pageToSnapTo = mTaskViewStartIndex;
                } else if (draggedIndex < pageToSnapTo || pageToSnapTo == (getTaskViewCount() - 1)) {
                    pageToSnapTo -= 1;
                }
                removeViewInLayout(taskView);
                if (getTaskViewCount() == 0) {
                    startHome();
                } else {
                    snapToPageImmediately(pageToSnapTo);
                    dispatchScrollChanged();
                    // Grid got messed up, reapply.
                    updateGridProperties(true);
                    if (showAsGrid() && getFocusedTaskView() == null && mActionsView.getVisibilityAlpha().getValue() == 1) {
                        animateActionsViewOut();
                    }
                }
                // Update the layout synchronously so that the position of next view is
                // immediately available.
                onLayout(false, /*  changed */
                getLeft(), getTop(), getRight(), getBottom());
            }
            onDismissAnimationEnds();
            mPendingAnimation = null;
        }
    });
    return anim;
}
Also used : PendingAnimation(com.android.launcher3.anim.PendingAnimation) FloatProperty(android.util.FloatProperty) ImageView(android.widget.ImageView) View(android.view.View) ListView(android.widget.ListView) PagedView(com.android.launcher3.PagedView) TextPaint(android.text.TextPaint) Point(android.graphics.Point)

Aggregations

ValueAnimator (android.animation.ValueAnimator)6 Animator (android.animation.Animator)5 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)5 Rect (android.graphics.Rect)5 PendingAnimation (com.android.launcher3.anim.PendingAnimation)5 RecentsView (com.android.quickstep.views.RecentsView)5 ObjectAnimator (android.animation.ObjectAnimator)4 Point (android.graphics.Point)4 MultiValueUpdateListener (com.android.quickstep.util.MultiValueUpdateListener)4 AnimatorSet (android.animation.AnimatorSet)3 Context (android.content.Context)3 Matrix (android.graphics.Matrix)3 RectF (android.graphics.RectF)3 View (android.view.View)3 LauncherState (com.android.launcher3.LauncherState)3 AnimatorPlaybackController (com.android.launcher3.anim.AnimatorPlaybackController)3 SurfaceTransactionApplier (com.android.quickstep.util.SurfaceTransactionApplier)3 TextPaint (android.text.TextPaint)2 FloatProperty (android.util.FloatProperty)2 FloatingIconView (com.android.launcher3.views.FloatingIconView)2