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

@@ -118,8 +118,6 @@ dependencies {
implementation(libs.coil.core) implementation(libs.coil.core)
implementation(libs.coil.compose) implementation(libs.coil.compose)
implementation(libs.emoji4j)
implementation(project(":libs:material-color-utilities")) implementation(project(":libs:material-color-utilities"))
implementation(project(":core:base")) implementation(project(":core:base"))

View File

@@ -4,16 +4,13 @@ import androidx.compose.foundation.clickable
import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredHeight import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.BasicTextField import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardActions 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.material.icons.rounded.Tag
import androidx.compose.material3.DropdownMenu import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.FilterChipDefaults
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.InputChip import androidx.compose.material3.InputChip
import androidx.compose.material3.InputChipDefaults 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.input.key.onKeyEvent
import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.VisualTransformation import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.PopupProperties import androidx.compose.ui.window.PopupProperties
import de.mm20.launcher2.ui.ktx.splitLeadingEmoji
import kotlinx.collections.immutable.toImmutableList import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@@ -151,30 +145,19 @@ fun OutlinedTagsInputField(
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically
) { ) {
for ((i, tag) in tags.withIndex()) { for ((i, tag) in tags.withIndex()) {
val (emoji, tagName) = remember(tag) {
tag.splitLeadingEmoji()
}
InputChip( InputChip(
selected = i == tags.lastIndex && lastTagFocused, selected = i == tags.lastIndex && lastTagFocused,
modifier = Modifier.padding(end = 12.dp), modifier = Modifier.padding(end = 12.dp),
onClick = { }, onClick = { },
leadingIcon = { leadingIcon = {
if (emoji != null && tagName != null) { Icon(
Text( modifier = Modifier
emoji, .size(InputChipDefaults.IconSize),
modifier = Modifier.width(FilterChipDefaults.IconSize), imageVector = Icons.Rounded.Tag,
textAlign = TextAlign.Center, contentDescription = null
) )
} else if (tagName != null) {
Icon(
modifier = Modifier
.size(InputChipDefaults.IconSize),
imageVector = Icons.Rounded.Tag,
contentDescription = null
)
}
}, },
label = { Text(tagName ?: emoji ?: "") }, label = { Text(tag) },
trailingIcon = { trailingIcon = {
Icon( Icon(
modifier = Modifier 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.LazyVerticalDragAndDropGrid
import de.mm20.launcher2.ui.component.dragndrop.rememberLazyDragAndDropGridState import de.mm20.launcher2.ui.component.dragndrop.rememberLazyDragAndDropGridState
import de.mm20.launcher2.ui.component.dragndrop.rememberLazyDragAndDropListState 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.ktx.toPixels
import de.mm20.launcher2.ui.locals.LocalGridSettings import de.mm20.launcher2.ui.locals.LocalGridSettings
import kotlin.math.roundToInt import kotlin.math.roundToInt
@@ -480,22 +479,11 @@ fun ReorderFavoritesGrid(viewModel: EditFavoritesSheetVM, paddingValues: Padding
expanded = showAddMenu, expanded = showAddMenu,
onDismissRequest = { showAddMenu = false }) { onDismissRequest = { showAddMenu = false }) {
for (tag in availableTags) { for (tag in availableTags) {
val (emoji, tagName) = remember(tag.tag) {
tag.tag.splitLeadingEmoji()
}
DropdownMenuItem( DropdownMenuItem(
leadingIcon = { leadingIcon = {
if (emoji != null) { Icon(Icons.Rounded.Tag, null)
Text(
emoji,
modifier = Modifier.width(FilterChipDefaults.IconSize),
textAlign = TextAlign.Center,
)
} else {
Icon(Icons.Rounded.Tag, null)
}
}, },
text = { Text(tagName ?: "") }, text = { Text(tag.tag) },
onClick = { onClick = {
viewModel.pinTag(tag) viewModel.pinTag(tag)
showAddMenu = false showAddMenu = false

View File

@@ -182,13 +182,6 @@ val OpenSourceLicenses = arrayOf(
licenseText = R.raw.license_apache_2, licenseText = R.raw.license_apache_2,
url = "https://bigbadaboom.github.io/androidsvg/" url = "https://bigbadaboom.github.io/androidsvg/"
), ),
OpenSourceLibrary(
name = "emoji4j",
description = "Emoji4j is a high-performance, standards-compliant emoji processor supporting Unicode 15 for Java 8 or later.",
licenseName = R.string.apache_license_name,
licenseText = R.raw.license_apache_2,
url = "https://github.com/sigpwned/emoji4j"
),
OpenSourceLibrary( OpenSourceLibrary(
name = "AndroidAddressFormatter", name = "AndroidAddressFormatter",
description = "A package for formatting data in the OpenStreetMaps address field generated by the Nominatim API.", description = "A package for formatting data in the OpenStreetMaps address field generated by the Nominatim API.",

View File

@@ -54,7 +54,6 @@ dependencies {
ksp(libs.androidx.roomcompiler) ksp(libs.androidx.roomcompiler)
api(libs.androidx.room) api(libs.androidx.room)
implementation(libs.koin.android) implementation(libs.koin.android)
implementation(libs.emoji4j)
implementation(project(":core:i18n")) implementation(project(":core:i18n"))
implementation(project(":core:ktx")) implementation(project(":core:ktx"))

View File

@@ -39,7 +39,6 @@ import de.mm20.launcher2.database.migrations.Migration_22_23
import de.mm20.launcher2.database.migrations.Migration_23_24 import de.mm20.launcher2.database.migrations.Migration_23_24
import de.mm20.launcher2.database.migrations.Migration_24_25 import de.mm20.launcher2.database.migrations.Migration_24_25
import de.mm20.launcher2.database.migrations.Migration_25_26 import de.mm20.launcher2.database.migrations.Migration_25_26
import de.mm20.launcher2.database.migrations.Migration_26_27
import de.mm20.launcher2.database.migrations.Migration_27_28 import de.mm20.launcher2.database.migrations.Migration_27_28
import de.mm20.launcher2.database.migrations.Migration_28_29 import de.mm20.launcher2.database.migrations.Migration_28_29
import de.mm20.launcher2.database.migrations.Migration_29_30 import de.mm20.launcher2.database.migrations.Migration_29_30
@@ -164,7 +163,6 @@ abstract class AppDatabase : RoomDatabase() {
Migration_23_24(), Migration_23_24(),
Migration_24_25(), Migration_24_25(),
Migration_25_26(), Migration_25_26(),
Migration_26_27(),
Migration_27_28(), Migration_27_28(),
Migration_28_29(), Migration_28_29(),
Migration_29_30(), Migration_29_30(),

View File

@@ -1,72 +0,0 @@
package de.mm20.launcher2.database.migrations
import android.content.ContentValues
import android.database.sqlite.SQLiteDatabase
import android.util.Log
import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase
import com.sigpwned.emoji4j.core.Grapheme
import com.sigpwned.emoji4j.core.GraphemeMatcher
import de.mm20.launcher2.ktx.jsonObjectOf
class Migration_26_27 : Migration(26, 27) {
override fun migrate(db: SupportSQLiteDatabase) {
Log.d("Tags-Migration", "Migrating tags")
db.query("SELECT DISTINCT value FROM CustomAttributes WHERE type = 'tag'").use { cursor ->
while (cursor.moveToNext()) {
val oldName = cursor.getString(0)
val (emoji, newName) = oldName.splitLeadingEmoji()
if (emoji != null) {
db.update(
"CustomAttributes",
SQLiteDatabase.CONFLICT_FAIL,
ContentValues().apply {
put("value", newName)
}, "type = 'tag' AND value = ?",
arrayOf(oldName)
)
db.insert(
"CustomAttributes",
SQLiteDatabase.CONFLICT_REPLACE,
ContentValues().apply {
put("key", "tag://$newName")
put("type", "icon")
put("value", jsonObjectOf(
"type" to "custom_text_icon",
"text" to emoji,
"color" to 0,
).toString())
}
)
db.update(
"Searchable",
SQLiteDatabase.CONFLICT_IGNORE,
ContentValues().apply {
put("key", "tag://$newName")
put("searchable", jsonObjectOf(
"tag" to newName
).toString())
},
"key = ?",
arrayOf("tag://$oldName")
)
}
}
}
}
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).takeIf { it.isNotBlank() }
if (tagName == null) return emoji to emoji
return emoji to tagName
}
return null to this.trim()
}
}

View File

@@ -126,8 +126,6 @@ mathparser = { group = "org.mariuszgromada.math", name = "MathParser.org-mXparse
koin-android = { group = "io.insert-koin", name = "koin-android", version.ref = "koin" } koin-android = { group = "io.insert-koin", name = "koin-android", version.ref = "koin" }
koin-androidxcompose = { group = "io.insert-koin", name = "koin-androidx-compose", version.ref = "koin" } koin-androidxcompose = { group = "io.insert-koin", name = "koin-androidx-compose", version.ref = "koin" }
emoji4j = { group = "com.sigpwned", name = "emoji4j-core", version = "16.0.0" }
junit = { group = "junit", name = "junit", version.ref = "junit" } junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" } androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }