diff options
Diffstat (limited to '')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/ConversationFragment.java | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 67eafefb..eb2688fd 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -289,26 +289,6 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa //Will automatically set size according to the soft keyboard size mEmojPopup.setSizeForSoftKeyboard(); - //Set on emojicon click listener - mEmojPopup.setOnEmojiconClickedListener(new EmojiconGridView.OnEmojiconClickedListener() { - - @Override - public void onEmojiconClicked(Emojicon emojicon) { - mEditMessage.append(emojicon.getEmoji()); - } - }); - - //Set on backspace click listener - mEmojPopup.setOnEmojiconBackspaceClickedListener(new EmojiconsPopup.OnEmojiconBackspaceClickedListener() { - - @Override - public void onEmojiconBackspaceClicked(View v) { - KeyEvent event = new KeyEvent( - 0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL); - mEditMessage.dispatchKeyEvent(event); - } - }); - //If the emoji popup is dismissed, change emojiButton to smiley icon mEmojPopup.setOnDismissListener(new PopupWindow.OnDismissListener() { @@ -338,7 +318,19 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa @Override public void onEmojiconClicked(Emojicon emojicon) { - mEditMessage.append(emojicon.getEmoji()); + if (mEditMessage == null || emojicon == null) { + return; + } + + int start = mEditMessage.getSelectionStart(); + int end = mEditMessage.getSelectionEnd(); + if (start < 0) { + mEditMessage.append(emojicon.getEmoji()); + } else { + mEditMessage.getText().replace(Math.min(start, end), + Math.max(start, end), emojicon.getEmoji(), 0, + emojicon.getEmoji().length()); + } } }); |