diff --git a/example-app/src/pages/Home.tsx b/example-app/src/pages/Home.tsx index e2d3404..8b852f5 100644 --- a/example-app/src/pages/Home.tsx +++ b/example-app/src/pages/Home.tsx @@ -48,6 +48,9 @@ const Home: React.FC = () => { scanText: scanText, cameraDirection: cameraDirection, scanOrientation: scanOrientation, + cancelButtonAccessibilityLabel: "Cancel scanning", + torchButtonOnAccessibilityLabel: "Turn off flashlight", + torchButtonOffAccessibilityLabel: "Turn on flashlight", android: { scanningLibrary: androidScanningLibrary } diff --git a/plugin/CapacitorBarcodeScanner.podspec b/plugin/CapacitorBarcodeScanner.podspec index 9a43812..99840ca 100644 --- a/plugin/CapacitorBarcodeScanner.podspec +++ b/plugin/CapacitorBarcodeScanner.podspec @@ -13,6 +13,6 @@ Pod::Spec.new do |s| s.source_files = 'ios/Sources/**/*.{swift,h,m,c,cc,mm,cpp}' s.ios.deployment_target = '15.0' s.dependency 'Capacitor' - s.dependency 'OSBarcodeLib', '2.0.1' + s.dependency 'OSBarcodeLib', '2.2.0' s.swift_version = '5.1' end diff --git a/plugin/Package.swift b/plugin/Package.swift index ece7156..c4e0516 100644 --- a/plugin/Package.swift +++ b/plugin/Package.swift @@ -11,7 +11,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0"), - .package(url: "https://github.com/OutSystems/OSBarcodeLib-iOS.git", from: "2.1.1") + .package(url: "https://github.com/OutSystems/OSBarcodeLib-iOS.git", from: "2.2.0") ], targets: [ .target( diff --git a/plugin/README.md b/plugin/README.md index 5cffee9..0a0f68d 100644 --- a/plugin/README.md +++ b/plugin/README.md @@ -90,7 +90,7 @@ to represent the hint for the type of barcode to be scanned. Defines the options for configuring a barcode scan. -{ hint: CapacitorBarcodeScannerTypeHint; scanInstructions?: string; scanButton?: boolean; scanText?: string; cameraDirection?: CapacitorBarcodeScannerCameraDirection; scanOrientation?: CapacitorBarcodeScannerScanOrientation; android?: { scanningLibrary?: CapacitorBarcodeScannerAndroidScanningLibrary; }; web?: { showCameraSelection?: boolean; scannerFPS?: number; }; } +{ hint: CapacitorBarcodeScannerTypeHint; scanInstructions?: string; scanButton?: boolean; scanText?: string; cameraDirection?: CapacitorBarcodeScannerCameraDirection; scanOrientation?: CapacitorBarcodeScannerScanOrientation; /** * Accessibility label (alternative text) read by screen readers for the cancel button. * When omitted, the native library's default is used. Has no effect on web. */ cancelButtonAccessibilityLabel?: string; /** * Accessibility label (alternative text) read by screen readers for the torch button when the torch is on. * When omitted, the native library's default is used. Has no effect on web. */ torchButtonOnAccessibilityLabel?: string; /** * Accessibility label (alternative text) read by screen readers for the torch button when the torch is off. * When omitted, the native library's default is used. Has no effect on web. */ torchButtonOffAccessibilityLabel?: string; android?: { scanningLibrary?: CapacitorBarcodeScannerAndroidScanningLibrary; }; web?: { showCameraSelection?: boolean; scannerFPS?: number; }; } ### Enums diff --git a/plugin/android/build.gradle b/plugin/android/build.gradle index 7b28fd0..035ea67 100644 --- a/plugin/android/build.gradle +++ b/plugin/android/build.gradle @@ -59,7 +59,7 @@ repositories { } dependencies { - implementation "io.ionic.libs:ionbarcode-android:2.0.2@aar" + implementation "io.ionic.libs:ionbarcode-android:2.1.0@aar" implementation project(':capacitor-android') implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion" implementation 'androidx.activity:activity-ktx:1.11.0' diff --git a/plugin/android/src/main/java/com/capacitorjs/barcodescanner/OSBarcodePlugin.kt b/plugin/android/src/main/java/com/capacitorjs/barcodescanner/OSBarcodePlugin.kt index 5fc343c..7edf5e8 100644 --- a/plugin/android/src/main/java/com/capacitorjs/barcodescanner/OSBarcodePlugin.kt +++ b/plugin/android/src/main/java/com/capacitorjs/barcodescanner/OSBarcodePlugin.kt @@ -39,6 +39,9 @@ class CapacitorBarcodeScannerPlugin : Plugin() { val cameraDirection = call.getInt("cameraDirection") val scanOrientation = call.getInt("scanOrientation") val androidScanningLibrary = call.getObject("android")?.getString("scanningLibrary") + val cancelButtonAccessibilityLabel = call.getString("cancelButtonAccessibilityLabel") + val torchButtonOnAccessibilityLabel = call.getString("torchButtonOnAccessibilityLabel") + val torchButtonOffAccessibilityLabel = call.getString("torchButtonOffAccessibilityLabel") val parameters = OSBARCScanParameters( scanInstructions = scanInstructions, @@ -47,7 +50,10 @@ class CapacitorBarcodeScannerPlugin : Plugin() { scanButton = scanButton, scanText = scanText, hint = hint, - androidScanningLibrary = androidScanningLibrary + androidScanningLibrary = androidScanningLibrary, + cancelButtonAccessibilityLabel = cancelButtonAccessibilityLabel, + torchButtonOnAccessibilityLabel = torchButtonOnAccessibilityLabel, + torchButtonOffAccessibilityLabel = torchButtonOffAccessibilityLabel ) val scanIntent = Intent(activity, OSBARCScannerActivity::class.java) diff --git a/plugin/ios/Sources/CapacitorBarcodeScannerPlugin/OSBARCScanParameters+Decodable.swift b/plugin/ios/Sources/CapacitorBarcodeScannerPlugin/OSBARCScanParameters+Decodable.swift index ddbe916..3773f49 100644 --- a/plugin/ios/Sources/CapacitorBarcodeScannerPlugin/OSBARCScanParameters+Decodable.swift +++ b/plugin/ios/Sources/CapacitorBarcodeScannerPlugin/OSBARCScanParameters+Decodable.swift @@ -10,6 +10,9 @@ extension OSBARCScanParameters: Decodable { case cameraDirection case scanOrientation case hint + case cancelButtonAccessibilityLabel + case torchButtonOnAccessibilityLabel + case torchButtonOffAccessibilityLabel } public init(from decoder: Decoder) throws { @@ -32,12 +35,19 @@ extension OSBARCScanParameters: Decodable { let hintInt = try container.decode(Int.self, forKey: .hint) let hint = OSBARCScannerHint(rawValue: hintInt) + let cancelButtonAccessibilityLabel = try container.decodeIfPresent(String.self, forKey: .cancelButtonAccessibilityLabel) + let torchButtonOnAccessibilityLabel = try container.decodeIfPresent(String.self, forKey: .torchButtonOnAccessibilityLabel) + let torchButtonOffAccessibilityLabel = try container.decodeIfPresent(String.self, forKey: .torchButtonOffAccessibilityLabel) + self.init( scanInstructions: scanInstructions, scanButtonText: scanButtonText, cameraDirection: cameraDirection, scanOrientation: scanOrientation, - hint: hint + hint: hint, + cancelButtonAccessibilityLabel: cancelButtonAccessibilityLabel, + torchButtonOnAccessibilityLabel: torchButtonOnAccessibilityLabel, + torchButtonOffAccessibilityLabel: torchButtonOffAccessibilityLabel ) } } diff --git a/plugin/src/definitions.ts b/plugin/src/definitions.ts index 91382ac..a87ca12 100644 --- a/plugin/src/definitions.ts +++ b/plugin/src/definitions.ts @@ -68,6 +68,21 @@ export type CapacitorBarcodeScannerOptions = { scanText?: string; cameraDirection?: CapacitorBarcodeScannerCameraDirection; scanOrientation?: CapacitorBarcodeScannerScanOrientation; + /** + * Accessibility label (alternative text) read by screen readers for the cancel button. + * When omitted, the native library's default is used. Has no effect on web. + */ + cancelButtonAccessibilityLabel?: string; + /** + * Accessibility label (alternative text) read by screen readers for the torch button when the torch is on. + * When omitted, the native library's default is used. Has no effect on web. + */ + torchButtonOnAccessibilityLabel?: string; + /** + * Accessibility label (alternative text) read by screen readers for the torch button when the torch is off. + * When omitted, the native library's default is used. Has no effect on web. + */ + torchButtonOffAccessibilityLabel?: string; android?: { scanningLibrary?: CapacitorBarcodeScannerAndroidScanningLibrary; };