mirror of https://github.com/M66B/FairEmail.git
Allow ignoring individual messages
This commit is contained in:
parent
3d5e4ca4a2
commit
1527208327
File diff suppressed because it is too large
Load Diff
|
@ -437,6 +437,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
draft.ui_flagged = false;
|
||||
draft.ui_hide = false;
|
||||
draft.ui_found = false;
|
||||
draft.ui_ignored = false;
|
||||
draft.id = db.message().insertMessage(draft);
|
||||
draft.write(context, body);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ import androidx.sqlite.db.SupportSQLiteDatabase;
|
|||
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||
|
||||
@Database(
|
||||
version = 20,
|
||||
version = 21,
|
||||
entities = {
|
||||
EntityIdentity.class,
|
||||
EntityAccount.class,
|
||||
|
@ -257,6 +257,14 @@ public abstract class DB extends RoomDatabase {
|
|||
db.execSQL("ALTER TABLE `folder` ADD COLUMN `poll_interval` INTEGER");
|
||||
}
|
||||
})
|
||||
.addMigrations(new Migration(20, 21) {
|
||||
@Override
|
||||
public void migrate(SupportSQLiteDatabase db) {
|
||||
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("ALTER TABLE `message` ADD COLUMN `ui_ignored` INTEGER NOT NULL DEFAULT 0");
|
||||
db.execSQL("CREATE INDEX `index_message_ui_ignored` ON `message` (`ui_ignored`)");
|
||||
}
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -159,7 +159,9 @@ public interface DaoMessage {
|
|||
" JOIN folder ON folder.id = message.folder" +
|
||||
" WHERE account.`synchronize`" +
|
||||
" AND folder.unified" +
|
||||
" AND NOT message.ui_seen AND NOT message.ui_hide" +
|
||||
" AND NOT message.ui_seen" +
|
||||
" AND NOT message.ui_hide" +
|
||||
" AND NOT message.ui_ignored" +
|
||||
" ORDER BY message.received")
|
||||
LiveData<List<EntityMessage>> liveUnseenUnified();
|
||||
|
||||
|
@ -194,6 +196,9 @@ public interface DaoMessage {
|
|||
@Query("UPDATE message SET ui_hide = :ui_hide WHERE id = :id")
|
||||
int setMessageUiHide(long id, boolean ui_hide);
|
||||
|
||||
@Query("UPDATE message SET ui_ignored = :ui_ignored WHERE id = :id")
|
||||
int setMessageUiIgnored(long id, boolean ui_ignored);
|
||||
|
||||
@Query("UPDATE message SET error = :error WHERE id = :id")
|
||||
int setMessageError(long id, String error);
|
||||
|
||||
|
|
|
@ -64,7 +64,8 @@ import static androidx.room.ForeignKey.CASCADE;
|
|||
@Index(value = {"received"}),
|
||||
@Index(value = {"ui_seen"}),
|
||||
@Index(value = {"ui_hide"}),
|
||||
@Index(value = {"ui_found"})
|
||||
@Index(value = {"ui_found"}),
|
||||
@Index(value = {"ui_ignored"})
|
||||
}
|
||||
)
|
||||
public class EntityMessage implements Serializable {
|
||||
|
@ -111,6 +112,8 @@ public class EntityMessage implements Serializable {
|
|||
public Boolean ui_hide;
|
||||
@NonNull
|
||||
public Boolean ui_found;
|
||||
@NonNull
|
||||
public Boolean ui_ignored;
|
||||
public String error;
|
||||
|
||||
@Ignore
|
||||
|
@ -211,6 +214,7 @@ public class EntityMessage implements Serializable {
|
|||
this.ui_flagged.equals(other.ui_flagged) &&
|
||||
this.ui_hide.equals(other.ui_hide) &&
|
||||
this.ui_found.equals(other.ui_found) &&
|
||||
this.ui_ignored.equals(other.ui_ignored) &&
|
||||
(this.error == null ? other.error == null : this.error.equals(other.error)));
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -152,6 +152,7 @@ public class FragmentAbout extends FragmentEx {
|
|||
draft.ui_flagged = false;
|
||||
draft.ui_hide = false;
|
||||
draft.ui_found = false;
|
||||
draft.ui_ignored = false;
|
||||
draft.id = db.message().insertMessage(draft);
|
||||
draft.write(context, body);
|
||||
|
||||
|
|
|
@ -959,6 +959,7 @@ public class FragmentCompose extends FragmentEx {
|
|||
draft.ui_flagged = false;
|
||||
draft.ui_hide = false;
|
||||
draft.ui_found = false;
|
||||
draft.ui_ignored = false;
|
||||
|
||||
draft.id = db.message().insertMessage(draft);
|
||||
draft.write(context, body == null ? "" : body);
|
||||
|
|
|
@ -137,6 +137,7 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
|
||||
static final int PI_SEEN = 1;
|
||||
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_PROCESS_OPERATIONS = BuildConfig.APPLICATION_ID + ".PROCESS_OPERATIONS";
|
||||
|
@ -237,7 +238,7 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
serviceManager.queue_stop();
|
||||
else if ("reload".equals(action))
|
||||
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();
|
||||
args.putLong("id", Long.parseLong(action.split(":")[1]));
|
||||
args.putString("action", action.split(":")[0]);
|
||||
|
@ -261,7 +262,8 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
EntityFolder trash = db.folder().getFolderByType(message.account, EntityFolder.TRASH);
|
||||
if (trash != null)
|
||||
EntityOperation.queue(db, message, EntityOperation.MOVE, trash.id);
|
||||
}
|
||||
} else if ("ignored".equals(action))
|
||||
db.message().setMessageUiIgnored(message.id, true);
|
||||
|
||||
db.setTransactionSuccessful();
|
||||
} finally {
|
||||
|
@ -272,11 +274,6 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLoaded(Bundle args, Void data) {
|
||||
Log.i(Helper.TAG, "Set seen");
|
||||
}
|
||||
}.load(this, args);
|
||||
}
|
||||
}
|
||||
|
@ -391,9 +388,13 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
Intent thread = new Intent(this, ActivityView.class);
|
||||
thread.setAction("thread:" + message.id);
|
||||
thread.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
PendingIntent piThread = PendingIntent.getActivity(
|
||||
PendingIntent piContent = PendingIntent.getActivity(
|
||||
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);
|
||||
seen.setAction("seen:" + message.id);
|
||||
PendingIntent piSeen = PendingIntent.getService(this, PI_SEEN, seen, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
@ -422,10 +423,10 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
.addExtras(args)
|
||||
.setSmallIcon(R.drawable.baseline_mail_24)
|
||||
.setContentTitle(MessageHelper.getFormattedAddresses(message.from, true))
|
||||
.setContentIntent(piThread)
|
||||
.setContentIntent(piContent)
|
||||
.setSound(uri)
|
||||
.setWhen(message.sent == null ? message.received : message.sent)
|
||||
.setOngoing(true)
|
||||
.setDeleteIntent(piDelete)
|
||||
.setPriority(Notification.PRIORITY_DEFAULT)
|
||||
.setCategory(Notification.CATEGORY_STATUS)
|
||||
.setVisibility(Notification.VISIBILITY_PRIVATE)
|
||||
|
@ -1694,6 +1695,7 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
message.ui_flagged = false;
|
||||
message.ui_hide = false;
|
||||
message.ui_found = found;
|
||||
message.ui_ignored = false;
|
||||
|
||||
if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_CONTACTS)
|
||||
== PackageManager.PERMISSION_GRANTED) {
|
||||
|
|
Loading…
Reference in New Issue