diff --git a/lawnchair/res/values/strings.xml b/lawnchair/res/values/strings.xml index 26804c3b809..3b4612a882a 100644 --- a/lawnchair/res/values/strings.xml +++ b/lawnchair/res/values/strings.xml @@ -210,6 +210,7 @@ Egg iOS Octagon + Hexagon One UI Rounded square Sharp square diff --git a/lawnchair/src/app/lawnchair/icons/shape/IconCornerShape.kt b/lawnchair/src/app/lawnchair/icons/shape/IconCornerShape.kt index 519685b549b..d1d572a83db 100644 --- a/lawnchair/src/app/lawnchair/icons/shape/IconCornerShape.kt +++ b/lawnchair/src/app/lawnchair/icons/shape/IconCornerShape.kt @@ -23,6 +23,7 @@ import android.graphics.Path import android.graphics.PointF import com.android.app.animation.Interpolators.LINEAR import com.android.launcher3.Utilities +import kotlin.math.sqrt sealed class IconCornerShape { @@ -97,6 +98,41 @@ sealed class IconCornerShape { override fun toString(): String = "cut" } + object CutHex : BaseBezierPath() { + + override fun addCorner( + path: Path, + position: Position, + size: PointF, + progress: Float, + offsetX: Float, + offsetY: Float, + ) { + if (progress == 0f) { + val paddingX = size.x - (size.x * sqrt(3.0) / 2).toFloat() + var newOffsetX = offsetX + + when (position) { + Position.BottomLeft -> newOffsetX += paddingX + Position.BottomRight -> path.rMoveTo(-paddingX, 0f) + Position.TopLeft -> path.setLastPoint(paddingX + offsetX, size.y + offsetY) + Position.TopRight -> newOffsetX -= paddingX + } + + path.lineTo( + position.endX * size.x + newOffsetX, + position.endY * size.y + offsetY, + ) + } else { + super.addCorner(path, position, size, progress, offsetX, offsetY) + } + } + + override fun toString(): String { + return "cuthex" + } + } + object LightSquircle : BaseBezierPath() { override val controlDistance: Float = .1f @@ -276,6 +312,7 @@ sealed class IconCornerShape { fun fromString(value: String): IconCornerShape { return when (value) { "cut" -> Cut + "cuthex" -> CutHex "lightsquircle" -> LightSquircle "cubic", "squircle" -> Squircle "strongsquircle" -> StrongSquircle diff --git a/lawnchair/src/app/lawnchair/icons/shape/IconShape.kt b/lawnchair/src/app/lawnchair/icons/shape/IconShape.kt index 3f625b3e07d..eab13da5233 100644 --- a/lawnchair/src/app/lawnchair/icons/shape/IconShape.kt +++ b/lawnchair/src/app/lawnchair/icons/shape/IconShape.kt @@ -412,6 +412,22 @@ open class IconShape( } } + object Hexagon : IconShape( + IconCornerShape.CutHex, + IconCornerShape.CutHex, + IconCornerShape.CutHex, + IconCornerShape.CutHex, + PointF(1f, .5f), + PointF(1f, .5f), + PointF(1f, .5f), + PointF(1f, .5f), + ) { + + override fun toString(): String { + return "hexagon" + } + } + object Diamond : IconShape( IconCornerShape.Cut, IconCornerShape.Cut, @@ -470,6 +486,7 @@ open class IconShape( "cylinder" -> Cylinder "cupertino" -> Cupertino "octagon" -> Octagon + "hexagon" -> Hexagon "diamond" -> Diamond "egg" -> Egg "" -> null diff --git a/lawnchair/src/app/lawnchair/ui/preferences/destinations/IconShapePreference.kt b/lawnchair/src/app/lawnchair/ui/preferences/destinations/IconShapePreference.kt index 5a56c43c079..fe4f772445e 100644 --- a/lawnchair/src/app/lawnchair/ui/preferences/destinations/IconShapePreference.kt +++ b/lawnchair/src/app/lawnchair/ui/preferences/destinations/IconShapePreference.kt @@ -76,6 +76,7 @@ fun iconShapeEntries(context: Context): List> { ListPreferenceEntry(IconShape.Cylinder) { stringResource(id = R.string.icon_shape_cylinder) }, ListPreferenceEntry(IconShape.Diamond) { stringResource(id = R.string.icon_shape_diamond) }, ListPreferenceEntry(IconShape.Egg) { stringResource(id = R.string.icon_shape_egg) }, + ListPreferenceEntry(IconShape.Hexagon) { stringResource(id = R.string.icon_shape_hexagon) }, ListPreferenceEntry(IconShape.Cupertino) { stringResource(id = R.string.icon_shape_cupertino) }, ListPreferenceEntry(IconShape.Octagon) { stringResource(id = R.string.icon_shape_octagon) }, ListPreferenceEntry(IconShape.Sammy) { stringResource(id = R.string.icon_shape_sammy) },