diff --git a/vector/src/main/java/im/vector/app/core/extensions/ViewExtensions.kt b/vector/src/main/java/im/vector/app/core/extensions/ViewExtensions.kt index b28f33816b..06aa1225c9 100644 --- a/vector/src/main/java/im/vector/app/core/extensions/ViewExtensions.kt +++ b/vector/src/main/java/im/vector/app/core/extensions/ViewExtensions.kt @@ -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 + } +} diff --git a/vector/src/main/java/im/vector/app/features/settings/push/PushGatewayItem.kt b/vector/src/main/java/im/vector/app/features/settings/push/PushGatewayItem.kt index ee0ef87cc7..2ac156d9fd 100644 --- a/vector/src/main/java/im/vector/app/features/settings/push/PushGatewayItem.kt +++ b/vector/src/main/java/im/vector/app/features/settings/push/PushGatewayItem.kt @@ -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() 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() val kind by bind(R.id.pushGatewayKind) val pushKey by bind(R.id.pushGatewayKeyValue) val deviceName by bind(R.id.pushGatewayDeviceNameValue) + val formatTitle by bind(R.id.pushGatewayFormat) val format by bind(R.id.pushGatewayFormatValue) + val urlTitle by bind(R.id.pushGatewayURL) val url by bind(R.id.pushGatewayURLValue) val appName by bind(R.id.pushGatewayAppNameValue) val appId by bind(R.id.pushGatewayAppIdValue)