Merge branch 'ref/design' of github.com:matiu/copay into ref/design

This commit is contained in:
Matias Alejo Garcia 2016-08-18 10:13:00 -03:00
commit 1f5e55efae
No known key found for this signature in database
GPG key ID: 02470DB551277AB3
12 changed files with 149 additions and 48 deletions

View file

@ -1061,6 +1061,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}); });
$rootScope.$on('Local/WalletImported', function(event, walletId) { $rootScope.$on('Local/WalletImported', function(event, walletId) {
console.log('[index.js:1063] walletImported'); //TODO
return;
self.needsBackup = false; self.needsBackup = false;
storageService.setBackupFlag(walletId, function() { storageService.setBackupFlag(walletId, function() {
$log.debug('Backup done stored'); $log.debug('Backup done stored');
@ -1322,6 +1324,8 @@ return;
lodash.each(['NewCopayer', 'CopayerUpdated'], function(eventName) { lodash.each(['NewCopayer', 'CopayerUpdated'], function(eventName) {
$rootScope.$on(eventName, function() { $rootScope.$on(eventName, function() {
console.log('[index.js:1324] NewCopayer, CopayerUpdated'); //TODO
return;
// Re try to open wallet (will triggers) // Re try to open wallet (will triggers)
self.setFocusedWallet(); self.setFocusedWallet();
}); });

View file

@ -1,9 +1,11 @@
<ion-view view-title="Create new wallet" ng-controller="createController as create" ng-init="create.setTotalCopayers(1)"> <ion-view view-title="Create new wallet">
<ion-nav-buttons side="primary"> <ion-nav-bar class="bar-stable">
<a href ui-sref="add" class="button icon-left ion-chevron-left button-clear button-dark">Add</a> <ion-nav-buttons side="primary">
</ion-nav-buttons> <a href ui-sref="add" class="button icon-left ion-chevron-left button-clear button-dark">Add</a>
</ion-nav-buttons>
</ion-nav-bar>
<ion-content> <ion-content ng-controller="createController as create" ng-init="create.setTotalCopayers(1)">
<div class="row" ng-hide="create.hideTabs"> <div class="row" ng-hide="create.hideTabs">
<div class="col"> <div class="col">

View file

@ -1,12 +1,11 @@
<ion-view view-title="Import wallet" ng-controller="importController" ng-init="type='12'"> <ion-view view-title="Import wallet">
<ion-nav-buttons side="primary"> <ion-nav-bar class="bar-stable">
<a href ui-sref="add" class="button icon-left ion-chevron-left button-clear button-dark">Add</a> <ion-nav-buttons side="primary">
</ion-nav-buttons> <a href ui-sref="add" class="button icon-left ion-chevron-left button-clear button-dark">Add</a>
<ion-nav-buttons side="secondary"> </ion-nav-buttons>
<qr-scanner class="button button-clear button-positive" on-scan="processWalletInfo(data)"></qr-scanner> </ion-nav-bar>
</ion-nav-buttons>
<ion-content> <ion-content ng-controller="importController" ng-init="type='12'">
<div class="row"> <div class="row">
<div class="col"> <div class="col">
@ -57,6 +56,7 @@
<form name="importForm12" ng-submit="importMnemonic(importForm12)" novalidate> <form name="importForm12" ng-submit="importMnemonic(importForm12)" novalidate>
<div class="list"> <div class="list">
<qr-scanner class="button button-clear button-positive" on-scan="processWalletInfo(data)"></qr-scanner>
<label class="item item-input item-stacked-label"> <label class="item item-input item-stacked-label">
<span class="input-label" translate>Type the Recovery Phrase (usually 12 words)</span> <span class="input-label" translate>Type the Recovery Phrase (usually 12 words)</span>
<textarea name="words" <textarea name="words"

View file

@ -1,12 +1,12 @@
<ion-view view-title="Join shared wallet" ng-controller="joinController as join"> <ion-view view-title="Join shared wallet">
<ion-nav-buttons side="primary"> <ion-nav-bar class="bar-stable">
<a href ui-sref="add" class="button icon-left ion-chevron-left button-clear button-dark">Add</a> <ion-nav-buttons side="primary">
</ion-nav-buttons> <a href ui-sref="add" class="button icon-left ion-chevron-left button-clear button-dark">Add</a>
<ion-nav-buttons side="secondary"> </ion-nav-buttons>
<qr-scanner class="button button-clear button-positive" on-scan="join.onQrCodeScanned(data)"></qr-scanner> </ion-nav-bar>
</ion-nav-buttons>
<ion-content>
<ion-content ng-controller="joinController as join">
<div class="padding assertive" ng-show="join.error"> <div class="padding assertive" ng-show="join.error">
{{join.error|translate}} {{join.error|translate}}
@ -25,6 +25,7 @@
ng-required="true"> ng-required="true">
</label> </label>
<qr-scanner class="button button-clear button-positive" on-scan="join.onQrCodeScanned(data)"></qr-scanner>
<label class="item item-input item-stacked-label"> <label class="item item-input item-stacked-label">
<span class="input-label"> <span class="input-label">
Wallet Invitation Wallet Invitation

View file

@ -2,7 +2,7 @@
<ion-nav-bar class="bar-stable"> <ion-nav-bar class="bar-stable">
<ion-nav-title>Scan</ion-nav-title> <ion-nav-title>Scan</ion-nav-title>
</ion-nav-bar> </ion-nav-bar>
<ion-content ng-controller="tabScanController" ng-init="init()"> <ion-content class="padding" ng-controller="tabScanController" ng-init="init()">
<canvas id="qr-canvas" width="200" height="150"></canvas> <canvas id="qr-canvas" width="200" height="150"></canvas>
<video id="qrcode-scanner-video" width="300" height="225"></video> <video id="qrcode-scanner-video" width="300" height="225"></video>

View file

@ -92,7 +92,7 @@ angular.module('copayApp.controllers').controller('copayersController',
} }
var wallet = profileService.getWallet($stateParams.walletId); var wallet = profileService.getWallet($stateParams.walletId);
var secret = wallet.status.wallet.secret; var secret;
try { try {
secret = wallet.status.wallet.secret; secret = wallet.status.wallet.secret;
} catch (e) {}; } catch (e) {};

View file

@ -166,7 +166,7 @@ angular.module('copayApp.controllers').controller('createController',
ongoingProcess.set('creatingWallet', true); ongoingProcess.set('creatingWallet', true);
$timeout(function() { $timeout(function() {
profileService.createWallet(opts, function(err, wallet) { profileService.createWallet(opts, function(err, client) {
ongoingProcess.set('creatingWallet', false); ongoingProcess.set('creatingWallet', false);
if (err) { if (err) {
$log.warn(err); $log.warn(err);
@ -177,8 +177,8 @@ angular.module('copayApp.controllers').controller('createController',
return; return;
} }
walletService.updateRemotePreferences(wallet, {}, function() { walletService.updateRemotePreferences(client, {}, function() {
$log.debug('Remote preferences saved for:' + wallet.walletId) $log.debug('Remote preferences saved for:' + client.credentials.walletId)
}); });

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('importController', angular.module('copayApp.controllers').controller('importController',
function($scope, $rootScope, $timeout, $log, profileService, configService, notification, go, sjcl, gettext, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess) { function($scope, $rootScope, $timeout, $log, profileService, configService, notification, go, sjcl, gettext, ledger, trezor, derivationPathHelper, platformInfo, bwcService, ongoingProcess, walletService) {
var isChromeApp = platformInfo.isChromeApp; var isChromeApp = platformInfo.isChromeApp;
var isDevel = platformInfo.isDevel; var isDevel = platformInfo.isDevel;
@ -95,7 +95,7 @@ angular.module('copayApp.controllers').controller('importController',
opts.password = null; opts.password = null;
$timeout(function() { $timeout(function() {
profileService.importWallet(str2, opts, function(err, wallet) { profileService.importWallet(str2, opts, function(err, client) {
ongoingProcess.set('importingWallet', false); ongoingProcess.set('importingWallet', false);
if (err) { if (err) {
$scope.error = err; $scope.error = err;
@ -103,11 +103,11 @@ angular.module('copayApp.controllers').controller('importController',
} }
walletService.updateRemotePreferences(wallet, {}, function() { walletService.updateRemotePreferences(client, {}, function() {
$log.debug('Remote preferences saved for:' + wallet.walletId) $log.debug('Remote preferences saved for:' + client.credentials.walletId)
}); });
$rootScope.$emit('Local/WalletImported', wallet.walletId); $rootScope.$emit('Local/WalletImported', client.credentials.walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome(); go.walletHome();
}); });
@ -117,7 +117,7 @@ angular.module('copayApp.controllers').controller('importController',
var _importExtendedPrivateKey = function(xPrivKey, opts) { var _importExtendedPrivateKey = function(xPrivKey, opts) {
ongoingProcess.set('importingWallet', true); ongoingProcess.set('importingWallet', true);
$timeout(function() { $timeout(function() {
profileService.importExtendedPrivateKey(xPrivKey, opts, function(err, wallet) { profileService.importExtendedPrivateKey(xPrivKey, opts, function(err, client) {
ongoingProcess.set('importingWallet', false); ongoingProcess.set('importingWallet', false);
if (err) { if (err) {
if (err instanceof errors.NOT_AUTHORIZED) { if (err instanceof errors.NOT_AUTHORIZED) {
@ -131,11 +131,11 @@ angular.module('copayApp.controllers').controller('importController',
} }
walletService.updateRemotePreferences(wallet, {}, function() { walletService.updateRemotePreferences(client, {}, function() {
$log.debug('Remote preferences saved for:' + wallet.walletId) $log.debug('Remote preferences saved for:' + client.credentials.walletId)
}); });
$rootScope.$emit('Local/WalletImported', wallet.walletId); $rootScope.$emit('Local/WalletImported', client.credentials.walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome(); go.walletHome();
}); });
@ -168,7 +168,7 @@ angular.module('copayApp.controllers').controller('importController',
ongoingProcess.set('importingWallet', true); ongoingProcess.set('importingWallet', true);
$timeout(function() { $timeout(function() {
profileService.importMnemonic(words, opts, function(err, wallet) { profileService.importMnemonic(words, opts, function(err, client) {
ongoingProcess.set('importingWallet', false); ongoingProcess.set('importingWallet', false);
if (err) { if (err) {
@ -182,11 +182,11 @@ angular.module('copayApp.controllers').controller('importController',
}); });
} }
walletService.updateRemotePreferences(wallet, {}, function() { walletService.updateRemotePreferences(client, {}, function() {
$log.debug('Remote preferences saved for:' + wallet.walletId) $log.debug('Remote preferences saved for:' + client.credentials.walletId)
}); });
$rootScope.$emit('Local/WalletImported', wallet.walletId); $rootScope.$emit('Local/WalletImported', client.credentials.walletId);
notification.success(gettext('Success'), gettext('Your wallet has been imported correctly')); notification.success(gettext('Success'), gettext('Your wallet has been imported correctly'));
go.walletHome(); go.walletHome();
}); });

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('joinController', angular.module('copayApp.controllers').controller('joinController',
function($scope, $rootScope, $timeout, go, notification, profileService, configService, storageService, applicationService, gettext, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess) { function($scope, $rootScope, $timeout, go, notification, profileService, configService, storageService, applicationService, gettext, lodash, ledger, trezor, platformInfo, derivationPathHelper, ongoingProcess, walletService, $log) {
var isChromeApp = platformInfo.isChromeApp; var isChromeApp = platformInfo.isChromeApp;
var isDevel = platformInfo.isDevel; var isDevel = platformInfo.isDevel;
@ -128,7 +128,7 @@ angular.module('copayApp.controllers').controller('joinController',
this._join = function(opts) { this._join = function(opts) {
ongoingProcess.set('joiningWallet', true); ongoingProcess.set('joiningWallet', true);
$timeout(function() { $timeout(function() {
profileService.joinWallet(opts, function(err, wallet) { profileService.joinWallet(opts, function(err, client) {
ongoingProcess.set('joiningWallet', false); ongoingProcess.set('joiningWallet', false);
if (err) { if (err) {
self.error = err; self.error = err;
@ -136,8 +136,8 @@ angular.module('copayApp.controllers').controller('joinController',
return; return;
} }
walletService.updateRemotePreferences(wallet, {}, function() { walletService.updateRemotePreferences(client, {}, function() {
$log.debug('Remote preferences saved for:' + wallet.walletId) $log.debug('Remote preferences saved for:' + client.credentials.walletId)
}); });
go.walletHome(); go.walletHome();

View file

@ -1,11 +1,91 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('tabScanController', function($scope, $timeout, $ionicModal, gettextCatalog, platformInfo) { angular.module('copayApp.controllers').controller('tabScanController', function($scope, $timeout, $ionicModal, $log, $ionicPopup, configService, gettextCatalog, platformInfo, go, bitcore, lodash) {
var isCordova = platformInfo.isCordova; var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP; var isWP = platformInfo.isWP;
var isIOS = platformInfo.isIOS; var isIOS = platformInfo.isIOS;
var config = configService.getSync();
var configWallet = config.wallet;
var walletSettings = configWallet.settings;
var unitToSatoshi = walletSettings.unitToSatoshi;
var unitDecimals = walletSettings.unitDecimals;
var satToUnit = 1 / unitToSatoshi;
var _showAlert = function(title, msg, cb) {
$log.warn(title + ":"+ msg);
var alertPopup = $ionicPopup.alert({
title: title,
template: msg
});
if (!cb) cb = function(res) {};
alertPopup.then(cb);
};
var _dataScanned = function(data) {
var parsedData = _parseFromUri(data);
if (lodash.isEmpty(parsedData)) {
_showAlert('Bad bitcoin address', 'Could not recognize the bitcoin address', function(res) {
$scope.init();
});
return;
}
go.confirm(parsedData);
};
var _parseFromUri = function(uri) {
function sanitizeUri(uri) {
// Fixes when a region uses comma to separate decimals
var regex = /[\?\&]amount=(\d+([\,\.]\d+)?)/i;
var match = regex.exec(uri);
if (!match || match.length === 0) {
return uri;
}
var value = match[0].replace(',', '.');
var newUri = uri.replace(regex, value);
return newUri;
};
var satToUnit = 1 / unitToSatoshi;
// URI extensions for Payment Protocol with non-backwards-compatible request
if ((/^bitcoin:\?r=[\w+]/).exec(uri)) {
// TODO: PAYPRO
} else {
uri = sanitizeUri(uri);
if (!bitcore.URI.isValid(uri)) {
return uri;
}
var parsed = new bitcore.URI(uri);
var addr = parsed.address ? parsed.address.toString() : '';
var message = parsed.message;
var amount = parsed.amount ?
(parsed.amount.toFixed(0) * satToUnit).toFixed(unitDecimals) : 0;
if (parsed.r) {
// TODO: PAYPRO
} else {
// TODO: message
return {
toAddress: addr,
toAmount: amount
};
}
}
};
var onSuccess = function(result) { var onSuccess = function(result) {
$timeout(function() { $timeout(function() {
window.plugins.spinnerDialog.hide(); window.plugins.spinnerDialog.hide();
@ -14,6 +94,11 @@ angular.module('copayApp.controllers').controller('tabScanController', function(
$timeout(function() { $timeout(function() {
var data = isIOS ? result : result.text; var data = isIOS ? result : result.text;
// Check if the current page is tabs.scan
if (go.is('tabs.scan')) {
_dataScanned(data);
return;
}
$scope.onScan({ $scope.onScan({
data: data data: data
}); });
@ -103,7 +188,12 @@ angular.module('copayApp.controllers').controller('tabScanController', function(
prevResult = data; prevResult = data;
return; return;
} }
// Check if the current page is tabs.scan
_scanStop(); _scanStop();
if (go.is('tabs.scan')) {
_dataScanned(data);
return;
}
$scope.cancel(); $scope.cancel();
$scope.onScan({ $scope.onScan({
data: data data: data

View file

@ -32,13 +32,17 @@ angular.module('copayApp.services').factory('go', function($window, $ionicSideMe
root.walletHome = function() { root.walletHome = function() {
var fc = profileService.focusedClient; var fc = profileService.focusedClient;
if (fc && !fc.isComplete()) { if (fc && !fc.isComplete()) {
$log.debug("Wallet not complete at startup... redirecting") $log.debug("Wallet not complete at startup... redirecting");
root.path('copayers'); $state.transitionTo('wallet.details', {walletId: fc.credentials.walletId})
} else { } else {
root.path('tabs.home'); root.path('tabs.home');
} }
}; };
root.confirm = function(params) {
$state.transitionTo('confirm', params)
};
root.send = function() { root.send = function() {
root.path('tabs.send'); root.path('tabs.send');
}; };

View file

@ -540,7 +540,7 @@ angular.module('copayApp.services')
var config = configService.getSync(); var config = configService.getSync();
if (config.pushNotifications.enabled) if (config.pushNotifications.enabled)
pushNotificationsService.enableNotifications(root.wallet); pushNotificationsService.enableNotifications(root.wallet);
return cb(err, walletClient); return cb(err, client);
}); });
}); });
}); });