aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2017-11-25 20:55:43 +0100
committerDaniel Gultsch <daniel@gultsch.de>2017-11-25 20:55:43 +0100
commit64dd622d32147513968d5ab8e0d0d9c38294d27a (patch)
treea638ba30f1571ec4cec7ea3b8f18452a9feeb5c5
parent7f4f30c84901655c9312b9aa2abe0e4ebca75029 (diff)
make 'markable' attribute persistent
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Message.java16
-rw-r--r--src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java9
2 files changed, 18 insertions, 7 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java
index fda02c3..9e8f294 100644
--- a/src/main/java/eu/siacs/conversations/entities/Message.java
+++ b/src/main/java/eu/siacs/conversations/entities/Message.java
@@ -72,6 +72,7 @@ public class Message extends AbstractEntity {
public static final String READ = "read";
public static final String ERROR_MESSAGE = "errorMsg";
public static final String READ_BY_MARKERS = "readByMarkers";
+ public static final String MARKABLE = "markable";
public static final String ME_COMMAND = "/me ";
@@ -98,7 +99,7 @@ public class Message extends AbstractEntity {
private Message mPreviousMessage = null;
private String axolotlFingerprint = null;
private String errorMessage = null;
- protected Set<ReadByMarker> readByMarkers = new HashSet<>();
+ private Set<ReadByMarker> readByMarkers = new HashSet<>();
private Boolean isGeoUri = null;
private Boolean isEmojisOnly = null;
@@ -133,7 +134,8 @@ public class Message extends AbstractEntity {
null,
false,
null,
- null);
+ null,
+ false);
}
private Message(final Conversation conversation, final String uuid, final String conversationUUid, final Jid counterpart,
@@ -141,7 +143,8 @@ public class Message extends AbstractEntity {
final int encryption, final int status, final int type, final boolean carbon,
final String remoteMsgId, final String relativeFilePath,
final String serverMsgId, final String fingerprint, final boolean read,
- final String edited, final boolean oob, final String errorMessage, final Set<ReadByMarker> readByMarkers) {
+ final String edited, final boolean oob, final String errorMessage, final Set<ReadByMarker> readByMarkers,
+ final boolean markable) {
this.conversation = conversation;
this.uuid = uuid;
this.conversationUuid = conversationUUid;
@@ -161,7 +164,8 @@ public class Message extends AbstractEntity {
this.edited = edited;
this.oob = oob;
this.errorMessage = errorMessage;
- this.readByMarkers = new HashSet<>();
+ this.readByMarkers = readByMarkers == null ? new HashSet<ReadByMarker>() : readByMarkers;
+ this.markable = markable;
}
public static Message fromCursor(Cursor cursor, Conversation conversation) {
@@ -208,7 +212,8 @@ public class Message extends AbstractEntity {
cursor.getString(cursor.getColumnIndex(EDITED)),
cursor.getInt(cursor.getColumnIndex(OOB)) > 0,
cursor.getString(cursor.getColumnIndex(ERROR_MESSAGE)),
- ReadByMarker.fromJsonString(cursor.getString(cursor.getColumnIndex(READ_BY_MARKERS))));
+ ReadByMarker.fromJsonString(cursor.getString(cursor.getColumnIndex(READ_BY_MARKERS))),
+ cursor.getInt(cursor.getColumnIndex(MARKABLE)) > 0);
}
public static Message createStatusMessage(Conversation conversation, String body) {
@@ -264,6 +269,7 @@ public class Message extends AbstractEntity {
values.put(OOB, oob ? 1 : 0);
values.put(ERROR_MESSAGE,errorMessage);
values.put(READ_BY_MARKERS,ReadByMarker.toJson(readByMarkers).toString());
+ values.put(MARKABLE, markable ? 1 : 0);
return values;
}
diff --git a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java
index de8dbb0..d61c7f0 100644
--- a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java
+++ b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java
@@ -60,7 +60,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
private static DatabaseBackend instance = null;
private static final String DATABASE_NAME = "history";
- private static final int DATABASE_VERSION = 37;
+ private static final int DATABASE_VERSION = 38;
private static String CREATE_CONTATCS_STATEMENT = "create table "
+ Contact.TABLENAME + "(" + Contact.ACCOUNT + " TEXT, "
@@ -198,6 +198,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
+ Message.OOB + " INTEGER, "
+ Message.ERROR_MESSAGE + " TEXT,"
+ Message.READ_BY_MARKERS + " TEXT,"
+ + Message.MARKABLE + " NUMBER DEFAULT 0,"
+ Message.REMOTE_MSG_ID + " TEXT, FOREIGN KEY("
+ Message.CONVERSATION + ") REFERENCES "
+ Conversation.TABLENAME + "(" + Conversation.UUID
@@ -457,7 +458,11 @@ public class DatabaseBackend extends SQLiteOpenHelper {
}
if (oldVersion < 37 && newVersion >= 37) {
- db.execSQL("ALTER TABLE " + Message.TABLENAME + " ADD COLUMN " + Message.READ_BY_MARKERS + " TEXTs");
+ db.execSQL("ALTER TABLE " + Message.TABLENAME + " ADD COLUMN " + Message.READ_BY_MARKERS + " TEXT");
+ }
+
+ if (oldVersion < 38 && newVersion >= 38) {
+ db.execSQL("ALTER TABLE " + Message.TABLENAME + " ADD COLUMN " + Message.MARKABLE + " NUMBER DEFAULT 0");
}
}