|
|
|
@ -652,7 +652,6 @@ class NotificationHelper {
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
|
boolean notify_grouping = prefs.getBoolean("notify_grouping", true);
|
|
|
|
|
boolean notify_private = prefs.getBoolean("notify_private", true);
|
|
|
|
|
boolean notify_public_actions = prefs.getBoolean("notify_public_actions", true);
|
|
|
|
|
boolean notify_newest_first = prefs.getBoolean("notify_newest_first", false);
|
|
|
|
|
MessageHelper.AddressFormat email_format = MessageHelper.getAddressFormat(context);
|
|
|
|
|
boolean prefer_contact = prefs.getBoolean("prefer_contact", false);
|
|
|
|
@ -969,84 +968,6 @@ class NotificationHelper {
|
|
|
|
|
|
|
|
|
|
DB db = DB.getInstance(context);
|
|
|
|
|
|
|
|
|
|
if (message.content && notify_preview) {
|
|
|
|
|
// Android will truncate the text
|
|
|
|
|
String preview = message.preview;
|
|
|
|
|
if (notify_preview_all)
|
|
|
|
|
try {
|
|
|
|
|
File file = message.getFile(context);
|
|
|
|
|
preview = HtmlHelper.getFullText(file);
|
|
|
|
|
if (preview != null && preview.length() > MAX_PREVIEW)
|
|
|
|
|
preview = preview.substring(0, MAX_PREVIEW);
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
Log.e(ex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Wearables
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
if (!TextUtils.isEmpty(message.subject))
|
|
|
|
|
sb.append(TextHelper.normalizeNotification(context, message.subject));
|
|
|
|
|
if (wearable_preview && !TextUtils.isEmpty(preview)) {
|
|
|
|
|
if (sb.length() > 0)
|
|
|
|
|
sb.append(" - ");
|
|
|
|
|
sb.append(TextHelper.normalizeNotification(context, preview));
|
|
|
|
|
}
|
|
|
|
|
if (sb.length() > 0)
|
|
|
|
|
mbuilder.setContentText(sb.toString());
|
|
|
|
|
|
|
|
|
|
// Device
|
|
|
|
|
if (!notify_messaging) {
|
|
|
|
|
StringBuilder sbm = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
if (message.keywords != null && BuildConfig.DEBUG)
|
|
|
|
|
for (String keyword : message.keywords)
|
|
|
|
|
if (keyword.startsWith("!"))
|
|
|
|
|
sbm.append(Html.escapeHtml(keyword)).append(": ");
|
|
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(message.subject))
|
|
|
|
|
sbm.append("<em>").append(Html.escapeHtml(message.subject)).append("</em>").append("<br>");
|
|
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(preview))
|
|
|
|
|
sbm.append(Html.escapeHtml(preview));
|
|
|
|
|
|
|
|
|
|
if (sbm.length() > 0) {
|
|
|
|
|
NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle()
|
|
|
|
|
.bigText(HtmlHelper.fromHtml(sbm.toString(), context));
|
|
|
|
|
if (!TextUtils.isEmpty(message.subject))
|
|
|
|
|
bigText.setSummaryText(message.subject);
|
|
|
|
|
|
|
|
|
|
mbuilder.setStyle(bigText);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (!TextUtils.isEmpty(message.subject))
|
|
|
|
|
mbuilder.setContentText(TextHelper.normalizeNotification(context, message.subject));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (info[0].hasPhoto())
|
|
|
|
|
mbuilder.setLargeIcon(info[0].getPhotoBitmap());
|
|
|
|
|
|
|
|
|
|
if (info[0].hasLookupUri()) {
|
|
|
|
|
Person.Builder you = new Person.Builder()
|
|
|
|
|
.setUri(info[0].getLookupUri().toString());
|
|
|
|
|
mbuilder.addPerson(you.build());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pro) {
|
|
|
|
|
Integer color = getColor(message);
|
|
|
|
|
if (color != null) {
|
|
|
|
|
mbuilder.setColor(color);
|
|
|
|
|
mbuilder.setColorized(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!notify_private && !notify_public_actions) {
|
|
|
|
|
Notification pub = mbuilder.build();
|
|
|
|
|
mbuilder
|
|
|
|
|
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
|
|
|
|
|
.setPublicVersion(pub);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<NotificationCompat.Action> wactions = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
if (notify_trash &&
|
|
|
|
@ -1281,6 +1202,77 @@ class NotificationHelper {
|
|
|
|
|
wactions.add(actionSnooze.build());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (message.content && notify_preview) {
|
|
|
|
|
// Android will truncate the text
|
|
|
|
|
String preview = message.preview;
|
|
|
|
|
if (notify_preview_all)
|
|
|
|
|
try {
|
|
|
|
|
File file = message.getFile(context);
|
|
|
|
|
preview = HtmlHelper.getFullText(file);
|
|
|
|
|
if (preview != null && preview.length() > MAX_PREVIEW)
|
|
|
|
|
preview = preview.substring(0, MAX_PREVIEW);
|
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
|
Log.e(ex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Wearables
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
if (!TextUtils.isEmpty(message.subject))
|
|
|
|
|
sb.append(TextHelper.normalizeNotification(context, message.subject));
|
|
|
|
|
if (wearable_preview && !TextUtils.isEmpty(preview)) {
|
|
|
|
|
if (sb.length() > 0)
|
|
|
|
|
sb.append(" - ");
|
|
|
|
|
sb.append(TextHelper.normalizeNotification(context, preview));
|
|
|
|
|
}
|
|
|
|
|
if (sb.length() > 0)
|
|
|
|
|
mbuilder.setContentText(sb.toString());
|
|
|
|
|
|
|
|
|
|
// Device
|
|
|
|
|
if (!notify_messaging) {
|
|
|
|
|
StringBuilder sbm = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
if (message.keywords != null && BuildConfig.DEBUG)
|
|
|
|
|
for (String keyword : message.keywords)
|
|
|
|
|
if (keyword.startsWith("!"))
|
|
|
|
|
sbm.append(Html.escapeHtml(keyword)).append(": ");
|
|
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(message.subject))
|
|
|
|
|
sbm.append("<em>").append(Html.escapeHtml(message.subject)).append("</em>").append("<br>");
|
|
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(preview))
|
|
|
|
|
sbm.append(Html.escapeHtml(preview));
|
|
|
|
|
|
|
|
|
|
if (sbm.length() > 0) {
|
|
|
|
|
NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle()
|
|
|
|
|
.bigText(HtmlHelper.fromHtml(sbm.toString(), context));
|
|
|
|
|
if (!TextUtils.isEmpty(message.subject))
|
|
|
|
|
bigText.setSummaryText(message.subject);
|
|
|
|
|
|
|
|
|
|
mbuilder.setStyle(bigText);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (!TextUtils.isEmpty(message.subject))
|
|
|
|
|
mbuilder.setContentText(TextHelper.normalizeNotification(context, message.subject));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (info[0].hasPhoto())
|
|
|
|
|
mbuilder.setLargeIcon(info[0].getPhotoBitmap());
|
|
|
|
|
|
|
|
|
|
if (info[0].hasLookupUri()) {
|
|
|
|
|
Person.Builder you = new Person.Builder()
|
|
|
|
|
.setUri(info[0].getLookupUri().toString());
|
|
|
|
|
mbuilder.addPerson(you.build());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pro) {
|
|
|
|
|
Integer color = getColor(message);
|
|
|
|
|
if (color != null) {
|
|
|
|
|
mbuilder.setColor(color);
|
|
|
|
|
mbuilder.setColorized(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// https://developer.android.com/training/wearables/notifications
|
|
|
|
|
// https://developer.android.com/reference/androidx/core/app/NotificationCompat.Action.WearableExtender
|
|
|
|
|
mbuilder.extend(new NotificationCompat.WearableExtender()
|
|
|
|
|