Adjust themed icon scale

Close #467
This commit is contained in:
MM20 2023-07-15 18:10:10 +02:00
parent dc376b9321
commit 484ae13025
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389
2 changed files with 15 additions and 2 deletions

View File

@ -259,7 +259,7 @@ class IconPackManager(
return StaticLauncherIcon(
foregroundLayer = TintedIconLayer(
icon = drawable.monochrome!!,
scale = 1f,
scale = 1.5f,
),
backgroundLayer = ColorLayer(),
)

View File

@ -3,7 +3,10 @@ package de.mm20.launcher2.icons
import android.content.res.Resources
import android.graphics.drawable.AdaptiveIconDrawable
import androidx.core.content.res.ResourcesCompat
import de.mm20.launcher2.icons.compat.AdaptiveIconDrawableCompat
import de.mm20.launcher2.icons.compat.toLauncherIcon
import de.mm20.launcher2.icons.transformations.LauncherIconTransformation
import de.mm20.launcher2.icons.transformations.transform
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.time.Instant
@ -18,6 +21,16 @@ internal class ThemedDynamicCalendarIcon(
val day = Instant.ofEpochMilli(time).atZone(ZoneId.systemDefault()).dayOfMonth
val resId = resourceIds[day - 1]
val adaptiveIconCompat = AdaptiveIconDrawableCompat.from(resources, resId)
if (adaptiveIconCompat != null) {
var icon = adaptiveIconCompat.toLauncherIcon(themed = true)
for (transformation in transformations) {
icon = transformation.transform(icon)
}
return@withContext icon
}
val drawable = try {
ResourcesCompat.getDrawable(resources, resId, null)
} catch (e: Resources.NotFoundException) {
@ -39,7 +52,7 @@ internal class ThemedDynamicCalendarIcon(
else -> StaticLauncherIcon(
foregroundLayer = TintedIconLayer(
icon = drawable,
scale = 0.5f,
scale = 0.65f,
),
backgroundLayer = ColorLayer()
)