aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/entities
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-11-11 13:51:15 +0100
committerChristian Schneppe <christian@pix-art.de>2018-11-11 13:51:15 +0100
commitb38fe1e8f0a9a1aa479b4a61f65f61ae78db6665 (patch)
tree3cd92b820a39ee463fca74a92841b3a31e3f6062 /src/main/java/de/pixart/messenger/entities
parent13586d7b797cd6ce9ec967e2657a0180340dcfb5 (diff)
implement message deletion
fixed #208
Diffstat (limited to 'src/main/java/de/pixart/messenger/entities')
-rw-r--r--src/main/java/de/pixart/messenger/entities/Conversation.java14
-rw-r--r--src/main/java/de/pixart/messenger/entities/IndividualMessage.java5
-rw-r--r--src/main/java/de/pixart/messenger/entities/Message.java12
3 files changed, 28 insertions, 3 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java
index 1e5224489..db6006ca3 100644
--- a/src/main/java/de/pixart/messenger/entities/Conversation.java
+++ b/src/main/java/de/pixart/messenger/entities/Conversation.java
@@ -222,6 +222,20 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
}
}
+ public void findDeletedMessages(final OnMessageFound onMessageFound) {
+ final ArrayList<Message> results = new ArrayList<>();
+ synchronized (this.messages) {
+ for (final Message m : this.messages) {
+ if (m.isDeleted()) {
+ results.add(m);
+ }
+ }
+ }
+ for (Message result : results) {
+ onMessageFound.onMessageFound(result);
+ }
+ }
+
public Message findMessageWithFileAndUuid(final String uuid) {
synchronized (this.messages) {
for (final Message message : this.messages) {
diff --git a/src/main/java/de/pixart/messenger/entities/IndividualMessage.java b/src/main/java/de/pixart/messenger/entities/IndividualMessage.java
index f8d0b7938..2a7b4c8da 100644
--- a/src/main/java/de/pixart/messenger/entities/IndividualMessage.java
+++ b/src/main/java/de/pixart/messenger/entities/IndividualMessage.java
@@ -41,8 +41,8 @@ public class IndividualMessage extends Message {
super(conversation);
}
- private IndividualMessage(Conversational conversation, String uuid, String conversationUUid, Jid counterpart, Jid trueCounterpart, String body, long timeSent, int encryption, int status, int type, boolean carbon, String remoteMsgId, String relativeFilePath, String serverMsgId, String fingerprint, boolean read, String edited, boolean oob, String errorMessage, Set<ReadByMarker> readByMarkers, boolean markable) {
- super(conversation, uuid, conversationUUid, counterpart, trueCounterpart, body, timeSent, encryption, status, type, carbon, remoteMsgId, relativeFilePath, serverMsgId, fingerprint, read, edited, oob, errorMessage, readByMarkers, markable);
+ private IndividualMessage(Conversational conversation, String uuid, String conversationUUid, Jid counterpart, Jid trueCounterpart, String body, long timeSent, int encryption, int status, int type, boolean carbon, String remoteMsgId, String relativeFilePath, String serverMsgId, String fingerprint, boolean read, boolean deleted, String edited, boolean oob, String errorMessage, Set<ReadByMarker> readByMarkers, boolean markable) {
+ super(conversation, uuid, conversationUUid, counterpart, trueCounterpart, body, timeSent, encryption, status, type, carbon, remoteMsgId, relativeFilePath, serverMsgId, fingerprint, read, deleted, edited, oob, errorMessage, readByMarkers, markable);
}
public static Message createDateSeparator(Message message) {
@@ -94,6 +94,7 @@ public class IndividualMessage extends Message {
cursor.getString(cursor.getColumnIndex(SERVER_MSG_ID)),
cursor.getString(cursor.getColumnIndex(FINGERPRINT)),
cursor.getInt(cursor.getColumnIndex(READ)) > 0,
+ cursor.getInt(cursor.getColumnIndex(DELETED)) > 0,
cursor.getString(cursor.getColumnIndex(EDITED)),
cursor.getInt(cursor.getColumnIndex(OOB)) > 0,
cursor.getString(cursor.getColumnIndex(ERROR_MESSAGE)),
diff --git a/src/main/java/de/pixart/messenger/entities/Message.java b/src/main/java/de/pixart/messenger/entities/Message.java
index 9a529877b..14d235553 100644
--- a/src/main/java/de/pixart/messenger/entities/Message.java
+++ b/src/main/java/de/pixart/messenger/entities/Message.java
@@ -68,6 +68,7 @@ public class Message extends AbstractEntity {
public static final String RELATIVE_FILE_PATH = "relativeFilePath";
public static final String FINGERPRINT = "axolotl_fingerprint";
public static final String READ = "read";
+ public static final String DELETED = "deleted";
public static final String ERROR_MESSAGE = "errorMsg";
public static final String READ_BY_MARKERS = "readByMarkers";
public static final String MARKABLE = "markable";
@@ -89,6 +90,7 @@ public class Message extends AbstractEntity {
protected String edited = null;
protected String relativeFilePath;
protected boolean read = true;
+ protected boolean deleted = false;
protected String remoteMsgId = null;
protected String serverMsgId = null;
private final Conversational conversation;
@@ -131,6 +133,7 @@ public class Message extends AbstractEntity {
null,
null,
true,
+ false,
null,
false,
null,
@@ -142,7 +145,7 @@ public class Message extends AbstractEntity {
final Jid trueCounterpart, final String body, final long timeSent,
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 serverMsgId, final String fingerprint, final boolean read, final boolean deleted,
final String edited, final boolean oob, final String errorMessage, final Set<ReadByMarker> readByMarkers,
final boolean markable) {
this.conversation = conversation;
@@ -161,6 +164,7 @@ public class Message extends AbstractEntity {
this.serverMsgId = serverMsgId;
this.axolotlFingerprint = fingerprint;
this.read = read;
+ this.deleted = deleted;
this.edited = edited;
this.oob = oob;
this.errorMessage = errorMessage;
@@ -209,6 +213,7 @@ public class Message extends AbstractEntity {
cursor.getString(cursor.getColumnIndex(SERVER_MSG_ID)),
cursor.getString(cursor.getColumnIndex(FINGERPRINT)),
cursor.getInt(cursor.getColumnIndex(READ)) > 0,
+ cursor.getInt(cursor.getColumnIndex(DELETED)) > 0,
cursor.getString(cursor.getColumnIndex(EDITED)),
cursor.getInt(cursor.getColumnIndex(OOB)) > 0,
cursor.getString(cursor.getColumnIndex(ERROR_MESSAGE)),
@@ -257,6 +262,7 @@ public class Message extends AbstractEntity {
values.put(SERVER_MSG_ID, serverMsgId);
values.put(FINGERPRINT, axolotlFingerprint);
values.put(READ, read ? 1 : 0);
+ values.put(DELETED, deleted ? 1 : 0);
values.put(EDITED, edited);
values.put(OOB, oob ? 1 : 0);
values.put(ERROR_MESSAGE, errorMessage);
@@ -379,6 +385,10 @@ public class Message extends AbstractEntity {
return this.read;
}
+ public boolean isMessageDeleted() {
+ return this.deleted;
+ }
+
public void markRead() {
this.read = true;
}