-
Notifications
You must be signed in to change notification settings - Fork 130
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
[2 pane layout] Tablet mode detection logic change #13228
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 @@
## trunk #13228 +/- ##
============================================
- Coverage 41.23% 41.22% -0.01%
+ Complexity 6548 6547 -1
============================================
Files 1326 1326
Lines 77731 77730 -1
Branches 10706 10701 -5
============================================
- Hits 32049 32046 -3
- Misses 42836 42839 +3
+ Partials 2846 2845 -1 ☔ View full report in Codecov by Sentry. |
RELEASE-NOTES.txt
Outdated
@@ -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
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.
Updated here: dd61dda
|
||
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?
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.
Sorry for the late response.
I agree with your opinion that mixing Window classes and our custom detection logic would create confusion. I've updated the logic to remove Window class reference. Please take a look.
Version |
Version |
Generated by 🚫 Danger |
…-logic-change # Conflicts: # WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/details/OrderDetailFragment.kt # WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/list/OrderListFragment.kt # WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/list/OrderListViewModel.kt
|
||
val Context.deviceTypeToAnalyticsString: String | ||
get() = buildAnalyticsDeviceTypeValue( | ||
IsScreenLargerThanCompactValue(value = windowSizeClass != WindowSizeClass.Compact) | ||
IsScreenLargerThanCompactValue(value = isTwoPanesShouldBeUsed) |
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.
IsScreenLargerThanCompactValue
should probably be renamed? I see that we track:
const val VALUE_DEVICE_TYPE_REGULAR = "regular"
const val VALUE_DEVICE_TYPE_COMPACT = "compact"
But is this the same as 2 panes and 1 pane?
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.
Logically it seems that what we want to track -> either 2 panes or 1 pane used, but naming is old so maybe confusing. Wdyt regarding this?
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.
I've renamed variables used for analytics here: 91c4324
I've commented for more clarity on why we had kept the values for analytics as it is.
@@ -568,8 +567,8 @@ class OrderCreateEditViewModel @Inject constructor( | |||
handleCouponEditResult(couponEditResult) | |||
} | |||
|
|||
private fun getScreenSizeClassNameForAnalytics(windowSize: WindowSizeClass) = | |||
IsScreenLargerThanCompactValue(windowSize != WindowSizeClass.Compact).deviceTypeToAnalyticsString | |||
private fun getScreenSizeClassNameForAnalytics(isTwoPane: Boolean) = |
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.
Renaming is needed
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.
Renamed: 91c4324
@@ -580,7 +579,7 @@ class OrderCreateEditViewModel @Inject constructor( | |||
KEY_STATUS to order.status, | |||
KEY_TYPE to CUSTOMER, | |||
KEY_FLOW to flow, | |||
KEY_HORIZONTAL_SIZE_CLASS to getScreenSizeClassNameForAnalytics(viewState.windowSizeClass) | |||
KEY_HORIZONTAL_SIZE_CLASS to getScreenSizeClassNameForAnalytics(viewState.isTwoPaneLayout) |
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.
Hmm... I am thinking about how we could keep the naming that we send to Tracks (for backward compatibility) but at the same time make it clear what we track in the code 🤔 I think maybe just renaming the variables to something that make it clear that we track 1/2 panes, but the values keep the same?
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.
I've commented for more clarity on why we had kept the values for analytics as it is -91c4324
|
||
class IsWindowClassExpandedAndBigger @Inject constructor(val context: Context) { | ||
operator fun invoke() = context.windowSizeClass >= WindowSizeClass.ExpandedAndBigger | ||
operator fun invoke() = context.isTwoPanesShouldBeUsed |
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.
Naming here could be changed too
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.
Renamed: 91c4324
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.
LGTM! I'd just recommend to improve the naming of the variables, to make it clear what are we doing, especially in tracking
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: