aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/entities')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/entities/Conversation.java6
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/entities/Message.java103
2 files changed, 3 insertions, 106 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/Conversation.java b/src/main/java/de/thedevstack/conversationsplus/entities/Conversation.java
index b822ef0e..3a4c3d4b 100644
--- a/src/main/java/de/thedevstack/conversationsplus/entities/Conversation.java
+++ b/src/main/java/de/thedevstack/conversationsplus/entities/Conversation.java
@@ -260,16 +260,12 @@ public class Conversation extends AbstractEntity implements Blockable {
return null;
}
+ // TODO Check if this is really necessary
public void populateWithMessages(final List<Message> messages) {
synchronized (this.messages) {
messages.clear();
messages.addAll(this.messages);
}
- for(Iterator<Message> iterator = messages.iterator(); iterator.hasNext();) {
- if (iterator.next().wasMergedIntoPrevious()) {
- iterator.remove();
- }
- }
}
@Override
diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/Message.java b/src/main/java/de/thedevstack/conversationsplus/entities/Message.java
index f1da885e..9fbfce54 100644
--- a/src/main/java/de/thedevstack/conversationsplus/entities/Message.java
+++ b/src/main/java/de/thedevstack/conversationsplus/entities/Message.java
@@ -5,11 +5,8 @@ import android.database.Cursor;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Arrays;
-import de.thedevstack.conversationsplus.Config;
import de.thedevstack.conversationsplus.crypto.axolotl.XmppAxolotlSession;
-import de.thedevstack.conversationsplus.utils.GeoHelper;
import de.thedevstack.conversationsplus.utils.MimeUtils;
import de.thedevstack.conversationsplus.xmpp.jid.InvalidJidException;
import de.thedevstack.conversationsplus.xmpp.jid.Jid;
@@ -344,10 +341,6 @@ public class Message extends AbstractEntity {
this.carbon = carbon;
}
- public void setEdited(String edited) {
- this.edited = edited;
- }
-
public boolean edited() {
return this.edited != null;
}
@@ -356,10 +349,6 @@ public class Message extends AbstractEntity {
this.trueCounterpart = trueCounterpart;
}
- public Jid getTrueCounterpart() {
- return this.trueCounterpart;
- }
-
public Transferable getTransferable() {
return this.transferable;
}
@@ -391,8 +380,7 @@ public class Message extends AbstractEntity {
} else {
return this.remoteMsgId == null
&& this.counterpart.equals(message.getCounterpart())
- && body.equals(otherBody)
- && Math.abs(this.getTimeSent() - message.getTimeSent()) < Config.MESSAGE_MERGE_WINDOW * 1000;
+ && body.equals(otherBody);
}
}
}
@@ -425,95 +413,8 @@ public class Message extends AbstractEntity {
}
}
- public boolean isLastCorrectableMessage() {
- Message next = next();
- while(next != null) {
- if (next.isCorrectable()) {
- return false;
- }
- next = next.next();
- }
- return isCorrectable();
- }
-
- private boolean isCorrectable() {
- return getStatus() != STATUS_RECEIVED && !isCarbon();
- }
-
- public boolean mergeable(final Message message) {
- return message != null &&
- (message.getType() == Message.TYPE_TEXT &&
- this.getTransferable() == null &&
- message.getTransferable() == null &&
- message.getEncryption() != Message.ENCRYPTION_PGP &&
- message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED &&
- this.getType() == message.getType() &&
- //this.getStatus() == message.getStatus() &&
- isStatusMergeable(this.getStatus(), message.getStatus()) &&
- this.getEncryption() == message.getEncryption() &&
- this.getCounterpart() != null &&
- this.getCounterpart().equals(message.getCounterpart()) &&
- this.edited() == message.edited() &&
- (message.getTimeSent() - this.getTimeSent()) <= (Config.MESSAGE_MERGE_WINDOW * 1000) &&
- !GeoHelper.isGeoUri(message.getBody()) &&
- !GeoHelper.isGeoUri(this.getBody()) &&
- message.treatAsDownloadable() == Decision.NEVER &&
- this.treatAsDownloadable() == Decision.NEVER &&
- !message.getBody().startsWith(ME_COMMAND) &&
- !this.getBody().startsWith(ME_COMMAND) &&
- this.isTrusted() == message.isTrusted()
- );
- }
-
- private static boolean isStatusMergeable(int a, int b) {
- return a == b || (
- (a == Message.STATUS_SEND_RECEIVED && b == Message.STATUS_UNSEND)
- || (a == Message.STATUS_SEND_RECEIVED && b == Message.STATUS_SEND)
- || (a == Message.STATUS_UNSEND && b == Message.STATUS_SEND)
- || (a == Message.STATUS_UNSEND && b == Message.STATUS_SEND_RECEIVED)
- || (a == Message.STATUS_SEND && b == Message.STATUS_UNSEND)
- || (a == Message.STATUS_SEND && b == Message.STATUS_SEND_RECEIVED)
- );
- }
-
- public String getMergedBody() {
- StringBuilder body = new StringBuilder(this.body);
- Message current = this;
- while(current.mergeable(current.next())) {
- current = current.next();
- body.append(MERGE_SEPARATOR);
- body.append(current.getBody());
- }
- return body.toString();
- }
-
public boolean hasMeCommand() {
- return getMergedBody().startsWith(ME_COMMAND);
- }
-
- public int getMergedStatus() {
- int status = this.status;
- Message current = this;
- while(current.mergeable(current.next())) {
- current = current.next();
- status = current.status;
- }
- return status;
- }
-
- public long getMergedTimeSent() {
- long time = this.timeSent;
- Message current = this;
- while(current.mergeable(current.next())) {
- current = current.next();
- time = current.timeSent;
- }
- return time;
- }
-
- public boolean wasMergedIntoPrevious() {
- Message prev = this.prev();
- return prev != null && prev.mergeable(this);
+ return getBody().startsWith(ME_COMMAND);
}
public boolean trusted() {