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

[Reader Customization] Allow dragging to close Preferences bottom sheet #20640

Merged
merged 5 commits into from
Apr 23, 2024

Conversation

thomashorta
Copy link
Contributor

Improvement suggested by @notandyvee here: pcdRpT-6gD-p2#comment-9800

Allow dragging to hide and close the Reading Preferences bottom sheet, saving the latest user selection.

The main caveat is that dragging down conflicts with preview content scroll when the font is too large and/or the screen size is too small, which has the potential to be more annoying than dragging being disabled, so it would be great to have feedback from the Reviewers here and maybe merging this change and keeping an eye out for user complaints/reviews.

If anyone knows if there's some sort of way of providing some "scroll preference order" to the gesture system so it first scrolls the content and only scrolls the sheet when content is at the top, that would be ideal, but I couldn't find something like that. 😞


To Test:

  1. Open the Reader
  2. Open any post
  3. Go to Reading Preferences
  4. Change some preferences
  5. Drag down to close the Preferences sheet

Make sure to also test using large font sizes and trying to drag the preview content.

Note: It's possible to drag the content consistently if the user starts by dragging the finger UP before trying to drag it down.


Regression Notes

  1. Potential unintended areas of impact

    • Not saving properly the Reading Preferences
    • Not sending the correct analytics events
  2. What I did to test those areas of impact (or what existing automated tests I relied on)

    • Manual testing
    • Unit Testing
  3. What automated tests I added (or what prevented me from doing so)

    • Unit tests for the new scenarios

PR Submission Checklist:

  • I have completed the Regression Notes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Testing Checklist (strike-out the not-applying and unnecessary ones):

N/A

  • WordPress.com sites and self-hosted Jetpack sites.
  • Portrait and landscape orientations.
  • Light and dark modes.
  • Fonts: Larger, smaller and bold text.
  • High contrast.
  • Talkback.
  • Languages with large words or with letters/accents not frequently used in English.
  • Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
  • Large and small screen sizes. (Tablet and smaller phones)
  • Multi-tasking: Split screen and Pop-up view. (Android 10 or higher)

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Apr 15, 2024

Jetpack📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack Jetpack
FlavorJalapeno
Build TypeDebug
Versionpr20640-18a893e
Commit18a893e
Direct Downloadjetpack-prototype-build-pr20640-18a893e.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Apr 15, 2024

WordPress📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress WordPress
FlavorJalapeno
Build TypeDebug
Versionpr20640-18a893e
Commit18a893e
Direct Downloadwordpress-prototype-build-pr20640-18a893e.apk
Note: Google Login is not supported on these builds.

Copy link

codecov bot commented Apr 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 40.49%. Comparing base (42220a6) to head (18a893e).
Report is 166 commits behind head on trunk.

Additional details and impacted files
@@           Coverage Diff           @@
##            trunk   #20640   +/-   ##
=======================================
  Coverage   40.48%   40.49%           
=======================================
  Files        1479     1479           
  Lines       68342    68349    +7     
  Branches    11290    11290           
=======================================
+ Hits        27669    27676    +7     
  Misses      38173    38173           
  Partials     2500     2500           

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

@osullivanchris
Copy link

I installed the build to test this but I cant see the behaviour, sorry. In theory scrolling to close screens is something I'm generally in favour of. Though I am interested in how it affects or doesn't the presentation of the screen. Should a screen come from above rather than from the left if it can be dragged down. And similarly should it have an X icon like a modal view rather than a back arrow.

@thomashorta
Copy link
Contributor Author

I installed the build to test this but I cant see the behaviour, sorry.

Could you share the device and Android version you tried? I used an emulator with Android 14 while developing and it works as expected.

reader-customization-draggable.mp4

@osullivanchris
Copy link

  • Jetpack Pre-Alpha vpr2051-4cd9168 (1418)
  • Pixel 6
  • Android version 14

Looks pretty good in the video. To add to my other question, I wonder should we be doing this in many places, not just one

Copy link
Contributor

@notandyvee notandyvee left a comment

Choose a reason for hiding this comment

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

Overall, great job. Don't have much to say other than to utilize kotlin styling a bit more and remove some curlies. But I guess you can argue its a nit 😅 .

The main caveat is that dragging down conflicts with preview content scroll when the font is too large and/or the screen size is too small, which has the potential to be more annoying than dragging being disabled, so it would be great to have feedback from the Reviewers here and maybe merging this change and keeping an eye out for user complaints/reviews.

I'm familiar with the general problem. Never used compose though. So took the opportunity to test and play around with it. In ReadingPreferenceScreen, the very first Column, add

    Column(
        modifier = Modifier.fillMaxSize().nestedScroll(rememberNestedScrollInteropConnection()),

This nestedScroll will tell the bottom sheet's coordinatorlayout to work with nested scrollable containers. Works for me. I can't guarantee this is the best approach though since I havent dealt with compose much yet. Hopefully this helps.

* The bottom sheet has been hidden by the user, which means the dismiss process is already on its way. All we need
* to do is save the current preferences.
*/
fun onBottomSheetHidden() {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can remove the function curly braces = launch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not a big fan of that approach since doing that causes the function to return a Job, which is not really what I'm going for and it would be just a side-effect of trying to make the code look prettier.

I get that using = launch is kinda common practice. Still, I personally think that the function signature should better match the intention of the code, so if no callers need the returned Job (and they shouldn't as this function is public and the coroutine is an implementation detail relevant to the ViewModel only) I prefer "returning" Unit.

* An exit action has been triggered by the user. This means that we need to save the current preferences and emit
* the close event, so the dialog is dismissed.
*/
fun onExitActionClick() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto here. Just to save some curly braces.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same reasoning for not returning Job here.

@thomashorta
Copy link
Contributor Author

This nestedScroll will tell the bottom sheet's coordinatorlayout to work with nested scrollable containers. Works for me. I can't guarantee this is the best approach though since I havent dealt with compose much yet. Hopefully this helps.

Nice! I will try it and apply the other suggestion you commented and push the changes soon! Thanks for the Review!

Copy link

sonarcloud bot commented Apr 22, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@thomashorta
Copy link
Contributor Author

thomashorta commented Apr 22, 2024

Jetpack Pre-Alpha vpr2051-4cd9168 (1418)

@osullivanchris this looks to be the problem. You are not using the build generated by this PR (which should have pr20640 in the filename). A second confirmation is that the version you're using is based on 1418 while the version in this PR is based on 1421.

Download and install the build for this PR here: #20640 (comment)

I suggest waiting a few minutes though since I just pushed the changes fixing the nested scroll that @notandyvee suggested (thanks again btw!), so a new build should be up soon.

Copy link
Contributor

@notandyvee notandyvee left a comment

Choose a reason for hiding this comment

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

Re-reviewed and it works great! Thanks for making that change 🍕

@thomashorta thomashorta merged commit c90f31b into trunk Apr 23, 2024
20 checks passed
@thomashorta thomashorta deleted the feature/reader-customization-draggable-sheet branch April 23, 2024 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants