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