fix: widen snackbars on tablets - #4985
ibrahim-iqbal wants to merge 5 commits into
Conversation
|
Hi @ibrahim-iqbal! Thanks for opening this PR! 🙌🏻 I'll start with the CR as soon as possible. Stay tuned! |
joragua
left a comment
There was a problem hiding this comment.
Hi @ibrahim-iqbal! 💯 Nice job! The first CR round is here:
- We use to have one commit for calens entry (
chore: add calens file) in each PR. Could you split the commit of this PR in two different ones? Thanks in advance!
Let us know if you have any doubts and we will be happy to help you! 😄
a26f43d to
10c2429
Compare
|
Pushed
|
There was a problem hiding this comment.
More comments here @ibrahim-iqbal:
-
Add a blank line at the end of the calens file and
SnackbarExt.kt. Otherwise, CI will fail because Detekt will not accept the code (as you can see in the CI checks) -
Every commit must be GPG/PGP signed and include a
Signed-off-byline. Use the command:git commit -s -S -m "..."for that. Unfortunately, we won't be able to merge the PR until all commits are properly signed.
Thanks for the effort! 🙌🏻
10c2429 to
b9374a1
Compare
|
Hey @joragua! 👋 Thanks for the thorough reviews — really appreciate the guidance! All feedback from both rounds is now addressed: Round 1:
Round 2:
Let me know if anything else needs tweaking! 🚀 |
joragua
left a comment
There was a problem hiding this comment.
Just one comment and we are ready for QA!
There are two snackbars (one in TransferListFragment and another one in BaseActivity) that don't use the applyResponsiveWitdh method. Is there any reason for that, or were they just forgotten? 🤔
|
Good catch @joragua! They were indeed forgotten. Pushed
All snackbar call sites in the codebase should now go through the responsive width helper. Let me know if anything else needs tweaking! |
|
Correction on my last comment: I said |
joragua
left a comment
There was a problem hiding this comment.
LGTM! Thanks for the effort @ibrahim-iqbal! Let's move it to QA 🚀
|
One question about the suggested fix, @ibrahim-iqbal In tablets, i noticed the snackbar length is static in both orientations. That means, in portrait the snackbar takes ~80% of the screen width, but in landscape takes ~50% (it really improves the previous behaviour 🚀 ). The point: is making the snackbar length adaptative to the screen width depending orientation something feasible? so, in landscape, we'll take even more advantage of the screen width for longer messages. What do you think? |
|
Good observation @jesmrec! You're right — the current implementation uses a fixed Making it orientation-adaptive is definitely feasible. The simplest approach would be to check the current orientation and apply a different max-width factor:
I can push that change to this PR — would you prefer a fixed dp value for landscape, or a percentage-based approach? Percentage would adapt better across different tablet sizes, but a fixed value keeps it simpler and more predictable. |
|
@ibrahim-iqbal i'd say to go to the percentage approach |
|
Done — switched to percentage-based width in |
|
@ibrahim-iqbal unfortunately, your fix in
don't you see the same? thanks in advance |
|
Thanks for testing @jesmrec — the issue was that Material's Fixed in |
joragua
left a comment
There was a problem hiding this comment.
Just one comment after your changes @ibrahim-iqbal
Calens file must be updated with the new implementation. Do not forget that we use to have only one commit for the calens in each PR. So, you can do an interactive rebase in the PR, modified the content and add a new commit chore: add calens file.
Thanks for your effort! 💪🏻 Let us know if you have any doubts
| Snackbar width has been expanded to fill the parent on tablets with a | ||
| smallest-width of at least 600dp, so tablet users see a full-width snackbar | ||
| instead of the narrow Material default. |
There was a problem hiding this comment.
| Snackbar width has been expanded to fill the parent on tablets with a | |
| smallest-width of at least 600dp, so tablet users see a full-width snackbar | |
| instead of the narrow Material default. | |
| Snackbar width has been expanded to 80% on tablets with a | |
| smallest-width of at least 600dp, so tablet users see a larger snackbar | |
| instead of the narrow Material default. |
Signed-off-by: ibrahim-iqbal <ibrahim-iqbal@users.noreply.github.com>
Signed-off-by: ibrahim-iqbal <ibrahim-iqbal@users.noreply.github.com>
…Fragment These two call sites were missed in the original sweep. A fix for them was written and comment-claimed as pushed in 00bfb0b, but that commit landed on a different fork (ibrahim-iqbal/android) than the one this PR is served from, so it never actually reached this branch. Applying the same change here for real. Signed-off-by: ibrahim-iqbal <ibrahim-iqbal@users.noreply.github.com>
Use 80% of current screen width for tablet snackbars so the width adapts to orientation changes, filling ~80% in both portrait and landscape instead of a fixed 600dp that looks different in each. Signed-off-by: ibrahim-iqbal <ibrahim-iqbal@users.noreply.github.com>
Material's design_snackbar_max_width is 576dp on sw600dp devices, which clamps the LayoutParams width set by applyResponsiveWidth(). Override it to -1px so the percentage-based width takes effect in both portrait and landscape orientations. Signed-off-by: ibrahim-iqbal <ibrahim-iqbal@users.noreply.github.com>
a479408 to
7896465
Compare
|
Updated the calens file with the suggested description in |

Related Issues
App: closes #4921
Snackbars used the Material default width on tablets, so they only occupied a narrow band in the middle of the screen and left most of the row empty. This ports the phone-like behaviour to tablets: at a smallest-width of at least 600dp — the same qualifier the existing
layout-sw600dpfolder targets — the snackbar view expands to fill the parent, so a device the size of the Galaxy Tab A8 in the original report gets a snackbar that spans the row.Changes
New helper
owncloudApp/src/main/java/com/owncloud/android/extensions/SnackbarExt.kt:Snackbar.applyResponsiveWidth()readsresources.configuration.smallestScreenWidthDpand, on tablet-sized devices (>= 600dp), sets the snackbar view's layout width toMATCH_PARENT. Below the threshold it returns the snackbar unchanged, so phones keep the current Material width.ActivityExt.ktandFragmentExt.kt: the four helpers (showMessageInSnackbar,showSnackbarWithActionon bothActivityandFragment) chainapplyResponsiveWidth()beforeshow().Inline
Snackbar.make(...)sites that bypass the helpers:FileDisplayActivity.kt:1411,PreviewImageFragment.kt:251/257,PreviewAudioFragment.kt:308/314,PreviewTextFragment.kt:173/181,PreviewVideoActivity.kt:414/422. All now chain the same helper so no snackbar in the app is narrow on a tablet.Changelog file at
changelog/unreleased/4921(Bugfix:type).Release Notes in
ReleaseNotesViewModel.kt— not added, this is a UI polish fix rather than a headline feature; happy to add one if you'd prefer.QA
./gradlew :owncloudApp:compileOriginalDebugKotlin→ BUILD SUCCESSFUL../gradlew :owncloudApp:ktlintCheck— no new violations in the changed files; pre-existing ktlint violations elsewhere onmasterare unchanged.applyResponsiveWidth()returns early and the snackbar keeps its Material default layout params.PreviewImageFragment) on a sw600dp+ tablet (Galaxy Tab A8 in the original report) and confirm the snackbar now spans the row. A phone (< 600dp) should look identical to today.