Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: update emoji.json now includes hex, dec and unicode along with removal of AbstractEmoji and expose IEmoji #224

Merged
merged 2 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 33 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ You must use one of our artifacts `kotlinx`, `gson` or `moshi` for deserializati
e.g.
```groovy
dependencies {
implementation 'com.github.anitrend:android-emojify:{latest_version}'
implementation 'com.github.anitrend:android-emojify:contract:{latest_version}'
implementation 'com.github.anitrend:android-emojify:kotlinx:{latest_version}'
implementation 'com.github.anitrend.android-emojify:emojify:{latest_version}'
implementation 'com.github.anitrend.android-emojify:contract:{latest_version}'
implementation 'com.github.anitrend.android-emojify:kotlinx:{latest_version}'
}
```

Expand All @@ -88,18 +88,39 @@ class App : Application() {

### Step4. Optional - Init EmojiManager with androidx-startup
```kotlin
class EmojiInitializer : AbstractEmojiInitializer() {
override val serializer: IEmojiDeserializer = KotlinxDeserializer()
class EmojiInitializer : Initializer<EmojiManager> {
private val serializer: IEmojiDeserializer = KotlinxDeserializer()

/**
* Initializes and a component given the application [Context]
*
* @param context The application context.
*/
override fun create(context: Context) = EmojiManager.create(context, serializer)

/**
* @return A list of dependencies that this [Initializer] depends on. This is
* used to determine initialization order of [Initializer]s.
*
* For e.g. if a [Initializer] `B` defines another
* [Initializer] `A` as its dependency, then `A` gets initialized before `B`.
*/
override fun dependencies() = emptyList<Class<out Initializer<*>>>()
}


class App : Application() {
internal val emojiManager: EmojiManager by lazy {
// should already be initialized if we haven't disabled initialization in manifest
// see: https://developer.android.com/topic/libraries/app-startup#disable-individual
AppInitializer.getInstance(this)
.initializeComponent(EmojiInitializer::class.java)
}

/**
* Application scope bound emojiManager, you could keep a reference to this object in a
* dependency injector framework like as a singleton in `Hilt`, `Dagger` or `Koin`
*/
internal val startupEmojiManager: EmojiManager by lazy {
// should already be initialized if we haven't disabled initialization in manifest
// see: https://developer.android.com/topic/libraries/app-startup#disable-individual
AppInitializer.getInstance(this)
.initializeComponent(EmojiInitializer::class.java)
}
}
```

Expand All @@ -111,7 +132,7 @@ class App : Application() {
android:exported="false"
tools:node="merge">
<meta-data
android:name="io.wax911.emojify.initializer.EmojiInitializer"
android:name="{some_package_name_of_your_choosing}.EmojiInitializer"
android:value="androidx.startup" />
</provider>
```
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
<meta-data
android:name="io.wax911.emojifysample.EmojiInitializer"
android:value="androidx.startup" />
<meta-data
android:name="io.wax911.emojify.initializer.AbstractEmojiInitializer"
android:value="androidx.startup"
tools:node="remove"/>
</provider>
</application>

Expand Down
3 changes: 3 additions & 0 deletions contract/consumer-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-keep interface io.wax911.emojify.contract.serializer.IEmojiDeserializer
-keep interface io.wax911.emojify.contract.model.IEmoji
-keep class io.wax911.emojify.contract.util.trie.Matches

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,14 @@ package io.wax911.emojify.contract.model
* @property supportsGender true if the emoji supports the gender modifiers, else false
* @property tags a list of tags for this emoji
*/
internal interface IEmoji {
interface IEmoji {
val aliases: List<String>?
val description: String?
val emoji: String
val emojiChar: String
val supportsFitzpatrick: Boolean
val supportsGender: Boolean
val tags: List<String>?

val unicode: String
val htmlDec: String
val htmlHex: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

package io.wax911.emojify.contract.serializer

import io.wax911.emojify.contract.model.AbstractEmoji
import io.wax911.emojify.contract.model.IEmoji
import java.io.InputStream

/**
* Interface to implement for custom deserializer.
*/
interface IEmojiDeserializer {
/**
* Decodes the given [InputStream] to an object of type List<[AbstractEmoji]>
* Decodes the given [InputStream] to an object of type List<[IEmoji]>
*/
fun decodeFromStream(inputStream: InputStream): List<AbstractEmoji>
fun decodeFromStream(inputStream: InputStream): List<IEmoji>
}
4 changes: 4 additions & 0 deletions emojify/consumer-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-keepattributes *Annotation*, InnerClasses
-keepclassmembers class io.wax911.emojify.** {
*** Companion;
}
34 changes: 0 additions & 34 deletions emojify/proguard-rules.pro

This file was deleted.

Loading
Loading