From 3e3451bcffb56740f46d447aaa0356b81ca573c7 Mon Sep 17 00:00:00 2001 From: Bahtiar `kalkin-` Gadimov Date: Sun, 31 Aug 2014 17:24:52 +0200 Subject: [PATCH] Smarter nickname highlight insert in confernces --- src/eu/siacs/conversations/ui/ConversationFragment.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java index 9309db9cf..f4af72773 100644 --- a/src/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/eu/siacs/conversations/ui/ConversationFragment.java @@ -287,14 +287,11 @@ public class ConversationFragment extends Fragment { protected void highlightInConference(String nick) { String oldString = mEditMessage.getText().toString().trim(); - if (oldString.isEmpty()) { - mEditMessage.setText(nick + ": "); + if (oldString.isEmpty() || mEditMessage.getSelectionStart() == 0) { + mEditMessage.getText().insert(0, nick + ": "); } else { - mEditMessage.setText(oldString + " " + nick + " "); + mEditMessage.getText().insert(mEditMessage.getSelectionStart(), nick + " "); } - int position = mEditMessage.length(); - Editable etext = mEditMessage.getText(); - Selection.setSelection(etext, position); } @Override