diff --git a/build.gradle b/build.gradle index 2bf8ed519..92033c42a 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { propMinSdkVersion = 16 propTargetSdkVersion = propCompileSdkVersion propVersionCode = 1 - propVersionName = '4.6.5' + propVersionName = '4.6.6' kotlin_version = '1.2.60' support_libs = '27.1.1' } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/String.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/String.kt index e395785bd..3ba86d252 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/String.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/extensions/String.kt @@ -10,6 +10,7 @@ import android.text.Spannable import android.text.SpannableString import android.text.style.ForegroundColorSpan import com.simplemobiletools.commons.helpers.* +import java.text.Normalizer import java.text.SimpleDateFormat import java.util.* @@ -234,14 +235,14 @@ fun String.highlightTextPart(textToHighlight: String, color: Int, highlightAll: return spannableString } - var startIndex = indexOf(textToHighlight, 0, true) + var startIndex = normalizeString().indexOf(textToHighlight, 0, true) val indexes = ArrayList() while (startIndex >= 0) { if (startIndex != -1) { indexes.add(startIndex) } - startIndex = indexOf(textToHighlight, startIndex + textToHighlight.length, true) + startIndex = normalizeString().indexOf(textToHighlight, startIndex + textToHighlight.length, true) if (!highlightAll) { break } @@ -255,6 +256,8 @@ fun String.highlightTextPart(textToHighlight: String, color: Int, highlightAll: return spannableString } +fun String.normalizeString() = Normalizer.normalize(this, Normalizer.Form.NFD).replace(normalizeRegex, "") + fun String.getMimeType(): String { val typesMap = HashMap().apply { put("323", "text/h323") diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/Constants.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/Constants.kt index f041e4605..6cf11e10f 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/Constants.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/helpers/Constants.kt @@ -236,3 +236,5 @@ fun getDateFormats() = arrayListOf( "MM/dd", "MM.dd" ) + +val normalizeRegex = "\\p{InCombiningDiacriticalMarks}+".toRegex()