Skip to content

Commit 04949bb

Browse files
authored
Merge branch 'trunk' into woomob-945-wooposbarcodes-disable-scanning-when-the-support-view-is
2 parents a3158db + 56ca8c3 commit 04949bb

File tree

19 files changed

+518
-43
lines changed

19 files changed

+518
-43
lines changed

Modules/Sources/Experiments/DefaultFeatureFlagService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public struct DefaultFeatureFlagService: FeatureFlagService {
104104
case .pointOfSaleBarcodeScanningi2:
105105
return buildConfig == .localDeveloper || buildConfig == .alpha
106106
case .orderAddressMapSearch:
107-
return buildConfig == .localDeveloper || buildConfig == .alpha
107+
return true
108108
default:
109109
return true
110110
}

RELEASE-NOTES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
- [*] Increased decimal sensitivity in order creation to mitigate tax rounding issues [https://github.com/woocommerce/woocommerce-ios/pull/15957]
77
- [*] Fix initialization of authenticator to avoid crashes during login [https://github.com/woocommerce/woocommerce-ios/pull/15953]
88
- [*] Shipping Labels: Made HS tariff number field required in customs form for EU destinations [https://github.com/woocommerce/woocommerce-ios/pull/15946]
9+
- [*] Order Details > Edit Shipping/Billing Address: Added map-based address lookup support for iOS 17+. [https://github.com/woocommerce/woocommerce-ios/pull/15964]
10+
- [*] Order Creation: Prevent subscription products to be added to an order [https://github.com/woocommerce/woocommerce-ios/pull/15960]
911
- [internal] Replace COTS_DEVICE reader model name with TAP_TO_PAY_DEVICE. [https://github.com/woocommerce/woocommerce-ios/pull/15961]
1012

1113
22.9

WooCommerce/Classes/Analytics/WooAnalyticsStat.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,8 @@ enum WooAnalyticsStat: String {
450450
case orderDetailEditFlowFailed = "order_detail_edit_flow_failed"
451451
case orderDetailPaymentLinkShared = "order_detail_payment_link_shared"
452452
case orderDetailTrashButtonTapped = "order_detail_trash_tapped"
453+
case orderDetailEditAddressMapPickerTapped = "order_detail_edit_address_map_picker_tapped"
454+
case orderDetailEditAddressMapPickerUseAddressTapped = "order_detail_edit_address_map_picker_use_address_tapped"
453455

454456
// MARK: Test order
455457
//

WooCommerce/Classes/POS/Models/Cart+BarcodeScanError.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ extension PointOfSaleBarcodeScanError {
121121
)
122122

123123
static let incompleteScan = NSLocalizedString(
124-
"pointOfSale.barcodeScan.error.incompleteScan",
125-
value: "Partial barcode scan",
126-
comment: "Error message shown when scan is incomplete."
124+
"pointOfSale.barcodeScan.error.incompleteScan.2",
125+
value: "The scanner did not send an end-of-line character",
126+
comment: "Error message shown when scanner times out without sending end-of-line character."
127127
)
128128

129129
static let parsingError = NSLocalizedString(

WooCommerce/Classes/POS/Presentation/Barcode Scanner Setup/PointOfSaleBarcodeScannerSetupModels.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ enum PointOfSaleBarcodeScannerType {
2929
var analyticsName: String {
3030
switch self {
3131
case .starBSH20B:
32-
return "Star_BSH_20B"
32+
return "star_bsh_20b"
3333
case .tera12002D:
34-
return "Tera_1200_2D"
34+
return "tera_1200_2d"
3535
case .netum1228BC:
36-
return "Netum_1228BC"
36+
return "netum_1228bc"
3737
case .other:
3838
return "other"
3939
}

WooCommerce/Classes/POS/Presentation/Barcode Scanner Setup/PointOfSaleBarcodeScannerSetupStepViews.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ private extension PointOfSaleBarcodeScannerSetupCompleteView {
196196
comment: "Title shown when scanner setup is successfully completed"
197197
)
198198
static let instruction = NSLocalizedString(
199-
"pos.barcodeScannerSetup.complete.instruction",
200-
value: "You are ready to start scanning products. \nRead more about barcode and QR code scanner support.",
201-
comment: "Message shown when scanner setup is complete, with additional information link"
199+
"pos.barcodeScannerSetup.complete.instruction.2",
200+
value: "You are ready to start scanning products. Next time you need to connect your scanner, just turn it on and it will reconnect automatically.",
201+
comment: "Message shown when scanner setup is complete"
202202
)
203203
}
204204
}

WooCommerce/Classes/POS/Presentation/Barcode Scanning/GameControllerBarcodeParser.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ final class GameControllerBarcodeParser {
1515
private var buffer = ""
1616
private var lastKeyPressTime: Date?
1717
private var scanStartTime: Date?
18+
private var timeoutTimer: Timer?
1819

1920
init(configuration: HIDBarcodeParserConfiguration,
2021
onScan: @escaping (HIDBarcodeParserResult) -> Void,
@@ -49,6 +50,7 @@ final class GameControllerBarcodeParser {
4950
}
5051

5152
buffer.append(character)
53+
scheduleTimeoutTimer()
5254
}
5355
}
5456

@@ -186,6 +188,31 @@ final class GameControllerBarcodeParser {
186188
buffer = ""
187189
lastKeyPressTime = nil
188190
scanStartTime = nil
191+
cancelTimeoutTimer()
192+
}
193+
194+
private func scheduleTimeoutTimer() {
195+
cancelTimeoutTimer()
196+
timeoutTimer = timeProvider.scheduleTimer(
197+
timeInterval: configuration.maximumInterCharacterTime,
198+
target: self,
199+
selector: #selector(handleTimeoutExpiry)
200+
)
201+
}
202+
203+
private func cancelTimeoutTimer() {
204+
timeoutTimer?.invalidate()
205+
timeoutTimer = nil
206+
}
207+
208+
@objc private func handleTimeoutExpiry() {
209+
guard !buffer.isEmpty else { return }
210+
211+
let scanDurationMs = calculateScanDurationMs()
212+
let result = HIDBarcodeParserResult.failure(error: HIDBarcodeParserError.timedOut(barcode: buffer), scanDurationMs: scanDurationMs)
213+
214+
onScan(result)
215+
resetScan()
189216
}
190217

191218
private func calculateScanDurationMs() -> Int {
@@ -194,6 +221,7 @@ final class GameControllerBarcodeParser {
194221
}
195222

196223
private func processScan() {
224+
cancelTimeoutTimer()
197225
checkForTimeoutBetweenKeystrokes()
198226
let scanDurationMs = calculateScanDurationMs()
199227

WooCommerce/Classes/POS/Presentation/Barcode Scanning/TimeProvider.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@ import Foundation
22

33
protocol TimeProvider {
44
func now() -> Date
5+
func scheduleTimer(timeInterval: TimeInterval, target: Any, selector: Selector) -> Timer
56
}
67

78
struct DefaultTimeProvider: TimeProvider {
89
func now() -> Date {
910
Date()
1011
}
12+
13+
func scheduleTimer(timeInterval: TimeInterval, target: Any, selector: Selector) -> Timer {
14+
return Timer.scheduledTimer(timeInterval: timeInterval, target: target, selector: selector, userInfo: nil, repeats: false)
15+
}
1116
}

WooCommerce/Classes/POS/Presentation/POSFloatingControlView.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,13 @@ struct POSFloatingControlView: View {
6363
ServiceLocator.analytics.track(.pointOfSaleBarcodeScanningMenuItemTapped)
6464
} label: {
6565
Label(
66-
title: { Text(Localization.barcodeScanning) },
66+
title: {
67+
if ServiceLocator.featureFlagService.isFeatureFlagEnabled(.pointOfSaleBarcodeScanningi2) {
68+
Text(Localization.barcodeScanningSetup)
69+
} else {
70+
Text(Localization.barcodeScanning)
71+
}
72+
},
6773
icon: { Image(systemName: "barcode.viewfinder") })
6874
}
6975
}
@@ -173,6 +179,12 @@ private extension POSFloatingControlView {
173179
value: "Barcode scanning",
174180
comment: "The title of the menu button to view barcode scanner documentation, shown in a popover menu."
175181
)
182+
183+
static let barcodeScanningSetup = NSLocalizedString(
184+
"pointOfSale.floatingButtons.barcodeScanningSetup.button.title",
185+
value: "Initial barcode scanner setup",
186+
comment: "The title of the menu button to start a barcode scanner setup flow."
187+
)
176188
}
177189
}
178190

WooCommerce/Classes/ViewRelated/Orders/Order Details/Address Edit/AddressMapPickerView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ struct AddressMapPickerView: View {
9393
isSearchFocused = false
9494
viewModel.updateFields(&fields)
9595
dismiss()
96+
ServiceLocator.analytics.track(.orderDetailEditAddressMapPickerUseAddressTapped)
9697
}
9798
.disabled(!viewModel.hasValidSelection)
9899
}

0 commit comments

Comments
 (0)