mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-23 22:51:02 +00:00
Show number of unsent messages
This commit is contained in:
parent
d9875de010
commit
670c0f04ae
4 changed files with 24 additions and 9 deletions
|
@ -45,17 +45,21 @@ public interface DaoAccount {
|
|||
LiveData<EntityAccount> 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<TupleAccountStats> liveStats();
|
||||
|
||||
@Insert
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -23,4 +23,5 @@ public class TupleAccountStats {
|
|||
public Integer accounts;
|
||||
public Integer operations;
|
||||
public Integer unseen;
|
||||
public Integer unsent;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,12 @@
|
|||
<item quantity="other">%1$d new messages</item>
|
||||
</plurals>
|
||||
|
||||
<plurals name="title_notification_unsent">
|
||||
<item quantity="zero"></item>
|
||||
<item quantity="one">%1$d unsent message</item>
|
||||
<item quantity="other">%1$d unsent messages</item>
|
||||
</plurals>
|
||||
|
||||
<string name="title_notification_failed">\'%1$s\' failed</string>
|
||||
|
||||
<string name="menu_setup">Setup</string>
|
||||
|
|
Loading…
Reference in a new issue