nativescript-barcodescanner
Advanced tools
Comparing version 1.2.1 to 1.2.2
var barcodescanner = require("./barcodescanner-common"); | ||
var appModule = require("application"); | ||
var context = appModule.android.context; | ||
@@ -8,2 +7,4 @@ var SCANNER_REQUEST_CODE = 444; | ||
barcodescanner.rememberedContext = null; | ||
barcodescanner._cameraPermissionGranted = function () { | ||
@@ -13,3 +14,3 @@ var hasPermission = android.os.Build.VERSION.SDK_INT < 23; // Android M. (6.0) | ||
hasPermission = android.content.pm.PackageManager.PERMISSION_GRANTED == | ||
android.support.v4.content.ContextCompat.checkSelfPermission(appModule.android.foregroundActivity, android.Manifest.permission.CAMERA); | ||
android.support.v4.content.ContextCompat.checkSelfPermission(appModule.android.currentContext, android.Manifest.permission.CAMERA); | ||
} | ||
@@ -30,3 +31,3 @@ return hasPermission; | ||
android.support.v4.app.ActivityCompat.requestPermissions( | ||
appModule.android.foregroundActivity, | ||
appModule.android.currentContext, | ||
[android.Manifest.permission.CAMERA], | ||
@@ -54,3 +55,3 @@ CAMERA_PERMISSION_REQUEST_CODE); | ||
// limit searching for a valid Intent to this package only | ||
intent.setPackage(context.getPackageName()); | ||
intent.setPackage(appModule.android.context.getPackageName()); | ||
@@ -73,2 +74,6 @@ if (arg !== null) { | ||
appModule.android.onActivityResult = function (requestCode, resultCode, data) { | ||
if (barcodescanner.rememberedContext !== null) { | ||
appModule.android.currentContext = barcodescanner.rememberedContext; | ||
barcodescanner.rememberedContext = null; | ||
} | ||
appModule.android.onActivityResult = previousResult; | ||
@@ -86,4 +91,6 @@ if (requestCode === SCANNER_REQUEST_CODE) { | ||
}; | ||
appModule.android.foregroundActivity.startActivityForResult(intent, SCANNER_REQUEST_CODE); | ||
// we need to cache and restore the context, otherwise the dialogs module will be broken (and possibly other things as well) | ||
barcodescanner.rememberedContext = appModule.android.currentContext; | ||
appModule.android.currentContext.startActivityForResult(intent, SCANNER_REQUEST_CODE); | ||
} else { | ||
@@ -90,0 +97,0 @@ // this is next to impossible |
{ | ||
"name": "nativescript-barcodescanner", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Scan QR/barcodes with a {N} app.", | ||
@@ -5,0 +5,0 @@ "main": "barcodescanner.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1268721
274