Browse Source

Allow ignoring individual messages

main
M66B 6 years ago
parent
commit
1527208327
8 changed files with 1049 additions and 13 deletions
  1. +1014
    -0
      app/schemas/eu.faircode.email.DB/21.json
  2. +1
    -0
      app/src/main/java/eu/faircode/email/ActivityView.java
  3. +9
    -1
      app/src/main/java/eu/faircode/email/DB.java
  4. +6
    -1
      app/src/main/java/eu/faircode/email/DaoMessage.java
  5. +5
    -1
      app/src/main/java/eu/faircode/email/EntityMessage.java
  6. +1
    -0
      app/src/main/java/eu/faircode/email/FragmentAbout.java
  7. +1
    -0
      app/src/main/java/eu/faircode/email/FragmentCompose.java
  8. +12
    -10
      app/src/main/java/eu/faircode/email/ServiceSynchronize.java

+ 1014
- 0
app/schemas/eu.faircode.email.DB/21.json
File diff suppressed because it is too large
View File


+ 1
- 0
app/src/main/java/eu/faircode/email/ActivityView.java View File

@ -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);
}


+ 9
- 1
app/src/main/java/eu/faircode/email/DB.java View File

@ -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();
}


+ 6
- 1
app/src/main/java/eu/faircode/email/DaoMessage.java View File

@ -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);


+ 5
- 1
app/src/main/java/eu/faircode/email/EntityMessage.java View File

@ -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;


+ 1
- 0
app/src/main/java/eu/faircode/email/FragmentAbout.java View File

@ -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);


+ 1
- 0
app/src/main/java/eu/faircode/email/FragmentCompose.java View File

@ -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);


+ 12
- 10
app/src/main/java/eu/faircode/email/ServiceSynchronize.java View File

@ -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…
Cancel
Save