Skip to content

Conversation

@kidinov
Copy link
Contributor

@kidinov kidinov commented Dec 9, 2025

WOOMOB-1854

Description

Wire up the card reader connection dialog into WooPos screens:

  • Home screen shows connection dialog when reader is disconnected
  • Settings screen gets card reader update action
  • Toolbar and totals ViewModels trigger connection flow when needed
  • Update related tests

Test Steps

  • Verify connection and update flows work in the POS
  • Smoke test IPP
  • 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.

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 9, 2025

📲 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 NameWooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commit9bd3609
Direct Downloadwoocommerce-wear-prototype-build-pr15072-9bd3609.apk

@kidinov kidinov changed the title [WOOMOB-1854] Integrate card reader connection into WooPos screens [WOOMOB-1854] PR 4/6: Integrate card reader connection into WooPos screens Dec 9, 2025
@kidinov kidinov changed the title [WOOMOB-1854] PR 4/6: Integrate card reader connection into WooPos screens [WOOMOB-1854] PR 4/5: Integrate card reader connection into WooPos screens Dec 9, 2025
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Dec 9, 2025

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

App NameWooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commit9bd3609
Direct Downloadwoocommerce-prototype-build-pr15072-9bd3609.apk

@codecov-commenter
Copy link

codecov-commenter commented Dec 9, 2025

Codecov Report

❌ Patch coverage is 41.66667% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.21%. Comparing base (f8c0fd4) to head (9bd3609).
⚠️ Report is 291 commits behind head on woomob-1854-woopos-card-reader-connection-ui.

Files with missing lines Patch % Lines
...roid/ui/woopos/settings/WooPosSettingsViewModel.kt 0.00% 10 Missing ⚠️
...connection/WooPosCardReaderConnectionController.kt 0.00% 9 Missing ⚠️
...erce/android/ui/woopos/home/WooPosHomeViewModel.kt 0.00% 5 Missing and 1 partial ⚠️
...eader/WooPosSettingsHardwareCardReaderViewModel.kt 81.81% 2 Missing ⚠️
...der/connection/WooPosCardReaderConnectionDialog.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                                Coverage Diff                                 @@
##             woomob-1854-woopos-card-reader-connection-ui   #15072      +/-   ##
==================================================================================
- Coverage                                           38.68%   38.21%   -0.47%     
- Complexity                                          10482    10550      +68     
==================================================================================
  Files                                                2182     2197      +15     
  Lines                                              124004   126311    +2307     
  Branches                                            17119    17518     +399     
==================================================================================
+ Hits                                                47967    48270     +303     
- Misses                                              71203    73162    +1959     
- Partials                                             4834     4879      +45     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kidinov kidinov requested a review from samiuelson December 9, 2025 09:54
@kidinov kidinov added status: do not merge Dependent on another PR, ready for review but not ready for merge. feature: POS labels Dec 9, 2025
@kidinov kidinov marked this pull request as ready for review December 9, 2025 09:55
@kidinov kidinov changed the title [WOOMOB-1854] PR 4/5: Integrate card reader connection into WooPos screens [HACK][Woo POS] PR 4/5: Integrate card reader connection into WooPos screens Dec 10, 2025
@samiuelson samiuelson self-assigned this Dec 12, 2025
@samiuelson samiuelson requested a review from Copilot December 16, 2025 17:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR integrates card reader connection and update dialogs into WooPos screens, moving from direct facade calls to an event-driven architecture using dialog states and parent-child event communication.

Key changes:

  • Connection and update operations now trigger dialog events instead of direct facade calls
  • Settings and Home screens show card reader connection/update dialogs via state management
  • Toolbar and totals ViewModels use connection controller for disconnect operations

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
WooPosSettingsHardwareCardReaderViewModelTest.kt Updated tests to verify connection/update events are sent instead of direct facade calls; added controller factory mock
WooPosTotalsViewModelTest.kt Updated test to verify connection dialog event is sent when reader connection is needed
WooPosHomeFloatingToolbarViewModelTest.kt Updated tests to verify connection dialog events and controller disconnect usage; added controller factory mock
WooPosSettingsHardwareCardReaderViewModel.kt Changed connect/update to send events; disconnect now uses controller; added controller factory dependency
WooPosSettingsViewModel.kt Added handlers for card reader connection/update dialog events from child components
WooPosSettingsState.kt Added CardReaderConnectionDialog and CardReaderUpdateDialog dialog states
WooPosSettingsScreen.kt Added UI integration to show card reader connection and update dialogs based on state
WooPosTotalsViewModel.kt Changed connect reader click to send dialog event instead of calling facade
WooPosHomeFloatingToolbarViewModel.kt Changed connection to send dialog event; disconnect now uses controller; added controller factory dependency
WooPosHomeViewModel.kt Added handler for ShowCardReaderConnectionDialog event and dismiss event
WooPosHomeUIEvent.kt Added DismissCardReaderConnectionDialog event
WooPosHomeState.kt Added CardReaderConnectionDialog dialog state
WooPosHomeScreen.kt Added UI integration to show card reader connection dialog based on state
WooPosHomeChildToParentCommunication.kt Added ShowCardReaderConnectionDialog event and SettingsEvent variants for connection/update dialogs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 66 to 69
fun onDisconnectClicked() {
viewModelScope.launch {
cardReaderFacade.disconnectFromReader()
controller.disconnect()
}
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The onDisconnectClicked method now uses controller.disconnect instead of cardReaderFacade.disconnectFromReader, but there is no test coverage for this functionality. Consider adding a test case to verify that controller.disconnect is called when onDisconnectClicked is invoked, similar to how the toolbar ViewModel tests verify disconnect behavior.

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +42
private val controller: WooPosCardReaderConnectionController by lazy {
controllerFactory.create(viewModelScope)
}
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The controller is initialized lazily but only used for the disconnect operation. This means the controller won't be created until the first disconnect call, which could lead to unexpected behavior if other controller lifecycle management is expected. Consider either initializing it eagerly in the init block or documenting why lazy initialization is appropriate here.

Suggested change
private val controller: WooPosCardReaderConnectionController by lazy {
controllerFactory.create(viewModelScope)
}
private val controller: WooPosCardReaderConnectionController =
controllerFactory.create(viewModelScope)

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@samiuelson samiuelson left a comment

Choose a reason for hiding this comment

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

Looks good overall, @kidinov, thanks!

There's are two scenarios that are worth improving:

  1. Multiple, quick taps on "Connect your reader" button - the connect flow seems to be opened multiple times.
  2. "Pending requirements" full screen warning - consider moving to dialog 🤔
pending-req.mp4

Base automatically changed from woomob-1854-pr3-dialog-viewmodel to woomob-1854-woopos-card-reader-connection-ui January 15, 2026 14:31
kidinov and others added 3 commits January 15, 2026 15:53
Add guard to prevent starting a new connection flow if one is already
in progress. This fixes an issue where clicking the connect button
multiple times would start multiple concurrent connection flows.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…ob-1854-pr4-integration

# Conflicts:
#	WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/cardreader/connection/WooPosCardReaderConnectionController.kt
Use custom ic_close_24dp drawable instead of Material Icons default
Close icon for consistency with the app's design system.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@kidinov
Copy link
Contributor Author

kidinov commented Jan 15, 2026

@samiuelson thanks for review!

Multiple, quick taps on "Connect your reader" button - the connect flow seems to be opened multiple times.

Fixed here: 21101c3

"Pending requirements" full screen warning - consider moving to dialog 🤔

This not really related to this flow/PR and as far as I remember, this is a tricky job to do. Created an issue in backlog

WOOMOB-2002

@kidinov kidinov removed the status: do not merge Dependent on another PR, ready for review but not ready for merge. label Jan 15, 2026
Copy link
Contributor

@samiuelson samiuelson left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@samiuelson samiuelson merged commit 55817f5 into woomob-1854-woopos-card-reader-connection-ui Jan 15, 2026
20 checks passed
@samiuelson samiuelson deleted the woomob-1854-pr4-integration branch January 15, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants