Search in sources :

Example 1 with SCALE_PROPERTY

use of com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY 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 SCALE_PROPERTY

use of com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY in project android_packages_apps_Launcher3 by crdroidandroid.

the class HotseatPredictionController method pinPrediction.

/**
 * Pins a predicted app icon into place.
 */
public void pinPrediction(ItemInfo info) {
    PredictedAppIcon icon = (PredictedAppIcon) mHotseat.getChildAt(mHotseat.getCellXFromOrder(info.rank), mHotseat.getCellYFromOrder(info.rank));
    if (icon == null) {
        return;
    }
    WorkspaceItemInfo workspaceItemInfo = new WorkspaceItemInfo((WorkspaceItemInfo) info);
    mLauncher.getModelWriter().addItemToDatabase(workspaceItemInfo, LauncherSettings.Favorites.CONTAINER_HOTSEAT, workspaceItemInfo.screenId, workspaceItemInfo.cellX, workspaceItemInfo.cellY);
    ObjectAnimator.ofFloat(icon, SCALE_PROPERTY, 1, 0.8f, 1).start();
    icon.pin(workspaceItemInfo);
    mLauncher.getStatsLogManager().logger().withItemInfo(workspaceItemInfo).log(LAUNCHER_HOTSEAT_PREDICTION_PINNED);
}
Also used : PredictedAppIcon(com.android.launcher3.uioverrides.PredictedAppIcon) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 3 with SCALE_PROPERTY

use of com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY in project android_packages_apps_Launcher3 by crdroidandroid.

the class FolderAnimationManager method addPreviewItemAnimators.

/**
 * Animate the items on the current page.
 */
private void addPreviewItemAnimators(AnimatorSet animatorSet, final float folderScale, int previewItemOffsetX, int previewItemOffsetY) {
    ClippedFolderIconLayoutRule rule = mFolderIcon.getLayoutRule();
    boolean isOnFirstPage = mFolder.mContent.getCurrentPage() == 0;
    final List<BubbleTextView> itemsInPreview = getPreviewIconsOnPage(isOnFirstPage ? 0 : mFolder.mContent.getCurrentPage());
    final int numItemsInPreview = itemsInPreview.size();
    final int numItemsInFirstPagePreview = isOnFirstPage ? numItemsInPreview : MAX_NUM_ITEMS_IN_PREVIEW;
    TimeInterpolator previewItemInterpolator = getPreviewItemInterpolator();
    ShortcutAndWidgetContainer cwc = mContent.getPageAt(0).getShortcutsAndWidgets();
    for (int i = 0; i < numItemsInPreview; ++i) {
        final BubbleTextView btv = itemsInPreview.get(i);
        CellLayout.LayoutParams btvLp = (CellLayout.LayoutParams) btv.getLayoutParams();
        // Calculate the final values in the LayoutParams.
        btvLp.isLockedToGrid = true;
        cwc.setupLp(btv);
        // Match scale of icons in the preview of the items on the first page.
        float previewScale = rule.scaleForItem(numItemsInFirstPagePreview);
        float previewSize = rule.getIconSize() * previewScale;
        float iconScale = previewSize / itemsInPreview.get(i).getIconSize();
        final float initialScale = iconScale / folderScale;
        final float finalScale = 1f;
        float scale = mIsOpening ? initialScale : finalScale;
        btv.setScaleX(scale);
        btv.setScaleY(scale);
        // Match positions of the icons in the folder with their positions in the preview
        rule.computePreviewItemDrawingParams(i, numItemsInFirstPagePreview, mTmpParams);
        // The PreviewLayoutRule assumes that the icon size takes up the entire width so we
        // offset by the actual size.
        int iconOffsetX = (int) ((btvLp.width - btv.getIconSize()) * iconScale) / 2;
        final int previewPosX = (int) ((mTmpParams.transX - iconOffsetX + previewItemOffsetX) / folderScale);
        final float paddingTop = btv.getPaddingTop() * iconScale;
        final int previewPosY = (int) ((mTmpParams.transY + previewItemOffsetY - paddingTop) / folderScale);
        final float xDistance = previewPosX - btvLp.x;
        final float yDistance = previewPosY - btvLp.y;
        Animator translationX = getAnimator(btv, View.TRANSLATION_X, xDistance, 0f);
        translationX.setInterpolator(previewItemInterpolator);
        play(animatorSet, translationX);
        Animator translationY = getAnimator(btv, View.TRANSLATION_Y, yDistance, 0f);
        translationY.setInterpolator(previewItemInterpolator);
        play(animatorSet, translationY);
        Animator scaleAnimator = getAnimator(btv, SCALE_PROPERTY, initialScale, finalScale);
        scaleAnimator.setInterpolator(previewItemInterpolator);
        play(animatorSet, scaleAnimator);
        if (mFolder.getItemCount() > MAX_NUM_ITEMS_IN_PREVIEW) {
            // These delays allows the preview items to move as part of the Folder's motion,
            // and its only necessary for large folders because of differing interpolators.
            int delay = mIsOpening ? mDelay : mDelay * 2;
            if (mIsOpening) {
                translationX.setStartDelay(delay);
                translationY.setStartDelay(delay);
                scaleAnimator.setStartDelay(delay);
            }
            translationX.setDuration(translationX.getDuration() - delay);
            translationY.setDuration(translationY.getDuration() - delay);
            scaleAnimator.setDuration(scaleAnimator.getDuration() - delay);
        }
        animatorSet.addListener(new AnimatorListenerAdapter() {

            @Override
            public void onAnimationStart(Animator animation) {
                super.onAnimationStart(animation);
                // Necessary to initialize values here because of the start delay.
                if (mIsOpening) {
                    btv.setTranslationX(xDistance);
                    btv.setTranslationY(yDistance);
                    btv.setScaleX(initialScale);
                    btv.setScaleY(initialScale);
                }
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                btv.setTranslationX(0.0f);
                btv.setTranslationY(0.0f);
                btv.setScaleX(1f);
                btv.setScaleY(1f);
            }
        });
    }
}
Also used : ShortcutAndWidgetContainer(com.android.launcher3.ShortcutAndWidgetContainer) TimeInterpolator(android.animation.TimeInterpolator) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) CellLayout(com.android.launcher3.CellLayout) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) BubbleTextView(com.android.launcher3.BubbleTextView)

Example 4 with SCALE_PROPERTY

use of com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY in project android_packages_apps_Launcher3 by crdroidandroid.

the class FolderAnimationManager method getAnimator.

/**
 * Prepares the Folder for animating between open / closed states.
 */
public AnimatorSet getAnimator() {
    final BaseDragLayer.LayoutParams lp = (BaseDragLayer.LayoutParams) mFolder.getLayoutParams();
    mFolderIcon.getPreviewItemManager().recomputePreviewDrawingParams();
    ClippedFolderIconLayoutRule rule = mFolderIcon.getLayoutRule();
    final List<BubbleTextView> itemsInPreview = getPreviewIconsOnPage(0);
    // Match position of the FolderIcon
    final Rect folderIconPos = new Rect();
    float scaleRelativeToDragLayer = mFolder.mActivityContext.getDragLayer().getDescendantRectRelativeToSelf(mFolderIcon, folderIconPos);
    int scaledRadius = mPreviewBackground.getScaledRadius();
    float initialSize = (scaledRadius * 2) * scaleRelativeToDragLayer;
    // Match size/scale of icons in the preview
    float previewScale = rule.scaleForItem(itemsInPreview.size());
    float previewSize = rule.getIconSize() * previewScale;
    float initialScale = previewSize / itemsInPreview.get(0).getIconSize() * scaleRelativeToDragLayer;
    final float finalScale = 1f;
    float scale = mIsOpening ? initialScale : finalScale;
    mFolder.setPivotX(0);
    mFolder.setPivotY(0);
    // Scale the contents of the folder.
    mFolder.mContent.setScaleX(scale);
    mFolder.mContent.setScaleY(scale);
    mFolder.mContent.setPivotX(0);
    mFolder.mContent.setPivotY(0);
    mFolder.mFooter.setScaleX(scale);
    mFolder.mFooter.setScaleY(scale);
    mFolder.mFooter.setPivotX(0);
    mFolder.mFooter.setPivotY(0);
    // We want to create a small X offset for the preview items, so that they follow their
    // expected path to their final locations. ie. an icon should not move right, if it's final
    // location is to its left. This value is arbitrarily defined.
    int previewItemOffsetX = (int) (previewSize / 2);
    if (Utilities.isRtl(mContext.getResources())) {
        previewItemOffsetX = (int) (lp.width * initialScale - initialSize - previewItemOffsetX);
    }
    final int paddingOffsetX = (int) (mContent.getPaddingLeft() * initialScale);
    final int paddingOffsetY = (int) (mContent.getPaddingTop() * initialScale);
    int initialX = folderIconPos.left + mFolder.getPaddingLeft() + mPreviewBackground.getOffsetX() - paddingOffsetX - previewItemOffsetX;
    int initialY = folderIconPos.top + mFolder.getPaddingTop() + mPreviewBackground.getOffsetY() - paddingOffsetY;
    final float xDistance = initialX - lp.x;
    final float yDistance = initialY - lp.y;
    // Set up the Folder background.
    final int finalColor;
    int folderFillColor = Themes.getAttrColor(mContext, R.attr.folderFillColor);
    if (mIsOpening) {
        finalColor = folderFillColor;
    } else {
        finalColor = mFolderBackground.getColor().getDefaultColor();
    }
    final int initialColor = setColorAlphaBound(folderFillColor, mPreviewBackground.getBackgroundAlpha());
    mFolderBackground.mutate();
    mFolderBackground.setColor(mIsOpening ? initialColor : finalColor);
    // Set up the reveal animation that clips the Folder.
    int totalOffsetX = paddingOffsetX + previewItemOffsetX;
    Rect startRect = new Rect(totalOffsetX, paddingOffsetY, Math.round((totalOffsetX + initialSize)), Math.round((paddingOffsetY + initialSize)));
    Rect endRect = new Rect(0, 0, lp.width, lp.height);
    float finalRadius = mFolderBackground.getCornerRadius();
    // Create the animators.
    AnimatorSet a = new AnimatorSet();
    // Initialize the Folder items' text.
    PropertyResetListener colorResetListener = new PropertyResetListener<>(TEXT_ALPHA_PROPERTY, 1f);
    for (BubbleTextView icon : mFolder.getItemsOnPage(mFolder.mContent.getCurrentPage())) {
        if (mIsOpening) {
            icon.setTextVisibility(false);
        }
        ObjectAnimator anim = icon.createTextAlphaAnimator(mIsOpening);
        anim.addListener(colorResetListener);
        play(a, anim);
    }
    mBgColorAnimator = getAnimator(mFolderBackground, "color", initialColor, finalColor);
    play(a, mBgColorAnimator);
    play(a, getAnimator(mFolder, View.TRANSLATION_X, xDistance, 0f));
    play(a, getAnimator(mFolder, View.TRANSLATION_Y, yDistance, 0f));
    play(a, getAnimator(mFolder.mContent, SCALE_PROPERTY, initialScale, finalScale));
    play(a, getAnimator(mFolder.mFooter, SCALE_PROPERTY, initialScale, finalScale));
    final int footerAlphaDuration;
    final int footerStartDelay;
    if (isLargeFolder()) {
        if (mIsOpening) {
            footerAlphaDuration = LARGE_FOLDER_FOOTER_DURATION;
            footerStartDelay = mDuration - footerAlphaDuration;
        } else {
            footerAlphaDuration = 0;
            footerStartDelay = 0;
        }
    } else {
        footerStartDelay = 0;
        footerAlphaDuration = mDuration;
    }
    play(a, getAnimator(mFolder.mFooter, ALPHA, 0, 1f), footerStartDelay, footerAlphaDuration);
    // Create reveal animator for the folder background
    play(a, getShape().createRevealAnimator(mFolder, startRect, endRect, finalRadius, !mIsOpening));
    // Create reveal animator for the folder content (capture the top 4 icons 2x2)
    int width = mDeviceProfile.folderCellLayoutBorderSpacingPx + mDeviceProfile.folderCellWidthPx * 2;
    int height = mDeviceProfile.folderCellLayoutBorderSpacingPx + mDeviceProfile.folderCellHeightPx * 2;
    int page = mIsOpening ? mContent.getCurrentPage() : mContent.getDestinationPage();
    int left = mContent.getPaddingLeft() + page * lp.width;
    Rect contentStart = new Rect(left, 0, left + width, height);
    Rect contentEnd = new Rect(left, 0, left + lp.width, lp.height);
    play(a, getShape().createRevealAnimator(mFolder.getContent(), contentStart, contentEnd, finalRadius, !mIsOpening));
    // Fade in the folder name, as the text can overlap the icons when grid size is small.
    mFolder.mFolderName.setAlpha(mIsOpening ? 0f : 1f);
    play(a, getAnimator(mFolder.mFolderName, View.ALPHA, 0, 1), mIsOpening ? FOLDER_NAME_ALPHA_DURATION : 0, mIsOpening ? mDuration - FOLDER_NAME_ALPHA_DURATION : FOLDER_NAME_ALPHA_DURATION);
    // Translate the footer so that it tracks the bottom of the content.
    float normalHeight = mFolder.getContentAreaHeight();
    float scaledHeight = normalHeight * initialScale;
    float diff = normalHeight - scaledHeight;
    play(a, getAnimator(mFolder.mFooter, View.TRANSLATION_Y, -diff, 0f));
    // Animate the elevation midway so that the shadow is not noticeable in the background.
    int midDuration = mDuration / 2;
    Animator z = getAnimator(mFolder, View.TRANSLATION_Z, -mFolder.getElevation(), 0);
    play(a, z, mIsOpening ? midDuration : 0, midDuration);
    // Store clip variables
    CellLayout cellLayout = mContent.getCurrentCellLayout();
    boolean folderClipChildren = mFolder.getClipChildren();
    boolean folderClipToPadding = mFolder.getClipToPadding();
    boolean contentClipChildren = mContent.getClipChildren();
    boolean contentClipToPadding = mContent.getClipToPadding();
    boolean cellLayoutClipChildren = cellLayout.getClipChildren();
    boolean cellLayoutClipPadding = cellLayout.getClipToPadding();
    mFolder.setClipChildren(false);
    mFolder.setClipToPadding(false);
    mContent.setClipChildren(false);
    mContent.setClipToPadding(false);
    cellLayout.setClipChildren(false);
    cellLayout.setClipToPadding(false);
    a.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            mFolder.setTranslationX(0.0f);
            mFolder.setTranslationY(0.0f);
            mFolder.setTranslationZ(0.0f);
            mFolder.mContent.setScaleX(1f);
            mFolder.mContent.setScaleY(1f);
            mFolder.mFooter.setScaleX(1f);
            mFolder.mFooter.setScaleY(1f);
            mFolder.mFooter.setTranslationX(0f);
            mFolder.mFolderName.setAlpha(1f);
            mFolder.setClipChildren(folderClipChildren);
            mFolder.setClipToPadding(folderClipToPadding);
            mContent.setClipChildren(contentClipChildren);
            mContent.setClipToPadding(contentClipToPadding);
            cellLayout.setClipChildren(cellLayoutClipChildren);
            cellLayout.setClipToPadding(cellLayoutClipPadding);
        }
    });
    // animators may use a different interpolator.
    for (Animator animator : a.getChildAnimations()) {
        animator.setInterpolator(mFolderInterpolator);
    }
    int radiusDiff = scaledRadius - mPreviewBackground.getRadius();
    addPreviewItemAnimators(a, initialScale / scaleRelativeToDragLayer, // difference to keep the preview items centered.
    previewItemOffsetX + radiusDiff, radiusDiff);
    return a;
}
Also used : Rect(android.graphics.Rect) ObjectAnimator(android.animation.ObjectAnimator) PropertyResetListener(com.android.launcher3.anim.PropertyResetListener) AnimatorSet(android.animation.AnimatorSet) BaseDragLayer(com.android.launcher3.views.BaseDragLayer) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) CellLayout(com.android.launcher3.CellLayout) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) BubbleTextView(com.android.launcher3.BubbleTextView)

Example 5 with SCALE_PROPERTY

use of com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY in project android_packages_apps_Launcher3 by crdroidandroid.

the class WorkspaceStateTransitionAnimation method setWorkspaceProperty.

/**
 * Starts a transition animation for the workspace.
 */
private void setWorkspaceProperty(LauncherState state, PropertySetter propertySetter, StateAnimationConfig config) {
    ScaleAndTranslation scaleAndTranslation = state.getWorkspaceScaleAndTranslation(mLauncher);
    ScaleAndTranslation hotseatScaleAndTranslation = state.getHotseatScaleAndTranslation(mLauncher);
    mNewScale = scaleAndTranslation.scale;
    PageAlphaProvider pageAlphaProvider = state.getWorkspacePageAlphaProvider(mLauncher);
    final int childCount = mWorkspace.getChildCount();
    for (int i = 0; i < childCount; i++) {
        applyChildState(state, (CellLayout) mWorkspace.getChildAt(i), i, pageAlphaProvider, propertySetter, config);
    }
    int elements = state.getVisibleElements(mLauncher);
    Interpolator fadeInterpolator = config.getInterpolator(ANIM_WORKSPACE_FADE, pageAlphaProvider.interpolator);
    Hotseat hotseat = mWorkspace.getHotseat();
    Interpolator scaleInterpolator = config.getInterpolator(ANIM_WORKSPACE_SCALE, ZOOM_OUT);
    LauncherState fromState = mLauncher.getStateManager().getState();
    boolean shouldSpring = propertySetter instanceof PendingAnimation && fromState == HINT_STATE && state == NORMAL;
    if (shouldSpring) {
        ((PendingAnimation) propertySetter).add(getSpringScaleAnimator(mLauncher, mWorkspace, mNewScale));
    } else {
        propertySetter.setFloat(mWorkspace, SCALE_PROPERTY, mNewScale, scaleInterpolator);
    }
    mWorkspace.setPivotToScaleWithSelf(hotseat);
    float hotseatScale = hotseatScaleAndTranslation.scale;
    if (shouldSpring) {
        PendingAnimation pa = (PendingAnimation) propertySetter;
        pa.add(getSpringScaleAnimator(mLauncher, hotseat, hotseatScale));
    } else {
        Interpolator hotseatScaleInterpolator = config.getInterpolator(ANIM_HOTSEAT_SCALE, scaleInterpolator);
        propertySetter.setFloat(hotseat, SCALE_PROPERTY, hotseatScale, hotseatScaleInterpolator);
    }
    float hotseatIconsAlpha = (elements & HOTSEAT_ICONS) != 0 ? 1 : 0;
    propertySetter.setViewAlpha(hotseat, hotseatIconsAlpha, fadeInterpolator);
    float workspacePageIndicatorAlpha = (elements & WORKSPACE_PAGE_INDICATOR) != 0 ? 1 : 0;
    propertySetter.setViewAlpha(mLauncher.getWorkspace().getPageIndicator(), workspacePageIndicatorAlpha, fadeInterpolator);
    Interpolator translationInterpolator = config.getInterpolator(ANIM_WORKSPACE_TRANSLATE, ZOOM_OUT);
    propertySetter.setFloat(mWorkspace, VIEW_TRANSLATE_X, scaleAndTranslation.translationX, translationInterpolator);
    propertySetter.setFloat(mWorkspace, VIEW_TRANSLATE_Y, scaleAndTranslation.translationY, translationInterpolator);
    Interpolator hotseatTranslationInterpolator = config.getInterpolator(ANIM_HOTSEAT_TRANSLATE, translationInterpolator);
    propertySetter.setFloat(hotseat, VIEW_TRANSLATE_Y, hotseatScaleAndTranslation.translationY, hotseatTranslationInterpolator);
    propertySetter.setFloat(mWorkspace.getPageIndicator(), VIEW_TRANSLATE_Y, hotseatScaleAndTranslation.translationY, hotseatTranslationInterpolator);
    if (!config.hasAnimationFlag(SKIP_SCRIM)) {
        setScrim(propertySetter, state, config);
    }
}
Also used : ScaleAndTranslation(com.android.launcher3.LauncherState.ScaleAndTranslation) PendingAnimation(com.android.launcher3.anim.PendingAnimation) PageAlphaProvider(com.android.launcher3.LauncherState.PageAlphaProvider) Interpolator(android.view.animation.Interpolator)

Aggregations

Animator (android.animation.Animator)4 AnimatorSet (android.animation.AnimatorSet)4 ObjectAnimator (android.animation.ObjectAnimator)4 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)3 Rect (android.graphics.Rect)2 Interpolator (android.view.animation.Interpolator)2 BubbleTextView (com.android.launcher3.BubbleTextView)2 CellLayout (com.android.launcher3.CellLayout)2 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)2 PredictedAppIcon (com.android.launcher3.uioverrides.PredictedAppIcon)2 TimeInterpolator (android.animation.TimeInterpolator)1 ValueAnimator (android.animation.ValueAnimator)1 Context (android.content.Context)1 PackageManager (android.content.pm.PackageManager)1 Resources (android.content.res.Resources)1 Color (android.graphics.Color)1 Matrix (android.graphics.Matrix)1 Point (android.graphics.Point)1 RectF (android.graphics.RectF)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1