Skip to content
This repository has been archived by the owner on Jul 23, 2019. It is now read-only.

Wrap emojis with custom font #390

Closed
wants to merge 1 commit into from
Closed

Conversation

stravag
Copy link

@stravag stravag commented Nov 6, 2016

Older Android versions don't support all emojis, so it might be convenient to wrap emojis in a text with a font (ie. emojione) that supports all of them, without altering the overall look of the application.

The current solution to build the shortNameToUnicode map is terrible in my opinion. It might be wise to create a proper Android Library with the emoji_strategy.json embedded, and tests etc...

    @Test
    public void emojiWrapping() {

        SpannableStringBuilder mock = mock(SpannableStringBuilder.class);

        String text = "A\uD83D\uDC86B\uD83C\uDDE8\uD83C\uDDEDC\uD83D\uDC8FD";
        Emojione.wrapEmojis(text, Typeface.DEFAULT, mock);

        InOrder inOrder = inOrder(mock);
        inOrder.verify(mock).append(text);
        inOrder.verify(mock).setSpan(any(CustomTypeFaceSpan.class), eq(1), eq(3), eq(Spanned.SPAN_EXCLUSIVE_EXCLUSIVE));
        inOrder.verify(mock).setSpan(any(CustomTypeFaceSpan.class), eq(4), eq(8), eq(Spanned.SPAN_EXCLUSIVE_EXCLUSIVE));
        inOrder.verify(mock).setSpan(any(CustomTypeFaceSpan.class), eq(9), eq(11), eq(Spanned.SPAN_EXCLUSIVE_EXCLUSIVE));
        verifyNoMoreInteractions(mock);
    }

    @Test
    public void shortnameToUnicode() {

        String se = "\uD83C\uDDF8\uD83C\uDDEA";
        assertEquals(se, Emojione.shortnameToUnicode(":flag_se:", false));
    }

@stravag
Copy link
Author

stravag commented Nov 6, 2017

Thanks to the new emoji compatibility feature in the android support library this is no longer an issue: https://developer.android.com/guide/topics/ui/look-and-feel/emoji-compat.html

@stravag stravag closed this Nov 6, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant