This commit is contained in:
Constantin A 2018-07-03 11:22:59 +02:00
commit cc73a9967e
5 changed files with 56 additions and 8 deletions

View file

@ -14,6 +14,7 @@ Another thing is that this emoji set includes some emojis and ZWJ-sequences whic
Please note that I did not create most of the emojis. You can find an overview of the changes I made in the file CHANGES.txt
Most information on this fork will be included in the [Wiki](https://github.com/C1710/blobmoji/wiki). There you'll find more detailed build instructions and other helpful information on how to use this font and much more.
If you want to use this font - there's a [Wiki page](https://github.com/C1710/blobmoji/wiki/Installation-Usage) :D
(_[Emojipedia®](https://emojipedia.org) is a registered trademark of Emojipedia Pty Ltd_)

View file

@ -5,7 +5,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.android.tools.build:gradle:3.1.3'
}
}
@ -18,7 +18,7 @@ ext {
libraryDescription = 'An EmojiCompat implementation using files from a local file or a file inside your assets directory'
siteUrl = 'https://github.com/c1710/blobmoji'
gitUrl = 'https://github.com/c1710/blobmoji.git'
libraryVersion = '1.0.7'
libraryVersion = '1.0.11'
developerId = 'c1710'
developerName = 'Constantin A.'
developerEmail = 'c1710.apps@outlook.com'
@ -33,8 +33,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 27
versionCode 7
versionName "1.0.7"
versionCode 12
versionName "1.0.12"
}
@ -47,7 +47,6 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:support-emoji:27.1.1'
}
apply from: 'https://raw.githubusercontent.com/numetriclabz/jcenter/master/installv.gradle'

View file

@ -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

View 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
@ -238,6 +284,7 @@ public class FileEmojiCompatConfig extends EmojiCompat.Config {
MetadataRepo.create(assetManager, FONT_FALLBACK);
loaderCallback.onLoaded(resourceIndex);
} catch (Throwable t2) {
Log.e(TAG, "Even the fallback font couldn't be loaded", t2);
loaderCallback.onFailed(t);
}
}