From 4e4fe07dc41d893afc19006c05224fd45d35a842 Mon Sep 17 00:00:00 2001 From: TommyDL-Infomaniak Date: Thu, 18 Jul 2024 15:57:17 +0200 Subject: [PATCH] String.removeAccents does not require SKD > 24 anymore --- src/main/java/com/infomaniak/lib/core/utils/Extensions.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/infomaniak/lib/core/utils/Extensions.kt b/src/main/java/com/infomaniak/lib/core/utils/Extensions.kt index b9e10b04..17b4a100 100644 --- a/src/main/java/com/infomaniak/lib/core/utils/Extensions.kt +++ b/src/main/java/com/infomaniak/lib/core/utils/Extensions.kt @@ -30,7 +30,6 @@ import android.content.res.Resources import android.content.res.TypedArray import android.graphics.Color import android.graphics.drawable.GradientDrawable -import android.icu.text.Normalizer2 import android.net.Uri import android.os.Build import android.os.Bundle @@ -78,6 +77,7 @@ import com.infomaniak.lib.core.utils.UtilsUi.generateInitialsAvatarDrawable import com.infomaniak.lib.core.utils.UtilsUi.getBackgroundColorBasedOnId import org.apache.commons.cli.MissingArgumentException import java.io.Serializable +import java.text.Normalizer import kotlin.properties.ReadWriteProperty import kotlin.reflect.KProperty @@ -478,10 +478,7 @@ fun String.camelToSnakeCase() = replace(CAMEL_CASE_REGEX) { "_${it.value}" }.low fun String.snakeToCamelCase() = replace(SNAKE_CASE_REGEX) { it.value.replace("_", "").uppercase() } -@RequiresApi(Build.VERSION_CODES.N) -fun String.removeAccents(): String { - return ACCENTS_PATTERN.matcher(Normalizer2.getNFDInstance().normalize(this)).replaceAll("") -} +fun String.removeAccents(): String = ACCENTS_PATTERN.matcher(Normalizer.normalize(this, Normalizer.Form.NFD)).replaceAll("") inline val ViewBinding.context: Context get() = root.context