element-x-android
element-x-android copied to clipboard
Tapping user mxid or room alias copies it to the clipboard
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
- Step 1
- Step 2
- Step ...
Tested devices
- [x] 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
- [x] Pull request is based on the develop branch
- [x] Pull request title will be used in the release note, it clearly define what will change for the user
- [x] Pull request includes screenshots or videos if containing UI changes
- [x] Pull request includes a sign off
- [x] You've made a self review of your PR
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 screenshotsGH 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.
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 1875 commits behind head on develop.
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
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
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 :).
Perfect, thanks Benoit. I'll give that a go in a few days and see how I get on
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
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):
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
My guess would be either Pixel, or some modern Android version
I'm pretty sure this started on Android 13.
@frebib thanks for the update. I believe that this PR can be merged, but it needs to be updated first, to fix the conflict. We apologize for the delay on this and the extra needed work. Let me know if you need any help on this.
Replaced by #4549