mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-25 15:32:52 +00:00
Added send idle status
This commit is contained in:
parent
f88a1c8064
commit
d9e5608b89
4 changed files with 52 additions and 9 deletions
|
@ -87,12 +87,15 @@ public interface DaoOperation {
|
|||
" AND (NOT folder.account IS NULL OR identity.synchronize IS NULL OR identity.synchronize)")
|
||||
LiveData<TupleOperationStats> liveStats();
|
||||
|
||||
@Query("SELECT COUNT(operation.id) FROM operation" +
|
||||
@Query("SELECT" +
|
||||
" COUNT(operation.id) AS count" +
|
||||
", SUM(CASE WHEN operation.state = 'executing' THEN 1 ELSE 0 END) AS busy" +
|
||||
" FROM operation" +
|
||||
" JOIN message ON message.id = operation.message" +
|
||||
" JOIN identity ON identity.id = message.identity" +
|
||||
" WHERE operation.name = '" + EntityOperation.SEND + "'" +
|
||||
" AND identity.synchronize")
|
||||
LiveData<Integer> liveUnsent();
|
||||
LiveData<TupleUnsent> liveUnsent();
|
||||
|
||||
@Query("SELECT * FROM operation ORDER BY id")
|
||||
List<EntityOperation> getOperations();
|
||||
|
|
|
@ -63,7 +63,7 @@ import javax.mail.internet.MimeMessage;
|
|||
import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
|
||||
|
||||
public class ServiceSend extends ServiceBase {
|
||||
private int lastUnsent = 0;
|
||||
private TupleUnsent lastUnsent = null;
|
||||
private boolean lastSuitable = false;
|
||||
|
||||
private PowerManager.WakeLock wlOutbox;
|
||||
|
@ -83,10 +83,10 @@ public class ServiceSend extends ServiceBase {
|
|||
|
||||
// Observe unsent count
|
||||
DB db = DB.getInstance(this);
|
||||
db.operation().liveUnsent().observe(this, new Observer<Integer>() {
|
||||
db.operation().liveUnsent().observe(this, new Observer<TupleUnsent>() {
|
||||
@Override
|
||||
public void onChanged(Integer unsent) {
|
||||
if (unsent != null && lastUnsent != unsent) {
|
||||
public void onChanged(TupleUnsent unsent) {
|
||||
if (unsent == null || !unsent.equals(lastUnsent)) {
|
||||
lastUnsent = unsent;
|
||||
|
||||
try {
|
||||
|
@ -188,9 +188,11 @@ public class ServiceSend extends ServiceBase {
|
|||
.setCategory(NotificationCompat.CATEGORY_SERVICE)
|
||||
.setVisibility(NotificationCompat.VISIBILITY_SECRET);
|
||||
|
||||
if (lastUnsent > 0)
|
||||
if (lastUnsent != null)
|
||||
builder.setContentText(getResources().getQuantityString(
|
||||
R.plurals.title_notification_unsent, lastUnsent, lastUnsent));
|
||||
R.plurals.title_notification_unsent, lastUnsent.count, lastUnsent.count));
|
||||
if (lastUnsent == null || lastUnsent.busy == 0)
|
||||
builder.setSubText(getString(R.string.title_notification_idle));
|
||||
if (!lastSuitable)
|
||||
builder.setSubText(getString(R.string.title_notification_waiting));
|
||||
|
||||
|
|
37
app/src/main/java/eu/faircode/email/TupleUnsent.java
Normal file
37
app/src/main/java/eu/faircode/email/TupleUnsent.java
Normal file
|
@ -0,0 +1,37 @@
|
|||
package eu.faircode.email;
|
||||
|
||||
/*
|
||||
This file is part of FairEmail.
|
||||
|
||||
FairEmail is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
FairEmail is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with FairEmail. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright 2018-2020 by Marcel Bokhorst (M66B)
|
||||
*/
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class TupleUnsent {
|
||||
public Integer count;
|
||||
public Integer busy;
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (obj instanceof TupleUnsent) {
|
||||
TupleUnsent other = (TupleUnsent) obj;
|
||||
return (this.count.equals(other.count) &&
|
||||
this.busy.equals(other.busy));
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -93,8 +93,9 @@
|
|||
Creating and using rules is a pro feature.
|
||||
</string>
|
||||
|
||||
<string name="title_notification_waiting">Waiting for suitable connection</string>
|
||||
<string name="title_notification_sending">Sending messages</string>
|
||||
<string name="title_notification_waiting">Waiting for suitable connection</string>
|
||||
<string name="title_notification_idle">Idle</string>
|
||||
<string name="title_notification_failed">\'%1$s\' failed</string>
|
||||
<string name="title_notification_alert">\'%1$s\' server alert</string>
|
||||
|
||||
|
|
Loading…
Reference in a new issue