hiding the notification url/format UI fields when they're null (which is the case for email pushers)

This commit is contained in:
Adam Brown 2021-09-23 12:54:52 +01:00
parent d31ad7e187
commit 1865e3c450
2 changed files with 17 additions and 2 deletions

View File

@ -22,6 +22,7 @@ import android.view.View
import android.view.ViewGroup
import android.widget.EditText
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.widget.SearchView
import androidx.core.view.isVisible
import im.vector.app.R
@ -58,3 +59,14 @@ fun ImageView.setDrawableOrHide(drawableRes: Drawable?) {
setImageDrawable(drawableRes)
isVisible = drawableRes != null
}
fun TextView.setText(text: String?, nullVisibility: Int, vararg relatedViews: View) {
if (text == null) {
visibility = nullVisibility
relatedViews.forEach { it.visibility = nullVisibility }
} else {
visibility = View.VISIBLE
relatedViews.forEach { it.visibility = View.VISIBLE }
this.text = text
}
}

View File

@ -23,6 +23,7 @@ import com.airbnb.epoxy.EpoxyModelClass
import com.airbnb.epoxy.EpoxyModelWithHolder
import im.vector.app.R
import im.vector.app.core.epoxy.VectorEpoxyHolder
import im.vector.app.core.extensions.setText
import org.matrix.android.sdk.api.session.pushers.Pusher
@EpoxyModelClass(layout = R.layout.item_pushgateway)
@ -45,8 +46,8 @@ abstract class PushGatewayItem : EpoxyModelWithHolder<PushGatewayItem.Holder>()
holder.appId.text = pusher.appId
holder.pushKey.text = pusher.pushKey
holder.appName.text = pusher.appDisplayName
holder.url.text = pusher.data.url
holder.format.text = pusher.data.format
holder.url.setText(pusher.data.url, nullVisibility = View.GONE, holder.urlTitle)
holder.format.setText(pusher.data.format, nullVisibility = View.GONE, holder.formatTitle)
holder.deviceName.text = pusher.deviceDisplayName
holder.removeButton.setOnClickListener {
interactions.onRemovePushTapped(pusher)
@ -57,7 +58,9 @@ abstract class PushGatewayItem : EpoxyModelWithHolder<PushGatewayItem.Holder>()
val kind by bind<TextView>(R.id.pushGatewayKind)
val pushKey by bind<TextView>(R.id.pushGatewayKeyValue)
val deviceName by bind<TextView>(R.id.pushGatewayDeviceNameValue)
val formatTitle by bind<View>(R.id.pushGatewayFormat)
val format by bind<TextView>(R.id.pushGatewayFormatValue)
val urlTitle by bind<View>(R.id.pushGatewayURL)
val url by bind<TextView>(R.id.pushGatewayURLValue)
val appName by bind<TextView>(R.id.pushGatewayAppNameValue)
val appId by bind<TextView>(R.id.pushGatewayAppIdValue)