Hiding the last content item divider
This commit is contained in:
parent
30effb781b
commit
ecb7d77582
@ -18,6 +18,7 @@ package im.vector.app.features.settings.devices.v2.details
|
|||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import com.airbnb.epoxy.EpoxyAttribute
|
import com.airbnb.epoxy.EpoxyAttribute
|
||||||
import com.airbnb.epoxy.EpoxyModelClass
|
import com.airbnb.epoxy.EpoxyModelClass
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
@ -33,6 +34,9 @@ abstract class SessionDetailsContentItem : VectorEpoxyModel<SessionDetailsConten
|
|||||||
@EpoxyAttribute
|
@EpoxyAttribute
|
||||||
var description: String? = null
|
var description: String? = null
|
||||||
|
|
||||||
|
@EpoxyAttribute
|
||||||
|
var hasDivider: Boolean = true
|
||||||
|
|
||||||
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
|
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
|
||||||
var onLongClickListener: View.OnLongClickListener? = null
|
var onLongClickListener: View.OnLongClickListener? = null
|
||||||
|
|
||||||
@ -42,10 +46,12 @@ abstract class SessionDetailsContentItem : VectorEpoxyModel<SessionDetailsConten
|
|||||||
holder.sessionDetailsContentDescription.text = description
|
holder.sessionDetailsContentDescription.text = description
|
||||||
holder.view.isClickable = onLongClickListener != null
|
holder.view.isClickable = onLongClickListener != null
|
||||||
holder.view.setOnLongClickListener(onLongClickListener)
|
holder.view.setOnLongClickListener(onLongClickListener)
|
||||||
|
holder.sessionDetailsContentDivider.isVisible = hasDivider
|
||||||
}
|
}
|
||||||
|
|
||||||
class Holder : VectorEpoxyHolder() {
|
class Holder : VectorEpoxyHolder() {
|
||||||
val sessionDetailsContentTitle by bind<TextView>(R.id.sessionDetailsContentTitle)
|
val sessionDetailsContentTitle by bind<TextView>(R.id.sessionDetailsContentTitle)
|
||||||
val sessionDetailsContentDescription by bind<TextView>(R.id.sessionDetailsContentDescription)
|
val sessionDetailsContentDescription by bind<TextView>(R.id.sessionDetailsContentDescription)
|
||||||
|
val sessionDetailsContentDivider by bind<View>(R.id.sessionDetailsContentDivider)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,13 +63,14 @@ class SessionDetailsController @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildContentItem(@StringRes titleResId: Int, value: String) {
|
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
|
// 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))
|
||||||
description(value)
|
description(value)
|
||||||
|
hasDivider(hasDivider)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,16 +85,18 @@ class SessionDetailsController @Inject constructor(
|
|||||||
|
|
||||||
buildHeaderItem(R.string.device_manager_session_details_section_session_title)
|
buildHeaderItem(R.string.device_manager_session_details_section_session_title)
|
||||||
|
|
||||||
// TODO hide divider on the last visible item
|
|
||||||
sessionName?.let {
|
sessionName?.let {
|
||||||
buildContentItem(R.string.device_manager_session_details_session_name, it)
|
val hasDivider = sessionId != null || sessionLastSeenTs != null
|
||||||
|
buildContentItem(R.string.device_manager_session_details_session_name, it, hasDivider)
|
||||||
}
|
}
|
||||||
sessionId?.let {
|
sessionId?.let {
|
||||||
buildContentItem(R.string.device_manager_session_details_session_id, it)
|
val hasDivider = sessionLastSeenTs != null
|
||||||
|
buildContentItem(R.string.device_manager_session_details_session_id, it, hasDivider)
|
||||||
}
|
}
|
||||||
sessionLastSeenTs?.let {
|
sessionLastSeenTs?.let {
|
||||||
val formattedDate = dateFormatter.format(it, DateFormatKind.MESSAGE_DETAIL)
|
val formattedDate = dateFormatter.format(it, DateFormatKind.MESSAGE_DETAIL)
|
||||||
buildContentItem(R.string.device_manager_session_details_session_last_activity, formattedDate)
|
val hasDivider = false
|
||||||
|
buildContentItem(R.string.device_manager_session_details_session_last_activity, formattedDate, hasDivider)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,9 +109,9 @@ class SessionDetailsController @Inject constructor(
|
|||||||
|
|
||||||
buildHeaderItem(R.string.device_manager_session_details_section_device_title, addExtraTopMargin)
|
buildHeaderItem(R.string.device_manager_session_details_section_device_title, addExtraTopMargin)
|
||||||
|
|
||||||
// TODO hide divider on the last visible item
|
|
||||||
lastSeenIp?.let {
|
lastSeenIp?.let {
|
||||||
buildContentItem(R.string.device_manager_session_details_device_ip_address, it)
|
val hasDivider = false
|
||||||
|
buildContentItem(R.string.device_manager_session_details_device_ip_address, it, hasDivider)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user