Skip to content

Commit

Permalink
Improve compatibility with Java Code. (#786)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanniktech authored May 16, 2022
1 parent 34bc52a commit 91bd342
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 61 deletions.
72 changes: 41 additions & 31 deletions emoji/api/current.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
package com.vanniktech.emoji

data class EmojiInformation internal constructor(
val isOnlyEmojis: Boolean,
val emojis: List<EmojiRange>,
@JvmField val isOnlyEmojis: Boolean,
@JvmField val emojis: List<EmojiRange>,
)
8 changes: 4 additions & 4 deletions emoji/src/main/kotlin/com/vanniktech/emoji/EmojiManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ object EmojiManager {
internal var emojiRepetitivePattern: Regex? = null
private var emojiReplacer: EmojiReplacer? = null

fun replaceWithImages(context: Context?, text: Spannable?, emojiSize: Float) {
@JvmStatic fun replaceWithImages(context: Context?, text: Spannable?, emojiSize: Float) {
verifyInstalled()
emojiReplacer!!.replaceWithImages(context!!, text!!, emojiSize, DEFAULT_EMOJI_REPLACER)
}
Expand Down Expand Up @@ -103,7 +103,7 @@ object EmojiManager {
*
* [provider] the provider that should be installed.
*/
fun install(provider: EmojiProvider) {
@JvmStatic fun install(provider: EmojiProvider) {
synchronized(EmojiManager::class.java) {
categories = provider.categories
emojiMap.clear()
Expand Down Expand Up @@ -150,7 +150,7 @@ object EmojiManager {
*
* @see .destroy
*/
fun destroy() {
@JvmStatic fun destroy() {
synchronized(EmojiManager::class.java) {
release()
emojiMap.clear()
Expand All @@ -170,7 +170,7 @@ object EmojiManager {
*
* @see .destroy
*/
fun release() {
@JvmStatic fun release() {
synchronized(EmojiManager::class.java) {
for (emoji in emojiMap.values) {
emoji.destroy()
Expand Down
2 changes: 1 addition & 1 deletion emoji/src/main/kotlin/com/vanniktech/emoji/EmojiPopup.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import com.vanniktech.emoji.variant.VariantEmoji
import com.vanniktech.emoji.variant.VariantEmojiManager
import java.lang.ref.WeakReference

class EmojiPopup(
class EmojiPopup @JvmOverloads constructor(
/** The root View of your layout.xml which will be used for calculating the height of the keyboard. */
rootView: View,
private val editText: EditText,
Expand Down
4 changes: 2 additions & 2 deletions emoji/src/main/kotlin/com/vanniktech/emoji/EmojiRange.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
package com.vanniktech.emoji

data class EmojiRange(
val emoji: Emoji,
val range: IntRange,
@JvmField val emoji: Emoji,
@JvmField val range: IntRange,
)
25 changes: 8 additions & 17 deletions emoji/src/main/kotlin/com/vanniktech/emoji/EmojiTheming.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,48 +23,39 @@ import androidx.annotation.ColorInt
import kotlinx.parcelize.Parcelize

/** Control the colors of all Emoji UI components. */
@Parcelize data class EmojiTheming(
@Parcelize data class EmojiTheming @JvmOverloads constructor(
/**
* If set, it will be taken.
* Otherwise it'll look for a theme attribute called emojiBackgroundColor.
* If that isn't found, the library has a default.
*/
@ColorInt val backgroundColor: Int?,
@ColorInt @JvmField val backgroundColor: Int? = null,
/**
* If set, it will be taken.
* Otherwise it'll take the color from your theme.
*/
@ColorInt val primaryColor: Int?,
@ColorInt @JvmField val primaryColor: Int? = null,
/**
* If set, it will be taken.
* Otherwise it'll take the color from your theme.
*/
@ColorInt val secondaryColor: Int?,
@ColorInt @JvmField val secondaryColor: Int? = null,
/**
* If set, it will be taken.
* Otherwise it'll look for a theme attribute called emojiDividerColor.
* If that isn't found, the library has a default.
*/
@ColorInt val dividerColor: Int?,
@ColorInt @JvmField val dividerColor: Int? = null,
/**
* If set, it will be taken.
* Otherwise it'll look for a theme attribute called emojiTextColor.
* If that isn't found, the library has a default.
*/
@ColorInt val textColor: Int?,
@ColorInt @JvmField val textColor: Int? = null,
/**
* If set, it will be taken.
* Otherwise it'll look for a theme attribute called emojiTextSecondaryColor.
* If that isn't found, the library has a default.
*/
@ColorInt val textSecondaryColor: Int?,
) : Parcelable {
constructor() : this(
backgroundColor = null,
primaryColor = null,
secondaryColor = null,
dividerColor = null,
textColor = null,
textSecondaryColor = null,
)
}
@ColorInt @JvmField val textSecondaryColor: Int? = null,
) : Parcelable
2 changes: 1 addition & 1 deletion emoji/src/main/kotlin/com/vanniktech/emoji/EmojiView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class EmojiView @JvmOverloads constructor(
* Call this method to set up the EmojiView.
* Once you're done with it, please call [.tearDown].
*/
fun setUp(
@JvmOverloads fun setUp(
rootView: View,
onEmojiClickListener: OnEmojiClickListener?,
onEmojiBackspaceClickListener: OnEmojiBackspaceClickListener?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ package com.vanniktech.emoji.search
import com.vanniktech.emoji.Emoji

data class SearchEmojiResult(
val emoji: Emoji,
val shortcode: String,
@JvmField val emoji: Emoji,
@JvmField val shortcode: String,
/** The range in [shortcode], which matches the query. This is used for highlighting. */
val range: IntRange,
@JvmField val range: IntRange,
) {
init {
require(range.first in shortcode.indices) { "Index ${range.first} is out of bounds in $shortcode" }
Expand Down

0 comments on commit 91bd342

Please sign in to comment.