From 2028797f7bc4cfc7fba0568d4a1ab9b02c79b9cf Mon Sep 17 00:00:00 2001 From: Arne Date: Fri, 23 Aug 2024 18:28:38 +0200 Subject: [PATCH] Allow placing sticker at cursors position --- .../siacs/conversations/ui/ConversationFragment.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index adf3b3df3..0e2381a73 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -2013,7 +2013,10 @@ public class ConversationFragment extends XmppFragment Matcher lastColonMatcher = lastColonPattern.matcher(s); int lastColon = 0; while(lastColonMatcher.find()) lastColon = lastColonMatcher.end(); - if (lastColon >= 0) s.replace(lastColon, s.length(), toInsert, 0, toInsert.length()); + if (lastColon >= 0) { + int start = binding.textinput.getSelectionStart(); //this is to get the the cursor position + binding.textinput.getText().insert(start, toInsert); //this will get the text and insert the emoji into the current position + } }); setupEmojiSearch(); @@ -2082,10 +2085,7 @@ public class ConversationFragment extends XmppFragment Matcher lastColonMatcher = lastColonPattern.matcher(s); int lastColon = 0; while(lastColonMatcher.find()) lastColon = lastColonMatcher.end(); - if (lastColon < 0) { - binding.stickersview.setVisibility(GONE); - return; - } + final String q = s.toString().substring(lastColon); EmojiSearch.EmojiSearchAdapter adapter = ((EmojiSearch.EmojiSearchAdapter) binding.stickersview.getAdapter()); if (adapter != null) {