diff --git a/vector/src/main/java/im/vector/app/features/crypto/verification/epoxy/BottomSheetVerificationEmojisItem.kt b/vector/src/main/java/im/vector/app/features/crypto/verification/epoxy/BottomSheetVerificationEmojisItem.kt index decb9eaad5..e1b703e0fc 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/verification/epoxy/BottomSheetVerificationEmojisItem.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/verification/epoxy/BottomSheetVerificationEmojisItem.kt @@ -18,8 +18,6 @@ package im.vector.app.features.crypto.verification.epoxy import android.content.Context import android.view.ViewGroup -import android.widget.ImageView -import android.widget.TextView import androidx.core.content.ContextCompat import androidx.core.view.isVisible import com.airbnb.epoxy.EpoxyAttribute @@ -27,6 +25,7 @@ import com.airbnb.epoxy.EpoxyModelClass import im.vector.app.R import im.vector.app.core.epoxy.VectorEpoxyHolder import im.vector.app.core.epoxy.VectorEpoxyModel +import im.vector.app.databinding.ItemEmojiVerifBinding import me.gujun.android.span.Span import me.gujun.android.span.image import me.gujun.android.span.span @@ -68,16 +67,18 @@ abstract class BottomSheetVerificationEmojisItem : VectorEpoxyModel(R.id.item_emoji_tv).isVisible = false - view.findViewById(R.id.item_emoji_image).isVisible = true - view.findViewById(R.id.item_emoji_image).setImageDrawable(ContextCompat.getDrawable(view.context, it)) - } ?: run { - view.findViewById(R.id.item_emoji_tv).isVisible = true - view.findViewById(R.id.item_emoji_image).isVisible = false - view.findViewById(R.id.item_emoji_tv).text = rep.emoji + val views = ItemEmojiVerifBinding.bind(view) + val drawableRes = rep.drawableRes + if (drawableRes != null) { + views.itemEmojiTv.isVisible = false + views.itemEmojiImage.isVisible = true + views.itemEmojiImage.setImageDrawable(ContextCompat.getDrawable(view.context, drawableRes)) + } else { + views.itemEmojiTv.isVisible = true + views.itemEmojiImage.isVisible = false + views.itemEmojiTv.text = rep.emoji } - view.findViewById(R.id.item_emoji_name_tv).setText(rep.nameResId) + views.itemEmojiNameTv.setText(rep.nameResId) } class Holder : VectorEpoxyHolder() { diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/CallTileTimelineItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/CallTileTimelineItem.kt index a9b6bbf0aa..1f12bdbd2c 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/CallTileTimelineItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/CallTileTimelineItem.kt @@ -69,7 +69,7 @@ abstract class CallTileTimelineItem : AbsBaseMessageItem { holder.rejectView.setText(R.string.ignore) holder.acceptView.setText(R.string.join) - holder.acceptView.setLeftDrawable(R.drawable.ic_call_audio_small, R.attr.colorPrimary) + holder.acceptView.setLeftDrawable(R.drawable.ic_call_audio_small, R.attr.colorOnPrimary) } CallKind.AUDIO -> { holder.rejectView.setText(R.string.call_notification_reject) holder.acceptView.setText(R.string.call_notification_answer) - holder.acceptView.setLeftDrawable(R.drawable.ic_call_audio_small, R.attr.colorPrimary) + holder.acceptView.setLeftDrawable(R.drawable.ic_call_audio_small, R.attr.colorOnPrimary) } CallKind.VIDEO -> { holder.rejectView.setText(R.string.call_notification_reject) holder.acceptView.setText(R.string.call_notification_answer) - holder.acceptView.setLeftDrawable(R.drawable.ic_call_video_small, R.attr.colorPrimary) + holder.acceptView.setLeftDrawable(R.drawable.ic_call_video_small, R.attr.colorOnPrimary) } else -> { Timber.w("Shouldn't be in that state") diff --git a/vector/src/main/java/im/vector/app/features/popup/IncomingCallAlert.kt b/vector/src/main/java/im/vector/app/features/popup/IncomingCallAlert.kt index 8a4fc7a78d..17ad35f07a 100644 --- a/vector/src/main/java/im/vector/app/features/popup/IncomingCallAlert.kt +++ b/vector/src/main/java/im/vector/app/features/popup/IncomingCallAlert.kt @@ -18,11 +18,10 @@ package im.vector.app.features.popup import android.app.Activity import android.view.View -import android.widget.ImageView -import android.widget.TextView import im.vector.app.R import im.vector.app.core.extensions.setLeftDrawable import im.vector.app.core.glide.GlideApp +import im.vector.app.databinding.AlerterIncomingCallLayoutBinding import im.vector.app.features.home.AvatarRenderer import org.matrix.android.sdk.api.util.MatrixItem @@ -40,30 +39,24 @@ class IncomingCallAlert(uid: String, private val avatarRenderer: AvatarRenderer, private val isVideoCall: Boolean, private val onAccept: () -> Unit, - private val onReject: () -> Unit) - : VectorAlert.ViewBinder { + private val onReject: () -> Unit) : VectorAlert.ViewBinder { override fun bind(view: View) { - val (callKindText, callKindIcon) = if (isVideoCall) { - Pair(R.string.action_video_call, R.drawable.ic_call_video_small) + val views = AlerterIncomingCallLayoutBinding.bind(view) + val (callKindText, callKindIcon, callKindActionIcon) = if (isVideoCall) { + Triple(R.string.action_video_call, R.drawable.ic_call_video_small, R.drawable.ic_call_answer_video) } else { - Pair(R.string.action_voice_call, R.drawable.ic_call_audio_small) + Triple(R.string.action_voice_call, R.drawable.ic_call_audio_small, R.drawable.ic_call_answer) } - view.findViewById(R.id.incomingCallKindView).apply { - setText(callKindText) - setLeftDrawable(callKindIcon) + views.incomingCallKindView.setText(callKindText) + views.incomingCallKindView.setLeftDrawable(callKindIcon) + views.incomingCallNameView.text = matrixItem?.getBestName() + matrixItem?.let { avatarRenderer.render(it, views.incomingCallAvatar, GlideApp.with(view.context.applicationContext)) } + views.incomingCallAcceptView.setOnClickListener { + onAccept() } - view.findViewById(R.id.incomingCallNameView).text = matrixItem?.getBestName() - view.findViewById(R.id.incomingCallAvatar)?.let { imageView -> - matrixItem?.let { avatarRenderer.render(it, imageView, GlideApp.with(view.context.applicationContext)) } - } - view.findViewById(R.id.incomingCallAcceptView).apply { - setOnClickListener { - onAccept() - } - setImageResource(callKindIcon) - } - view.findViewById(R.id.incomingCallRejectView).setOnClickListener { + views.incomingCallAcceptView.setImageResource(callKindActionIcon) + views.incomingCallRejectView.setOnClickListener { onReject() } } diff --git a/vector/src/main/java/im/vector/app/features/popup/VerificationVectorAlert.kt b/vector/src/main/java/im/vector/app/features/popup/VerificationVectorAlert.kt index ee6728f969..228c629161 100644 --- a/vector/src/main/java/im/vector/app/features/popup/VerificationVectorAlert.kt +++ b/vector/src/main/java/im/vector/app/features/popup/VerificationVectorAlert.kt @@ -18,10 +18,10 @@ package im.vector.app.features.popup import android.app.Activity import android.view.View -import android.widget.ImageView import androidx.annotation.DrawableRes import im.vector.app.R import im.vector.app.core.glide.GlideApp +import im.vector.app.databinding.AlerterVerificationLayoutBinding import im.vector.app.features.home.AvatarRenderer import org.matrix.android.sdk.api.util.MatrixItem @@ -33,19 +33,15 @@ class VerificationVectorAlert(uid: String, * Alert are displayed by default, but let this lambda return false to prevent displaying */ override val shouldBeDisplayedIn: ((Activity) -> Boolean) = { true } -) : DefaultVectorAlert( - uid, title, description, iconId, shouldBeDisplayedIn -) { +) : DefaultVectorAlert(uid, title, description, iconId, shouldBeDisplayedIn) { override val layoutRes = R.layout.alerter_verification_layout class ViewBinder(private val matrixItem: MatrixItem?, - private val avatarRenderer: AvatarRenderer) - : VectorAlert.ViewBinder { + private val avatarRenderer: AvatarRenderer) : VectorAlert.ViewBinder { override fun bind(view: View) { - view.findViewById(R.id.ivUserAvatar)?.let { imageView -> - matrixItem?.let { avatarRenderer.render(it, imageView, GlideApp.with(view.context.applicationContext)) } - } + val views = AlerterVerificationLayoutBinding.bind(view) + matrixItem?.let { avatarRenderer.render(it, views.ivUserAvatar, GlideApp.with(view.context.applicationContext)) } } } } diff --git a/vector/src/main/java/im/vector/app/features/settings/troubleshoot/NotificationTroubleshootRecyclerViewAdapter.kt b/vector/src/main/java/im/vector/app/features/settings/troubleshoot/NotificationTroubleshootRecyclerViewAdapter.kt index fd7e3cbb6a..70e5bdff10 100644 --- a/vector/src/main/java/im/vector/app/features/settings/troubleshoot/NotificationTroubleshootRecyclerViewAdapter.kt +++ b/vector/src/main/java/im/vector/app/features/settings/troubleshoot/NotificationTroubleshootRecyclerViewAdapter.kt @@ -18,13 +18,10 @@ package im.vector.app.features.settings.troubleshoot import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.Button -import android.widget.ImageView -import android.widget.ProgressBar -import android.widget.TextView import androidx.core.content.ContextCompat import androidx.recyclerview.widget.RecyclerView import im.vector.app.R +import im.vector.app.databinding.ItemNotificationTroubleshootBinding import im.vector.app.features.themes.ThemeUtils class NotificationTroubleshootRecyclerViewAdapter(val tests: ArrayList) @@ -46,71 +43,67 @@ class NotificationTroubleshootRecyclerViewAdapter(val tests: ArrayList(R.id.troubleshootProgressBar) - private val troubleshootTestTitle = itemView.findViewById(R.id.troubleshootTestTitle) - private val troubleshootTestDescription = itemView.findViewById(R.id.troubleshootTestDescription) - private val troubleshootStatusIcon = itemView.findViewById(R.id.troubleshootStatusIcon) - private val troubleshootTestButton = itemView.findViewById