EmojiCompat.Config
abstract class EmojiCompat.Config
BundledEmojiCompatConfig |
|
FontRequestEmojiCompatConfig |
|
Configuration class for EmojiCompat. Changes to the values will be ignored after init is called.
| See also | |
|---|---|
init |
Summary
Protected constructors |
|---|
Config(metadataLoader: EmojiCompat.MetadataRepoLoader)Default constructor. |
Public functions |
|
|---|---|
EmojiCompat.Config |
registerInitCallback(initCallback: EmojiCompat.InitCallback)Registers an initialization callback. |
EmojiCompat.Config |
registerInitCallback(Registers an initialization callback. |
EmojiCompat.Config |
setEmojiSpanIndicatorColor(color: @ColorInt Int)Sets the color used as emoji span indicator. |
EmojiCompat.Config |
setEmojiSpanIndicatorEnabled(emojiSpanIndicatorEnabled: Boolean)Determines whether a background will be drawn for the emojis that are found and replaced by EmojiCompat. |
EmojiCompat.Config |
setGlyphChecker(glyphChecker: EmojiCompat.GlyphChecker)The interface that is used by EmojiCompat in order to check if a given emoji can be rendered by the system. |
EmojiCompat.Config |
setMetadataLoadStrategy(strategy: Int)Determines the strategy to start loading the metadata. |
EmojiCompat.Config |
setReplaceAll(replaceAll: Boolean)Determines whether EmojiCompat should replace all the emojis it finds with the EmojiSpans. |
EmojiCompat.Config |
setSpanFactory(factory: EmojiCompat.SpanFactory)Set the span factory used to actually draw emoji replacements. |
EmojiCompat.Config |
setUseEmojiAsDefaultStyle(useEmojiAsDefaultStyle: Boolean)Determines whether EmojiCompat should use the emoji presentation style for emojis that have text style as default. |
EmojiCompat.Config |
setUseEmojiAsDefaultStyle( |
EmojiCompat.Config |
unregisterInitCallback(initCallback: EmojiCompat.InitCallback)Unregisters a callback that was added before. |
Protected functions |
|
|---|---|
EmojiCompat.MetadataRepoLoader |
Returns the |
Protected constructors
Config
protected Config(metadataLoader: EmojiCompat.MetadataRepoLoader)
Default constructor.
| Parameters | |
|---|---|
metadataLoader: EmojiCompat.MetadataRepoLoader |
MetadataRepoLoader instance, cannot be |
Public functions
registerInitCallback
fun registerInitCallback(initCallback: EmojiCompat.InitCallback): EmojiCompat.Config
Registers an initialization callback.
| Parameters | |
|---|---|
initCallback: EmojiCompat.InitCallback |
the initialization callback to register, cannot be |
| Returns | |
|---|---|
EmojiCompat.Config |
EmojiCompat.Config instance |
registerInitCallback
fun registerInitCallback(
executor: Executor,
initCallback: EmojiCompat.InitCallback
): EmojiCompat.Config
Registers an initialization callback.
| Parameters | |
|---|---|
executor: Executor |
executor to dispatch callback on |
initCallback: EmojiCompat.InitCallback |
the initialization callback to register, cannot be |
| Returns | |
|---|---|
EmojiCompat.Config |
EmojiCompat.Config instance |
setEmojiSpanIndicatorColor
fun setEmojiSpanIndicatorColor(color: @ColorInt Int): EmojiCompat.Config
Sets the color used as emoji span indicator. The default value is Color.GREEN.
| See also | |
|---|---|
setEmojiSpanIndicatorEnabled |
setEmojiSpanIndicatorEnabled
fun setEmojiSpanIndicatorEnabled(emojiSpanIndicatorEnabled: Boolean): EmojiCompat.Config
Determines whether a background will be drawn for the emojis that are found and replaced by EmojiCompat. Should be used only for debugging purposes. The indicator color can be set using setEmojiSpanIndicatorColor.
| Parameters | |
|---|---|
emojiSpanIndicatorEnabled: Boolean |
when |
setGlyphChecker
fun setGlyphChecker(glyphChecker: EmojiCompat.GlyphChecker): EmojiCompat.Config
The interface that is used by EmojiCompat in order to check if a given emoji can be rendered by the system.
| Parameters | |
|---|---|
glyphChecker: EmojiCompat.GlyphChecker |
|
setMetadataLoadStrategy
fun setMetadataLoadStrategy(strategy: Int): EmojiCompat.Config
Determines the strategy to start loading the metadata. By default EmojiCompat will start loading the metadata during init. When set to LOAD_STRATEGY_MANUAL, you should call load to initiate metadata loading.
EmojiCompat.MetadataRepoLoader start a thread during their load functions. Just instantiating and starting a thread might take time especially in older devices. Since init has to be called before any EmojiCompat widgets are inflated, this results in time spent either on your Application.onCreate or Activity .onCreate. If you'd like to gain more control on when to start loading the metadata and be able to call init with absolute minimum time cost you can use LOAD_STRATEGY_MANUAL. When set to LOAD_STRATEGY_MANUAL, EmojiCompat will wait for load to be called by the developer in order to start loading metadata, therefore you should call load to initiate metadata loading. load can be called from any thread.
EmojiCompat.Config config = new FontRequestEmojiCompatConfig(context, fontRequest) .setMetadataLoadStrategy(EmojiCompat.LOAD_STRATEGY_MANUAL); // EmojiCompat will not start loading metadata and MetadataRepoLoader#load(...) // will not be called EmojiCompat.init(config); // At any time (i.e. idle time or executorService is ready) // call EmojiCompat#load() to start loading metadata. executorService.execute(() -> EmojiCompat.get().load());
| Parameters | |
|---|---|
strategy: Int |
setReplaceAll
fun setReplaceAll(replaceAll: Boolean): EmojiCompat.Config
Determines whether EmojiCompat should replace all the emojis it finds with the EmojiSpans. By default EmojiCompat tries its best to understand if the system already can render an emoji and do not replace those emojis.
| Parameters | |
|---|---|
replaceAll: Boolean |
replace all emojis found with EmojiSpans |
| Returns | |
|---|---|
EmojiCompat.Config |
EmojiCompat.Config instance |
setSpanFactory
fun setSpanFactory(factory: EmojiCompat.SpanFactory): EmojiCompat.Config
Set the span factory used to actually draw emoji replacements.
| Parameters | |
|---|---|
factory: EmojiCompat.SpanFactory |
custum span factory that can draw the emoji replacements |
| Returns | |
|---|---|
EmojiCompat.Config |
this |
setUseEmojiAsDefaultStyle
fun setUseEmojiAsDefaultStyle(useEmojiAsDefaultStyle: Boolean): EmojiCompat.Config
Determines whether EmojiCompat should use the emoji presentation style for emojis that have text style as default. By default, the text style would be used, unless these are followed by the U+FE0F variation selector. Details about emoji presentation and text presentation styles can be found here: http://unicode.org/reports/tr51/#Presentation_Style If useEmojiAsDefaultStyle is true, the emoji presentation style will be used for all emojis, including potentially unexpected ones (such as digits or other keycap emojis). If this is not the expected behaviour, method setUseEmojiAsDefaultStyle can be used to specify the exception emojis that should be still presented as text style.
| Parameters | |
|---|---|
useEmojiAsDefaultStyle: Boolean |
whether to use the emoji style presentation for all emojis that would be presented as text style by default |
setUseEmojiAsDefaultStyle
fun setUseEmojiAsDefaultStyle(
useEmojiAsDefaultStyle: Boolean,
emojiAsDefaultStyleExceptions: (Mutable)List<Int!>?
): EmojiCompat.Config
| Parameters | |
|---|---|
emojiAsDefaultStyleExceptions: (Mutable)List<Int!>? |
Contains the exception emojis which will be still presented as text style even if the useEmojiAsDefaultStyle flag is set to |
| See also | |
|---|---|
setUseEmojiAsDefaultStyle |
unregisterInitCallback
fun unregisterInitCallback(initCallback: EmojiCompat.InitCallback): EmojiCompat.Config
Unregisters a callback that was added before.
| Parameters | |
|---|---|
initCallback: EmojiCompat.InitCallback |
the initialization callback to be removed, cannot be |
| Returns | |
|---|---|
EmojiCompat.Config |
EmojiCompat.Config instance |
Protected functions
getMetadataRepoLoader
protected fun getMetadataRepoLoader(): EmojiCompat.MetadataRepoLoader
Returns the MetadataRepoLoader.