Highlight unsnoozed messages

pull/178/head
M66B 5 years ago
parent ae9b4b2d42
commit a3f7ee6f10

File diff suppressed because it is too large Load Diff

@ -1001,8 +1001,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibSnoozed.setImageResource(
message.ui_snoozed != null && message.ui_snoozed == Long.MAX_VALUE
? R.drawable.baseline_visibility_off_24 : R.drawable.baseline_timelapse_24);
if (message.ui_unsnoozed)
ibSnoozed.setColorFilter(colorAccent);
else
ibSnoozed.clearColorFilter();
ibSnoozed.setVisibility(message.ui_snoozed == null ? View.GONE : View.VISIBLE);
ibSnoozed.setVisibility(message.ui_snoozed == null && !message.ui_unsnoozed ? View.GONE : View.VISIBLE);
ivAnswered.setVisibility(message.ui_answered ? View.VISIBLE : View.GONE);
ivForwarded.setVisibility(message.isForwarded() ? View.VISIBLE : View.GONE);
ivAttachments.setVisibility(message.attachments > 0 ? View.VISIBLE : View.GONE);
@ -4901,6 +4905,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
same = false;
log("ui_snoozed changed", next.id);
}
if (!Objects.equals(prev.ui_unsnoozed, next.ui_unsnoozed)) {
same = false;
log("ui_unsnoozed changed", next.id);
}
if (!Objects.equals(prev.color, next.color)) {
same = false;
log("color changed", next.id);

@ -60,7 +60,7 @@ import io.requery.android.database.sqlite.SQLiteDatabase;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 158,
version = 159,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -1572,6 +1572,13 @@ public abstract class DB extends RoomDatabase {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `uidl` TEXT");
}
})
.addMigrations(new Migration(158, 159) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `ui_unsnoozed` INTEGER NOT NULL DEFAULT 0");
}
});
}

@ -668,6 +668,9 @@ public interface DaoMessage {
@Query("UPDATE message SET ui_snoozed = :wakeup WHERE id = :id")
int setMessageSnoozed(long id, Long wakeup);
@Query("UPDATE message SET ui_unsnoozed = :unsnoozed WHERE id = :id")
int setMessageUnsnoozed(long id, boolean unsnoozed);
@Query("UPDATE message SET uidl = :uidl WHERE id = :id")
int setMessageUidl(long id, String uidl);

@ -179,6 +179,8 @@ public class EntityMessage implements Serializable {
public Boolean ui_browsed = false;
public Long ui_busy;
public Long ui_snoozed;
@NonNull
public Boolean ui_unsnoozed = false;
public Integer color;
public Integer revision; // compose
public Integer revisions; // compose
@ -368,7 +370,9 @@ public class EntityMessage implements Serializable {
this.ui_found.equals(other.ui_found) &&
this.ui_ignored.equals(other.ui_ignored) &&
this.ui_browsed.equals(other.ui_browsed) &&
Objects.equals(this.ui_busy, other.ui_busy) &&
Objects.equals(this.ui_snoozed, other.ui_snoozed) &&
this.ui_unsnoozed.equals(other.ui_unsnoozed) &&
Objects.equals(this.color, other.color) &&
Objects.equals(this.revision, other.revision) &&
Objects.equals(this.revisions, other.revisions) &&

@ -1480,6 +1480,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
(message.accountAutoSeen && !message.ui_seen && !message.folderReadOnly))) {
message.unseen = 0;
message.ui_seen = true;
message.ui_unsnoozed = false;
}
setValue("expanded", message.id, value);
@ -4299,6 +4300,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if (account == null)
return null;
if (message.ui_unsnoozed)
db.message().setMessageUnsnoozed(message.id, false);
if (account.protocol != EntityAccount.TYPE_IMAP) {
if (!message.ui_seen)
EntityOperation.queue(context, message, EntityOperation.SEEN, true);
@ -4311,9 +4315,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
int ops = db.operation().getOperationCount(message.folder, message.id, EntityOperation.SEEN);
if (!message.seen || ops > 0)
EntityOperation.queue(context, message, EntityOperation.SEEN, true);
} else
} else {
if (!message.ui_ignored)
db.message().setMessageUiIgnored(message.id, true);
}
}
db.setTransactionSuccessful();
} finally {

@ -475,6 +475,7 @@ public class ServiceUI extends IntentService {
.renameTo(message.getFile(this));
}
db.message().setMessageSnoozed(message.id, null);
db.message().setMessageUnsnoozed(message.id, true);
EntityOperation.queue(this, message, EntityOperation.SEEN, false, false);
}

Loading…
Cancel
Save