|
|
|
@ -38,7 +38,9 @@ import android.util.Pair;
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
|
import androidx.core.app.NotificationCompat;
|
|
|
|
|
import androidx.core.app.Person;
|
|
|
|
|
import androidx.core.app.RemoteInput;
|
|
|
|
|
import androidx.core.graphics.drawable.IconCompat;
|
|
|
|
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
|
|
|
|
import androidx.preference.PreferenceManager;
|
|
|
|
|
|
|
|
|
@ -3562,6 +3564,7 @@ class Core {
|
|
|
|
|
boolean name_email = prefs.getBoolean("name_email", false);
|
|
|
|
|
boolean prefer_contact = prefs.getBoolean("prefer_contact", false);
|
|
|
|
|
boolean flags = prefs.getBoolean("flags", true);
|
|
|
|
|
boolean notify_messaging = prefs.getBoolean("notify_messaging", false);
|
|
|
|
|
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);
|
|
|
|
@ -3782,6 +3785,17 @@ class Core {
|
|
|
|
|
.setOnlyAlertOnce(alert_once)
|
|
|
|
|
.setAllowSystemGeneratedContextualActions(false);
|
|
|
|
|
|
|
|
|
|
NotificationCompat.MessagingStyle messagingStyle = null;
|
|
|
|
|
if (notify_messaging) {
|
|
|
|
|
// https://developer.android.com/training/cars/messaging
|
|
|
|
|
Person.Builder me = new Person.Builder()
|
|
|
|
|
.setName(MessageHelper.formatAddresses(message.to, name_email, false));
|
|
|
|
|
messagingStyle = new NotificationCompat.MessagingStyle(me.build());
|
|
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(message.subject))
|
|
|
|
|
messagingStyle.setConversationTitle(message.subject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
|
|
|
|
mbuilder
|
|
|
|
|
.setGroup(Long.toString(group))
|
|
|
|
@ -3815,6 +3829,7 @@ class Core {
|
|
|
|
|
context.getString(R.string.title_advanced_notify_action_trash),
|
|
|
|
|
piTrash)
|
|
|
|
|
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_DELETE)
|
|
|
|
|
.setShowsUserInterface(false)
|
|
|
|
|
.setAllowGeneratedReplies(false);
|
|
|
|
|
mbuilder.addAction(actionTrash.build());
|
|
|
|
|
|
|
|
|
@ -3832,6 +3847,7 @@ class Core {
|
|
|
|
|
R.drawable.twotone_report_problem_24,
|
|
|
|
|
context.getString(R.string.title_advanced_notify_action_junk),
|
|
|
|
|
piJunk)
|
|
|
|
|
.setShowsUserInterface(false)
|
|
|
|
|
.setAllowGeneratedReplies(false);
|
|
|
|
|
mbuilder.addAction(actionJunk.build());
|
|
|
|
|
|
|
|
|
@ -3850,6 +3866,7 @@ class Core {
|
|
|
|
|
context.getString(R.string.title_advanced_notify_action_archive),
|
|
|
|
|
piArchive)
|
|
|
|
|
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_ARCHIVE)
|
|
|
|
|
.setShowsUserInterface(false)
|
|
|
|
|
.setAllowGeneratedReplies(false);
|
|
|
|
|
mbuilder.addAction(actionArchive.build());
|
|
|
|
|
|
|
|
|
@ -3870,6 +3887,7 @@ class Core {
|
|
|
|
|
R.drawable.twotone_folder_24,
|
|
|
|
|
folder.getDisplayName(context),
|
|
|
|
|
piMove)
|
|
|
|
|
.setShowsUserInterface(false)
|
|
|
|
|
.setAllowGeneratedReplies(false);
|
|
|
|
|
mbuilder.addAction(actionMove.build());
|
|
|
|
|
|
|
|
|
@ -3890,7 +3908,7 @@ class Core {
|
|
|
|
|
R.drawable.twotone_reply_24,
|
|
|
|
|
context.getString(R.string.title_advanced_notify_action_reply),
|
|
|
|
|
piReply)
|
|
|
|
|
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_REPLY)
|
|
|
|
|
.setShowsUserInterface(true)
|
|
|
|
|
.setAllowGeneratedReplies(false);
|
|
|
|
|
mbuilder.addAction(actionReply.build());
|
|
|
|
|
}
|
|
|
|
@ -3909,6 +3927,7 @@ class Core {
|
|
|
|
|
context.getString(R.string.title_advanced_notify_action_reply_direct),
|
|
|
|
|
piReply)
|
|
|
|
|
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_REPLY)
|
|
|
|
|
.setShowsUserInterface(false)
|
|
|
|
|
.setAllowGeneratedReplies(false);
|
|
|
|
|
RemoteInput.Builder input = new RemoteInput.Builder("text")
|
|
|
|
|
.setLabel(context.getString(R.string.title_advanced_notify_action_reply));
|
|
|
|
@ -3927,6 +3946,7 @@ class Core {
|
|
|
|
|
context.getString(R.string.title_advanced_notify_action_flag),
|
|
|
|
|
piFlag)
|
|
|
|
|
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_THUMBS_UP)
|
|
|
|
|
.setShowsUserInterface(false)
|
|
|
|
|
.setAllowGeneratedReplies(false);
|
|
|
|
|
mbuilder.addAction(actionFlag.build());
|
|
|
|
|
|
|
|
|
@ -3943,6 +3963,7 @@ class Core {
|
|
|
|
|
context.getString(R.string.title_advanced_notify_action_seen),
|
|
|
|
|
piSeen)
|
|
|
|
|
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_MARK_AS_READ)
|
|
|
|
|
.setShowsUserInterface(false)
|
|
|
|
|
.setAllowGeneratedReplies(false);
|
|
|
|
|
mbuilder.addAction(actionSeen.build());
|
|
|
|
|
|
|
|
|
@ -3959,6 +3980,7 @@ class Core {
|
|
|
|
|
context.getString(R.string.title_advanced_notify_action_snooze),
|
|
|
|
|
piSnooze)
|
|
|
|
|
.setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_MUTE)
|
|
|
|
|
.setShowsUserInterface(false)
|
|
|
|
|
.setAllowGeneratedReplies(false);
|
|
|
|
|
mbuilder.addAction(actionSnooze.build());
|
|
|
|
|
|
|
|
|
@ -3998,20 +4020,35 @@ class Core {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Device
|
|
|
|
|
StringBuilder sbm = new StringBuilder();
|
|
|
|
|
if (!TextUtils.isEmpty(message.subject))
|
|
|
|
|
sbm.append("<em>").append(message.subject).append("</em>").append("<br>");
|
|
|
|
|
if (messagingStyle == null) {
|
|
|
|
|
StringBuilder sbm = new StringBuilder();
|
|
|
|
|
if (!TextUtils.isEmpty(message.subject))
|
|
|
|
|
sbm.append("<em>").append(message.subject).append("</em>").append("<br>");
|
|
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(preview))
|
|
|
|
|
sbm.append(preview);
|
|
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(preview))
|
|
|
|
|
sbm.append(preview);
|
|
|
|
|
if (sbm.length() > 0) {
|
|
|
|
|
NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle()
|
|
|
|
|
.bigText(HtmlHelper.fromHtml(sbm.toString(), true, context));
|
|
|
|
|
if (!TextUtils.isEmpty(message.subject))
|
|
|
|
|
bigText.setSummaryText(message.subject);
|
|
|
|
|
|
|
|
|
|
if (sbm.length() > 0) {
|
|
|
|
|
NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle()
|
|
|
|
|
.bigText(HtmlHelper.fromHtml(sbm.toString(), true, context));
|
|
|
|
|
if (!TextUtils.isEmpty(message.subject))
|
|
|
|
|
bigText.setSummaryText(message.subject);
|
|
|
|
|
mbuilder.setStyle(bigText);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Person.Builder you = new Person.Builder()
|
|
|
|
|
.setName(MessageHelper.formatAddresses(message.from, name_email, false));
|
|
|
|
|
|
|
|
|
|
if (info[0].hasPhoto())
|
|
|
|
|
you.setIcon(IconCompat.createWithBitmap(info[0].getPhotoBitmap()));
|
|
|
|
|
|
|
|
|
|
if (info[0].hasLookupUri())
|
|
|
|
|
you.setUri(info[0].getLookupUri().toString());
|
|
|
|
|
|
|
|
|
|
messagingStyle.addMessage(preview == null ? "" : preview, message.received, you.build());
|
|
|
|
|
|
|
|
|
|
mbuilder.setStyle(bigText);
|
|
|
|
|
mbuilder.setStyle(messagingStyle);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (!TextUtils.isEmpty(message.subject))
|
|
|
|
|