aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-11-26 21:31:45 +0100
committerChristian Schneppe <christian@pix-art.de>2017-11-26 21:31:45 +0100
commit45cd67c6a134ddba75736b0a9f2967157ab753fd (patch)
tree772e55affbd90807bfbf3d889590df7dd3498d9d /src
parent2dd6a04fc116367f195dc973d94d86a9214f57cf (diff)
make 'markable' attribute persistent
Diffstat (limited to '')
-rw-r--r--src/main/java/de/pixart/messenger/entities/Message.java16
-rw-r--r--src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java9
2 files changed, 18 insertions, 7 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Message.java b/src/main/java/de/pixart/messenger/entities/Message.java
index 828d810bf..8a59b4cf4 100644
--- a/src/main/java/de/pixart/messenger/entities/Message.java
+++ b/src/main/java/de/pixart/messenger/entities/Message.java
@@ -70,6 +70,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 ";
@@ -96,7 +97,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 isXmppUri = null;
@@ -132,7 +133,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,
@@ -140,7 +142,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;
@@ -160,7 +163,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) {
@@ -207,7 +211,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) {
@@ -263,6 +268,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/de/pixart/messenger/persistance/DatabaseBackend.java b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
index cef543018..1af09a621 100644
--- a/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
+++ b/src/main/java/de/pixart/messenger/persistance/DatabaseBackend.java
@@ -58,7 +58,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
private static DatabaseBackend instance = null;
public static final String DATABASE_NAME = "history";
- public static final int DATABASE_VERSION = 38; // = Conversations DATABASE_VERSION + 1
+ public static final int DATABASE_VERSION = 39; // = Conversations DATABASE_VERSION + 1
private static String CREATE_CONTATCS_STATEMENT = "create table "
+ Contact.TABLENAME + "(" + Contact.ACCOUNT + " TEXT, "
@@ -194,6 +194,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
@@ -468,7 +469,11 @@ public class DatabaseBackend extends SQLiteOpenHelper {
}
if (oldVersion < 38 && newVersion >= 38) {
- 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 < 39 && newVersion >= 39) {
+ db.execSQL("ALTER TABLE " + Message.TABLENAME + " ADD COLUMN " + Message.MARKABLE + " NUMBER DEFAULT 0");
}
}