mirror of
https://github.com/SimpleMobileTools/Simple-Keyboard.git
synced 2025-04-13 01:42:34 +02:00
Remove unnecessary emoji class
This commit is contained in:
parent
276270fa63
commit
c3bd3f787e
@ -6,11 +6,10 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.simplemobiletools.keyboard.R
|
import com.simplemobiletools.keyboard.R
|
||||||
import com.simplemobiletools.keyboard.media.emoji.Emoji
|
|
||||||
import kotlinx.android.synthetic.main.item_emoji.view.*
|
import kotlinx.android.synthetic.main.item_emoji.view.*
|
||||||
|
|
||||||
class EmojisAdapter(
|
class EmojisAdapter(
|
||||||
val context: Context, var items: List<Emoji>, val itemClick: (emoji: Emoji) -> Unit
|
val context: Context, var items: List<String>, val itemClick: (emoji: String) -> Unit
|
||||||
) : RecyclerView.Adapter<EmojisAdapter.ViewHolder>() {
|
) : RecyclerView.Adapter<EmojisAdapter.ViewHolder>() {
|
||||||
|
|
||||||
private val layoutInflater = LayoutInflater.from(context)
|
private val layoutInflater = LayoutInflater.from(context)
|
||||||
@ -32,17 +31,17 @@ class EmojisAdapter(
|
|||||||
return items.size
|
return items.size
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupEmoji(view: View, emoji: Emoji) {
|
private fun setupEmoji(view: View, emoji: String) {
|
||||||
view.emoji_value.text = emoji.value
|
view.emoji_value.text = emoji
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||||
fun bindView(any: Emoji, callback: (itemView: View) -> Unit): View {
|
fun bindView(emoji: String, callback: (itemView: View) -> Unit): View {
|
||||||
return itemView.apply {
|
return itemView.apply {
|
||||||
callback(this)
|
callback(this)
|
||||||
|
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
itemClick.invoke(any)
|
itemClick.invoke(emoji)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.simplemobiletools.keyboard.media.emoji
|
package com.simplemobiletools.keyboard.helpers
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
|
||||||
private var cachedEmojiData: MutableList<Emoji>? = null
|
private var cachedEmojiData: MutableList<String>? = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the emoji list at the given [path] and returns an parsed [MutableList]. If the
|
* Reads the emoji list at the given [path] and returns an parsed [MutableList]. If the
|
||||||
@ -13,10 +13,10 @@ private var cachedEmojiData: MutableList<Emoji>? = null
|
|||||||
*/
|
*/
|
||||||
fun parseRawEmojiSpecsFile(
|
fun parseRawEmojiSpecsFile(
|
||||||
context: Context, path: String
|
context: Context, path: String
|
||||||
): MutableList<Emoji> {
|
): MutableList<String> {
|
||||||
cachedEmojiData?.let { return it }
|
cachedEmojiData?.let { return it }
|
||||||
val emojis = mutableListOf<Emoji>()
|
val emojis = mutableListOf<String>()
|
||||||
var emojiEditorList: MutableList<Emoji>? = null
|
var emojiEditorList: MutableList<String>? = null
|
||||||
|
|
||||||
fun commitEmojiEditorList() {
|
fun commitEmojiEditorList() {
|
||||||
emojiEditorList?.let {
|
emojiEditorList?.let {
|
||||||
@ -42,11 +42,7 @@ fun parseRawEmojiSpecsFile(
|
|||||||
// Assume it is a data line
|
// Assume it is a data line
|
||||||
val data = line.split(";")
|
val data = line.split(";")
|
||||||
if (data.size == 3) {
|
if (data.size == 3) {
|
||||||
val emoji = Emoji(
|
val emoji = data[0].trim()
|
||||||
value = data[0].trim(),
|
|
||||||
name = data[1].trim(),
|
|
||||||
keywords = data[2].split("|").map { it.trim() }
|
|
||||||
)
|
|
||||||
if (emojiEditorList != null) {
|
if (emojiEditorList != null) {
|
||||||
emojiEditorList!!.add(emoji)
|
emojiEditorList!!.add(emoji)
|
||||||
} else {
|
} else {
|
@ -1,8 +0,0 @@
|
|||||||
package com.simplemobiletools.keyboard.media.emoji
|
|
||||||
|
|
||||||
|
|
||||||
data class Emoji(val value: String, val name: String, val keywords: List<String>) {
|
|
||||||
override fun toString(): String {
|
|
||||||
return "Emoji { value=$value, name=$name, keywords=$keywords }"
|
|
||||||
}
|
|
||||||
}
|
|
@ -43,8 +43,6 @@ import com.simplemobiletools.keyboard.helpers.MyKeyboard.Companion.KEYCODE_MODE_
|
|||||||
import com.simplemobiletools.keyboard.helpers.MyKeyboard.Companion.KEYCODE_SHIFT
|
import com.simplemobiletools.keyboard.helpers.MyKeyboard.Companion.KEYCODE_SHIFT
|
||||||
import com.simplemobiletools.keyboard.helpers.MyKeyboard.Companion.KEYCODE_SPACE
|
import com.simplemobiletools.keyboard.helpers.MyKeyboard.Companion.KEYCODE_SPACE
|
||||||
import com.simplemobiletools.keyboard.interfaces.RefreshClipsListener
|
import com.simplemobiletools.keyboard.interfaces.RefreshClipsListener
|
||||||
import com.simplemobiletools.keyboard.media.emoji.Emoji
|
|
||||||
import com.simplemobiletools.keyboard.media.emoji.parseRawEmojiSpecsFile
|
|
||||||
import com.simplemobiletools.keyboard.models.Clip
|
import com.simplemobiletools.keyboard.models.Clip
|
||||||
import com.simplemobiletools.keyboard.models.ClipsSectionLabel
|
import com.simplemobiletools.keyboard.models.ClipsSectionLabel
|
||||||
import com.simplemobiletools.keyboard.models.ListItem
|
import com.simplemobiletools.keyboard.models.ListItem
|
||||||
@ -1444,7 +1442,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
typeface = Typeface.DEFAULT
|
typeface = Typeface.DEFAULT
|
||||||
}
|
}
|
||||||
val emojis = fullEmojiList.filter { emoji ->
|
val emojis = fullEmojiList.filter { emoji ->
|
||||||
systemFontPaint.hasGlyph(emoji.value)
|
systemFontPaint.hasGlyph(emoji)
|
||||||
}
|
}
|
||||||
Handler(Looper.getMainLooper()).post {
|
Handler(Looper.getMainLooper()).post {
|
||||||
setupEmojiAdapter(emojis)
|
setupEmojiAdapter(emojis)
|
||||||
@ -1452,14 +1450,14 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupEmojiAdapter(emojis: List<Emoji>) {
|
private fun setupEmojiAdapter(emojis: List<String>) {
|
||||||
val emojiItemWidth = context.resources.getDimensionPixelSize(R.dimen.emoji_item_size)
|
val emojiItemWidth = context.resources.getDimensionPixelSize(R.dimen.emoji_item_size)
|
||||||
val emojiTopBarElevation = context.resources.getDimensionPixelSize(R.dimen.emoji_top_bar_elevation).toFloat()
|
val emojiTopBarElevation = context.resources.getDimensionPixelSize(R.dimen.emoji_top_bar_elevation).toFloat()
|
||||||
|
|
||||||
mEmojiPaletteHolder!!.emojis_list.apply {
|
mEmojiPaletteHolder!!.emojis_list.apply {
|
||||||
layoutManager = AutoGridLayoutManager(context, emojiItemWidth)
|
layoutManager = AutoGridLayoutManager(context, emojiItemWidth)
|
||||||
adapter = EmojisAdapter(context = context, items = emojis) { emoji ->
|
adapter = EmojisAdapter(context = context, items = emojis) { emoji ->
|
||||||
mOnKeyboardActionListener!!.onText(emoji.value)
|
mOnKeyboardActionListener!!.onText(emoji)
|
||||||
vibrateIfNeeded()
|
vibrateIfNeeded()
|
||||||
}
|
}
|
||||||
onScroll {
|
onScroll {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user