/emoji

Kotlin Multi-platform Emoji Support Library

Primary LanguageKotlinApache License 2.0Apache-2.0

emoji

Kotlin Multi-platform Emoji Support Library.
GitHub tag (latest by date)

Usage

Create an Emoji

Emoji(
    unicodeString = "U+1F600",
    character = "😀",
    name = "grinning face",
    aliases = listOf("grinning_face", "grin_face", "grin face"),
    category = "Smileys & Emotion",
    group = "face-smiling",
    iconUri = null
)

Accessing Emojis

Emojis can be retrieved from a EmojiRepository instance:

val emojiByName = emojiRepository.getByName("grinning face")
val emojiByAlias = emojiRepository.getByAlias(":grinning_face:")
val allEmojis = emojiRepository.getAll()

Retrieving an EmojiRepository

The EmojiRepository interface is in the emoji-core module but there are different implementations in the emoji-repo-map and emoji-repo-sqlite modules. Note that the emoji-repo-sqlite module uses the sqldelight library and requires a SqlDriver to obtain an instance of the SqliteEmojiRepository.

emoji-repo-map:

val repo = KotlinMapEmojiRepository()

emoji-repo-sqlite:

val database = EmojiDatabase(sqldriver)
val repo = SqliteEmojiRepository(database)

Initializing an EmojiRepository

Before the EmojiRepository implementation class is used for the first time, it has to be initialized by calling the init() function. This loads the emoji data set. Note that the init() function is only on the implementation classes and not on the EmojiRepository interface.

repository.init()

Categorizing Emojis

It may be useful to have the Emojis grouped by their category and/or group properties. There are convenience functions to achieve this.

repository.getAll().categorize() // List<EmojiCategory>
repository.getAll().group() // List<EmojiGroup>

Building

The library is provided through Repsy.io. Checkout the releases page to get the latest version.
GitHub tag (latest by date)

Repository

repositories {
    maven { url = uri("https://repo.repsy.io/mvn/chrynan/public") }
}

Core Dependency

implementation("com.chrynan.emoji:emoji-core:$VERSION")

Map Repository Dependency

implementation("com.chrynan.emoji:emoji-repo-map:$VERSION")

SQLite Repository Dependency

implementation("com.chrynan.emoji:emoji-repo-sqlite:$VERSION")

Jetpack Compose Dependency

implementation("com.chrynan.emoji:emoji-ui-compose:$VERSION")

Documentation

More detailed documentation is available in the docs folder. The entry point to the documentation can be found here.

License

Copyright 2020 chRyNaN

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.