diff --git a/app/src/main/java/eu/faircode/email/DaoAccount.java b/app/src/main/java/eu/faircode/email/DaoAccount.java index 1087c83e..4029b703 100644 --- a/app/src/main/java/eu/faircode/email/DaoAccount.java +++ b/app/src/main/java/eu/faircode/email/DaoAccount.java @@ -45,17 +45,21 @@ public interface DaoAccount { LiveData liveAccount(long id); @Query("SELECT" + - " (SELECT COUNT(*) FROM account WHERE synchronize) AS accounts" + - ", (SELECT COUNT(*) FROM operation" + + " (SELECT COUNT(account.id) FROM account WHERE synchronize) AS accounts" + + ", (SELECT COUNT(operation.id) FROM operation" + " JOIN message ON message.id = operation.message" + " JOIN account ON account.id = message.account" + " WHERE synchronize) AS operations" + - ", (SELECT COUNT(*) FROM message" + + ", (SELECT COUNT(message.id) FROM message" + " JOIN account ON account.id = message.account" + " JOIN folder ON folder.id = message.folder" + " WHERE NOT message.ui_seen AND NOT message.ui_hide" + " AND (account.seen_until IS NULL OR message.received > account.seen_until)" + - " AND folder.type = '" + EntityFolder.INBOX + "') AS unseen") + " AND folder.type = '" + EntityFolder.INBOX + "') AS unseen" + + ", (SELECT COUNT(message.id) FROM message" + + " JOIN folder ON folder.id = message.folder" + + " WHERE NOT message.ui_seen" + + " AND folder.type = '" + EntityFolder.OUTBOX + "') AS unsent") LiveData liveStats(); @Insert diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index ce112b7b..8e5bde0e 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -118,7 +118,7 @@ public class ServiceSynchronize extends LifecycleService { public void onCreate() { Log.i(Helper.TAG, "Service create"); super.onCreate(); - startForeground(NOTIFICATION_SYNCHRONIZE, getNotificationService(0, 0).build()); + startForeground(NOTIFICATION_SYNCHRONIZE, getNotificationService(0, 0, 0).build()); // Listen for network changes ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); @@ -136,7 +136,7 @@ public class ServiceSynchronize extends LifecycleService { if (stats != null) { NotificationManager nm = getSystemService(NotificationManager.class); nm.notify(NOTIFICATION_SYNCHRONIZE, - getNotificationService(stats.accounts, stats.operations).build()); + getNotificationService(stats.accounts, stats.operations, stats.unsent).build()); if (stats.unseen > 0) { if (stats.unseen > prev_unseen) { @@ -192,7 +192,7 @@ public class ServiceSynchronize extends LifecycleService { return START_STICKY; } - private Notification.Builder getNotificationService(int accounts, int operations) { + private Notification.Builder getNotificationService(int accounts, int operations, int unsent) { // Build pending intent Intent intent = new Intent(this, ActivityView.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); @@ -217,7 +217,11 @@ public class ServiceSynchronize extends LifecycleService { .setVisibility(Notification.VISIBILITY_SECRET); if (operations > 0) - builder.setContentText(getResources().getQuantityString(R.plurals.title_notification_operations, operations, operations)); + builder.setStyle(new Notification.BigTextStyle().setSummaryText( + getResources().getQuantityString(R.plurals.title_notification_operations, operations, operations))); + + if (unsent > 0) + builder.setContentText(getResources().getQuantityString(R.plurals.title_notification_unsent, unsent, unsent)); return builder; } @@ -922,7 +926,7 @@ public class ServiceSynchronize extends LifecycleService { // Update state if (message.thread == null) message.thread = imessage.getMessageID(); - message.sent = new Date().getTime(); + message.sent = imessage.getSentDate().getTime(); message.seen = true; message.ui_seen = true; db.message().updateMessage(message); diff --git a/app/src/main/java/eu/faircode/email/TupleAccountStats.java b/app/src/main/java/eu/faircode/email/TupleAccountStats.java index 815ef9f0..3c062ea1 100644 --- a/app/src/main/java/eu/faircode/email/TupleAccountStats.java +++ b/app/src/main/java/eu/faircode/email/TupleAccountStats.java @@ -23,4 +23,5 @@ public class TupleAccountStats { public Integer accounts; public Integer operations; public Integer unseen; + public Integer unsent; } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ab6763a9..fd711908 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -23,6 +23,12 @@ %1$d new messages + + + %1$d unsent message + %1$d unsent messages + + \'%1$s\' failed Setup