-
Notifications
You must be signed in to change notification settings - Fork 137
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
[2 pane layout] Tablet mode detection logic change #13228
base: trunk
Are you sure you want to change the base?
Conversation
… and height for split mode.
📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
|
📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## issue/13221-remove-variation-quantity #13228 +/- ##
===========================================================================
- Coverage 40.64% 40.64% -0.01%
Complexity 6380 6380
===========================================================================
Files 1349 1349
Lines 77400 77407 +7
Branches 10647 10647
===========================================================================
Hits 31461 31461
- Misses 43159 43166 +7
Partials 2780 2780 ☔ View full report in Codecov by Sentry. |
@@ -7,6 +7,7 @@ | |||
- [*] Fixed overlap issue in Settings > WooCommerce Version [https://github.com/woocommerce/woocommerce-android/pull/13183] | |||
- [*] Fixed a crash on the order details [https://github.com/woocommerce/woocommerce-android/pull/13191] | |||
- [**] Fixed a crash when a shop manager was trying to install or activate plugin in the POS onboarding [https://github.com/woocommerce/woocommerce-android/pull/13203] | |||
- [*] Refactored tablet detection logic to consider both width and height dimensions, enhancing compatibility with larger phones and tablets, particularly in landscape mode [https://github.com/woocommerce/woocommerce-android/pull/13228] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np: I think this is not a refactoring, but change of the logic
|
||
val Context.windowSizeClass: WindowSizeClass | ||
get() = determineWindowWidthSizeClassByGivenSize(resources.configuration.screenWidthDp) | ||
get() = determineWindowSizeClassByDimensions( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AnirudhBhat I think we can not use the same semantics here if we change the logic. Window classes we use here are from https://m3.material.io/foundations/layout/applying-layout/window-size-classes and those are determined based on the width of a device. Reusing the same concept but with different logic may bring confusion and errors
I am thinking that:
- We should either simplify all of this and end up with something "isTwoPaneShouldBeUsed" with logic similar/the same as
WooPosIsScreenSizeAllowed
. I'd say this is preferred, as I think we learned that the use of those size classes doesn't work well at all - Or at least refactor all of this and call it in not attaching to the material design size classes name (remove comments etc) to make sure that we don't mix the concepts
wdyt?
Version |
Closes: #12861
Description
This PR refactors the tablet detection logic to account for both width and height dimensions when determining if a device qualifies as a tablet. The updated logic improves compatibility with larger phones especially in landscape mode.
Changes Introduced:
New Size Class Determination Method:
Introduced
determineWindowSizeClassByDimensions(widthDp: Int, heightDp: Int)
.Evaluates both
shortSize
andlongSize
(smallest and largest dimensions, respectively) to classify devices asCompact
,Medium
, orExpandedAndBigger
.Steps to reproduce
On smaller devices: The screen remains in single-pane mode and does not split into tablet mode.
On larger phones and tablets: The screen transitions to split-pane (tablet) mode as expected.
The tests that have been performed
Verified behaviour on below emulators:
Tablets (portrait and landscape)
Large phones in landscape mode
Images/gif
tablet_detection_logic.mp4
RELEASE-NOTES.txt
if necessary. Use the "[Internal]" label for non-user-facing changes.Reviewer (or Author, in the case of optional code reviews):
Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement: