Ability added to replace all emojis when using fallback

This commit is contained in:
Constantin A 2018-05-05 15:19:46 +02:00
parent 3667d9b43e
commit 2bd81dce8a
2 changed files with 21 additions and 4 deletions

View file

@ -18,7 +18,7 @@ ext {
libraryDescription = 'An EmojiCompat implementation using files from a local file or a file inside your assets directory' libraryDescription = 'An EmojiCompat implementation using files from a local file or a file inside your assets directory'
siteUrl = 'https://github.com/c1710/blobmoji' siteUrl = 'https://github.com/c1710/blobmoji'
gitUrl = 'https://github.com/c1710/blobmoji.git' gitUrl = 'https://github.com/c1710/blobmoji.git'
libraryVersion = '1.0.5' libraryVersion = '1.0.6'
developerId = 'c1710' developerId = 'c1710'
developerName = 'Constantin A.' developerName = 'Constantin A.'
developerEmail = 'c1710.apps@outlook.com' developerEmail = 'c1710.apps@outlook.com'
@ -33,8 +33,8 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 27 targetSdkVersion 27
versionCode 5 versionCode 6
versionName "1.0.5" versionName "1.0.6"
} }

View file

@ -34,6 +34,7 @@ import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.locks.ReentrantLock;
/** /**
* A simple implementation of EmojiCompat.Config using typeface files. * A simple implementation of EmojiCompat.Config using typeface files.
@ -49,6 +50,10 @@ public class FileEmojiCompatConfig extends EmojiCompat.Config {
* This boolean indicates whether the fallback solution is used. * This boolean indicates whether the fallback solution is used.
*/ */
private boolean fallback; private boolean fallback;
/**
* Indicates whether all emojis should be replaced when the fallback font is used.
*/
private boolean replaceAllOnFallback = false;
/** /**
* Create a new configuration for this EmojiCompat * Create a new configuration for this EmojiCompat
@ -107,7 +112,19 @@ public class FileEmojiCompatConfig extends EmojiCompat.Config {
@Override @Override
public FileEmojiCompatConfig setReplaceAll(boolean replaceAll) { public FileEmojiCompatConfig setReplaceAll(boolean replaceAll) {
if(!fallback) { return setReplaceAll(replaceAll, replaceAllOnFallback);
}
/**
* Replace all emojis
* @param replaceAll Whether all emojis should be replaced
* @param replaceAllOnFallback true if this is supposed to be the case even when using the fallback font.
* Useful if the NoEmojiCompat.ttf is overridden by a "real" EmojiCompat font.
* @return This EmojiCompat.Config
*/
public FileEmojiCompatConfig setReplaceAll(boolean replaceAll, boolean replaceAllOnFallback) {
this.replaceAllOnFallback = replaceAllOnFallback;
if(!fallback || replaceAllOnFallback) {
super.setReplaceAll(replaceAll); super.setReplaceAll(replaceAll);
} }
else { else {