mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-24 18:36:21 +03:00
Move standard emojis to top of autocompletion
Now that we can limit emojis per category while allowing to expand them, makes sense to show standard emojis on top, above custom emotes, especially when users have lots of emotes. Change-Id: I822cc091bf595795fa08fef32f0737073a43163a
This commit is contained in:
parent
07a0d315f5
commit
cb593ebb14
2 changed files with 18 additions and 11 deletions
|
@ -110,8 +110,12 @@ class AutocompleteEmojiController @Inject constructor(
|
|||
}
|
||||
|
||||
companion object {
|
||||
// Count of standard emoji matches - WARN: do not set to 8 or less, or epoxy/recycler will sometimes crash with some class casts,
|
||||
// e.g. when repeatedly typing `:turt`, then deleting back to `:`?!?
|
||||
// What makes 8 magic? Probably that no-search proposals also returns 8 results? But wtf?
|
||||
const val STANDARD_EMOJI_MAX = 9
|
||||
// Count of emojis for the current room's image pack
|
||||
const val CUSTOM_THIS_ROOM_MAX = 10
|
||||
const val CUSTOM_THIS_ROOM_MAX = 8
|
||||
// Count of emojis per other image pack
|
||||
const val CUSTOM_OTHER_ROOM_MAX = 5
|
||||
// Count of emojis for global account data
|
||||
|
@ -122,7 +126,8 @@ class AutocompleteEmojiController @Inject constructor(
|
|||
const val MAX = 50
|
||||
// Total max after expanding a section
|
||||
const val MAX_EXPAND = 10000
|
||||
// Internal ID
|
||||
// Internal IDs
|
||||
const val ACCOUNT_DATA_EMOTE_ID = "de.spiritcroc.riotx.ACCOUNT_DATA_EMOTES"
|
||||
const val STANDARD_EMOJI_ID = "de.spiritcroc.riotx.STANDARD_EMOJI"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,12 +105,19 @@ class AutocompleteEmojiPresenter @AssistedInject constructor(
|
|||
lastQuery = query
|
||||
coroutineScope.launch {
|
||||
// Plain emojis
|
||||
val fullStandardEmojis: List<EmojiItem>
|
||||
val data = if (query.isNullOrBlank()) {
|
||||
// Return common emojis
|
||||
emojiDataSource.getQuickReactions()
|
||||
fullStandardEmojis = emojiDataSource.getQuickReactions()
|
||||
fullStandardEmojis
|
||||
} else {
|
||||
emojiDataSource.filterWith(query.toString())
|
||||
}.toAutocompleteItems()
|
||||
fullStandardEmojis = emojiDataSource.filterWith(query.toString())
|
||||
fullStandardEmojis.maybeLimit(AutocompleteEmojiController.STANDARD_EMOJI_MAX, AutocompleteEmojiController.STANDARD_EMOJI_ID, null)
|
||||
}.toAutocompleteItems().toMutableList()
|
||||
|
||||
if (fullStandardEmojis.size > data.size) {
|
||||
data += listOf(AutocompleteEmojiDataItem.Expand(AutocompleteEmojiController.STANDARD_EMOJI_ID, null, fullStandardEmojis.size - data.size))
|
||||
}
|
||||
|
||||
// Custom emotes: This room's emotes
|
||||
val currentRoomEmotes = room.getAllEmojiItems(query)
|
||||
|
@ -203,12 +210,7 @@ class AutocompleteEmojiPresenter @AssistedInject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
val dataHeader = if (data.isNotEmpty() && emoteData.isNotEmpty()) {
|
||||
listOf(AutocompleteEmojiDataItem.Header("de.spiritcroc.riotx.STANDARD_EMOJI_HEADER", context.getString(R.string.standard_emojis)))
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
controller.setData(emoteData + dataHeader + data)
|
||||
controller.setData(data + emoteData)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue