Handling correct UI for selected session
This commit is contained in:
parent
a703b8ae10
commit
3390d7fde4
@ -22,7 +22,6 @@ import android.view.View.OnLongClickListener
|
|||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import com.airbnb.epoxy.EpoxyAttribute
|
import com.airbnb.epoxy.EpoxyAttribute
|
||||||
import com.airbnb.epoxy.EpoxyModelClass
|
import com.airbnb.epoxy.EpoxyModelClass
|
||||||
import im.vector.app.R
|
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.VectorEpoxyHolder
|
||||||
import im.vector.app.core.epoxy.VectorEpoxyModel
|
import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||||
import im.vector.app.core.epoxy.onClick
|
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.resources.StringProvider
|
||||||
import im.vector.app.core.ui.views.ShieldImageView
|
import im.vector.app.core.ui.views.ShieldImageView
|
||||||
import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel
|
import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel
|
||||||
@ -59,6 +60,12 @@ abstract class OtherSessionItem : VectorEpoxyModel<OtherSessionItem.Holder>(R.la
|
|||||||
@EpoxyAttribute
|
@EpoxyAttribute
|
||||||
lateinit var stringProvider: StringProvider
|
lateinit var stringProvider: StringProvider
|
||||||
|
|
||||||
|
@EpoxyAttribute
|
||||||
|
lateinit var colorProvider: ColorProvider
|
||||||
|
|
||||||
|
@EpoxyAttribute
|
||||||
|
lateinit var drawableProvider: DrawableProvider
|
||||||
|
|
||||||
@EpoxyAttribute
|
@EpoxyAttribute
|
||||||
var selected: Boolean = false
|
var selected: Boolean = false
|
||||||
|
|
||||||
@ -74,11 +81,18 @@ abstract class OtherSessionItem : VectorEpoxyModel<OtherSessionItem.Holder>(R.la
|
|||||||
super.bind(holder)
|
super.bind(holder)
|
||||||
holder.view.onClick(clickListener)
|
holder.view.onClick(clickListener)
|
||||||
holder.view.setOnLongClickListener(onLongClickListener)
|
holder.view.setOnLongClickListener(onLongClickListener)
|
||||||
if (clickListener == null) {
|
if (clickListener == null && onLongClickListener == null) {
|
||||||
holder.view.isClickable = false
|
holder.view.isClickable = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
setDeviceTypeIconUseCase.execute(deviceType, holder.otherSessionDeviceTypeImageView, stringProvider)
|
||||||
|
}
|
||||||
holder.otherSessionVerificationStatusImageView.render(roomEncryptionTrustLevel)
|
holder.otherSessionVerificationStatusImageView.render(roomEncryptionTrustLevel)
|
||||||
holder.otherSessionNameTextView.text = sessionName
|
holder.otherSessionNameTextView.text = sessionName
|
||||||
holder.otherSessionDescriptionTextView.text = sessionDescription
|
holder.otherSessionDescriptionTextView.text = sessionDescription
|
||||||
@ -86,9 +100,7 @@ abstract class OtherSessionItem : VectorEpoxyModel<OtherSessionItem.Holder>(R.la
|
|||||||
holder.otherSessionDescriptionTextView.setTextColor(it)
|
holder.otherSessionDescriptionTextView.setTextColor(it)
|
||||||
}
|
}
|
||||||
holder.otherSessionDescriptionTextView.setCompoundDrawablesWithIntrinsicBounds(sessionDescriptionDrawable, null, null, null)
|
holder.otherSessionDescriptionTextView.setCompoundDrawablesWithIntrinsicBounds(sessionDescriptionDrawable, null, null, null)
|
||||||
// TODO set drawable with correct color and corners
|
holder.otherSessionItemBackgroundView.isSelected = selected
|
||||||
val color = if (selected) R.color.alert_default_error_background else android.R.color.transparent
|
|
||||||
holder.otherSessionItemBackgroundView.setBackgroundColor(ContextCompat.getColor(holder.view.context, color))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Holder : VectorEpoxyHolder() {
|
class Holder : VectorEpoxyHolder() {
|
||||||
|
@ -73,6 +73,8 @@ class OtherSessionsController @Inject constructor(
|
|||||||
sessionDescriptionDrawable(descriptionDrawable)
|
sessionDescriptionDrawable(descriptionDrawable)
|
||||||
sessionDescriptionColor(descriptionColor)
|
sessionDescriptionColor(descriptionColor)
|
||||||
stringProvider(this@OtherSessionsController.stringProvider)
|
stringProvider(this@OtherSessionsController.stringProvider)
|
||||||
|
colorProvider(this@OtherSessionsController.colorProvider)
|
||||||
|
drawableProvider(this@OtherSessionsController.drawableProvider)
|
||||||
selected(device.isSelected)
|
selected(device.isSelected)
|
||||||
clickListener { device.deviceInfo.deviceId?.let { host.callback?.onItemClicked(it) } }
|
clickListener { device.deviceInfo.deviceId?.let { host.callback?.onItemClicked(it) } }
|
||||||
onLongClickListener(View.OnLongClickListener {
|
onLongClickListener(View.OnLongClickListener {
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
android:shape="oval">
|
<item android:state_selected="true">
|
||||||
|
<shape android:shape="oval">
|
||||||
<solid android:color="?vctr_system" />
|
<solid android:color="?attr/vctr_content_primary" />
|
||||||
|
|
||||||
</shape>
|
</shape>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<shape android:shape="oval">
|
||||||
|
<solid android:color="?attr/colorSurface" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</selector>
|
||||||
|
9
vector/src/main/res/drawable/bg_other_session.xml
Normal file
9
vector/src/main/res/drawable/bg_other_session.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:drawable="@drawable/rounded_rect_shape_8" android:state_selected="true" />
|
||||||
|
<item>
|
||||||
|
<shape android:shape="rectangle">
|
||||||
|
<solid android:color="@android:color/transparent" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</selector>
|
@ -12,6 +12,7 @@
|
|||||||
android:id="@+id/otherSessionItemBackground"
|
android:id="@+id/otherSessionItemBackground"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
|
android:background="@drawable/bg_other_session"
|
||||||
app:layout_constraintBottom_toBottomOf="@id/otherSessionVerificationStatusImageView"
|
app:layout_constraintBottom_toBottomOf="@id/otherSessionVerificationStatusImageView"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user