mirror of https://github.com/M66B/FairEmail.git
Added notify ASCI only
This commit is contained in:
parent
4179c2dd6c
commit
a59fccb25d
|
@ -6360,11 +6360,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.transliterateNotification(context, message.subject));
|
sb.append(TextHelper.normalizeNotification(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.transliterateNotification(context, preview));
|
sb.append(TextHelper.normalizeNotification(context, preview));
|
||||||
}
|
}
|
||||||
if (sb.length() > 0)
|
if (sb.length() > 0)
|
||||||
mbuilder.setContentText(sb.toString());
|
mbuilder.setContentText(sb.toString());
|
||||||
|
@ -6395,7 +6395,7 @@ class Core {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!TextUtils.isEmpty(message.subject))
|
if (!TextUtils.isEmpty(message.subject))
|
||||||
mbuilder.setContentText(TextHelper.transliterateNotification(context, message.subject));
|
mbuilder.setContentText(TextHelper.normalizeNotification(context, message.subject));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info[0].hasPhoto())
|
if (info[0].hasPhoto())
|
||||||
|
|
|
@ -111,6 +111,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
|
||||||
private SwitchCompat swNotifyPreviewAll;
|
private SwitchCompat swNotifyPreviewAll;
|
||||||
private SwitchCompat swNotifyPreviewOnly;
|
private SwitchCompat swNotifyPreviewOnly;
|
||||||
private SwitchCompat swNotifyTransliterate;
|
private SwitchCompat swNotifyTransliterate;
|
||||||
|
private SwitchCompat swNotifyAscii;
|
||||||
private ImageButton ibLight;
|
private ImageButton ibLight;
|
||||||
private SwitchCompat swWearablePreview;
|
private SwitchCompat swWearablePreview;
|
||||||
private ImageButton ibWearable;
|
private ImageButton ibWearable;
|
||||||
|
@ -140,7 +141,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
|
||||||
"badge", "unseen_ignored",
|
"badge", "unseen_ignored",
|
||||||
"notify_grouping", "notify_private", "notify_background_only", "notify_known", "notify_suppress_in_call", "notify_suppress_in_car",
|
"notify_grouping", "notify_private", "notify_background_only", "notify_known", "notify_suppress_in_call", "notify_suppress_in_car",
|
||||||
"notify_remove", "notify_clear",
|
"notify_remove", "notify_clear",
|
||||||
"notify_subtext", "notify_preview", "notify_preview_all", "notify_preview_only", "notify_transliterate",
|
"notify_subtext", "notify_preview", "notify_preview_all", "notify_preview_only", "notify_transliterate", "notify_ascii",
|
||||||
"wearable_preview",
|
"wearable_preview",
|
||||||
"notify_messaging",
|
"notify_messaging",
|
||||||
"biometrics_notify", "notify_open_folder", "background_service", "alert_once"
|
"biometrics_notify", "notify_open_folder", "background_service", "alert_once"
|
||||||
|
@ -201,6 +202,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
|
||||||
swNotifyPreviewAll = view.findViewById(R.id.swNotifyPreviewAll);
|
swNotifyPreviewAll = view.findViewById(R.id.swNotifyPreviewAll);
|
||||||
swNotifyPreviewOnly = view.findViewById(R.id.swNotifyPreviewOnly);
|
swNotifyPreviewOnly = view.findViewById(R.id.swNotifyPreviewOnly);
|
||||||
swNotifyTransliterate = view.findViewById(R.id.swNotifyTransliterate);
|
swNotifyTransliterate = view.findViewById(R.id.swNotifyTransliterate);
|
||||||
|
swNotifyAscii = view.findViewById(R.id.swNotifyAscii);
|
||||||
ibLight = view.findViewById(R.id.ibLight);
|
ibLight = view.findViewById(R.id.ibLight);
|
||||||
swWearablePreview = view.findViewById(R.id.swWearablePreview);
|
swWearablePreview = view.findViewById(R.id.swWearablePreview);
|
||||||
ibWearable = view.findViewById(R.id.ibWearable);
|
ibWearable = view.findViewById(R.id.ibWearable);
|
||||||
|
@ -654,6 +656,13 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
swNotifyAscii.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||||
|
prefs.edit().putBoolean("notify_ascii", checked).apply();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
ibLight.setOnClickListener(new View.OnClickListener() {
|
ibLight.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -858,6 +867,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
|
||||||
swNotifyPreviewAll.setChecked(prefs.getBoolean("notify_preview_all", false));
|
swNotifyPreviewAll.setChecked(prefs.getBoolean("notify_preview_all", false));
|
||||||
swNotifyPreviewOnly.setChecked(prefs.getBoolean("notify_preview_only", false));
|
swNotifyPreviewOnly.setChecked(prefs.getBoolean("notify_preview_only", false));
|
||||||
swNotifyTransliterate.setChecked(prefs.getBoolean("notify_transliterate", false));
|
swNotifyTransliterate.setChecked(prefs.getBoolean("notify_transliterate", false));
|
||||||
|
swNotifyAscii.setChecked(prefs.getBoolean("notify_ascii", false));
|
||||||
swWearablePreview.setChecked(prefs.getBoolean("wearable_preview", false));
|
swWearablePreview.setChecked(prefs.getBoolean("wearable_preview", false));
|
||||||
swMessagingStyle.setChecked(prefs.getBoolean("notify_messaging", false));
|
swMessagingStyle.setChecked(prefs.getBoolean("notify_messaging", false));
|
||||||
swBiometricsNotify.setChecked(prefs.getBoolean("biometrics_notify", true));
|
swBiometricsNotify.setChecked(prefs.getBoolean("biometrics_notify", true));
|
||||||
|
|
|
@ -36,6 +36,7 @@ import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
import java.text.Normalizer;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -127,13 +128,20 @@ public class TextHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static String transliterateNotification(Context context, String text) {
|
static String normalizeNotification(Context context, String 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)
|
boolean notify_ascii = prefs.getBoolean("notify_ascii", false);
|
||||||
return text;
|
|
||||||
|
|
||||||
return transliterate(context, text);
|
if (notify_transliterate)
|
||||||
|
text = transliterate(context, text);
|
||||||
|
|
||||||
|
if (notify_ascii) {
|
||||||
|
text = Normalizer.normalize(text, Normalizer.Form.NFKD)
|
||||||
|
.replaceAll("[^\\p{ASCII}]", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
static String transliterate(Context context, String text) {
|
static String transliterate(Context context, String text) {
|
||||||
|
|
|
@ -754,6 +754,17 @@
|
||||||
app:layout_constraintTop_toBottomOf="@id/tvNotifyPreviewOnlyHint"
|
app:layout_constraintTop_toBottomOf="@id/tvNotifyPreviewOnlyHint"
|
||||||
app:switchPadding="12dp" />
|
app:switchPadding="12dp" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
|
android:id="@+id/swNotifyAscii"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:text="@string/title_advanced_notify_ascii"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/swNotifyTransliterate"
|
||||||
|
app:switchPadding="12dp" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/ibLight"
|
android:id="@+id/ibLight"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -762,7 +773,7 @@
|
||||||
android:contentDescription="@string/title_info"
|
android:contentDescription="@string/title_info"
|
||||||
android:tooltipText="@string/title_info"
|
android:tooltipText="@string/title_info"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/swNotifyTransliterate"
|
app:layout_constraintTop_toBottomOf="@id/swNotifyAscii"
|
||||||
app:srcCompat="@drawable/baseline_wb_incandescent_24" />
|
app:srcCompat="@drawable/baseline_wb_incandescent_24" />
|
||||||
|
|
||||||
<androidx.appcompat.widget.SwitchCompat
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
|
|
|
@ -717,7 +717,8 @@
|
||||||
<string name="title_advanced_notify_preview">Show message preview in notifications</string>
|
<string name="title_advanced_notify_preview">Show message preview in notifications</string>
|
||||||
<string name="title_advanced_notify_preview_all">Preview all text</string>
|
<string name="title_advanced_notify_preview_all">Preview all text</string>
|
||||||
<string name="title_advanced_notify_preview_only">Show notifications with a preview text only</string>
|
<string name="title_advanced_notify_preview_only">Show notifications with a preview text only</string>
|
||||||
<string name="title_advanced_notify_transliterate" translatable="false">Transliterate</string>
|
<string name="title_advanced_notify_transliterate">Transliterate text</string>
|
||||||
|
<string name="title_advanced_notify_ascii">ASCII text only</string>
|
||||||
<string name="title_advanced_notify_actions">Notification actions</string>
|
<string name="title_advanced_notify_actions">Notification actions</string>
|
||||||
<string name="title_advanced_notify_action_trash">Trash</string>
|
<string name="title_advanced_notify_action_trash">Trash</string>
|
||||||
<string name="title_advanced_notify_action_delete">Delete</string>
|
<string name="title_advanced_notify_action_delete">Delete</string>
|
||||||
|
|
Loading…
Reference in New Issue