diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-04-13 21:44:50 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-04-13 21:44:50 +0200 |
commit | bc03a692264de9e6b06539a8abf17b69cc65a2ff (patch) | |
tree | 0a44340ca40635a78c4cd3b3b3e881ecda1a9e62 /src/main/java/de/pixart/messenger/ui | |
parent | c42d2759f89a39d6caada419653b2b05bf38ef3d (diff) |
be more careful with corner cases when mentioning multiple people
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationFragment.java | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index c94e6f4f0..50b93cf5e 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -44,6 +44,7 @@ import net.java.otr4j.session.SessionStatus; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Date; import java.util.List; @@ -74,6 +75,7 @@ import de.pixart.messenger.ui.adapter.MessageAdapter.OnContactPictureClicked; import de.pixart.messenger.ui.adapter.MessageAdapter.OnContactPictureLongClicked; import de.pixart.messenger.ui.widget.ListSelectionManager; import de.pixart.messenger.utils.GeoHelper; +import de.pixart.messenger.utils.NickValidityChecker; import de.pixart.messenger.utils.UIHelper; import de.pixart.messenger.utils.XmppUri; import de.pixart.messenger.xmpp.XmppConnection; @@ -879,13 +881,15 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa editable.insert(pos, nick + ": "); } else { if (pos > 2 && editable.subSequence(pos - 2, pos).toString().equals(": ")) { - editable.insert(pos - 2, ", " + nick); - } else { - editable.insert(pos, (Character.isWhitespace(before) ? "" : " ") + nick + (Character.isWhitespace(after) ? "" : " ")); - if (Character.isWhitespace(after)) { - mEditMessage.setSelection(mEditMessage.getSelectionStart() + 1); + if (NickValidityChecker.check(conversation, Arrays.asList(editable.subSequence(0, pos - 2).toString().split(", ")))) { + editable.insert(pos - 2, ", " + nick); + return; } } + editable.insert(pos, (Character.isWhitespace(before) ? "" : " ") + nick + (Character.isWhitespace(after) ? "" : " ")); + if (Character.isWhitespace(after)) { + mEditMessage.setSelection(mEditMessage.getSelectionStart() + 1); + } } } } |