Use cordova-plugin-camera for notice slips due to bugs in document-scanner

This commit is contained in:
Skylar Ittner 2021-02-06 23:15:30 -07:00
parent 5bc7bcc808
commit 5685b924f7
5 changed files with 39 additions and 26 deletions

View File

@ -75,9 +75,9 @@
<allow-intent href="itms-apps:*" />
<preference name="scheme" value="app" />
<preference name="hostname" value="localhost" />
<config-file platform="ios" target="*-Info.plist" parent="NSCameraUsageDescription">
<edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="merge">
<string>Camera is used to scan receipts and redelivery notice slips</string>
</config-file>
</edit-config>
<splash src="res/ios/splash/Default@2x~universal~anyany.png" />
<splash src="res/ios/splash/Default@2x~universal~anyany~dark.png" />

12
package-lock.json generated
View File

@ -611,17 +611,17 @@
"recursive-readdir": "^2.2.2"
}
},
"cordova-plugin-camera": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/cordova-plugin-camera/-/cordova-plugin-camera-5.0.1.tgz",
"integrity": "sha512-9gXyZvI8u9KzsZuqmB8Yw+uheF+7f+usMAwvOMw7L7pqbykg+bm9US5zjhJbwit3A1cSblgZkpBafe5cFiMcTA==",
"dev": true
},
"cordova-plugin-device": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/cordova-plugin-device/-/cordova-plugin-device-2.0.3.tgz",
"integrity": "sha1-wrQbfv0EVd0Jf4k1bYW/3V2t6w8="
},
"cordova-plugin-document-scanner": {
"version": "5.0.0-beta.0",
"resolved": "https://registry.npmjs.org/cordova-plugin-document-scanner/-/cordova-plugin-document-scanner-5.0.0-beta.0.tgz",
"integrity": "sha512-ydBWR06fwAIKah3HQbp+ZwfCsVReebGpBVBKM53ff46rplW4WNK9pLubg02qRmByUdNwalSVZ0ugns8pGhlwRg==",
"dev": true
},
"cordova-plugin-headercolor": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/cordova-plugin-headercolor/-/cordova-plugin-headercolor-1.0.0.tgz",

View File

@ -28,13 +28,12 @@
"cordova-plugin-headercolor": {},
"cordova-plugin-theme-detection": {},
"cordova-plugin-nativestorage": {},
"cordova-plugin-document-scanner": {
"CAMERA_USAGE_DESCRIPTION": "This app needs camera access",
"PHOTOLIBRARY_USAGE_DESCRIPTION": "This app needs read/write-access photo library access"
},
"cordova-plugin-androidx": {},
"cordova-plugin-androidx-adapter": {},
"cordova-plugin-splashscreen": {}
"cordova-plugin-splashscreen": {},
"cordova-plugin-camera": {
"ANDROID_SUPPORT_V4_VERSION": "27.+"
}
},
"platforms": [
"browser",
@ -56,7 +55,7 @@
"cordova-plugin-add-swift-support": "^2.0.2",
"cordova-plugin-androidx": "^3.0.0",
"cordova-plugin-androidx-adapter": "^1.1.3",
"cordova-plugin-document-scanner": "^5.0.0-beta.0",
"cordova-plugin-camera": "^5.0.1",
"cordova-plugin-nativestorage": "^2.3.2",
"cordova-plugin-splashscreen": "^6.0.0"
}

View File

@ -45,7 +45,7 @@ function initNoticeSlipForm() {
function takeDocPhoto(side) {
try {
scan.scanDoc(function (img) {
navigator.camera.getPicture(function (img) {
if (side == "front") {
frontSlipImg = "data:image/jpg;base64," + img;
$("#noticefrontimg").attr("src", frontSlipImg);
@ -54,12 +54,31 @@ function takeDocPhoto(side) {
$("#noticebackimg").attr("src", backSlipImg);
}
}, function (err) {
app.dialog.alert(err, "Error");
}, {
sourceType: 1,
quality: 3,
returnBase64: true
quality: 80,
targetWidth: 1000,
destinationType: Camera.DestinationType.DATA_URL,
encodingType: Camera.EncodingType.JPEG,
saveToPhotoAlbum: false,
cameraDirection: Camera.Direction.BACK
});
// cordova-plugin-document-scanner was removed because the plugin is buggy.
// scan.scanDoc(function (img) {
// if (side == "front") {
// frontSlipImg = "data:image/jpg;base64," + img;
// $("#noticefrontimg").attr("src", frontSlipImg);
// } else if (side == "back") {
// backSlipImg = "data:image/jpg;base64," + img;
// $("#noticebackimg").attr("src", backSlipImg);
// }
// }, function (err) {
//
// }, {
// sourceType: 1,
// quality: 3,
// returnBase64: true
// });
} catch (ex) {
app.dialog.alert("Looks like you can't do that with this device.", "Whoops!");
}
@ -228,9 +247,4 @@ $("#app").on("click", "#signatureUndoBtn", function () {
data.pop(); // remove the last dot or line
signaturePad.fromData(data);
}
});
//$(window).on("resize", function () {
// if (signaturePad != null) {
// resizeCanvas(document.getElementById("signaturecanvas"));
// }
//});
});

View File

@ -60,7 +60,7 @@
</ul>
</div>
<div class="block">
Press the buttons to take a photo of the front and back of your signed notice slip. You'll be able to adjust the photo to ensure the image is clear.
Press the buttons to take a photo of the front and back of your signed notice slip.
<div class="row" style="min-height: 100px;">
<div class="col-50">