|
|
@ -1715,8 +1715,12 @@ class Core {
|
|
|
|
return notifications;
|
|
|
|
return notifications;
|
|
|
|
|
|
|
|
|
|
|
|
boolean pro = Helper.isPro(context);
|
|
|
|
boolean pro = Helper.isPro(context);
|
|
|
|
|
|
|
|
boolean canGroup = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N);
|
|
|
|
|
|
|
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
boolean flags = prefs.getBoolean("flags", true);
|
|
|
|
boolean flags = prefs.getBoolean("flags", true);
|
|
|
|
|
|
|
|
boolean notify_group = (prefs.getBoolean("notify_group", true) && canGroup);
|
|
|
|
|
|
|
|
boolean notify_preview = prefs.getBoolean("notify_preview", true);
|
|
|
|
boolean notify_trash = prefs.getBoolean("notify_trash", true);
|
|
|
|
boolean notify_trash = prefs.getBoolean("notify_trash", true);
|
|
|
|
boolean notify_archive = prefs.getBoolean("notify_archive", true);
|
|
|
|
boolean notify_archive = prefs.getBoolean("notify_archive", true);
|
|
|
|
boolean notify_reply = prefs.getBoolean("notify_reply", false);
|
|
|
|
boolean notify_reply = prefs.getBoolean("notify_reply", false);
|
|
|
@ -1730,6 +1734,7 @@ class Core {
|
|
|
|
for (TupleMessageEx message : messages)
|
|
|
|
for (TupleMessageEx message : messages)
|
|
|
|
messageContact.put(message, ContactInfo.get(context, message.from, false));
|
|
|
|
messageContact.put(message, ContactInfo.get(context, message.from, false));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (notify_group) {
|
|
|
|
// Build pending intents
|
|
|
|
// Build pending intents
|
|
|
|
Intent summary = new Intent(context, ActivityView.class).setAction("unified");
|
|
|
|
Intent summary = new Intent(context, ActivityView.class).setAction("unified");
|
|
|
|
PendingIntent piSummary = PendingIntent.getActivity(context, ActivityView.REQUEST_UNIFIED, summary, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
PendingIntent piSummary = PendingIntent.getActivity(context, ActivityView.REQUEST_UNIFIED, summary, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
@ -1762,17 +1767,7 @@ class Core {
|
|
|
|
.setPublicVersion(pub);
|
|
|
|
.setPublicVersion(pub);
|
|
|
|
|
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
|
|
|
boolean light = prefs.getBoolean("light", false);
|
|
|
|
setNotificationSoundAndLight(context, builder);
|
|
|
|
String sound = prefs.getString("sound", null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (light)
|
|
|
|
|
|
|
|
builder.setLights(Color.GREEN, 1000, 1000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Uri uri = (sound == null ? null : Uri.parse(sound));
|
|
|
|
|
|
|
|
if (uri == null || "file".equals(uri.getScheme()))
|
|
|
|
|
|
|
|
uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
|
|
|
|
|
|
|
|
builder.setSound(uri);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
builder.setOnlyAlertOnce(true);
|
|
|
|
builder.setOnlyAlertOnce(true);
|
|
|
|
} else
|
|
|
|
} else
|
|
|
|
builder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN);
|
|
|
|
builder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN);
|
|
|
@ -1792,8 +1787,9 @@ class Core {
|
|
|
|
.setSummaryText(title));
|
|
|
|
.setSummaryText(title));
|
|
|
|
|
|
|
|
|
|
|
|
notifications.add(builder.build());
|
|
|
|
notifications.add(builder.build());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
boolean preview = prefs.getBoolean("notify_preview", true);
|
|
|
|
// Message notifications
|
|
|
|
for (TupleMessageEx message : messages) {
|
|
|
|
for (TupleMessageEx message : messages) {
|
|
|
|
ContactInfo info = messageContact.get(message);
|
|
|
|
ContactInfo info = messageContact.get(message);
|
|
|
|
|
|
|
|
|
|
|
@ -1844,10 +1840,11 @@ class Core {
|
|
|
|
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
|
|
|
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
|
|
|
.setCategory(NotificationCompat.CATEGORY_MESSAGE)
|
|
|
|
.setCategory(NotificationCompat.CATEGORY_MESSAGE)
|
|
|
|
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
|
|
|
|
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
|
|
|
|
.setGroup(group)
|
|
|
|
|
|
|
|
.setGroupSummary(false)
|
|
|
|
|
|
|
|
.setOnlyAlertOnce(true);
|
|
|
|
.setOnlyAlertOnce(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (notify_group)
|
|
|
|
|
|
|
|
mbuilder.setGroup(group).setGroupSummary(false);
|
|
|
|
|
|
|
|
|
|
|
|
if (notify_trash) {
|
|
|
|
if (notify_trash) {
|
|
|
|
Intent trash = new Intent(context, ServiceUI.class).setAction("trash:" + message.id);
|
|
|
|
Intent trash = new Intent(context, ServiceUI.class).setAction("trash:" + message.id);
|
|
|
|
PendingIntent piTrash = PendingIntent.getService(context, ServiceUI.PI_TRASH, trash, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
PendingIntent piTrash = PendingIntent.getService(context, ServiceUI.PI_TRASH, trash, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
@ -1901,7 +1898,7 @@ class Core {
|
|
|
|
if (!TextUtils.isEmpty(message.subject))
|
|
|
|
if (!TextUtils.isEmpty(message.subject))
|
|
|
|
mbuilder.setContentText(message.subject);
|
|
|
|
mbuilder.setContentText(message.subject);
|
|
|
|
|
|
|
|
|
|
|
|
if (message.content && preview)
|
|
|
|
if (message.content && notify_preview)
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
String body = Helper.readText(message.getFile(context));
|
|
|
|
String body = Helper.readText(message.getFile(context));
|
|
|
|
StringBuilder sbm = new StringBuilder();
|
|
|
|
StringBuilder sbm = new StringBuilder();
|
|
|
@ -1934,10 +1931,15 @@ class Core {
|
|
|
|
mbuilder.setColorized(true);
|
|
|
|
mbuilder.setColorized(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
|
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
|
|
|
|
|
|
|
if (notify_group)
|
|
|
|
mbuilder.setSound(null);
|
|
|
|
mbuilder.setSound(null);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
|
|
|
|
setNotificationSoundAndLight(context, mbuilder);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (notify_group)
|
|
|
|
mbuilder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN);
|
|
|
|
mbuilder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
notifications.add(mbuilder.build());
|
|
|
|
notifications.add(mbuilder.build());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1945,6 +1947,20 @@ class Core {
|
|
|
|
return notifications;
|
|
|
|
return notifications;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void setNotificationSoundAndLight(Context context, NotificationCompat.Builder builder) {
|
|
|
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
|
|
|
|
|
|
|
boolean light = prefs.getBoolean("light", false);
|
|
|
|
|
|
|
|
String sound = prefs.getString("sound", null);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (light)
|
|
|
|
|
|
|
|
builder.setLights(Color.GREEN, 1000, 1000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Uri uri = (sound == null ? null : Uri.parse(sound));
|
|
|
|
|
|
|
|
if (uri == null || "file".equals(uri.getScheme()))
|
|
|
|
|
|
|
|
uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
|
|
|
|
|
|
|
|
builder.setSound(uri);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void reportError(Context context, EntityAccount account, EntityFolder folder, Throwable ex) {
|
|
|
|
static void reportError(Context context, EntityAccount account, EntityFolder folder, Throwable ex) {
|
|
|
|
// FolderClosedException: can happen when no connectivity
|
|
|
|
// FolderClosedException: can happen when no connectivity
|
|
|
|
|
|
|
|
|
|
|
|