Glidera working again. Rm ignoreMobilePause!
This commit is contained in:
parent
2a97446ef9
commit
ecf16d61ea
8 changed files with 128 additions and 92 deletions
11
public/views/uri.html
Normal file
11
public/views/uri.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
<div class="row columns p20" ng-controller="uriController">
|
||||
<div class="text-center">
|
||||
<logo width="146"></logo>
|
||||
<div class="text-white" ng-include="'views/includes/version.html'"></div>
|
||||
</div>
|
||||
<h3 class="text-center">
|
||||
Please wait to be redirected...
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
|
|
@ -1,40 +1,43 @@
|
|||
'use strict';
|
||||
angular.module('copayApp.controllers').controller('glideraUriController',
|
||||
function($scope, $stateParams, $timeout, profileService, configService, glideraService, storageService, go) {
|
||||
function($scope, $log, $stateParams, $timeout, profileService, configService, glideraService, storageService, go) {
|
||||
|
||||
this.submitOauthCode = function(code) {
|
||||
console.log('[glideraUri.js.5:code:]'+code); //TODO
|
||||
var self = this;
|
||||
var glideraTestnet = configService.getSync().glidera.testnet;
|
||||
var network = glideraTestnet ? 'testnet' : 'livenet';
|
||||
this.loading = true;
|
||||
this.error = null;
|
||||
$timeout(function() {
|
||||
glideraService.getToken(code, function(err, data) {
|
||||
self.loading = null;
|
||||
if (err) {
|
||||
self.error = err;
|
||||
this.submitOauthCode = function(code) {
|
||||
$log.debug('Glidera Oauth Code:' + code);
|
||||
var self = this;
|
||||
var glideraTestnet = configService.getSync().glidera.testnet;
|
||||
var network = glideraTestnet ? 'testnet' : 'livenet';
|
||||
this.loading = true;
|
||||
this.error = null;
|
||||
$timeout(function() {
|
||||
glideraService.getToken(code, function(err, data) {
|
||||
self.loading = null;
|
||||
if (err) {
|
||||
self.error = err;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
} else if (data && data.access_token) {
|
||||
storageService.setGlideraToken(network, data.access_token, function() {
|
||||
$scope.$emit('Local/GlideraUpdated', data.access_token);
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
}
|
||||
else if (data && data.access_token) {
|
||||
storageService.setGlideraToken(network, data.access_token, function() {
|
||||
$scope.$emit('Local/GlideraUpdated', data.access_token);
|
||||
$timeout(function() {
|
||||
go.path('glidera');
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
});
|
||||
}, 100);
|
||||
};
|
||||
go.path('glidera');
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
});
|
||||
}, 100);
|
||||
};
|
||||
|
||||
this.checkCode = function() {
|
||||
console.log('[glideraUri.js.35:$stateParams:]' + JSON.stringify($stateParams)); //TODO
|
||||
this.code = $stateParams.code;
|
||||
this.submitOauthCode(this.code);
|
||||
};
|
||||
|
||||
});
|
||||
this.checkCode = function() {
|
||||
if ($stateParams.url) {
|
||||
var match = $stateParams.url.match(/code=(.+)/);
|
||||
if (match && match[1]) {
|
||||
this.code = match[1];
|
||||
return this.submitOauthCode(this.code);
|
||||
}
|
||||
}
|
||||
$log.error('Bad state: ' + JSON.stringify($stateParams));
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1500,11 +1500,11 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
|
||||
if (!self.lastUpdate || (now - self.lastUpdate) > oneHr) {
|
||||
self.updateAll({
|
||||
quiet: true
|
||||
triggerTxUpdate: true,
|
||||
quiet: true,
|
||||
triggerTxUpdate: true
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$rootScope.$on('Local/Resume', function(event) {
|
||||
$log.debug('### Resume event');
|
||||
|
|
|
|||
12
src/js/controllers/uri.js
Normal file
12
src/js/controllers/uri.js
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
'use strict';
|
||||
angular.module('copayApp.controllers').controller('uriController',
|
||||
function($rootScope, $stateParams, $log, openURLService) {
|
||||
|
||||
|
||||
/* This is only for BROWSER links, it is not excecuted on mobile devices */
|
||||
|
||||
$log.info('DEEP LINK from Browser:' + $stateParams.url);
|
||||
openURLService.handleURL({
|
||||
url: $stateParams.url
|
||||
});
|
||||
});
|
||||
|
|
@ -112,6 +112,15 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
}
|
||||
})
|
||||
.state('uri', {
|
||||
url: '/uri/:url',
|
||||
needProfile: true,
|
||||
views: {
|
||||
'main': {
|
||||
templateUrl: 'views/uri.html'
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('uripayment', {
|
||||
url: '/uri-payment/:url',
|
||||
templateUrl: 'views/paymentUri.html',
|
||||
|
|
@ -122,11 +131,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
},
|
||||
needProfile: true
|
||||
})
|
||||
.state('selectWalletForPayment', {
|
||||
url: '/selectWalletForPayment',
|
||||
controller: 'walletForPaymentController',
|
||||
needProfile: true
|
||||
})
|
||||
.state('join', {
|
||||
url: '/join',
|
||||
needProfile: true,
|
||||
|
|
@ -215,7 +219,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
})
|
||||
.state('uriglidera', {
|
||||
url: '/uri-glidera/:code',
|
||||
url: '/uri-glidera/:url',
|
||||
needProfile: true,
|
||||
views: {
|
||||
'main': {
|
||||
|
|
@ -284,7 +288,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
})
|
||||
.state('uricoinbase', {
|
||||
url: '/uri-coinbase/:code',
|
||||
url: '/uri-coinbase/:url',
|
||||
needProfile: true,
|
||||
views: {
|
||||
'main': {
|
||||
|
|
@ -504,12 +508,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
},
|
||||
}
|
||||
})
|
||||
.state('warning', {
|
||||
url: '/warning',
|
||||
controller: 'warningController',
|
||||
templateUrl: 'views/warning.html',
|
||||
needProfile: false
|
||||
})
|
||||
.state('add', {
|
||||
url: '/add',
|
||||
needProfile: true,
|
||||
|
|
@ -520,7 +518,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
});
|
||||
})
|
||||
.run(function($rootScope, $state, $location, $log, $timeout, $ionicPlatform, uriHandler, platformInfo, profileService, uxLanguage, animationService, go, gettextCatalog) {
|
||||
.run(function($rootScope, $state, $location, $log, $timeout, $ionicPlatform, platformInfo, profileService, uxLanguage, animationService, go, gettextCatalog) {
|
||||
|
||||
$ionicPlatform.ready(function() {
|
||||
if (platformInfo.isCordova) {
|
||||
|
|
@ -539,7 +537,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
});
|
||||
|
||||
$ionicPlatform.on('resume', function() {
|
||||
// Nothing to do
|
||||
$rootScope.$emit('Local/Resume');
|
||||
});
|
||||
|
||||
|
|
@ -583,11 +580,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
|
||||
uxLanguage.init();
|
||||
|
||||
// Register URI handler, not for mobileApp
|
||||
if (!platformInfo.isMobile) {
|
||||
uriHandler.register();
|
||||
}
|
||||
|
||||
if (platformInfo.isNW) {
|
||||
var gui = require('nw.gui');
|
||||
var win = gui.Window.get();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('openURLService', function($ionicHistory, $document, $log, $state, go) {
|
||||
angular.module('copayApp.services').factory('openURLService', function($ionicHistory, $document, $log, $state, go, platformInfo, lodash) {
|
||||
var root = {};
|
||||
|
||||
root.registeredUriHandlers = [{
|
||||
|
|
@ -9,11 +9,11 @@ angular.module('copayApp.services').factory('openURLService', function($ionicHis
|
|||
transitionTo: 'uripayment',
|
||||
}, {
|
||||
name: 'Glidera Authentication Callback',
|
||||
startsWith: 'copay://glidera',
|
||||
startsWith: 'copay:glidera',
|
||||
transitionTo: 'uriglidera',
|
||||
}, {
|
||||
name: 'Coinbase Authentication Callback',
|
||||
startsWith: 'copay://coinbase',
|
||||
startsWith: 'copay:coinbase',
|
||||
transitionTo: 'uricoinbase',
|
||||
}];
|
||||
|
||||
|
|
@ -27,43 +27,76 @@ angular.module('copayApp.services').factory('openURLService', function($ionicHis
|
|||
disableBack: true,
|
||||
disableAnimation: true
|
||||
});
|
||||
var url = args.url;
|
||||
if (!url) {
|
||||
$log.error('No url provided');
|
||||
return;
|
||||
};
|
||||
|
||||
if (url) {
|
||||
window.cordova.removeDocumentEventHandler('handleopenurl');
|
||||
window.cordova.addStickyDocumentEventHandler('handleopenurl');
|
||||
document.removeEventListener('handleopenurl', root.handleOpenUrl);
|
||||
if ('cordova' in window) {
|
||||
window.cordova.removeDocumentEventHandler('handleopenurl');
|
||||
window.cordova.addStickyDocumentEventHandler('handleopenurl');
|
||||
}
|
||||
document.removeEventListener('handleopenurl', handleOpenURL);
|
||||
}
|
||||
|
||||
document.addEventListener('handleopenurl', handleOpenURL, false);
|
||||
|
||||
var url = args.url;
|
||||
|
||||
lodash.each(root.registeredUriHandlers, function(x) {
|
||||
if (url.indexOf(x.startWith) == 0) {
|
||||
$log.debug('openURL GOT ' + x.name + ' URL');
|
||||
return $state.transitionTo(x.transitionTo, {
|
||||
url: url
|
||||
});
|
||||
}
|
||||
var x = lodash.find(root.registeredUriHandlers, function(x) {
|
||||
return url.indexOf(x.startsWith) == 0 ||
|
||||
url.indexOf('web+' + x.startsWith) == 0 || // web protocols
|
||||
url.indexOf(x.startsWith.replace(':','://')) == 0 // from mobile devices
|
||||
;
|
||||
});
|
||||
$log.warn('Unknown URL! : ' + url);
|
||||
|
||||
if (x) {
|
||||
$log.debug('openURL GOT ' + x.name + ' URL');
|
||||
return $state.transitionTo(x.transitionTo, {
|
||||
url: url
|
||||
});
|
||||
} else {
|
||||
$log.warn('Unknown URL! : ' + url);
|
||||
}
|
||||
};
|
||||
|
||||
var handleResume = function() {
|
||||
$log.debug('Handle Resume @ openURL...');
|
||||
document.addEventListener('handleopenurl', handleOpenUrl, false);
|
||||
document.addEventListener('handleopenurl', handleOpenURL, false);
|
||||
};
|
||||
|
||||
root.init = function() {
|
||||
console.log('[openURL.js.29]'); //TODO
|
||||
$log.debug('Initializing openURL');
|
||||
document.addEventListener('handleopenurl', handleOpenURL, false);
|
||||
document.addEventListener('resume', handleResume, false);
|
||||
};
|
||||
|
||||
if (platformInfo.isChromeApp) {
|
||||
$log.debug('Registering Chrome message listener');
|
||||
chrome.runtime.onMessage.addListener(
|
||||
function(request, sender, sendResponse) {
|
||||
if (request.url) {
|
||||
handleOpenURL(request.url);
|
||||
}
|
||||
});
|
||||
} else if (platformInfo.isDevel) {
|
||||
|
||||
var base = window.location.origin + '/';
|
||||
var url = base + '#/uri/%s';
|
||||
|
||||
if (navigator.registerProtocolHandler) {
|
||||
$log.debug('Registering Browser handlers base:' + base);
|
||||
navigator.registerProtocolHandler('bitcoin', url, 'Copay Bitcoin Handler');
|
||||
navigator.registerProtocolHandler('web+copay', url, 'Copay Wallet Handler');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
root.registerHandler = function(x) {
|
||||
$log.debug('Registering URL Handler: ' + x.name);
|
||||
root.registeredUriHandlers.push(x);
|
||||
};
|
||||
|
||||
root.handleURL = handleOpenURL;
|
||||
|
||||
return root;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -293,7 +293,6 @@ angular.module('copayApp.services')
|
|||
var name = opts.name || gettextCatalog.getString('Personal Wallet');
|
||||
var myName = opts.myName || gettextCatalog.getString('me');
|
||||
|
||||
console.log('[profileService.js.303]', opts); //TODO
|
||||
walletClient.createWallet(name, myName, opts.m, opts.n, {
|
||||
network: opts.networkName,
|
||||
singleAddress: opts.singleAddress,
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
var UriHandler = function() {};
|
||||
|
||||
UriHandler.prototype.register = function() {
|
||||
var base = window.location.origin + '/';
|
||||
var url = base + '#/uri-payment/%s';
|
||||
|
||||
if(navigator.registerProtocolHandler) {
|
||||
navigator.registerProtocolHandler('bitcoin', url, 'Copay');
|
||||
}
|
||||
};
|
||||
|
||||
angular.module('copayApp.services').value('uriHandler', new UriHandler());
|
||||
Loading…
Add table
Add a link
Reference in a new issue