diff --git a/src/com/android/launcher3/LauncherAnimUtils.java b/src/com/android/launcher3/LauncherAnimUtils.java index 9157dab143..b86ce4c38f 100644 --- a/src/com/android/launcher3/LauncherAnimUtils.java +++ b/src/com/android/launcher3/LauncherAnimUtils.java @@ -88,6 +88,7 @@ public class LauncherAnimUtils { public static final int SCALE_INDEX_WORKSPACE_STATE = 2; public static final int SCALE_INDEX_REVEAL_ANIM = 3; public static final int SCALE_INDEX_WIDGET_TRANSITION = 4; + public static final int SCALE_INDEX_FOLDER_ANIM = 5; /** Increase the duration if we prevented the fling, as we are going against a high velocity. */ public static int blockedFlingDurationFactor(float velocity) { diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java index 2b2c68fe9b..d07c5aa3b4 100644 --- a/src/com/android/launcher3/folder/Folder.java +++ b/src/com/android/launcher3/folder/Folder.java @@ -1139,7 +1139,8 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo mContent.setCurrentPage(0); if (Flags.enableExpressiveFolderExpansion()) { - FolderAnimationSpringBuilderManager.resetLauncherUi(mLauncherDelegate); + FolderAnimationSpringBuilderManager.resetLauncherScale(mLauncherDelegate); + FolderAnimationSpringBuilderManager.resetScrimAndZoom(mLauncherDelegate); } } diff --git a/src/com/android/launcher3/folder/FolderAnimationSpringBuilderManager.kt b/src/com/android/launcher3/folder/FolderAnimationSpringBuilderManager.kt index c4dc195593..0005ce4bdb 100644 --- a/src/com/android/launcher3/folder/FolderAnimationSpringBuilderManager.kt +++ b/src/com/android/launcher3/folder/FolderAnimationSpringBuilderManager.kt @@ -19,6 +19,9 @@ import android.animation.AnimatorSet import android.graphics.Color import android.view.View import com.android.launcher3.BubbleTextView +import com.android.launcher3.LauncherAnimUtils.HOTSEAT_SCALE_PROPERTY_FACTORY +import com.android.launcher3.LauncherAnimUtils.SCALE_INDEX_FOLDER_ANIM +import com.android.launcher3.LauncherAnimUtils.WORKSPACE_SCALE_PROPERTY_FACTORY import com.android.launcher3.Utilities import com.android.launcher3.apppairs.AppPairIcon import com.android.launcher3.folder.ClipRevealData.Factory.getClipRevealData @@ -44,7 +47,7 @@ class FolderAnimationSpringBuilderManager( override fun createAnimatorSet(isOpening: Boolean): AnimatorSet { // Since we scale down workspace/hotseat when opening folder, // need to have initial values to find starting folder icon location - resetLauncherUi(launcherDelegate) + resetLauncherScale(launcherDelegate) val folderAnimData: FolderAnimationData = folder.getAnimationData(isOpening) val clipRevealData: ClipRevealData = folder.getClipRevealData(shapeDelegate, folderAnimData) val iconAnimData: List = folder.getIconAnimationDataList(folderAnimData) @@ -59,21 +62,23 @@ class FolderAnimationSpringBuilderManager( } companion object { - /** Resets the scale of the launcher components and the scrim. */ + /** Resets the scale of the launcher workspace. Used to prepare for folder calculations. */ @JvmStatic - fun resetLauncherUi(launcherDelegate: LauncherDelegate) { + fun resetLauncherScale(launcherDelegate: LauncherDelegate) { val launcher = launcherDelegate.launcher ?: return val workspace = launcher.workspace val hotseat = launcher.hotseat - val scrim = launcher.scrimView - // Used to match the translation of the scaling between hotseat and workspace. workspace.setPivotToScaleWithSelf(hotseat) - workspace.scaleX = 1f - workspace.scaleY = 1f - hotseat.scaleX = 1f - hotseat.scaleY = 1f + WORKSPACE_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_FOLDER_ANIM).set(workspace, 1f) + HOTSEAT_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_FOLDER_ANIM).set(hotseat, 1f) + } + /** Resets the scrim and wallpaper zoom, which are changed by the folder animation. */ + @JvmStatic + fun resetScrimAndZoom(launcherDelegate: LauncherDelegate) { + val launcher = launcherDelegate.launcher ?: return + val scrim = launcher.scrimView launcherDelegate.launcher?.depthController?.folderZoom?.value = 0f scrim.alpha = 1f scrim.setBackgroundColor(Color.TRANSPARENT) diff --git a/src/com/android/launcher3/folder/FolderSpringAnimatorSet.kt b/src/com/android/launcher3/folder/FolderSpringAnimatorSet.kt index 955cb619bb..e000c0ad51 100644 --- a/src/com/android/launcher3/folder/FolderSpringAnimatorSet.kt +++ b/src/com/android/launcher3/folder/FolderSpringAnimatorSet.kt @@ -31,8 +31,12 @@ import androidx.dynamicanimation.animation.DynamicAnimation.MIN_VISIBLE_CHANGE_P import androidx.dynamicanimation.animation.DynamicAnimation.MIN_VISIBLE_CHANGE_SCALE import com.android.launcher3.BubbleTextView import com.android.launcher3.LauncherAnimUtils +import com.android.launcher3.LauncherAnimUtils.HOTSEAT_SCALE_PROPERTY_FACTORY +import com.android.launcher3.LauncherAnimUtils.SCALE_INDEX_FOLDER_ANIM import com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY +import com.android.launcher3.LauncherAnimUtils.WORKSPACE_SCALE_PROPERTY_FACTORY import com.android.launcher3.LauncherState +import com.android.launcher3.R import com.android.launcher3.Utilities.isDarkTheme import com.android.launcher3.anim.SpringAnimationBuilder import com.android.launcher3.apppairs.AppPairIcon @@ -75,19 +79,14 @@ class FolderSpringAnimatorSet(val animatorSet: AnimatorSet) { addFolderScaleAndTranslateAnimators(folder, animatorSet, folderAnimData) addClipRevealAnimators(folder, animatorSet, clipRevealData) addAlphaAndColorAnimators(folder, animatorSet, folderAnimData) - addScrimAnimators( + addWorkspaceAnimators( folder.context, animatorSet, folderAnimData.isOpening, launcherDelegate, ) launcherDelegate.launcher?.depthController?.folderZoom?.let { - addWallpaperZoomAnimator( - folder.context, - animatorSet, - folderAnimData.isOpening, - it, - ) + addWallpaperZoomAnimator(folder.context, animatorSet, folderAnimData.isOpening, it) } iconAnimData.forEach { addContentIconAnimators(folder.context, animatorSet, it) } return FolderSpringAnimatorSet(animatorSet) @@ -352,7 +351,7 @@ class FolderSpringAnimatorSet(val animatorSet: AnimatorSet) { } } - private fun addScrimAnimators( + private fun addWorkspaceAnimators( context: Context, animatorSet: AnimatorSet, isOpening: Boolean, @@ -367,6 +366,8 @@ class FolderSpringAnimatorSet(val animatorSet: AnimatorSet) { val scrimView = launcher.scrimView val workspace = launcher.workspace val hotseat = launcher.hotseat + val workspaceScale = WORKSPACE_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_FOLDER_ANIM) + val hotseatScale = HOTSEAT_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_FOLDER_ANIM) val finalScrimAlpha = if (isDarkTheme(context)) 0.32f else 0.2f scrimView.setBackgroundColor(Color.BLACK) playSpringAnimation( @@ -392,7 +393,7 @@ class FolderSpringAnimatorSet(val animatorSet: AnimatorSet) { startValue = 1f, endValue = LAUNCHER_SCALE, minVisibleChange = MIN_VISIBLE_CHANGE_SCALE, - property = SCALE_PROPERTY, + property = workspaceScale, view = workspace, ) playSpringAnimation( @@ -405,7 +406,7 @@ class FolderSpringAnimatorSet(val animatorSet: AnimatorSet) { startValue = 1f, endValue = LAUNCHER_SCALE, minVisibleChange = MIN_VISIBLE_CHANGE_SCALE, - property = SCALE_PROPERTY, + property = hotseatScale, view = hotseat, ) animatorSet.addListener(FolderScrimAnimationListener(scrimView, isOpening, launcher))