Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WM-6309]-Add:changes #414

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,3 @@ npm-debug.log*
# Dependency directories
node_modules/

# generated files
dist/
src/browser/plugin.min.js
www/www.min.js
2 changes: 2 additions & 0 deletions dist/cordova-plugin-qrscanner-lib.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/cordova-plugin-qrscanner-lib.min.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
</feature>
</config-file>
<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.CAMERA" android:required="false" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.front" android:required="false" />
</config-file>
Expand Down
2 changes: 1 addition & 1 deletion src/android/QRScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.json.JSONObject;
import android.hardware.Camera;
import android.provider.Settings;
import android.support.v4.app.ActivityCompat;
import androidx.core.app.ActivityCompat;
import android.view.ViewGroup;
import android.widget.FrameLayout;

Expand Down
4 changes: 2 additions & 2 deletions src/android/qrscanner.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ repositories {
}

dependencies {
compile 'com.journeyapps:zxing-android-embedded:3.3.0'
compile 'com.android.support:appcompat-v7:23.1.0'
implementation 'com.journeyapps:zxing-android-embedded:3.3.0'
implementation 'com.android.support:appcompat-v7:23.1.0'
}

android {
Expand Down
344 changes: 344 additions & 0 deletions www/www.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,344 @@
cordova.define("cordova-plugin-qrscanner.QRScanner", function(require, exports, module) {
// This file is generated by `npm run build`.

/*global exports:false*/
/*jshint unused:false */
// remap parameter names from cordova.define
// see `externals` in webpack.cordova.config.js
var cordovaRequire = require;
var cordovaExports = exports;
var cordovaModule = module;
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 18);
/******/ })
/************************************************************************/
/******/ ({

/***/ 1:
/***/ (function(module, exports) {

module.exports = cordovaModule;

/***/ }),

/***/ 18:
/***/ (function(module, exports, __webpack_require__) {

var globalCordova = __webpack_require__(4);
var cordovaModule = __webpack_require__(1);

var createQRScannerAdapter = __webpack_require__(3);

// pass in global cordova object to expose cordova.exec
var QRScannerAdapter = createQRScannerAdapter(globalCordova);
cordovaModule.exports = QRScannerAdapter;


/***/ }),

/***/ 3:
/***/ (function(module, exports) {

module.exports = function createQRScanner(cordova){
// The native implementations should return their status as ['string':'string']
// dictionaries. Boolean values are encoded to '0' and '1', respectively.
function stringToBool(string) {
switch (string) {
case '1':
return true;
case '0':
return false;
default:
throw new Error('QRScanner plugin returned an invalid boolean number-string: ' + string);
}
}

// Converts the returned ['string':'string'] dictionary to a status object.
function convertStatus(statusDictionary) {
return {
authorized: stringToBool(statusDictionary.authorized),
denied: stringToBool(statusDictionary.denied),
restricted: stringToBool(statusDictionary.restricted),
prepared: stringToBool(statusDictionary.prepared),
scanning: stringToBool(statusDictionary.scanning),
previewing: stringToBool(statusDictionary.previewing),
showing: stringToBool(statusDictionary.showing),
lightEnabled: stringToBool(statusDictionary.lightEnabled),
canOpenSettings: stringToBool(statusDictionary.canOpenSettings),
canEnableLight: stringToBool(statusDictionary.canEnableLight),
canChangeCamera: stringToBool(statusDictionary.canChangeCamera),
currentCamera: parseInt(statusDictionary.currentCamera)
};
}

// Simple utility method to ensure the background is transparent. Used by the
// plugin to force re-rendering immediately after the native webview background
// is made transparent.
function clearBackground() {
var body = document.body;
if (body.style) {
body.style.backgroundColor = 'rgba(0,0,0,0.01)';
body.style.backgroundImage = '';
setTimeout(function() {
body.style.backgroundColor = 'transparent';
}, 1);
if (body.parentNode && body.parentNode.style) {
body.parentNode.style.backgroundColor = 'transparent';
body.parentNode.style.backgroundImage = '';
}
}
}

function errorCallback(callback) {
if (!callback) {
return null;
}
return function(error) {
var errorCode = parseInt(error);
var QRScannerError = {};
switch (errorCode) {
case 0:
QRScannerError = {
name: 'UNEXPECTED_ERROR',
code: 0,
_message: 'QRScanner experienced an unexpected error.'
};
break;
case 1:
QRScannerError = {
name: 'CAMERA_ACCESS_DENIED',
code: 1,
_message: 'The user denied camera access.'
};
break;
case 2:
QRScannerError = {
name: 'CAMERA_ACCESS_RESTRICTED',
code: 2,
_message: 'Camera access is restricted.'
};
break;
case 3:
QRScannerError = {
name: 'BACK_CAMERA_UNAVAILABLE',
code: 3,
_message: 'The back camera is unavailable.'
};
break;
case 4:
QRScannerError = {
name: 'FRONT_CAMERA_UNAVAILABLE',
code: 4,
_message: 'The front camera is unavailable.'
};
break;
case 5:
QRScannerError = {
name: 'CAMERA_UNAVAILABLE',
code: 5,
_message: 'The camera is unavailable.'
};
break;
case 6:
QRScannerError = {
name: 'SCAN_CANCELED',
code: 6,
_message: 'Scan was canceled.'
};
break;
case 7:
QRScannerError = {
name: 'LIGHT_UNAVAILABLE',
code: 7,
_message: 'The device light is unavailable.'
};
break;
case 8:
// Open settings is only available on iOS 8.0+.
QRScannerError = {
name: 'OPEN_SETTINGS_UNAVAILABLE',
code: 8,
_message: 'The device is unable to open settings.'
};
break;
default:
QRScannerError = {
name: 'UNEXPECTED_ERROR',
code: 0,
_message: 'QRScanner returned an invalid error code.'
};
break;
}
callback(QRScannerError);
};
}

function successCallback(callback) {
if (!callback) {
return null;
}
return function(statusDict) {
callback(null, convertStatus(statusDict));
};
}

function doneCallback(callback, clear) {
if (!callback) {
return null;
}
return function(statusDict) {
if (clear) {
clearBackground();
}
callback(convertStatus(statusDict));
};
}

return {
prepare: function(callback) {
cordova.exec(successCallback(callback), errorCallback(callback), 'QRScanner', 'prepare', []);
},
destroy: function(callback) {
cordova.exec(doneCallback(callback, true), null, 'QRScanner', 'destroy', []);
},
scan: function(callback) {
if (!callback) {
throw new Error('No callback provided to scan method.');
}
var success = function(result) {
callback(null, result);
};
cordova.exec(success, errorCallback(callback), 'QRScanner', 'scan', []);
},
cancelScan: function(callback) {
cordova.exec(doneCallback(callback), null, 'QRScanner', 'cancelScan', []);
},
show: function(callback) {
cordova.exec(doneCallback(callback, true), null, 'QRScanner', 'show', []);
},
hide: function(callback) {
cordova.exec(doneCallback(callback, true), null, 'QRScanner', 'hide', []);
},
pausePreview: function(callback) {
cordova.exec(doneCallback(callback), null, 'QRScanner', 'pausePreview', []);
},
resumePreview: function(callback) {
cordova.exec(doneCallback(callback), null, 'QRScanner', 'resumePreview', []);
},
enableLight: function(callback) {
cordova.exec(successCallback(callback), errorCallback(callback), 'QRScanner', 'enableLight', []);
},
disableLight: function(callback) {
cordova.exec(successCallback(callback), errorCallback(callback), 'QRScanner', 'disableLight', []);
},
useCamera: function(index, callback) {
cordova.exec(successCallback(callback), errorCallback(callback), 'QRScanner', 'useCamera', [index]);
},
useFrontCamera: function(callback) {
var frontCamera = 1;
if (callback) {
this.useCamera(frontCamera, callback);
} else {
cordova.exec(null, null, 'QRScanner', 'useCamera', [frontCamera]);
}
},
useBackCamera: function(callback) {
var backCamera = 0;
if (callback) {
this.useCamera(backCamera, callback);
} else {
cordova.exec(null, null, 'QRScanner', 'useCamera', [backCamera]);
}
},
openSettings: function(callback) {
if (callback) {
cordova.exec(successCallback(callback), errorCallback(callback), 'QRScanner', 'openSettings', []);
} else {
cordova.exec(null, null, 'QRScanner', 'openSettings', []);
}
},
getStatus: function(callback) {
if (!callback) {
throw new Error('No callback provided to getStatus method.');
}
cordova.exec(doneCallback(callback), null, 'QRScanner', 'getStatus', []);
}
};
};


/***/ }),

/***/ 4:
/***/ (function(module, exports) {

module.exports = cordova;

/***/ })

/******/ });
});