Added option to disable subject in notifications

pull/217/head
M66B 6 months ago
parent 4d2fb605b0
commit 1a5f8ee3ac

@ -115,6 +115,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
private SwitchCompat swNotifyRemove;
private SwitchCompat swNotifyClear;
private SwitchCompat swNotifySubtext;
private SwitchCompat swNotifySubject;
private SwitchCompat swNotifyPreview;
private SwitchCompat swNotifyPreviewAll;
private SwitchCompat swNotifyPreviewOnly;
@ -150,7 +151,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
"badge", "unseen_ignored",
"notify_grouping", "notify_private", "notify_background_only", "notify_known", "notify_suppress_in_call", "notify_suppress_in_car",
"notify_remove", "notify_clear",
"notify_subtext", "notify_preview", "notify_preview_all", "notify_preview_only", "notify_transliterate", "notify_ascii",
"notify_subtext", "notify_subject", "notify_preview", "notify_preview_all", "notify_preview_only", "notify_transliterate", "notify_ascii",
"wearable_preview",
"notify_messaging",
"biometrics_notify", "notify_open_folder", "background_service", "notify_rate_limit", "alert_once"
@ -208,6 +209,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
swNotifyRemove = view.findViewById(R.id.swNotifyRemove);
swNotifyClear = view.findViewById(R.id.swNotifyClear);
swNotifySubtext = view.findViewById(R.id.swNotifySubtext);
swNotifySubject = view.findViewById(R.id.swNotifySubject);
swNotifyPreview = view.findViewById(R.id.swNotifyPreview);
swNotifyPreviewAll = view.findViewById(R.id.swNotifyPreviewAll);
swNotifyPreviewOnly = view.findViewById(R.id.swNotifyPreviewOnly);
@ -658,6 +660,13 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
}
});
swNotifySubject.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("notify_subject", checked).apply();
}
});
swNotifyPreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -918,6 +927,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
swNotifyRemove.setChecked(prefs.getBoolean("notify_remove", true));
swNotifyClear.setChecked(prefs.getBoolean("notify_clear", false));
swNotifySubtext.setChecked(prefs.getBoolean("notify_subtext", true));
swNotifySubject.setChecked(prefs.getBoolean("notify_subject", true));
swNotifyPreview.setChecked(prefs.getBoolean("notify_preview", true));
swNotifyPreviewAll.setChecked(prefs.getBoolean("notify_preview_all", false));
swNotifyPreviewOnly.setChecked(prefs.getBoolean("notify_preview_only", false));

@ -707,6 +707,7 @@ class NotificationHelper {
boolean flags = prefs.getBoolean("flags", true);
boolean notify_messaging = prefs.getBoolean("notify_messaging", false);
boolean notify_subtext = prefs.getBoolean("notify_subtext", true);
boolean notify_subject = prefs.getBoolean("notify_subject", true);
boolean notify_preview = prefs.getBoolean("notify_preview", true);
boolean notify_preview_all = prefs.getBoolean("notify_preview_all", false);
boolean wearable_preview = prefs.getBoolean("wearable_preview", false);
@ -873,7 +874,7 @@ class NotificationHelper {
Address[] afrom = messageFrom.get(message.id);
String from = MessageHelper.formatAddresses(afrom, email_format, false);
sb.append("<strong>").append(Html.escapeHtml(from)).append("</strong>");
if (!TextUtils.isEmpty(message.subject))
if (!TextUtils.isEmpty(message.subject) && notify_subject)
sb.append(": ").append(Html.escapeHtml(message.subject));
sb.append(" ").append(Html.escapeHtml(DTF.format(message.received)));
sb.append("<br>");
@ -997,7 +998,7 @@ class NotificationHelper {
NotificationCompat.MessagingStyle messagingStyle = new NotificationCompat.MessagingStyle(me.build());
if (!TextUtils.isEmpty(message.subject))
if (!TextUtils.isEmpty(message.subject) && notify_subject)
messagingStyle.setConversationTitle(message.subject);
messagingStyle.addMessage(
@ -1043,7 +1044,7 @@ class NotificationHelper {
// Wearables
StringBuilder sb = new StringBuilder();
if (!TextUtils.isEmpty(message.subject))
if (!TextUtils.isEmpty(message.subject) && notify_subject)
sb.append(TextHelper.normalizeNotification(context, message.subject));
if (wearable_preview && !TextUtils.isEmpty(preview)) {
if (sb.length() > 0)
@ -1062,7 +1063,7 @@ class NotificationHelper {
if (keyword.startsWith("!"))
sbm.append(Html.escapeHtml(keyword)).append(": ");
if (!TextUtils.isEmpty(message.subject))
if (!TextUtils.isEmpty(message.subject) && notify_subject)
sbm.append("<em>").append(Html.escapeHtml(message.subject)).append("</em>").append("<br>");
if (!TextUtils.isEmpty(preview))
@ -1071,14 +1072,14 @@ class NotificationHelper {
if (sbm.length() > 0) {
NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle()
.bigText(HtmlHelper.fromHtml(sbm.toString(), context));
if (!TextUtils.isEmpty(message.subject))
if (!TextUtils.isEmpty(message.subject) && notify_subject)
bigText.setSummaryText(message.subject);
mbuilder.setStyle(bigText);
}
}
} else {
if (!TextUtils.isEmpty(message.subject))
if (!TextUtils.isEmpty(message.subject) && notify_subject)
mbuilder.setContentText(TextHelper.normalizeNotification(context, message.subject));
}

@ -709,6 +709,18 @@
app:layout_constraintTop_toBottomOf="@id/swNotifyClear"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifySubject"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_notify_subject"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swNotifySubtext"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifyPreview"
android:layout_width="0dp"
@ -718,7 +730,7 @@
android:text="@string/title_advanced_notify_preview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swNotifySubtext"
app:layout_constraintTop_toBottomOf="@id/swNotifySubject"
app:switchPadding="12dp" />
<TextView

@ -785,6 +785,7 @@
<string name="title_advanced_notify_suppress_in_call">Delay notifications while on a call</string>
<string name="title_advanced_notify_suppress_in_car">Delay notifications while Android Auto is connected</string>
<string name="title_advanced_notify_summary">Show summary notification only</string>
<string name="title_advanced_notify_subject">Show subject 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_only">Show notifications with a preview text only</string>

Loading…
Cancel
Save