From e752f5ad1eff417e2b4a9620c94e3e78071cea39 Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Thu, 13 Apr 2017 21:32:14 +0200 Subject: use comma seperation for multiple mentions --- .../java/de/pixart/messenger/ui/ConversationFragment.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/main/java/de/pixart/messenger') diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 7324f27b0..c94e6f4f0 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -871,16 +871,20 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa String oldString = editable.toString().trim(); final int pos = mEditMessage.getSelectionStart(); if (oldString.isEmpty() || pos == 0) { - mEditMessage.getText().insert(0, nick + ": "); + editable.insert(0, nick + ": "); } else { final char before = editable.charAt(pos - 1); final char after = editable.length() > pos ? editable.charAt(pos) : '\0'; if (before == '\n') { editable.insert(pos, nick + ": "); } else { - editable.insert(pos, (Character.isWhitespace(before) ? "" : " ") + nick + (Character.isWhitespace(after) ? "" : " ")); - if (Character.isWhitespace(after)) { - mEditMessage.setSelection(mEditMessage.getSelectionStart() + 1); + 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); + } } } } -- cgit v1.2.3