diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java
index e5dc2e7240..c99f87f27e 100644
--- a/app/src/main/java/eu/faircode/email/Core.java
+++ b/app/src/main/java/eu/faircode/email/Core.java
@@ -2611,6 +2611,7 @@ class Core {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean notify_summary = prefs.getBoolean("notify_summary", false);
+ boolean wearable_preview = prefs.getBoolean("wearable_preview", false);
boolean biometrics = prefs.getBoolean("biometrics", false);
boolean biometric_notify = prefs.getBoolean("biometrics_notify", false);
boolean pro = ActivityBilling.isPro(context);
@@ -2725,8 +2726,9 @@ class Core {
for (NotificationCompat.Builder builder : notifications) {
long id = builder.getExtras().getLong("id", 0);
if ((id == 0 && add.size() + remove.size() > 0) || add.contains(id)) {
- if (update.contains(id))
+ if (wearable_preview ? id < 0 : update.contains(id))
builder.setLocalOnly(true);
+
String tag = "unseen." + group + "." + Math.abs(id);
Notification notification = builder.build();
Log.i("Notifying tag=" + tag + " id=" + id +
@@ -3071,33 +3073,27 @@ class Core {
mbuilder.extend(new NotificationCompat.WearableExtender()
.addActions(wactions));
- if (message.content && notify_preview)
- try {
- StringBuilder sbm = new StringBuilder();
- if (!TextUtils.isEmpty(message.subject))
- sbm.append(message.subject).append("
");
+ if (message.content && notify_preview) {
+ // Wearables
+ mbuilder.setContentText(
+ (message.subject == null ? "" : message.subject) + " - " +
+ (message.preview == null ? "" : message.preview));
- String body = Helper.readText(message.getFile(context));
- String preview = HtmlHelper.getPreview(body);
- if (!TextUtils.isEmpty(preview))
- sbm.append("").append(preview).append("");
+ // Device
+ StringBuilder sbm = new StringBuilder();
+ if (!TextUtils.isEmpty(message.subject))
+ sbm.append(message.subject).append("
");
- NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle()
- .bigText(HtmlHelper.fromHtml(sbm.toString()));
+ if (!TextUtils.isEmpty(message.preview))
+ sbm.append("").append(message.preview).append("");
- if (!TextUtils.isEmpty(message.subject)) {
- bigText.setSummaryText(message.subject);
- mbuilder.setContentText(message.subject); // Wearable
- }
+ NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle()
+ .bigText(HtmlHelper.fromHtml(sbm.toString()));
+ if (!TextUtils.isEmpty(message.subject))
+ bigText.setSummaryText(message.subject);
- mbuilder.setStyle(bigText);
- } catch (IOException ex) {
- Log.e(ex);
- mbuilder.setStyle(new NotificationCompat.BigTextStyle()
- .bigText(ex.toString())
- .setSummaryText(Helper.formatThrowable(ex)));
- }
- else {
+ mbuilder.setStyle(bigText);
+ } else {
if (!TextUtils.isEmpty(message.subject))
mbuilder.setContentText(message.subject);
}
diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java b/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java
index c4668847d9..b2d1647d95 100644
--- a/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java
+++ b/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java
@@ -56,6 +56,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
private SwitchCompat swNotifySummary;
private SwitchCompat swNotifyRemove;
private SwitchCompat swNotifyPreview;
+ private SwitchCompat swWearablePreview;
private CheckBox cbNotifyActionTrash;
private CheckBox cbNotifyActionJunk;
private CheckBox cbNotifyActionArchive;
@@ -79,7 +80,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
private final static String[] RESET_OPTIONS = new String[]{
"badge", "unseen_ignored",
- "notify_summary", "notify_remove", "notify_preview",
+ "notify_summary", "notify_remove", "notify_preview", "wearable_preview",
"notify_trash", "notify_junk", "notify_archive", "notify_reply", "notify_reply_direct",
"notify_flag", "notify_seen", "notify_snooze",
"biometrics_notify",
@@ -101,6 +102,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
swNotifySummary = view.findViewById(R.id.swNotifySummary);
swNotifyRemove = view.findViewById(R.id.swNotifyRemove);
swNotifyPreview = view.findViewById(R.id.swNotifyPreview);
+ swWearablePreview = view.findViewById(R.id.swWearablePreview);
cbNotifyActionTrash = view.findViewById(R.id.cbNotifyActionTrash);
cbNotifyActionJunk = view.findViewById(R.id.cbNotifyActionJunk);
cbNotifyActionArchive = view.findViewById(R.id.cbNotifyActionArchive);
@@ -164,6 +166,14 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("notify_preview", checked).apply();
+ swWearablePreview.setEnabled(checked);
+ }
+ });
+
+ swWearablePreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
+ prefs.edit().putBoolean("wearable_preview", checked).apply();
}
});
@@ -343,6 +353,8 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
swUnseenIgnored.setChecked(prefs.getBoolean("unseen_ignored", false));
swNotifySummary.setChecked(prefs.getBoolean("notify_summary", false));
swNotifyPreview.setChecked(prefs.getBoolean("notify_preview", true));
+ swWearablePreview.setChecked(prefs.getBoolean("wearable_preview", false));
+ swWearablePreview.setEnabled(swNotifyPreview.isChecked());
cbNotifyActionTrash.setChecked(prefs.getBoolean("notify_trash", true) || !pro);
cbNotifyActionJunk.setChecked(prefs.getBoolean("notify_junk", false) && pro);
diff --git a/app/src/main/res/layout/fragment_options_notifications.xml b/app/src/main/res/layout/fragment_options_notifications.xml
index 78fd3bb8bc..c170180c33 100644
--- a/app/src/main/res/layout/fragment_options_notifications.xml
+++ b/app/src/main/res/layout/fragment_options_notifications.xml
@@ -106,6 +106,29 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swNotifyPreview" />
+
+
+
+
+ app:layout_constraintTop_toBottomOf="@id/tvWearablePreviewHint" />
Read
Snooze
Remove new message notification on tapping on notification
+ Only send notifications with a message preview to wearables
Show notification content when using biometric authentication
Use notification light
Select notification sound
@@ -364,6 +365,7 @@
Group messages related to each other
When disabled only names will be shown when available
Only available when message text has been downloaded
+ Notifications are only sent to a wearable after the message text has been downloaded
Inline images are images included in the message
Automatically open message when there is just one message or just one unread message in a conversation