mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
hiding the notification url/format UI fields when they're null (which is the case for email pushers)
This commit is contained in:
parent
d31ad7e187
commit
1865e3c450
2 changed files with 17 additions and 2 deletions
|
@ -22,6 +22,7 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
|
import android.widget.TextView
|
||||||
import androidx.appcompat.widget.SearchView
|
import androidx.appcompat.widget.SearchView
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
|
@ -58,3 +59,14 @@ fun ImageView.setDrawableOrHide(drawableRes: Drawable?) {
|
||||||
setImageDrawable(drawableRes)
|
setImageDrawable(drawableRes)
|
||||||
isVisible = drawableRes != null
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import com.airbnb.epoxy.EpoxyModelClass
|
||||||
import com.airbnb.epoxy.EpoxyModelWithHolder
|
import com.airbnb.epoxy.EpoxyModelWithHolder
|
||||||
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.extensions.setText
|
||||||
import org.matrix.android.sdk.api.session.pushers.Pusher
|
import org.matrix.android.sdk.api.session.pushers.Pusher
|
||||||
|
|
||||||
@EpoxyModelClass(layout = R.layout.item_pushgateway)
|
@EpoxyModelClass(layout = R.layout.item_pushgateway)
|
||||||
|
@ -45,8 +46,8 @@ abstract class PushGatewayItem : EpoxyModelWithHolder<PushGatewayItem.Holder>()
|
||||||
holder.appId.text = pusher.appId
|
holder.appId.text = pusher.appId
|
||||||
holder.pushKey.text = pusher.pushKey
|
holder.pushKey.text = pusher.pushKey
|
||||||
holder.appName.text = pusher.appDisplayName
|
holder.appName.text = pusher.appDisplayName
|
||||||
holder.url.text = pusher.data.url
|
holder.url.setText(pusher.data.url, nullVisibility = View.GONE, holder.urlTitle)
|
||||||
holder.format.text = pusher.data.format
|
holder.format.setText(pusher.data.format, nullVisibility = View.GONE, holder.formatTitle)
|
||||||
holder.deviceName.text = pusher.deviceDisplayName
|
holder.deviceName.text = pusher.deviceDisplayName
|
||||||
holder.removeButton.setOnClickListener {
|
holder.removeButton.setOnClickListener {
|
||||||
interactions.onRemovePushTapped(pusher)
|
interactions.onRemovePushTapped(pusher)
|
||||||
|
@ -57,7 +58,9 @@ abstract class PushGatewayItem : EpoxyModelWithHolder<PushGatewayItem.Holder>()
|
||||||
val kind by bind<TextView>(R.id.pushGatewayKind)
|
val kind by bind<TextView>(R.id.pushGatewayKind)
|
||||||
val pushKey by bind<TextView>(R.id.pushGatewayKeyValue)
|
val pushKey by bind<TextView>(R.id.pushGatewayKeyValue)
|
||||||
val deviceName by bind<TextView>(R.id.pushGatewayDeviceNameValue)
|
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 format by bind<TextView>(R.id.pushGatewayFormatValue)
|
||||||
|
val urlTitle by bind<View>(R.id.pushGatewayURL)
|
||||||
val url by bind<TextView>(R.id.pushGatewayURLValue)
|
val url by bind<TextView>(R.id.pushGatewayURLValue)
|
||||||
val appName by bind<TextView>(R.id.pushGatewayAppNameValue)
|
val appName by bind<TextView>(R.id.pushGatewayAppNameValue)
|
||||||
val appId by bind<TextView>(R.id.pushGatewayAppIdValue)
|
val appId by bind<TextView>(R.id.pushGatewayAppIdValue)
|
||||||
|
|
Loading…
Reference in a new issue