simplified message merge condition

This commit is contained in:
iNPUTmice 2014-11-18 14:49:49 +01:00
parent 10bf2b77a8
commit 1122e084a0

View File

@ -225,14 +225,14 @@ public class Message extends AbstractEntity {
this.status = status; this.status = status;
} }
public void setRelativeFilePath(String path) {
this.relativeFilePath = path;
}
public String getRelativeFilePath() { public String getRelativeFilePath() {
return this.relativeFilePath; return this.relativeFilePath;
} }
public void setRelativeFilePath(String path) {
this.relativeFilePath = path;
}
public String getRemoteMsgId() { public String getRemoteMsgId() {
return this.remoteMsgId; return this.remoteMsgId;
} }
@ -286,14 +286,7 @@ public class Message extends AbstractEntity {
} }
public boolean equals(Message message) { public boolean equals(Message message) {
if ((this.remoteMsgId != null) && (this.body != null) return (this.remoteMsgId != null) && (this.body != null) && (this.counterpart != null) && this.remoteMsgId.equals(message.getRemoteMsgId()) && this.body.equals(message.getBody()) && this.counterpart.equals(message.getCounterpart());
&& (this.counterpart != null)) {
return this.remoteMsgId.equals(message.getRemoteMsgId())
&& this.body.equals(message.getBody())
&& this.counterpart.equals(message.getCounterpart());
} else {
return false;
}
} }
public Message next() { public Message next() {
@ -327,26 +320,8 @@ public class Message extends AbstractEntity {
return this.mPreviousMessage; return this.mPreviousMessage;
} }
public boolean mergeable(Message message) { public boolean mergeable(final Message message) {
if (message == null) { return message != null && (message.getType() == Message.TYPE_TEXT && this.getDownloadable() == null && message.getDownloadable() == null && message.getEncryption() != Message.ENCRYPTION_PGP && this.getType() == message.getType() && this.getStatus() == message.getStatus() && this.getEncryption() == message.getEncryption() && this.getCounterpart() != null && this.getCounterpart().equals(message.getCounterpart()) && (message.getTimeSent() - this.getTimeSent()) <= (Config.MESSAGE_MERGE_WINDOW * 1000) && !message.bodyContainsDownloadable() && !this.bodyContainsDownloadable());
return false;
}
return (message.getType() == Message.TYPE_TEXT
&& this.getDownloadable() == null
&& message.getDownloadable() == null
&& message.getEncryption() != Message.ENCRYPTION_PGP
&& this.getType() == message.getType()
&& this.getEncryption() == message.getEncryption()
&& this.getCounterpart() != null
&& this.getCounterpart().equals(message.getCounterpart())
&& (message.getTimeSent() - this.getTimeSent()) <= (Config.MESSAGE_MERGE_WINDOW * 1000) && ((this
.getStatus() == message.getStatus() || ((this.getStatus() == Message.STATUS_SEND || this
.getStatus() == Message.STATUS_SEND_RECEIVED) && (message
.getStatus() == Message.STATUS_UNSEND
|| message.getStatus() == Message.STATUS_SEND || message
.getStatus() == Message.STATUS_SEND_DISPLAYED))))
&& !message.bodyContainsDownloadable()
&& !this.bodyContainsDownloadable());
} }
public String getMergedBody() { public String getMergedBody() {
@ -358,13 +333,8 @@ public class Message extends AbstractEntity {
} }
public int getMergedStatus() { public int getMergedStatus() {
Message next = this.next();
if (this.mergeable(next)) {
return next.getMergedStatus();
} else {
return getStatus(); return getStatus();
} }
}
public long getMergedTimeSent() { public long getMergedTimeSent() {
Message next = this.next(); Message next = this.next();