Remove emoji4j library

This commit is contained in:
MM20
2025-09-06 18:21:35 +02:00
parent de86f5f312
commit c2f160f952
9 changed files with 9 additions and 141 deletions

View File

@@ -4,16 +4,13 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardActions
@@ -22,7 +19,6 @@ import androidx.compose.material.icons.rounded.Clear
import androidx.compose.material.icons.rounded.Tag
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.FilterChipDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.InputChip
import androidx.compose.material3.InputChipDefaults
@@ -48,10 +44,8 @@ import androidx.compose.ui.input.key.key
import androidx.compose.ui.input.key.onKeyEvent
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.PopupProperties
import de.mm20.launcher2.ui.ktx.splitLeadingEmoji
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.launch
@@ -151,30 +145,19 @@ fun OutlinedTagsInputField(
verticalAlignment = Alignment.CenterVertically
) {
for ((i, tag) in tags.withIndex()) {
val (emoji, tagName) = remember(tag) {
tag.splitLeadingEmoji()
}
InputChip(
selected = i == tags.lastIndex && lastTagFocused,
modifier = Modifier.padding(end = 12.dp),
onClick = { },
leadingIcon = {
if (emoji != null && tagName != null) {
Text(
emoji,
modifier = Modifier.width(FilterChipDefaults.IconSize),
textAlign = TextAlign.Center,
)
} else if (tagName != null) {
Icon(
modifier = Modifier
.size(InputChipDefaults.IconSize),
imageVector = Icons.Rounded.Tag,
contentDescription = null
)
}
Icon(
modifier = Modifier
.size(InputChipDefaults.IconSize),
imageVector = Icons.Rounded.Tag,
contentDescription = null
)
},
label = { Text(tagName ?: emoji ?: "") },
label = { Text(tag) },
trailingIcon = {
Icon(
modifier = Modifier

View File

@@ -1,17 +0,0 @@
package de.mm20.launcher2.ui.ktx
import com.sigpwned.emoji4j.core.Grapheme
import com.sigpwned.emoji4j.core.GraphemeMatcher
fun String.splitLeadingEmoji(): Pair<String?, String?> {
val matcher = GraphemeMatcher(this)
if (!matcher.find()) return null to this.trim()
val grapheme = matcher.grapheme()
if (grapheme?.type == Grapheme.Type.EMOJI && matcher.start() == 0) {
val end = matcher.end()
val emoji = this.substring(0, end)
val tagName = this.substring(end)
return emoji to tagName.takeIf { it.isNotBlank() }
}
return null to this.trim()
}

View File

@@ -87,7 +87,6 @@ import de.mm20.launcher2.ui.component.dragndrop.LazyDragAndDropRow
import de.mm20.launcher2.ui.component.dragndrop.LazyVerticalDragAndDropGrid
import de.mm20.launcher2.ui.component.dragndrop.rememberLazyDragAndDropGridState
import de.mm20.launcher2.ui.component.dragndrop.rememberLazyDragAndDropListState
import de.mm20.launcher2.ui.ktx.splitLeadingEmoji
import de.mm20.launcher2.ui.ktx.toPixels
import de.mm20.launcher2.ui.locals.LocalGridSettings
import kotlin.math.roundToInt
@@ -480,22 +479,11 @@ fun ReorderFavoritesGrid(viewModel: EditFavoritesSheetVM, paddingValues: Padding
expanded = showAddMenu,
onDismissRequest = { showAddMenu = false }) {
for (tag in availableTags) {
val (emoji, tagName) = remember(tag.tag) {
tag.tag.splitLeadingEmoji()
}
DropdownMenuItem(
leadingIcon = {
if (emoji != null) {
Text(
emoji,
modifier = Modifier.width(FilterChipDefaults.IconSize),
textAlign = TextAlign.Center,
)
} else {
Icon(Icons.Rounded.Tag, null)
}
Icon(Icons.Rounded.Tag, null)
},
text = { Text(tagName ?: "") },
text = { Text(tag.tag) },
onClick = {
viewModel.pinTag(tag)
showAddMenu = false