Skip to content

Commit

Permalink
Merge pull request #209 from Infomaniak/imp/remove-accents-function
Browse files Browse the repository at this point in the history
String.removeAccents does not require SKD > 24 anymore
  • Loading branch information
FabianDevel authored Jul 22, 2024
2 parents 45da376 + 4e4fe07 commit 5125ac7
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/main/java/com/infomaniak/lib/core/utils/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 5125ac7

Please sign in to comment.