mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Filter (most) unsupported emoji from menu for older devices
This commit is contained in:
parent
ed36c99ff9
commit
0302cbffd9
@ -1,6 +1,7 @@
|
|||||||
package org.futo.inputmethod.latin.uix.actions
|
package org.futo.inputmethod.latin.uix.actions
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@ -79,6 +80,7 @@ import org.futo.inputmethod.latin.uix.actions.emoji.EmojiView
|
|||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
import kotlin.streams.toList
|
||||||
|
|
||||||
data class PopupInfo(val emoji: EmojiItem, val x: Int, val y: Int)
|
data class PopupInfo(val emoji: EmojiItem, val x: Int, val y: Int)
|
||||||
|
|
||||||
@ -444,16 +446,28 @@ class PersistentEmojiState : PersistentActionState {
|
|||||||
|
|
||||||
withContext(Dispatchers.Default) {
|
withContext(Dispatchers.Default) {
|
||||||
val emojiData = Json.parseToJsonElement(text)
|
val emojiData = Json.parseToJsonElement(text)
|
||||||
emojis.value = emojiData.jsonArray.map {
|
|
||||||
|
emojis.value = emojiData.jsonArray.mapNotNull {
|
||||||
|
val emoji = it.jsonObject["emoji"]!!.jsonPrimitive.content
|
||||||
|
val supported = emoji.codePoints().toList().all { c -> Character.getName(c) != null }
|
||||||
|
|
||||||
|
if(!supported) {
|
||||||
|
//Log.d("Emoji", "Emoji $emoji is unsupported")
|
||||||
|
null
|
||||||
|
} else {
|
||||||
EmojiItem(
|
EmojiItem(
|
||||||
emoji = it.jsonObject["emoji"]!!.jsonPrimitive.content,
|
emoji = emoji,
|
||||||
description = it.jsonObject["description"]!!.jsonPrimitive.content,
|
description = it.jsonObject["description"]!!.jsonPrimitive.content,
|
||||||
category = it.jsonObject["category"]!!.jsonPrimitive.content,
|
category = it.jsonObject["category"]!!.jsonPrimitive.content,
|
||||||
skinTones = it.jsonObject["skin_tones"]?.jsonPrimitive?.booleanOrNull ?: false,
|
skinTones = it.jsonObject["skin_tones"]?.jsonPrimitive?.booleanOrNull
|
||||||
tags = it.jsonObject["tags"]?.jsonArray?.map { it.jsonPrimitive.content }?.toList() ?: listOf(),
|
?: false,
|
||||||
aliases = it.jsonObject["aliases"]?.jsonArray?.map { it.jsonPrimitive.content }?.toList() ?: listOf(),
|
tags = it.jsonObject["tags"]?.jsonArray?.map { it.jsonPrimitive.content }
|
||||||
|
?.toList() ?: listOf(),
|
||||||
|
aliases = it.jsonObject["aliases"]?.jsonArray?.map { it.jsonPrimitive.content }
|
||||||
|
?.toList() ?: listOf(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
emojiMap = HashMap<String, EmojiItem>().apply {
|
emojiMap = HashMap<String, EmojiItem>().apply {
|
||||||
emojis.value!!.forEach {
|
emojis.value!!.forEach {
|
||||||
|
Loading…
Reference in New Issue
Block a user