Skip to content

Commit

Permalink
Breaking: Rename EmojiDrawableProvider to EmojiAndroidProvider. (#830)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanniktech authored May 26, 2022
1 parent 42f7829 commit 658786a
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion emoji-facebook/api/current.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Signature format: 4.0
package com.vanniktech.emoji.facebook {

public final class FacebookEmojiProvider implements com.vanniktech.emoji.EmojiDrawableProvider com.vanniktech.emoji.EmojiProvider {
public final class FacebookEmojiProvider implements com.vanniktech.emoji.EmojiAndroidProvider com.vanniktech.emoji.EmojiProvider {
ctor public FacebookEmojiProvider();
method public com.vanniktech.emoji.EmojiCategory![] getCategories();
method public android.graphics.drawable.Drawable getDrawable(com.vanniktech.emoji.Emoji emoji, android.content.Context context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.util.LruCache
import com.vanniktech.emoji.Emoji
import com.vanniktech.emoji.EmojiAndroidProvider
import com.vanniktech.emoji.EmojiCategory
import com.vanniktech.emoji.EmojiDrawableProvider
import com.vanniktech.emoji.EmojiProvider
import com.vanniktech.emoji.facebook.category.ActivitiesCategory
import com.vanniktech.emoji.facebook.category.AnimalsAndNatureCategory
Expand All @@ -37,7 +37,7 @@ import com.vanniktech.emoji.facebook.category.SymbolsCategory
import com.vanniktech.emoji.facebook.category.TravelAndPlacesCategory
import java.lang.ref.SoftReference

class FacebookEmojiProvider : EmojiProvider, EmojiDrawableProvider {
class FacebookEmojiProvider : EmojiProvider, EmojiAndroidProvider {
override val categories: Array<EmojiCategory>
get() = arrayOf(
SmileysAndPeopleCategory(),
Expand Down
2 changes: 1 addition & 1 deletion emoji-google-compat/api/current.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Signature format: 4.0
package com.vanniktech.emoji.googlecompat {

public final class GoogleCompatEmojiProvider implements com.vanniktech.emoji.EmojiDrawableProvider com.vanniktech.emoji.EmojiProvider com.vanniktech.emoji.EmojiReplacer {
public final class GoogleCompatEmojiProvider implements com.vanniktech.emoji.EmojiAndroidProvider com.vanniktech.emoji.EmojiProvider com.vanniktech.emoji.EmojiReplacer {
ctor public GoogleCompatEmojiProvider(androidx.emoji.text.EmojiCompat emojiCompat);
method public com.vanniktech.emoji.EmojiCategory![] getCategories();
method public android.graphics.drawable.Drawable getDrawable(com.vanniktech.emoji.Emoji emoji, android.content.Context context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import android.graphics.drawable.Drawable
import android.text.Spannable
import androidx.emoji.text.EmojiCompat
import com.vanniktech.emoji.Emoji
import com.vanniktech.emoji.EmojiAndroidProvider
import com.vanniktech.emoji.EmojiCategory
import com.vanniktech.emoji.EmojiDrawableProvider
import com.vanniktech.emoji.EmojiProvider
import com.vanniktech.emoji.EmojiReplacer
import com.vanniktech.emoji.googlecompat.category.ActivitiesCategory
Expand All @@ -36,7 +36,7 @@ import com.vanniktech.emoji.googlecompat.category.TravelAndPlacesCategory

class GoogleCompatEmojiProvider(
@Suppress("unused") private val emojiCompat: EmojiCompat,
) : EmojiProvider, EmojiDrawableProvider, EmojiReplacer {
) : EmojiProvider, EmojiAndroidProvider, EmojiReplacer {
override val categories: Array<EmojiCategory>
get() = arrayOf(
SmileysAndPeopleCategory(),
Expand Down
2 changes: 1 addition & 1 deletion emoji-google/api/current.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Signature format: 4.0
package com.vanniktech.emoji.google {

public final class GoogleEmojiProvider implements com.vanniktech.emoji.EmojiDrawableProvider com.vanniktech.emoji.EmojiProvider {
public final class GoogleEmojiProvider implements com.vanniktech.emoji.EmojiAndroidProvider com.vanniktech.emoji.EmojiProvider {
ctor public GoogleEmojiProvider();
method public com.vanniktech.emoji.EmojiCategory![] getCategories();
method public android.graphics.drawable.Drawable getDrawable(com.vanniktech.emoji.Emoji emoji, android.content.Context context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.util.LruCache
import com.vanniktech.emoji.Emoji
import com.vanniktech.emoji.EmojiAndroidProvider
import com.vanniktech.emoji.EmojiCategory
import com.vanniktech.emoji.EmojiDrawableProvider
import com.vanniktech.emoji.EmojiProvider
import com.vanniktech.emoji.google.category.ActivitiesCategory
import com.vanniktech.emoji.google.category.AnimalsAndNatureCategory
Expand All @@ -37,7 +37,7 @@ import com.vanniktech.emoji.google.category.SymbolsCategory
import com.vanniktech.emoji.google.category.TravelAndPlacesCategory
import java.lang.ref.SoftReference

class GoogleEmojiProvider : EmojiProvider, EmojiDrawableProvider {
class GoogleEmojiProvider : EmojiProvider, EmojiAndroidProvider {
override val categories: Array<EmojiCategory>
get() = arrayOf(
SmileysAndPeopleCategory(),
Expand Down
2 changes: 1 addition & 1 deletion emoji-ios/api/current.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Signature format: 4.0
package com.vanniktech.emoji.ios {

public final class IosEmojiProvider implements com.vanniktech.emoji.EmojiDrawableProvider com.vanniktech.emoji.EmojiProvider {
public final class IosEmojiProvider implements com.vanniktech.emoji.EmojiAndroidProvider com.vanniktech.emoji.EmojiProvider {
ctor public IosEmojiProvider();
method public com.vanniktech.emoji.EmojiCategory![] getCategories();
method public android.graphics.drawable.Drawable getDrawable(com.vanniktech.emoji.Emoji emoji, android.content.Context context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.util.LruCache
import com.vanniktech.emoji.Emoji
import com.vanniktech.emoji.EmojiAndroidProvider
import com.vanniktech.emoji.EmojiCategory
import com.vanniktech.emoji.EmojiDrawableProvider
import com.vanniktech.emoji.EmojiProvider
import com.vanniktech.emoji.ios.category.ActivitiesCategory
import com.vanniktech.emoji.ios.category.AnimalsAndNatureCategory
Expand All @@ -37,7 +37,7 @@ import com.vanniktech.emoji.ios.category.SymbolsCategory
import com.vanniktech.emoji.ios.category.TravelAndPlacesCategory
import java.lang.ref.SoftReference

class IosEmojiProvider : EmojiProvider, EmojiDrawableProvider {
class IosEmojiProvider : EmojiProvider, EmojiAndroidProvider {
override val categories: Array<EmojiCategory>
get() = arrayOf(
SmileysAndPeopleCategory(),
Expand Down
2 changes: 1 addition & 1 deletion emoji-twitter/api/current.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Signature format: 4.0
package com.vanniktech.emoji.twitter {

public final class TwitterEmojiProvider implements com.vanniktech.emoji.EmojiDrawableProvider com.vanniktech.emoji.EmojiProvider {
public final class TwitterEmojiProvider implements com.vanniktech.emoji.EmojiAndroidProvider com.vanniktech.emoji.EmojiProvider {
ctor public TwitterEmojiProvider();
method public com.vanniktech.emoji.EmojiCategory![] getCategories();
method public android.graphics.drawable.Drawable getDrawable(com.vanniktech.emoji.Emoji emoji, android.content.Context context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.util.LruCache
import com.vanniktech.emoji.Emoji
import com.vanniktech.emoji.EmojiAndroidProvider
import com.vanniktech.emoji.EmojiCategory
import com.vanniktech.emoji.EmojiDrawableProvider
import com.vanniktech.emoji.EmojiProvider
import com.vanniktech.emoji.twitter.category.ActivitiesCategory
import com.vanniktech.emoji.twitter.category.AnimalsAndNatureCategory
Expand All @@ -37,7 +37,7 @@ import com.vanniktech.emoji.twitter.category.SymbolsCategory
import com.vanniktech.emoji.twitter.category.TravelAndPlacesCategory
import java.lang.ref.SoftReference

class TwitterEmojiProvider : EmojiProvider, EmojiDrawableProvider {
class TwitterEmojiProvider : EmojiProvider, EmojiAndroidProvider {
override val categories: Array<EmojiCategory>
get() = arrayOf(
SmileysAndPeopleCategory(),
Expand Down
10 changes: 5 additions & 5 deletions emoji/api/current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ package com.vanniktech.emoji {
property public abstract java.util.List<com.vanniktech.emoji.Emoji> variants;
}

public interface EmojiAndroidProvider extends com.vanniktech.emoji.EmojiProvider {
method public android.graphics.drawable.Drawable getDrawable(com.vanniktech.emoji.Emoji emoji, android.content.Context context);
method @DrawableRes public int getIcon(com.vanniktech.emoji.EmojiCategory emojiCategory);
}

public class EmojiAutoCompleteTextView extends androidx.appcompat.widget.AppCompatAutoCompleteTextView implements com.vanniktech.emoji.EmojiDisplayable {
ctor public EmojiAutoCompleteTextView(android.content.Context context, optional android.util.AttributeSet? attrs);
ctor public EmojiAutoCompleteTextView(android.content.Context context);
Expand Down Expand Up @@ -62,11 +67,6 @@ package com.vanniktech.emoji {
method public void setEmojiSizeRes(@DimenRes int res, boolean shouldInvalidate);
}

public interface EmojiDrawableProvider {
method public android.graphics.drawable.Drawable getDrawable(com.vanniktech.emoji.Emoji emoji, android.content.Context context);
method @DrawableRes public int getIcon(com.vanniktech.emoji.EmojiCategory emojiCategory);
}

public class EmojiEditText extends androidx.appcompat.widget.AppCompatEditText implements com.vanniktech.emoji.EmojiDisplayable {
ctor public EmojiEditText(android.content.Context context, optional android.util.AttributeSet? attrs);
ctor public EmojiEditText(android.content.Context context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import android.content.Context
import android.graphics.drawable.Drawable
import androidx.annotation.DrawableRes

interface EmojiDrawableProvider {
interface EmojiAndroidProvider : EmojiProvider {
@DrawableRes fun getIcon(emojiCategory: EmojiCategory): Int
fun getDrawable(emoji: Emoji, context: Context): Drawable
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import androidx.annotation.AttrRes
import androidx.annotation.ColorInt
import androidx.annotation.ColorRes
import androidx.core.content.ContextCompat
import com.vanniktech.emoji.EmojiDrawableProvider
import com.vanniktech.emoji.EmojiAndroidProvider
import com.vanniktech.emoji.EmojiManager
import kotlin.math.roundToInt

Expand Down Expand Up @@ -147,8 +147,8 @@ internal fun EditText.hideKeyboardAndFocus() {
}
}

internal fun EmojiManager.emojiDrawableProvider(): EmojiDrawableProvider {
internal fun EmojiManager.emojiDrawableProvider(): EmojiAndroidProvider {
val emojiProvider = emojiProvider()
require(emojiProvider is EmojiDrawableProvider) { "Your provider needs to implement EmojiDrawableProvider" }
require(emojiProvider is EmojiAndroidProvider) { "Your provider needs to implement EmojiDrawableProvider" }
return emojiProvider
}
4 changes: 2 additions & 2 deletions generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ async function generateCode(map, targets) {
const emojiCompatTemplate = await fs.readFile("template/EmojiCompat.kt", "utf-8");
const categoryTemplate = await fs.readFile("template/Category.kt", "utf-8");
const categoryChunkTemplate = await fs.readFile("template/CategoryChunk.kt", "utf-8");
const emojiProviderTemplate = await fs.readFile("template/EmojiProvider.kt", "utf-8");
const emojiProviderAndroid = await fs.readFile("template/EmojiProviderAndroid.kt", "utf-8");
const emojiProviderCompatTemplate = await fs.readFile("template/EmojiProviderCompat.kt", "utf-8");
const emojiProviderJvm = await fs.readFile("template/EmojiProviderJvm.kt", "utf-8");

Expand Down Expand Up @@ -456,7 +456,7 @@ async function generateCode(map, targets) {
})

if (target.module !== "google-compat") {
await fs.writeFile(`${srcDir}/${target.name}Provider.kt`, template(emojiProviderTemplate)({
await fs.writeFile(`${srcDir}/${target.name}Provider.kt`, template(emojiProviderAndroid)({
package: target.package,
imports: imports,
name: target.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.util.LruCache
import com.vanniktech.emoji.Emoji
import com.vanniktech.emoji.EmojiAndroidProvider
import com.vanniktech.emoji.EmojiCategory
import com.vanniktech.emoji.EmojiDrawableProvider
import com.vanniktech.emoji.EmojiProvider
<%= imports %>
import java.lang.ref.SoftReference

class <%= name %>Provider : EmojiProvider, EmojiDrawableProvider {
class <%= name %>Provider : EmojiProvider, EmojiAndroidProvider {
override val categories: Array<EmojiCategory>
get() = arrayOf(<% categories.forEach(function(category) { %>
<%= category.name %>(),<% }); %>
Expand Down
4 changes: 2 additions & 2 deletions generator/template/EmojiProviderCompat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ import android.graphics.drawable.Drawable
import android.text.Spannable
import androidx.emoji.text.EmojiCompat
import com.vanniktech.emoji.Emoji
import com.vanniktech.emoji.EmojiAndroidProvider
import com.vanniktech.emoji.EmojiCategory
import com.vanniktech.emoji.EmojiDrawableProvider
import com.vanniktech.emoji.EmojiProvider
import com.vanniktech.emoji.EmojiReplacer
<%= imports %>

class <%= name %>Provider(
@Suppress("unused") private val emojiCompat: EmojiCompat,
) : EmojiProvider, EmojiDrawableProvider, EmojiReplacer {
) : EmojiProvider, EmojiAndroidProvider, EmojiReplacer {
override val categories: Array<EmojiCategory>
get() = arrayOf(<% categories.forEach(function(category) { %>
<%= category.name %>(),<% }); %>
Expand Down

0 comments on commit 658786a

Please sign in to comment.