From f2f775cb9966009ce46f31cd0fab7dddaf8a12d5 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Sat, 1 Feb 2020 00:27:19 +0100 Subject: [PATCH 01/16] Add TODOs --- .../android/api/session/room/model/message/MessageContent.kt | 1 + .../matrix/android/internal/session/room/RoomSummaryUpdater.kt | 1 + 2 files changed, 2 insertions(+) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageContent.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageContent.kt index 157ff00d69..c0adfa4c36 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageContent.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/message/MessageContent.kt @@ -20,6 +20,7 @@ import im.vector.matrix.android.api.session.events.model.Content import im.vector.matrix.android.api.session.room.model.relation.RelationDefaultContent interface MessageContent { + // TODO Rename to msgType val type: String val body: String val relatesTo: RelationDefaultContent? diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomSummaryUpdater.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomSummaryUpdater.kt index e65a1eb73e..3f3f6f4c3c 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomSummaryUpdater.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomSummaryUpdater.kt @@ -52,6 +52,7 @@ internal class RoomSummaryUpdater @Inject constructor( // TODO: maybe allow user of SDK to give that list private val PREVIEWABLE_TYPES = listOf( + // TODO filter message type (KEY_VERIFICATION_READY, etc.) EventType.MESSAGE, EventType.STATE_ROOM_NAME, EventType.STATE_ROOM_TOPIC, From 256f8b77aaea0cf882e675a108bedde9e7f16fe0 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Sat, 1 Feb 2020 10:09:22 +0100 Subject: [PATCH 02/16] Add Timber to rx module --- matrix-sdk-android-rx/build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/matrix-sdk-android-rx/build.gradle b/matrix-sdk-android-rx/build.gradle index 1d8e81e44f..8907ee8b50 100644 --- a/matrix-sdk-android-rx/build.gradle +++ b/matrix-sdk-android-rx/build.gradle @@ -41,6 +41,9 @@ dependencies { // Paging implementation "androidx.paging:paging-runtime-ktx:2.1.0" + // Logging + implementation 'com.jakewharton.timber:timber:4.7.1' + testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' From fc4f5faffdd0d5744f4555e03c9d6a419d3d7006 Mon Sep 17 00:00:00 2001 From: Valere Date: Sat, 1 Feb 2020 10:21:29 +0100 Subject: [PATCH 03/16] Update Room decoration algo --- .../main/java/im/vector/matrix/rx/RxRoom.kt | 14 ++++++------- .../java/im/vector/matrix/rx/RxSession.kt | 2 +- .../DefaultCrossSigningService.kt | 21 +++++++++++-------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt index 9cf382cfd2..a0301e5cab 100644 --- a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt +++ b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt @@ -46,7 +46,7 @@ class RxRoom(private val room: Room, private val session: Session) { it.getOrNull()?.let { roomSummary -> if (roomSummary.isEncrypted) { // Return the list of other users - roomSummary.otherMemberIds + roomSummary.otherMemberIds + listOf(session.myUserId) } else { // Return an empty list, the room is not encrypted emptyList() @@ -56,21 +56,21 @@ class RxRoom(private val room: Room, private val session: Session) { // Observe the device info of the users in the room val cryptoDeviceInfoObservable = memberIdsChangeObservable - .switchMap { otherUserIds -> - session.getLiveCryptoDeviceInfo(otherUserIds) + .switchMap { membersIds -> + session.getLiveCryptoDeviceInfo(membersIds) .asObservable() .map { // If any key change, emit the userIds list - otherUserIds + membersIds } } val roomEncryptionTrustLevelObservable = cryptoDeviceInfoObservable - .map { otherUserIds -> - if (otherUserIds.isEmpty()) { + .map { userIds -> + if (userIds.isEmpty()) { Optional(null) } else { - session.getCrossSigningService().getTrustLevelForUsers(otherUserIds).toOptional() + session.getCrossSigningService().getTrustLevelForUsers(userIds).toOptional() } } diff --git a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt index f9021dde45..cbe47472c4 100644 --- a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt +++ b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt @@ -51,7 +51,7 @@ class RxSession(private val session: Session) { summaries.map { if (it.isEncrypted) { it.copy( - roomEncryptionTrustLevel = session.getCrossSigningService().getTrustLevelForUsers(it.otherMemberIds) + roomEncryptionTrustLevel = session.getCrossSigningService().getTrustLevelForUsers(it.otherMemberIds + listOf(session.myUserId)) ) } else { it diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/crosssigning/DefaultCrossSigningService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/crosssigning/DefaultCrossSigningService.kt index d01ebb7ea4..b987dd6818 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/crosssigning/DefaultCrossSigningService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/crosssigning/DefaultCrossSigningService.kt @@ -659,16 +659,19 @@ internal class DefaultCrossSigningService @Inject constructor( } override fun getTrustLevelForUsers(userIds: List): RoomEncryptionTrustLevel { - val atLeastOneTrusted = userIds - .filter { it != userId } - .map { getUserCrossSigningKeys(it) } - .any { it?.isTrusted() == true } + val allTrusted = userIds + .filter { getUserCrossSigningKeys(it)?.isTrusted() == true } - return if (!atLeastOneTrusted) { + val allUsersAreVerified = userIds.size == allTrusted.size + + return if (allTrusted.isEmpty()) { RoomEncryptionTrustLevel.Default } else { - // I have verified at least one other user - val allDevices = userIds.mapNotNull { + + // If one of the verified user as an untrusted device -> warning + // Green if all devices of all verified users are trusted -> green + // else black + val allDevices = allTrusted.mapNotNull { cryptoStore.getUserDeviceList(it) }.flatten() if (getMyCrossSigningKeys() != null) { @@ -676,14 +679,14 @@ internal class DefaultCrossSigningService @Inject constructor( if (hasWarning) { RoomEncryptionTrustLevel.Warning } else { - RoomEncryptionTrustLevel.Trusted + if (allUsersAreVerified) RoomEncryptionTrustLevel.Trusted else RoomEncryptionTrustLevel.Default } } else { val hasWarningLegacy = allDevices.any { !it.isVerified } if (hasWarningLegacy) { RoomEncryptionTrustLevel.Warning } else { - RoomEncryptionTrustLevel.Trusted + if (allUsersAreVerified) RoomEncryptionTrustLevel.Trusted else RoomEncryptionTrustLevel.Default } } } From 64df9e23c22053adaeeb0b97247367a68028fbd9 Mon Sep 17 00:00:00 2001 From: Valere Date: Sat, 1 Feb 2020 11:03:00 +0100 Subject: [PATCH 04/16] Room Profile / Just show e2e status remove learn more --- .../features/roomprofile/RoomProfileController.kt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileController.kt b/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileController.kt index 44a50ee5e6..39886b24a2 100644 --- a/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileController.kt +++ b/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileController.kt @@ -23,6 +23,7 @@ import im.vector.riotx.core.epoxy.profiles.buildProfileAction import im.vector.riotx.core.epoxy.profiles.buildProfileSection import im.vector.riotx.core.resources.ColorProvider import im.vector.riotx.core.resources.StringProvider +import im.vector.riotx.core.ui.list.genericFooterItem import javax.inject.Inject class RoomProfileController @Inject constructor( @@ -55,14 +56,12 @@ class RoomProfileController @Inject constructor( } else { R.string.room_profile_not_encrypted_subtitle } - buildProfileAction( - id = "learn_more", - title = stringProvider.getString(R.string.room_profile_section_security_learn_more), - dividerColor = dividerColor, - subtitle = stringProvider.getString(learnMoreSubtitle), - action = { callback?.onLearnMoreClicked() } - ) - + genericFooterItem { + id("e2e info") + centered(false) + text(stringProvider.getString(learnMoreSubtitle)) + } + // More buildProfileSection(stringProvider.getString(R.string.room_profile_section_more)) buildProfileAction( From 59abee10f82cc61bcea12c6ae954af2f78b671eb Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Sat, 1 Feb 2020 10:44:02 +0100 Subject: [PATCH 05/16] Convert to ConstraintLayout --- .../view_stub_room_member_profile_header.xml | 43 +++++++++++++------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/vector/src/main/res/layout/view_stub_room_member_profile_header.xml b/vector/src/main/res/layout/view_stub_room_member_profile_header.xml index dcaa4bd553..026561dd80 100644 --- a/vector/src/main/res/layout/view_stub_room_member_profile_header.xml +++ b/vector/src/main/res/layout/view_stub_room_member_profile_header.xml @@ -1,5 +1,6 @@ - + android:paddingStart="16dp" + android:paddingEnd="16dp" + app:layout_constraintBottom_toTopOf="@+id/memberProfileNameView" + app:layout_constraintTop_toTopOf="@+id/memberProfileNameView"> - + \ No newline at end of file From cd606ba8a107a4461baade1a1c4343be91a15f37 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Sat, 1 Feb 2020 11:36:07 +0100 Subject: [PATCH 06/16] RoomMember decoration --- .../main/java/im/vector/matrix/rx/RxRoom.kt | 24 ++++++++++- .../session/room/model/RoomMemberSummary.kt | 8 +++- .../DefaultCrossSigningService.kt | 1 - .../mapper/RoomMemberSummaryMapper.kt | 3 +- .../core/epoxy/profiles/ProfileMatrixItem.kt | 5 +++ .../RoomMemberProfileController.kt | 14 +++++-- .../RoomMemberProfileFragment.kt | 41 ++++++++++++++++++- .../RoomMemberProfileViewModel.kt | 12 ++++-- .../RoomMemberProfileViewState.kt | 3 +- .../members/RoomMemberListController.kt | 1 + .../res/layout/item_profile_matrix_item.xml | 10 +++++ .../view_stub_room_member_profile_header.xml | 10 +++++ 12 files changed, 117 insertions(+), 15 deletions(-) diff --git a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt index a0301e5cab..6ca0b55fd7 100644 --- a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt +++ b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt @@ -30,6 +30,7 @@ import im.vector.matrix.android.api.session.room.send.UserDraft import im.vector.matrix.android.api.session.room.timeline.TimelineEvent import im.vector.matrix.android.api.util.Optional import im.vector.matrix.android.api.util.toOptional +import im.vector.matrix.android.internal.crypto.model.CryptoDeviceInfo import io.reactivex.Observable import io.reactivex.Single import io.reactivex.functions.BiFunction @@ -87,8 +88,29 @@ class RxRoom(private val room: Room, private val session: Session) { } fun liveRoomMembers(queryParams: RoomMemberQueryParams): Observable> { - return room.getRoomMembersLive(queryParams).asObservable() + val roomMembersObservable = room.getRoomMembersLive(queryParams).asObservable() .startWith(room.getRoomMembers(queryParams)) + + // TODO Do it only for room members of the room (switchMap) + val cryptoDeviceInfoObservable = session.getLiveCryptoDeviceInfo().asObservable() + + return Observable + .combineLatest, List, List>( + roomMembersObservable, + cryptoDeviceInfoObservable, + BiFunction { summaries, _ -> + summaries.map { + if (room.isEncrypted()) { + it.copy( + // Get the trust level of a virtual room with only this user + userEncryptionTrustLevel = session.getCrossSigningService().getTrustLevelForUsers(listOf(it.userId)) + ) + } else { + it + } + } + } + ) } fun liveAnnotationSummary(eventId: String): Observable> { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/RoomMemberSummary.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/RoomMemberSummary.kt index 17768362b2..d3b7f3f026 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/RoomMemberSummary.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/RoomMemberSummary.kt @@ -16,12 +16,16 @@ package im.vector.matrix.android.api.session.room.model +import im.vector.matrix.android.api.crypto.RoomEncryptionTrustLevel + /** * Class representing a simplified version of EventType.STATE_ROOM_MEMBER state event content */ -data class RoomMemberSummary( +data class RoomMemberSummary constructor( val membership: Membership, val userId: String, val displayName: String? = null, - val avatarUrl: String? = null + val avatarUrl: String? = null, + // TODO Warning: Will not be populated if not using RxRoom + val userEncryptionTrustLevel: RoomEncryptionTrustLevel? = null ) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/crosssigning/DefaultCrossSigningService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/crosssigning/DefaultCrossSigningService.kt index b987dd6818..1c5a549a05 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/crosssigning/DefaultCrossSigningService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/crypto/crosssigning/DefaultCrossSigningService.kt @@ -667,7 +667,6 @@ internal class DefaultCrossSigningService @Inject constructor( return if (allTrusted.isEmpty()) { RoomEncryptionTrustLevel.Default } else { - // If one of the verified user as an untrusted device -> warning // Green if all devices of all verified users are trusted -> green // else black diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/RoomMemberSummaryMapper.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/RoomMemberSummaryMapper.kt index 470772a40e..5e8db4cf84 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/RoomMemberSummaryMapper.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/mapper/RoomMemberSummaryMapper.kt @@ -26,7 +26,8 @@ internal object RoomMemberSummaryMapper { userId = roomMemberSummaryEntity.userId, avatarUrl = roomMemberSummaryEntity.avatarUrl, displayName = roomMemberSummaryEntity.displayName, - membership = roomMemberSummaryEntity.membership + membership = roomMemberSummaryEntity.membership, + userEncryptionTrustLevel = null ) } } diff --git a/vector/src/main/java/im/vector/riotx/core/epoxy/profiles/ProfileMatrixItem.kt b/vector/src/main/java/im/vector/riotx/core/epoxy/profiles/ProfileMatrixItem.kt index 4fe65748ce..5d9a89be34 100644 --- a/vector/src/main/java/im/vector/riotx/core/epoxy/profiles/ProfileMatrixItem.kt +++ b/vector/src/main/java/im/vector/riotx/core/epoxy/profiles/ProfileMatrixItem.kt @@ -22,11 +22,13 @@ import android.widget.ImageView import android.widget.TextView import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass +import im.vector.matrix.android.api.crypto.RoomEncryptionTrustLevel import im.vector.matrix.android.api.util.MatrixItem import im.vector.riotx.R import im.vector.riotx.core.epoxy.VectorEpoxyHolder import im.vector.riotx.core.epoxy.VectorEpoxyModel import im.vector.riotx.core.extensions.setTextOrHide +import im.vector.riotx.features.crypto.util.toImageRes import im.vector.riotx.features.home.AvatarRenderer @EpoxyModelClass(layout = R.layout.item_profile_matrix_item) @@ -34,6 +36,7 @@ abstract class ProfileMatrixItem : VectorEpoxyModel() @EpoxyAttribute lateinit var avatarRenderer: AvatarRenderer @EpoxyAttribute lateinit var matrixItem: MatrixItem + @EpoxyAttribute var userEncryptionTrustLevel: RoomEncryptionTrustLevel? = null @EpoxyAttribute var clickListener: View.OnClickListener? = null override fun bind(holder: Holder) { @@ -43,11 +46,13 @@ abstract class ProfileMatrixItem : VectorEpoxyModel() holder.titleView.text = bestName holder.subtitleView.setTextOrHide(matrixId) avatarRenderer.render(matrixItem, holder.avatarImageView) + holder.avatarDecorationImageView.setImageResource(userEncryptionTrustLevel.toImageRes()) } class Holder : VectorEpoxyHolder() { val titleView by bind(R.id.matrixItemTitle) val subtitleView by bind(R.id.matrixItemSubtitle) val avatarImageView by bind(R.id.matrixItemAvatar) + val avatarDecorationImageView by bind(R.id.matrixItemAvatarDecoration) } } diff --git a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileController.kt b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileController.kt index 5a18588daa..b98235b29a 100644 --- a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileController.kt +++ b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileController.kt @@ -79,11 +79,17 @@ class RoomMemberProfileController @Inject constructor( // Cross signing is enabled for this user if (state.userMXCrossSigningInfo.isTrusted()) { // User is trusted - val icon = if (state.allDevicesAreTrusted.invoke() == true) R.drawable.ic_shield_trusted - else R.drawable.ic_shield_warning + val icon = if (state.allDevicesAreTrusted) { + R.drawable.ic_shield_trusted + } else { + R.drawable.ic_shield_warning + } - val titleRes = if (state.allDevicesAreTrusted.invoke() == true) R.string.verification_profile_verified - else R.string.verification_profile_warning + val titleRes = if (state.allDevicesAreTrusted) { + R.string.verification_profile_verified + } else { + R.string.verification_profile_warning + } buildProfileAction( id = "learn_more", diff --git a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileFragment.kt b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileFragment.kt index 5a711f5cdb..cce105619a 100644 --- a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileFragment.kt @@ -20,6 +20,7 @@ package im.vector.riotx.features.roommemberprofile import android.os.Bundle import android.os.Parcelable import android.view.View +import androidx.core.view.isVisible import com.airbnb.mvrx.Fail import com.airbnb.mvrx.Incomplete import com.airbnb.mvrx.Success @@ -79,8 +80,13 @@ class RoomMemberProfileFragment @Inject constructor( memberProfileStateView.contentView = memberProfileInfoContainer matrixProfileRecyclerView.configureWith(roomMemberProfileController, hasFixedSize = true) roomMemberProfileController.callback = this - appBarStateChangeListener = MatrixItemAppBarStateChangeListener(headerView, listOf(matrixProfileToolbarAvatarImageView, - matrixProfileToolbarTitleView)) + appBarStateChangeListener = MatrixItemAppBarStateChangeListener(headerView, + listOf( + matrixProfileToolbarAvatarImageView, + matrixProfileToolbarTitleView, + matrixProfileDecorationToolbarAvatarImageView + ) + ) matrixProfileAppBarLayout.addOnOffsetChangedListener(appBarStateChangeListener) viewModel.observeViewEvents { when (it) { @@ -133,6 +139,37 @@ class RoomMemberProfileFragment @Inject constructor( matrixProfileToolbarTitleView.text = bestName avatarRenderer.render(userMatrixItem, memberProfileAvatarView) avatarRenderer.render(userMatrixItem, matrixProfileToolbarAvatarImageView) + + if (state.isRoomEncrypted) { + memberProfileDecorationImageView.isVisible = true + if (state.userMXCrossSigningInfo != null) { + // Cross signing is enabled for this user + val icon = if (state.userMXCrossSigningInfo.isTrusted()) { + // User is trusted + if (state.allDevicesAreCrossSignedTrusted) { + R.drawable.ic_shield_trusted + } else { + R.drawable.ic_shield_warning + } + } else { + R.drawable.ic_shield_black + } + + memberProfileDecorationImageView.setImageResource(icon) + matrixProfileDecorationToolbarAvatarImageView.setImageResource(icon) + } else { + // Legacy + if (state.allDevicesAreTrusted) { + memberProfileDecorationImageView.setImageResource(R.drawable.ic_shield_trusted) + matrixProfileDecorationToolbarAvatarImageView.setImageResource(R.drawable.ic_shield_trusted) + } else { + memberProfileDecorationImageView.setImageResource(R.drawable.ic_shield_warning) + matrixProfileDecorationToolbarAvatarImageView.setImageResource(R.drawable.ic_shield_warning) + } + } + } else { + memberProfileDecorationImageView.isVisible = false + } } } memberProfilePowerLevelView.setTextOrHide(state.userPowerLevelString()) diff --git a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt index f6fe353f29..1820262b49 100644 --- a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt @@ -104,10 +104,16 @@ class RoomMemberProfileViewModel @AssistedInject constructor(@Assisted private v session.rx().liveUserCryptoDevices(initialState.userId) .map { - it.fold(true, { prev, dev -> prev && dev.isVerified }) + Pair( + it.fold(true, { prev, dev -> prev && dev.isVerified }), + it.fold(true, { prev, dev -> prev && (dev.trustLevel?.crossSigningVerified == true) }) + ) } - .execute { - copy(allDevicesAreTrusted = it) + .execute { it -> + copy( + allDevicesAreTrusted = it()?.first == true, + allDevicesAreCrossSignedTrusted = it()?.second == true + ) } session.rx().liveCrossSigningInfo(initialState.userId) diff --git a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewState.kt b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewState.kt index b9044b1d36..a5c140d0ab 100644 --- a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewState.kt +++ b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewState.kt @@ -35,7 +35,8 @@ data class RoomMemberProfileViewState( val userPowerLevelString: Async = Uninitialized, val userMatrixItem: Async = Uninitialized, val userMXCrossSigningInfo: MXCrossSigningInfo? = null, - val allDevicesAreTrusted: Async = Uninitialized + val allDevicesAreTrusted: Boolean = false, + val allDevicesAreCrossSignedTrusted: Boolean = false ) : MvRxState { constructor(args: RoomMemberProfileArgs) : this(roomId = args.roomId, userId = args.userId) diff --git a/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMemberListController.kt b/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMemberListController.kt index 0d838e9c72..bd3dd06bd3 100644 --- a/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMemberListController.kt +++ b/vector/src/main/java/im/vector/riotx/features/roomprofile/members/RoomMemberListController.kt @@ -62,6 +62,7 @@ class RoomMemberListController @Inject constructor( id(roomMember.userId) matrixItem(roomMember.toMatrixItem()) avatarRenderer(avatarRenderer) + userEncryptionTrustLevel(roomMember.userEncryptionTrustLevel) clickListener { _ -> callback?.onRoomMemberClicked(roomMember) } diff --git a/vector/src/main/res/layout/item_profile_matrix_item.xml b/vector/src/main/res/layout/item_profile_matrix_item.xml index cdca2341e8..87f2f8de27 100644 --- a/vector/src/main/res/layout/item_profile_matrix_item.xml +++ b/vector/src/main/res/layout/item_profile_matrix_item.xml @@ -25,6 +25,16 @@ app:layout_constraintTop_toTopOf="parent" tools:src="@tools:sample/avatars" /> + + + + Date: Sat, 1 Feb 2020 11:45:45 +0100 Subject: [PATCH 07/16] Add startWith --- .../src/main/java/im/vector/matrix/rx/RxRoom.kt | 1 + .../src/main/java/im/vector/matrix/rx/RxSession.kt | 1 + 2 files changed, 2 insertions(+) diff --git a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt index 6ca0b55fd7..42720fcaa5 100644 --- a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt +++ b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt @@ -93,6 +93,7 @@ class RxRoom(private val room: Room, private val session: Session) { // TODO Do it only for room members of the room (switchMap) val cryptoDeviceInfoObservable = session.getLiveCryptoDeviceInfo().asObservable() + .startWith(emptyList()) return Observable .combineLatest, List, List>( diff --git a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt index cbe47472c4..0bddf8b685 100644 --- a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt +++ b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt @@ -42,6 +42,7 @@ class RxSession(private val session: Session) { .startWith(session.getRoomSummaries(queryParams)) val cryptoDeviceInfoObservable = session.getLiveCryptoDeviceInfo().asObservable() + .startWith(emptyList()) return Observable .combineLatest, List, List>( From 6ec2dd8c00ba2252cff5e4577c8f215ed3ea9a44 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Sat, 1 Feb 2020 12:12:40 +0100 Subject: [PATCH 08/16] Add startWith and logs --- .../src/main/java/im/vector/matrix/rx/RxRoom.kt | 11 +++++++++++ .../src/main/java/im/vector/matrix/rx/RxSession.kt | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt index 42720fcaa5..7779bd1a0e 100644 --- a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt +++ b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt @@ -34,6 +34,7 @@ import im.vector.matrix.android.internal.crypto.model.CryptoDeviceInfo import io.reactivex.Observable import io.reactivex.Single import io.reactivex.functions.BiFunction +import timber.log.Timber class RxRoom(private val room: Room, private val session: Session) { @@ -41,6 +42,7 @@ class RxRoom(private val room: Room, private val session: Session) { val summaryObservable = room.getRoomSummaryLive() .asObservable() .startWith(room.roomSummary().toOptional()) + .doOnNext { Timber.d("RX: summary emitted for: ${it.getOrNull()?.roomId}") } val memberIdsChangeObservable = summaryObservable .map { @@ -54,6 +56,7 @@ class RxRoom(private val room: Room, private val session: Session) { } }.orEmpty() }.distinctUntilChanged() + .doOnNext { Timber.d("RX: memberIds emitted. Size: ${it.size}") } // Observe the device info of the users in the room val cryptoDeviceInfoObservable = memberIdsChangeObservable @@ -64,7 +67,10 @@ class RxRoom(private val room: Room, private val session: Session) { // If any key change, emit the userIds list membersIds } + .startWith(membersIds) + .doOnNext { Timber.d("RX: CryptoDeviceInfo emitted. Size: ${it.size}") } } + .doOnNext { Timber.d("RX: cryptoDeviceInfo emitted 2. Size: ${it.size}") } val roomEncryptionTrustLevelObservable = cryptoDeviceInfoObservable .map { userIds -> @@ -74,6 +80,7 @@ class RxRoom(private val room: Room, private val session: Session) { session.getCrossSigningService().getTrustLevelForUsers(userIds).toOptional() } } + .doOnNext { Timber.d("RX: roomEncryptionTrustLevel emitted: ${it.getOrNull()?.name}") } return Observable .combineLatest, Optional, Optional>( @@ -85,15 +92,18 @@ class RxRoom(private val room: Room, private val session: Session) { ).toOptional() } ) + .doOnNext { Timber.d("RX: final room summary emitted for ${it.getOrNull()?.roomId}") } } fun liveRoomMembers(queryParams: RoomMemberQueryParams): Observable> { val roomMembersObservable = room.getRoomMembersLive(queryParams).asObservable() .startWith(room.getRoomMembers(queryParams)) + .doOnNext { Timber.d("RX: room members emitted. Size: ${it.size}") } // TODO Do it only for room members of the room (switchMap) val cryptoDeviceInfoObservable = session.getLiveCryptoDeviceInfo().asObservable() .startWith(emptyList()) + .doOnNext { Timber.d("RX: cryptoDeviceInfo emitted. Size: ${it.size}") } return Observable .combineLatest, List, List>( @@ -112,6 +122,7 @@ class RxRoom(private val room: Room, private val session: Session) { } } ) + .doOnNext { Timber.d("RX: final room members emitted. Size: ${it.size}") } } fun liveAnnotationSummary(eventId: String): Observable> { diff --git a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt index 0bddf8b685..705e8cf19f 100644 --- a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt +++ b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt @@ -34,15 +34,18 @@ import im.vector.matrix.android.internal.crypto.model.CryptoDeviceInfo import io.reactivex.Observable import io.reactivex.Single import io.reactivex.functions.BiFunction +import timber.log.Timber class RxSession(private val session: Session) { fun liveRoomSummaries(queryParams: RoomSummaryQueryParams): Observable> { val summariesObservable = session.getRoomSummariesLive(queryParams).asObservable() .startWith(session.getRoomSummaries(queryParams)) + .doOnNext { Timber.d("RX: summaries emitted: size: ${it.size}") } val cryptoDeviceInfoObservable = session.getLiveCryptoDeviceInfo().asObservable() .startWith(emptyList()) + .doOnNext { Timber.d("RX: crypto device info emitted: size: ${it.size}") } return Observable .combineLatest, List, List>( @@ -60,6 +63,7 @@ class RxSession(private val session: Session) { } } ) + .doOnNext { Timber.d("RX: final summaries emitted: size: ${it.size}") } } fun liveGroupSummaries(queryParams: GroupSummaryQueryParams): Observable> { From 53e36dca9ccbe48fd0a246d6270b53c667be80f3 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Sat, 1 Feb 2020 13:52:33 +0100 Subject: [PATCH 09/16] ZXing 3.3.3 because of https://github.com/zxing/zxing/issues/1170 --- vector/build.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vector/build.gradle b/vector/build.gradle index 2b0296c9d0..879bb0b984 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -369,7 +369,8 @@ dependencies { implementation "androidx.emoji:emoji-appcompat:1.0.0" // QR-code - implementation 'com.google.zxing:core:3.4.0' + // Stick to 3.3.3 because of https://github.com/zxing/zxing/issues/1170 + implementation 'com.google.zxing:core:3.3.3' implementation 'me.dm7.barcodescanner:zxing:1.9.13' // TESTS From 10094a212cebba7f0f3af3cf1d292fc99bd1add8 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Sat, 1 Feb 2020 13:59:28 +0100 Subject: [PATCH 10/16] ktlint --- .../src/main/java/im/vector/matrix/rx/RxSession.kt | 3 ++- .../vector/riotx/features/roomprofile/RoomProfileController.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt index 705e8cf19f..1f5ff9422c 100644 --- a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt +++ b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxSession.kt @@ -55,7 +55,8 @@ class RxSession(private val session: Session) { summaries.map { if (it.isEncrypted) { it.copy( - roomEncryptionTrustLevel = session.getCrossSigningService().getTrustLevelForUsers(it.otherMemberIds + listOf(session.myUserId)) + roomEncryptionTrustLevel = session.getCrossSigningService() + .getTrustLevelForUsers(it.otherMemberIds + session.myUserId) ) } else { it diff --git a/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileController.kt b/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileController.kt index 39886b24a2..dcc0e678d1 100644 --- a/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileController.kt +++ b/vector/src/main/java/im/vector/riotx/features/roomprofile/RoomProfileController.kt @@ -61,7 +61,7 @@ class RoomProfileController @Inject constructor( centered(false) text(stringProvider.getString(learnMoreSubtitle)) } - + // More buildProfileSection(stringProvider.getString(R.string.room_profile_section_more)) buildProfileAction( From 8f7b18239d7dcd830ffc8b9bf21ce2251e72efdc Mon Sep 17 00:00:00 2001 From: Valere Date: Sat, 1 Feb 2020 14:35:18 +0100 Subject: [PATCH 11/16] Warn on verify when private keys not known --- .../RoomMemberProfileAction.kt | 2 +- .../RoomMemberProfileFragment.kt | 20 ++++++++++++++++--- .../RoomMemberProfileViewModel.kt | 7 ++++++- vector/src/main/res/values/strings_riotX.xml | 2 ++ 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileAction.kt b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileAction.kt index 9122b180e8..5b890d1ef6 100644 --- a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileAction.kt +++ b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileAction.kt @@ -23,5 +23,5 @@ sealed class RoomMemberProfileAction : VectorViewModelAction { object RetryFetchingInfo: RoomMemberProfileAction() object IgnoreUser: RoomMemberProfileAction() - data class VerifyUser(val userId: String? = null, val roomId: String? = null): RoomMemberProfileAction() + data class VerifyUser(val userId: String? = null, val roomId: String? = null, val canCrossSign: Boolean? = true): RoomMemberProfileAction() } diff --git a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileFragment.kt b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileFragment.kt index cce105619a..e9ecbf78e3 100644 --- a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileFragment.kt @@ -20,6 +20,7 @@ package im.vector.riotx.features.roommemberprofile import android.os.Bundle import android.os.Parcelable import android.view.View +import androidx.appcompat.app.AlertDialog import androidx.core.view.isVisible import com.airbnb.mvrx.Fail import com.airbnb.mvrx.Incomplete @@ -100,9 +101,22 @@ class RoomMemberProfileFragment @Inject constructor( is Success -> { when (val action = async.invoke()) { is RoomMemberProfileAction.VerifyUser -> { - VerificationBottomSheet - .withArgs(roomId = null, otherUserId = action.userId!!) - .show(parentFragmentManager, "VERIF") + if (action.canCrossSign == true) { + VerificationBottomSheet + .withArgs(roomId = null, otherUserId = action.userId!!) + .show(parentFragmentManager, "VERIF") + } else { + AlertDialog.Builder(requireContext()) + .setTitle(R.string.dialog_title_warning) + .setMessage(R.string.verify_cannot_cross_sign) + .setPositiveButton(R.string.verification_profile_verify) { _, _ -> + VerificationBottomSheet + .withArgs(roomId = null, otherUserId = action.userId!!) + .show(parentFragmentManager, "VERIF") + } + .setNegativeButton(R.string.cancel, null) + .show() + } } } } diff --git a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt index 1820262b49..bbccab3913 100644 --- a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt @@ -149,7 +149,12 @@ class RoomMemberProfileViewModel @AssistedInject constructor(@Assisted private v if (!state.isMine && state.userMXCrossSigningInfo?.isTrusted() == false) { // ok, let's find or create the DM room _actionResultLiveData.postValue( - LiveEvent(Success(action.copy(userId = state.userId))) + LiveEvent(Success( + action.copy( + userId = state.userId, + canCrossSign = session.getCrossSigningService().canCrossSign() + ) + )) ) } } diff --git a/vector/src/main/res/values/strings_riotX.xml b/vector/src/main/res/values/strings_riotX.xml index bf6bcf40d3..d093f2b4d5 100644 --- a/vector/src/main/res/values/strings_riotX.xml +++ b/vector/src/main/res/values/strings_riotX.xml @@ -91,6 +91,8 @@ Unignore + This session is unable to share this verification with your other sessions.\nThe verification will be saved locally and shared in a future version of the app. + Recent rooms Other rooms From 9d6e7d7bd0b033258d1be83b4fec3ecedb881dde Mon Sep 17 00:00:00 2001 From: Valere Date: Sat, 1 Feb 2020 14:32:55 +0100 Subject: [PATCH 12/16] Learn more shows my devices when keys not trusted --- .../roommemberprofile/RoomMemberProfileController.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileController.kt b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileController.kt index b98235b29a..c77d575f01 100644 --- a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileController.kt +++ b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileController.kt @@ -112,6 +112,15 @@ class RoomMemberProfileController @Inject constructor( divider = false, action = { callback?.onTapVerify() } ) + } else { + buildProfileAction( + id = "learn_more", + title = stringProvider.getString(R.string.room_profile_section_security_learn_more), + dividerColor = dividerColor, + editable = false, + divider = false, + action = { callback?.onShowDeviceListNoCrossSigning() } + ) } genericFooterItem { From 2e0a84ccc941afb558a2bfb548adaacc49e19a8a Mon Sep 17 00:00:00 2001 From: Valere Date: Sat, 1 Feb 2020 15:03:00 +0100 Subject: [PATCH 13/16] display profile faster from known info --- .../RoomMemberProfileViewModel.kt | 46 +++++++++++-------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt index bbccab3913..b702bd5d94 100644 --- a/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/roommemberprofile/RoomMemberProfileViewModel.kt @@ -24,6 +24,7 @@ import com.airbnb.mvrx.Async import com.airbnb.mvrx.FragmentViewModelContext import com.airbnb.mvrx.MvRxViewModelFactory import com.airbnb.mvrx.Success +import com.airbnb.mvrx.Uninitialized import com.airbnb.mvrx.ViewModelContext import com.squareup.inject.assisted.Assisted import com.squareup.inject.assisted.AssistedInject @@ -85,7 +86,12 @@ class RoomMemberProfileViewModel @AssistedInject constructor(@Assisted private v } init { - setState { copy(isMine = session.myUserId == this.userId) } + setState { + copy( + isMine = session.myUserId == this.userId, + userMatrixItem = room?.getRoomMember(initialState.userId)?.toMatrixItem()?.let { Success(it) } ?: Uninitialized + ) + } observeIgnoredState() viewModelScope.launch(Dispatchers.Main) { // Do we have a room member for this id. @@ -101,26 +107,26 @@ class RoomMemberProfileViewModel @AssistedInject constructor(@Assisted private v observeRoomMemberSummary(room) observeRoomSummaryAndPowerLevels(room) } - - session.rx().liveUserCryptoDevices(initialState.userId) - .map { - Pair( - it.fold(true, { prev, dev -> prev && dev.isVerified }), - it.fold(true, { prev, dev -> prev && (dev.trustLevel?.crossSigningVerified == true) }) - ) - } - .execute { it -> - copy( - allDevicesAreTrusted = it()?.first == true, - allDevicesAreCrossSignedTrusted = it()?.second == true - ) - } - - session.rx().liveCrossSigningInfo(initialState.userId) - .execute { - copy(userMXCrossSigningInfo = it.invoke()?.getOrNull()) - } } + + session.rx().liveUserCryptoDevices(initialState.userId) + .map { + Pair( + it.fold(true, { prev, dev -> prev && dev.isVerified }), + it.fold(true, { prev, dev -> prev && (dev.trustLevel?.crossSigningVerified == true) }) + ) + } + .execute { it -> + copy( + allDevicesAreTrusted = it()?.first == true, + allDevicesAreCrossSignedTrusted = it()?.second == true + ) + } + + session.rx().liveCrossSigningInfo(initialState.userId) + .execute { + copy(userMXCrossSigningInfo = it.invoke()?.getOrNull()) + } } private fun observeIgnoredState() { From 6ee7ee14607a4f9e8fb3919fc42412569822ce6a Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Sat, 1 Feb 2020 15:04:22 +0100 Subject: [PATCH 14/16] Fix blink effect --- vector/src/main/res/layout/fragment_matrix_profile.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vector/src/main/res/layout/fragment_matrix_profile.xml b/vector/src/main/res/layout/fragment_matrix_profile.xml index c98e595c51..685b64fa86 100644 --- a/vector/src/main/res/layout/fragment_matrix_profile.xml +++ b/vector/src/main/res/layout/fragment_matrix_profile.xml @@ -63,9 +63,11 @@ android:id="@+id/matrixProfileDecorationToolbarAvatarImageView" android:layout_width="24dp" android:layout_height="24dp" + android:alpha="0" app:layout_constraintCircle="@+id/matrixProfileToolbarAvatarImageView" app:layout_constraintCircleAngle="135" app:layout_constraintCircleRadius="20dp" + tools:alpha="1" tools:ignore="MissingConstraints" tools:src="@drawable/ic_shield_trusted" /> From 282be29247794d2ba5151a20aa548e0bf0be35d3 Mon Sep 17 00:00:00 2001 From: Valere Date: Sat, 1 Feb 2020 15:19:37 +0100 Subject: [PATCH 15/16] temp shield for read only --- .../VectorSettingsSecurityPrivacyFragment.kt | 2 +- .../crosssigning/CrossSigningEpoxyController.kt | 2 +- vector/src/main/res/drawable/ic_shield_custom.xml | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 vector/src/main/res/drawable/ic_shield_custom.xml diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt index e688b6b68e..c30464ab77 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsSecurityPrivacyFragment.kt @@ -143,7 +143,7 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor( mCrossSigningStatePreference.setIcon(R.drawable.ic_shield_trusted) mCrossSigningStatePreference.summary = getString(R.string.encryption_information_dg_xsigning_complete) } else if (xSigningKeysAreTrusted) { - mCrossSigningStatePreference.setIcon(R.drawable.ic_shield_warning) + mCrossSigningStatePreference.setIcon(R.drawable.ic_shield_custom) mCrossSigningStatePreference.summary = getString(R.string.encryption_information_dg_xsigning_trusted) } else if (xSigningIsEnableInAccount) { mCrossSigningStatePreference.setIcon(R.drawable.ic_shield_black) diff --git a/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningEpoxyController.kt b/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningEpoxyController.kt index ccaa3d749d..681b6030bf 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningEpoxyController.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningEpoxyController.kt @@ -63,7 +63,7 @@ class CrossSigningEpoxyController @Inject constructor( } else if (data.xSigningKeysAreTrusted) { genericItem { id("trusted") - titleIconResourceId(R.drawable.ic_shield_warning) + titleIconResourceId(R.drawable.ic_shield_custom) title(stringProvider.getString(R.string.encryption_information_dg_xsigning_trusted)) } if (!data.isUploadingKeys) { diff --git a/vector/src/main/res/drawable/ic_shield_custom.xml b/vector/src/main/res/drawable/ic_shield_custom.xml new file mode 100644 index 0000000000..cb5e98c033 --- /dev/null +++ b/vector/src/main/res/drawable/ic_shield_custom.xml @@ -0,0 +1,14 @@ + + + From 26400e6372e0baae76384c32f1cff11f743a7bf4 Mon Sep 17 00:00:00 2001 From: Valere Date: Sat, 1 Feb 2020 15:19:49 +0100 Subject: [PATCH 16/16] Prompt before resetting keys --- .../settings/crosssigning/CrossSigningSettingsFragment.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningSettingsFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningSettingsFragment.kt index 0c2f8cdee6..84be3ade8a 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningSettingsFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/crosssigning/CrossSigningSettingsFragment.kt @@ -120,6 +120,12 @@ class CrossSigningSettingsFragment @Inject constructor( } override fun onResetCrossSigningKeys() { - viewModel.handle(CrossSigningAction.InitializeCrossSigning()) + AlertDialog.Builder(requireContext()) + .setTitle(R.string.dialog_title_confirmation) + .setMessage(R.string.are_you_sure) + .setPositiveButton(R.string.ok) { _, _ -> + viewModel.handle(CrossSigningAction.InitializeCrossSigning()) + } + .show() } }