mirror of
https://github.com/element-hq/element-android
synced 2024-10-26 20:57:20 +03:00
Completion on emoji: display the first 50 results
This commit is contained in:
parent
c8e67f8ab4
commit
0e5fcd071c
5 changed files with 64 additions and 13 deletions
|
@ -47,18 +47,26 @@ class AutocompleteEmojiController @Inject constructor(
|
||||||
if (data.isNullOrEmpty()) {
|
if (data.isNullOrEmpty()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data.forEach { emojiItem ->
|
data
|
||||||
autocompleteEmojiItem {
|
.take(MAX)
|
||||||
id(emojiItem.name)
|
.forEach { emojiItem ->
|
||||||
emojiItem(emojiItem)
|
autocompleteEmojiItem {
|
||||||
emojiTypeFace(emojiTypeface)
|
id(emojiItem.name)
|
||||||
onClickListener(
|
emojiItem(emojiItem)
|
||||||
object : ReactionClickListener {
|
emojiTypeFace(emojiTypeface)
|
||||||
override fun onReactionSelected(reaction: String) {
|
onClickListener(
|
||||||
listener?.onItemClick(reaction)
|
object : ReactionClickListener {
|
||||||
}
|
override fun onReactionSelected(reaction: String) {
|
||||||
}
|
listener?.onItemClick(reaction)
|
||||||
)
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.size > MAX) {
|
||||||
|
autocompleteMoreResultItem {
|
||||||
|
id("more_result")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,4 +75,8 @@ class AutocompleteEmojiController @Inject constructor(
|
||||||
super.onDetachedFromRecyclerView(recyclerView)
|
super.onDetachedFromRecyclerView(recyclerView)
|
||||||
fontProvider.removeListener(fontProviderListener)
|
fontProvider.removeListener(fontProviderListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val MAX = 50
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2019 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package im.vector.riotx.features.autocomplete.emoji
|
||||||
|
|
||||||
|
import com.airbnb.epoxy.EpoxyModelClass
|
||||||
|
import im.vector.riotx.R
|
||||||
|
import im.vector.riotx.core.epoxy.VectorEpoxyHolder
|
||||||
|
import im.vector.riotx.core.epoxy.VectorEpoxyModel
|
||||||
|
|
||||||
|
@EpoxyModelClass(layout = R.layout.item_autocomplete_more_result)
|
||||||
|
abstract class AutocompleteMoreResultItem : VectorEpoxyModel<AutocompleteMoreResultItem.Holder>() {
|
||||||
|
|
||||||
|
class Holder : VectorEpoxyHolder()
|
||||||
|
}
|
|
@ -166,7 +166,7 @@ class AutoCompleter @Inject constructor(
|
||||||
|
|
||||||
private fun setupEmojis(backgroundDrawable: Drawable, editText: EditText) {
|
private fun setupEmojis(backgroundDrawable: Drawable, editText: EditText) {
|
||||||
Autocomplete.on<String>(editText)
|
Autocomplete.on<String>(editText)
|
||||||
.with(CharPolicy(':', true))
|
.with(CharPolicy(':', false))
|
||||||
.with(autocompleteEmojiPresenter)
|
.with(autocompleteEmojiPresenter)
|
||||||
.with(ELEVATION)
|
.with(ELEVATION)
|
||||||
.with(backgroundDrawable)
|
.with(backgroundDrawable)
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?riotx_background"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:text="@string/autocomplete_limited_results"
|
||||||
|
android:textColor="?riotx_text_secondary"
|
||||||
|
android:textSize="12sp" />
|
|
@ -18,4 +18,6 @@
|
||||||
<string name="devices_current_device">Current device</string>
|
<string name="devices_current_device">Current device</string>
|
||||||
<string name="devices_other_devices">Other devices</string>
|
<string name="devices_other_devices">Other devices</string>
|
||||||
|
|
||||||
|
<string name="autocomplete_limited_results">Limited results, please type more letters…</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue