Search in sources :

Example 1 with StickerSettingFragment

use of net.iGap.fragments.emoji.remove.StickerSettingFragment in project iGap-Android by KianIranian-STDG.

the class FragmentChat method createKeyboardView.

private void createKeyboardView() {
    if (getContext() != null) {
        keyboardView = new KeyboardView(getContext(), new KeyboardView.Listener() {

            @Override
            public void onViewCreated(int mode) {
            }

            @Override
            public void onStickerSettingClicked() {
                if (getActivity() != null) {
                    showPopup(-1);
                    new HelperFragment(getActivity().getSupportFragmentManager(), new StickerSettingFragment()).setReplace(false).load();
                }
            }

            @Override
            public void onBackSpace() {
                if (edtChat.length() == 0) {
                    return;
                }
                edtChat.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
            }

            @Override
            public void onSendStickerAsMessage(StructIGSticker structIGSticker) {
                sendStickerAsMessage(structIGSticker);
            }

            @Override
            public void onAddStickerClicked() {
                if (getActivity() != null) {
                    showPopup(-1);
                    new HelperFragment(getActivity().getSupportFragmentManager(), FragmentSettingAddStickers.newInstance("ALL")).setReplace(false).load();
                }
            }

            @Override
            public void onEmojiSelected(String unicode) {
                int i = edtChat.getSelectionEnd();
                if (i < 0)
                    i = 0;
                try {
                    CharSequence sequence = EmojiManager.getInstance().replaceEmoji(unicode, edtChat.getPaint().getFontMetricsInt(), LayoutCreator.dp(22), false);
                    if (edtChat.getText() != null)
                        edtChat.setText(edtChat.getText().insert(i, sequence));
                    int j = i + sequence.length();
                    edtChat.setSelection(j, j);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (EmojiManager.getInstance().isValidEmoji(unicode) && edtChat.getText().toString().equals(unicode)) {
                    getStickerByEmoji(unicode);
                } else if (edtChat.getText() != null && !edtChat.getText().toString().equals("")) {
                    if (suggestedLayout != null && suggestedLayout.getVisibility() == View.VISIBLE) {
                        suggestedLayout.setVisibility(View.GONE);
                        lastChar = null;
                    }
                }
            }
        }, KeyboardView.MODE_KEYBOARD, true);
        keyboardView.setVisibility(View.GONE);
        if (mustCheckPermission())
            keyboardView.setStickerPermission(currentRoomAccess != null && currentRoomAccess.getRealmPostMessageRights() != null && currentRoomAccess.getRealmPostMessageRights().isCanSendSticker());
        keyboardContainer.addView(keyboardView);
    }
}
Also used : KeyEvent(android.view.KeyEvent) RealmObjectChangeListener(io.realm.RealmObjectChangeListener) LocationListener(net.iGap.observers.interfaces.LocationListener) OnFileSelectedListener(net.iGap.module.FileListerDialog.OnFileSelectedListener) StructIGSticker(net.iGap.fragments.emoji.struct.StructIGSticker) StickerSettingFragment(net.iGap.fragments.emoji.remove.StickerSettingFragment) RealmString(net.iGap.realm.RealmString) HelperString(net.iGap.helper.HelperString) KeyboardView(net.iGap.libs.emojiKeyboard.KeyboardView) HelperFragment(net.iGap.helper.HelperFragment) SuppressLint(android.annotation.SuppressLint) IOException(java.io.IOException) JsonSyntaxException(com.google.gson.JsonSyntaxException)

Example 2 with StickerSettingFragment

use of net.iGap.fragments.emoji.remove.StickerSettingFragment in project iGap-Android by KianIranian-STDG.

the class StoryDisplayFragment method createKeyboardView.

private void createKeyboardView() {
    if (getContext() != null) {
        keyboardView = new KeyboardView(getContext(), new KeyboardView.Listener() {

            @Override
            public void onViewCreated(int mode) {
            }

            @Override
            public void onStickerSettingClicked() {
                if (getActivity() != null) {
                    showPopup(-1);
                    new HelperFragment(getActivity().getSupportFragmentManager(), new StickerSettingFragment()).setReplace(false).load();
                }
            }

            @Override
            public void onBackSpace() {
                if (replyEditText.length() == 0) {
                    return;
                }
                replyEditText.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
            }

            @Override
            public void onSendStickerAsMessage(StructIGSticker structIGSticker) {
                sendStickerAsMessage(structIGSticker);
            }

            @Override
            public void onAddStickerClicked() {
                if (getActivity() != null) {
                    showPopup(-1);
                    new HelperFragment(getActivity().getSupportFragmentManager(), FragmentSettingAddStickers.newInstance("ALL")).setReplace(false).load();
                }
            }

            @Override
            public void onEmojiSelected(String unicode) {
                int i = replyEditText.getSelectionEnd();
                if (i < 0)
                    i = 0;
                try {
                    CharSequence sequence = EmojiManager.getInstance().replaceEmoji(unicode, replyEditText.getPaint().getFontMetricsInt(), LayoutCreator.dp(22), false);
                    if (replyEditText.getText() != null)
                        replyEditText.setText(replyEditText.getText().insert(i, sequence));
                    int j = i + sequence.length();
                    replyEditText.setSelection(j, j);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (EmojiManager.getInstance().isValidEmoji(unicode) && replyEditText.getText().toString().equals(unicode)) {
                    getStickerByEmoji(unicode);
                } else if (replyEditText.getText() != null && !replyEditText.getText().toString().equals("")) {
                    if (suggestedLayout != null && suggestedLayout.getVisibility() == View.VISIBLE) {
                        suggestedLayout.setVisibility(View.GONE);
                        lastChar = null;
                    }
                }
            }
        }, KeyboardView.MODE_KEYBOARD, false);
        keyboardView.setVisibility(View.GONE);
        // if (mustCheckPermission())
        // keyboardView.setStickerPermission(currentRoomAccess != null && currentRoomAccess.getRealmPostMessageRights() != null && currentRoomAccess.getRealmPostMessageRights().isCanSendSticker());
        keyboardContainer.addView(keyboardView);
    }
}
Also used : KeyEvent(android.view.KeyEvent) StructIGSticker(net.iGap.fragments.emoji.struct.StructIGSticker) StickerSettingFragment(net.iGap.fragments.emoji.remove.StickerSettingFragment) KeyboardView(net.iGap.libs.emojiKeyboard.KeyboardView) HelperFragment(net.iGap.helper.HelperFragment)

Aggregations

KeyEvent (android.view.KeyEvent)2 StickerSettingFragment (net.iGap.fragments.emoji.remove.StickerSettingFragment)2 StructIGSticker (net.iGap.fragments.emoji.struct.StructIGSticker)2 HelperFragment (net.iGap.helper.HelperFragment)2 KeyboardView (net.iGap.libs.emojiKeyboard.KeyboardView)2 SuppressLint (android.annotation.SuppressLint)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 RealmObjectChangeListener (io.realm.RealmObjectChangeListener)1 IOException (java.io.IOException)1 HelperString (net.iGap.helper.HelperString)1 OnFileSelectedListener (net.iGap.module.FileListerDialog.OnFileSelectedListener)1 LocationListener (net.iGap.observers.interfaces.LocationListener)1 RealmString (net.iGap.realm.RealmString)1