[PM-34127] feat: Integrate card scanner with VaultAddEdit#6722
[PM-34127] feat: Integrate card scanner with VaultAddEdit#6722SaintPatrck merged 3 commits intomainfrom
Conversation
Bitwarden Claude Code ReviewOverall Assessment: APPROVE This PR integrates the card scanner with the VaultAddEdit screen, adding scan-card button UI gated behind a feature flag, camera permission handling with a settings dialog, card scan result mapping to form fields (number, expiry, CVV, brand detection), and post-scan focus on the cardholder name input. The implementation closely follows the established QR code scanner pattern for navigation, permission handling, and result flow. Card data remains client-side throughout the flow. Test coverage is comprehensive, including ViewModel tests for scan results, partial scans, flag gating, permission states, and Screen tests for UI visibility and focus behavior. Code Review DetailsNo findings. The code follows established patterns, handles edge cases well (partial scans preserve existing fields, duplicate scan guard via |
app/src/main/kotlin/com/x8bit/bitwarden/ui/vault/feature/addedit/VaultAddEditViewModel.kt
Outdated
Show resolved
Hide resolved
app/src/test/kotlin/com/x8bit/bitwarden/ui/vault/feature/addedit/VaultAddEditScreenTest.kt
Outdated
Show resolved
Hide resolved
|
New Issues (128)Checkmarx found the following issues in this Pull Request
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6722 +/- ##
==========================================
+ Coverage 84.85% 85.69% +0.83%
==========================================
Files 844 827 -17
Lines 59037 58549 -488
Branches 8563 8589 +26
==========================================
+ Hits 50097 50173 +76
+ Misses 5958 5376 -582
- Partials 2982 3000 +18
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
583a110 to
7c9d521
Compare
...main/kotlin/com/x8bit/bitwarden/ui/platform/feature/vaultunlocked/VaultUnlockedNavigation.kt
Outdated
Show resolved
Hide resolved
7c9d521 to
204305e
Compare
app/src/test/kotlin/com/x8bit/bitwarden/ui/vault/feature/addedit/VaultAddEditViewModelTest.kt
Outdated
Show resolved
Hide resolved
be951b7 to
ff88fbb
Compare
204305e to
ca82c3b
Compare
21a7f1a to
31ae25f
Compare
31ae25f to
cb0433e
Compare
...kotlin/com/x8bit/bitwarden/ui/vault/feature/addedit/handlers/VaultAddEditCardTypeHandlers.kt
Outdated
Show resolved
Hide resolved
| } else { | ||
| toastManager.show( | ||
| messageId = BitwardenString | ||
| .enable_camera_permission_to_use_the_scanner, |
There was a problem hiding this comment.
Should this be a Snackbar?
There was a problem hiding this comment.
That's a good question. I'll have to check with design. Good catch.
There was a problem hiding this comment.
We use a dialog with an option to navigate to settings or dismiss the dialog in other places. That's what happens here now, too.
app/src/main/kotlin/com/x8bit/bitwarden/ui/vault/feature/addedit/VaultAddEditScreen.kt
Outdated
Show resolved
Hide resolved
app/src/test/kotlin/com/x8bit/bitwarden/ui/vault/feature/addedit/VaultAddEditViewModelTest.kt
Show resolved
Hide resolved
eeede50 to
d076c37
Compare
d16f24a to
009a1bc
Compare
app/src/main/kotlin/com/x8bit/bitwarden/ui/platform/composition/LocalManagerProvider.kt
Outdated
Show resolved
Hide resolved
app/src/main/kotlin/com/x8bit/bitwarden/ui/vault/feature/addedit/VaultAddEditScreen.kt
Outdated
Show resolved
Hide resolved
4f8369b to
2b11285
Compare
Wire the card scanner into the card cipher add/edit flow: - VaultAddEditViewModel: inject CardScanManager, handle scan results, populate card fields with brand-aware CVV validation - VaultAddEditScreen: pass scanner enabled state and click handler - VaultAddEditCardItems: conditionally render Scan Card button - VaultUnlockedNavigation: register card scan route
2b11285 to
daa0596
Compare
| class CardScanViewModel @Inject constructor( | ||
| savedStateHandle: SavedStateHandle, | ||
| private val cardScanManager: CardScanManager, | ||
| savedStateHandle: SavedStateHandle, |
There was a problem hiding this comment.
What's up with this change?
There was a problem hiding this comment.
Another rebase artifact 🤦
app/src/main/kotlin/com/x8bit/bitwarden/ui/vault/feature/cardscanner/CardScanViewModel.kt
Show resolved
Hide resolved
app/src/test/kotlin/com/x8bit/bitwarden/ui/vault/feature/addedit/VaultAddEditScreenTest.kt
Show resolved
Hide resolved
| CardScanViewModel( | ||
| savedStateHandle = SavedStateHandle(), | ||
| savedStateHandle = SavedStateHandle().apply { | ||
| set("state", initialState) |


🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-34127
📔 Objective
Integrate the card scanner with the VaultAddEdit screen:
CardScanManagerresults, map scanned card data to form fields (number, expiry, CVV, brand detection), and emit focus event for cardholder name inputcard-scanner-mobilefeature flag. After a successful scan, focus the cardholder name field and show the keyboard usingDeferredBackgroundEventto survive lifecycle filteringCardScanScreendestination and navigationIncludes ViewModel and Screen tests for scan result handling, partial scans, feature flag gating, and post-scan focus behavior.
📸 Screenshots
Figma designs (based on iOS)
Permission dialog
Scan flow
Screen_recording_20260402_155715.mp4