mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Tweak emoji suggestions UX.
This commit is contained in:
committed by
Greyson Parrelli
parent
440d041402
commit
d7d923c820
@@ -18,18 +18,20 @@ private const val MINIMUM_QUERY_THRESHOLD = 1
|
||||
private const val MINIMUM_INLINE_QUERY_THRESHOLD = 2
|
||||
private const val EMOJI_SEARCH_LIMIT = 20
|
||||
|
||||
private val NOT_PUNCTUATION = "[A-Za-z0-9 ]".toRegex()
|
||||
|
||||
class EmojiSearchRepository(private val context: Context) {
|
||||
|
||||
private val emojiSearchDatabase: EmojiSearchDatabase = SignalDatabase.emojiSearch
|
||||
|
||||
fun submitQuery(query: String, limit: Int = EMOJI_SEARCH_LIMIT): Single<List<String>> {
|
||||
if (query.length < MINIMUM_INLINE_QUERY_THRESHOLD) {
|
||||
return Single.just(emptyList())
|
||||
val result = if (query.length >= MINIMUM_INLINE_QUERY_THRESHOLD && NOT_PUNCTUATION.matches(query.substring(query.lastIndex))) {
|
||||
Single.fromCallable<List<String>> { emojiSearchDatabase.query(query, limit) }
|
||||
} else {
|
||||
Single.just(emptyList())
|
||||
}
|
||||
|
||||
return Single.fromCallable<List<String>> {
|
||||
emojiSearchDatabase.query(query, limit)
|
||||
}.subscribeOn(Schedulers.io())
|
||||
return result.subscribeOn(Schedulers.io())
|
||||
}
|
||||
|
||||
fun submitQuery(query: String, includeRecents: Boolean, limit: Int = EMOJI_SEARCH_LIMIT, consumer: Consumer<EmojiPageModel>) {
|
||||
|
||||
Reference in New Issue
Block a user