Added setting to issue notifications with a preview only

pull/183/head
M66B 5 years ago
parent 32c8ce15a2
commit 1f9a953b43

@ -3102,6 +3102,8 @@ class Core {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean notify_summary = prefs.getBoolean("notify_summary", false); boolean notify_summary = prefs.getBoolean("notify_summary", false);
boolean notify_preview = prefs.getBoolean("notify_preview", true);
boolean notify_preview_only = prefs.getBoolean("notify_preview_only", false);
boolean wearable_preview = prefs.getBoolean("wearable_preview", false); boolean wearable_preview = prefs.getBoolean("wearable_preview", false);
boolean biometrics = prefs.getBoolean("biometrics", false); boolean biometrics = prefs.getBoolean("biometrics", false);
boolean biometric_notify = prefs.getBoolean("biometrics_notify", false); boolean biometric_notify = prefs.getBoolean("biometrics_notify", false);
@ -3130,6 +3132,9 @@ class Core {
} }
} }
if (notify_preview && notify_preview_only && !message.content)
continue;
long group = (pro && message.accountNotify ? message.account : 0); long group = (pro && message.accountNotify ? message.account : 0);
if (!message.folderUnified) if (!message.folderUnified)
group = -message.folder; group = -message.folder;

@ -77,6 +77,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
private SwitchCompat swNotifyClear; private SwitchCompat swNotifyClear;
private SwitchCompat swNotifyPreview; private SwitchCompat swNotifyPreview;
private SwitchCompat swNotifyPreviewAll; private SwitchCompat swNotifyPreviewAll;
private SwitchCompat swNotifyPreviewOnly;
private SwitchCompat swWearablePreview; private SwitchCompat swWearablePreview;
private SwitchCompat swBiometricsNotify; private SwitchCompat swBiometricsNotify;
private SwitchCompat swAlertOnce; private SwitchCompat swAlertOnce;
@ -93,7 +94,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
"light", "sound", "light", "sound",
"badge", "unseen_ignored", "badge", "unseen_ignored",
"notify_known", "notify_summary", "notify_remove", "notify_clear", "notify_known", "notify_summary", "notify_remove", "notify_clear",
"notify_preview", "notify_preview_all", "wearable_preview", "notify_preview", "notify_preview_all", "notify_preview_only", "wearable_preview",
"biometrics_notify", "biometrics_notify",
"alert_once" "alert_once"
}; };
@ -136,6 +137,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
swNotifyClear = view.findViewById(R.id.swNotifyClear); swNotifyClear = view.findViewById(R.id.swNotifyClear);
swNotifyPreview = view.findViewById(R.id.swNotifyPreview); swNotifyPreview = view.findViewById(R.id.swNotifyPreview);
swNotifyPreviewAll = view.findViewById(R.id.swNotifyPreviewAll); swNotifyPreviewAll = view.findViewById(R.id.swNotifyPreviewAll);
swNotifyPreviewOnly = view.findViewById(R.id.swNotifyPreviewOnly);
swWearablePreview = view.findViewById(R.id.swWearablePreview); swWearablePreview = view.findViewById(R.id.swWearablePreview);
swBiometricsNotify = view.findViewById(R.id.swBiometricsNotify); swBiometricsNotify = view.findViewById(R.id.swBiometricsNotify);
swAlertOnce = view.findViewById(R.id.swAlertOnce); swAlertOnce = view.findViewById(R.id.swAlertOnce);
@ -351,6 +353,13 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
} }
}); });
swNotifyPreviewOnly.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("notify_preview_only", checked).apply();
}
});
swWearablePreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swWearablePreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -454,6 +463,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
swNotifyClear.setChecked(prefs.getBoolean("notify_clear", false)); swNotifyClear.setChecked(prefs.getBoolean("notify_clear", false));
swNotifyPreview.setChecked(prefs.getBoolean("notify_preview", true)); swNotifyPreview.setChecked(prefs.getBoolean("notify_preview", true));
swNotifyPreviewAll.setChecked(prefs.getBoolean("notify_preview_all", false)); swNotifyPreviewAll.setChecked(prefs.getBoolean("notify_preview_all", false));
swNotifyPreviewOnly.setChecked(prefs.getBoolean("notify_preview_only", false));
swWearablePreview.setChecked(prefs.getBoolean("wearable_preview", false)); swWearablePreview.setChecked(prefs.getBoolean("wearable_preview", false));
swBiometricsNotify.setChecked(prefs.getBoolean("biometrics_notify", false)); swBiometricsNotify.setChecked(prefs.getBoolean("biometrics_notify", false));
swAlertOnce.setChecked(!prefs.getBoolean("alert_once", true)); swAlertOnce.setChecked(!prefs.getBoolean("alert_once", true));
@ -477,6 +487,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
cbNotifyActionSnooze.setEnabled(pro && !summary); cbNotifyActionSnooze.setEnabled(pro && !summary);
swNotifyPreview.setEnabled(!summary); swNotifyPreview.setEnabled(!summary);
swNotifyPreviewAll.setEnabled(!summary && swNotifyPreview.isChecked()); swNotifyPreviewAll.setEnabled(!summary && swNotifyPreview.isChecked());
swNotifyPreviewOnly.setEnabled(!summary && swNotifyPreview.isChecked());
swWearablePreview.setEnabled(!summary && swNotifyPreview.isChecked()); swWearablePreview.setEnabled(!summary && swNotifyPreview.isChecked());
swBiometricsNotify.setEnabled(!summary); swBiometricsNotify.setEnabled(!summary);
} }

@ -446,6 +446,29 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swNotifyPreviewAll" /> app:layout_constraintTop_toBottomOf="@id/swNotifyPreviewAll" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifyPreviewOnly"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_notify_preview_only"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyPreviewAllHint"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvNotifyPreviewOnlyHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_notify_preview_only_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swNotifyPreviewOnly" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swWearablePreview" android:id="@+id/swWearablePreview"
android:layout_width="0dp" android:layout_width="0dp"
@ -454,7 +477,7 @@
android:text="@string/title_advanced_wearable_preview" android:text="@string/title_advanced_wearable_preview"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyPreviewAllHint" app:layout_constraintTop_toBottomOf="@id/tvNotifyPreviewOnlyHint"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView

@ -411,6 +411,7 @@
<string name="title_advanced_notify_summary">Show summary notification only</string> <string name="title_advanced_notify_summary">Show summary notification only</string>
<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_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_junk">Spam</string> <string name="title_advanced_notify_action_junk">Spam</string>
@ -540,6 +541,7 @@
<string name="title_advanced_notify_manage_default_hint">To set the default sound, etc</string> <string name="title_advanced_notify_manage_default_hint">To set the default sound, etc</string>
<string name="title_advanced_notify_manage_service_hint">To disable the permanent notification</string> <string name="title_advanced_notify_manage_service_hint">To disable the permanent notification</string>
<string name="title_advanced_notify_preview_all_hint">For wearables that can show the full text (up to 5,000 characters)</string> <string name="title_advanced_notify_preview_all_hint">For wearables that can show the full text (up to 5,000 characters)</string>
<string name="title_advanced_notify_preview_only_hint">This delays showing of notifications until the message text has been downloaded</string>
<string name="title_advanced_wearable_hint">Notifications are only sent to a wearable after the message text has been downloaded</string> <string name="title_advanced_wearable_hint">Notifications are only sent to a wearable after the message text has been downloaded</string>
<string name="title_advanced_move_hint">The target folder can be configured in the account settings</string> <string name="title_advanced_move_hint">The target folder can be configured in the account settings</string>
<string name="title_advanced_notify_no_grouping">This Android version does not support notification grouping</string> <string name="title_advanced_notify_no_grouping">This Android version does not support notification grouping</string>

Loading…
Cancel
Save