From c6f0ae6dad6a965ef90d6f854d46d3504673f5cb Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 11 Feb 2020 19:55:03 +0100 Subject: [PATCH] Added setting to enable full notification text --- app/src/main/java/eu/faircode/email/Core.java | 25 ++++++++++--------- .../email/FragmentOptionsNotifications.java | 13 +++++++++- .../layout/fragment_options_notifications.xml | 25 ++++++++++++++++++- app/src/main/res/values/strings.xml | 2 ++ 4 files changed, 51 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 92a3978955..edeb241507 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -2862,6 +2862,7 @@ class Core { boolean name_email = prefs.getBoolean("name_email", false); boolean flags = prefs.getBoolean("flags", 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); boolean notify_trash = (prefs.getBoolean("notify_trash", true) || !pro); boolean notify_junk = (prefs.getBoolean("notify_junk", false) && pro); @@ -3210,14 +3211,14 @@ class Core { if (message.content && notify_preview) { // Android will truncate the text - String text = null; - try { - String html = Helper.readText(message.getFile(context)); - text = HtmlHelper.getPreviewText(html); - } catch (Throwable ex) { - Log.e(ex); - text = message.preview; - } + String preview = message.preview; + if (notify_preview_all) + try { + String html = Helper.readText(message.getFile(context)); + preview = HtmlHelper.getPreviewText(html); + } catch (Throwable ex) { + Log.e(ex); + } // Wearables StringBuilder sb = new StringBuilder(); @@ -3226,8 +3227,8 @@ class Core { if (wearable_preview) { if (sb.length() != 0) sb.append(" - "); - if (!TextUtils.isEmpty(text)) - sb.append(text); + if (!TextUtils.isEmpty(preview)) + sb.append(preview); } if (sb.length() > 0) mbuilder.setContentText(sb.toString()); @@ -3237,8 +3238,8 @@ class Core { if (!TextUtils.isEmpty(message.subject)) sbm.append("").append(message.subject).append("").append("
"); - if (!TextUtils.isEmpty(text)) - sbm.append(text); + if (!TextUtils.isEmpty(preview)) + sbm.append(preview); if (sbm.length() > 0) { NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle() diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java b/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java index f99e449ffa..caa731d299 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java @@ -58,6 +58,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared private SwitchCompat swNotifyRemove; private SwitchCompat swNotifyClear; private SwitchCompat swNotifyPreview; + private SwitchCompat swNotifyPreviewAll; private SwitchCompat swWearablePreview; private CheckBox cbNotifyActionTrash; private CheckBox cbNotifyActionJunk; @@ -81,7 +82,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared private final static String[] RESET_OPTIONS = new String[]{ "badge", "unseen_ignored", - "notify_summary", "notify_remove", "notify_clear", "notify_preview", "wearable_preview", + "notify_summary", "notify_remove", "notify_clear", "notify_preview", "notify_preview_all", "wearable_preview", "notify_trash", "notify_junk", "notify_archive", "notify_move", "notify_reply", "notify_reply_direct", "notify_flag", "notify_seen", "notify_snooze", @@ -108,6 +109,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared swNotifyRemove = view.findViewById(R.id.swNotifyRemove); swNotifyClear = view.findViewById(R.id.swNotifyClear); swNotifyPreview = view.findViewById(R.id.swNotifyPreview); + swNotifyPreviewAll = view.findViewById(R.id.swNotifyPreviewAll); swWearablePreview = view.findViewById(R.id.swWearablePreview); cbNotifyActionTrash = view.findViewById(R.id.cbNotifyActionTrash); cbNotifyActionJunk = view.findViewById(R.id.cbNotifyActionJunk); @@ -217,6 +219,13 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared } }); + swNotifyPreviewAll.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { + prefs.edit().putBoolean("notify_preview_all", checked).apply(); + } + }); + swWearablePreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { @@ -390,6 +399,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared swNotifyRemove.setChecked(prefs.getBoolean("notify_remove", true)); swNotifyClear.setChecked(prefs.getBoolean("notify_clear", false)); swNotifyPreview.setChecked(prefs.getBoolean("notify_preview", true)); + swNotifyPreviewAll.setChecked(prefs.getBoolean("notify_preview_all", false)); swWearablePreview.setChecked(prefs.getBoolean("wearable_preview", false)); cbNotifyActionTrash.setChecked(prefs.getBoolean("notify_trash", true) || !pro); @@ -415,6 +425,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared boolean summary = swNotifySummary.isChecked(); swNotifyPreview.setEnabled(!summary); + swNotifyPreviewAll.setEnabled(!summary && swNotifyPreview.isChecked()); swWearablePreview.setEnabled(!summary && swNotifyPreview.isChecked()); cbNotifyActionTrash.setEnabled(pro && !summary); cbNotifyActionJunk.setEnabled(pro && !summary); diff --git a/app/src/main/res/layout/fragment_options_notifications.xml b/app/src/main/res/layout/fragment_options_notifications.xml index 32c2403737..70794ea2e5 100644 --- a/app/src/main/res/layout/fragment_options_notifications.xml +++ b/app/src/main/res/layout/fragment_options_notifications.xml @@ -191,6 +191,29 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/swNotifyPreview" /> + + + + Let the number of new messages match the number of notifications Show summary notification only Show message preview in notifications + Preview all text Notification actions Trash Spam @@ -465,6 +466,7 @@ Tap on the channel name to set the channel properties To set the default sound, etc To disable the permanent notification + For wearables that can show the full text (up to 5,000 characters) Notifications are only sent to a wearable after the message text has been downloaded The target folder can be configured in the account settings This Android version does not support notification grouping