mirror of
https://github.com/googlefonts/noto-emoji.git
synced 2025-07-08 13:36:40 +00:00
Fully integrated AssetEmojiCompatConfig into FileEmojiCompatConfig
This commit is contained in:
parent
e6ef2e32a6
commit
323c74744b
3 changed files with 51 additions and 4 deletions
|
@ -33,8 +33,8 @@ android {
|
|||
defaultConfig {
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 27
|
||||
versionCode 11
|
||||
versionName "1.0.11"
|
||||
versionCode 12
|
||||
versionName "1.0.12"
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -23,15 +23,16 @@ import android.support.annotation.NonNull;
|
|||
import android.support.annotation.RequiresApi;
|
||||
import android.support.text.emoji.EmojiCompat;
|
||||
import android.support.text.emoji.MetadataRepo;
|
||||
import android.util.Log;
|
||||
import android.support.v4.util.Preconditions;
|
||||
|
||||
/**
|
||||
* A simple implementation of EmojiCompat.Config using typeface assets.
|
||||
* 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.
|
||||
* @deprecated Please use {@link FileEmojiCompatConfig#createFromAsset(Context, String)} instead
|
||||
* for greater flexibility.
|
||||
*/
|
||||
@Deprecated
|
||||
public class AssetEmojiCompatConfig extends EmojiCompat.Config {
|
||||
// The class name is obviously changed from the original file
|
||||
|
||||
|
|
|
@ -55,6 +55,52 @@ public class FileEmojiCompatConfig extends EmojiCompat.Config {
|
|||
*/
|
||||
private static final String FONT_FALLBACK = "NoEmojiCompat.ttf";
|
||||
|
||||
/**
|
||||
* Creates a new FileEmojiCompatConfig based on an asset.
|
||||
* <p/>
|
||||
* This means that you can have the flexibility of {@link AssetEmojiCompatConfig}
|
||||
* while giving your users the choice to optionally override the font.
|
||||
* <p/>
|
||||
* The default location for a substituting font is
|
||||
* {@code /sdcard/Android/data/your.apps.package/files/EmojiCompat.ttf}.
|
||||
*
|
||||
* @param context The app's context is needed for several tasks
|
||||
* @param assetPath The path inside the {@code assets} folder for the default font file
|
||||
* @return A FileEmojiCompatConfig which will use the given font by default
|
||||
*/
|
||||
public FileEmojiCompatConfig createFromAsset(@NonNull Context context,
|
||||
@Nullable String assetPath) {
|
||||
if (assetPath != null) {
|
||||
FileEmojiCompatConfig config = new FileEmojiCompatConfig(context,
|
||||
new File(context.getExternalFilesDir(null), "EmojiCompat.ttf"),
|
||||
assetPath);
|
||||
config.replaceAllOnFallback = true;
|
||||
return config;
|
||||
} else {
|
||||
return createFromAsset(context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new FileEmojiCompatConfig based on an asset.
|
||||
* <p/>
|
||||
* This means that you can have the flexibility of {@link AssetEmojiCompatConfig}
|
||||
* while giving your users the choice to optionally override the font.
|
||||
* <p/>
|
||||
* The default location for a substituting font is
|
||||
* {@code /sdcard/Android/data/your.apps.package/files/EmojiCompat.ttf}.
|
||||
* <p/>
|
||||
* The default name for the Assets font is {@code NoEmojiCompat.ttf}.
|
||||
* If you wish to use a different name for this font, please use
|
||||
* {@link #createFromAsset(Context, String)}.
|
||||
*
|
||||
* @param context The app's context is needed for several tasks
|
||||
* @return A FileEmojiCompatConfig which will use the given font by default
|
||||
*/
|
||||
public FileEmojiCompatConfig createFromAsset(@NonNull Context context) {
|
||||
return createFromAsset(context, FONT_FALLBACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new configuration for this EmojiCompat
|
||||
* @param path The file name/path of the requested font
|
||||
|
|
Loading…
Add table
Reference in a new issue