aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-01-25 19:30:00 +0100
committerDaniel Gultsch <daniel@gultsch.de>2015-01-25 19:30:00 +0100
commit155914470118e0d68f3e042644beadeb7590b666 (patch)
treec62cdc977e984bb245969315fabe7d631277fd3e /src/main
parent14fc520ec086a64739892f3aa8bb1837cbd21471 (diff)
parent29331e49b9fa97949e14f2a326b26c69a4ca3022 (diff)
Merge pull request #933 from betheg/mergeable
fix mergable() for /me command.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Message.java6
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java3
-rw-r--r--src/main/java/eu/siacs/conversations/utils/UIHelper.java5
3 files changed, 9 insertions, 5 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java
index 55a1d2ce..8112f5de 100644
--- a/src/main/java/eu/siacs/conversations/entities/Message.java
+++ b/src/main/java/eu/siacs/conversations/entities/Message.java
@@ -47,6 +47,7 @@ public class Message extends AbstractEntity {
public static final String REMOTE_MSG_ID = "remoteMsgId";
public static final String SERVER_MSG_ID = "serverMsgId";
public static final String RELATIVE_FILE_PATH = "relativeFilePath";
+ public static final String ME_COMMAND = "/me ";
public boolean markable = false;
protected String conversationUuid;
@@ -367,7 +368,8 @@ public class Message extends AbstractEntity {
(message.getTimeSent() - this.getTimeSent()) <= (Config.MESSAGE_MERGE_WINDOW * 1000) &&
!message.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() {
- return getMergedBody().startsWith("/me ");
+ return getMergedBody().startsWith(ME_COMMAND);
}
public int getMergedStatus() {
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
index 1d4e2493..442c6ecf 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -220,7 +220,8 @@ public class MessageAdapter extends ArrayAdapter<Message> {
viewHolder.messageBody.setVisibility(View.VISIBLE);
if (message.getBody() != null) {
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.hasMeCommand()) {
final Spannable span = new SpannableString(formattedBody);
diff --git a/src/main/java/eu/siacs/conversations/utils/UIHelper.java b/src/main/java/eu/siacs/conversations/utils/UIHelper.java
index 32227ff8..ffb9390f 100644
--- a/src/main/java/eu/siacs/conversations/utils/UIHelper.java
+++ b/src/main/java/eu/siacs/conversations/utils/UIHelper.java
@@ -150,8 +150,9 @@ public class UIHelper {
return new Pair<>(getFileDescriptionString(context,message),true);
}
} else {
- if (message.getBody().startsWith("/me ")) {
- return new Pair<>(message.getBody().replaceAll("^/me ",UIHelper.getMessageDisplayName(message) + " "),false);
+ if (message.getBody().startsWith(Message.ME_COMMAND)) {
+ return new Pair<>(message.getBody().replaceAll("^" + Message.ME_COMMAND,
+ UIHelper.getMessageDisplayName(message) + " "), false);
} else {
return new Pair<>(message.getBody(), false);
}