Navigation from other session item

This commit is contained in:
Maxime NATUREL 2022-09-01 10:43:17 +02:00
parent b626a1e4f9
commit 30710f7f15
5 changed files with 33 additions and 0 deletions

View File

@ -42,6 +42,7 @@ import im.vector.app.features.settings.devices.DevicesViewEvents
import im.vector.app.features.settings.devices.DevicesViewModel
import im.vector.app.features.settings.devices.v2.list.SESSION_IS_MARKED_AS_INACTIVE_AFTER_DAYS
import im.vector.app.features.settings.devices.v2.list.SecurityRecommendationViewState
import im.vector.app.features.settings.devices.v2.list.OtherSessionsController
import im.vector.app.features.settings.devices.v2.list.SessionInfoViewState
import javax.inject.Inject
@ -76,6 +77,7 @@ class VectorSettingsDevicesFragment :
initLearnMoreButtons()
initWaitingView()
initOtherSessionsView()
observeViewEvents()
}
@ -114,6 +116,14 @@ class VectorSettingsDevicesFragment :
views.waitingView.waitingStatusText.isVisible = true
}
private fun initOtherSessionsView() {
views.deviceListOtherSessions.setCallback(object : OtherSessionsController.Callback {
override fun onItemClicked(deviceId: String) {
navigateToSessionOverview(deviceId)
}
})
}
override fun onDestroyView() {
cleanUpLearnMoreButtonsListeners()
super.onDestroyView()

View File

@ -22,8 +22,10 @@ import android.widget.TextView
import com.airbnb.epoxy.EpoxyAttribute
import com.airbnb.epoxy.EpoxyModelClass
import im.vector.app.R
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.StringProvider
import im.vector.app.core.ui.views.ShieldImageView
import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel
@ -49,8 +51,16 @@ abstract class OtherSessionItem : VectorEpoxyModel<OtherSessionItem.Holder>(R.la
@EpoxyAttribute
lateinit var stringProvider: StringProvider
@EpoxyAttribute(EpoxyAttribute.Option.DoNotHash)
var clickListener: ClickListener? = null
override fun bind(holder: Holder) {
super.bind(holder)
holder.view.onClick(clickListener)
if (clickListener == null) {
holder.view.isClickable = false
}
when (deviceType) {
DeviceType.MOBILE -> {
holder.otherSessionDeviceTypeImageView.setImageResource(R.drawable.ic_device_type_mobile)

View File

@ -35,6 +35,12 @@ class OtherSessionsController @Inject constructor(
private val colorProvider: ColorProvider,
) : TypedEpoxyController<List<DeviceFullInfo>>() {
var callback: Callback? = null
interface Callback {
fun onItemClicked(deviceId: String)
}
override fun buildModels(data: List<DeviceFullInfo>?) {
val host = this
@ -70,6 +76,7 @@ class OtherSessionsController @Inject constructor(
sessionDescription(description)
sessionDescriptionDrawable(descriptionDrawable)
stringProvider(this@OtherSessionsController.stringProvider)
clickListener { device.deviceInfo.deviceId?.let { host.callback?.onItemClicked(it) } }
}
}
}

View File

@ -49,7 +49,12 @@ class OtherSessionsView @JvmOverloads constructor(
otherSessionsController.setData(devices)
}
fun setCallback(callback: OtherSessionsController.Callback) {
otherSessionsController.callback = callback
}
override fun onDetachedFromWindow() {
otherSessionsController.callback = null
views.otherSessionsRecyclerView.cleanup()
super.onDetachedFromWindow()
}

View File

@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="?selectableItemBackground"
android:paddingTop="16dp">
<ImageView