From c2f160f952fced9d0f1dfe41effdfeb0f67505d8 Mon Sep 17 00:00:00 2001 From: MM20 <15646950+MM2-0@users.noreply.github.com> Date: Sat, 6 Sep 2025 18:21:35 +0200 Subject: [PATCH] Remove emoji4j library --- app/ui/build.gradle.kts | 2 - .../ui/component/OutlinedTagsInputField.kt | 31 ++------ .../java/de/mm20/launcher2/ui/ktx/String.kt | 17 ----- .../ui/launcher/sheets/EditFavoritesSheet.kt | 16 +---- .../launcher2/licenses/OpenSourceLicenses.kt | 7 -- data/database/build.gradle.kts | 1 - .../de/mm20/launcher2/database/AppDatabase.kt | 2 - .../database/migrations/Migration_26_27.kt | 72 ------------------- gradle/libs.versions.toml | 2 - 9 files changed, 9 insertions(+), 141 deletions(-) delete mode 100644 app/ui/src/main/java/de/mm20/launcher2/ui/ktx/String.kt delete mode 100644 data/database/src/main/java/de/mm20/launcher2/database/migrations/Migration_26_27.kt diff --git a/app/ui/build.gradle.kts b/app/ui/build.gradle.kts index 244233f51..a8be7eda7 100644 --- a/app/ui/build.gradle.kts +++ b/app/ui/build.gradle.kts @@ -118,8 +118,6 @@ dependencies { implementation(libs.coil.core) implementation(libs.coil.compose) - implementation(libs.emoji4j) - implementation(project(":libs:material-color-utilities")) implementation(project(":core:base")) diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/component/OutlinedTagsInputField.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/component/OutlinedTagsInputField.kt index ed794bd72..7d4070a0b 100644 --- a/app/ui/src/main/java/de/mm20/launcher2/ui/component/OutlinedTagsInputField.kt +++ b/app/ui/src/main/java/de/mm20/launcher2/ui/component/OutlinedTagsInputField.kt @@ -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 diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/ktx/String.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/ktx/String.kt deleted file mode 100644 index 49e40ec33..000000000 --- a/app/ui/src/main/java/de/mm20/launcher2/ui/ktx/String.kt +++ /dev/null @@ -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 { - 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() -} \ No newline at end of file diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/sheets/EditFavoritesSheet.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/sheets/EditFavoritesSheet.kt index c59b28be2..ebb577a94 100644 --- a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/sheets/EditFavoritesSheet.kt +++ b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/sheets/EditFavoritesSheet.kt @@ -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 diff --git a/core/base/src/main/java/de/mm20/launcher2/licenses/OpenSourceLicenses.kt b/core/base/src/main/java/de/mm20/launcher2/licenses/OpenSourceLicenses.kt index 91eaa21cb..8f273a8d9 100644 --- a/core/base/src/main/java/de/mm20/launcher2/licenses/OpenSourceLicenses.kt +++ b/core/base/src/main/java/de/mm20/launcher2/licenses/OpenSourceLicenses.kt @@ -182,13 +182,6 @@ val OpenSourceLicenses = arrayOf( licenseText = R.raw.license_apache_2, 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( name = "AndroidAddressFormatter", description = "A package for formatting data in the OpenStreetMaps address field generated by the Nominatim API.", diff --git a/data/database/build.gradle.kts b/data/database/build.gradle.kts index ab19b7631..3dce9d3fd 100644 --- a/data/database/build.gradle.kts +++ b/data/database/build.gradle.kts @@ -54,7 +54,6 @@ dependencies { ksp(libs.androidx.roomcompiler) api(libs.androidx.room) implementation(libs.koin.android) - implementation(libs.emoji4j) implementation(project(":core:i18n")) implementation(project(":core:ktx")) diff --git a/data/database/src/main/java/de/mm20/launcher2/database/AppDatabase.kt b/data/database/src/main/java/de/mm20/launcher2/database/AppDatabase.kt index 9ba30e990..057fabb62 100644 --- a/data/database/src/main/java/de/mm20/launcher2/database/AppDatabase.kt +++ b/data/database/src/main/java/de/mm20/launcher2/database/AppDatabase.kt @@ -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_24_25 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_28_29 import de.mm20.launcher2.database.migrations.Migration_29_30 @@ -164,7 +163,6 @@ abstract class AppDatabase : RoomDatabase() { Migration_23_24(), Migration_24_25(), Migration_25_26(), - Migration_26_27(), Migration_27_28(), Migration_28_29(), Migration_29_30(), diff --git a/data/database/src/main/java/de/mm20/launcher2/database/migrations/Migration_26_27.kt b/data/database/src/main/java/de/mm20/launcher2/database/migrations/Migration_26_27.kt deleted file mode 100644 index 47adf8887..000000000 --- a/data/database/src/main/java/de/mm20/launcher2/database/migrations/Migration_26_27.kt +++ /dev/null @@ -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 { - 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() - } -} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 342967e78..9818a3825 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -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-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" } androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }