From 0531628302bc32b36ea74941a097c7500dff6066 Mon Sep 17 00:00:00 2001 From: MM20 <15646950+MM2-0@users.noreply.github.com> Date: Wed, 7 Sep 2022 19:19:26 +0200 Subject: [PATCH] Add teardrop icon shape --- i18n/src/main/res/values/strings.xml | 1 + preferences/src/main/proto/settings.proto | 1 + .../ui/component/ShapedLauncherIcon.kt | 31 +++++++++++++++++++ .../appearance/AppearanceSettingsScreen.kt | 1 + 4 files changed, 34 insertions(+) diff --git a/i18n/src/main/res/values/strings.xml b/i18n/src/main/res/values/strings.xml index e9ee179c..b5e0422d 100644 --- a/i18n/src/main/res/values/strings.xml +++ b/i18n/src/main/res/values/strings.xml @@ -450,6 +450,7 @@ Squircle Reuleaux triangle Circle + Teardrop Hexagon Search bar Services diff --git a/preferences/src/main/proto/settings.proto b/preferences/src/main/proto/settings.proto index a6aa5389..a2957d4d 100644 --- a/preferences/src/main/proto/settings.proto +++ b/preferences/src/main/proto/settings.proto @@ -219,6 +219,7 @@ message Settings { Hexagon = 6; Pentagon = 7; EasterEgg = 8; + Teardrop = 9; } IconShape shape = 1; bool themed_icons = 2; diff --git a/ui/src/main/java/de/mm20/launcher2/ui/component/ShapedLauncherIcon.kt b/ui/src/main/java/de/mm20/launcher2/ui/component/ShapedLauncherIcon.kt index b30be838..e169376f 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/component/ShapedLauncherIcon.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/component/ShapedLauncherIcon.kt @@ -368,6 +368,7 @@ fun getShape(iconShape: IconShape): Shape { IconShape.Squircle -> SquircleShape IconShape.Hexagon -> HexagonShape IconShape.Pentagon -> PentagonShape + IconShape.Teardrop -> TeardropShape IconShape.EasterEgg -> EasterEggShape IconShape.UNRECOGNIZED -> CircleShape } @@ -466,6 +467,36 @@ private val PentagonShape: Shape close() } +private val TeardropShape: Shape +get() = GenericShape { size, _ -> + moveTo(0.5f * size.width, 0f) + cubicTo( + 0.776f * size.width, 0f, + size.width, 0.224f * size.height, + size.width, 0.5f * size.height, + ) + lineTo( + size.width, 0.88f * size.height, + ) + cubicTo( + size.width, 0.946f * size.height, + 0.946f * size.width, size.height, + 0.88f * size.width, size.height, + ) + lineTo(0.5f * size.width, size.height) + cubicTo( + 0.224f * size.width, size.height, + 0f, 0.776f * size.height, + 0f, 0.5f * size.height, + ) + cubicTo( + 0f, 0.224f * size.height, + 0.224f * size.width, 0f, + 0.5f * size.width, 0f, + ) + close() +} + private val EasterEggShape: Shape get() = GenericShape { size, _ -> moveTo( diff --git a/ui/src/main/java/de/mm20/launcher2/ui/settings/appearance/AppearanceSettingsScreen.kt b/ui/src/main/java/de/mm20/launcher2/ui/settings/appearance/AppearanceSettingsScreen.kt index 2488282b..7ff49a8e 100644 --- a/ui/src/main/java/de/mm20/launcher2/ui/settings/appearance/AppearanceSettingsScreen.kt +++ b/ui/src/main/java/de/mm20/launcher2/ui/settings/appearance/AppearanceSettingsScreen.kt @@ -592,6 +592,7 @@ private fun getShapeName(shape: IconSettings.IconShape?): String? { IconSettings.IconShape.Pentagon -> R.string.preference_icon_shape_pentagon IconSettings.IconShape.PlatformDefault -> R.string.preference_icon_shape_platform IconSettings.IconShape.Circle -> R.string.preference_icon_shape_circle + IconSettings.IconShape.Teardrop -> R.string.preference_icon_shape_teardrop else -> return null } )