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';
|
'use strict';
|
||||||
angular.module('copayApp.controllers').controller('glideraUriController',
|
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) {
|
this.submitOauthCode = function(code) {
|
||||||
console.log('[glideraUri.js.5:code:]'+code); //TODO
|
$log.debug('Glidera Oauth Code:' + code);
|
||||||
var self = this;
|
var self = this;
|
||||||
var glideraTestnet = configService.getSync().glidera.testnet;
|
var glideraTestnet = configService.getSync().glidera.testnet;
|
||||||
var network = glideraTestnet ? 'testnet' : 'livenet';
|
var network = glideraTestnet ? 'testnet' : 'livenet';
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.error = null;
|
this.error = null;
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
glideraService.getToken(code, function(err, data) {
|
glideraService.getToken(code, function(err, data) {
|
||||||
self.loading = null;
|
self.loading = null;
|
||||||
if (err) {
|
if (err) {
|
||||||
self.error = 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() {
|
$timeout(function() {
|
||||||
$scope.$apply();
|
go.path('glidera');
|
||||||
}, 100);
|
$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() {
|
}, 100);
|
||||||
go.path('glidera');
|
};
|
||||||
$scope.$apply();
|
|
||||||
}, 100);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, 100);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.checkCode = function() {
|
this.checkCode = function() {
|
||||||
console.log('[glideraUri.js.35:$stateParams:]' + JSON.stringify($stateParams)); //TODO
|
if ($stateParams.url) {
|
||||||
this.code = $stateParams.code;
|
var match = $stateParams.url.match(/code=(.+)/);
|
||||||
this.submitOauthCode(this.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) {
|
if (!self.lastUpdate || (now - self.lastUpdate) > oneHr) {
|
||||||
self.updateAll({
|
self.updateAll({
|
||||||
quiet: true
|
quiet: true,
|
||||||
triggerTxUpdate: true,
|
triggerTxUpdate: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
$rootScope.$on('Local/Resume', function(event) {
|
$rootScope.$on('Local/Resume', function(event) {
|
||||||
$log.debug('### Resume 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', {
|
.state('uripayment', {
|
||||||
url: '/uri-payment/:url',
|
url: '/uri-payment/:url',
|
||||||
templateUrl: 'views/paymentUri.html',
|
templateUrl: 'views/paymentUri.html',
|
||||||
|
|
@ -122,11 +131,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
||||||
},
|
},
|
||||||
needProfile: true
|
needProfile: true
|
||||||
})
|
})
|
||||||
.state('selectWalletForPayment', {
|
|
||||||
url: '/selectWalletForPayment',
|
|
||||||
controller: 'walletForPaymentController',
|
|
||||||
needProfile: true
|
|
||||||
})
|
|
||||||
.state('join', {
|
.state('join', {
|
||||||
url: '/join',
|
url: '/join',
|
||||||
needProfile: true,
|
needProfile: true,
|
||||||
|
|
@ -215,7 +219,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.state('uriglidera', {
|
.state('uriglidera', {
|
||||||
url: '/uri-glidera/:code',
|
url: '/uri-glidera/:url',
|
||||||
needProfile: true,
|
needProfile: true,
|
||||||
views: {
|
views: {
|
||||||
'main': {
|
'main': {
|
||||||
|
|
@ -284,7 +288,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.state('uricoinbase', {
|
.state('uricoinbase', {
|
||||||
url: '/uri-coinbase/:code',
|
url: '/uri-coinbase/:url',
|
||||||
needProfile: true,
|
needProfile: true,
|
||||||
views: {
|
views: {
|
||||||
'main': {
|
'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', {
|
.state('add', {
|
||||||
url: '/add',
|
url: '/add',
|
||||||
needProfile: true,
|
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() {
|
$ionicPlatform.ready(function() {
|
||||||
if (platformInfo.isCordova) {
|
if (platformInfo.isCordova) {
|
||||||
|
|
@ -539,7 +537,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
||||||
});
|
});
|
||||||
|
|
||||||
$ionicPlatform.on('resume', function() {
|
$ionicPlatform.on('resume', function() {
|
||||||
// Nothing to do
|
|
||||||
$rootScope.$emit('Local/Resume');
|
$rootScope.$emit('Local/Resume');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -583,11 +580,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
||||||
|
|
||||||
uxLanguage.init();
|
uxLanguage.init();
|
||||||
|
|
||||||
// Register URI handler, not for mobileApp
|
|
||||||
if (!platformInfo.isMobile) {
|
|
||||||
uriHandler.register();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (platformInfo.isNW) {
|
if (platformInfo.isNW) {
|
||||||
var gui = require('nw.gui');
|
var gui = require('nw.gui');
|
||||||
var win = gui.Window.get();
|
var win = gui.Window.get();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'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 = {};
|
var root = {};
|
||||||
|
|
||||||
root.registeredUriHandlers = [{
|
root.registeredUriHandlers = [{
|
||||||
|
|
@ -9,11 +9,11 @@ angular.module('copayApp.services').factory('openURLService', function($ionicHis
|
||||||
transitionTo: 'uripayment',
|
transitionTo: 'uripayment',
|
||||||
}, {
|
}, {
|
||||||
name: 'Glidera Authentication Callback',
|
name: 'Glidera Authentication Callback',
|
||||||
startsWith: 'copay://glidera',
|
startsWith: 'copay:glidera',
|
||||||
transitionTo: 'uriglidera',
|
transitionTo: 'uriglidera',
|
||||||
}, {
|
}, {
|
||||||
name: 'Coinbase Authentication Callback',
|
name: 'Coinbase Authentication Callback',
|
||||||
startsWith: 'copay://coinbase',
|
startsWith: 'copay:coinbase',
|
||||||
transitionTo: 'uricoinbase',
|
transitionTo: 'uricoinbase',
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
@ -27,43 +27,76 @@ angular.module('copayApp.services').factory('openURLService', function($ionicHis
|
||||||
disableBack: true,
|
disableBack: true,
|
||||||
disableAnimation: true
|
disableAnimation: true
|
||||||
});
|
});
|
||||||
|
var url = args.url;
|
||||||
|
if (!url) {
|
||||||
|
$log.error('No url provided');
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
window.cordova.removeDocumentEventHandler('handleopenurl');
|
if ('cordova' in window) {
|
||||||
window.cordova.addStickyDocumentEventHandler('handleopenurl');
|
window.cordova.removeDocumentEventHandler('handleopenurl');
|
||||||
document.removeEventListener('handleopenurl', root.handleOpenUrl);
|
window.cordova.addStickyDocumentEventHandler('handleopenurl');
|
||||||
|
}
|
||||||
|
document.removeEventListener('handleopenurl', handleOpenURL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.addEventListener('handleopenurl', handleOpenURL, false);
|
||||||
|
|
||||||
var url = args.url;
|
var x = lodash.find(root.registeredUriHandlers, function(x) {
|
||||||
|
return url.indexOf(x.startsWith) == 0 ||
|
||||||
lodash.each(root.registeredUriHandlers, function(x) {
|
url.indexOf('web+' + x.startsWith) == 0 || // web protocols
|
||||||
if (url.indexOf(x.startWith) == 0) {
|
url.indexOf(x.startsWith.replace(':','://')) == 0 // from mobile devices
|
||||||
$log.debug('openURL GOT ' + x.name + ' URL');
|
;
|
||||||
return $state.transitionTo(x.transitionTo, {
|
|
||||||
url: url
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
$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() {
|
var handleResume = function() {
|
||||||
$log.debug('Handle Resume @ openURL...');
|
$log.debug('Handle Resume @ openURL...');
|
||||||
document.addEventListener('handleopenurl', handleOpenUrl, false);
|
document.addEventListener('handleopenurl', handleOpenURL, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
root.init = function() {
|
root.init = function() {
|
||||||
console.log('[openURL.js.29]'); //TODO
|
$log.debug('Initializing openURL');
|
||||||
document.addEventListener('handleopenurl', handleOpenURL, false);
|
document.addEventListener('handleopenurl', handleOpenURL, false);
|
||||||
document.addEventListener('resume', handleResume, 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) {
|
root.registerHandler = function(x) {
|
||||||
$log.debug('Registering URL Handler: ' + x.name);
|
$log.debug('Registering URL Handler: ' + x.name);
|
||||||
root.registeredUriHandlers.push(x);
|
root.registeredUriHandlers.push(x);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
root.handleURL = handleOpenURL;
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -293,7 +293,6 @@ angular.module('copayApp.services')
|
||||||
var name = opts.name || gettextCatalog.getString('Personal Wallet');
|
var name = opts.name || gettextCatalog.getString('Personal Wallet');
|
||||||
var myName = opts.myName || gettextCatalog.getString('me');
|
var myName = opts.myName || gettextCatalog.getString('me');
|
||||||
|
|
||||||
console.log('[profileService.js.303]', opts); //TODO
|
|
||||||
walletClient.createWallet(name, myName, opts.m, opts.n, {
|
walletClient.createWallet(name, myName, opts.m, opts.n, {
|
||||||
network: opts.networkName,
|
network: opts.networkName,
|
||||||
singleAddress: opts.singleAddress,
|
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