Copy content to clipboard on long click on an item
This commit is contained in:
parent
ecb7d77582
commit
4cd81f194c
|
@ -24,6 +24,7 @@ import com.airbnb.epoxy.EpoxyModelClass
|
|||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
import im.vector.app.core.extensions.copyOnLongClick
|
||||
|
||||
@EpoxyModelClass
|
||||
abstract class SessionDetailsContentItem : VectorEpoxyModel<SessionDetailsContentItem.Holder>(R.layout.item_session_details_content) {
|
||||
|
@ -37,15 +38,11 @@ abstract class SessionDetailsContentItem : VectorEpoxyModel<SessionDetailsConten
|
|||
@EpoxyAttribute
|
||||
var hasDivider: Boolean = true
|
||||
|
||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
|
||||
var onLongClickListener: View.OnLongClickListener? = null
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.sessionDetailsContentTitle.text = title
|
||||
holder.sessionDetailsContentDescription.text = description
|
||||
holder.view.isClickable = onLongClickListener != null
|
||||
holder.view.setOnLongClickListener(onLongClickListener)
|
||||
holder.sessionDetailsContentDescription.copyOnLongClick()
|
||||
holder.sessionDetailsContentDivider.isVisible = hasDivider
|
||||
}
|
||||
|
||||
|
|
|
@ -34,12 +34,6 @@ class SessionDetailsController @Inject constructor(
|
|||
private val dimensionConverter: DimensionConverter,
|
||||
) : TypedEpoxyController<DeviceInfo>() {
|
||||
|
||||
var callback: Callback? = null
|
||||
|
||||
interface Callback {
|
||||
fun onItemLongClicked(content: String)
|
||||
}
|
||||
|
||||
override fun buildModels(data: DeviceInfo?) {
|
||||
data?.let { info ->
|
||||
val hasSectionSession = hasSectionSession(data)
|
||||
|
@ -65,7 +59,6 @@ class SessionDetailsController @Inject constructor(
|
|||
|
||||
private fun buildContentItem(@StringRes titleResId: Int, value: String, hasDivider: Boolean) {
|
||||
val host = this
|
||||
// TODO bind the longClickListener to copy the description to the clipboard
|
||||
sessionDetailsContentItem {
|
||||
id(titleResId)
|
||||
title(host.stringProvider.getString(titleResId))
|
||||
|
|
Loading…
Reference in New Issue