Add QR code scanning (#1)
This commit is contained in:
parent
a088005d07
commit
16d55af2ae
@ -21,8 +21,8 @@
|
|||||||
<preference name="android-minSdkVersion" value="21" />
|
<preference name="android-minSdkVersion" value="21" />
|
||||||
<preference name="android-targetSdkVersion" value="27" />
|
<preference name="android-targetSdkVersion" value="27" />
|
||||||
<allow-intent href="market:*" />
|
<allow-intent href="market:*" />
|
||||||
<preference name="HeaderColor" value="#F44336" />
|
<preference name="HeaderColor" value="#FF9800" />
|
||||||
<preference name="StatusBarBackgroundColor" value="#D32F2F" />
|
<preference name="StatusBarBackgroundColor" value="#F57C00" />
|
||||||
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
|
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
|
||||||
<application android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" />
|
<application android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" />
|
||||||
</edit-config>
|
</edit-config>
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cordova-android": "^8.0.0",
|
"cordova-android": "^8.0.0",
|
||||||
"cordova-plugin-app-version": "^0.1.9",
|
"cordova-plugin-app-version": "^0.1.9",
|
||||||
|
"cordova-plugin-barcodescanner": "^0.7.4",
|
||||||
|
"cordova-plugin-compat": "^1.2.0",
|
||||||
"cordova-plugin-headercolor": "^1.0.0",
|
"cordova-plugin-headercolor": "^1.0.0",
|
||||||
"cordova-plugin-inappbrowser": "^3.0.0",
|
"cordova-plugin-inappbrowser": "^3.0.0",
|
||||||
"cordova-plugin-statusbar": "^2.4.2",
|
"cordova-plugin-statusbar": "^2.4.2",
|
||||||
@ -23,7 +25,8 @@
|
|||||||
"cordova-plugin-statusbar": {},
|
"cordova-plugin-statusbar": {},
|
||||||
"cordova-plugin-headercolor": {},
|
"cordova-plugin-headercolor": {},
|
||||||
"cordova-plugin-app-version": {},
|
"cordova-plugin-app-version": {},
|
||||||
"cordova-plugin-inappbrowser": {}
|
"cordova-plugin-inappbrowser": {},
|
||||||
|
"cordova-plugin-barcodescanner": {}
|
||||||
},
|
},
|
||||||
"platforms": [
|
"platforms": [
|
||||||
"android"
|
"android"
|
||||||
|
@ -8,7 +8,7 @@ var accountBalance = 0.0;
|
|||||||
|
|
||||||
$(".view-main").on("ptr:refresh", ".ptr-content", function () {
|
$(".view-main").on("ptr:refresh", ".ptr-content", function () {
|
||||||
loadHomePage(function () {
|
loadHomePage(function () {
|
||||||
app.ptr.done();
|
setTimeout(app.ptr.done, 500);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ function loadQrCode(callback) {
|
|||||||
var typeNumber = 4;
|
var typeNumber = 4;
|
||||||
var errorCorrectionLevel = 'L';
|
var errorCorrectionLevel = 'L';
|
||||||
var qr = qrcode(typeNumber, errorCorrectionLevel);
|
var qr = qrcode(typeNumber, errorCorrectionLevel);
|
||||||
qr.addData('https://app.helpinghelena.org/?sendto=' + data.profile.publicid);
|
qr.addData(SETTINGS['webapp_url'] + '?sendto=' + data.profile.publicid);
|
||||||
qr.make();
|
qr.make();
|
||||||
var svg = qr.createSvgTag({
|
var svg = qr.createSvgTag({
|
||||||
margin: 6,
|
margin: 6,
|
||||||
|
@ -151,7 +151,7 @@ if (localStorage.getItem("configured") == null) {
|
|||||||
|
|
||||||
setupKeyRefresh();
|
setupKeyRefresh();
|
||||||
} else {
|
} else {
|
||||||
//router.navigate("/setup/0");
|
router.navigate("/setup/0");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ function initCordova() {
|
|||||||
|
|
||||||
document.addEventListener("deviceready", function () {
|
document.addEventListener("deviceready", function () {
|
||||||
if (cordova.platformId == 'android') {
|
if (cordova.platformId == 'android') {
|
||||||
StatusBar.backgroundColorByHexString("#D32F2F");
|
StatusBar.backgroundColorByHexString("#F57C00");
|
||||||
StatusBar.styleLightContent();
|
StatusBar.styleLightContent();
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
@ -23,6 +23,30 @@ $("#typecodebtn").on("click", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#scanqrcodebtn").on("click", function () {
|
||||||
|
cordova.plugins.barcodeScanner.scan(
|
||||||
|
function (result) {
|
||||||
|
if (!result.cancelled) {
|
||||||
|
console.log("Barcode: ", result);
|
||||||
|
if (result.format == "QR_CODE" && result.text.startsWith(SETTINGS['webapp_url'])) {
|
||||||
|
var url = new URL(result.text);
|
||||||
|
if (typeof url.searchParams.get("sendto") == "string") {
|
||||||
|
$("#publicid").val(url.searchParams.get("sendto"));
|
||||||
|
loadSendMoneyPage();
|
||||||
|
} else {
|
||||||
|
app.dialog.alert("Not a valid payment code.", "Scan Error");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
app.dialog.alert("Not a valid payment code.", "Scan Error");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
app.dialog.alert(error, "Scan Error");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
function sendMoney(id, amount, name) {
|
function sendMoney(id, amount, name) {
|
||||||
if (id == "0") {
|
if (id == "0") {
|
||||||
return;
|
return;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
{{#if @global.qrenabled}}
|
{{#if @global.qrenabled}}
|
||||||
<div class="col-100 tablet-50 desktop-25">
|
<div class="col-100 tablet-50 desktop-25">
|
||||||
<div class="button button-large button-fill button-round">
|
<div class="button button-large button-fill button-round" id="scanqrcodebtn">
|
||||||
<i class="fas fa-qrcode"></i> Scan Code
|
<i class="fas fa-qrcode"></i> Scan Code
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -8,5 +8,6 @@
|
|||||||
* Array of global settings.
|
* Array of global settings.
|
||||||
*/
|
*/
|
||||||
var SETTINGS = {
|
var SETTINGS = {
|
||||||
server: "http://localhost/helpinghelena/api"
|
server: "http://localhost/helpinghelena/api",
|
||||||
|
webapp_url: "https://app.helpinghelena.org/"
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user