Added setting to disable notification message preview

pull/147/head
M66B 7 years ago
parent 50ee5750fc
commit 4f83c18b60

@ -86,6 +86,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
private SwitchCompat swAutoResize;
private SwitchCompat swAutoSend;
private SwitchCompat swNotifyPreview;
private SwitchCompat swLight;
private Button btnSound;
@ -104,7 +105,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
"metered", "download",
"unified", "date", "threading", "avatars", "identicons", "name_email", "preview", "addresses", "autoimages", "actionbar",
"pull", "swipenav", "autoexpand", "autoclose", "autonext", "collapse", "autoread", "automove", "sender", "autoresize", "autosend",
"light", "sound",
"notify_preview", "light", "sound",
"debug",
"first", "why", "last_update_check", "app_support", "message_swipe", "message_select", "folder_actions", "folder_sync",
"edit_ref_confirmed", "autosend", "automove", "show_html_confirmed", "show_images_confirmed"
@ -150,6 +151,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
swAutoResize = view.findViewById(R.id.swAutoResize);
swAutoSend = view.findViewById(R.id.swAutoSend);
swNotifyPreview = view.findViewById(R.id.swNotifyPreview);
swLight = view.findViewById(R.id.swLight);
btnSound = view.findViewById(R.id.btnSound);
@ -381,6 +383,13 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
}
});
swNotifyPreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("notify_preview", checked).apply();
}
});
swLight.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -512,6 +521,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
swAutoResize.setChecked(prefs.getBoolean("autoresize", true));
swAutoSend.setChecked(!prefs.getBoolean("autosend", false));
swNotifyPreview.setChecked(prefs.getBoolean("notify_preview", true));
swLight.setChecked(prefs.getBoolean("light", false));
swDebug.setChecked(prefs.getBoolean("debug", false));

@ -552,10 +552,12 @@ public class ServiceSynchronize extends LifecycleService {
builder.setSubText(accountName);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
if (prefs.getBoolean("light", false))
boolean light = prefs.getBoolean("light", false);
String sound = prefs.getString("sound", null);
if (light)
builder.setLights(Color.GREEN, 1000, 1000);
String sound = prefs.getString("sound", null);
if (sound == null) {
Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
builder.setSound(uri);
@ -584,6 +586,7 @@ public class ServiceSynchronize extends LifecycleService {
notifications.add(builder.build());
boolean preview = prefs.getBoolean("notify_preview", true);
for (TupleMessageEx message : messages) {
ContactInfo info = messageContact.get(message);
@ -665,7 +668,7 @@ public class ServiceSynchronize extends LifecycleService {
if (!TextUtils.isEmpty(message.subject))
mbuilder.setContentText(message.subject);
if (message.content)
if (message.content && preview)
try {
String body = Helper.readText(EntityMessage.getFile(this, message.id));
StringBuilder sb = new StringBuilder();

@ -603,6 +603,44 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSectionMisc" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifyPreview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_notify_preview"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparatorMisc"
app:switchPadding="12dp" />
<TextView
android:id="@+id/swNotifyPreviewHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginEnd="60dp"
android:text="@string/title_advanced_preview_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/swNotifyPreview" />
<TextView
android:id="@+id/swNotifyPreviewPro"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginEnd="60dp"
android:text="@string/title_pro_feature"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swNotifyPreviewHint" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swLight"
android:layout_width="match_parent"
@ -612,7 +650,7 @@
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_light"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparatorMisc"
app:layout_constraintTop_toBottomOf="@id/swNotifyPreviewPro"
app:switchPadding="12dp" />
<Button

@ -157,6 +157,7 @@
<string name="title_advanced_images">Automatically show images for known contacts</string>
<string name="title_advanced_actionbar">Conversation action bar</string>
<string name="title_advanced_notify_preview">Show message preview in notifications</string>
<string name="title_advanced_light">Use notification light</string>
<string name="title_advanced_sound">Select notification sound</string>

Loading…
Cancel
Save