2017-09-29 17:44:30 +00:00
|
|
|
|
package eu.siacs.conversations.ui.service;
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
2018-03-17 20:43:18 +00:00
|
|
|
|
import android.os.Build;
|
2017-09-29 17:44:30 +00:00
|
|
|
|
import android.support.text.emoji.EmojiCompat;
|
|
|
|
|
|
|
|
|
|
public abstract class AbstractEmojiService {
|
|
|
|
|
|
|
|
|
|
protected final Context context;
|
|
|
|
|
|
|
|
|
|
public AbstractEmojiService(Context context) {
|
|
|
|
|
this.context = context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected abstract EmojiCompat.Config buildConfig();
|
|
|
|
|
|
|
|
|
|
public void init() {
|
|
|
|
|
final EmojiCompat.Config config = buildConfig();
|
2018-03-17 20:43:18 +00:00
|
|
|
|
//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)
|
|
|
|
|
config.setReplaceAll(Build.VERSION.SDK_INT < Build.VERSION_CODES.O);
|
2017-09-29 17:44:30 +00:00
|
|
|
|
EmojiCompat.init(config);
|
|
|
|
|
}
|
|
|
|
|
}
|