mirror of
https://github.com/googlefonts/noto-emoji.git
synced 2025-07-09 05:45:31 +00:00
New fallback font which should work on more devices
This commit is contained in:
parent
fa57c7eb5e
commit
633f21f777
6 changed files with 113 additions and 113 deletions
|
@ -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.11'
|
libraryVersion = '1.0.13'
|
||||||
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 12
|
versionCode 13
|
||||||
versionName "1.0.12"
|
versionName "1.0.13"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ dependencies {
|
||||||
implementation 'com.android.support:support-emoji:27.1.1'
|
implementation 'com.android.support:support-emoji:27.1.1'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
apply from: 'https://raw.githubusercontent.com/numetriclabz/jcenter/master/installv.gradle'
|
apply from: 'https://raw.githubusercontent.com/numetriclabz/jcenter/master/installv.gradle'
|
||||||
apply from: 'https://raw.githubusercontent.com/numetriclabz/jcenter/master/bintrayv.gradle'
|
apply from: 'https://raw.githubusercontent.com/numetriclabz/jcenter/master/bintrayv.gradle'
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest package="de.c1710.filemojicompat" />
|
||||||
package="de.c1710.filemojicompat" />
|
|
||||||
|
|
Binary file not shown.
|
@ -29,6 +29,7 @@ import android.support.text.emoji.MetadataRepo;
|
||||||
* Based on:
|
* Based on:
|
||||||
* https://android.googlesource.com/platform/frameworks/support/+/master/emoji/bundled/src/main/java/android/support/text/emoji/bundled/BundledEmojiCompatConfig.java
|
* 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.
|
* Changes are marked with comments. Formatting and other simple changes are not always marked.
|
||||||
|
*
|
||||||
* @deprecated Please use {@link FileEmojiCompatConfig#createFromAsset(Context, String)} instead
|
* @deprecated Please use {@link FileEmojiCompatConfig#createFromAsset(Context, String)} instead
|
||||||
* for greater flexibility.
|
* for greater flexibility.
|
||||||
*/
|
*/
|
||||||
|
@ -38,6 +39,7 @@ public class AssetEmojiCompatConfig extends EmojiCompat.Config {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new configuration for this EmojiCompat
|
* Create a new configuration for this EmojiCompat
|
||||||
|
*
|
||||||
* @param assetName The file name/path of the requested font
|
* @param assetName The file name/path of the requested font
|
||||||
* @param context Context instance
|
* @param context Context instance
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -41,7 +41,10 @@ import java.io.InputStream;
|
||||||
public class FileEmojiCompatConfig extends EmojiCompat.Config {
|
public class FileEmojiCompatConfig extends EmojiCompat.Config {
|
||||||
// The class name is obviously changed from the original file
|
// The class name is obviously changed from the original file
|
||||||
private final static String TAG = "FileEmojiCompatConfig";
|
private final static String TAG = "FileEmojiCompatConfig";
|
||||||
|
/**
|
||||||
|
* The default name of the fallback font
|
||||||
|
*/
|
||||||
|
private static final String FONT_FALLBACK = "NoEmojiCompat.ttf";
|
||||||
/**
|
/**
|
||||||
* This boolean indicates whether the fallback solution is used.
|
* This boolean indicates whether the fallback solution is used.
|
||||||
*/
|
*/
|
||||||
|
@ -50,59 +53,10 @@ public class FileEmojiCompatConfig extends EmojiCompat.Config {
|
||||||
* Indicates whether all emojis should be replaced when the fallback font is used.
|
* Indicates whether all emojis should be replaced when the fallback font is used.
|
||||||
*/
|
*/
|
||||||
private boolean replaceAllOnFallback = false;
|
private boolean replaceAllOnFallback = false;
|
||||||
/**
|
|
||||||
* The default name of the fallback font
|
|
||||||
*/
|
|
||||||
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
|
* Create a new configuration for this EmojiCompat
|
||||||
|
*
|
||||||
* @param path The file name/path of the requested font
|
* @param path The file name/path of the requested font
|
||||||
* @param context Context instance
|
* @param context Context instance
|
||||||
*/
|
*/
|
||||||
|
@ -115,6 +69,7 @@ public class FileEmojiCompatConfig extends EmojiCompat.Config {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new configuration for this EmojiCompat
|
* Create a new configuration for this EmojiCompat
|
||||||
|
*
|
||||||
* @param path The file name/path of the requested font
|
* @param path The file name/path of the requested font
|
||||||
* @param context Context instance
|
* @param context Context instance
|
||||||
* @param fallbackFont The asset path of the fallback font
|
* @param fallbackFont The asset path of the fallback font
|
||||||
|
@ -129,6 +84,7 @@ public class FileEmojiCompatConfig extends EmojiCompat.Config {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new configuration for this EmojiCompat based on a file
|
* Create a new configuration for this EmojiCompat based on a file
|
||||||
|
*
|
||||||
* @param context Context instance
|
* @param context Context instance
|
||||||
* @param fontFile The file containing the EmojiCompat font
|
* @param fontFile The file containing the EmojiCompat font
|
||||||
*/
|
*/
|
||||||
|
@ -140,6 +96,7 @@ public class FileEmojiCompatConfig extends EmojiCompat.Config {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new configuration for this EmojiCompat based on a file
|
* Create a new configuration for this EmojiCompat based on a file
|
||||||
|
*
|
||||||
* @param context Context instance
|
* @param context Context instance
|
||||||
* @param fontFile The file containing the EmojiCompat font
|
* @param fontFile The file containing the EmojiCompat font
|
||||||
* @param fallbackFont The asset path of the fallback font
|
* @param fallbackFont The asset path of the fallback font
|
||||||
|
@ -185,6 +142,52 @@ public class FileEmojiCompatConfig extends EmojiCompat.Config {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileEmojiCompatConfig setReplaceAll(boolean replaceAll) {
|
public FileEmojiCompatConfig setReplaceAll(boolean replaceAll) {
|
||||||
return setReplaceAll(replaceAll, replaceAllOnFallback);
|
return setReplaceAll(replaceAll, replaceAllOnFallback);
|
||||||
|
@ -192,6 +195,7 @@ public class FileEmojiCompatConfig extends EmojiCompat.Config {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace all emojis
|
* Replace all emojis
|
||||||
|
*
|
||||||
* @param replaceAll Whether all emojis should be replaced
|
* @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.
|
* @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.
|
* Useful if the NoEmojiCompat.ttf is overridden by a "real" EmojiCompat font.
|
||||||
|
@ -201,8 +205,7 @@ public class FileEmojiCompatConfig extends EmojiCompat.Config {
|
||||||
this.replaceAllOnFallback = replaceAllOnFallback;
|
this.replaceAllOnFallback = replaceAllOnFallback;
|
||||||
if (!fallback || replaceAllOnFallback) {
|
if (!fallback || replaceAllOnFallback) {
|
||||||
super.setReplaceAll(replaceAll);
|
super.setReplaceAll(replaceAll);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
super.setReplaceAll(false);
|
super.setReplaceAll(false);
|
||||||
if (replaceAll) {
|
if (replaceAll) {
|
||||||
// If replaceAll would have been set to false anyway, there's no need for apologizing.
|
// If replaceAll would have been set to false anyway, there's no need for apologizing.
|
||||||
|
@ -274,8 +277,7 @@ public class FileEmojiCompatConfig extends EmojiCompat.Config {
|
||||||
final InputStream stream = new FileInputStream(FONT_FILE);
|
final InputStream stream = new FileInputStream(FONT_FILE);
|
||||||
MetadataRepo resourceIndex = MetadataRepo.create(typeface, stream);
|
MetadataRepo resourceIndex = MetadataRepo.create(typeface, stream);
|
||||||
loaderCallback.onLoaded(resourceIndex);
|
loaderCallback.onLoaded(resourceIndex);
|
||||||
}
|
} catch (Throwable t) {
|
||||||
catch (Throwable t) {
|
|
||||||
// Instead of crashing, this one will first try to load the fallback font
|
// Instead of crashing, this one will first try to load the fallback font
|
||||||
try {
|
try {
|
||||||
android.util.Log.w(TAG, "Error while loading the font file.", t);
|
android.util.Log.w(TAG, "Error while loading the font file.", t);
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
# Project-wide Gradle settings.
|
# Project-wide Gradle settings.
|
||||||
|
|
||||||
# IDE (e.g. Android Studio) users:
|
# IDE (e.g. Android Studio) users:
|
||||||
# Gradle settings configured through the IDE *will override*
|
# Gradle settings configured through the IDE *will override*
|
||||||
# any settings specified in this file.
|
# any settings specified in this file.
|
||||||
|
|
||||||
# For more details on how to configure your build environment visit
|
# For more details on how to configure your build environment visit
|
||||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||||
|
|
||||||
# Specifies the JVM arguments used for the daemon process.
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
# The setting is particularly useful for tweaking memory settings.
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
org.gradle.jvmargs=-Xmx1024m
|
org.gradle.jvmargs=-Xmx1024m
|
||||||
|
|
||||||
# When configured, Gradle will run in incubating parallel mode.
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
# This option should only be used with decoupled projects. More details, visit
|
# This option should only be used with decoupled projects. More details, visit
|
||||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||||
|
|
Loading…
Add table
Reference in a new issue