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

[Barcode Scanner] Implement Fallback to Front-Facing Camera if Back Camera is Unavailable #13230

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

Conversation

AnirudhBhat
Copy link
Contributor

@AnirudhBhat AnirudhBhat commented Jan 2, 2025

Closes: #13174

Description

This PR updates the barcode scanner to gracefully handle devices where a back-facing camera is unavailable, such as Chromebooks. The code now checks for available cameras and falls back to the front-facing camera if necessary.

Steps to reproduce

Devices that have both back and front facing camera

  1. Navigate to Orders tab
  2. Click on the barcode icon in the toolbar
  3. Ensure barcode scanner works as expected

Devices that have doesn't have back facing camera (Chromebook)

  1. Navigate to Orders tab
  2. Click on the barcode icon in the toolbar
  3. Ensure barcode scanner works as expected

The tests that have been performed

Simulated Testing: Modify the code to skip the back camera temporarily and test fallback to the front camera.

  • 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: enhancement A request for an enhancement. type: task An internally driven task. labels Jan 2, 2025
@AnirudhBhat AnirudhBhat added this to the 21.4 milestone Jan 2, 2025
@AnirudhBhat AnirudhBhat requested a review from samiuelson January 2, 2025 04:49
@wpmobilebot
Copy link
Collaborator

📲 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
Commit26fa3f2
Direct Downloadwoocommerce-wear-prototype-build-pr13230-26fa3f2.apk

@wpmobilebot
Copy link
Collaborator

📲 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
Commit26fa3f2
Direct Downloadwoocommerce-prototype-build-pr13230-26fa3f2.apk

@codecov-commenter
Copy link

Codecov Report

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

Project coverage is 40.64%. Comparing base (bcbbde1) to head (26fa3f2).

Files with missing lines Patch % Lines
...mmerce/android/ui/barcodescanner/BarcodeScanner.kt 0.00% 8 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #13230      +/-   ##
============================================
- Coverage     40.64%   40.64%   -0.01%     
+ Complexity     6387     6386       -1     
============================================
  Files          1351     1351              
  Lines         77444    77451       +7     
  Branches      10650    10652       +2     
============================================
- Hits          31479    31478       -1     
- Misses        43186    43193       +7     
- Partials       2779     2780       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A request for an enhancement. type: task An internally driven task.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Barcode scanner] Allow scanning barcodes with front camera if rear camera is not available
3 participants