Merge pull request #936 from yemel/feature/android-cordova
Android - Migration to Cordova + Crosswalk Framework
This commit is contained in:
commit
560702df58
51 changed files with 4706 additions and 12 deletions
|
|
@ -32,6 +32,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
|
||||
// Detect protocol
|
||||
$scope.isHttp = ($window.location.protocol.indexOf('http') === 0);
|
||||
$scope.isCordova = typeof(window.cordova) != 'undefined';
|
||||
|
||||
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
|
||||
window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
|
||||
|
|
@ -194,6 +195,25 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
}, 500);
|
||||
};
|
||||
|
||||
$scope.scannerIntent = function() {
|
||||
cordova.plugins.barcodeScanner.scan(
|
||||
function onSuccess(result) {
|
||||
if (result.cancelled) return;
|
||||
|
||||
var bip21 = copay.Structure.parseBitcoinURI(result.text);
|
||||
$scope.address = bip21.address;
|
||||
|
||||
if (bip21.amount) {
|
||||
$scope.amount = bip21.amount * bitcore.util.COIN * satToUnit;
|
||||
}
|
||||
|
||||
$rootScope.$digest();
|
||||
},
|
||||
function onError(error) {
|
||||
alert('Scanning error');
|
||||
});
|
||||
}
|
||||
|
||||
$scope.toggleAddressBookEntry = function(key) {
|
||||
var w = $rootScope.wallet;
|
||||
w.toggleAddressBookEntry(key);
|
||||
|
|
|
|||
|
|
@ -59,13 +59,16 @@ Structure.parseBitcoinURI = function(uri) {
|
|||
data = splitDots[1];
|
||||
var splitQuestion = data.split('?');
|
||||
ret.address = splitQuestion[0];
|
||||
var search = splitQuestion[1];
|
||||
data = JSON.parse('{"' + search.replace(/&/g, '","').replace(/=/g, '":"') + '"}',
|
||||
function(key, value) {
|
||||
return key === "" ? value : decodeURIComponent(value);
|
||||
});
|
||||
ret.amount = parseFloat(data.amount);
|
||||
ret.message = data.message;
|
||||
|
||||
if (splitQuestion.length > 1) {
|
||||
var search = splitQuestion[1];
|
||||
data = JSON.parse('{"' + search.replace(/&/g, '","').replace(/=/g, '":"') + '"}',
|
||||
function(key, value) {
|
||||
return key === "" ? value : decodeURIComponent(value);
|
||||
});
|
||||
ret.amount = parseFloat(data.amount);
|
||||
ret.message = data.message;
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -30,13 +30,14 @@ BackupService.prototype.download = function(wallet) {
|
|||
}
|
||||
|
||||
// throw an email intent if we are in the mobile version
|
||||
if (window.xwalk) {
|
||||
if (window.cordova) {
|
||||
var name = wallet.name ? wallet.name + ' ' : '';
|
||||
var partial = partial ? 'Partial ' : '';
|
||||
var subject = 'Copay - ' + name + 'Wallet ' + partial + 'Backup';
|
||||
var body = 'This is the encrypted backup of the wallet ' + wallet.id + ':\n\n' + ew;
|
||||
var mailURL = encodeURI('mailto:?subject=' + subject + '&body=' + body);
|
||||
return window.open(mailURL,'_blank');
|
||||
return window.plugin.email.open({
|
||||
subject: 'Copay - ' + name + 'Wallet ' + partial + 'Backup',
|
||||
body: 'Here is the encrypted backup of the wallet ' + wallet.id,
|
||||
attachments: ['base64:' + filename + '//' + btoa(ew)]
|
||||
});
|
||||
}
|
||||
|
||||
// otherwise lean on the browser implementation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue