Improve tag emoji assignment
This commit is contained in:
@@ -11,6 +11,7 @@ import de.mm20.launcher2.data.customattrs.AdaptifiedLegacyIcon
|
||||
import de.mm20.launcher2.data.customattrs.CustomAttributesRepository
|
||||
import de.mm20.launcher2.data.customattrs.CustomIcon
|
||||
import de.mm20.launcher2.data.customattrs.CustomIconPackIcon
|
||||
import de.mm20.launcher2.data.customattrs.CustomTextIcon
|
||||
import de.mm20.launcher2.data.customattrs.LegacyCustomIconPackIcon
|
||||
import de.mm20.launcher2.data.customattrs.CustomThemedIcon
|
||||
import de.mm20.launcher2.data.customattrs.DefaultPlaceholderIcon
|
||||
@@ -19,6 +20,7 @@ import de.mm20.launcher2.data.customattrs.UnmodifiedSystemDefaultIcon
|
||||
import de.mm20.launcher2.icons.providers.CalendarIconProvider
|
||||
import de.mm20.launcher2.icons.providers.CompatIconProvider
|
||||
import de.mm20.launcher2.icons.providers.CustomIconPackIconProvider
|
||||
import de.mm20.launcher2.icons.providers.CustomTextIconProvider
|
||||
import de.mm20.launcher2.icons.providers.LegacyCustomIconPackIconProvider
|
||||
import de.mm20.launcher2.icons.providers.CustomThemedIconProvider
|
||||
import de.mm20.launcher2.icons.providers.DynamicClockIconProvider
|
||||
@@ -203,6 +205,9 @@ class IconService(
|
||||
if (customIcon is DefaultPlaceholderIcon) {
|
||||
return iconProviders.value.lastOrNull()?.let { listOf(it) } ?: emptyList()
|
||||
}
|
||||
if (customIcon is CustomTextIcon) {
|
||||
return listOf(CustomTextIconProvider(customIcon))
|
||||
}
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package de.mm20.launcher2.icons.providers
|
||||
|
||||
import de.mm20.launcher2.data.customattrs.CustomIconPackIcon
|
||||
import de.mm20.launcher2.data.customattrs.CustomTextIcon
|
||||
import de.mm20.launcher2.icons.ColorLayer
|
||||
import de.mm20.launcher2.icons.LauncherIcon
|
||||
import de.mm20.launcher2.icons.StaticLauncherIcon
|
||||
import de.mm20.launcher2.icons.TextLayer
|
||||
import de.mm20.launcher2.search.SavableSearchable
|
||||
|
||||
class CustomTextIconProvider(
|
||||
private val customIcon: CustomTextIcon,
|
||||
): IconProvider {
|
||||
override suspend fun getIcon(
|
||||
searchable: SavableSearchable,
|
||||
size: Int
|
||||
): LauncherIcon? {
|
||||
return StaticLauncherIcon(
|
||||
foregroundLayer = TextLayer(
|
||||
text = customIcon.text,
|
||||
color = customIcon.color,
|
||||
),
|
||||
backgroundLayer = ColorLayer(
|
||||
color = customIcon.color,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -45,14 +45,7 @@ internal class TagsServiceImpl(
|
||||
}
|
||||
if (newName != null && newName != tag) {
|
||||
customAttributesRepository.renameTag(tag, newName).join()
|
||||
val pinnedTags = searchableRepository.get(
|
||||
includeTypes = listOf(Tag.Domain),
|
||||
minPinnedLevel = PinnedLevel.AutomaticallySorted,
|
||||
).first()
|
||||
val oldTag = Tag(tag)
|
||||
if (pinnedTags.any { it.key == oldTag.key }) {
|
||||
searchableRepository.replace(oldTag.key, Tag(newName))
|
||||
}
|
||||
searchableRepository.replace(Tag(tag).key, Tag(newName))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user