Merge pull request #3602 from cmgustavo/ref/disclaimer-flag

Ref bootstrapping (disclaimer)
This commit is contained in:
Matias Alejo Garcia 2015-12-07 12:58:31 -03:00
commit 74d7b24d02
6 changed files with 132 additions and 110 deletions

View file

@ -18,7 +18,7 @@
ng-controller="indexController as index" ng-controller="indexController as index"
ng-swipe-disable-mouse ng-swipe-disable-mouse
ng-swipe-left="index.closeMenu()" ng-swipe-left="index.closeMenu()"
ng-swipe-right="index.agreeDisclaimer() ? index.openMenu() : null"> ng-swipe-right="index.openMenu()">
<div class="off-canvas-wrap" id="off-canvas-wrap"> <div class="off-canvas-wrap" id="off-canvas-wrap">
<div class="inner-wrap"> <div class="inner-wrap">

View file

@ -1,56 +1,54 @@
<div class="splash content text-center" <div class="splash content text-center"
ng-controller="disclaimerController"> ng-controller="disclaimerController as disclaimer" ng-init="disclaimer.init()">
<div> <div class="row">
<div class="row"> <div class="container-image large-2 medium-2 small-2 medium-centered small-centered large-centered columns">
<div class="container-image large-2 medium-2 small-2 medium-centered small-centered large-centered columns"> <img src="img/icon-splash.png" alt="icon" width="100%">
<img src="img/icon-splash.png" alt="icon" width="100%"> </div>
<div class="row">
<div class="medium-centered small-centered large-centered columns">
<span class="text-bold size-16 text-white" translate>WELCOME TO COPAY</span>
<p class="text-gray size-14 m0 text-light" translate>A multisignature bitcoin wallet</p>
</div> </div>
<div class="row"> </div>
<div class="medium-centered small-centered large-centered columns"> <div class="row">
<span class="text-bold size-16 text-white" translate>WELCOME TO COPAY</span> <div class="scrollArea">
<p class="text-gray size-14 m0 text-light" translate>A multisignature bitcoin wallet</p> <p class="enable_text_select m0">
</div> <div class="size-16 text-gray" translate>Terms of Use</div>
</div> <div ng-include="'views/includes/terms.html'"></div>
<div class="row">
<div class="scrollArea">
<p class="enable_text_select m0">
<div class="size-16 text-gray" translate>Terms of Use</div>
<div ng-include="'views/includes/terms.html'"></div>
</p>
</div>
</div>
</div>
<div class="row">
<p ng-show="lang != 'en'">
<a class="center" ng-click="$root.openExternalLink('https://copay.io/disclaimer')" translate>Official English Disclaimer</a>
</p> </p>
</div> </div>
<div> </div>
<p class="text-gray columns" translate>I affirm that I have read, understood, and agree with these terms.</p> </div>
</div>
<div class="row">
<div class="text-center size-12 text-warning" ng-show="error"> <div class="row">
{{(error)|translate}}. <span translate>Retrying...</span> <p ng-show="disclaimer.lang != 'en'">
</div> <a class="center" ng-click="$root.openExternalLink('https://copay.io/disclaimer')" translate>Official English Disclaimer</a>
<div class="onGoingProcess" ng-show="creatingProfile"> </p>
<div class="onGoingProcess-content" ng-style="{'background-color':'#222'}"> </div>
<div class="spinner"> <div>
<div class="rect1"></div> <p class="text-gray columns" translate>I affirm that I have read, understood, and agree with these terms.</p>
<div class="rect2"></div> </div>
<div class="rect3"></div> <div class="row">
<div class="rect4"></div>
<div class="rect5"></div> <div class="text-center size-12 text-warning" ng-show="error">
</div> {{(error)|translate}}. <span translate>Retrying...</span>
<span translate>Creating Profile...</span>
</div>
</div> </div>
<div class="start-button columns"> <div class="onGoingProcess" ng-show="creatingProfile">
<button ng-disabled="creatingProfile" ng-click="goHome()" class="button black expand round size-12 text-spacing" translate> <div class="onGoingProcess-content" ng-style="{'background-color':'#222'}">
I AGREE. GET STARTED <div class="spinner">
</button> <div class="rect1"></div>
<div class="rect2"></div>
<div class="rect3"></div>
<div class="rect4"></div>
<div class="rect5"></div>
</div> </div>
<span translate>Creating Profile...</span>
</div>
</div>
<div class="start-button columns">
<button ng-disabled="creatingProfile" ng-click="index.acceptDisclaimer()" class="button black expand round size-12 text-spacing" translate>
I AGREE. GET STARTED
</button>
</div> </div>
</div> </div>
</div> </div>

View file

@ -3,18 +3,6 @@
angular.module('copayApp.controllers').controller('disclaimerController', angular.module('copayApp.controllers').controller('disclaimerController',
function($scope, $timeout, $log, profileService, isCordova, storageService, applicationService, gettextCatalog, uxLanguage, go) { function($scope, $timeout, $log, profileService, isCordova, storageService, applicationService, gettextCatalog, uxLanguage, go) {
self = this; self = this;
$scope.lang = uxLanguage.currentLanguage;
$scope.goHome = function() {
$scope.error = "";
profileService.storeDisclaimer(function(err) {
if (err) {
$scope.error = err;
$log.warn(err);
$scope.$apply();
} else go.walletHome();
});
};
var create = function() { var create = function() {
$scope.creatingProfile = true; $scope.creatingProfile = true;
@ -35,13 +23,16 @@ angular.module('copayApp.controllers').controller('disclaimerController',
}); });
}; };
storageService.getProfile(function(err, profile) { this.init = function() {
if (!profile) create(); self.lang = uxLanguage.currentLanguage;
else $scope.creatingProfile = false; storageService.getProfile(function(err, profile) {
if (!profile) create();
else $scope.creatingProfile = false;
//compatible //compatible
storageService.getCopayDisclaimerFlag(function(err, val) { profileService.isDisclaimerAccepted(function(val) {
if (val) go.walletHome(); if (val) go.walletHome();
});
}); });
}); };
}); });

View file

@ -141,14 +141,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}); });
}; };
self.agreeDisclaimer = function() {
storageService.getProfile(function(err, profile) {
if (profile && profile.agreeDisclaimer)
return profile.agreeDisclaimer;
return null;
});
};
self.setCustomBWSFlag = function() { self.setCustomBWSFlag = function() {
var defaults = configService.getDefaults(); var defaults = configService.getDefaults();
var config = configService.getSync(); var config = configService.getSync();
@ -156,6 +148,28 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.usingCustomBWS = config.bwsFor && config.bwsFor[self.walletId] && (config.bwsFor[self.walletId] != defaults.bws.url); self.usingCustomBWS = config.bwsFor && config.bwsFor[self.walletId] && (config.bwsFor[self.walletId] != defaults.bws.url);
}; };
self.acceptDisclaimer = function() {
var profile = profileService.profile;
if (profile) profile.disclaimerAccepted = true;
self.disclaimerAccepted = true;
profileService.setDisclaimerAccepted(function(err) {
if (err) $log.error(err);
go.walletHome();
});
};
self.isDisclaimerAccepted = function() {
if (self.disclaimerAccepted == true) {
go.walletHome();
return;
}
profileService.isDisclaimerAccepted(function(v) {
if (v) {
self.acceptDisclaimer();
} else go.path('disclaimer');
});
};
self.setTab = function(tab, reset, tries, switchState) { self.setTab = function(tab, reset, tries, switchState) {
tries = tries || 0; tries = tries || 0;
@ -980,6 +994,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}; };
self.openMenu = function() { self.openMenu = function() {
if (!self.disclaimerAccepted) return;
go.swipe(true); go.swipe(true);
}; };
@ -1168,10 +1183,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}); });
}); });
$rootScope.$on('Local/NewFocusedWallet', function() {
self.setUxLanguage();
});
$rootScope.$on('Local/LanguageSettingUpdated', function() { $rootScope.$on('Local/LanguageSettingUpdated', function() {
self.setUxLanguage(); self.setUxLanguage();
self.updateRemotePreferences({ self.updateRemotePreferences({
@ -1229,6 +1240,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
$rootScope.$on('Local/Resume', function(event) { $rootScope.$on('Local/Resume', function(event) {
$log.debug('### Resume event'); $log.debug('### Resume event');
self.isDisclaimerAccepted();
self.debouncedUpdate(); self.debouncedUpdate();
}); });
@ -1348,24 +1360,18 @@ angular.module('copayApp.controllers').controller('indexController', function($r
}); });
$rootScope.$on('Local/NewFocusedWallet', function() { $rootScope.$on('Local/NewFocusedWallet', function() {
self.setUxLanguage();
self.setFocusedWallet(); self.setFocusedWallet();
self.updateTxHistory(); self.updateTxHistory();
storageService.getProfile(function(err, profile) { self.isDisclaimerAccepted();
if (profile && profile.agreeDisclaimer) go.walletHome(); storageService.getCleanAndScanAddresses(function(err, walletId) {
if (walletId && profileService.walletClients[walletId]) {
//compatible $log.debug('Clear last address cache and Scan ', walletId);
storageService.getCopayDisclaimerFlag(function(err, val) { addressService.expireAddress(walletId, function(err) {
if (val) go.walletHome(); self.startScan(walletId);
storageService.getCleanAndScanAddresses(function(err, walletId) {
if (walletId && profileService.walletClients[walletId]) {
$log.debug('Clear last address cache and Scan ', walletId);
addressService.expireAddress(walletId, function(err) {
self.startScan(walletId);
});
storageService.removeCleanAndScanAddresses(function() {});
}
}); });
}); storageService.removeCleanAndScanAddresses(function() {});
}
}); });
}); });

View file

@ -15,7 +15,7 @@ Profile.create = function(opts) {
var x = new Profile(); var x = new Profile();
x.createdOn = Date.now(); x.createdOn = Date.now();
x.credentials = opts.credentials || []; x.credentials = opts.credentials || [];
x.agreeDisclaimer = false; x.disclaimerAccepted = false;
return x; return x;
}; };
@ -24,7 +24,7 @@ Profile.fromObj = function(obj) {
x.createdOn = obj.createdOn; x.createdOn = obj.createdOn;
x.credentials = obj.credentials; x.credentials = obj.credentials;
x.agreeDisclaimer = obj.agreeDisclaimer; x.disclaimerAccepted = obj.disclaimerAccepted;
if (x.credentials[0] && typeof x.credentials[0] != 'object') if (x.credentials[0] && typeof x.credentials[0] != 'object')
throw ("credentials should be an object"); throw ("credentials should be an object");

View file

@ -127,10 +127,18 @@ angular.module('copayApp.services')
if (err) return cb(err); if (err) return cb(err);
root._setFocus(focusedWalletId, function() { root._setFocus(focusedWalletId, function() {
$rootScope.$emit('Local/ProfileBound'); $rootScope.$emit('Local/ProfileBound');
return cb(); root.isDisclaimerAccepted(function(val) {
if (!val) {
return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer'));
}
else {
return cb();
}
});
}); });
}); });
}); });
}; };
root.loadAndBindProfile = function(cb) { root.loadAndBindProfile = function(cb) {
@ -150,13 +158,8 @@ angular.module('copayApp.services')
return root.bindProfile(profile, cb); return root.bindProfile(profile, cb);
}) })
} else { } else {
storageService.getCopayDisclaimerFlag(function(err, val) { $log.debug('Profile read');
if (!profile.agreeDisclaimer) { return root.bindProfile(profile, cb);
if (!val) return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer'));
}
$log.debug('Profile read');
return root.bindProfile(profile, cb);
});
} }
}); });
}; };
@ -518,14 +521,38 @@ angular.module('copayApp.services')
}); });
}; };
root.storeDisclaimer = function(cb) { root.setDisclaimerAccepted = function(cb) {
storageService.getProfile(function(err, profile) { storageService.getProfile(function(err, profile) {
profile.agreeDisclaimer = true; profile.disclaimerAccepted = true;
storageService.storeProfile(profile, function() { storageService.storeProfile(profile, function(err) {
return cb(err); return cb(err);
}); });
}); });
} };
root.isDisclaimerAccepted = function(cb) {
storageService.getProfile(function(err, profile) {
if (profile && profile.disclaimerAccepted)
return cb(true);
else if (profile && !profile.disclaimerAccepted) {
storageService.getCopayDisclaimerFlag(function(err, val) {
if (val) {
profile.disclaimerAccepted = true;
storageService.storeProfile(profile, function(err) {
if (err) $log.error(err);
return cb(true);
});
}
else {
return cb();
}
});
}
else {
return cb();
}
});
};
root.importLegacyWallet = function(username, password, blob, cb) { root.importLegacyWallet = function(username, password, blob, cb) {
var walletClient = bwcService.getClient(); var walletClient = bwcService.getClient();