Refactoring

pull/213/head
M66B 1 year ago
parent db496e7254
commit 4cf027e4c1

@ -6280,11 +6280,11 @@ class Core {
// Wearables // Wearables
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (!TextUtils.isEmpty(message.subject)) if (!TextUtils.isEmpty(message.subject))
sb.append(TextHelper.transliterate(context, message.subject)); sb.append(TextHelper.transliterateNotification(context, message.subject));
if (wearable_preview && !TextUtils.isEmpty(preview)) { if (wearable_preview && !TextUtils.isEmpty(preview)) {
if (sb.length() > 0) if (sb.length() > 0)
sb.append(" - "); sb.append(" - ");
sb.append(TextHelper.transliterate(context, preview)); sb.append(TextHelper.transliterateNotification(context, preview));
} }
if (sb.length() > 0) if (sb.length() > 0)
mbuilder.setContentText(sb.toString()); mbuilder.setContentText(sb.toString());
@ -6315,7 +6315,7 @@ class Core {
} }
} else { } else {
if (!TextUtils.isEmpty(message.subject)) if (!TextUtils.isEmpty(message.subject))
mbuilder.setContentText(TextHelper.transliterate(context, message.subject)); mbuilder.setContentText(TextHelper.transliterateNotification(context, message.subject));
} }
if (info[0].hasPhoto()) if (info[0].hasPhoto())

@ -127,15 +127,19 @@ public class TextHelper {
} }
} }
static String transliterate(Context context, String text) { static String transliterateNotification(Context context, String text) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q)
return text;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean notify_transliterate = prefs.getBoolean("notify_transliterate", false); boolean notify_transliterate = prefs.getBoolean("notify_transliterate", false);
if (!notify_transliterate) if (!notify_transliterate)
return text; return text;
return transliterate(context, text);
}
static String transliterate(Context context, String text) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q)
return text;
try { try {
// http://userguide.icu-project.org/transforms/general // http://userguide.icu-project.org/transforms/general
return Transliterator.getInstance(TRANSLITERATOR).transliterate(text); return Transliterator.getInstance(TRANSLITERATOR).transliterate(text);

Loading…
Cancel
Save