element-hq / element-x-android

Android Matrix messenger application using the Matrix Rust Sdk and Jetpack Compose
GNU Affero General Public License v3.0
1k stars 136 forks source link

Tapping user mxid or room alias copies it to the clipboard #3502

Open frebib opened 1 week ago

frebib commented 1 week ago

Content

Make user id and room alias text in room/user view pages clickable and copy the text to the clipboard on click.

One small issue with this implementation is the snackbars don't appear until the view is closed.. not sure why, because I copy-pasted some other code that does the same thing and it works fine. Coroutines in Kotlin are ~shit~ weird. Suggestions welcome šŸ™šŸ»

Motivation and context

Fixes https://github.com/element-hq/element-x-android/issues/3496

(Do note that I have no idea what I'm doing.. I merely mimic what I see until it works)

Screenshots / GIFs

https://github.com/user-attachments/assets/50915a67-b92f-467d-8c1f-ec93fa00a83a

Tests

Finger touchy screeny

Tested devices

Checklist

github-actions[bot] commented 1 week ago

Thank you for your contribution! Here are a few things to check in the PR to ensure it's reviewed as quickly as possible:

codecov[bot] commented 5 days ago

Codecov Report

Attention: Patch coverage is 61.76471% with 13 lines in your changes missing coverage. Please review.

Project coverage is 82.64%. Comparing base (cc1cee8) to head (bf360d8).

Files with missing lines Patch % Lines
.../features/roomdetails/impl/RoomDetailsPresenter.kt 50.00% 1 Missing and 1 partial :warning:
...droid/features/roomdetails/impl/RoomDetailsView.kt 81.81% 2 Missing :warning:
...impl/members/details/RoomMemberDetailsPresenter.kt 60.00% 2 Missing :warning:
...ures/userprofile/impl/root/UserProfilePresenter.kt 60.00% 2 Missing :warning:
...roid/features/roomdetails/impl/RoomDetailsEvent.kt 0.00% 1 Missing :warning:
...d/features/roomdetails/impl/di/RoomMemberModule.kt 0.00% 1 Missing :warning:
.../features/userprofile/impl/di/UserProfileModule.kt 0.00% 1 Missing :warning:
...d/features/userprofile/shared/UserProfileEvents.kt 0.00% 1 Missing :warning:
...oid/features/userprofile/shared/UserProfileView.kt 50.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #3502 +/- ## =========================================== - Coverage 82.67% 82.64% -0.03% =========================================== Files 1731 1731 Lines 40867 40896 +29 Branches 4973 4978 +5 =========================================== + Hits 33785 33798 +13 - Misses 5317 5329 +12 - Partials 1765 1769 +4 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

bmarty commented 4 days ago

One small issue with this implementation is the snackbars don't appear until the view is closed.. not sure why, because I copy-pasted some other code that does the same thing and it works fine. Coroutines in Kotlin are ~shit~ weird. Suggestions welcome šŸ™šŸ»

You need the View where SnackBar may be rendered to have a SnackBarHost.

You can look for val snackbarHostState = rememberSnackbarHostState(snackbarMessage = state.snackbarMessage) in the code base and add the code to all the View which may have to render a Snackar. I know this is painful :).

frebib commented 4 days ago

Perfect, thanks Benoit. I'll give that a go in a few days and see how I get on