From d91c314ac2e1e81535d8c4d3ac91d15f20d920d2 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 6 Apr 2017 18:06:07 +0200 Subject: [PATCH] use comma seperation for multiple mentions --- .../conversations/ui/ConversationFragment.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index dff6bce6e..fe38108df 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -9,8 +9,6 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentSender.SendIntentException; -import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.support.v13.view.inputmethod.InputConnectionCompat; @@ -34,7 +32,6 @@ import android.widget.AbsListView; import android.widget.AbsListView.OnScrollListener; import android.widget.AdapterView; import android.widget.AdapterView.AdapterContextMenuInfo; -import android.widget.EditText; import android.widget.ImageButton; import android.widget.ListView; import android.widget.PopupMenu; @@ -840,16 +837,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); + } } } }