fix mergable() for /me command.
This commit is contained in:
parent
90d06d38d6
commit
29331e49b9
|
@ -47,6 +47,7 @@ public class Message extends AbstractEntity {
|
||||||
public static final String REMOTE_MSG_ID = "remoteMsgId";
|
public static final String REMOTE_MSG_ID = "remoteMsgId";
|
||||||
public static final String SERVER_MSG_ID = "serverMsgId";
|
public static final String SERVER_MSG_ID = "serverMsgId";
|
||||||
public static final String RELATIVE_FILE_PATH = "relativeFilePath";
|
public static final String RELATIVE_FILE_PATH = "relativeFilePath";
|
||||||
|
public static final String ME_COMMAND = "/me ";
|
||||||
|
|
||||||
public boolean markable = false;
|
public boolean markable = false;
|
||||||
protected String conversationUuid;
|
protected String conversationUuid;
|
||||||
|
@ -367,7 +368,8 @@ public class Message extends AbstractEntity {
|
||||||
(message.getTimeSent() - this.getTimeSent()) <= (Config.MESSAGE_MERGE_WINDOW * 1000) &&
|
(message.getTimeSent() - this.getTimeSent()) <= (Config.MESSAGE_MERGE_WINDOW * 1000) &&
|
||||||
!message.bodyContainsDownloadable() &&
|
!message.bodyContainsDownloadable() &&
|
||||||
!this.bodyContainsDownloadable() &&
|
!this.bodyContainsDownloadable() &&
|
||||||
!this.body.startsWith("/me ")
|
!message.getBody().startsWith(ME_COMMAND) &&
|
||||||
|
!this.getBody().startsWith(ME_COMMAND)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,7 +382,7 @@ public class Message extends AbstractEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasMeCommand() {
|
public boolean hasMeCommand() {
|
||||||
return getMergedBody().startsWith("/me ");
|
return getMergedBody().startsWith(ME_COMMAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMergedStatus() {
|
public int getMergedStatus() {
|
||||||
|
|
|
@ -220,7 +220,8 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
||||||
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
||||||
if (message.getBody() != null) {
|
if (message.getBody() != null) {
|
||||||
final String nick = UIHelper.getMessageDisplayName(message);
|
final String nick = UIHelper.getMessageDisplayName(message);
|
||||||
final String formattedBody = message.getMergedBody().replaceAll("^/me ", nick + " ");
|
final String formattedBody = message.getMergedBody().replaceAll("^" + Message.ME_COMMAND,
|
||||||
|
nick + " ");
|
||||||
if (message.getType() != Message.TYPE_PRIVATE) {
|
if (message.getType() != Message.TYPE_PRIVATE) {
|
||||||
if (message.hasMeCommand()) {
|
if (message.hasMeCommand()) {
|
||||||
final Spannable span = new SpannableString(formattedBody);
|
final Spannable span = new SpannableString(formattedBody);
|
||||||
|
|
|
@ -150,8 +150,9 @@ public class UIHelper {
|
||||||
return new Pair<>(getFileDescriptionString(context,message),true);
|
return new Pair<>(getFileDescriptionString(context,message),true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (message.getBody().startsWith("/me ")) {
|
if (message.getBody().startsWith(Message.ME_COMMAND)) {
|
||||||
return new Pair<>(message.getBody().replaceAll("^/me ",UIHelper.getMessageDisplayName(message) + " "),false);
|
return new Pair<>(message.getBody().replaceAll("^" + Message.ME_COMMAND,
|
||||||
|
UIHelper.getMessageDisplayName(message) + " "), false);
|
||||||
} else {
|
} else {
|
||||||
return new Pair<>(message.getBody(), false);
|
return new Pair<>(message.getBody(), false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue