Updated emoji2

pull/213/head
M66B 2 years ago
parent 59f3db62b6
commit 14dda0a5f6

@ -450,7 +450,7 @@ dependencies {
def annotation_version_experimental = "1.3.1" def annotation_version_experimental = "1.3.1"
def core_version = "1.10.1" // 1.12.0-rc01 def core_version = "1.10.1" // 1.12.0-rc01
def appcompat_version = "1.6.1" // 1.7.0-alpha03 def appcompat_version = "1.6.1" // 1.7.0-alpha03
def emoji_version = "1.3.0" // Version 1.4.0-rc01 def emoji_version = "1.4.0"
def flatbuffers_version = "2.0.0" def flatbuffers_version = "2.0.0"
def activity_version = "1.7.2" // 1.8.0-alpha06 def activity_version = "1.7.2" // 1.8.0-alpha06
def fragment_version = "1.6.1" // 1.7.0-alpha02 def fragment_version = "1.6.1" // 1.7.0-alpha02

@ -102,7 +102,6 @@ public final class DefaultEmojiCompatConfig {
* Actual factory for generating default emoji configs, does service locator lookup internally. * Actual factory for generating default emoji configs, does service locator lookup internally.
* *
* @see DefaultEmojiCompatConfig#create * @see DefaultEmojiCompatConfig#create
* @hide
*/ */
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
public static class DefaultEmojiCompatConfigFactory { public static class DefaultEmojiCompatConfigFactory {
@ -113,7 +112,6 @@ public final class DefaultEmojiCompatConfig {
private final DefaultEmojiCompatConfigHelper mHelper; private final DefaultEmojiCompatConfigHelper mHelper;
/** /**
* @hide
*/ */
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
public DefaultEmojiCompatConfigFactory(@Nullable DefaultEmojiCompatConfigHelper helper) { public DefaultEmojiCompatConfigFactory(@Nullable DefaultEmojiCompatConfigHelper helper) {
@ -122,7 +120,6 @@ public final class DefaultEmojiCompatConfig {
/** /**
* @see DefaultEmojiCompatConfig#create * @see DefaultEmojiCompatConfig#create
* @hide
*/ */
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
@Nullable @Nullable
@ -150,7 +147,6 @@ public final class DefaultEmojiCompatConfig {
* Find the installed font provider and return a FontInfo that describes it. * Find the installed font provider and return a FontInfo that describes it.
* @param context context for getting package manager * @param context context for getting package manager
* @return valid FontRequest, or null if no provider could be found * @return valid FontRequest, or null if no provider could be found
* @hide
*/ */
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
@Nullable @Nullable
@ -256,7 +252,6 @@ public final class DefaultEmojiCompatConfig {
/** /**
* Helper to lookup signatures in package manager. * Helper to lookup signatures in package manager.
* *
* @hide
*/ */
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
public static class DefaultEmojiCompatConfigHelper { public static class DefaultEmojiCompatConfigHelper {
@ -295,7 +290,6 @@ public final class DefaultEmojiCompatConfig {
/** /**
* Actually do lookups > API 19 * Actually do lookups > API 19
* *
* @hide
*/ */
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
@RequiresApi(19) @RequiresApi(19)
@ -318,7 +312,6 @@ public final class DefaultEmojiCompatConfig {
/** /**
* Helper to lookup signatures in package manager > API 28 * Helper to lookup signatures in package manager > API 28
* @hide
*/ */
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
@RequiresApi(28) @RequiresApi(28)

@ -29,7 +29,6 @@ import androidx.core.graphics.PaintCompat;
/** /**
* Utility class that checks if the system can render a given glyph. * Utility class that checks if the system can render a given glyph.
* *
* @hide
*/ */
@AnyThread @AnyThread
@RestrictTo(LIBRARY) @RestrictTo(LIBRARY)

@ -17,7 +17,6 @@ package androidx.emoji2.text;
import static androidx.annotation.RestrictTo.Scope.LIBRARY; import static androidx.annotation.RestrictTo.Scope.LIBRARY;
import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP; import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP;
import static androidx.annotation.RestrictTo.Scope.TESTS;
import android.app.Application; import android.app.Application;
import android.content.Context; import android.content.Context;
@ -43,6 +42,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo; import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.collection.ArraySet; import androidx.collection.ArraySet;
import androidx.core.util.Preconditions; import androidx.core.util.Preconditions;
@ -160,7 +160,6 @@ public class EmojiCompat {
public static final int LOAD_STATE_FAILED = 2; public static final int LOAD_STATE_FAILED = 2;
/** /**
* @hide
*/ */
@RestrictTo(LIBRARY) @RestrictTo(LIBRARY)
@IntDef({LOAD_STATE_DEFAULT, LOAD_STATE_LOADING, LOAD_STATE_SUCCEEDED, LOAD_STATE_FAILED}) @IntDef({LOAD_STATE_DEFAULT, LOAD_STATE_LOADING, LOAD_STATE_SUCCEEDED, LOAD_STATE_FAILED})
@ -188,7 +187,6 @@ public class EmojiCompat {
public static final int REPLACE_STRATEGY_NON_EXISTENT = 2; public static final int REPLACE_STRATEGY_NON_EXISTENT = 2;
/** /**
* @hide
*/ */
@RestrictTo(LIBRARY) @RestrictTo(LIBRARY)
@IntDef({REPLACE_STRATEGY_DEFAULT, REPLACE_STRATEGY_NON_EXISTENT, REPLACE_STRATEGY_ALL}) @IntDef({REPLACE_STRATEGY_DEFAULT, REPLACE_STRATEGY_NON_EXISTENT, REPLACE_STRATEGY_ALL})
@ -212,7 +210,6 @@ public class EmojiCompat {
public static final int LOAD_STRATEGY_MANUAL = 1; public static final int LOAD_STRATEGY_MANUAL = 1;
/** /**
* @hide
*/ */
@RestrictTo(LIBRARY) @RestrictTo(LIBRARY)
@IntDef({LOAD_STRATEGY_DEFAULT, LOAD_STRATEGY_MANUAL}) @IntDef({LOAD_STRATEGY_DEFAULT, LOAD_STRATEGY_MANUAL})
@ -221,7 +218,6 @@ public class EmojiCompat {
} }
/** /**
* @hide
*/ */
@RestrictTo(LIBRARY) @RestrictTo(LIBRARY)
@IntDef({EMOJI_UNSUPPORTED, EMOJI_SUPPORTED, @IntDef({EMOJI_UNSUPPORTED, EMOJI_SUPPORTED,
@ -341,7 +337,6 @@ public class EmojiCompat {
public static final int EMOJI_FALLBACK = 2; public static final int EMOJI_FALLBACK = 2;
/** /**
* @hide
*/ */
@RestrictTo(LIBRARY) @RestrictTo(LIBRARY)
static final int EMOJI_COUNT_UNLIMITED = Integer.MAX_VALUE; static final int EMOJI_COUNT_UNLIMITED = Integer.MAX_VALUE;
@ -502,7 +497,6 @@ public class EmojiCompat {
} }
/** /**
* @hide
*/ */
@RestrictTo(LIBRARY) @RestrictTo(LIBRARY)
@Nullable @Nullable
@ -602,8 +596,8 @@ public class EmojiCompat {
* Used by the tests to reset EmojiCompat with a new configuration. Every time it is called a * Used by the tests to reset EmojiCompat with a new configuration. Every time it is called a
* new instance is created with the new configuration. * new instance is created with the new configuration.
* *
* @hide
*/ */
@RestrictTo(LIBRARY)
@NonNull @NonNull
public static EmojiCompat reset(@NonNull final Config config) { public static EmojiCompat reset(@NonNull final Config config) {
synchronized (INSTANCE_LOCK) { synchronized (INSTANCE_LOCK) {
@ -616,9 +610,9 @@ public class EmojiCompat {
/** /**
* Used by the tests to reset EmojiCompat with a new singleton instance. * Used by the tests to reset EmojiCompat with a new singleton instance.
* *
* @hide
*/ */
@RestrictTo(TESTS) @RestrictTo(LIBRARY)
@VisibleForTesting
@Nullable @Nullable
public static EmojiCompat reset(@Nullable final EmojiCompat emojiCompat) { public static EmojiCompat reset(@Nullable final EmojiCompat emojiCompat) {
synchronized (INSTANCE_LOCK) { synchronized (INSTANCE_LOCK) {
@ -630,9 +624,9 @@ public class EmojiCompat {
/** /**
* Reset default configuration lookup flag, for tests. * Reset default configuration lookup flag, for tests.
* *
* @hide
*/ */
@RestrictTo(TESTS) @RestrictTo(LIBRARY)
@VisibleForTesting
public static void skipDefaultConfigurationLookup(boolean shouldSkip) { public static void skipDefaultConfigurationLookup(boolean shouldSkip) {
synchronized (CONFIG_LOCK) { synchronized (CONFIG_LOCK) {
sHasDoneDefaultConfigLookup = shouldSkip; sHasDoneDefaultConfigLookup = shouldSkip;
@ -801,7 +795,6 @@ public class EmojiCompat {
/** /**
* @return whether a background should be drawn for the emoji for debugging * @return whether a background should be drawn for the emoji for debugging
* @hide
*/ */
@RestrictTo(LIBRARY_GROUP) @RestrictTo(LIBRARY_GROUP)
public boolean isEmojiSpanIndicatorEnabled() { public boolean isEmojiSpanIndicatorEnabled() {
@ -810,7 +803,6 @@ public class EmojiCompat {
/** /**
* @return color of background drawn if {@link EmojiCompat#isEmojiSpanIndicatorEnabled} is true * @return color of background drawn if {@link EmojiCompat#isEmojiSpanIndicatorEnabled} is true
* @hide
*/ */
@RestrictTo(LIBRARY_GROUP) @RestrictTo(LIBRARY_GROUP)
public @ColorInt int getEmojiSpanIndicatorColor() { public @ColorInt int getEmojiSpanIndicatorColor() {
@ -830,6 +822,8 @@ public class EmojiCompat {
*/ */
public int getEmojiStart(@NonNull final CharSequence charSequence, public int getEmojiStart(@NonNull final CharSequence charSequence,
@IntRange(from = 0) int offset) { @IntRange(from = 0) int offset) {
Preconditions.checkState(isInitialized(), "Not initialized yet");
Preconditions.checkNotNull(charSequence, "charSequence cannot be null");
return mHelper.getEmojiStart(charSequence, offset); return mHelper.getEmojiStart(charSequence, offset);
} }
@ -838,6 +832,8 @@ public class EmojiCompat {
*/ */
public int getEmojiEnd(@NonNull final CharSequence charSequence, public int getEmojiEnd(@NonNull final CharSequence charSequence,
@IntRange(from = 0) int offset) { @IntRange(from = 0) int offset) {
Preconditions.checkState(isInitialized(), "Not initialized yet");
Preconditions.checkNotNull(charSequence, "charSequence cannot be null");
return mHelper.getEmojiEnd(charSequence, offset); return mHelper.getEmojiEnd(charSequence, offset);
} }
@ -1201,7 +1197,6 @@ public class EmojiCompat {
/** /**
* @hide
*/ */
@RestrictTo(LIBRARY) @RestrictTo(LIBRARY)
public static class DefaultSpanFactory implements SpanFactory { public static class DefaultSpanFactory implements SpanFactory {

@ -21,7 +21,6 @@ import androidx.annotation.RestrictTo;
/** /**
* Defaults for emojicompat * Defaults for emojicompat
* *
* @hide
*/ */
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
public class EmojiDefaults { public class EmojiDefaults {

@ -45,7 +45,6 @@ import java.util.Set;
/** /**
* Processes the CharSequence and adds the emojis. * Processes the CharSequence and adds the emojis.
* *
* @hide
*/ */
@AnyThread @AnyThread
@RestrictTo(LIBRARY) @RestrictTo(LIBRARY)

@ -16,7 +16,6 @@
package androidx.emoji2.text; package androidx.emoji2.text;
import static androidx.annotation.RestrictTo.Scope.LIBRARY; import static androidx.annotation.RestrictTo.Scope.LIBRARY;
import static androidx.annotation.RestrictTo.Scope.TESTS;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.graphics.Paint; import android.graphics.Paint;
@ -26,6 +25,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo; import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.core.util.Preconditions; import androidx.core.util.Preconditions;
/** /**
@ -68,7 +68,6 @@ public abstract class EmojiSpan extends ReplacementSpan {
* *
* @param rasterizer information about the emoji, cannot be {@code null} * @param rasterizer information about the emoji, cannot be {@code null}
* *
* @hide
*/ */
@RestrictTo(LIBRARY) @RestrictTo(LIBRARY)
EmojiSpan(@NonNull final TypefaceEmojiRasterizer rasterizer) { EmojiSpan(@NonNull final TypefaceEmojiRasterizer rasterizer) {
@ -113,7 +112,6 @@ public abstract class EmojiSpan extends ReplacementSpan {
/** /**
* @return width of the span * @return width of the span
* *
* @hide
*/ */
@RestrictTo(LIBRARY) @RestrictTo(LIBRARY)
final int getWidth() { final int getWidth() {
@ -123,15 +121,14 @@ public abstract class EmojiSpan extends ReplacementSpan {
/** /**
* @return height of the span * @return height of the span
* *
* @hide
*/ */
@RestrictTo(TESTS) @RestrictTo(LIBRARY)
@VisibleForTesting
public final int getHeight() { public final int getHeight() {
return mHeight; return mHeight;
} }
/** /**
* @hide
*/ */
@RestrictTo(LIBRARY) @RestrictTo(LIBRARY)
final float getRatio() { final float getRatio() {
@ -141,9 +138,9 @@ public abstract class EmojiSpan extends ReplacementSpan {
/** /**
* @return unique id for the emoji that this EmojiSpan is used for * @return unique id for the emoji that this EmojiSpan is used for
* *
* @hide
*/ */
@RestrictTo(TESTS) @RestrictTo(LIBRARY)
@VisibleForTesting
public final int getId() { public final int getId() {
return getTypefaceRasterizer().getId(); return getTypefaceRasterizer().getId();
} }

@ -123,7 +123,6 @@ public class FontRequestEmojiCompatConfig extends EmojiCompat.Config {
} }
/** /**
* @hide
*/ */
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
public FontRequestEmojiCompatConfig(@NonNull Context context, @NonNull FontRequest request, public FontRequestEmojiCompatConfig(@NonNull Context context, @NonNull FontRequest request,
@ -406,7 +405,6 @@ public class FontRequestEmojiCompatConfig extends EmojiCompat.Config {
/** /**
* Delegate class for mocking FontsContractCompat.fetchFonts. * Delegate class for mocking FontsContractCompat.fetchFonts.
* @hide
*/ */
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
public static class FontProviderHelper { public static class FontProviderHelper {

@ -32,7 +32,6 @@ import java.nio.ByteOrder;
/** /**
* Reads the emoji metadata from a given InputStream or ByteBuffer. * Reads the emoji metadata from a given InputStream or ByteBuffer.
* *
* @hide
*/ */
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
@AnyThread @AnyThread

@ -15,6 +15,8 @@
*/ */
package androidx.emoji2.text; package androidx.emoji2.text;
import static androidx.annotation.RestrictTo.Scope.LIBRARY;
import android.content.res.AssetManager; import android.content.res.AssetManager;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.util.SparseArray; import android.util.SparseArray;
@ -85,10 +87,10 @@ public final class MetadataRepo {
* Construct MetadataRepo with empty metadata. * Construct MetadataRepo with empty metadata.
* *
* This should only be used from tests. * This should only be used from tests.
* @hide
*/ */
@RestrictTo(LIBRARY)
@NonNull @NonNull
@RestrictTo(RestrictTo.Scope.TESTS) @VisibleForTesting
public static MetadataRepo create(@NonNull final Typeface typeface) { public static MetadataRepo create(@NonNull final Typeface typeface) {
try { try {
TraceCompat.beginSection(S_TRACE_CREATE_REPO); TraceCompat.beginSection(S_TRACE_CREATE_REPO);
@ -170,7 +172,6 @@ public final class MetadataRepo {
} }
/** /**
* @hide
*/ */
@NonNull @NonNull
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
@ -179,7 +180,6 @@ public final class MetadataRepo {
} }
/** /**
* @hide
*/ */
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
int getMetadataVersion() { int getMetadataVersion() {
@ -187,7 +187,6 @@ public final class MetadataRepo {
} }
/** /**
* @hide
*/ */
@NonNull @NonNull
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
@ -196,7 +195,6 @@ public final class MetadataRepo {
} }
/** /**
* @hide
*/ */
@NonNull @NonNull
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
@ -205,7 +203,6 @@ public final class MetadataRepo {
} }
/** /**
* @hide
*/ */
@NonNull @NonNull
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
@ -216,7 +213,6 @@ public final class MetadataRepo {
/** /**
* Add a TypefaceEmojiRasterizer to the index. * Add a TypefaceEmojiRasterizer to the index.
* *
* @hide
*/ */
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
@VisibleForTesting @VisibleForTesting
@ -233,7 +229,6 @@ public final class MetadataRepo {
* *
* A single codepoint emoji is represented by a child of the root node. * A single codepoint emoji is represented by a child of the root node.
* *
* @hide
*/ */
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
static class Node { static class Node {

@ -44,7 +44,6 @@ import java.util.concurrent.atomic.AtomicInteger;
* applied only for EmojiSpans. Therefore any other span change operation works the same way as in * applied only for EmojiSpans. Therefore any other span change operation works the same way as in
* the framework. * the framework.
* *
* @hide
*/ */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public final class SpannableBuilder extends eu.faircode.email.SpannableStringBuilderEx { public final class SpannableBuilder extends eu.faircode.email.SpannableStringBuilderEx {
@ -59,7 +58,6 @@ public final class SpannableBuilder extends eu.faircode.email.SpannableStringBui
private final @NonNull List<WatcherWrapper> mWatchers = new ArrayList<>(); private final @NonNull List<WatcherWrapper> mWatchers = new ArrayList<>();
/** /**
* @hide
*/ */
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
SpannableBuilder(@NonNull Class<?> watcherClass) { SpannableBuilder(@NonNull Class<?> watcherClass) {
@ -68,7 +66,6 @@ public final class SpannableBuilder extends eu.faircode.email.SpannableStringBui
} }
/** /**
* @hide
*/ */
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
SpannableBuilder(@NonNull Class<?> watcherClass, @NonNull CharSequence text) { SpannableBuilder(@NonNull Class<?> watcherClass, @NonNull CharSequence text) {
@ -78,7 +75,6 @@ public final class SpannableBuilder extends eu.faircode.email.SpannableStringBui
} }
/** /**
* @hide
*/ */
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
SpannableBuilder(@NonNull Class<?> watcherClass, @NonNull CharSequence text, int start, SpannableBuilder(@NonNull Class<?> watcherClass, @NonNull CharSequence text, int start,
@ -89,7 +85,6 @@ public final class SpannableBuilder extends eu.faircode.email.SpannableStringBui
} }
/** /**
* @hide
*/ */
@NonNull @NonNull
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@ -137,7 +132,6 @@ public final class SpannableBuilder extends eu.faircode.email.SpannableStringBui
mWatchers.add(span); mWatchers.add(span);
what = span; what = span;
} }
super.setSpan(what, start, end, flags); super.setSpan(what, start, end, flags);
} }
@ -255,7 +249,6 @@ public final class SpannableBuilder extends eu.faircode.email.SpannableStringBui
} }
/** /**
* @hide
*/ */
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
public void beginBatchEdit() { public void beginBatchEdit() {
@ -263,7 +256,6 @@ public final class SpannableBuilder extends eu.faircode.email.SpannableStringBui
} }
/** /**
* @hide
*/ */
@RestrictTo(RestrictTo.Scope.LIBRARY) @RestrictTo(RestrictTo.Scope.LIBRARY)
public void endBatchEdit() { public void endBatchEdit() {

@ -17,7 +17,6 @@ package androidx.emoji2.text;
import static androidx.annotation.RestrictTo.Scope.LIBRARY; import static androidx.annotation.RestrictTo.Scope.LIBRARY;
import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP; import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP;
import static androidx.annotation.RestrictTo.Scope.TESTS;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.graphics.Canvas; import android.graphics.Canvas;
@ -30,6 +29,7 @@ import androidx.annotation.IntRange;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo; import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
import androidx.emoji2.text.flatbuffer.MetadataItem; import androidx.emoji2.text.flatbuffer.MetadataItem;
import androidx.emoji2.text.flatbuffer.MetadataList; import androidx.emoji2.text.flatbuffer.MetadataList;
@ -54,7 +54,6 @@ import java.lang.annotation.RetentionPolicy;
public class TypefaceEmojiRasterizer { public class TypefaceEmojiRasterizer {
/** /**
* Defines whether the system can render the emoji. * Defines whether the system can render the emoji.
* @hide
*/ */
@IntDef({HAS_GLYPH_UNKNOWN, HAS_GLYPH_ABSENT, HAS_GLYPH_EXISTS}) @IntDef({HAS_GLYPH_UNKNOWN, HAS_GLYPH_ABSENT, HAS_GLYPH_EXISTS})
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@ -64,21 +63,18 @@ public class TypefaceEmojiRasterizer {
/** /**
* Not calculated on device yet. * Not calculated on device yet.
* @hide
*/ */
@RestrictTo(LIBRARY) @RestrictTo(LIBRARY)
static final int HAS_GLYPH_UNKNOWN = 0; static final int HAS_GLYPH_UNKNOWN = 0;
/** /**
* Device cannot render the emoji. * Device cannot render the emoji.
* @hide
*/ */
@RestrictTo(LIBRARY) @RestrictTo(LIBRARY)
static final int HAS_GLYPH_ABSENT = 1; static final int HAS_GLYPH_ABSENT = 1;
/** /**
* Device can render the emoji. * Device can render the emoji.
* @hide
*/ */
@RestrictTo(LIBRARY) @RestrictTo(LIBRARY)
static final int HAS_GLYPH_EXISTS = 2; static final int HAS_GLYPH_EXISTS = 2;
@ -108,7 +104,6 @@ public class TypefaceEmojiRasterizer {
private volatile int mCache = 0; private volatile int mCache = 0;
/** /**
* @hide
*/ */
@RestrictTo(LIBRARY) @RestrictTo(LIBRARY)
TypefaceEmojiRasterizer(@NonNull final MetadataRepo metadataRepo, TypefaceEmojiRasterizer(@NonNull final MetadataRepo metadataRepo,
@ -172,7 +167,6 @@ public class TypefaceEmojiRasterizer {
* Unique id for the emoji, as loaded from the font file. * Unique id for the emoji, as loaded from the font file.
* *
* @return unique id for the emoji * @return unique id for the emoji
* @hide
*/ */
@RestrictTo(LIBRARY) @RestrictTo(LIBRARY)
public int getId() { public int getId() {
@ -195,7 +189,6 @@ public class TypefaceEmojiRasterizer {
/** /**
* @return in which metadata version the emoji was added * @return in which metadata version the emoji was added
* @hide
*/ */
@RestrictTo(LIBRARY) @RestrictTo(LIBRARY)
public short getCompatAdded() { public short getCompatAdded() {
@ -204,7 +197,6 @@ public class TypefaceEmojiRasterizer {
/** /**
* @return first SDK that the support for this emoji was added * @return first SDK that the support for this emoji was added
* @hide
*/ */
@RestrictTo(LIBRARY) @RestrictTo(LIBRARY)
public short getSdkAdded() { public short getSdkAdded() {
@ -219,7 +211,6 @@ public class TypefaceEmojiRasterizer {
* *
* @see TypefaceEmojiRasterizer#setHasGlyph * @see TypefaceEmojiRasterizer#setHasGlyph
* @return the set value of hasGlyph for this metadata item * @return the set value of hasGlyph for this metadata item
* @hide
*/ */
@HasGlyph @HasGlyph
@SuppressLint("KotlinPropertyAccess") @SuppressLint("KotlinPropertyAccess")
@ -233,9 +224,9 @@ public class TypefaceEmojiRasterizer {
* *
* This is only useful for testing, and will make the next display of this emoji slower. * This is only useful for testing, and will make the next display of this emoji slower.
* *
* @hide
*/ */
@RestrictTo(TESTS) @RestrictTo(LIBRARY)
@VisibleForTesting
public void resetHasGlyphCache() { public void resetHasGlyphCache() {
boolean willExclude = isPreferredSystemRender(); boolean willExclude = isPreferredSystemRender();
if (willExclude) { if (willExclude) {
@ -250,7 +241,6 @@ public class TypefaceEmojiRasterizer {
* *
* @see PaintCompat#hasGlyph * @see PaintCompat#hasGlyph
* @param hasGlyph {@code true} if system can render the emoji * @param hasGlyph {@code true} if system can render the emoji
* @hide
*/ */
@SuppressLint("KotlinPropertyAccess") @SuppressLint("KotlinPropertyAccess")
@RestrictTo(LIBRARY) @RestrictTo(LIBRARY)
@ -268,7 +258,6 @@ public class TypefaceEmojiRasterizer {
* If this emoji is excluded due to CodepointExclusions.getExcludedCodpoints() * If this emoji is excluded due to CodepointExclusions.getExcludedCodpoints()
* *
* @param exclude if the emoji should never be rendered by emojicompat * @param exclude if the emoji should never be rendered by emojicompat
* @hide
*/ */
@RestrictTo(LIBRARY) @RestrictTo(LIBRARY)
public void setExclusion(boolean exclude) { public void setExclusion(boolean exclude) {

@ -21,6 +21,7 @@ import android.graphics.Paint;
import android.text.Spanned; import android.text.Spanned;
import android.text.TextPaint; import android.text.TextPaint;
import android.text.style.CharacterStyle; import android.text.style.CharacterStyle;
import android.text.style.MetricAffectingSpan;
import androidx.annotation.IntRange; import androidx.annotation.IntRange;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -31,7 +32,6 @@ import androidx.annotation.RestrictTo;
/** /**
* EmojiSpan subclass used to render emojis using Typeface. * EmojiSpan subclass used to render emojis using Typeface.
* *
* @hide
*/ */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@RequiresApi(19) @RequiresApi(19)
@ -122,7 +122,10 @@ public final class TypefaceEmojiSpan extends EmojiSpan {
wp.set(paint); wp.set(paint);
//noinspection ForLoopReplaceableByForEach //noinspection ForLoopReplaceableByForEach
for (int pos = 0; pos < spans.length; pos++) { for (int pos = 0; pos < spans.length; pos++) {
spans[pos].updateDrawState(wp); if (!(spans[pos] instanceof MetricAffectingSpan)) {
// we're in draw, so at this point we can't do anything to metrics don't try
spans[pos].updateDrawState(wp);
}
} }
return wp; return wp;
} else { } else {

Loading…
Cancel
Save