Made UI hide boolean again

pull/162/head
M66B 5 years ago
parent 51780f3d15
commit a1d49dba54

File diff suppressed because it is too large Load Diff

@ -813,7 +813,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (debug) { if (debug) {
String text = "error=" + error + String text = "error=" + error +
"\nuid=" + message.uid + " id=" + message.id + " " + DTF.format(new Date(message.received)) + "\nuid=" + message.uid + " id=" + message.id + " " + DTF.format(new Date(message.received)) +
"\n" + (message.ui_hide == 0 ? "" : "HIDDEN ") + "\n" + (message.ui_hide ? "HIDDEN " : "") +
"seen=" + message.seen + "/" + message.ui_seen + "seen=" + message.seen + "/" + message.ui_seen +
" unseen=" + message.unseen + " unseen=" + message.unseen +
" ignored=" + message.ui_ignored + " ignored=" + message.ui_ignored +

@ -123,7 +123,6 @@ class Core {
private static final int SYNC_BATCH_SIZE = 20; private static final int SYNC_BATCH_SIZE = 20;
private static final int DOWNLOAD_BATCH_SIZE = 20; private static final int DOWNLOAD_BATCH_SIZE = 20;
private static final long YIELD_DURATION = 200L; // milliseconds private static final long YIELD_DURATION = 200L; // milliseconds
private static final long MIN_HIDE = 60 * 1000L; // milliseconds
static void processOperations( static void processOperations(
Context context, Context context,
@ -353,7 +352,7 @@ class Core {
// Delete temporary copy in target folder // Delete temporary copy in target folder
if (newid != null) { if (newid != null) {
db.message().deleteMessage(newid); db.message().deleteMessage(newid);
db.message().setMessageUiHide(message.id, 0L); db.message().setMessageUiHide(message.id, false);
} }
} }
@ -1306,7 +1305,7 @@ class Core {
message.ui_seen = false; message.ui_seen = false;
message.ui_answered = false; message.ui_answered = false;
message.ui_flagged = false; message.ui_flagged = false;
message.ui_hide = 0L; message.ui_hide = false;
message.ui_found = false; message.ui_found = false;
message.ui_ignored = false; message.ui_ignored = false;
message.ui_browsed = false; message.ui_browsed = false;
@ -1691,7 +1690,7 @@ class Core {
Log.i(folder.name + " sent orphans=" + orphans.size()); Log.i(folder.name + " sent orphans=" + orphans.size());
for (EntityMessage orphan : orphans) { for (EntityMessage orphan : orphans) {
Log.i(folder.name + " adding orphan id=" + orphan.id); Log.i(folder.name + " adding orphan id=" + orphan.id);
if (orphan.content && orphan.ui_hide == 0L) if (orphan.content && !orphan.ui_hide)
EntityOperation.queue(context, orphan, EntityOperation.ADD); EntityOperation.queue(context, orphan, EntityOperation.ADD);
} }
} else { } else {
@ -1921,7 +1920,7 @@ class Core {
message.ui_seen = seen; message.ui_seen = seen;
message.ui_answered = answered; message.ui_answered = answered;
message.ui_flagged = flagged; message.ui_flagged = flagged;
message.ui_hide = 0L; message.ui_hide = false;
message.ui_found = false; message.ui_found = false;
message.ui_ignored = seen; message.ui_ignored = seen;
message.ui_browsed = browsed; message.ui_browsed = browsed;
@ -2067,10 +2066,10 @@ class Core {
" keywords=" + TextUtils.join(" ", keywords)); " keywords=" + TextUtils.join(" ", keywords));
} }
if (message.ui_hide != 0 && message.ui_hide + MIN_HIDE < new Date().getTime() && if (message.ui_hide &&
db.operation().getOperationCount(folder.id, message.id) == 0) { db.operation().getOperationCount(folder.id, message.id) == 0) {
update = true; update = true;
message.ui_hide = 0L; message.ui_hide = false;
Log.i(folder.name + " updated id=" + message.id + " uid=" + message.uid + " unhide"); Log.i(folder.name + " updated id=" + message.id + " uid=" + message.uid + " unhide");
} }
@ -2405,7 +2404,7 @@ class Core {
} }
} }
if (!(message.ui_seen || message.ui_ignored || message.ui_hide != 0)) { if (!(message.ui_seen || message.ui_ignored || message.ui_hide)) {
// This assumes the messages are properly ordered // This assumes the messages are properly ordered
if (groupMessages.get(group).size() < MAX_NOTIFICATION_COUNT) if (groupMessages.get(group).size() < MAX_NOTIFICATION_COUNT)
groupMessages.get(group).add(message); groupMessages.get(group).add(message);

@ -58,7 +58,7 @@ import io.requery.android.database.sqlite.RequerySQLiteOpenHelperFactory;
// https://developer.android.com/topic/libraries/architecture/room.html // https://developer.android.com/topic/libraries/architecture/room.html
@Database( @Database(
version = 103, version = 104,
entities = { entities = {
EntityIdentity.class, EntityIdentity.class,
EntityAccount.class, EntityAccount.class,
@ -1027,6 +1027,13 @@ public abstract class DB extends RoomDatabase {
db.execSQL("UPDATE `account` SET browse = 1 WHERE pop = 1"); db.execSQL("UPDATE `account` SET browse = 1 WHERE pop = 1");
} }
}) })
.addMigrations(new Migration(103, 104) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("UPDATE `message` SET ui_hide = 1 WHERE ui_hide <> 0");
}
})
.build(); .build();
} }

@ -53,7 +53,7 @@ public interface DaoAccount {
" AND folder.type <> '" + EntityFolder.DRAFTS + "'" + " AND folder.type <> '" + EntityFolder.DRAFTS + "'" +
" AND folder.type <> '" + EntityFolder.OUTBOX + "'" + " AND folder.type <> '" + EntityFolder.OUTBOX + "'" +
" AND NOT ui_seen" + " AND NOT ui_seen" +
" AND ui_hide = 0) AS unseen" + " AND NOT ui_hide) AS unseen" +
", (SELECT COUNT(identity.id)" + ", (SELECT COUNT(identity.id)" +
" FROM identity" + " FROM identity" +
" WHERE identity.account = account.id" + " WHERE identity.account = account.id" +

@ -40,7 +40,7 @@ public interface DaoFolder {
", COUNT(DISTINCT CASE WHEN rule.enabled THEN rule.id ELSE NULL END) rules" + ", COUNT(DISTINCT CASE WHEN rule.enabled THEN rule.id ELSE NULL END) rules" +
", COUNT(DISTINCT CASE WHEN message.ui_hide THEN NULL ELSE message.id END) AS messages" + ", COUNT(DISTINCT CASE WHEN message.ui_hide THEN NULL ELSE message.id END) AS messages" +
", COUNT(DISTINCT CASE WHEN message.content = 1 AND NOT message.ui_hide THEN message.id ELSE NULL END) AS content" + ", COUNT(DISTINCT CASE WHEN message.content = 1 AND NOT message.ui_hide THEN message.id ELSE NULL END) AS content" +
", COUNT(DISTINCT CASE WHEN message.ui_seen = 0 AND NOT message.ui_hide THEN message.id ELSE NULL END) AS unseen" + ", COUNT(DISTINCT CASE WHEN NOT message.ui_seen AND NOT message.ui_hide THEN message.id ELSE NULL END) AS unseen" +
", COUNT(DISTINCT CASE WHEN operation.state = 'executing' THEN operation.id ELSE NULL END) AS executing" + ", COUNT(DISTINCT CASE WHEN operation.state = 'executing' THEN operation.id ELSE NULL END) AS executing" +
" FROM folder" + " FROM folder" +
" LEFT JOIN account ON account.id = folder.account" + " LEFT JOIN account ON account.id = folder.account" +
@ -77,7 +77,7 @@ public interface DaoFolder {
", COUNT(DISTINCT CASE WHEN rule.enabled THEN rule.id ELSE NULL END) rules" + ", COUNT(DISTINCT CASE WHEN rule.enabled THEN rule.id ELSE NULL END) rules" +
", COUNT(DISTINCT CASE WHEN message.ui_hide THEN NULL ELSE message.id END) AS messages" + ", COUNT(DISTINCT CASE WHEN message.ui_hide THEN NULL ELSE message.id END) AS messages" +
", COUNT(DISTINCT CASE WHEN message.content = 1 AND NOT message.ui_hide THEN message.id ELSE NULL END) AS content" + ", COUNT(DISTINCT CASE WHEN message.content = 1 AND NOT message.ui_hide THEN message.id ELSE NULL END) AS content" +
", COUNT(DISTINCT CASE WHEN message.ui_seen = 0 AND NOT message.ui_hide THEN message.id ELSE NULL END) AS unseen" + ", COUNT(DISTINCT CASE WHEN NOT message.ui_seen AND NOT message.ui_hide THEN message.id ELSE NULL END) AS unseen" +
", COUNT(DISTINCT CASE WHEN operation.state = 'executing' THEN operation.id ELSE NULL END) AS executing" + ", COUNT(DISTINCT CASE WHEN operation.state = 'executing' THEN operation.id ELSE NULL END) AS executing" +
" FROM folder" + " FROM folder" +
" LEFT JOIN account ON account.id = folder.account" + " LEFT JOIN account ON account.id = folder.account" +
@ -97,7 +97,7 @@ public interface DaoFolder {
", COUNT(DISTINCT CASE WHEN rule.enabled THEN rule.id ELSE NULL END) rules" + ", COUNT(DISTINCT CASE WHEN rule.enabled THEN rule.id ELSE NULL END) rules" +
", COUNT(DISTINCT CASE WHEN message.ui_hide THEN NULL ELSE message.id END) AS messages" + ", COUNT(DISTINCT CASE WHEN message.ui_hide THEN NULL ELSE message.id END) AS messages" +
", COUNT(DISTINCT CASE WHEN message.content = 1 AND NOT message.ui_hide THEN message.id ELSE NULL END) AS content" + ", COUNT(DISTINCT CASE WHEN message.content = 1 AND NOT message.ui_hide THEN message.id ELSE NULL END) AS content" +
", COUNT(DISTINCT CASE WHEN message.ui_seen = 0 AND NOT message.ui_hide THEN message.id ELSE NULL END) AS unseen" + ", COUNT(DISTINCT CASE WHEN NOT message.ui_seen AND NOT message.ui_hide THEN message.id ELSE NULL END) AS unseen" +
", COUNT(DISTINCT CASE WHEN operation.state = 'executing' THEN operation.id ELSE NULL END) AS executing" + ", COUNT(DISTINCT CASE WHEN operation.state = 'executing' THEN operation.id ELSE NULL END) AS executing" +
" FROM folder" + " FROM folder" +
" JOIN account ON account.id = folder.account" + " JOIN account ON account.id = folder.account" +
@ -111,13 +111,13 @@ public interface DaoFolder {
@Query("SELECT folder.*" + @Query("SELECT folder.*" +
", account.`order` AS accountOrder, account.name AS accountName, account.color AS accountColor" + ", account.`order` AS accountOrder, account.name AS accountName, account.color AS accountColor" +
", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" + ", SUM(CASE WHEN NOT message.ui_seen THEN 1 ELSE 0 END) AS unseen" +
", SUM(CASE WHEN message.ui_snoozed IS NULL THEN 0 ELSE 1 END) AS snoozed" + ", SUM(CASE WHEN message.ui_snoozed IS NULL THEN 0 ELSE 1 END) AS snoozed" +
", (SELECT COUNT(operation.id) FROM operation WHERE operation.folder = folder.id) AS operations" + ", (SELECT COUNT(operation.id) FROM operation WHERE operation.folder = folder.id) AS operations" +
", (SELECT COUNT(operation.id) FROM operation WHERE operation.folder = folder.id AND operation.state = 'executing') AS executing" + ", (SELECT COUNT(operation.id) FROM operation WHERE operation.folder = folder.id AND operation.state = 'executing') AS executing" +
" FROM folder" + " FROM folder" +
" LEFT JOIN account ON account.id = folder.account" + " LEFT JOIN account ON account.id = folder.account" +
" LEFT JOIN message ON message.folder = folder.id AND message.ui_hide = 0" + " LEFT JOIN message ON message.folder = folder.id AND NOT message.ui_hide" +
" WHERE account.id IS NULL" + " WHERE account.id IS NULL" +
" OR (account.`synchronize` AND folder.navigation)" + " OR (account.`synchronize` AND folder.navigation)" +
" GROUP BY folder.id") " GROUP BY folder.id")
@ -134,7 +134,7 @@ public interface DaoFolder {
", COUNT(DISTINCT CASE WHEN rule.enabled THEN rule.id ELSE NULL END) rules" + ", COUNT(DISTINCT CASE WHEN rule.enabled THEN rule.id ELSE NULL END) rules" +
", COUNT(DISTINCT CASE WHEN message.ui_hide THEN NULL ELSE message.id END) AS messages" + ", COUNT(DISTINCT CASE WHEN message.ui_hide THEN NULL ELSE message.id END) AS messages" +
", COUNT(DISTINCT CASE WHEN message.content = 1 AND NOT message.ui_hide THEN message.id ELSE NULL END) AS content" + ", COUNT(DISTINCT CASE WHEN message.content = 1 AND NOT message.ui_hide THEN message.id ELSE NULL END) AS content" +
", COUNT(DISTINCT CASE WHEN message.ui_seen = 0 AND NOT message.ui_hide THEN message.id ELSE NULL END) AS unseen" + ", COUNT(DISTINCT CASE WHEN NOT message.ui_seen AND NOT message.ui_hide THEN message.id ELSE NULL END) AS unseen" +
", COUNT(DISTINCT CASE WHEN operation.state = 'executing' THEN operation.id ELSE NULL END) AS executing" + ", COUNT(DISTINCT CASE WHEN operation.state = 'executing' THEN operation.id ELSE NULL END) AS executing" +
" FROM folder" + " FROM folder" +
" LEFT JOIN account ON account.id = folder.account" + " LEFT JOIN account ON account.id = folder.account" +
@ -154,7 +154,7 @@ public interface DaoFolder {
List<EntityFolder> getSystemFolders(long account); List<EntityFolder> getSystemFolders(long account);
@Query("SELECT folder.type," + @Query("SELECT folder.type," +
" SUM(CASE WHEN NOT message.ui_seen AND message.ui_hide = 0 THEN 1 ELSE 0 END) AS unseen" + " SUM(CASE WHEN NOT message.ui_seen AND NOT message.ui_hide THEN 1 ELSE 0 END) AS unseen" +
" FROM folder" + " FROM folder" +
" JOIN account ON account.id = folder.account" + " JOIN account ON account.id = folder.account" +
" LEFT JOIN message ON message.folder = folder.id" + " LEFT JOIN message ON message.folder = folder.id" +

@ -62,7 +62,7 @@ public interface DaoMessage {
" LEFT JOIN identity ON identity.id = message.identity" + " LEFT JOIN identity ON identity.id = message.identity" +
" JOIN folder ON folder.id = message.folder" + " JOIN folder ON folder.id = message.folder" +
" WHERE account.`synchronize`" + " WHERE account.`synchronize`" +
" AND (message.ui_hide = 0 OR :debug)" + " AND (NOT message.ui_hide OR :debug)" +
" AND (NOT :found OR ui_found = :found)" + " AND (NOT :found OR ui_found = :found)" +
" GROUP BY account.id, CASE WHEN message.thread IS NULL OR NOT :threading THEN message.id ELSE message.thread END" + " GROUP BY account.id, CASE WHEN message.thread IS NULL OR NOT :threading THEN message.id ELSE message.thread END" +
" HAVING (:found OR" + " HAVING (:found OR" +
@ -107,7 +107,7 @@ public interface DaoMessage {
" JOIN folder ON folder.id = message.folder" + " JOIN folder ON folder.id = message.folder" +
" JOIN folder AS f ON f.id = :folder" + " JOIN folder AS f ON f.id = :folder" +
" WHERE (message.account = f.account OR " + is_outbox + ")" + " WHERE (message.account = f.account OR " + is_outbox + ")" +
" AND (message.ui_hide = 0 OR :debug)" + " AND (NOT message.ui_hide OR :debug)" +
" AND (NOT :found OR ui_found = :found)" + " AND (NOT :found OR ui_found = :found)" +
" GROUP BY CASE WHEN message.thread IS NULL OR NOT :threading THEN message.id ELSE message.thread END" + " GROUP BY CASE WHEN message.thread IS NULL OR NOT :threading THEN message.id ELSE message.thread END" +
" HAVING SUM(CASE WHEN folder.id = :folder THEN 1 ELSE 0 END) > 0" + " HAVING SUM(CASE WHEN folder.id = :folder THEN 1 ELSE 0 END) > 0" +
@ -149,7 +149,7 @@ public interface DaoMessage {
" WHERE message.account = :account" + " WHERE message.account = :account" +
" AND message.thread = :thread" + " AND message.thread = :thread" +
" AND (:id IS NULL OR message.id = :id)" + " AND (:id IS NULL OR message.id = :id)" +
" AND (message.ui_hide = 0 OR :debug)" + " AND (NOT message.ui_hide OR :debug)" +
" ORDER BY CASE WHEN :ascending THEN message.received ELSE -message.received END" + " ORDER BY CASE WHEN :ascending THEN message.received ELSE -message.received END" +
", CASE WHEN folder.type = '" + EntityFolder.ARCHIVE + "' THEN 1 ELSE 0 END") ", CASE WHEN folder.type = '" + EntityFolder.ARCHIVE + "' THEN 1 ELSE 0 END")
DataSource.Factory<Integer, TupleMessageEx> pagedThread(long account, String thread, Long id, boolean ascending, boolean debug); DataSource.Factory<Integer, TupleMessageEx> pagedThread(long account, String thread, Long id, boolean ascending, boolean debug);
@ -162,7 +162,7 @@ public interface DaoMessage {
" WHERE message.account = :account" + " WHERE message.account = :account" +
" AND message.thread = :thread" + " AND message.thread = :thread" +
" AND (:id IS NULL OR message.id = :id)" + " AND (:id IS NULL OR message.id = :id)" +
" AND message.ui_hide = 0" + " AND NOT message.ui_hide" +
" GROUP BY account.id") " GROUP BY account.id")
LiveData<TupleThreadStats> liveThreadStats(long account, String thread, Long id); LiveData<TupleThreadStats> liveThreadStats(long account, String thread, Long id);
@ -170,13 +170,13 @@ public interface DaoMessage {
" JOIN message ON message.folder = folder.id" + " JOIN message ON message.folder = folder.id" +
" WHERE ((:folder IS NULL AND :type IS NULL AND folder.unified)" + " WHERE ((:folder IS NULL AND :type IS NULL AND folder.unified)" +
" OR folder.type = :type OR folder.id = :folder)" + " OR folder.type = :type OR folder.id = :folder)" +
" AND ui_hide <> 0") " AND ui_hide")
LiveData<List<Long>> liveHiddenFolder(Long folder, String type); LiveData<List<Long>> liveHiddenFolder(Long folder, String type);
@Query("SELECT id FROM message" + @Query("SELECT id FROM message" +
" WHERE account = :account" + " WHERE account = :account" +
" AND thread = :thread" + " AND thread = :thread" +
" AND ui_hide <> 0") " AND ui_hide")
LiveData<List<Long>> liveHiddenThread(long account, String thread); LiveData<List<Long>> liveHiddenThread(long account, String thread);
@Query("SELECT *" + @Query("SELECT *" +
@ -193,14 +193,14 @@ public interface DaoMessage {
@Query("SELECT id" + @Query("SELECT id" +
" FROM message" + " FROM message" +
" WHERE folder = :folder" + " WHERE folder = :folder" +
" AND ui_hide = 0" + " AND NOT ui_hide" +
" ORDER BY message.received DESC") " ORDER BY message.received DESC")
List<Long> getMessageByFolder(long folder); List<Long> getMessageByFolder(long folder);
@Query("SELECT id" + @Query("SELECT id" +
" FROM message" + " FROM message" +
" WHERE (:folder IS NULL OR folder = :folder)" + " WHERE (:folder IS NULL OR folder = :folder)" +
" AND ui_hide = 0" + " AND NOT ui_hide" +
" ORDER BY message.received DESC") " ORDER BY message.received DESC")
List<Long> getMessageIdsByFolder(Long folder); List<Long> getMessageIdsByFolder(Long folder);
@ -217,7 +217,7 @@ public interface DaoMessage {
" AND (:id IS NULL OR message.id = :id)" + " AND (:id IS NULL OR message.id = :id)" +
" AND (:folder IS NULL OR message.folder = :folder)" + " AND (:folder IS NULL OR message.folder = :folder)" +
" AND NOT uid IS NULL" + " AND NOT uid IS NULL" +
" AND ui_hide = 0") " AND NOT ui_hide")
List<EntityMessage> getMessagesByThread(long account, String thread, Long id, Long folder); List<EntityMessage> getMessagesByThread(long account, String thread, Long id, Long folder);
@Query("SELECT * FROM message" + @Query("SELECT * FROM message" +
@ -254,7 +254,7 @@ public interface DaoMessage {
" JOIN folder ON folder.id = message.folder" + " JOIN folder ON folder.id = message.folder" +
" WHERE account.`synchronize`" + " WHERE account.`synchronize`" +
" AND folder.notify" + " AND folder.notify" +
" AND NOT (message.ui_seen OR message.ui_hide <> 0)"; " AND NOT (message.ui_seen OR message.ui_hide)";
@Query(widget) @Query(widget)
LiveData<TupleMessageStats> liveUnseenWidget(); LiveData<TupleMessageStats> liveUnseenWidget();
@ -280,7 +280,7 @@ public interface DaoMessage {
" WHERE account.`synchronize`" + " WHERE account.`synchronize`" +
" AND folder.notify" + " AND folder.notify" +
" AND (account.created IS NULL OR message.received > account.created)" + " AND (account.created IS NULL OR message.received > account.created)" +
" AND (notifying <> 0 OR NOT (message.ui_seen OR message.ui_hide <> 0))" + " AND (notifying <> 0 OR NOT (message.ui_seen OR message.ui_hide))" +
" ORDER BY message.received") " ORDER BY message.received")
LiveData<List<TupleMessageEx>> liveUnseenNotify(); LiveData<List<TupleMessageEx>> liveUnseenNotify();
@ -293,7 +293,7 @@ public interface DaoMessage {
" JOIN folder ON folder.id = message.folder" + " JOIN folder ON folder.id = message.folder" +
" WHERE account.`synchronize`" + " WHERE account.`synchronize`" +
" AND folder.unified" + " AND folder.unified" +
" AND message.ui_hide = 0" + " AND NOT message.ui_hide" +
" AND message.ui_snoozed IS NULL" + " AND message.ui_snoozed IS NULL" +
" AND (NOT :unseen OR NOT message.ui_seen)" + " AND (NOT :unseen OR NOT message.ui_seen)" +
" AND (NOT :flagged OR message.ui_flagged)" + " AND (NOT :flagged OR message.ui_flagged)" +
@ -387,7 +387,7 @@ public interface DaoMessage {
int setMessageUiAnswered(long id, boolean ui_answered); int setMessageUiAnswered(long id, boolean ui_answered);
@Query("UPDATE message SET ui_hide = :ui_hide WHERE id = :id") @Query("UPDATE message SET ui_hide = :ui_hide WHERE id = :id")
int setMessageUiHide(long id, long ui_hide); int setMessageUiHide(long id, Boolean ui_hide);
@Query("UPDATE message SET ui_ignored = :ui_ignored WHERE id = :id") @Query("UPDATE message SET ui_ignored = :ui_ignored WHERE id = :id")
int setMessageUiIgnored(long id, boolean ui_ignored); int setMessageUiIgnored(long id, boolean ui_ignored);

@ -143,7 +143,7 @@ public class EntityMessage implements Serializable {
@NonNull @NonNull
public Boolean ui_flagged = false; public Boolean ui_flagged = false;
@NonNull @NonNull
public Long ui_hide = 0L; public Boolean ui_hide = false;
@NonNull @NonNull
public Boolean ui_found = false; public Boolean ui_found = false;
@NonNull @NonNull

@ -146,7 +146,7 @@ public class EntityOperation {
if (!EntityFolder.ARCHIVE.equals(source.type) || if (!EntityFolder.ARCHIVE.equals(source.type) ||
EntityFolder.TRASH.equals(target.type) || EntityFolder.JUNK.equals(target.type)) EntityFolder.TRASH.equals(target.type) || EntityFolder.JUNK.equals(target.type))
db.message().setMessageUiHide(message.id, new Date().getTime()); db.message().setMessageUiHide(message.id, true);
if (message.ui_snoozed != null && if (message.ui_snoozed != null &&
(EntityFolder.ARCHIVE.equals(target.type) || EntityFolder.TRASH.equals(target.type))) { (EntityFolder.ARCHIVE.equals(target.type) || EntityFolder.TRASH.equals(target.type))) {
@ -168,7 +168,7 @@ public class EntityOperation {
int notifying = message.notifying; int notifying = message.notifying;
boolean seen = message.seen; boolean seen = message.seen;
boolean ui_seen = message.ui_seen; boolean ui_seen = message.ui_seen;
Long ui_hide = message.ui_hide; Boolean ui_hide = message.ui_hide;
boolean ui_browsed = message.ui_browsed; boolean ui_browsed = message.ui_browsed;
String error = message.error; String error = message.error;
@ -182,7 +182,7 @@ public class EntityOperation {
message.seen = true; message.seen = true;
message.ui_seen = true; message.ui_seen = true;
} }
message.ui_hide = 0L; message.ui_hide = false;
message.ui_browsed = false; message.ui_browsed = false;
message.error = null; message.error = null;
message.id = db.message().insertMessage(message); message.id = db.message().insertMessage(message);
@ -222,7 +222,7 @@ public class EntityOperation {
name = RAW; name = RAW;
} else if (DELETE.equals(name)) } else if (DELETE.equals(name))
db.message().setMessageUiHide(message.id, Long.MAX_VALUE); db.message().setMessageUiHide(message.id, true);
} catch (JSONException ex) { } catch (JSONException ex) {
Log.e(ex); Log.e(ex);

@ -2158,7 +2158,7 @@ public class FragmentCompose extends FragmentBase {
throw new IllegalStateException(getString(R.string.title_no_identities)); throw new IllegalStateException(getString(R.string.title_no_identities));
data.draft = db.message().getMessage(id); data.draft = db.message().getMessage(id);
if (data.draft == null || data.draft.ui_hide != 0) { if (data.draft == null || data.draft.ui_hide) {
// New draft // New draft
if ("edit".equals(action)) if ("edit".equals(action))
throw new MessageRemovedException("Draft for edit was deleted hide=" + (data.draft != null)); throw new MessageRemovedException("Draft for edit was deleted hide=" + (data.draft != null));
@ -2615,7 +2615,7 @@ public class FragmentCompose extends FragmentBase {
@Override @Override
public void onChanged(EntityMessage draft) { public void onChanged(EntityMessage draft) {
// Draft was deleted // Draft was deleted
if (draft == null || draft.ui_hide != 0) if (draft == null || draft.ui_hide)
finish(); finish();
else { else {
Log.i("Draft content=" + draft.content); Log.i("Draft content=" + draft.content);
@ -2708,7 +2708,7 @@ public class FragmentCompose extends FragmentBase {
EntityIdentity identity = db.identity().getIdentity(iid); EntityIdentity identity = db.identity().getIdentity(iid);
// Draft deleted by server // Draft deleted by server
if (draft == null || draft.ui_hide != 0) if (draft == null || draft.ui_hide)
throw new MessageRemovedException("Draft for action was deleted hide=" + (draft != null)); throw new MessageRemovedException("Draft for action was deleted hide=" + (draft != null));
Log.i("Load action id=" + draft.id + " action=" + getActionName(action)); Log.i("Load action id=" + draft.id + " action=" + getActionName(action));
@ -2737,7 +2737,7 @@ public class FragmentCompose extends FragmentBase {
Long uid = draft.uid; Long uid = draft.uid;
String msgid = draft.msgid; String msgid = draft.msgid;
boolean content = draft.content; boolean content = draft.content;
long ui_hide = draft.ui_hide; Boolean ui_hide = draft.ui_hide;
// To prevent violating constraints // To prevent violating constraints
draft.uid = null; draft.uid = null;
@ -2749,7 +2749,7 @@ public class FragmentCompose extends FragmentBase {
draft.uid = uid; draft.uid = uid;
draft.msgid = msgid; draft.msgid = msgid;
draft.content = false; draft.content = false;
draft.ui_hide = new Date().getTime(); draft.ui_hide = true;
draft.id = db.message().insertMessage(draft); draft.id = db.message().insertMessage(draft);
EntityOperation.queue(context, draft, EntityOperation.DELETE); EntityOperation.queue(context, draft, EntityOperation.DELETE);
@ -3014,7 +3014,7 @@ public class FragmentCompose extends FragmentBase {
draft.id = null; draft.id = null;
draft.folder = db.folder().getOutbox().id; draft.folder = db.folder().getOutbox().id;
draft.uid = null; draft.uid = null;
draft.ui_hide = 0L; draft.ui_hide = false;
draft.id = db.message().insertMessage(draft); draft.id = db.message().insertMessage(draft);
Helper.writeText(draft.getFile(context), body); Helper.writeText(draft.getFile(context), body);
if (refDraftFile.exists()) { if (refDraftFile.exists()) {

@ -1649,7 +1649,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
message.account, message.thread, threading && thread ? null : id, message.folder); message.account, message.thread, threading && thread ? null : id, message.folder);
for (EntityMessage threaded : messages) { for (EntityMessage threaded : messages) {
result.add(new MessageTarget(threaded, account, target)); result.add(new MessageTarget(threaded, account, target));
db.message().setMessageUiHide(threaded.id, new Date().getTime()); db.message().setMessageUiHide(threaded.id, true);
// Prevent new message notification on undo // Prevent new message notification on undo
db.message().setMessageUiIgnored(threaded.id, true); db.message().setMessageUiIgnored(threaded.id, true);
} }
@ -3434,7 +3434,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
ArrayList<MessageTarget> result = args.getParcelableArrayList("result"); ArrayList<MessageTarget> result = args.getParcelableArrayList("result");
for (MessageTarget target : result) { for (MessageTarget target : result) {
Log.i("Move undo id=" + target.id); Log.i("Move undo id=" + target.id);
db.message().setMessageUiHide(target.id, 0L); db.message().setMessageUiHide(target.id, false);
} }
db.setTransactionSuccessful(); db.setTransactionSuccessful();
@ -3478,7 +3478,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
for (MessageTarget target : result) { for (MessageTarget target : result) {
EntityMessage message = db.message().getMessage(target.id); EntityMessage message = db.message().getMessage(target.id);
if (message == null || message.ui_hide == 0) if (message == null || !message.ui_hide)
continue; continue;
Log.i("Move id=" + id + " target=" + target.folder.name); Log.i("Move id=" + id + " target=" + target.folder.name);

@ -144,7 +144,7 @@ public class FragmentOperations extends FragmentBase {
for (EntityOperation op : ops) { for (EntityOperation op : ops) {
Log.w("Deleting operation=" + op.id + " error=" + op.error); Log.w("Deleting operation=" + op.id + " error=" + op.error);
if (op.message != null) if (op.message != null)
db.message().setMessageUiHide(op.message, 0L); db.message().setMessageUiHide(op.message, false);
db.operation().deleteOperation(op.id); db.operation().deleteOperation(op.id);
} }
return null; return null;

@ -374,7 +374,7 @@ public class ServiceSend extends ServiceBase {
message.received = new Date().getTime(); message.received = new Date().getTime();
message.seen = true; message.seen = true;
message.ui_seen = true; message.ui_seen = true;
message.ui_hide = Long.MAX_VALUE; message.ui_hide = true;
message.error = null; message.error = null;
message.id = db.message().insertMessage(message); message.id = db.message().insertMessage(message);
@ -420,7 +420,7 @@ public class ServiceSend extends ServiceBase {
parts.getWarnings(message.warning)); parts.getWarnings(message.warning));
db.message().setMessageSent(sid, time); db.message().setMessageSent(sid, time);
db.message().setMessageUiHide(sid, 0L); db.message().setMessageUiHide(sid, false);
// Check for sent orphans // Check for sent orphans
EntityMessage orphan = db.message().getMessage(sid); EntityMessage orphan = db.message().getMessage(sid);

@ -48,7 +48,7 @@ public class ServiceTileUnseen extends TileService {
int unseen = 0; int unseen = 0;
for (TupleMessageEx message : messages) for (TupleMessageEx message : messages)
if (!message.ui_seen && !message.ui_ignored && message.ui_hide == 0) if (!message.ui_seen && !message.ui_ignored && !message.ui_hide)
unseen++; unseen++;
Log.i("Update tile unseen=" + unseen); Log.i("Update tile unseen=" + unseen);

Loading…
Cancel
Save