Implement basic icon picker
This commit is contained in:
@@ -53,6 +53,6 @@ dependencies {
|
||||
implementation(project(":search"))
|
||||
implementation(project(":applications"))
|
||||
implementation(project(":crashreporter"))
|
||||
implementation(project(":customattrs"))
|
||||
api(project(":customattrs"))
|
||||
|
||||
}
|
||||
@@ -175,15 +175,24 @@ class IconRepository(
|
||||
|
||||
val defaultTransformedIcon = applyTransformations(rawIcon, defaultTransformations)
|
||||
|
||||
suggestions.add(CustomIconSuggestion(
|
||||
defaultTransformedIcon,
|
||||
null,
|
||||
))
|
||||
suggestions.add(
|
||||
CustomIconSuggestion(
|
||||
defaultTransformedIcon,
|
||||
null,
|
||||
)
|
||||
)
|
||||
|
||||
if (rawIcon is StaticLauncherIcon && rawIcon.backgroundLayer is TransparentLayer) {
|
||||
val adaptifyOptions = listOf(
|
||||
// Legacy icons that simply fill the entire canvas
|
||||
AdaptifiedLegacyIcon(
|
||||
fgScale = 1.25f,
|
||||
fgScale = 1f,
|
||||
bgColor = 1
|
||||
),
|
||||
// 48x48 with 5px padding used to be the default icon size for icons generated by
|
||||
// the Android Studio asset generator. Upscale these icons to remove that padding.
|
||||
AdaptifiedLegacyIcon(
|
||||
fgScale = 48f / 38f,
|
||||
bgColor = 1
|
||||
),
|
||||
AdaptifiedLegacyIcon(
|
||||
@@ -197,7 +206,8 @@ class IconRepository(
|
||||
)
|
||||
suggestions.addAll(
|
||||
adaptifyOptions.mapNotNull {
|
||||
val transformation = getTransformations(it)?.firstOrNull() ?: return@mapNotNull null
|
||||
val transformation =
|
||||
getTransformations(it)?.firstOrNull() ?: return@mapNotNull null
|
||||
CustomIconSuggestion(
|
||||
icon = transformation.transform(rawIcon),
|
||||
data = it,
|
||||
@@ -211,7 +221,10 @@ class IconRepository(
|
||||
|
||||
}
|
||||
|
||||
private suspend fun applyTransformations(icon: LauncherIcon, transformations: List<LauncherIconTransformation>): LauncherIcon {
|
||||
private suspend fun applyTransformations(
|
||||
icon: LauncherIcon,
|
||||
transformations: List<LauncherIconTransformation>
|
||||
): LauncherIcon {
|
||||
var icon = icon
|
||||
if (icon is StaticLauncherIcon) {
|
||||
for (transformation in transformations) {
|
||||
@@ -221,6 +234,10 @@ class IconRepository(
|
||||
return icon
|
||||
}
|
||||
|
||||
fun setCustomIcon(searchable: Searchable, icon: CustomIcon?) {
|
||||
customAttributesRepository.setCustomIcon(searchable, icon)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
data class CustomIconSuggestion(
|
||||
|
||||
Reference in New Issue
Block a user