Clear group

pull/162/head
M66B 6 years ago
parent d11684c5aa
commit 8d426f747b

@ -1922,7 +1922,7 @@ class Core {
} }
} }
static void notifyMessages(Context context, List<TupleMessageEx> messages, Map<String, List<Long>> groupNotifying) { static void notifyMessages(Context context, List<TupleMessageEx> messages, Map<Long, List<Long>> groupNotifying) {
if (messages == null) if (messages == null)
messages = new ArrayList<>(); messages = new ArrayList<>();
Log.i("Notify messages=" + messages.size()); Log.i("Notify messages=" + messages.size());
@ -1937,8 +1937,8 @@ class Core {
boolean pro = ActivityBilling.isPro(context); boolean pro = ActivityBilling.isPro(context);
int unseen = 0; int unseen = 0;
Map<String, List<TupleMessageEx>> groupMessages = new HashMap<>(); Map<Long, List<TupleMessageEx>> groupMessages = new HashMap<>();
for (String group : groupNotifying.keySet()) for (long group : groupNotifying.keySet())
groupMessages.put(group, new ArrayList<>()); groupMessages.put(group, new ArrayList<>());
// Current // Current
@ -1955,7 +1955,7 @@ class Core {
continue; continue;
} }
String group = Long.toString(pro && message.accountNotify ? message.account : 0); long group = (pro && message.accountNotify ? message.account : 0);
if (!groupMessages.containsKey(group)) { if (!groupMessages.containsKey(group)) {
groupNotifying.put(group, new ArrayList<Long>()); groupNotifying.put(group, new ArrayList<Long>());
groupMessages.put(group, new ArrayList<TupleMessageEx>()); groupMessages.put(group, new ArrayList<TupleMessageEx>());
@ -1986,7 +1986,7 @@ class Core {
} }
// Difference // Difference
for (String group : groupMessages.keySet()) { for (long group : groupMessages.keySet()) {
// Difference // Difference
final List<Long> add = new ArrayList<>(); final List<Long> add = new ArrayList<>();
final List<Long> remove = new ArrayList<>(groupNotifying.get(group)); final List<Long> remove = new ArrayList<>(groupNotifying.get(group));
@ -2051,7 +2051,7 @@ class Core {
groupNotifying.clear(); groupNotifying.clear();
} }
private static List<Notification> getNotificationUnseen(Context context, String group, List<TupleMessageEx> messages) { private static List<Notification> getNotificationUnseen(Context context, long group, List<TupleMessageEx> messages) {
List<Notification> notifications = new ArrayList<>(); List<Notification> notifications = new ArrayList<>();
// Android 7+ N https://developer.android.com/training/notify-user/group // Android 7+ N https://developer.android.com/training/notify-user/group
@ -2088,7 +2088,7 @@ class Core {
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);
Intent clear = new Intent(context, ServiceUI.class).setAction("clear"); Intent clear = new Intent(context, ServiceUI.class).setAction("clear:" + group);
PendingIntent piClear = PendingIntent.getService(context, ServiceUI.PI_CLEAR, clear, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piClear = PendingIntent.getService(context, ServiceUI.PI_CLEAR, clear, PendingIntent.FLAG_UPDATE_CURRENT);
// Build title // Build title
@ -2107,7 +2107,7 @@ class Core {
.setPriority(NotificationCompat.PRIORITY_DEFAULT) .setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setCategory(NotificationCompat.CATEGORY_STATUS) .setCategory(NotificationCompat.CATEGORY_STATUS)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setGroup(group) .setGroup(Long.toString(group))
.setGroupSummary(true) .setGroupSummary(true)
.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN); .setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN);
@ -2192,7 +2192,7 @@ class Core {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
mbuilder mbuilder
.setGroup(group) .setGroup(Long.toString(group))
.setGroupSummary(false) .setGroupSummary(false)
.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN); .setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN);

@ -427,9 +427,10 @@ public interface DaoMessage {
int setMessageLastAttempt(long id, long last_attempt); int setMessageLastAttempt(long id, long last_attempt);
@Query("UPDATE message SET ui_ignored = 1" + @Query("UPDATE message SET ui_ignored = 1" +
" WHERE NOT ui_ignored" + " WHERE (:account IS NULL OR account = :account)" +
" AND folder IN (SELECT id FROM folder WHERE type = '" + EntityFolder.INBOX + "')") " AND NOT ui_ignored" +
int ignoreAll(); " AND folder IN (SELECT id FROM folder WHERE folder.unified)")
int ignoreAll(Long account);
@Query("UPDATE message SET ui_found = 1" + @Query("UPDATE message SET ui_found = 1" +
" WHERE account = :account" + " WHERE account = :account" +

@ -165,7 +165,7 @@ public class ServiceSynchronize extends ServiceBase {
} }
}); });
Map<String, List<Long>> groupNotifying = new HashMap<>(); Map<Long, List<Long>> groupNotifying = new HashMap<>();
// Get existing notifications // Get existing notifications
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
@ -174,7 +174,7 @@ public class ServiceSynchronize extends ServiceBase {
String tag = sbn.getTag(); String tag = sbn.getTag();
if (tag != null && tag.startsWith("unseen.")) { if (tag != null && tag.startsWith("unseen.")) {
String[] p = tag.split(("\\.")); String[] p = tag.split(("\\."));
String group = p[1]; long group = Long.parseLong(p[1]);
long id = Long.parseLong(p[2]); long id = Long.parseLong(p[2]);
if (!groupNotifying.containsKey(group)) if (!groupNotifying.containsKey(group))

@ -91,7 +91,7 @@ public class ServiceUI extends IntentService {
switch (parts[0]) { switch (parts[0]) {
case "clear": case "clear":
onClear(); onClear(id);
break; break;
case "trash": case "trash":
@ -139,8 +139,10 @@ public class ServiceUI extends IntentService {
} }
} }
private void onClear() { private void onClear(long group) {
DB.getInstance(this).message().ignoreAll(); DB db = DB.getInstance(this);
int cleared = db.message().ignoreAll(group == 0 ? null : group);
Log.i("Cleared=" + cleared);
} }
private void cancel(String group, long id) { private void cancel(String group, long id) {

Loading…
Cancel
Save