Skip to content

fix: widen snackbars on tablets (#4921) - #4985

Open
ibrahim-iqbal wants to merge 1 commit into
owncloud:masterfrom
ibrahim-iqbal:fix/short-snackbar-tablet-4921
Open

ibrahim-iqbal wants to merge 1 commit into
owncloud:masterfrom
ibrahim-iqbal:fix/short-snackbar-tablet-4921

Conversation

@ibrahim-iqbal

Copy link
Copy Markdown

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-sw600dp folder 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() reads resources.configuration.smallestScreenWidthDp and, on tablet-sized devices (>= 600dp), sets the snackbar view's layout width to MATCH_PARENT. Below the threshold it returns the snackbar unchanged, so phones keep the current Material width.

  • ActivityExt.kt and FragmentExt.kt: the four helpers (showMessageInSnackbar, showSnackbarWithAction on both Activity and Fragment) chain applyResponsiveWidth() before show().

  • 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

  • Local:
    • ./gradlew :owncloudApp:compileOriginalDebugKotlin → BUILD SUCCESSFUL.
    • ./gradlew :owncloudApp:ktlintCheck — no new violations in the changed files; pre-existing ktlint violations elsewhere on master are unchanged.
    • No behaviour change on devices below 600dp smallestScreenWidthDp: applyResponsiveWidth() returns early and the snackbar keeps its Material default layout params.
  • Manual check to run on-device before merge: trigger any snackbar (e.g. set/unset a file as available offline in 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.

Snackbars used the Material default width on tablets, so they only
occupied a narrow band in the middle of the screen and left the rest of
the row empty. Add a small extension, applyResponsiveWidth, that
expands the snackbar view to match the parent width when the device
reports a smallest-width of at least 600dp, matching the sw600dp
qualifier the layouts already use. Apply it in the four snackbar helpers
in ActivityExt and FragmentExt, and in the inline Snackbar.make sites in
FileDisplayActivity, PreviewImageFragment, PreviewAudioFragment,
PreviewTextFragment, and PreviewVideoActivity so every snackbar in the
app benefits.

Phones and other devices below the 600dp threshold keep the current
Material width.

Signed-off-by: ibrahim-iqbal <ibrahim-iqbal@users.noreply.github.com>
@ibrahim-iqbal
ibrahim-iqbal requested a review from a team as a code owner September 19, 2026 11:16
@CLAassistant

CLAassistant commented Sep 19, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@joragua

joragua commented Sep 21, 2026

Copy link
Copy Markdown
Member

Hi @ibrahim-iqbal! Thanks for opening this PR! 🙌🏻

I'll start with the CR as soon as possible. Stay tuned!

@joragua joragua left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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! 😄

Comment thread changelog/unreleased/4921
Comment on lines +1 to +9
Bugfix: Widen snackbars on tablets

Snackbars used the Material default width on tablets, so they only occupied a
narrow band in the middle of the screen and left the rest of the row empty.
The width now expands to fill the parent when the device reports a
smallest-width of at least 600dp, so tablet users see a snackbar that spans
the row like it does on phones.

https://github.com/owncloud/android/issues/4921

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please, read the TEMPLATE.md file and apply the guidelines here

  • Description must be written in present perfect passive tense
  • The name of the file must be the PR ID, in this case 4985
  • The link of the PR must be added at the end of the file, just below the issue link

NOTE: Do not create a new commit with all the changes. Apply the suggestions to the same commit that creates the calens file (chore: add calens file)

Comment on lines +24 to +29
/**
* Expand the snackbar view to fill the width of its parent when the device
* reports a smallest-width of 600dp or more, so tablets don't render a short
* snackbar that leaves most of the row empty. Below 600dp the Material default
* is kept, which centres the snackbar and caps its width for readability.
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this comment necessary here? 🤔 Comments are not needed when code is self-explanatory, and in my opinion, the applyResponsiveWidth method is descriptive enough

* is kept, which centres the snackbar and caps its width for readability.
*/
fun Snackbar.applyResponsiveWidth(): Snackbar {
val smallestWidthDp = view.context.resources.configuration.smallestScreenWidthDp

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this variable needed? It is only used for comparison.
You can remove that line and write the method like this:

if (view.context.resources.configuration.smallestScreenWidthDp >= 600) { ... }

Do you agree? 🤔 It's just my opinion...

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.

[BUG] Short snackbar in tablets

3 participants