AbstractEmojiService.java

 1package eu.siacs.conversations.ui.service;
 2
 3import android.content.Context;
 4import android.os.Build;
 5import android.support.text.emoji.EmojiCompat;
 6
 7public abstract class AbstractEmojiService {
 8
 9	protected final Context context;
10
11	public AbstractEmojiService(Context context) {
12		this.context = context;
13	}
14
15	protected abstract EmojiCompat.Config buildConfig();
16
17	public void init() {
18		final EmojiCompat.Config config = buildConfig();
19		//On recent Androids we assume to have the latest emojis
20		//there are some annoying bugs with emoji compat that make it a safer choice not to use it when possible
21		// a) when using the ondemand emoji font (play store) flags don’t work
22		// b) the text preview has annoying glitches when the cut of text contains emojis (the emoji will be half visible)
23		config.setReplaceAll(Build.VERSION.SDK_INT < Build.VERSION_CODES.O);
24		EmojiCompat.init(config);
25	}
26}