diff --git a/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java b/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java index 6bd3d855e2..dd0ce27c91 100644 --- a/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/StashedHandleViewController.java @@ -17,6 +17,7 @@ package com.android.launcher3.taskbar; import static android.view.Display.DEFAULT_DISPLAY; +import static com.android.launcher3.taskbar.Utilities.getShapedTaskbarRadius; import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_NAV_BAR_HIDDEN; import android.animation.Animator; @@ -31,6 +32,7 @@ import android.view.View; import android.view.ViewOutlineProvider; import com.android.launcher3.DeviceProfile; +import com.android.launcher3.Flags; import com.android.launcher3.LauncherPrefs; import com.android.launcher3.R; import com.android.launcher3.anim.AnimatedFloat; @@ -147,7 +149,9 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT stashedCenterX + mStashedHandleWidth / 2, stashedCenterY + mStashedHandleHeight / 2); mStashedHandleView.updateSampledRegion(mStashedHandleBounds); - mStashedHandleRadius = view.getHeight() / 2f; + mStashedHandleRadius = Flags.enableLauncherIconShapes() + ? getShapedTaskbarRadius(mActivity) + : view.getHeight() / 2f; outline.setRoundRect(mStashedHandleBounds, mStashedHandleRadius); } }); @@ -167,6 +171,7 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT /** * Returns the stashed handle bounds. + * * @param out The destination rect. */ public void getStashedHandleBounds(Rect out) { @@ -221,8 +226,9 @@ public class StashedHandleViewController implements TaskbarControllers.LoggableT int heightDiff = (mTaskbarSize - visualBounds.height()) / 2; visualBounds.top -= heightDiff; visualBounds.bottom += heightDiff; - - startRadius = visualBounds.height() / 2f; + startRadius = Flags.enableLauncherIconShapes() + ? getShapedTaskbarRadius(mActivity) + : visualBounds.height() / 2f; } final RevealOutlineAnimation handleRevealProvider = new RoundedRectRevealOutlineProvider( diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt index 5e02d81035..70a303ca8e 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt @@ -23,6 +23,7 @@ import android.graphics.Paint import android.graphics.Path import android.graphics.RectF import com.android.app.animation.Interpolators +import com.android.launcher3.Flags import com.android.launcher3.R import com.android.launcher3.Utilities import com.android.launcher3.Utilities.mapRange @@ -30,6 +31,7 @@ import com.android.launcher3.Utilities.mapToRange import com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound import com.android.launcher3.taskbar.TaskbarPinningController.Companion.PINNING_PERSISTENT import com.android.launcher3.taskbar.TaskbarPinningController.Companion.PINNING_TRANSIENT +import com.android.launcher3.taskbar.Utilities.getShapedTaskbarRadius import kotlin.math.min /** Helps draw the taskbar background, made up of a rectangle plus two inverted rounded corners. */ @@ -193,10 +195,10 @@ class TaskbarBackgroundRenderer(private val context: TaskbarActivityContext) { scale = Math.round(scale * 100f) / 100f bottomMargin = mapRange( - scale, - 0f, - res.getDimensionPixelSize(R.dimen.transient_taskbar_bottom_margin).toFloat(), - ) + scale, + 0f, + res.getDimensionPixelSize(R.dimen.transient_taskbar_bottom_margin).toFloat(), + ) .toInt() shadowBlur = mapRange(scale, 0f, res.getDimension(R.dimen.transient_taskbar_shadow_blur)) @@ -222,7 +224,12 @@ class TaskbarBackgroundRenderer(private val context: TaskbarActivityContext) { val newWidth = mapRange(progress, backgroundWidthWhileAnimating, fullWidth.toFloat()) val halfWidthDelta = (fullWidth - newWidth) / 2f - val radius = newBackgroundHeight / 2f + val radius = + if (Flags.enableLauncherIconShapes()) { + getShapedTaskbarRadius(context) + } else { + newBackgroundHeight / 2f + } val bottomMarginProgress = bottomMargin * ((1f - progress) / 2f) // Aligns the bottom with the bottom of the stashed handle. diff --git a/quickstep/src/com/android/launcher3/taskbar/Utilities.java b/quickstep/src/com/android/launcher3/taskbar/Utilities.java index 47d6684727..123f0a3d00 100644 --- a/quickstep/src/com/android/launcher3/taskbar/Utilities.java +++ b/quickstep/src/com/android/launcher3/taskbar/Utilities.java @@ -16,12 +16,18 @@ package com.android.launcher3.taskbar; +import static com.android.launcher3.Utilities.dpToPx; + +import com.android.launcher3.graphics.ThemeManager; +import com.android.launcher3.taskbar.customization.TaskbarIconSpecs; + /** * Various utilities shared amongst the Taskbar's classes. */ public final class Utilities { - private Utilities() {} + private Utilities() { + } /** * Sets drag, long-click, and split selection behavior on 1P and 3P launchers with Taskbar @@ -36,4 +42,21 @@ public final class Utilities { controllers.taskbarPopupController.setAllowInitialSplitSelection( allowInitialSplitSelection); } + + /** + * Gives radius for Transient Taskbar based on selected Launcher Icon Shape. + * Transient Taskbar radius = (icon shape radius * icon size ratio) + padding. + * + * @return The radius for Transient Taskbar. + */ + static float getShapedTaskbarRadius(TaskbarActivityContext activityContext) { + float taskbarIconSize = + activityContext.getTaskbarSpecsEvaluator().getTaskbarIconSize().getSize(); + float maxIconSize = TaskbarIconSpecs.INSTANCE.getIconSize52dp().getSize(); + float iconShapeRadius = + ThemeManager.INSTANCE.get(activityContext).getIconState().getShapeRadius(); + float iconSizeRatio = taskbarIconSize / maxIconSize; + return dpToPx((iconShapeRadius * iconSizeRatio) + + TaskbarIconSpecs.INSTANCE.getDefaultTransientIconMargin().getSize()); + } } diff --git a/src/com/android/launcher3/graphics/ThemeManager.kt b/src/com/android/launcher3/graphics/ThemeManager.kt index 6a1bb77f76..3ea587db75 100644 --- a/src/com/android/launcher3/graphics/ThemeManager.kt +++ b/src/com/android/launcher3/graphics/ThemeManager.kt @@ -29,6 +29,7 @@ import com.android.launcher3.dagger.LauncherAppSingleton import com.android.launcher3.graphics.ShapeDelegate.Companion.pickBestShape import com.android.launcher3.icons.IconThemeController import com.android.launcher3.icons.mono.MonoIconThemeController +import com.android.launcher3.shapes.IconShapeModel.Companion.DEFAULT_ICON_RADIUS import com.android.launcher3.shapes.ShapesProvider import com.android.launcher3.util.DaggerSingletonObject import com.android.launcher3.util.DaggerSingletonTracker @@ -116,7 +117,7 @@ constructor( if (oldState != null && oldState.iconMask == iconMask) oldState.iconShape else pickBestShape(iconMask) - val folderRadius = shapeModel?.folderRadiusRatio ?: 26f + val folderRadius = shapeModel?.folderRadiusRatio ?: 1f val folderShape = if (oldState != null && oldState.folderRadius == folderRadius) { oldState.folderShape @@ -132,6 +133,7 @@ constructor( themeController = iconControllerFactory.createThemeController(), iconShape = iconShape, folderShape = folderShape, + shapeRadius = shapeModel?.shapeRadius ?: DEFAULT_ICON_RADIUS, ) } @@ -142,6 +144,7 @@ constructor( val themeCode: String = themeController?.themeID ?: "no-theme", val iconShape: ShapeDelegate, val folderShape: ShapeDelegate, + val shapeRadius: Float, ) { fun toUniqueId() = "${iconMask.hashCode()},$themeCode" } diff --git a/src/com/android/launcher3/shapes/IconShapeModel.kt b/src/com/android/launcher3/shapes/IconShapeModel.kt index 56e136ac3e..6d4ada462a 100644 --- a/src/com/android/launcher3/shapes/IconShapeModel.kt +++ b/src/com/android/launcher3/shapes/IconShapeModel.kt @@ -23,5 +23,10 @@ data class IconShapeModel( @StringRes val titleId: Int, val pathString: String, val folderRadiusRatio: Float = 1f, - val iconScale: Float = 1f, -) + val shapeRadius: Float = DEFAULT_ICON_RADIUS, +) { + companion object { + /** Default icon radius in dp to use for transient taskbar rounding. */ + const val DEFAULT_ICON_RADIUS = 26f + } +} diff --git a/src/com/android/launcher3/shapes/ShapesProvider.kt b/src/com/android/launcher3/shapes/ShapesProvider.kt index 253ea52b77..a9c282bfe8 100644 --- a/src/com/android/launcher3/shapes/ShapesProvider.kt +++ b/src/com/android/launcher3/shapes/ShapesProvider.kt @@ -48,11 +48,15 @@ object ShapesProvider { key = SQUARE_KEY, titleId = R.string.square_shape_title, pathString = SQUARE_PATH, + folderRadiusRatio = 1 / 3f, + shapeRadius = 17.33f, ), IconShapeModel( key = FOUR_SIDED_COOKIE_KEY, titleId = R.string.four_sided_cookie_shape_title, pathString = FOUR_SIDED_COOKIE_PATH, + folderRadiusRatio = 1 / 3f, + shapeRadius = 13.5f, ), IconShapeModel( key = SEVEN_SIDED_COOKIE_KEY, @@ -63,6 +67,8 @@ object ShapesProvider { key = ARCH_KEY, titleId = R.string.arch_shape_title, pathString = ARCH_PATH, + shapeRadius = 7.8f, + folderRadiusRatio = 1 / 4f, ), ) } else {