diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt index ca98be625c..80dfe25c77 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/VectorSettingsDevicesFragment.kt @@ -114,13 +114,13 @@ class VectorSettingsDevicesFragment : } private fun initLearnMoreButtons() { - views.deviceListHeaderSectionOther.onLearnMoreClickListener = { + views.deviceListHeaderOtherSessions.onLearnMoreClickListener = { Toast.makeText(context, "Learn more other", Toast.LENGTH_LONG).show() } } private fun cleanUpLearnMoreButtonsListeners() { - views.deviceListHeaderSectionOther.onLearnMoreClickListener = null + views.deviceListHeaderOtherSessions.onLearnMoreClickListener = null } override fun invalidate() = withState(viewModel) { state -> @@ -145,29 +145,29 @@ class VectorSettingsDevicesFragment : if (otherDevices.isNullOrEmpty()) { hideOtherSessionsView() } else { - views.deviceListHeaderSectionOther.isVisible = true + views.deviceListHeaderOtherSessions.isVisible = true views.deviceListOtherSessions.isVisible = true - views.deviceListOtherSessions.update(otherDevices) + views.deviceListOtherSessions.render(otherDevices) } } private fun hideOtherSessionsView() { - views.deviceListHeaderSectionOther.isVisible = false + views.deviceListHeaderOtherSessions.isVisible = false views.deviceListOtherSessions.isVisible = false } private fun renderCurrentDevice(currentDeviceInfo: DeviceFullInfo?) { currentDeviceInfo?.let { - views.deviceListHeaderSectionCurrent.isVisible = true + views.deviceListHeaderCurrentSession.isVisible = true views.deviceListCurrentSession.isVisible = true - views.deviceListCurrentSession.update(it) + views.deviceListCurrentSession.render(it) } ?: run { hideCurrentSessionView() } } private fun hideCurrentSessionView() { - views.deviceListHeaderSectionCurrent.isVisible = false + views.deviceListHeaderCurrentSession.isVisible = false views.deviceListCurrentSession.isVisible = false } diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/CurrentSessionView.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/CurrentSessionView.kt index c74dd9a7fa..d6f81f4f79 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/CurrentSessionView.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/CurrentSessionView.kt @@ -39,8 +39,8 @@ class CurrentSessionView @JvmOverloads constructor( views = ViewCurrentSessionBinding.bind(this) } - fun update(currentDeviceInfo: DeviceFullInfo) { - renderDeviceInfo(currentDeviceInfo.deviceInfo.displayName ?: "") + fun render(currentDeviceInfo: DeviceFullInfo) { + renderDeviceInfo(currentDeviceInfo.deviceInfo.displayName.orEmpty()) renderVerificationStatus(currentDeviceInfo.trustLevelForShield) } diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionDeviceType.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/DeviceType.kt similarity index 95% rename from vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionDeviceType.kt rename to vector/src/main/java/im/vector/app/features/settings/devices/v2/list/DeviceType.kt index 62e66f72f5..3082901375 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionDeviceType.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/DeviceType.kt @@ -16,7 +16,7 @@ package im.vector.app.features.settings.devices.v2.list -enum class SessionDeviceType { +enum class DeviceType { MOBILE, WEB, DESKTOP, 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 f3b44572b3..2a62100994 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 @@ -23,6 +23,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.core.resources.StringProvider import im.vector.app.core.ui.views.ShieldImageView import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel @@ -30,7 +31,7 @@ import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel abstract class OtherSessionItem : VectorEpoxyModel(R.layout.item_other_session) { @EpoxyAttribute - var deviceType: SessionDeviceType = SessionDeviceType.UNKNOWN + var deviceType: DeviceType = DeviceType.UNKNOWN @EpoxyAttribute var roomEncryptionTrustLevel: RoomEncryptionTrustLevel? = null @@ -41,16 +42,29 @@ abstract class OtherSessionItem : VectorEpoxyModel(R.la @EpoxyAttribute var sessionDescription: String? = null + @EpoxyAttribute + lateinit var stringProvider: StringProvider + override fun bind(holder: Holder) { super.bind(holder) - holder.otherSessionDeviceTypeImageView.setImageResource( - when (deviceType) { - SessionDeviceType.MOBILE -> R.drawable.ic_device_type_mobile - SessionDeviceType.WEB -> R.drawable.ic_device_type_web - SessionDeviceType.DESKTOP -> R.drawable.ic_device_type_desktop - SessionDeviceType.UNKNOWN -> R.drawable.ic_device_type_unknown - } - ) + when (deviceType) { + DeviceType.MOBILE -> { + holder.otherSessionDeviceTypeImageView.setImageResource(R.drawable.ic_device_type_mobile) + holder.otherSessionDeviceTypeImageView.contentDescription = stringProvider.getString(R.string.a11y_device_manager_device_type_mobile) + } + DeviceType.WEB -> { + holder.otherSessionDeviceTypeImageView.setImageResource(R.drawable.ic_device_type_web) + holder.otherSessionDeviceTypeImageView.contentDescription = stringProvider.getString(R.string.a11y_device_manager_device_type_web) + } + DeviceType.DESKTOP -> { + holder.otherSessionDeviceTypeImageView.setImageResource(R.drawable.ic_device_type_desktop) + holder.otherSessionDeviceTypeImageView.contentDescription = stringProvider.getString(R.string.a11y_device_manager_device_type_desktop) + } + DeviceType.UNKNOWN -> { + holder.otherSessionDeviceTypeImageView.setImageResource(R.drawable.ic_device_type_unknown) + holder.otherSessionDeviceTypeImageView.contentDescription = stringProvider.getString(R.string.a11y_device_manager_device_type_unknown) + } + } holder.otherSessionVerificationStatusImageView.render(roomEncryptionTrustLevel) holder.otherSessionNameTextView.text = sessionName holder.otherSessionDescriptionTextView.text = sessionDescription 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 24b9e539d8..44c73e6eb7 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 @@ -32,7 +32,6 @@ class OtherSessionsController @Inject constructor( ) : TypedEpoxyController>() { override fun buildModels(data: List?) { - data ?: return val host = this if (data.isNullOrEmpty()) { @@ -51,10 +50,11 @@ class OtherSessionsController @Inject constructor( otherSessionItem { id(device.deviceInfo.deviceId) - deviceType(SessionDeviceType.UNKNOWN) // TODO. We don't have this info yet. Update accordingly. + deviceType(DeviceType.UNKNOWN) // TODO. We don't have this info yet. Update accordingly. roomEncryptionTrustLevel(device.trustLevelForShield) sessionName(device.deviceInfo.displayName) sessionDescription(description) + stringProvider(this@OtherSessionsController.stringProvider) } } } diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsView.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsView.kt index 3dd445beb6..bcb9726b5c 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsView.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/OtherSessionsView.kt @@ -42,7 +42,7 @@ class OtherSessionsView @JvmOverloads constructor( views = ViewOtherSessionsBinding.bind(this) } - fun update(devices: List) { + fun render(devices: List) { views.otherSessionsRecyclerView.configureWith(otherSessionsController, hasFixedSize = true) views.otherSessionsViewAllButton.text = context.getString(R.string.device_manager_other_sessions_view_all, devices.size) otherSessionsController.setData(devices) diff --git a/vector/src/main/res/layout/fragment_settings_devices.xml b/vector/src/main/res/layout/fragment_settings_devices.xml index ea28531150..1367835d2c 100644 --- a/vector/src/main/res/layout/fragment_settings_devices.xml +++ b/vector/src/main/res/layout/fragment_settings_devices.xml @@ -9,7 +9,7 @@ android:layout_height="wrap_content"> + app:layout_constraintTop_toBottomOf="@id/deviceListHeaderCurrentSession" /> + app:layout_constraintTop_toBottomOf="@id/deviceListDividerCurrentSession" /> + app:layout_constraintTop_toBottomOf="@id/deviceListHeaderOtherSessions" /> Show All Sessions (V2, WIP) Mobile - Web - Desktop + Web + Desktop + Unknown device type Verified session Unverified session Your current session is ready for secure messaging.