Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Emojicons with SoftKeyboard #159

Open
orenafek opened this issue Feb 28, 2017 · 0 comments
Open

Use Emojicons with SoftKeyboard #159

orenafek opened this issue Feb 28, 2017 · 0 comments

Comments

@orenafek
Copy link

How can I determine if an integer represents a legal Emojicon?
I'm trying to dynamically add an Emoji key, and then detect it when its pressed.

This is my key addition snippet

private void registerEmoji (Keyboard keyboard, @DrawableRes int emojiRes) {
        List<Keyboard.Key> keys = keyboard.getKeys();
        Keyboard.Row row = new Keyboard.Row(keyboard);

        Drawable emoji = getResources().getDrawable(emojiRes);

        Emojicon emojicon = Emojicon.fromResource(emojiRes, 0);

        Keyboard.Key key = new Keyboard.Key(row);
        key.codes = new int[]{emojiRes};
        key.gap = 10;
        key.height = emoji.getMinimumWidth();
        key.width = emoji.getMinimumWidth();
        key.icon = emoji;
        keys.add(key);
    }

And here I'm trying to detect it

public void onKey(int primaryCode, int[] keyCodes) {
                InputConnection ic = getCurrentInputConnection();
                playClick(primaryCode);
       switch (primaryCode) {
                   ...
         default: {
               if (isEmoji(primaryCode)) {
                     ...
               } else {
                   char c = (char) primaryCode;
                      ic.commitText(String.valueOf(Character.isLetter(c) && capsLock ?
                          c : Character.toUpperCase(c)), 1);
                        }
                    }

                }

How can I implement the isEmoji method?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant