Merge branch 'ref/design' of https://github.com/bitpay/bitpay-wallet into feature/onboarding_push_notifications

# Conflicts:
#	public/views/onboarding/notifications.html
#	src/js/controllers/onboarding/collectEmail.js
This commit is contained in:
Jamal Jackson 2016-09-14 11:42:33 -04:00
commit fdb5e467b9
28 changed files with 150 additions and 59 deletions

View file

@ -120,6 +120,7 @@ module.exports = function(grunt) {
'bower_components/ng-csv/build/ng-csv.js', 'bower_components/ng-csv/build/ng-csv.js',
'bower_components/ionic-toast/dist/ionic-toast.bundle.min.js', 'bower_components/ionic-toast/dist/ionic-toast.bundle.min.js',
'bower_components/angular-clipboard/angular-clipboard.js', 'bower_components/angular-clipboard/angular-clipboard.js',
'bower_components/angular-md5/angular-md5.js',
'bower_components/angular-mocks/angular-mocks.js', 'bower_components/angular-mocks/angular-mocks.js',
'angular-pbkdf2/angular-pbkdf2.js', 'angular-pbkdf2/angular-pbkdf2.js',
'angular-bitcore-wallet-client/angular-bitcore-wallet-client.js' 'angular-bitcore-wallet-client/angular-bitcore-wallet-client.js'

View file

@ -18,7 +18,8 @@
"trezor-connect": "~1.0.1", "trezor-connect": "~1.0.1",
"ng-csv": "~0.3.6", "ng-csv": "~0.3.6",
"ionic-toast": "^0.4.1", "ionic-toast": "^0.4.1",
"angular-clipboard": "^1.4.2" "angular-clipboard": "^1.4.2",
"angular-md5": "^0.1.10"
}, },
"resolutions": { "resolutions": {
"angular": "1.5.3" "angular": "1.5.3"

View file

@ -29,10 +29,11 @@
<ion-list> <ion-list>
<ion-item ng-repeat="addrEntry in addressbook" <ion-item ng-repeat="addrEntry in addressbook"
class="item-icon-left item-icon-right" class="item-icon-right item-avatar"
ui-sref="tabs.addressbook.view({address:addrEntry.address})"> ui-sref="tabs.addressbook.view({address:addrEntry.address})">
<i class="icon ion-ios-person-outline"></i> <gravatar name="{{addrEntry.name}}" width="50" email="{{addrEntry.email}}"></gravatar>
{{addrEntry.name}} <h2>{{addrEntry.name}}</h2>
<p>{{addrEntry.address}}</p>
<i class="icon nav-item-arrow-right"></i> <i class="icon nav-item-arrow-right"></i>
<ion-option-button class="button-assertive" ng-click="remove(addrEntry.address)"> <ion-option-button class="button-assertive" ng-click="remove(addrEntry.address)">

View file

@ -12,6 +12,10 @@
<ion-content> <ion-content>
<div class="gravatar-content">
<gravatar name="{{addressbookEntry.name}}" width="80" email="{{addressbookEntry.email}}"></gravatar>
</div>
<div class="card"> <div class="card">
<div class="item item-text-wrap"> <div class="item item-text-wrap">
<h3 translate>Name</h3> <h3 translate>Name</h3>

View file

@ -13,7 +13,7 @@
<div class="item item-no-bottom-border" translate>Recipient</div> <div class="item item-no-bottom-border" translate>Recipient</div>
<div class="item item-text-wrap item-icon-left bitcoin-address"> <div class="item item-text-wrap item-icon-left bitcoin-address">
<i class="icon ion-ios-person-outline"></i> <gravatar class="send-gravatar" name="{{toName}}" width="30" email="{{toEmail}}"></gravatar>
<span>{{toName || toAddress}}</span> <span>{{toName || toAddress}}</span>
</div> </div>
</div> </div>

View file

@ -1,4 +1,4 @@
<ion-view> <ion-view id="view-confirm">
<ion-nav-bar class="bar-royal"> <ion-nav-bar class="bar-royal">
<ion-nav-back-button> <ion-nav-back-button>
<i class="icon ion-ios-arrow-thin-left"></i> <i class="icon ion-ios-arrow-thin-left"></i>
@ -23,7 +23,7 @@
</div> </div>
<div class="item item-icon-left"> <div class="item item-icon-left">
<i class="icon ion-ios-person-outline"></i> <gravatar class="send-gravatar" name="{{toName}}" width="30" email="{{toEmail}}"></gravatar>
<label translate>To</label> {{toAddress}} <label translate>To</label> {{toAddress}}
<p ng-show="toName">{{toName}}</p> <p ng-show="toName">{{toName}}</p>

View file

@ -1,5 +1,5 @@
<ion-view id="onboarding-backup-request" class="onboarding"> <ion-view id="onboarding-backup-request" class="onboarding">
<ion-content ng-controller="backupRequestController"> <ion-content ng-controller="backupRequestController" scroll="false">
<div class="row"> <div class="row">
<img src="img/onboarding-warning.svg" class="col col-75 warning"> <img src="img/onboarding-warning.svg" class="col col-75 warning">
</div> </div>

View file

@ -6,7 +6,7 @@
</button> </button>
</ion-nav-buttons> </ion-nav-buttons>
</ion-nav-bar> </ion-nav-bar>
<ion-content> <ion-content scroll="false">
<div class="row text-center"> <div class="row text-center">
<h3 translate class="col col-80"> <h3 translate class="col col-80">
Are you being watched? Are you being watched?

View file

@ -40,7 +40,7 @@
</div> </div>
</div> </div>
<div class="overlay collect-overlay"> <div class="overlay collect-overlay">
<button class="button button-stable button-clear" ng-click="onboardingMailSkip()"> <button class="button button-stable button-clear" ng-click="goNextView()">
{{'Skip' | translate}} {{'Skip' | translate}}
</button> </button>
</div> </div>

View file

@ -1,5 +1,5 @@
<ion-view id="onboarding-disclaimer" class="onboarding"> <ion-view id="onboarding-disclaimer" class="onboarding">
<ion-content ng-controller="disclaimerController" ng-init=init()> <ion-content ng-controller="disclaimerController" ng-init=init() scroll="false">
<div class="row text-center"> <div class="row text-center">
<h3 translate class="col-75 col">Almost done! Let's review</h3> <h3 translate class="col-75 col">Almost done! Let's review</h3>
</div> </div>

View file

@ -14,7 +14,7 @@
</ion-nav-bar> </ion-nav-bar>
<ion-slides class="slides" options="options" slider="data.slider"> <ion-slides class="slides" options="options" slider="data.slider">
<ion-slide-page> <ion-slide-page>
<ion-content id="onboard-tour-secure"> <ion-content id="onboard-tour-secure" scroll="false">
<div class="text-center row"> <div class="text-center row">
<h2 class="col col-60" translate>Bitcoin is secure, digital money</h2> <h2 class="col col-60" translate>Bitcoin is secure, digital money</h2>
</div> </div>
@ -38,7 +38,7 @@
</ion-content> </ion-content>
</ion-slide-page> </ion-slide-page>
<ion-slide-page> <ion-slide-page>
<ion-content id="onboard-tour-currency"> <ion-content id="onboard-tour-currency" scroll="false">
<div class="text-center row"> <div class="text-center row">
<h2 class="col col-75" translate>Bitcoin is a currency</h2> <h2 class="col col-75" translate>Bitcoin is a currency</h2>
</div> </div>
@ -62,7 +62,7 @@
</ion-content> </ion-content>
</ion-slide-page> </ion-slide-page>
<ion-slide-page> <ion-slide-page>
<ion-content id="onboard-tour-control"> <ion-content id="onboard-tour-control" scroll="false">
<div class="text-center row"> <div class="text-center row">
<h2 translate class="col col-75">You control your bitcoin</h2> <h2 translate class="col col-75">You control your bitcoin</h2>
</div> </div>

View file

@ -1,5 +1,5 @@
<ion-view id="onboard-welcome" class="onboarding"> <ion-view id="onboard-welcome" class="onboarding">
<ion-content ng-controller="welcomeController" ng-init="createProfile()"> <ion-content ng-controller="welcomeController" ng-init="createProfile()" scroll="false">
<qr-scanner id="shopping-24" on-scan="goImport(data)"></qr-scanner> <qr-scanner id="shopping-24" on-scan="goImport(data)"></qr-scanner>
<article id="logo-tagline"> <article id="logo-tagline">
<div class="row text-center"> <div class="row text-center">

View file

@ -24,7 +24,7 @@
<div class="item text-center" ng-show="!list[0]" translate>No Wallet - Contact</div> <div class="item text-center" ng-show="!list[0]" translate>No Wallet - Contact</div>
<a class="item item-icon-left" ng-repeat="item in list" ng-click="goToAmount(item)"> <a class="item item-icon-left" ng-repeat="item in list" ng-click="goToAmount(item)">
<i ng-show="item.isWallet" class="icon ion-briefcase size-21" ng-style="{'color':item.color}"></i> <i ng-show="item.isWallet" class="icon ion-briefcase size-21" ng-style="{'color':item.color}"></i>
<i ng-show="!item.isWallet" class="icon ion-ios-person-outline"></i> <gravatar class="send-gravatar" ng-show="!item.isWallet" name="{{item.name}}" width="30" email="{{item.email}}"></gravatar>
{{item.name}} {{item.name}}
</a> </a>
</div> </div>

View file

@ -9,6 +9,7 @@ var modules = [
'angular-clipboard', 'angular-clipboard',
'ngLodash', 'ngLodash',
'ngCsv', 'ngCsv',
'angular-md5',
'bwcModule', 'bwcModule',
'pbkdf2Module', 'pbkdf2Module',
'copayApp.filters', 'copayApp.filters',

View file

@ -50,6 +50,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
$scope.toAddress = $stateParams.toAddress; $scope.toAddress = $stateParams.toAddress;
$scope.toName = $stateParams.toName; $scope.toName = $stateParams.toName;
$scope.toEmail = $stateParams.toEmail;
var config = configService.getSync().wallet.settings; var config = configService.getSync().wallet.settings;
$scope.unitName = config.unitName; $scope.unitName = config.unitName;
@ -191,6 +192,7 @@ angular.module('copayApp.controllers').controller('amountController', function($
toAmount: amount * unitToSatoshi, toAmount: amount * unitToSatoshi,
toAddress: $scope.toAddress, toAddress: $scope.toAddress,
toName: $scope.toName, toName: $scope.toName,
toEmail: $scope.toEmail
}); });
}; };
}); });

View file

@ -102,6 +102,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.toAddress = $stateParams.toAddress; $scope.toAddress = $stateParams.toAddress;
$scope.toName = $stateParams.toName; $scope.toName = $stateParams.toName;
$scope.toEmail = $stateParams.toEmail;
$scope.description = $stateParams.description; $scope.description = $stateParams.description;
$scope.paypro = $stateParams.paypro; $scope.paypro = $stateParams.paypro;
@ -119,12 +120,14 @@ angular.module('copayApp.controllers').controller('confirmController', function(
lodash.each(wallets, function(w) { lodash.each(wallets, function(w) {
walletService.getStatus(w, {}, function(err, status) { walletService.getStatus(w, {}, function(err, status) {
if (err) $log.error(err); if (err || !status) {
if (!status.availableBalanceSat) $log.debug('No balance available in: ' + w.name); $log.error(err);
if (status.availableBalanceSat > amount) filteredWallets.push(w); } else {
if (!status.availableBalanceSat) $log.debug('No balance available in: ' + w.name);
if (status.availableBalanceSat > amount) filteredWallets.push(w);
}
if (++index == wallets.length) { if (++index == wallets.length) {
if (!lodash.isEmpty(filteredWallets)) { if (!lodash.isEmpty(filteredWallets)) {
$scope.wallets = lodash.clone(filteredWallets); $scope.wallets = lodash.clone(filteredWallets);
$scope.notAvailable = false; $scope.notAvailable = false;
@ -135,7 +138,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$timeout(function() { $timeout(function() {
$scope.$apply(); $scope.$apply();
}, 10); });
return; return;
} }
}); });

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('backupWarningController', function($scope, $state, $stateParams, $ionicPopup, profileService) { angular.module('copayApp.controllers').controller('backupWarningController', function($scope, $state, $timeout, $stateParams, $ionicPopup, profileService) {
$scope.walletId = $stateParams.walletId; $scope.walletId = $stateParams.walletId;
$scope.openPopup = function() { $scope.openPopup = function() {
@ -11,7 +11,10 @@ angular.module('copayApp.controllers').controller('backupWarningController', fun
$scope.close = function() { $scope.close = function() {
backupWarningPopup.close(); backupWarningPopup.close();
$state.go('onboarding.backup', {walletId: $stateParams.walletId, fromOnboarding: true}); $state.go('onboarding.backup', {
walletId: $stateParams.walletId,
fromOnboarding: true
});
}; };
} }
}); });

View file

@ -4,7 +4,8 @@ angular.module('copayApp.controllers').controller('collectEmailController', func
var isCordova = platformInfo.isCordova; var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP; var isWP = platformInfo.isWP;
var usePushNotifications = true; var usePushNotifications = isCordova && !isWP;
var requiresOptIn = platformInfo.isIOS;
var wallet = profileService.getWallet($stateParams.walletId); var wallet = profileService.getWallet($stateParams.walletId);
var walletId = wallet.credentials.walletId; var walletId = wallet.credentials.walletId;
@ -21,16 +22,29 @@ angular.module('copayApp.controllers').controller('collectEmailController', func
if (err) $log.warn(err); if (err) $log.warn(err);
configService.set(opts, function(err) { configService.set(opts, function(err) {
if (err) $log.warn(err); if (err) $log.warn(err);
if (!usePushNotifications) $state.go('onboarding.backupRequest', { $scope.goNextView();
walletId: walletId
});
else $state.go('onboarding.notifications', {
walletId: walletId
});
}); });
}); });
}; };
$scope.goNextView = function() {
if (!usePushNotifications) {
$state.go('onboarding.backupRequest', {
walletId: walletId
});
}
else if (requiresOptIn) {
$state.go('onboarding.notifications', {
walletId: walletId
});
} else {
profileService.pushNotificationsInit();
$state.go('onboarding.backupRequest', {
walletId: walletId
});
}
};
$scope.confirm = function(emailForm) { $scope.confirm = function(emailForm) {
if (emailForm.$invalid) return; if (emailForm.$invalid) return;
$scope.confirmation = true; $scope.confirmation = true;
@ -44,9 +58,4 @@ angular.module('copayApp.controllers').controller('collectEmailController', func
}, 1); }, 1);
}; };
$scope.onboardingMailSkip = function() {
$state.go('onboarding.backupRequest', {
walletId: walletId
});
};
}); });

View file

@ -5,7 +5,9 @@ angular.module('copayApp.controllers').controller('notificationsController', fun
$scope.walletId = $stateParams.walletId; $scope.walletId = $stateParams.walletId;
$scope.allowNotif = function() { $scope.allowNotif = function() {
profileService.pushNotificationsInit(); profileService.pushNotificationsInit();
$state.go('onboarding.backupRequest'); $state.go('onboarding.backupRequest', {
walletId: $scope.walletId
});
} }
}); });

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('tabSendController', function($scope, $log, $timeout, addressbookService, profileService, lodash, $state, walletService, incomingData ) { angular.module('copayApp.controllers').controller('tabSendController', function($scope, $log, $timeout, addressbookService, profileService, lodash, $state, walletService, incomingData) {
var originalList; var originalList;
@ -30,6 +30,7 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
contacts.push({ contacts.push({
name: lodash.isObject(v) ? v.name : v, name: lodash.isObject(v) ? v.name : v,
address: k, address: k,
email: lodash.isObject(v) ? v.email : null,
getAddress: function(cb) { getAddress: function(cb) {
return cb(null, k); return cb(null, k);
}, },
@ -76,7 +77,8 @@ angular.module('copayApp.controllers').controller('tabSendController', function(
$log.debug('Got toAddress:' + addr + ' | ' + item.name); $log.debug('Got toAddress:' + addr + ' | ' + item.name);
return $state.transitionTo('send.amount', { return $state.transitionTo('send.amount', {
toAddress: addr, toAddress: addr,
toName: item.name toName: item.name,
toEmail: item.email
}) })
}); });
}; };

View file

@ -113,15 +113,16 @@ angular.module('copayApp.directives')
} }
} }
}) })
.directive('contact', ['addressbookService', .directive('contact', ['addressbookService', 'lodash',
function(addressbookService) { function(addressbookService, lodash) {
return { return {
restrict: 'E', restrict: 'E',
link: function(scope, element, attrs) { link: function(scope, element, attrs) {
var addr = attrs.address; var addr = attrs.address;
addressbookService.getLabel(addr, function(label) { addressbookService.get(addr, function(err, ab) {
if (label) { if (ab) {
element.append(label); var name = lodash.isObject(ab) ? ab.name : ab;
element.append(name);
} else { } else {
element.append(addr); element.append(addr);
} }

View file

@ -0,0 +1,20 @@
'use strict';
angular.module('copayApp.directives')
.directive('gravatar', function(md5) {
return {
restrict: 'AE',
replace: true,
scope: {
name: '@',
height: '@',
width: '@',
email: '@'
},
link: function(scope, el, attr) {
scope.emailHash = md5.createHash(scope.email || '');
},
template: '<img class="gravatar" alt="{{ name }}" height="{{ height }}" width="{{ width }}" src="https://secure.gravatar.com/avatar/{{ emailHash }}.jpg?s={{ width }}&d=mm">'
}
});

View file

@ -235,7 +235,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
template: '<ion-nav-view name="send"></ion-nav-view>' template: '<ion-nav-view name="send"></ion-nav-view>'
}) })
.state('send.amount', { .state('send.amount', {
url: '/amount/:toAddress/:toName', url: '/amount/:toAddress/:toName/:toEmail',
views: { views: {
'send': { 'send': {
templateUrl: 'views/amount.html' templateUrl: 'views/amount.html'
@ -243,7 +243,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
} }
}) })
.state('send.confirm', { .state('send.confirm', {
url: '/confirm/:toAddress/:toName/:toAmount/:description/:paypro', url: '/confirm/:toAddress/:toName/:toAmount/:toEmail/:description/:paypro',
views: { views: {
'send': { 'send': {
templateUrl: 'views/confirm.html' templateUrl: 'views/confirm.html'
@ -490,14 +490,14 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
} }
}) })
/* /*
* *
* Addressbook * Addressbook
* *
*/ */
.state('tabs.addressbook', { .state('tabs.addressbook', {
url: '/addressbook', url: '/addressbook',
views: { views: {
'tab-settings': { 'tab-settings': {
@ -769,6 +769,9 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
$ionicPlatform.ready(function() { $ionicPlatform.ready(function() {
if (platformInfo.isCordova) { if (platformInfo.isCordova) {
if (screen.width < 768)
screen.lockOrientation('portrait');
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) { if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true); cordova.plugins.Keyboard.disableScroll(true);
@ -877,6 +880,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
var state = {}; var state = {};
state.name = toState.name; state.name = toState.name;
state.toParams = toParams; state.toParams = toParams;
storageService.setLastState(JSON.stringify(state), function() {}); if (state.name != 'starting') storageService.setLastState(JSON.stringify(state), function() {});
}); });
}); });

View file

@ -268,9 +268,6 @@ angular.module('copayApp.services')
if (!val) { if (!val) {
return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer')); return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer'));
} }
if (usePushNotifications)
root.pushNotificationsInit();
$rootScope.$emit('disclaimerAccepted');
return cb(); return cb();
}); });
}); });
@ -873,12 +870,15 @@ angular.module('copayApp.services')
if (err) { if (err) {
$log.warn('Error updating notifications:' + err); $log.warn('Error updating notifications:' + err);
} else { } else {
var n = lodash.filter(wallet.cachedActivity.n, function(x) {
var n;
n = lodash.filter(wallet.cachedActivity.n, function(x) {
return !typeFilter1[x.type]; return !typeFilter1[x.type];
}); });
if (wallet.n == 1) { if (wallet.m == 1) {
var n = lodash.filter(n, function(x) { n = lodash.filter(n, function(x) {
return !typeFilter2[x.type]; return !typeFilter2[x.type];
}); });
} }

View file

@ -937,6 +937,27 @@ input[type=number] {
} }
} }
/** Gravatar **/
.gravatar {
border-radius: 50%;
}
.gravatar-content {
position: relative;
height: 70px;
border-color: #172565;
background-color: #1e3186;
background-image: linear-gradient(0deg, #172565, #172565 0%, transparent 0%);
color: #fff;
margin-bottom: 50px;
.gravatar {
position: absolute;
bottom: -30px;
left: 41%;
}
}
/* Spinner */ /* Spinner */
.item-icon-left ion-spinner { .item-icon-left ion-spinner {
@ -961,6 +982,7 @@ input[type=number] {
@import 'mixins/mixins'; @import 'mixins/mixins';
@import "views/add"; @import "views/add";
@import "views/amount"; @import "views/amount";
@import "views/confirm";
@import "views/tab-home"; @import "views/tab-home";
@import "views/tab-receive"; @import "views/tab-receive";
@import "views/tab-send"; @import "views/tab-send";

View file

@ -9,7 +9,11 @@
padding-left: 48px; padding-left: 48px;
} }
} }
.send-gravatar {
left: 11px;
position: absolute;
top: 10px;
}
.amount-pane { .amount-pane {
position: absolute; position: absolute;
top: 125px; top: 125px;

View file

@ -0,0 +1,7 @@
#view-confirm {
.send-gravatar {
left: 11px;
position: absolute;
top: 10px;
}
}

View file

@ -11,4 +11,9 @@
padding-bottom: 1px; padding-bottom: 1px;
} }
} }
.send-gravatar {
left: 11px;
position: absolute;
top: 10px;
}
} }