Package de.c1710.filemojicompat
Class FileEmojiCompatConfig
- java.lang.Object
-
- androidx.emoji2.text.EmojiCompat.Config
-
- de.c1710.filemojicompat.FileEmojiCompatConfig
-
public class FileEmojiCompatConfig extends androidx.emoji2.text.EmojiCompat.ConfigA simple implementation of EmojiCompat.Config using typeface files. Based on: https://android.googlesource.com/platform/frameworks/support/+/master/emoji/bundled/src/main/java/android/support/text/emoji/bundled/BundledEmojiCompatConfig.java Changes are marked with comments. Formatting and other simple changes are not always marked.
-
-
Field Summary
Fields Modifier and Type Field Description MutableBooleanfallbackEnabled
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FileEmojiCompatConfigcreateFromAsset(Context context)Creates a new FileEmojiCompatConfig based on an asset.static FileEmojiCompatConfigcreateFromAsset(Context context, String assetPath)Creates a new FileEmojiCompatConfig based on an asset.static FileEmojiCompatConfiginit(Context context)static FileEmojiCompatConfiginit(Context context, File fontFile)static FileEmojiCompatConfiginit(Context context, File fontFile, String fallbackFontName)Create a new configuration for this EmojiCompat based on a filestatic FileEmojiCompatConfiginit(Context context, File fontFile, String fallbackFontName, boolean dontWarnOnEmptyFileName)Create a new configuration for this EmojiCompat based on a filestatic FileEmojiCompatConfiginit(Context context, String fontFile)static FileEmojiCompatConfiginit(Context context, String fontFile, String fallbackFontName)booleanisReplaceAll()FileEmojiCompatConfigsetReplaceAll(boolean replaceAll)Specifies whether all emojis should be replaced even for the fallback/default emoji font.FileEmojiCompatConfigsetReplaceAll(ReplaceStrategy strategy)Sets the strategy to use when it comes to replacing all or only unsupported emojis.
-
-
-
Field Detail
-
fallbackEnabled
public MutableBoolean fallbackEnabled
-
-
Method Detail
-
init
public static FileEmojiCompatConfig init(@NonNull Context context, @Nullable File fontFile, @Nullable String fallbackFontName)
Create a new configuration for this EmojiCompat based on a file- Parameters:
context- Context instancefontFile- The file containing the EmojiCompat fontfallbackFontName- The asset path of the fallback font
-
init
public static FileEmojiCompatConfig init(@NonNull Context context, @Nullable File fontFile, @Nullable String fallbackFontName, boolean dontWarnOnEmptyFileName)
Create a new configuration for this EmojiCompat based on a file- Parameters:
context- Context instancefontFile- The file containing the EmojiCompat fontfallbackFontName- The asset path of the fallback fontdontWarnOnEmptyFileName- If set to true, don't log a warning (only info) if the empty file was given as fontFile. This is used in FilemojiCompat-UI when an asset is loaded
-
init
public static FileEmojiCompatConfig init(@NonNull Context context, @Nullable File fontFile)
-
init
public static FileEmojiCompatConfig init(@NonNull Context context, @Nullable String fontFile, @Nullable String fallbackFontName)
-
init
public static FileEmojiCompatConfig init(@NonNull Context context, @Nullable String fontFile)
-
init
public static FileEmojiCompatConfig init(@NonNull Context context)
-
createFromAsset
public static FileEmojiCompatConfig createFromAsset(@NonNull Context context, @Nullable String assetPath)
Creates a new FileEmojiCompatConfig based on an asset. Will set the replacement strategy to treat the "normal" and the asset version equally.The default location for a substituting font is
/sdcard/Android/data/your.apps.package/files/EmojiCompat.ttf.- Parameters:
context- The app's context is needed for several tasksassetPath- The path inside theassetsfolder for the default font file- Returns:
- A FileEmojiCompatConfig which will use the given font by default
-
createFromAsset
public static FileEmojiCompatConfig createFromAsset(@NonNull Context context)
Creates a new FileEmojiCompatConfig based on an asset. Will set the replacement strategy to treat the "normal" and the asset version equally.The default location for a substituting font is
/sdcard/Android/data/your.apps.package/files/EmojiCompat.ttf.The default name for the Assets font is
NoEmojiCompat.ttf. If you wish to use a different name for this font, please usecreateFromAsset(Context, String).- Parameters:
context- The app's context is needed for several tasks- Returns:
- A FileEmojiCompatConfig which will use the given font by default
-
setReplaceAll
public FileEmojiCompatConfig setReplaceAll(ReplaceStrategy strategy)
Sets the strategy to use when it comes to replacing all or only unsupported emojis.- Parameters:
strategy- The strategy to use.- Returns:
- This
-
setReplaceAll
@NonNull public FileEmojiCompatConfig setReplaceAll(boolean replaceAll)
Specifies whether all emojis should be replaced even for the fallback/default emoji font.- Overrides:
setReplaceAllin classandroidx.emoji2.text.EmojiCompat.Config- Parameters:
replaceAll- True if the provided emoji font should also replace all emojis (useful e.g., if you already provide a custom emoji font)- Returns:
- This
-
isReplaceAll
public boolean isReplaceAll()
- Returns:
- Whether all emojis are replaced. Note: This does not return the strategy used, but how the actual state is.
-
-