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

[2 pane layout] Tablet mode detection logic change #13228

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

AnirudhBhat
Copy link
Contributor

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 and longSize (smallest and largest dimensions, respectively) to classify devices as Compact, Medium, or ExpandedAndBigger.

Steps to reproduce

  1. Open WooCommerce app
  2. Navigate to orders screen
  3. Rotate your device
  4. Observe the Behaviour:
    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
  • I have considered if this change warrants release notes and have added them to 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:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on big (tablet) and small (phone) in case of UI changes, and no regressions are added.

@AnirudhBhat AnirudhBhat added type: bug A confirmed bug. category: tablet Specific to tablet devices such as a Galaxy Tab or an iPad. labels Dec 31, 2024
@AnirudhBhat AnirudhBhat added this to the 21.4 milestone Dec 31, 2024
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 31, 2024

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commite0b9d62
Direct Downloadwoocommerce-wear-prototype-build-pr13228-e0b9d62.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 31, 2024

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commite0b9d62
Direct Downloadwoocommerce-prototype-build-pr13228-e0b9d62.apk

@codecov-commenter
Copy link

codecov-commenter commented Dec 31, 2024

Codecov Report

Attention: Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.

Project coverage is 40.64%. Comparing base (3f54acc) to head (e0b9d62).

Files with missing lines Patch % Lines
...n/com/woocommerce/android/extensions/ContextExt.kt 0.00% 10 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@AnirudhBhat AnirudhBhat requested a review from samiuelson January 2, 2025 04:10
@AnirudhBhat AnirudhBhat marked this pull request as ready for review January 2, 2025 04:10
@AnirudhBhat AnirudhBhat changed the title [Woo POS][Non-Simple Products] Tablet mode detection logic change [2 pane layout] Tablet mode detection logic change Jan 3, 2025
@kidinov kidinov requested review from kidinov and removed request for samiuelson January 6, 2025 09:40
@@ -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]
Copy link
Contributor

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(
Copy link
Contributor

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?

Base automatically changed from issue/13221-remove-variation-quantity to trunk January 10, 2025 04:14
@wpmobilebot wpmobilebot modified the milestones: 21.4, 21.5 Jan 10, 2025
@wpmobilebot
Copy link
Collaborator

Version 21.4 has now entered code-freeze, so the milestone of this PR has been updated to 21.5.

@kidinov kidinov self-assigned this Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: tablet Specific to tablet devices such as a Galaxy Tab or an iPad. type: bug A confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Order List] Squeezed Orders list on phone landscape mode
4 participants