Added option for wearable preview

pull/164/head
M66B 5 years ago
parent 21d89029ee
commit 726fce894d

@ -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("<br>");
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("<em>").append(preview).append("</em>");
// Device
StringBuilder sbm = new StringBuilder();
if (!TextUtils.isEmpty(message.subject))
sbm.append(message.subject).append("<br>");
NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle()
.bigText(HtmlHelper.fromHtml(sbm.toString()));
if (!TextUtils.isEmpty(message.preview))
sbm.append("<em>").append(message.preview).append("</em>");
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);
}

@ -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);

@ -106,6 +106,29 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swNotifyPreview" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swWearablePreview"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_wearable_preview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyPreviewHint"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvWearablePreviewHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_wearable_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/swWearablePreview" />
<TextView
android:id="@+id/tvNotifyActions"
android:layout_width="0dp"
@ -117,7 +140,7 @@
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyPreviewHint" />
app:layout_constraintTop_toBottomOf="@id/tvWearablePreviewHint" />
<CheckBox
android:id="@+id/cbNotifyActionTrash"

@ -309,6 +309,7 @@
<string name="title_advanced_notify_action_seen">Read</string>
<string name="title_advanced_notify_action_snooze">Snooze</string>
<string name="title_advanced_notify_remove">Remove new message notification on tapping on notification</string>
<string name="title_advanced_wearable_preview">Only send notifications with a message preview to wearables</string>
<string name="title_advanced_biometrics_notify">Show notification content when using biometric authentication</string>
<string name="title_advanced_light">Use notification light</string>
<string name="title_advanced_sound">Select notification sound</string>
@ -364,6 +365,7 @@
<string name="title_advanced_threading_hint">Group messages related to each other</string>
<string name="title_advanced_name_email_hint">When disabled only names will be shown when available</string>
<string name="title_advanced_preview_hint">Only available when 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_inline_hint">Inline images are images included in the message</string>
<string name="title_advanced_autoexpand_hint">Automatically open message when there is just one message or just one unread message in a conversation</string>

Loading…
Cancel
Save