aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlookshe <github@lookshe.org>2015-08-16 00:32:12 +0200
committerlookshe <github@lookshe.org>2015-08-16 00:32:12 +0200
commitb67060989302daf9850e84e2d4d4320e99bdfb83 (patch)
treeaa1ce31739ca13aa938a0cd4f8317a5c6229a9eb
parentfe3a3c24711538e1d866cf107481df6f69152494 (diff)
Fixes FS#15 - Adding smiley only possible at the end
Removed unnecessary ClickedListeners
Diffstat (limited to '')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationFragment.java34
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());
+ }
}
});