diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionItem.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionItem.kt index 888305fb4e..de1cd33d35 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionItem.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionItem.kt @@ -22,7 +22,6 @@ import android.view.View.OnLongClickListener import android.widget.ImageView import android.widget.TextView import androidx.annotation.ColorInt -import androidx.core.content.ContextCompat import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass import im.vector.app.R @@ -30,6 +29,8 @@ import im.vector.app.core.epoxy.ClickListener import im.vector.app.core.epoxy.VectorEpoxyHolder import im.vector.app.core.epoxy.VectorEpoxyModel import im.vector.app.core.epoxy.onClick +import im.vector.app.core.resources.ColorProvider +import im.vector.app.core.resources.DrawableProvider import im.vector.app.core.resources.StringProvider import im.vector.app.core.ui.views.ShieldImageView import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel @@ -59,6 +60,12 @@ abstract class OtherSessionItem : VectorEpoxyModel(R.la @EpoxyAttribute lateinit var stringProvider: StringProvider + @EpoxyAttribute + lateinit var colorProvider: ColorProvider + + @EpoxyAttribute + lateinit var drawableProvider: DrawableProvider + @EpoxyAttribute var selected: Boolean = false @@ -74,11 +81,18 @@ abstract class OtherSessionItem : VectorEpoxyModel(R.la super.bind(holder) holder.view.onClick(clickListener) holder.view.setOnLongClickListener(onLongClickListener) - if (clickListener == null) { + if (clickListener == null && onLongClickListener == null) { holder.view.isClickable = false } - setDeviceTypeIconUseCase.execute(deviceType, holder.otherSessionDeviceTypeImageView, stringProvider) + holder.otherSessionDeviceTypeImageView.isSelected = selected + if (selected) { + val drawableColor = colorProvider.getColorFromAttribute(android.R.attr.colorBackground) + val drawable = drawableProvider.getDrawable(R.drawable.ic_check_on, drawableColor) + holder.otherSessionDeviceTypeImageView.setImageDrawable(drawable) + } else { + setDeviceTypeIconUseCase.execute(deviceType, holder.otherSessionDeviceTypeImageView, stringProvider) + } holder.otherSessionVerificationStatusImageView.render(roomEncryptionTrustLevel) holder.otherSessionNameTextView.text = sessionName holder.otherSessionDescriptionTextView.text = sessionDescription @@ -86,9 +100,7 @@ abstract class OtherSessionItem : VectorEpoxyModel(R.la holder.otherSessionDescriptionTextView.setTextColor(it) } holder.otherSessionDescriptionTextView.setCompoundDrawablesWithIntrinsicBounds(sessionDescriptionDrawable, null, null, null) - // TODO set drawable with correct color and corners - val color = if (selected) R.color.alert_default_error_background else android.R.color.transparent - holder.otherSessionItemBackgroundView.setBackgroundColor(ContextCompat.getColor(holder.view.context, color)) + holder.otherSessionItemBackgroundView.isSelected = selected } class Holder : VectorEpoxyHolder() { diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsController.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsController.kt index b50abaaf7d..9193479b74 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsController.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsController.kt @@ -73,6 +73,8 @@ class OtherSessionsController @Inject constructor( sessionDescriptionDrawable(descriptionDrawable) sessionDescriptionColor(descriptionColor) stringProvider(this@OtherSessionsController.stringProvider) + colorProvider(this@OtherSessionsController.colorProvider) + drawableProvider(this@OtherSessionsController.drawableProvider) selected(device.isSelected) clickListener { device.deviceInfo.deviceId?.let { host.callback?.onItemClicked(it) } } onLongClickListener(View.OnLongClickListener { diff --git a/vector/src/main/res/drawable/bg_device_type.xml b/vector/src/main/res/drawable/bg_device_type.xml index 88a90ccbe6..dc85b723a8 100644 --- a/vector/src/main/res/drawable/bg_device_type.xml +++ b/vector/src/main/res/drawable/bg_device_type.xml @@ -1,7 +1,13 @@ - - - - - + + + + + + + + + + + + diff --git a/vector/src/main/res/drawable/bg_other_session.xml b/vector/src/main/res/drawable/bg_other_session.xml new file mode 100644 index 0000000000..a0c988b8a2 --- /dev/null +++ b/vector/src/main/res/drawable/bg_other_session.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/vector/src/main/res/layout/item_other_session.xml b/vector/src/main/res/layout/item_other_session.xml index 29f6fafcbc..908a0e0073 100644 --- a/vector/src/main/res/layout/item_other_session.xml +++ b/vector/src/main/res/layout/item_other_session.xml @@ -12,6 +12,7 @@ android:id="@+id/otherSessionItemBackground" android:layout_width="0dp" android:layout_height="0dp" + android:background="@drawable/bg_other_session" app:layout_constraintBottom_toBottomOf="@id/otherSessionVerificationStatusImageView" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"