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

Enhance Invite Section with Copy Functionality for LAO Details #1797

Merged
merged 7 commits into from
Apr 6, 2024

Conversation

Kaz-ookid
Copy link
Contributor

@Kaz-ookid Kaz-ookid commented Apr 3, 2024

Description

This pull request addresses issue #1793 by introducing a copy button next to the LAO ID and server address within the invite section. Additionally, the LAO ID and server address fields have been made selectable for manual copying.

Changes

  • Added copy buttons for the LAO ID and server address.
  • Enabled text selection on the LAO ID and server address TextViews for manual copying.

Impact

  • Enhances user experience by simplifying the sharing process of LAO information.
  • Facilitates quick sharing without the need to manually type the details.

image

@Kaz-ookid Kaz-ookid added enhancement New feature or request fe2-android labels Apr 3, 2024
@Kaz-ookid Kaz-ookid self-assigned this Apr 3, 2024
Copy link

github-actions bot commented Apr 3, 2024

Pull reviewers stats

Stats of the last 30 days for popstellar:

User Total reviews Time to review Total comments
MariemBaccari
🥇
3
▀▀▀
12d 5m
▀▀▀
2
▀▀▀
Tyratox
🥈
1
3d 10h 1m
3
▀▀▀▀
1florentin
🥉
1
6d 20h 7m
▀▀
0
sgueissa
1
15d 23h 37m
▀▀▀▀
0
ljankoschek
1
7h 42m
0
matteosz
1
4d 6h 41m
1
Kaz-ookid
1
2d 5h 33m
1
⚡️ Pull request stats

@Kaz-ookid Kaz-ookid linked an issue Apr 3, 2024 that may be closed by this pull request
Copy link
Contributor

@matteosz matteosz left a comment

Choose a reason for hiding this comment

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

Good job! Just few comments.

General suggestion: whenever you're modifying the UI (either layout or button behaviour) it would be nice to add to the PR description screenshots or screen recordings. That would help who's reviewing the PR as they wouldn't need to pull the code and run it to see the changes.
[EDIT: While I was reviewing it you actually anticipated my comment and added a screenshot, I'd call that telepathy :) )

Comment on lines 66 to 67
setupCopyServerButton(binding)
setupCopyIdentifierButton(binding)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd save the binding as a class attribute to avoid passing it around (it's just a preference but also how it's usually done in the codebase)

private fun copyTextToClipboard(token: String) {
val clipboard =
requireActivity().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
val clip = ClipData.newPlainText(token, token)
Copy link
Contributor

Choose a reason for hiding this comment

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

Here reading the doc the first param should be the text label that you're copying. So instead of reusing the token as its own label, I'd put an actual label that explains what has been copied (not its content)

Copy link
Contributor Author

@Kaz-ookid Kaz-ookid Apr 4, 2024

Choose a reason for hiding this comment

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

yes that's what I did first, but then I saw line 100 in TokenFragment.kt and went to do the same. Maybe I just should have trusted my critical sense 🤷‍♀️

And I should have changed the argument name, because "token" is not accurate at all

Also, this just makes code duplication through different fragments. Maybe we should put the copyTextToClipboard function somewhere to be used by multiple fragments?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes in an utils file would be perfect

Comment on lines 82 to 102
private fun setupCopyServerButton(binding: InviteFragmentBinding) {
val serverTextView = binding.laoPropertiesServerText
val copyButton = binding.copyServerButton

copyButton.setOnClickListener {
val text = serverTextView.text.toString()
copyTextToClipboard(text)
Toast.makeText(requireContext(), R.string.successful_copy, Toast.LENGTH_SHORT).show()
}
}

private fun setupCopyIdentifierButton(binding: InviteFragmentBinding) {
val identifierTextView = binding.laoPropertiesIdentifierText
val copyButton = binding.copyIdentifierButton

copyButton.setOnClickListener {
val text = identifierTextView.text.toString()
copyTextToClipboard(text)
Toast.makeText(requireContext(), R.string.successful_copy, Toast.LENGTH_SHORT).show()
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Refactoring opportunity: these 2 methods are almost the same, so you can extract a single method, which is more generic, and parametrise its usage to reduce code duplication

@Kaz-ookid Kaz-ookid marked this pull request as ready for review April 4, 2024 15:52
@Kaz-ookid Kaz-ookid requested a review from a team as a code owner April 4, 2024 15:52
Copy link

sonarcloud bot commented Apr 5, 2024

Quality Gate Passed Quality Gate passed for 'PoP - PoPCHA-Web-Client'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

sonarcloud bot commented Apr 5, 2024

Quality Gate Passed Quality Gate passed for 'PoP - Be1-Go'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

sonarcloud bot commented Apr 5, 2024

Quality Gate Passed Quality Gate passed for 'PoP - Be2-Scala'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

sonarcloud bot commented Apr 5, 2024

Quality Gate Passed Quality Gate passed for 'PoP - Fe1-Web'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link

sonarcloud bot commented Apr 5, 2024

Copy link
Contributor

@matteosz matteosz left a comment

Choose a reason for hiding this comment

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

LGTM! Really good job

@Kaz-ookid Kaz-ookid merged commit bdeeb02 into master Apr 6, 2024
18 checks passed
@Kaz-ookid Kaz-ookid deleted the work-fe2-maxime-lao-id-copy-to-clip-board branch April 6, 2024 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fe2-android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable copying of LAO's ID and Server in Invite section
2 participants