android.support.text.emoji.EmojiCompat Java Examples

The following examples show how to use android.support.text.emoji.EmojiCompat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java    From user-interface-samples with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    initEmojiCompat();

    setContentView(R.layout.activity_main);

    // TextView variant provided by EmojiCompat library
    final TextView emojiTextView = findViewById(R.id.emoji_text_view);
    emojiTextView.setText(getString(R.string.emoji_text_view, EMOJI));

    // EditText variant provided by EmojiCompat library
    final TextView emojiEditText = findViewById(R.id.emoji_edit_text);
    emojiEditText.setText(getString(R.string.emoji_edit_text, EMOJI));

    // Button variant provided by EmojiCompat library
    final TextView emojiButton = findViewById(R.id.emoji_button);
    emojiButton.setText(getString(R.string.emoji_button, EMOJI));

    // Regular TextView without EmojiCompat support; you have to manually process the text
    final TextView regularTextView = findViewById(R.id.regular_text_view);
    EmojiCompat.get().registerInitCallback(new InitCallback(regularTextView));

    // Custom TextView
    final TextView customTextView = findViewById(R.id.emoji_custom_text_view);
    customTextView.setText(getString(R.string.custom_text_view, EMOJI));
}
 
Example #2
Source File: MainActivity.java    From user-interface-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitialized() {
    final TextView regularTextView = mRegularTextViewRef.get();
    if (regularTextView != null) {
        final EmojiCompat compat = EmojiCompat.get();
        final Context context = regularTextView.getContext();
        regularTextView.setText(
                compat.process(context.getString(R.string.regular_text_view, EMOJI)));
    }
}
 
Example #3
Source File: MainActivity.java    From android-EmojiCompat with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    initEmojiCompat();

    setContentView(R.layout.activity_main);

    // TextView variant provided by EmojiCompat library
    final TextView emojiTextView = findViewById(R.id.emoji_text_view);
    emojiTextView.setText(getString(R.string.emoji_text_view, EMOJI));

    // EditText variant provided by EmojiCompat library
    final TextView emojiEditText = findViewById(R.id.emoji_edit_text);
    emojiEditText.setText(getString(R.string.emoji_edit_text, EMOJI));

    // Button variant provided by EmojiCompat library
    final TextView emojiButton = findViewById(R.id.emoji_button);
    emojiButton.setText(getString(R.string.emoji_button, EMOJI));

    // Regular TextView without EmojiCompat support; you have to manually process the text
    final TextView regularTextView = findViewById(R.id.regular_text_view);
    EmojiCompat.get().registerInitCallback(new InitCallback(regularTextView));

    // Custom TextView
    final TextView customTextView = findViewById(R.id.emoji_custom_text_view);
    customTextView.setText(getString(R.string.custom_text_view, EMOJI));
}
 
Example #4
Source File: MainActivity.java    From android-EmojiCompat with Apache License 2.0 5 votes vote down vote up
@Override
public void onInitialized() {
    final TextView regularTextView = mRegularTextViewRef.get();
    if (regularTextView != null) {
        final EmojiCompat compat = EmojiCompat.get();
        final Context context = regularTextView.getContext();
        regularTextView.setText(
                compat.process(context.getString(R.string.regular_text_view, EMOJI)));
    }
}
 
Example #5
Source File: EmojiService.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
public void init() {
    final FontRequest fontRequest = new FontRequest(
            "com.google.android.gms.fonts",
            "com.google.android.gms",
            "Noto Color Emoji Compat",
            R.array.font_certs);
    FontRequestEmojiCompatConfig fontRequestEmojiCompatConfig = new FontRequestEmojiCompatConfig(context, fontRequest);
    fontRequestEmojiCompatConfig.registerInitCallback(initCallback);
    //On recent Androids we assume to have the latest emojis
    //there are some annoying bugs with emoji compat that make it a safer choice not to use it when possible
    // a) when using the ondemand emoji font (play store) flags don’t work
    // b) the text preview has annoying glitches when the cut of text contains emojis (the emoji will be half visible)
    // c) can trigger a hardware rendering bug https://issuetracker.google.com/issues/67102093
    fontRequestEmojiCompatConfig.setReplaceAll(Build.VERSION.SDK_INT < Build.VERSION_CODES.O);
    EmojiCompat.init(fontRequestEmojiCompatConfig);
}
 
Example #6
Source File: EmojiWrapper.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
public static CharSequence transform(CharSequence input) {
	try {
		if (EmojiCompat.get().getLoadState() == EmojiCompat.LOAD_STATE_SUCCEEDED) {
			return EmojiCompat.get().process(input);
		} else {
			return input;
		}
	} catch (IllegalStateException e) {
		return input;
	}
}
 
Example #7
Source File: EmojiService.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
public void init() {
    BundledEmojiCompatConfig config = new BundledEmojiCompatConfig(context);
    //On recent Androids we assume to have the latest emojis
    //there are some annoying bugs with emoji compat that make it a safer choice not to use it when possible
    // a) the text preview has annoying glitches when the cut of text contains emojis (the emoji will be half visible)
    // b) can trigger a hardware rendering bug https://issuetracker.google.com/issues/67102093
    config.setReplaceAll(Build.VERSION.SDK_INT < Build.VERSION_CODES.O);
    EmojiCompat.init(config);
}
 
Example #8
Source File: EmojiWrapper.java    From Conversations with GNU General Public License v3.0 5 votes vote down vote up
public static CharSequence transform(CharSequence input) {
	try {
		if (EmojiCompat.get().getLoadState() == EmojiCompat.LOAD_STATE_SUCCEEDED) {
			return EmojiCompat.get().process(input);
		} else {
			return input;
		}
	} catch (IllegalStateException e) {
		return input;
	}
}
 
Example #9
Source File: weMessage.java    From weMessage with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    instance = this;

    if (AppLogger.USE_CRASHLYTICS) Fabric.with(this, new Crashlytics());

    updateDatabase();
    generateSharedPreferences();

    File attachmentFolder = new File(getFilesDir(), weMessage.ATTACHMENT_FOLDER_NAME);
    File chatIconsFolder = new File(getFilesDir(), weMessage.CHAT_ICONS_FOLDER_NAME);

    AndroidBase64Wrapper base64Wrapper = new AndroidBase64Wrapper();
    ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(base64Wrapper);
    EmojiCompat.Config emojiConfig = new FontRequestEmojiCompatConfig(this,
            new FontRequest("com.google.android.gms.fonts", "com.google.android.gms", "Noto Color Emoji Compat", R.array.com_google_android_gms_fonts_certs))
            .registerInitCallback(new EmojiCompat.InitCallback() {
                @Override
                public void onInitialized() {
                    isEmojiInitialized.set(true);
                }
            });

    AESCrypto.setMemoryAvailabilityCheck(true);
    AESCrypto.setBase64Wrapper(base64Wrapper);
    AESCrypto.setPrngHelper(new AesPrngHelper());

    ClientMessage.setByteArrayAdapter(byteArrayAdapter);
    ServerMessage.setByteArrayAdapter(byteArrayAdapter);

    EmojiCompat.init(emojiConfig);
    JobManager.create(this).addJobCreator(new JobsCreator());

    attachmentFolder.mkdir();
    chatIconsFolder.mkdir();

    this.attachmentFolder = attachmentFolder;
    this.chatIconsFolder = chatIconsFolder;
    this.currentSession = new Session();
    this.messageDatabase = new MessageDatabase(this);
    this.messageManager = new MessageManager(this);
    this.notificationManager = new NotificationManager(this);

    if (isSignedIn(true) && !StringUtils.isEmpty(getSharedPreferences().getString(weMessage.SHARED_PREFERENCES_LAST_EMAIL, ""))){
        getCurrentSession().setAccount(getMessageDatabase().getAccountByEmail(getSharedPreferences().getString(weMessage.SHARED_PREFERENCES_LAST_EMAIL, "")));
    }

    getMessageManager().initialize();
    if (MmsManager.isDefaultSmsApp()) enableSmsMode(getMessageDatabase().getSmsChats().isEmpty());
    else disableSmsMode();

    IOUtils.setDeviceName();
}