Add force themed icon to icon suggestions
This commit is contained in:
parent
6b33d4fcd7
commit
56e8471373
@ -93,6 +93,7 @@ sealed class CustomIcon : CustomAttribute {
|
|||||||
bgColor = payload.getInt("bg_color")
|
bgColor = payload.getInt("bg_color")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
"force_themed_icon" -> ForceThemedIcon
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,6 +153,14 @@ data class CustomThemedIcon(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object ForceThemedIcon : CustomIcon() {
|
||||||
|
override fun toDatabaseValue(): String {
|
||||||
|
return jsonObjectOf(
|
||||||
|
"type" to "force_themed_icon"
|
||||||
|
).toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use default icon, ignore any icon pack, themed icon or force adaptive settings.
|
* Use default icon, ignore any icon pack, themed icon or force adaptive settings.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -163,6 +163,11 @@ class IconRepository(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if (customIcon is ForceThemedIcon) {
|
||||||
|
return listOf(
|
||||||
|
ForceThemedIconTransformation()
|
||||||
|
)
|
||||||
|
}
|
||||||
if (customIcon is UnmodifiedSystemDefaultIcon) {
|
if (customIcon is UnmodifiedSystemDefaultIcon) {
|
||||||
return emptyList()
|
return emptyList()
|
||||||
}
|
}
|
||||||
@ -190,11 +195,11 @@ class IconRepository(
|
|||||||
|
|
||||||
val defaultTransformations = transformations.first()
|
val defaultTransformations = transformations.first()
|
||||||
|
|
||||||
val customIcons = mutableListOf<CustomIcon>(UnmodifiedSystemDefaultIcon)
|
val transformationOptions = mutableListOf<CustomIcon>(UnmodifiedSystemDefaultIcon)
|
||||||
|
|
||||||
if (rawIcon is StaticLauncherIcon && rawIcon.backgroundLayer is TransparentLayer) {
|
if (rawIcon is StaticLauncherIcon && rawIcon.backgroundLayer is TransparentLayer) {
|
||||||
// Legacy icons that simply fill the entire canvas
|
// Legacy icons that simply fill the entire canvas
|
||||||
customIcons.add(
|
transformationOptions.add(
|
||||||
AdaptifiedLegacyIcon(
|
AdaptifiedLegacyIcon(
|
||||||
fgScale = 1f,
|
fgScale = 1f,
|
||||||
bgColor = 1
|
bgColor = 1
|
||||||
@ -203,39 +208,25 @@ class IconRepository(
|
|||||||
// 48x48 with 5px padding used to be the default icon size for icons generated by
|
// 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.
|
// the Android Studio asset generator. Upscale these icons to remove that padding.
|
||||||
|
|
||||||
customIcons.add(
|
transformationOptions.add(
|
||||||
AdaptifiedLegacyIcon(
|
AdaptifiedLegacyIcon(
|
||||||
fgScale = 48f / 38f,
|
fgScale = 48f / 38f,
|
||||||
bgColor = 1
|
bgColor = 1
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
customIcons.add(
|
transformationOptions.add(
|
||||||
AdaptifiedLegacyIcon(
|
AdaptifiedLegacyIcon(
|
||||||
fgScale = 0.7f,
|
fgScale = 0.7f,
|
||||||
bgColor = 0
|
bgColor = 0
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
customIcons.add(
|
transformationOptions.add(
|
||||||
AdaptifiedLegacyIcon(
|
AdaptifiedLegacyIcon(
|
||||||
fgScale = 0.7f,
|
fgScale = 0.7f,
|
||||||
bgColor = Color.WHITE,
|
bgColor = Color.WHITE,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
suggestions.addAll(
|
|
||||||
customIcons.map {
|
|
||||||
val transformations = getTransformations(it) ?: defaultTransformations
|
|
||||||
val providers = getProviders(it)
|
|
||||||
|
|
||||||
val icon = providers.getFirstIcon(searchable, size) ?: rawIcon
|
|
||||||
|
|
||||||
CustomIconWithPreview(
|
|
||||||
preview = icon.transform(transformations),
|
|
||||||
customIcon = it,
|
|
||||||
)
|
|
||||||
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
val providerOptions = mutableListOf<CustomIcon>()
|
val providerOptions = mutableListOf<CustomIcon>()
|
||||||
|
|
||||||
@ -261,9 +252,28 @@ class IconRepository(
|
|||||||
iconPackageName = themedIcon.componentName.packageName,
|
iconPackageName = themedIcon.componentName.packageName,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
transformationOptions.add(
|
||||||
|
ForceThemedIcon
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suggestions.addAll(
|
||||||
|
transformationOptions.map {
|
||||||
|
val transformations = getTransformations(it) ?: defaultTransformations
|
||||||
|
val providers = getProviders(it)
|
||||||
|
|
||||||
|
val icon = providers.getFirstIcon(searchable, size) ?: rawIcon
|
||||||
|
|
||||||
|
CustomIconWithPreview(
|
||||||
|
preview = icon.transform(transformations),
|
||||||
|
customIcon = it,
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
suggestions.addAll(
|
suggestions.addAll(
|
||||||
providerOptions.mapNotNull {
|
providerOptions.mapNotNull {
|
||||||
val providers = getProviders(it)
|
val providers = getProviders(it)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user