nativescript-barcodescanner
Advanced tools
Comparing version 1.2.2 to 1.3.1
@@ -60,3 +60,4 @@ var barcodescanner = require("./barcodescanner-common"); | ||
if (arg.preferFrontCamera === true) { | ||
intent.putExtra(com.google.zxing.client.android.Intents.Scan.PREFER_FRONTCAMERA, true); | ||
// if no front cam is found this will fall back to the back camera | ||
intent.putExtra(com.google.zxing.client.android.Intents.Scan.CAMERA_ID, 1); | ||
} | ||
@@ -66,4 +67,16 @@ if (arg.showFlipCameraButton === true) { | ||
} | ||
if (arg.orientation) { | ||
// if not set, sensor orientation is used (rotates with the device) | ||
intent.putExtra(com.google.zxing.client.android.Intents.Scan.ORIENTATION_LOCK, arg.orientation); | ||
} | ||
} | ||
// TODO pass in 'formats', can also be done easily for iOS | ||
// intent.putExtra(com.google.zxing.client.android.Intents.Scan.SCAN_FORMATS, "QR_CODE"); | ||
// intent.putExtra(com.google.zxing.client.android.Intents.Scan.MODE, com.google.zxing.client.android.Intents.Scan.QR_CODE_MODE); | ||
// rectangle size can be controlled as well (but don't bother as of yet) | ||
// intent.putExtra(com.google.zxing.client.android.Intents.Scan.WIDTH, 200); | ||
// intent.putExtra(com.google.zxing.client.android.Intents.Scan.HEIGHT, 200); | ||
if (intent.resolveActivity(appModule.android.context.getPackageManager()) !== null) { | ||
@@ -80,4 +93,4 @@ var previousResult = appModule.android.onActivityResult; | ||
resolve({ | ||
format : data.getStringExtra("SCAN_RESULT_FORMAT"), | ||
text : data.getStringExtra("SCAN_RESULT") | ||
format : data.getStringExtra(com.google.zxing.client.android.Intents.Scan.RESULT_FORMAT), | ||
text : data.getStringExtra(com.google.zxing.client.android.Intents.Scan.RESULT) | ||
}); | ||
@@ -84,0 +97,0 @@ } else { |
@@ -33,2 +33,9 @@ declare module "nativescript-barcodescanner" { | ||
showFlipCameraButton?: boolean; | ||
/** | ||
* Optionally lock the orientation to 'portrait' or 'landscape'. | ||
* Default: "sensor", which follows the current device rotation. | ||
* Android only. | ||
*/ | ||
orientation?: string; | ||
} | ||
@@ -35,0 +42,0 @@ |
@@ -11,3 +11,3 @@ var barcodescanner = require("./barcodescanner-common"); | ||
// TODO consider giving camera PERMISSION beforehand: https://github.com/yannickl/QRCodeReaderViewController/issues/4, | ||
// would fit well with the Android 6 implementation. | ||
// would fit well with the Android 6 implementation. | ||
barcodescanner.scan = function (arg) { | ||
@@ -14,0 +14,0 @@ return new Promise(function (resolve, reject) { |
{ | ||
"name": "nativescript-barcodescanner", | ||
"version": "1.2.2", | ||
"version": "1.3.1", | ||
"description": "Scan QR/barcodes with a {N} app.", | ||
@@ -5,0 +5,0 @@ "main": "barcodescanner.js", |
@@ -5,9 +5,2 @@ # NativeScript BarcodeScanner | ||
## Prerequisites | ||
Set your Android target to level 23. | ||
NativeScript 1.2.3+ for iOS, 1.3.0+ for Android (`tns --version`), so please upgrade if you need to. | ||
If -for some reason- you need to build for {N} 1.2 on Android, please [use this branch](https://github.com/EddyVerbruggen/nativescript-barcodescanner/tree/nativescript-pre-1.3). | ||
## Installation | ||
@@ -29,4 +22,2 @@ From the command prompt go to your app's root folder and execute: | ||
* UPC_E | ||
### iOS only | ||
* Aztec | ||
@@ -52,3 +43,4 @@ * PDF417 | ||
preferFrontCamera: false, // Android only, default false | ||
showFlipCameraButton: true // Android only, default false (on iOS it's always available) | ||
showFlipCameraButton: true, // Android only, default false (on iOS it's always available) | ||
orientation: "landscape" // Android only, optionally lock the orientation to either "portrait" or "landscape" | ||
}).then( | ||
@@ -103,4 +95,4 @@ function(result) { | ||
Note that the `scan` function will also check fr permission and ask for it if it wasn't previously granted. | ||
Note that the `scan` function will also check for permission and ask for it if it wasn't previously granted. | ||
If you're relying on that, then you should know that since we're not catching the consent result | ||
the user will then need to allow camera access and launch the scanner again. | ||
the user will then need to allow camera access and launch the scanner again. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1407935
291
95