1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-02-24 15:11:03 +00:00

Updated emoji2

This commit is contained in:
M66B 2023-08-13 21:32:33 +02:00
parent 59f3db62b6
commit 14dda0a5f6
13 changed files with 28 additions and 70 deletions

View file

@ -450,7 +450,7 @@ dependencies {
def annotation_version_experimental = "1.3.1"
def core_version = "1.10.1" // 1.12.0-rc01
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 activity_version = "1.7.2" // 1.8.0-alpha06
def fragment_version = "1.6.1" // 1.7.0-alpha02

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -16,7 +16,6 @@
package androidx.emoji2.text;
import static androidx.annotation.RestrictTo.Scope.LIBRARY;
import static androidx.annotation.RestrictTo.Scope.TESTS;
import android.annotation.SuppressLint;
import android.graphics.Paint;
@ -26,6 +25,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
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}
*
* @hide
*/
@RestrictTo(LIBRARY)
EmojiSpan(@NonNull final TypefaceEmojiRasterizer rasterizer) {
@ -113,7 +112,6 @@ public abstract class EmojiSpan extends ReplacementSpan {
/**
* @return width of the span
*
* @hide
*/
@RestrictTo(LIBRARY)
final int getWidth() {
@ -123,15 +121,14 @@ public abstract class EmojiSpan extends ReplacementSpan {
/**
* @return height of the span
*
* @hide
*/
@RestrictTo(TESTS)
@RestrictTo(LIBRARY)
@VisibleForTesting
public final int getHeight() {
return mHeight;
}
/**
* @hide
*/
@RestrictTo(LIBRARY)
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
*
* @hide
*/
@RestrictTo(TESTS)
@RestrictTo(LIBRARY)
@VisibleForTesting
public final int getId() {
return getTypefaceRasterizer().getId();
}

View file

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

View file

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

View file

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

View file

@ -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
* the framework.
*
* @hide
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
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<>();
/**
* @hide
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
SpannableBuilder(@NonNull Class<?> watcherClass) {
@ -68,7 +66,6 @@ public final class SpannableBuilder extends eu.faircode.email.SpannableStringBui
}
/**
* @hide
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
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)
SpannableBuilder(@NonNull Class<?> watcherClass, @NonNull CharSequence text, int start,
@ -89,7 +85,6 @@ public final class SpannableBuilder extends eu.faircode.email.SpannableStringBui
}
/**
* @hide
*/
@NonNull
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@ -137,7 +132,6 @@ public final class SpannableBuilder extends eu.faircode.email.SpannableStringBui
mWatchers.add(span);
what = span;
}
super.setSpan(what, start, end, flags);
}
@ -255,7 +249,6 @@ public final class SpannableBuilder extends eu.faircode.email.SpannableStringBui
}
/**
* @hide
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
public void beginBatchEdit() {
@ -263,7 +256,6 @@ public final class SpannableBuilder extends eu.faircode.email.SpannableStringBui
}
/**
* @hide
*/
@RestrictTo(RestrictTo.Scope.LIBRARY)
public void endBatchEdit() {

View file

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

View file

@ -21,6 +21,7 @@ import android.graphics.Paint;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.style.CharacterStyle;
import android.text.style.MetricAffectingSpan;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
@ -31,7 +32,6 @@ import androidx.annotation.RestrictTo;
/**
* EmojiSpan subclass used to render emojis using Typeface.
*
* @hide
*/
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
@RequiresApi(19)
@ -122,7 +122,10 @@ public final class TypefaceEmojiSpan extends EmojiSpan {
wp.set(paint);
//noinspection ForLoopReplaceableByForEach
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;
} else {