Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user verification and verification state violation badges #4392

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from

Conversation

jmartinesp
Copy link
Member

@jmartinesp jmartinesp commented Mar 11, 2025

Content

  • Move observerRoomMemberIdentityStateChanges and associated classes from MessageComposer to :libraries:matrixui so we can reuse it in several places.
  • Add user verified badge to the top app bar of a DM room.
  • Add verification violation badge in the 'People' list item in the room details screen.
  • Add verified and violation badge to the 'Profile' list item in the DM details screen.
  • Add both badges to the room member list too.
  • Display verification state only for room member details screen, not in general user profile ones. Also, update this info in real time and make sure we can withdraw the verification state of a user with a verification violation state in this screen.

Motivation and context

Closes #4240

Screenshots / GIFs

There are quite a few in the PR.

Tests

Just test the changes mentioned above, if possible.

Tested devices

  • Physical
  • Emulator
  • OS version(s): 14

Checklist

  • Changes have been tested on an Android device or Android emulator with API 24
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • You've made a self review of your PR

@jmartinesp jmartinesp added the PR-Feature For a new feature label Mar 11, 2025
@github-actions github-actions bot added the Z-Community-PR Issue is solved by a community member's PR label Mar 11, 2025
Copy link
Contributor

github-actions bot commented Mar 11, 2025

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/ktZfED

Copy link

codecov bot commented Mar 11, 2025

Codecov Report

Attention: Patch coverage is 88.15166% with 25 lines in your changes missing coverage. Please review.

Project coverage is 80.12%. Comparing base (1cc95f2) to head (8077e8f).
Report is 14 commits behind head on develop.

Files with missing lines Patch % Lines
...es/matrix/impl/encryption/RustEncryptionService.kt 0.00% 12 Missing ⚠️
...impl/members/details/RoomMemberDetailsPresenter.kt 77.77% 2 Missing and 2 partials ⚠️
...oomdetails/impl/members/RoomMemberListPresenter.kt 57.14% 2 Missing and 1 partial ⚠️
...ndroid/features/messages/impl/MessagesPresenter.kt 85.71% 0 Missing and 1 partial ⚠️
...ent/android/features/messages/impl/MessagesView.kt 95.23% 0 Missing and 1 partial ⚠️
...d/features/roomdetails/impl/di/RoomMemberModule.kt 0.00% 1 Missing ⚠️
...res/roomdetails/impl/members/RoomMemberListView.kt 96.42% 0 Missing and 1 partial ⚠️
...ures/userprofile/impl/root/UserProfilePresenter.kt 50.00% 1 Missing ⚠️
...ix/ui/room/ObserveRoomMemberIdentityStateChange.kt 93.75% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           develop    #4392    +/-   ##
=========================================
  Coverage    80.12%   80.12%            
=========================================
  Files         2064     2063     -1     
  Lines        54998    55127   +129     
  Branches      6742     6757    +15     
=========================================
+ Hits         44065    44171   +106     
- Misses        8631     8645    +14     
- Partials      2302     2311     +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jmartinesp jmartinesp removed the Z-Community-PR Issue is solved by a community member's PR label Mar 11, 2025
@jmartinesp jmartinesp marked this pull request as ready for review March 11, 2025 12:03
@jmartinesp jmartinesp requested a review from a team as a code owner March 11, 2025 12:03
@jmartinesp jmartinesp requested review from bmarty and removed request for a team March 11, 2025 12:03
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, thanks!
I have some first remarks. I have not tested the PR yet.

var dmUserVerificationState by remember { mutableStateOf<IdentityState?>(null) }

LifecycleResumeEffect(Unit) {
if (room.isDm && room.isEncrypted) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use room.isDm and room.isEncrypted as keys of LifecycleResumeEffect?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think those can't change, but maybe I should use the RoomInfo.isDm and RoomInfo.isEncrypted instead (once the 2nd one is available) 🤔 .

LifecycleResumeEffect(Unit) {
if (room.isDm && room.isEncrypted) {
localCoroutineScope.launch {
val dmUserId = room.getMembers().getOrNull()?.find { it.userId != room.sessionId }?.userId
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if getMembers will always returns the whole member list. Maybe for DM this is OK.

Else you may want to use

val membersState by room.membersStateFlow.collectAsState()
val otherMember = room.getDirectRoomMember(membersState)

instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right, I just noticed the warning in its docs:

Get the members of the room. Note: generally this should not be used, please use [membersStateFlow] and [updateMembers] instead.

@@ -188,6 +190,7 @@ fun MessagesView(
roomAvatar = state.roomAvatar.dataOrNull(),
heroes = state.heroes,
roomCallState = state.roomCallState,
isDmUserVerified = state.dmUserVerificationState == IdentityState.Verified,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not confortable with this comparison because isDmUserVerified will be false when the room is not a DM. If later we decide to render something else when this is a DM and the other user is not verified, we will have some trouble.

Since dmUserVerificationState is nullable, can you change this to

Suggested change
isDmUserVerified = state.dmUserVerificationState == IdentityState.Verified,
isDmUserVerified = state.dmUserVerificationState?.let { it == IdentityState.Verified },

isDmUserVerified will need to be nullable as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I mean if it's not a DM for sure the DM user is not verified (since there isn't one 😅 ) but maybe with the null value it'll be clearer.


if (isDmUserVerified) {
Icon(imageVector = CompoundIcons.Verified(), tint = ElementTheme.colors.iconSuccessPrimary, contentDescription = null)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This icon will not be visible if the room name is too long:

image

Or its size will be reduced.

image

): T {
currentComposer.startProvider(LocalLifecycleOwner provides lifecycleOwner)
val state = block()
currentComposer.endProviders()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
currentComposer.endProviders()
currentComposer.endProvider()

Seems to be more appropriate. endProviders() has to be used when startProviders() has been called. This is probably equivalent though.

style = ElementTheme.typography.fontBodySmRegular,
color = ElementTheme.colors.textSecondary,
)
trailingContent = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not new, but I think we will need to add some padding at the start of the trailing content:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Feature For a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task] User verification state indicators
3 participants