diff --git a/app/src/main/java/eu/faircode/email/Log.java b/app/src/main/java/eu/faircode/email/Log.java index f397442102..8693426150 100644 --- a/app/src/main/java/eu/faircode/email/Log.java +++ b/app/src/main/java/eu/faircode/email/Log.java @@ -35,7 +35,6 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.database.sqlite.SQLiteFullException; import android.graphics.Point; -import android.icu.text.Transliterator; import android.net.ConnectivityManager; import android.net.LinkProperties; import android.net.Network; @@ -100,7 +99,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Date; -import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -1694,14 +1692,9 @@ public class Log { .append(" yes=").append((uiMode & Configuration.UI_MODE_NIGHT_YES) != 0) .append("\r\n"); - if (BuildConfig.DEBUG && - Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { - sb.append("Transliterators:"); - Enumeration ids = Transliterator.getAvailableIDs(); - while (ids.hasMoreElements()) - sb.append(' ').append(ids.nextElement()); - sb.append("\r\n"); - } + sb.append("Transliterate") + .append(TextHelper.canTransliterate()) + .append("\r\n"); try { int maxKeySize = javax.crypto.Cipher.getMaxAllowedKeyLength("AES"); diff --git a/app/src/main/java/eu/faircode/email/TextHelper.java b/app/src/main/java/eu/faircode/email/TextHelper.java index 2220b054ca..20a53f9ec8 100644 --- a/app/src/main/java/eu/faircode/email/TextHelper.java +++ b/app/src/main/java/eu/faircode/email/TextHelper.java @@ -32,7 +32,6 @@ import android.view.textclassifier.TextClassifier; import androidx.preference.PreferenceManager; -import java.text.Normalizer; import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.ArrayList; @@ -47,6 +46,7 @@ import java.util.Set; public class TextHelper { private static final int MAX_SAMPLE_SIZE = 8192; private static final float MIN_PROBABILITY = 0.80f; + private static final String TRANSLITERATOR = "Any-Latin; Latin-ASCII"; static { System.loadLibrary("fairemail"); @@ -95,7 +95,7 @@ public class TextHelper { return false; try { - Transliterator.getInstance("Any-Latin"); + Transliterator.getInstance(TRANSLITERATOR); return true; } catch (Throwable ex) { return false; @@ -112,10 +112,8 @@ public class TextHelper { return text; try { - Transliterator t = Transliterator.getInstance("Any-Latin"); - text = t.transliterate(text); - String normalized = Normalizer.normalize(text, Normalizer.Form.NFD); - text = normalized.replaceAll("\\p{InCombiningDiacriticalMarks}+", ""); + // http://userguide.icu-project.org/transforms/general + return Transliterator.getInstance(TRANSLITERATOR).transliterate(text); } catch (Throwable ex) { Log.w(ex); }