migration to platformInfo WIP

Conflicts:
	src/js/controllers/buyGlidera.js
	src/js/controllers/walletHome.js
	src/js/services/localStorage.js
This commit is contained in:
Matias Alejo Garcia 2016-05-31 14:55:08 -03:00
commit dd1981a26c
No known key found for this signature in database
GPG key ID: 02470DB551277AB3
23 changed files with 108 additions and 66 deletions

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('buyGlideraController', angular.module('copayApp.controllers').controller('buyGlideraController',
function($scope, $timeout, $modal, profileService, addressService, glideraService, bwsError, lodash, isChromeApp, animationService, walletService) { function($scope, $timeout, $modal, profileService, addressService, glideraService, bwsError, lodash, animationService, walletService) {
var self = this; var self = this;
this.show2faCodeInput = null; this.show2faCodeInput = null;

View file

@ -1,8 +1,9 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('coinbaseController', angular.module('copayApp.controllers').controller('coinbaseController',
function($rootScope, $scope, $timeout, $modal, profileService, configService, storageService, coinbaseService, isChromeApp, animationService, lodash, nodeWebkit) { function($rootScope, $scope, $timeout, $modal, profileService, configService, storageService, coinbaseService, animationService, lodash, nodeWebkit) {
var isChromeApp = platformInfo.isChromeApp;
window.ignoreMobilePause = true; window.ignoreMobilePause = true;
this.openAuthenticateWindow = function() { this.openAuthenticateWindow = function() {

View file

@ -1,11 +1,16 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('createController', angular.module('copayApp.controllers').controller('createController',
function($scope, $location, $anchorScroll, $rootScope, $timeout, $log, lodash, go, profileService, configService, isCordova, gettext, ledger, trezor, isMobile, isChromeApp, isDevel, derivationPathHelper) { function($scope, $location, $anchorScroll, $rootScope, $timeout, $log, lodash, go, profileService, configService, gettext, ledger, trezor, platformInfo, derivationPathHelper) {
var isChromeApp = platformInfo.isChromeApp;
var isCordova = platformInfo.isCordova;
var isDevel = platformInfo.isDevel;
var self = this; var self = this;
var defaults = configService.getDefaults(); var defaults = configService.getDefaults();
this.isWindowsPhoneApp = isMobile.Windows() && isCordova; this.isWindowsPhoneApp = platformInfo.isWP && isCordova;
$scope.account = 1; $scope.account = 1;
/* For compressed keys, m*73 + n*34 <= 496 */ /* For compressed keys, m*73 + n*34 <= 496 */

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('glideraController', angular.module('copayApp.controllers').controller('glideraController',
function($rootScope, $scope, $timeout, $modal, profileService, configService, storageService, glideraService, isChromeApp, animationService, lodash) { function($rootScope, $scope, $timeout, $modal, profileService, configService, storageService, glideraService, animationService, lodash) {
this.getAuthenticateUrl = function() { this.getAuthenticateUrl = function() {
return glideraService.getOauthCodeUrl(); return glideraService.getOauthCodeUrl();

View file

@ -1,7 +1,10 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('importController', angular.module('copayApp.controllers').controller('importController',
function($scope, $rootScope, $location, $timeout, $log, profileService, configService, notification, go, sjcl, gettext, lodash, ledger, trezor, isChromeApp, isDevel, derivationPathHelper) { function($scope, $rootScope, $location, $timeout, $log, profileService, configService, notification, go, sjcl, gettext, lodash, ledger, trezor, derivationPathHelper) {
var isChromeApp = platformInfo.isChromeApp;
var isDevel = platformInfo.isDevel;
var self = this; var self = this;
var reader = new FileReader(); var reader = new FileReader();

View file

@ -1,16 +1,18 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, latestReleaseService, bwcService, pushNotificationsService, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettext, gettextCatalog, amMoment, nodeWebkit, addonManager, isChromeApp, bwsError, txFormatService, uxLanguage, glideraService, coinbaseService, isMobile, addressbookService, walletService) { angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, latestReleaseService, bwcService, pushNotificationsService, lodash, go, profileService, configService, rateService, storageService, addressService, gettext, gettextCatalog, amMoment, nodeWebkit, addonManager, bwsError, txFormatService, uxLanguage, glideraService, coinbaseService, platformInfo, addressbookService, walletService) {
var self = this; var self = this;
var SOFT_CONFIRMATION_LIMIT = 12; var SOFT_CONFIRMATION_LIMIT = 12;
var errors = bwcService.getErrors(); var errors = bwcService.getErrors();
var historyUpdateInProgress = {}; var historyUpdateInProgress = {};
var isChromeApp = platformInfo.isChromeApp;
var isCordova = platformInfo.isCordova;
var ret = {}; var ret = {};
ret.isCordova = isCordova; ret.isCordova = isCordova;
ret.isChromeApp = isChromeApp; ret.isChromeApp = isChromeApp;
ret.isSafari = isMobile.Safari(); ret.isSafari = platformInfo.isSafari;
ret.isWindowsPhoneApp = isMobile.Windows() && isCordova; ret.isWindowsPhoneApp = platformInfo.isWP;
ret.onGoingProcess = {}; ret.onGoingProcess = {};
ret.historyShowLimit = 10; ret.historyShowLimit = 10;
ret.historyShowMoreLimit = 100; ret.historyShowMoreLimit = 100;
@ -1669,7 +1671,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
$rootScope.$on('Local/DeviceError', function(event, err) { $rootScope.$on('Local/DeviceError', function(event, err) {
self.showErrorPopup(err, function() { self.showErrorPopup(err, function() {
if (self.isCordova && navigator && navigator.app) { if (isCordova && navigator && navigator.app) {
navigator.app.exitApp(); navigator.app.exitApp();
} }
}); });

View file

@ -1,7 +1,10 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('joinController', angular.module('copayApp.controllers').controller('joinController',
function($scope, $rootScope, $timeout, go, notification, profileService, configService, isCordova, storageService, applicationService, $modal, gettext, lodash, ledger, trezor, isChromeApp, isDevel,derivationPathHelper) { function($scope, $rootScope, $timeout, go, notification, profileService, configService, isCordova, storageService, applicationService, $modal, gettext, lodash, ledger, trezor, platformInfo, derivationPathHelper) {
var isChromeApp = platformInfo.isChromeApp;
var isDevel = platformInfo.isDevel;
var self = this; var self = this;
var defaults = configService.getDefaults(); var defaults = configService.getDefaults();

View file

@ -1,6 +1,11 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $interval, $timeout, $filter, $modal, $log, notification, txStatus, isCordova, isMobile, profileService, lodash, configService, rateService, storageService, bitcore, isChromeApp, gettext, gettextCatalog, nodeWebkit, addressService, ledger, bwsError, confirmDialog, txFormatService, animationService, addressbookService, go, feeService, walletService, fingerprintService) { angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $interval, $timeout, $filter, $modal, $log, notification, txStatus, profileService, lodash, configService, rateService, storageService, bitcore, gettext, gettextCatalog, platformInfo, addressService, ledger, bwsError, confirmDialog, txFormatService, animationService, addressbookService, go, feeService, walletService, fingerprintService) {
var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;
var isAndroid = platformInfo.isAndroid;
var isChromeApp = platformInfo.isChromeApp; >>> >>> > migration to platformInfo WIP
var self = this; var self = this;
window.ignoreMobilePause = false; window.ignoreMobilePause = false;
@ -21,8 +26,8 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
ret.unitDecimals = walletSettings.unitDecimals; ret.unitDecimals = walletSettings.unitDecimals;
ret.isCordova = isCordova; ret.isCordova = isCordova;
ret.addresses = []; ret.addresses = [];
ret.isMobile = isMobile.any(); ret.isMobile = platformInfo.isMobile;
ret.isWindowsPhoneApp = isMobile.Windows() && isCordova; ret.isWindowsPhoneApp = platformInfo.isWP;
ret.countDown = null; ret.countDown = null;
ret.sendMaxInfo = {}; ret.sendMaxInfo = {};
var vanillaScope = ret; var vanillaScope = ret;
@ -115,7 +120,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
}); });
var getClipboard = function(cb) { var getClipboard = function(cb) {
if (!isCordova || isMobile.Windows()) return cb(); if (!isCordova || platformInfo.isWP) return cb();
window.cordova.plugins.clipboard.paste(function(value) { window.cordova.plugins.clipboard.paste(function(value) {
var fc = profileService.focusedClient; var fc = profileService.focusedClient;
@ -216,7 +221,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
return; return;
} }
$scope.list = ab; $scope.list = ab;
$timeout(function(){ $timeout(function() {
$scope.$digest(); $scope.$digest();
}); });
}); });
@ -606,14 +611,14 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
if (isCordova) { if (isCordova) {
window.cordova.plugins.clipboard.copy(addr); window.cordova.plugins.clipboard.copy(addr);
window.plugins.toast.showShortCenter(gettextCatalog.getString('Copied to clipboard')); window.plugins.toast.showShortCenter(gettextCatalog.getString('Copied to clipboard'));
} else if (nodeWebkit.isDefined()) { } else if (platformInfo.isNW) {
nodeWebkit.writeToClipboard(addr); nodeWebkit.writeToClipboard(addr);
} }
}; };
this.shareAddress = function(addr) { this.shareAddress = function(addr) {
if (isCordova) { if (isCordova) {
if (isMobile.Android() || isMobile.Windows()) { if (isAndroid || isWP) {
window.ignoreMobilePause = true; window.ignoreMobilePause = true;
} }
window.plugins.socialsharing.share('bitcoin:' + addr, null, null, null); window.plugins.socialsharing.share('bitcoin:' + addr, null, null, null);
@ -693,7 +698,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
$scope.shareAddress = function(uri) { $scope.shareAddress = function(uri) {
if (isCordova) { if (isCordova) {
if (isMobile.Android() || isMobile.Windows()) { if (isAndroid || isWP) {
window.ignoreMobilePause = true; window.ignoreMobilePause = true;
} }
window.plugins.socialsharing.share(uri, null, null, null); window.plugins.socialsharing.share(uri, null, null, null);

View file

@ -20,12 +20,12 @@ angular
$urlRouterProvider.otherwise('/'); $urlRouterProvider.otherwise('/');
$logProvider.debugEnabled(true); $logProvider.debugEnabled(true);
$provide.decorator('$log', ['$delegate', 'isDevel', $provide.decorator('$log', ['$delegate', 'platformInfo',
function($delegate, isDevel) { function($delegate, platformInfo) {
var historicLog = historicLogProvider.$get(); var historicLog = historicLogProvider.$get();
['debug', 'info', 'warn', 'error', 'log'].forEach(function(level) { ['debug', 'info', 'warn', 'error', 'log'].forEach(function(level) {
if (isDevel && level == 'error') return; if (platformInfo.isDevel && level == 'error') return;
var orig = $delegate[level]; var orig = $delegate[level];
$delegate[level] = function() { $delegate[level] = function() {
@ -531,7 +531,7 @@ angular
url: '/cordova/:status/:fromHome/:fromDisclaimer/:secondBackButtonPress', url: '/cordova/:status/:fromHome/:fromDisclaimer/:secondBackButtonPress',
views: { views: {
'main': { 'main': {
controller: function($rootScope, $state, $stateParams, $timeout, go, isCordova, gettextCatalog) { controller: function($rootScope, $state, $stateParams, $timeout, go, platformInfo, gettextCatalog) {
switch ($stateParams.status) { switch ($stateParams.status) {
case 'resume': case 'resume':
@ -542,7 +542,7 @@ angular
if ($stateParams.fromDisclaimer == 'true') if ($stateParams.fromDisclaimer == 'true')
navigator.app.exitApp(); navigator.app.exitApp();
if (isCordova && $stateParams.fromHome == 'true' && !$rootScope.modalOpened) { if (platformInfo.isCordova && $stateParams.fromHome == 'true' && !$rootScope.modalOpened) {
if ($stateParams.secondBackButtonPress == 'true') { if ($stateParams.secondBackButtonPress == 'true') {
navigator.app.exitApp(); navigator.app.exitApp();
} else { } else {
@ -563,16 +563,16 @@ angular
needProfile: false needProfile: false
}); });
}) })
.run(function($rootScope, $state, $log, uriHandler, isCordova, profileService, $timeout, nodeWebkit, uxLanguage, animationService) { .run(function($rootScope, $state, $log, uriHandler, platformInfo, profileService, $timeout, uxLanguage, animationService) {
uxLanguage.init(); uxLanguage.init();
// Register URI handler, not for mobileApp // Register URI handler, not for mobileApp
if (!isCordova) { if (!platformInfo.isCordova) {
uriHandler.register(); uriHandler.register();
} }
if (nodeWebkit.isDefined()) { if (platformInfo.isNW) {
var gui = require('nw.gui'); var gui = require('nw.gui');
var win = gui.Window.get(); var win = gui.Window.get();
var nativeMenuBar = new gui.Menu({ var nativeMenuBar = new gui.Menu({

View file

@ -1,10 +1,12 @@
'use strict'; 'use strict';
angular.module('copayApp.services').factory('animationService', function(isCordova) { angular.module('copayApp.services').factory('animationService', function(platformInfo) {
var root = {}; var root = {};
var cachedTransitionState, cachedBackPanel; var cachedTransitionState, cachedBackPanel;
var isCordova = platformInfo.isCordova;
// DISABLE ANIMATION ON DESKTOP // DISABLE ANIMATION ON DESKTOP
root.modalAnimated = { root.modalAnimated = {
slideUp: isCordova ? 'full animated slideInUp' : 'full', slideUp: isCordova ? 'full animated slideInUp' : 'full',

View file

@ -1,11 +1,14 @@
'use strict'; 'use strict';
angular.module('copayApp.services') angular.module('copayApp.services')
.factory('applicationService', function($rootScope, $timeout, isCordova, isChromeApp, nodeWebkit, go) { .factory('applicationService', function($rootScope, $timeout, platformInfo, go) {
var root = {}; var root = {};
var isChromeApp = platformInfo.isChromeApp;
var isNW = platformInfo.isNW;
root.restart = function() { root.restart = function() {
var hashIndex = window.location.href.indexOf('#/'); var hashIndex = window.location.href.indexOf('#/');
if (isCordova) { if (platformInfo.isCordova) {
window.location = window.location.href.substr(0, hashIndex); window.location = window.location.href.substr(0, hashIndex);
$timeout(function() { $timeout(function() {
$rootScope.$digest(); $rootScope.$digest();
@ -15,7 +18,7 @@ angular.module('copayApp.services')
// Go home reloading the application // Go home reloading the application
if (isChromeApp) { if (isChromeApp) {
chrome.runtime.reload(); chrome.runtime.reload();
} else if (nodeWebkit.isDefined()) { } else if (isNW) {
go.walletHome(); go.walletHome();
$timeout(function() { $timeout(function() {
var win = require('nw.gui').Window.get(); var win = require('nw.gui').Window.get();

View file

@ -1,8 +1,9 @@
'use strict'; 'use strict';
angular.module('copayApp.services').factory('coinbaseService', function($http, $log, isCordova, lodash, storageService, configService) { angular.module('copayApp.services').factory('coinbaseService', function($http, $log, platformInfo, lodash, storageService, configService) {
var root = {}; var root = {};
var credentials = {}; var credentials = {};
var isCordova = platformInfo.isCordova;
root.setCredentials = function(network) { root.setCredentials = function(network) {
credentials.SCOPE = '' credentials.SCOPE = ''

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
angular.module('copayApp.services').factory('confirmDialog', function($log, $timeout, profileService, configService, gettextCatalog, isCordova, isChromeApp) { angular.module('copayApp.services').factory('confirmDialog', function($log, $timeout, profileService, configService, gettextCatalog, platformInfo) {
var root = {}; var root = {};
@ -10,7 +10,7 @@ angular.module('copayApp.services').factory('confirmDialog', function($log, $tim
var confirmMsg = gettextCatalog.getString('Confirm'); var confirmMsg = gettextCatalog.getString('Confirm');
root.show = function(msg, cb) { root.show = function(msg, cb) {
if (isCordova) { if (platformInfo.isCordova) {
navigator.notification.confirm( navigator.notification.confirm(
msg, msg,
function(buttonIndex) { function(buttonIndex) {
@ -24,7 +24,7 @@ angular.module('copayApp.services').factory('confirmDialog', function($log, $tim
}, },
confirmMsg, [acceptMsg, cancelMsg] confirmMsg, [acceptMsg, cancelMsg]
); );
} else if (isChromeApp) { } else if (platformInfo.isChromeApp) {
// No feedback, alert/confirm not supported. // No feedback, alert/confirm not supported.
return cb(true); return cb(true);
} else { } else {

View file

@ -1,8 +1,9 @@
'use strict'; 'use strict';
angular.module('copayApp.services').factory('glideraService', function($http, $log, isCordova) { angular.module('copayApp.services').factory('glideraService', function($http, $log, platformInfo) {
var root = {}; var root = {};
var credentials = {}; var credentials = {};
var isCordova = platformInfo.isCordova;
root.setCredentials = function(network) { root.setCredentials = function(network) {
if (network == 'testnet') { if (network == 'testnet') {

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.services').factory('go', function($window, $rootScope, $location, $state, $timeout, $log, profileService, nodeWebkit) { angular.module('copayApp.services').factory('go', function($window, $rootScope, $location, $state, $timeout, $log, profileService, platformInfo, nodeWebkit) {
var root = {}; var root = {};
var hideSidebars = function() { var hideSidebars = function() {
@ -30,7 +30,7 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope,
}; };
root.openExternalLink = function(url, target) { root.openExternalLink = function(url, target) {
if (nodeWebkit.isDefined()) { if ( platformInfo.isNW) {
nodeWebkit.openExternalLink(url); nodeWebkit.openExternalLink(url);
} else { } else {
target = target || '_blank'; target = target || '_blank';

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.services') angular.module('copayApp.services')
.factory('latestReleaseService', function latestReleaseServiceFactory($log, $http, configService, gettext, nodeWebkit) { .factory('latestReleaseService', function latestReleaseServiceFactory($log, $http, configService) {
var root = {}; var root = {};

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.services') angular.module('copayApp.services')
.factory('legacyImportService', function($rootScope, $log, $timeout, $http, lodash, bitcore, bwcService, sjcl, profileService, isChromeApp) { .factory('legacyImportService', function($rootScope, $log, $timeout, $http, lodash, bitcore, bwcService, sjcl, profileService, platformInfo) {
var root = {}; var root = {};
var wc = bwcService.getClient(); var wc = bwcService.getClient();
@ -126,7 +126,7 @@ angular.module('copayApp.services')
}; };
var localStorageGet = function(key, cb) { var localStorageGet = function(key, cb) {
if (isChromeApp) { if (platformInfo.isChromeApp) {
chrome.storage.local.get(key, chrome.storage.local.get(key,
function(data) { function(data) {
return cb(null, data[key]); return cb(null, data[key]);

View file

@ -1,20 +1,21 @@
'use strict'; 'use strict';
angular.module('copayApp.services') angular.module('copayApp.services')
.factory('localStorageService', function(isChromeApp, nodeWebkit, $timeout) { .factory('localStorageService', function(platformInfo, $timeout) {
var isNW = platformInfo.isNW;
var isChromeApp = platformInfo.isChromeApp;
var root = {}; var root = {};
var ls = ((typeof window.localStorage !== "undefined") ? window.localStorage : null); var ls = ((typeof window.localStorage !== "undefined") ? window.localStorage : null);
if (isChromeApp && !nodeWebkit.isDefined() && !ls) { if (isChromeApp && !isNW && !ls) {
ls = localStorage = chrome.storage.local; ls = chrome.storage.local;
window.localStorage = chrome.storage.local;
} }
if (!ls) if (!ls)
throw new Error('localstorage not available'); throw new Error('localstorage not available');
root.get = function(k, cb) { root.get = function(k, cb) {
if (isChromeApp && !nodeWebkit.isDefined()) { if (isChromeApp && !isNW) {
chrome.storage.local.get(k, chrome.storage.local.get(k,
function(data) { function(data) {
//TODO check for errors //TODO check for errors
@ -40,7 +41,7 @@ angular.module('copayApp.services')
}; };
root.set = function(k, v, cb) { root.set = function(k, v, cb) {
if (isChromeApp && !nodeWebkit.isDefined()) { if (isChromeApp && !isNW) {
var obj = {}; var obj = {};
obj[k] = v; obj[k] = v;
@ -53,7 +54,7 @@ angular.module('copayApp.services')
}; };
root.remove = function(k, cb) { root.remove = function(k, cb) {
if (isChromeApp && !nodeWebkit.isDefined()) { if (isChromeApp && !isNW) {
chrome.storage.local.remove(k, cb); chrome.storage.local.remove(k, cb);
} else { } else {
ls.removeItem(k); ls.removeItem(k);

View file

@ -1,8 +1,7 @@
'use strict'; 'use strict';
angular.module('copayApp.services') angular.module('copayApp.services')
.factory('logHeader', function($log, isChromeApp, isCordova, nodeWebkit) { .factory('logHeader', function($log, platformInfo) {
$log.info('Starting Copay v' + window.version + ' #' + window.commitHash); $log.info('Starting Copay v' + window.version + ' #' + window.commitHash);
$log.info('Client: isCordova:', isCordova, 'isChromeApp:', isChromeApp, 'isNodeWebkit:', nodeWebkit.isDefined()); $log.info('Client: '+ JSON.stringify(platformInfo) );
$log.info('Navigator:', navigator.userAgent);
return {}; return {};
}); });

View file

@ -1,15 +1,20 @@
'use strict'; 'use strict';
angular.module('copayApp.services').factory('platformInfo', function( $navigator, $window) { angular.module('copayApp.services').factory('platformInfo', function($window) {
var ua= $navigator.userAgent; var ua = navigator ? navigator.userAgent : null;
if (!ua) {
console.log('Could not determine navigator. Using a random string');
ua = Math.floor(Math.random() * 100000);
}
var isNodeWebkit = function() { var isNodeWebkit = function() {
var isNode = (typeof process !== "undefined" && typeof require !== "undefined"); var isNode = (typeof process !== "undefined" && typeof require !== "undefined");
if(isNode) { if (isNode) {
try { try {
return (typeof require('nw.gui') !== "undefined"); return (typeof require('nw.gui') !== "undefined");
} catch(e) { } catch (e) {
return false; return false;
} }
} }
@ -27,16 +32,17 @@ angular.module('copayApp.services').factory('platformInfo', function( $navigator
isWP: function() { isWP: function() {
return !!ua.match(/IEMobile/i); return !!ua.match(/IEMobile/i);
}, },
Safari: function() { isSafari: function() {
return Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0; return Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
} }
}; };
ret.ua = ua;
ret.isMobile = ret.isAndroid() || ret.isIOS() || ret.isWP(); ret.isMobile = ret.isAndroid() || ret.isIOS() || ret.isWP();
ret.isChromeApp = !!($window.chrome && chrome.runtime && chrome.runtime.id && !nodeWebkit.isDefined());
ret.isCordova = !!$window.cordova; ret.isCordova = !!$window.cordova;
ret.isNW = isNodeWebkit(); ret.isNW = isNodeWebkit();
ret.isDevel =!ret.isMobile() && !ret.isChromeApp && !ret.isNW(); ret.isChromeApp = $window.chrome && chrome.runtime && chrome.runtime.id && !ret.isNW;
ret.isDevel = !ret.isMobile && !ret.isChromeApp && !ret.isNW;
return ret; return ret;
}); });

View file

@ -1,10 +1,15 @@
'use strict'; 'use strict';
angular.module('copayApp.services') angular.module('copayApp.services')
.factory('profileService', function profileServiceFactory($rootScope, $timeout, $filter, $log, sjcl, lodash, storageService, bwcService, configService, notificationService, pushNotificationsService, isChromeApp, isCordova, isMobile, gettext, gettextCatalog, nodeWebkit, bwsError, uxLanguage, bitcore) { .factory('profileService', function profileServiceFactory($rootScope, $timeout, $filter, $log, sjcl, lodash, storageService, bwcService, configService, notificationService, pushNotificationsService, gettext, gettextCatalog, bwsError, uxLanguage, bitcore, platformInfo) {
var isChromeApp = platformInfo.isChromeApp;
var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;
var root = {}; var root = {};
var errors = bwcService.getErrors(); var errors = bwcService.getErrors();
var usePushNotifications = isCordova && !isMobile.Windows(); var usePushNotifications = isCordova && !isWP;
var FOREGROUND_UPDATE_PERIOD = 5; var FOREGROUND_UPDATE_PERIOD = 5;
var BACKGROUND_UPDATE_PERIOD = 30; var BACKGROUND_UPDATE_PERIOD = 30;

View file

@ -1,8 +1,13 @@
'use strict'; 'use strict';
angular.module('copayApp.services') angular.module('copayApp.services')
.factory('pushNotificationsService', function($log, isMobile, storageService, configService, lodash, isCordova) { .factory('pushNotificationsService', function($log, platformInfo, storageService, configService, lodash) {
var root = {}; var root = {};
var usePushNotifications = isCordova && !isMobile.Windows(); var isCordova = platformInfo.isCordova;
var isWP = platformInfo.isWP;
var isIOS = platformInfo.isIOS;
var isAndroid = platformInfo.isAndroid;
var usePushNotifications = isCordova && !isWP;
root.init = function(walletsClients) { root.init = function(walletsClients) {
var defaults = configService.getDefaults(); var defaults = configService.getDefaults();
@ -32,7 +37,7 @@ angular.module('copayApp.services')
lodash.forEach(walletsClients, function(walletClient) { lodash.forEach(walletsClients, function(walletClient) {
var opts = {}; var opts = {};
opts.type = isMobile.iOS() ? "ios" : isMobile.Android() ? "android" : null; opts.type = isIOS ? "ios" : isAndroid ? "android" : null;
opts.token = root.token; opts.token = root.token;
root.subscribe(opts, walletClient, function(err, response) { root.subscribe(opts, walletClient, function(err, response) {
if (err) $log.warn('Subscription error: ' + err.message + ': ' + JSON.stringify(opts)); if (err) $log.warn('Subscription error: ' + err.message + ': ' + JSON.stringify(opts));

View file

@ -1,12 +1,12 @@
'use strict'; 'use strict';
angular.module('copayApp.services') angular.module('copayApp.services')
.factory('storageService', function(logHeader, fileStorageService, localStorageService, sjcl, $log, lodash, isCordova) { .factory('storageService', function(logHeader, fileStorageService, localStorageService, sjcl, $log, lodash, platformInfo) {
var root = {}; var root = {};
// File storage is not supported for writing according to // File storage is not supported for writing according to
// https://github.com/apache/cordova-plugin-file/#supported-platforms // https://github.com/apache/cordova-plugin-file/#supported-platforms
var shouldUseFileStorage = isCordova && !isMobile.Windows(); var shouldUseFileStorage = platformInfo.isCordova && !platformInfo.isWP;
$log.debug('Using file storage:', shouldUseFileStorage); $log.debug('Using file storage:', shouldUseFileStorage);