Example usage for android.graphics Paint hasGlyph

List of usage examples for android.graphics Paint hasGlyph

Introduction

In this page you can find the example usage for android.graphics Paint hasGlyph.

Prototype

public boolean hasGlyph(String string) 

Source Link

Document

Determine whether the typeface set on the paint has a glyph supporting the string.

Usage

From source file:com.waz.zclient.MainActivity.java

private void checkForUnsupportedEmojis() {
    if (getControllerFactory() == null || getControllerFactory().isTornDown()) {
        return;// w w  w  .  j  av  a 2 s . co  m
    }
    IUserPreferencesController userPreferencesController = getControllerFactory()
            .getUserPreferencesController();
    Collection<String> unsupported = new ArrayList<>();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        Paint paint = new Paint();
        for (String[] array : Emojis.getAllEmojisSortedByCategory()) {
            for (String emoji : array) {
                if (!paint.hasGlyph(emoji)) {
                    unsupported.add(emoji);
                }
            }
        }
    } else {
        for (String[] array : Emojis.getAllEmojisSortedByCategory()) {
            unsupported.addAll(Arrays.asList(array));
        }
        unsupported = StringUtils.getMissingInFont(unsupported);
    }
    if (!unsupported.isEmpty()) {
        userPreferencesController.setUnsupportedEmoji(unsupported, Emojis.VERSION);
    }
}