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

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

frebib
Copy link
Contributor

@frebib frebib commented Sep 19, 2024

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 #3496

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

Screenshots / GIFs

8d8853b8-dcc0-4a9d-9d9b-083791d765db.mp4

Tests

Finger touchy screeny

  • Step 1
  • Step 2
  • Step ...

Tested devices

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

Checklist

  • Changes have been tested on an Android device or Android emulator with API 23
  • 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
  • Pull request includes a sign off
  • You've made a self review of your PR

@frebib frebib requested a review from a team as a code owner September 19, 2024 22:54
@frebib frebib requested review from bmarty and removed request for a team September 19, 2024 22:54
Copy link
Contributor

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

  • Your branch should be based on origin/develop, at least when it was created.
  • The title of the PR will be used for release notes, so it needs to describe the change visible to the user.
  • The test pass locally running ./gradlew test.
  • The code quality check suite pass locally running ./gradlew runQualityChecks.
  • If you modified anything related to the UI, including previews, you'll have to run the Record screenshots GH action in your forked repo: that will generate compatible new screenshots. However, given Github Actions limitations, it will prevent the CI from running temporarily, until you upload a new commit after that one. To do so, just pull the latest changes and push an empty commit.

@frebib frebib force-pushed the feat/copy-user-room-id branch 4 times, most recently from 21a9c39 to bf360d8 Compare September 24, 2024 00:42
Copy link

codecov bot commented Sep 24, 2024

Codecov Report

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

Project coverage is 82.66%. Comparing base (249104b) to head (c88465c).
Report is 364 commits behind head on develop.

Files with missing lines Patch % Lines
.../features/roomdetails/impl/RoomDetailsPresenter.kt 66.66% 1 Missing and 1 partial ⚠️
...droid/features/roomdetails/impl/RoomDetailsView.kt 84.61% 2 Missing ⚠️
...impl/members/details/RoomMemberDetailsPresenter.kt 75.00% 2 Missing ⚠️
...ures/userprofile/impl/root/UserProfilePresenter.kt 75.00% 2 Missing ⚠️
...roid/features/roomdetails/impl/RoomDetailsEvent.kt 0.00% 1 Missing ⚠️
...d/features/roomdetails/impl/di/RoomMemberModule.kt 0.00% 1 Missing ⚠️
.../features/userprofile/impl/di/UserProfileModule.kt 0.00% 1 Missing ⚠️
...d/features/userprofile/shared/UserProfileEvents.kt 0.00% 1 Missing ⚠️
...oid/features/userprofile/shared/UserProfileView.kt 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3502      +/-   ##
===========================================
- Coverage    82.68%   82.66%   -0.03%     
===========================================
  Files         1732     1732              
  Lines        40982    41022      +40     
  Branches      4966     4972       +6     
===========================================
+ Hits         33886    33910      +24     
- Misses        5341     5354      +13     
- Partials      1755     1758       +3     

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

@bmarty
Copy link
Member

bmarty commented Sep 24, 2024

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
Copy link
Contributor Author

frebib commented Sep 24, 2024

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

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

Fixes element-hq#3496

Signed-off-by: Joe Groocock <me@frebib.net>
@frebib
Copy link
Contributor Author

frebib commented Sep 30, 2024

Snackbars are fixed, thanks!
As per the contributing guidelines, I'll still need to add translations to localazy for the snackbar message. I appreciate that this doesn't have a design, but perhaps we could agree on wording for that message? I've currently just copied what Element Android used, which is simply Copied to clipboard. Once we're agreed, I'll go ahead and work out how to submit that.
I should probably take a stab at trying to add some presenter tests for this new functionality at some point too

@@ -130,6 +130,7 @@
<string name="common_call_invite">"Call in progress (unsupported)"</string>
<string name="common_call_started">"Call started"</string>
<string name="common_chat_backup">"Chat backup"</string>
<string name="common_copied_to_clipboard">"Copied to clipboard"</string>
Copy link
Member

Choose a reason for hiding this comment

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

I have added the string to Localazy at https://localazy.com/p/element/source-language/_a7211042194211892347. (there is no action required from you since the key is the same).

@bmarty
Copy link
Member

bmarty commented Oct 1, 2024

Thanks for the update. I am wondering if the Snackbar interferes too much with the System clipboard alert (but I did not test the code yet):

image

@frebib
Copy link
Contributor Author

frebib commented Oct 1, 2024

I am wondering if the Snackbar interferes too much with the System clipboard alert

Yeah I thought about this too. I'm not sure which subset of Android this little pop-up applies to. My guess would be either Pixel, or some modern Android version. There are likely some devices that don't have this and on those the snackbar would be useful?

There are other places in the app that also use this snackbar popup when copying to the clipboard. I've added it here for consistency, but I'd be happy to remove it (It'll greatly simplify the patch) if the decision is taken to remove them from other places in the app too. I'm not sure what iOS does

@jmartinesp
Copy link
Member

My guess would be either Pixel, or some modern Android version

I'm pretty sure this started on Android 13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In the user profile screen, touching the mxid should copy it to clipboard
3 participants