Added option to show sender only in summary notifications

pull/217/head
M66B 6 months ago
parent 2e09042b33
commit 964ab3d61a

@ -126,6 +126,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
private SwitchCompat swMessagingStyle;
private ImageButton ibCar;
private SwitchCompat swBiometricsNotify;
private SwitchCompat swNotifyMinimal;
private SwitchCompat swNotifyOpenFolder;
private SwitchCompat swBackground;
private Spinner spRateLimit;
@ -153,7 +154,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
"notify_subtext", "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"
"biometrics_notify", "notify_minimal", "notify_open_folder", "background_service", "notify_rate_limit", "alert_once"
));
@Override
@ -219,6 +220,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
swMessagingStyle = view.findViewById(R.id.swMessagingStyle);
ibCar = view.findViewById(R.id.ibCar);
swBiometricsNotify = view.findViewById(R.id.swBiometricsNotify);
swNotifyMinimal = view.findViewById(R.id.swNotifyMinimal);
swNotifyOpenFolder = view.findViewById(R.id.swNotifyOpenFolder);
swBackground = view.findViewById(R.id.swBackground);
spRateLimit = view.findViewById(R.id.spRateLimit);
@ -733,6 +735,15 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("biometrics_notify", checked).apply();
enableOptions();
}
});
swNotifyMinimal.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("notify_minimal", checked).apply();
enableOptions();
}
});
@ -926,6 +937,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
swWearablePreview.setChecked(prefs.getBoolean("wearable_preview", false));
swMessagingStyle.setChecked(prefs.getBoolean("notify_messaging", false));
swBiometricsNotify.setChecked(prefs.getBoolean("biometrics_notify", true));
swNotifyMinimal.setChecked(prefs.getBoolean("notify_minimal", false));
swNotifyOpenFolder.setChecked(prefs.getBoolean("notify_open_folder", false));
swBackground.setChecked(prefs.getBoolean("background_service", false));
swAlertOnce.setChecked(!prefs.getBoolean("alert_once", true));
@ -956,6 +968,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
swNotifyPreviewOnly.setEnabled(!summary && swNotifyPreview.isChecked());
swWearablePreview.setEnabled(!summary && swNotifyPreview.isChecked());
swBiometricsNotify.setEnabled(!summary);
swNotifyMinimal.setEnabled(summary || !swBiometricsNotify.isChecked());
}
@Override

@ -727,6 +727,7 @@ class NotificationHelper {
boolean alert_once = prefs.getBoolean("alert_once", true);
boolean perform_expunge = prefs.getBoolean("perform_expunge", true);
boolean delete_notification = prefs.getBoolean("delete_notification", false);
boolean notify_minimal = prefs.getBoolean("notify_minimal", false);
// Get contact info
Long latest = null;
@ -864,7 +865,7 @@ class NotificationHelper {
}
if (notify_preview)
if (redacted)
if (redacted && !notify_minimal)
builder.setContentText(context.getString(R.string.title_notification_redacted));
else {
DateFormat DTF = Helper.getDateTimeInstance(context, SimpleDateFormat.SHORT, SimpleDateFormat.SHORT);
@ -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_minimal)
sb.append(": ").append(Html.escapeHtml(message.subject));
sb.append(" ").append(Html.escapeHtml(DTF.format(message.received)));
sb.append("<br>");

@ -890,6 +890,19 @@
app:layout_constraintTop_toBottomOf="@id/ibCar"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifyMinimal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_notify_minimal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swBiometricsNotify"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifyOpenFolder"
android:layout_width="0dp"
@ -899,7 +912,7 @@
android:text="@string/title_advanced_notify_open_folder"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swBiometricsNotify"
app:layout_constraintTop_toBottomOf="@id/swNotifyMinimal"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

@ -808,6 +808,7 @@
<string name="title_advanced_wearable_preview">Only send notifications with a message preview to wearables</string>
<string name="title_advanced_notify_messaging">Use Android \'messaging style\' notification format</string>
<string name="title_advanced_biometrics_notify">Show notification content when using biometric authentication</string>
<string name="title_advanced_notify_minimal">Show sender only</string>
<string name="title_advanced_notify_open_folder">Open folder when opening new message</string>
<string name="title_advanced_light">Use notification light</string>
<string name="title_advanced_sound">Select notification sound</string>

Loading…
Cancel
Save