Giter VIP home page Giter VIP logo

Comments (10)

Jaymo avatar Jaymo commented on September 7, 2024 1

Solved it by replacing Emojiconpopup.java with the on below: https://github.com/takenet/emojicon/blob/master/emojicon/src/main/java/github/ankushsachdeva/emojicon/EmojiconsPopup.java

from emojicon.

vinayjayaram avatar vinayjayaram commented on September 7, 2024

@Jaymo Tried your code, But did not work, It is having same issue

from emojicon.

Jaymo avatar Jaymo commented on September 7, 2024

Kindly share the code you use to toggle the emoji and keyboard

from emojicon.

vinayjayaram avatar vinayjayaram commented on September 7, 2024

@Jaymo
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.PopupWindow.OnDismissListener;

import github.ankushsachdeva.emojicon.EmojiconEditText;
import github.ankushsachdeva.emojicon.EmojiconGridView.OnEmojiconClickedListener;
import github.ankushsachdeva.emojicon.EmojiconsPopup;
import github.ankushsachdeva.emojicon.EmojiconsPopup.OnEmojiconBackspaceClickedListener;
import github.ankushsachdeva.emojicon.EmojiconsPopup.OnSoftKeyboardOpenCloseListener;
import github.ankushsachdeva.emojicon.emoji.Emojicon;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ListView lv = (ListView) findViewById(R.id.lv);
    final ArrayAdapter<String> mAdapter = new ArrayAdapter<>(this, R.layout.listview_row_layout);
    lv.setAdapter(mAdapter);
    final EmojiconEditText emojiconEditText = (EmojiconEditText) findViewById(R.id.emojicon_edit_text);
    final View rootView = findViewById(R.id.root_view);
    final ImageView emojiButton = (ImageView) findViewById(R.id.emoji_btn);
    final ImageView submitButton = (ImageView) findViewById(R.id.submit_btn);

    // Give the topmost view of your activity layout hierarchy. This will be used to measure soft keyboard height
    final EmojiconsPopup popup = new EmojiconsPopup(rootView, this);

    //Will automatically set size according to the soft keyboard size
    popup.setSizeForSoftKeyboard();

    //Set on emojicon click listener
    popup.setOnEmojiconClickedListener(new OnEmojiconClickedListener() {

        @Override
        public void onEmojiconClicked(Emojicon emojicon) {
            emojiconEditText.append(emojicon.getEmoji());
        }
    });

    //Set on backspace click listener
    popup.setOnEmojiconBackspaceClickedListener(new OnEmojiconBackspaceClickedListener() {

        @Override
        public void onEmojiconBackspaceClicked(View v) {
            KeyEvent event = new KeyEvent(
                    0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL);
            emojiconEditText.dispatchKeyEvent(event);
        }
    });

    //If the emoji popup is dismissed, change emojiButton to smiley icon
    popup.setOnDismissListener(new OnDismissListener() {

        @Override
        public void onDismiss() {
            changeEmojiKeyboardIcon(emojiButton, R.drawable.smiley);
        }
    });

    //If the text keyboard closes, also dismiss the emoji popup
    popup.setOnSoftKeyboardOpenCloseListener(new OnSoftKeyboardOpenCloseListener() {

        @Override
        public void onKeyboardOpen(int keyBoardHeight) {

        }

        @Override
        public void onKeyboardClose() {
            if (popup.isShowing())
                popup.dismiss();
        }
    });

    //On emoji clicked, add it to edittext
    popup.setOnEmojiconClickedListener(new OnEmojiconClickedListener() {

        @Override
        public void onEmojiconClicked(Emojicon emojicon) {
            emojiconEditText.append(emojicon.getEmoji());
        }
    });

    //On backspace clicked, emulate the KEYCODE_DEL key event
    popup.setOnEmojiconBackspaceClickedListener(new OnEmojiconBackspaceClickedListener() {

        @Override
        public void onEmojiconBackspaceClicked(View v) {
            KeyEvent event = new KeyEvent(
                    0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL);
            emojiconEditText.dispatchKeyEvent(event);
        }
    });

    // To toggle between text keyboard and emoji keyboard keyboard(Popup)
    emojiButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            //If popup is not showing => emoji keyboard is not visible, we need to show it
            if (!popup.isShowing()) {

                //If keyboard is visible, simply show the emoji popup
                if (popup.isKeyBoardOpen()) {
                    popup.showAtBottom();
                    changeEmojiKeyboardIcon(emojiButton, R.drawable.ic_action_keyboard);
                }

                //else, open the text keyboard first and immediately after that show the emoji popup
                else {
                    emojiconEditText.setFocusableInTouchMode(true);
                    emojiconEditText.requestFocus();
                    popup.showAtBottomPending();
                    final InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                    inputMethodManager.showSoftInput(emojiconEditText, InputMethodManager.SHOW_IMPLICIT);
                    changeEmojiKeyboardIcon(emojiButton, R.drawable.ic_action_keyboard);
                }
            }

            //If popup is showing, simply dismiss it to show the undelying text keyboard
            else {
                popup.dismiss();
            }
        }
    });

    //On submit, add the edittext text to listview and clear the edittext
    submitButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            String newText = emojiconEditText.getText().toString();
            emojiconEditText.getText().clear();
            mAdapter.add(newText);
            mAdapter.notifyDataSetChanged();

        }
    });
}

private void changeEmojiKeyboardIcon(ImageView iconToBeChanged, int drawableResourceId) {
    iconToBeChanged.setImageResource(drawableResourceId);
}

}

from emojicon.

Jaymo avatar Jaymo commented on September 7, 2024

Your code seems alright but I would suggest you use this libraray instead https://github.com/rockerhieu/emojicon its based Ankush Sachdeva's code but its more up updated and a larger community behind it

from emojicon.

vinayjayaram avatar vinayjayaram commented on September 7, 2024

@Jaymo will try that. Thanks for your update really appreciate

from emojicon.

remon avatar remon commented on September 7, 2024

@vinayjayaram , I am facing the same problem , did you fix it ?

from emojicon.

vinayjayaram avatar vinayjayaram commented on September 7, 2024

@remon No dude, was unable to solve it. However it is working in majority of phones except mine!

from emojicon.

zeeshanworkplains avatar zeeshanworkplains commented on September 7, 2024

@remon @vinayjayaram have you solved the problem? I'm facing the same issue :(

from emojicon.

Max01010101010101 avatar Max01010101010101 commented on September 7, 2024

same here ;'(

from emojicon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.