|
|
@ -137,6 +137,7 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
|
|
|
|
|
|
|
static final int PI_SEEN = 1;
|
|
|
|
static final int PI_SEEN = 1;
|
|
|
|
static final int PI_TRASH = 2;
|
|
|
|
static final int PI_TRASH = 2;
|
|
|
|
|
|
|
|
static final int PI_IGNORED = 3;
|
|
|
|
|
|
|
|
|
|
|
|
static final String ACTION_SYNCHRONIZE_FOLDER = BuildConfig.APPLICATION_ID + ".SYNCHRONIZE_FOLDER";
|
|
|
|
static final String ACTION_SYNCHRONIZE_FOLDER = BuildConfig.APPLICATION_ID + ".SYNCHRONIZE_FOLDER";
|
|
|
|
static final String ACTION_PROCESS_OPERATIONS = BuildConfig.APPLICATION_ID + ".PROCESS_OPERATIONS";
|
|
|
|
static final String ACTION_PROCESS_OPERATIONS = BuildConfig.APPLICATION_ID + ".PROCESS_OPERATIONS";
|
|
|
@ -237,7 +238,7 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
serviceManager.queue_stop();
|
|
|
|
serviceManager.queue_stop();
|
|
|
|
else if ("reload".equals(action))
|
|
|
|
else if ("reload".equals(action))
|
|
|
|
serviceManager.queue_reload();
|
|
|
|
serviceManager.queue_reload();
|
|
|
|
else if (action.startsWith("seen:") || action.startsWith("trash:")) {
|
|
|
|
else if (action.startsWith("seen:") || action.startsWith("trash:") || action.startsWith("ignored:")) {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putLong("id", Long.parseLong(action.split(":")[1]));
|
|
|
|
args.putLong("id", Long.parseLong(action.split(":")[1]));
|
|
|
|
args.putString("action", action.split(":")[0]);
|
|
|
|
args.putString("action", action.split(":")[0]);
|
|
|
@ -261,7 +262,8 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
EntityFolder trash = db.folder().getFolderByType(message.account, EntityFolder.TRASH);
|
|
|
|
EntityFolder trash = db.folder().getFolderByType(message.account, EntityFolder.TRASH);
|
|
|
|
if (trash != null)
|
|
|
|
if (trash != null)
|
|
|
|
EntityOperation.queue(db, message, EntityOperation.MOVE, trash.id);
|
|
|
|
EntityOperation.queue(db, message, EntityOperation.MOVE, trash.id);
|
|
|
|
}
|
|
|
|
} else if ("ignored".equals(action))
|
|
|
|
|
|
|
|
db.message().setMessageUiIgnored(message.id, true);
|
|
|
|
|
|
|
|
|
|
|
|
db.setTransactionSuccessful();
|
|
|
|
db.setTransactionSuccessful();
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
@ -272,11 +274,6 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
protected void onLoaded(Bundle args, Void data) {
|
|
|
|
|
|
|
|
Log.i(Helper.TAG, "Set seen");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}.load(this, args);
|
|
|
|
}.load(this, args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -391,9 +388,13 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
Intent thread = new Intent(this, ActivityView.class);
|
|
|
|
Intent thread = new Intent(this, ActivityView.class);
|
|
|
|
thread.setAction("thread:" + message.id);
|
|
|
|
thread.setAction("thread:" + message.id);
|
|
|
|
thread.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
thread.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
PendingIntent piThread = PendingIntent.getActivity(
|
|
|
|
PendingIntent piContent = PendingIntent.getActivity(
|
|
|
|
this, ActivityView.REQUEST_THREAD, thread, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
this, ActivityView.REQUEST_THREAD, thread, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Intent ignored = new Intent(this, ServiceSynchronize.class);
|
|
|
|
|
|
|
|
ignored.setAction("ignored:" + message.id);
|
|
|
|
|
|
|
|
PendingIntent piDelete = PendingIntent.getService(this, PI_IGNORED, ignored, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
|
|
|
|
|
|
|
|
Intent seen = new Intent(this, ServiceSynchronize.class);
|
|
|
|
Intent seen = new Intent(this, ServiceSynchronize.class);
|
|
|
|
seen.setAction("seen:" + message.id);
|
|
|
|
seen.setAction("seen:" + message.id);
|
|
|
|
PendingIntent piSeen = PendingIntent.getService(this, PI_SEEN, seen, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
PendingIntent piSeen = PendingIntent.getService(this, PI_SEEN, seen, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
@ -422,10 +423,10 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
.addExtras(args)
|
|
|
|
.addExtras(args)
|
|
|
|
.setSmallIcon(R.drawable.baseline_mail_24)
|
|
|
|
.setSmallIcon(R.drawable.baseline_mail_24)
|
|
|
|
.setContentTitle(MessageHelper.getFormattedAddresses(message.from, true))
|
|
|
|
.setContentTitle(MessageHelper.getFormattedAddresses(message.from, true))
|
|
|
|
.setContentIntent(piThread)
|
|
|
|
.setContentIntent(piContent)
|
|
|
|
.setSound(uri)
|
|
|
|
.setSound(uri)
|
|
|
|
.setWhen(message.sent == null ? message.received : message.sent)
|
|
|
|
.setWhen(message.sent == null ? message.received : message.sent)
|
|
|
|
.setOngoing(true)
|
|
|
|
.setDeleteIntent(piDelete)
|
|
|
|
.setPriority(Notification.PRIORITY_DEFAULT)
|
|
|
|
.setPriority(Notification.PRIORITY_DEFAULT)
|
|
|
|
.setCategory(Notification.CATEGORY_STATUS)
|
|
|
|
.setCategory(Notification.CATEGORY_STATUS)
|
|
|
|
.setVisibility(Notification.VISIBILITY_PRIVATE)
|
|
|
|
.setVisibility(Notification.VISIBILITY_PRIVATE)
|
|
|
@ -1694,6 +1695,7 @@ public class ServiceSynchronize extends LifecycleService {
|
|
|
|
message.ui_flagged = false;
|
|
|
|
message.ui_flagged = false;
|
|
|
|
message.ui_hide = false;
|
|
|
|
message.ui_hide = false;
|
|
|
|
message.ui_found = found;
|
|
|
|
message.ui_found = found;
|
|
|
|
|
|
|
|
message.ui_ignored = false;
|
|
|
|
|
|
|
|
|
|
|
|
if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_CONTACTS)
|
|
|
|
if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_CONTACTS)
|
|
|
|
== PackageManager.PERMISSION_GRANTED) {
|
|
|
|
== PackageManager.PERMISSION_GRANTED) {
|
|
|
|