diff options
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/ConversationFragment.java')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationFragment.java | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java index 59098f541..fa2ba5327 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java @@ -98,6 +98,7 @@ import de.pixart.messenger.ui.util.ActivityResult; import de.pixart.messenger.ui.util.AttachmentTool; import de.pixart.messenger.ui.util.ConversationMenuConfigurator; import de.pixart.messenger.ui.util.DateSeparator; +import de.pixart.messenger.ui.util.EditMessageActionModeCallback; import de.pixart.messenger.ui.util.ListViewUtils; import de.pixart.messenger.ui.util.PendingItem; import de.pixart.messenger.ui.util.PresenceSelector; @@ -1220,6 +1221,11 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke binding.messagesView.setAdapter(messageListAdapter); registerForContextMenu(binding.messagesView); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + this.binding.textinput.setCustomInsertionActionModeCallback(new EditMessageActionModeCallback(this.binding.textinput)); + } + return binding.getRoot(); } @@ -1235,20 +1241,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke private void quoteText(String text) { if (binding.textinput.isEnabled()) { - text = text.replaceAll("(\n *){2,}", "\n").replaceAll("(^|\n)", "$1> ").replaceAll("\n$", ""); - Editable editable = binding.textinput.getEditableText(); - int position = binding.textinput.getSelectionEnd(); - if (position == -1) position = editable.length(); - if (position > 0 && editable.charAt(position - 1) != '\n') { - editable.insert(position++, "\n"); - } - editable.insert(position, text); - position += text.length(); - editable.insert(position++, "\n"); - if (position < editable.length() && editable.charAt(position) != '\n') { - editable.insert(position, "\n"); - } - binding.textinput.setSelection(position); + binding.textinput.insertAsQuote(text); binding.textinput.requestFocus(); InputMethodManager inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); if (inputMethodManager != null) { |