diff --git a/src/js/controllers/buyGlidera.js b/src/js/controllers/buyGlidera.js index 2add687cb..018d13c8d 100644 --- a/src/js/controllers/buyGlidera.js +++ b/src/js/controllers/buyGlidera.js @@ -1,7 +1,7 @@ 'use strict'; 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; this.show2faCodeInput = null; diff --git a/src/js/controllers/coinbase.js b/src/js/controllers/coinbase.js index 780d4bc1d..4af218f8a 100644 --- a/src/js/controllers/coinbase.js +++ b/src/js/controllers/coinbase.js @@ -1,13 +1,14 @@ 'use strict'; 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, platformInfo) { + var isNW = platformInfo.isNW; window.ignoreMobilePause = true; this.openAuthenticateWindow = function() { var oauthUrl = this.getAuthenticateUrl(); - if (!nodeWebkit.isDefined()) { + if (!isNW) { $rootScope.openExternalLink(oauthUrl, '_system'); } else { var self = this; diff --git a/src/js/controllers/copayers.js b/src/js/controllers/copayers.js index 726828103..a4fcb5b91 100644 --- a/src/js/controllers/copayers.js +++ b/src/js/controllers/copayers.js @@ -1,8 +1,11 @@ 'use strict'; angular.module('copayApp.controllers').controller('copayersController', - function($scope, $rootScope, $timeout, $log, $modal, profileService, go, notification, isCordova, gettext, gettextCatalog, animationService) { + function($scope, $rootScope, $timeout, $log, $modal, profileService, go, notification, platformInfo, gettext, gettextCatalog, animationService) { var self = this; + var isCordova = platformInfo.isCordova; + var isWP = platformInfo.isWP; + var isAndroid = platformInfo.isAndroid; var delete_msg = gettextCatalog.getString('Are you sure you want to delete this wallet?'); var accept_msg = gettextCatalog.getString('Accept'); @@ -103,7 +106,7 @@ angular.module('copayApp.controllers').controller('copayersController', self.shareSecret = function(secret) { if (isCordova) { - if (isMobile.Android() || isMobile.Windows()) { + if (isAndroid || isWP) { window.ignoreMobilePause = true; } var message = gettextCatalog.getString('Join my Copay wallet. Here is the invitation code: {{secret}} You can download Copay for your phone or desktop at https://copay.io', {secret: secret}); diff --git a/src/js/controllers/create.js b/src/js/controllers/create.js index 5270f4622..3457651b0 100644 --- a/src/js/controllers/create.js +++ b/src/js/controllers/create.js @@ -1,11 +1,16 @@ 'use strict'; 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 defaults = configService.getDefaults(); - this.isWindowsPhoneApp = isMobile.Windows() && isCordova; + this.isWindowsPhoneApp = platformInfo.isWP && isCordova; $scope.account = 1; /* For compressed keys, m*73 + n*34 <= 496 */ diff --git a/src/js/controllers/disclaimer.js b/src/js/controllers/disclaimer.js index d6ac84576..d8891825d 100644 --- a/src/js/controllers/disclaimer.js +++ b/src/js/controllers/disclaimer.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('disclaimerController', - function($scope, $timeout, $log, profileService, isCordova, applicationService, gettextCatalog, uxLanguage, go) { + function($scope, $timeout, $log, profileService, applicationService, gettextCatalog, uxLanguage, go) { var self = this; self.tries = 0; $scope.creatingProfile = true; diff --git a/src/js/controllers/export.js b/src/js/controllers/export.js index 79402d6e7..21fe8d8ac 100644 --- a/src/js/controllers/export.js +++ b/src/js/controllers/export.js @@ -1,8 +1,10 @@ 'use strict'; angular.module('copayApp.controllers').controller('exportController', - function($rootScope, $scope, $timeout, $log, backupService, storageService, profileService, isMobile, notification, go, gettext, gettextCatalog) { + function($rootScope, $scope, $timeout, $log, backupService, storageService, profileService, platformInfo, notification, go, gettext, gettextCatalog) { var self = this; + var isWP = platformInfo.isWP; + var isAndroid = platformInfo.isAndroid; self.error = null; self.success = null; @@ -125,7 +127,7 @@ angular.module('copayApp.controllers').controller('exportController', self.sendWalletBackup = function() { var fc = profileService.focusedClient; - if (isMobile.Android() || isMobile.Windows()) { + if (isAndroid || isWP) { window.ignoreMobilePause = true; } window.plugins.toast.showShortCenter(gettextCatalog.getString('Preparing backup...')); diff --git a/src/js/controllers/glidera.js b/src/js/controllers/glidera.js index fbce3e95d..7c4df16d9 100644 --- a/src/js/controllers/glidera.js +++ b/src/js/controllers/glidera.js @@ -1,7 +1,7 @@ 'use strict'; 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() { return glideraService.getOauthCodeUrl(); diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js index e200961a3..35f27ed8a 100644 --- a/src/js/controllers/import.js +++ b/src/js/controllers/import.js @@ -1,7 +1,10 @@ 'use strict'; 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, platformInfo) { + + var isChromeApp = platformInfo.isChromeApp; + var isDevel = platformInfo.isDevel; var self = this; var reader = new FileReader(); diff --git a/src/js/controllers/index.js b/src/js/controllers/index.js index fbde07792..31db70abb 100644 --- a/src/js/controllers/index.js +++ b/src/js/controllers/index.js @@ -1,16 +1,19 @@ '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, addonManager, bwsError, txFormatService, uxLanguage, glideraService, coinbaseService, platformInfo, addressbookService, walletService) { var self = this; var SOFT_CONFIRMATION_LIMIT = 12; var errors = bwcService.getErrors(); var historyUpdateInProgress = {}; + var isChromeApp = platformInfo.isChromeApp; + var isCordova = platformInfo.isCordova; + var isNW = platformInfo.isNW; var ret = {}; ret.isCordova = isCordova; ret.isChromeApp = isChromeApp; - ret.isSafari = isMobile.Safari(); - ret.isWindowsPhoneApp = isMobile.Windows() && isCordova; + ret.isSafari = platformInfo.isSafari; + ret.isWindowsPhoneApp = platformInfo.isWP; ret.onGoingProcess = {}; ret.historyShowLimit = 10; ret.historyShowMoreLimit = 100; @@ -46,7 +49,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r ret.tab = 'walletHome'; var vanillaScope = ret; - if (nodeWebkit.isDefined()) { + if (isNW) { latestReleaseService.checkLatestRelease(function(err, newRelease) { if (err) { $log.warn(err); @@ -739,7 +742,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r $log.info('CSV generation not available in mobile'); return; } - var isNode = nodeWebkit.isDefined(); var fc = profileService.focusedClient; var c = fc.credentials; if (!fc.isComplete()) return; @@ -1669,7 +1671,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r $rootScope.$on('Local/DeviceError', function(event, err) { self.showErrorPopup(err, function() { - if (self.isCordova && navigator && navigator.app) { + if (isCordova && navigator && navigator.app) { navigator.app.exitApp(); } }); diff --git a/src/js/controllers/join.js b/src/js/controllers/join.js index 5a6ceabbb..9e10cc5b6 100644 --- a/src/js/controllers/join.js +++ b/src/js/controllers/join.js @@ -1,7 +1,10 @@ 'use strict'; 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, storageService, applicationService, $modal, gettext, lodash, ledger, trezor, platformInfo, derivationPathHelper) { + + var isChromeApp = platformInfo.isChromeApp; + var isDevel = platformInfo.isDevel; var self = this; var defaults = configService.getDefaults(); diff --git a/src/js/controllers/preferencesDelete.js b/src/js/controllers/preferencesDelete.js index 62e7c4ed8..e176fc5c6 100644 --- a/src/js/controllers/preferencesDelete.js +++ b/src/js/controllers/preferencesDelete.js @@ -1,7 +1,8 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesDeleteWalletController', - function($scope, $rootScope, $filter, $timeout, $modal, $log, storageService, notification, profileService, isCordova, go, gettext, gettextCatalog, animationService, applicationService) { + function($scope, $rootScope, $filter, $timeout, $modal, $log, storageService, notification, profileService, platformInfo, go, gettext, gettextCatalog, animationService, applicationService) { + var isCordova = platformInfo.isCordova; this.isCordova = isCordova; this.error = null; $scope.isDeletingWallet = false; diff --git a/src/js/controllers/preferencesGlidera.js b/src/js/controllers/preferencesGlidera.js index c2a901379..2c81e4e74 100644 --- a/src/js/controllers/preferencesGlidera.js +++ b/src/js/controllers/preferencesGlidera.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesGlideraController', - function($scope, $modal, $timeout, profileService, applicationService, glideraService, storageService, isChromeApp, animationService) { + function($scope, $modal, $timeout, profileService, applicationService, glideraService, storageService, animationService) { this.getEmail = function(token) { var self = this; diff --git a/src/js/controllers/preferencesGlobal.js b/src/js/controllers/preferencesGlobal.js index b38773da3..884e904e1 100644 --- a/src/js/controllers/preferencesGlobal.js +++ b/src/js/controllers/preferencesGlobal.js @@ -1,8 +1,9 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesGlobalController', - function($scope, $rootScope, $log, configService, uxLanguage, isCordova, isMobile, pushNotificationsService, profileService, feeService) { + function($scope, $rootScope, $log, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService) { + var isCordova = platformInfo.isCordova; this.init = function() { var config = configService.getSync(); this.unitName = config.wallet.settings.unitName; @@ -13,9 +14,9 @@ angular.module('copayApp.controllers').controller('preferencesGlobalController', }; this.feeOpts = feeService.feeOpts; this.currentFeeLevel = feeService.getCurrentFeeLevel(); - this.usePushNotifications = isCordova && !isMobile.Windows(); + this.usePushNotifications = isCordova && !platformInfo.isWP; $scope.PNEnabledByUser = true; - $scope.isIOSApp = isMobile.iOS() && isCordova; + $scope.isIOSApp = platformInfo.isIOS && isCordova; if ($scope.isIOSApp) { cordova.plugins.diagnostic.isRemoteNotificationsEnabled(function(isEnabled) { $scope.PNEnabledByUser = isEnabled; diff --git a/src/js/controllers/preferencesInformation.js b/src/js/controllers/preferencesInformation.js index f93055460..a3f148c61 100644 --- a/src/js/controllers/preferencesInformation.js +++ b/src/js/controllers/preferencesInformation.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('preferencesInformation', - function($scope, $log, $timeout, isMobile, gettextCatalog, lodash, profileService, storageService, go, bitcore) { + function($scope, $log, $timeout, platformInfo, gettextCatalog, lodash, profileService, storageService, go, bitcore) { var base = 'xpub'; var fc = profileService.focusedClient; var c = fc.credentials; @@ -20,20 +20,6 @@ angular.module('copayApp.controllers').controller('preferencesInformation', $scope.pubKeys = lodash.pluck(c.publicKeyRing, 'xPubKey'); $scope.addrs = null; - - if (isMobile.Android()) { - $scope.androidTest = 'testing'; - - var xp = bitcore.HDPrivateKey("tprv8ZgxMBicQKsPebv8CVghFoaaZ6ejmcSmSaKo99sUnswCCPeccGbLzfoksA2wd5XdHe8UHLwM2emuBWD4cBvQ7BPTJhFu75u3HcSjRVFmYM9"); - - var pub = xp.derive("m/44'/1'/0'").hdPublicKey.toString(); - if (pub == 'tpubDCe5stHkJZhfNMpQLgqRVYjSfADoosJ7FvxukgyXf1YzrCnru2z61giPXbgJGGxnHt922CY22DDDYD6d28jnd9okctoXNW837TmbNaAEM99') { - $scope.androidTest = 'OK, TEST PASSED'; - } else { - $scope.androidTest = 'FAILED!! Please report to matias@bitpay.com. Result:' + pub; - } - } - fc.getMainAddresses({ doNotVerify: true }, function(err, addrs) { @@ -60,7 +46,7 @@ angular.module('copayApp.controllers').controller('preferencesInformation', this.sendAddrs = function() { var self = this; - if (isMobile.Android() || isMobile.Windows()) { + if (platformInfo.isAndroid || platformInfo.isWP) { window.ignoreMobilePause = true; } diff --git a/src/js/controllers/sellGlidera.js b/src/js/controllers/sellGlidera.js index 129f2fb53..989fa1c7f 100644 --- a/src/js/controllers/sellGlidera.js +++ b/src/js/controllers/sellGlidera.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('sellGlideraController', - function($rootScope, $scope, $timeout, $log, $modal, configService, profileService, addressService, feeService, glideraService, bwsError, lodash, isChromeApp, animationService, walletService, fingerprintService) { + function($rootScope, $scope, $timeout, $log, $modal, configService, profileService, addressService, feeService, glideraService, bwsError, lodash, animationService, walletService, fingerprintService) { var self = this; var config = configService.getSync(); diff --git a/src/js/controllers/sidebar.js b/src/js/controllers/sidebar.js index b9efcd88c..af34c6f57 100644 --- a/src/js/controllers/sidebar.js +++ b/src/js/controllers/sidebar.js @@ -1,9 +1,9 @@ 'use strict'; angular.module('copayApp.controllers').controller('sidebarController', - function($rootScope, $timeout, lodash, profileService, configService, go, isMobile, isCordova) { + function($rootScope, $timeout, lodash, profileService, configService, go, platformInfo) { var self = this; - self.isWindowsPhoneApp = isMobile.Windows() && isCordova; + self.isWindowsPhoneApp = platformInfo.isWP && platformInfo.isCordova; self.walletSelection = false; // wallet list change diff --git a/src/js/controllers/tx.js b/src/js/controllers/tx.js index d9f9e4f39..9edc6d7fc 100644 --- a/src/js/controllers/tx.js +++ b/src/js/controllers/tx.js @@ -1,8 +1,9 @@ 'use strict'; angular.module('copayApp.controllers').controller('txController', - function($rootScope, $scope, $timeout, $filter, lodash, profileService, isCordova, nodeWebkit, configService, animationService, gettextCatalog) { + function($rootScope, $scope, $timeout, $filter, lodash, profileService, platformInfo, nodeWebkit, configService, animationService, gettextCatalog) { + var isCordova = platformInfo.isCordova; var fc = profileService.focusedClient; var config = configService.getSync(); var configWallet = config.wallet; @@ -53,7 +54,7 @@ angular.module('copayApp.controllers').controller('txController', if (isCordova) { window.cordova.plugins.clipboard.copy(value); window.plugins.toast.showShortCenter(gettextCatalog.getString('Copied to clipboard')); - } else if (nodeWebkit.isDefined()) { + } else if (platformInfo.isNW) { nodeWebkit.writeToClipboard(value); } }; diff --git a/src/js/controllers/walletHome.js b/src/js/controllers/walletHome.js index 5108e4b09..213db5443 100644 --- a/src/js/controllers/walletHome.js +++ b/src/js/controllers/walletHome.js @@ -1,6 +1,11 @@ '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, nodeWebkit) { + + var isCordova = platformInfo.isCordova; + var isWP = platformInfo.isWP; + var isAndroid = platformInfo.isAndroid; + var isChromeApp = platformInfo.isChromeApp; var self = this; window.ignoreMobilePause = false; @@ -21,8 +26,8 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi ret.unitDecimals = walletSettings.unitDecimals; ret.isCordova = isCordova; ret.addresses = []; - ret.isMobile = isMobile.any(); - ret.isWindowsPhoneApp = isMobile.Windows() && isCordova; + ret.isMobile = platformInfo.isMobile; + ret.isWindowsPhoneApp = platformInfo.isWP; ret.countDown = null; ret.sendMaxInfo = {}; var vanillaScope = ret; @@ -115,7 +120,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi }); var getClipboard = function(cb) { - if (!isCordova || isMobile.Windows()) return cb(); + if (!isCordova || platformInfo.isWP) return cb(); window.cordova.plugins.clipboard.paste(function(value) { var fc = profileService.focusedClient; @@ -216,7 +221,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi return; } $scope.list = ab; - $timeout(function(){ + $timeout(function() { $scope.$digest(); }); }); @@ -606,14 +611,14 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi if (isCordova) { window.cordova.plugins.clipboard.copy(addr); window.plugins.toast.showShortCenter(gettextCatalog.getString('Copied to clipboard')); - } else if (nodeWebkit.isDefined()) { + } else if (platformInfo.isNW) { nodeWebkit.writeToClipboard(addr); } }; this.shareAddress = function(addr) { if (isCordova) { - if (isMobile.Android() || isMobile.Windows()) { + if (isAndroid || isWP) { window.ignoreMobilePause = true; } window.plugins.socialsharing.share('bitcoin:' + addr, null, null, null); @@ -693,7 +698,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi $scope.shareAddress = function(uri) { if (isCordova) { - if (isMobile.Android() || isMobile.Windows()) { + if (isAndroid || isWP) { window.ignoreMobilePause = true; } window.plugins.socialsharing.share(uri, null, null, null); diff --git a/src/js/directives/qrScanner.js b/src/js/directives/qrScanner.js index ea3ae79e5..cb9bf0b88 100644 --- a/src/js/directives/qrScanner.js +++ b/src/js/directives/qrScanner.js @@ -1,174 +1,179 @@ 'use strict'; angular.module('copayApp.directives') - .directive('qrScanner', ['$rootScope', '$timeout', '$modal', 'isCordova', 'gettextCatalog', 'isMobile', - function($rootScope, $timeout, $modal, isCordova, gettextCatalog, isMobile) { + .directive('qrScanner', function($rootScope, $timeout, $modal, gettextCatalog, platformInfo) { - var controller = function($scope) { + var isCordova = platformInfo.isCordova; + var isWP = platformInfo.isWP; + var isIOS = platformInfo.isIOS; - var onSuccess = function(result) { - $timeout(function() { - window.plugins.spinnerDialog.hide(); - window.ignoreMobilePause = false; - }, 100); - if (isMobile.Windows() && result.cancelled) return; + var controller = function($scope) { - $timeout(function() { - var data = isMobile.iOS() ? result : result.text; - $scope.onScan({ data: data }); - }, 1000); - }; + var onSuccess = function(result) { + $timeout(function() { + window.plugins.spinnerDialog.hide(); + window.ignoreMobilePause = false; + }, 100); + if (isWP && result.cancelled) return; - var onError = function(error) { - $timeout(function() { - window.ignoreMobilePause = false; - window.plugins.spinnerDialog.hide(); - }, 100); - }; + $timeout(function() { + var data = isIOS ? result : result.text; + $scope.onScan({ + data: data + }); + }, 1000); + }; - $scope.cordovaOpenScanner = function() { - window.ignoreMobilePause = true; - window.plugins.spinnerDialog.show(null, gettextCatalog.getString('Preparing camera...'), true); - $timeout(function() { - if (isMobile.iOS()) { - cloudSky.zBar.scan({}, onSuccess, onError); - } else { - cordova.plugins.barcodeScanner.scan(onSuccess, onError); + var onError = function(error) { + $timeout(function() { + window.ignoreMobilePause = false; + window.plugins.spinnerDialog.hide(); + }, 100); + }; + + $scope.cordovaOpenScanner = function() { + window.ignoreMobilePause = true; + window.plugins.spinnerDialog.show(null, gettextCatalog.getString('Preparing camera...'), true); + $timeout(function() { + if (isIOS) { + cloudSky.zBar.scan({}, onSuccess, onError); + } else { + cordova.plugins.barcodeScanner.scan(onSuccess, onError); + } + if ($scope.beforeScan) { + $scope.beforeScan(); + } + }, 100); + }; + + $scope.modalOpenScanner = function() { + var parentScope = $scope; + var ModalInstanceCtrl = function($scope, $rootScope, $modalInstance) { + // QR code Scanner + var video; + var canvas; + var $video; + var context; + var localMediaStream; + var prevResult; + + var _scan = function(evt) { + if (localMediaStream) { + context.drawImage(video, 0, 0, 300, 225); + try { + qrcode.decode(); + } catch (e) { + //qrcodeError(e); } - if ($scope.beforeScan) { - $scope.beforeScan(); + } + $timeout(_scan, 800); + }; + + var _scanStop = function() { + if (localMediaStream && localMediaStream.active) { + var localMediaStreamTrack = localMediaStream.getTracks(); + for (var i = 0; i < localMediaStreamTrack.length; i++) { + localMediaStreamTrack[i].stop(); } - }, 100); + } else { + try { + localMediaStream.stop(); + } catch (e) { + // Older Chromium not support the STOP function + }; + } + localMediaStream = null; + video.src = ''; }; - $scope.modalOpenScanner = function() { - var parentScope = $scope; - var ModalInstanceCtrl = function($scope, $rootScope, $modalInstance) { - // QR code Scanner - var video; - var canvas; - var $video; - var context; - var localMediaStream; - var prevResult; - - var _scan = function(evt) { - if (localMediaStream) { - context.drawImage(video, 0, 0, 300, 225); - try { - qrcode.decode(); - } catch (e) { - //qrcodeError(e); - } - } - $timeout(_scan, 800); - }; - - var _scanStop = function() { - if (localMediaStream && localMediaStream.active) { - var localMediaStreamTrack = localMediaStream.getTracks(); - for (var i = 0; i < localMediaStreamTrack.length; i++) { - localMediaStreamTrack[i].stop(); - } - } else { - try { - localMediaStream.stop(); - } catch(e) { - // Older Chromium not support the STOP function - }; - } - localMediaStream = null; - video.src = ''; - }; - - qrcode.callback = function(data) { - if (prevResult != data) { - prevResult = data; - return; - } - _scanStop(); - $modalInstance.close(data); - }; - - var _successCallback = function(stream) { - video.src = (window.URL && window.URL.createObjectURL(stream)) || stream; - localMediaStream = stream; - video.play(); - $timeout(_scan, 1000); - }; - - var _videoError = function(err) { - $scope.cancel(); - }; - - var setScanner = function() { - navigator.getUserMedia = navigator.getUserMedia || - navigator.webkitGetUserMedia || navigator.mozGetUserMedia || - navigator.msGetUserMedia; - window.URL = window.URL || window.webkitURL || - window.mozURL || window.msURL; - }; - - $scope.init = function() { - setScanner(); - $timeout(function() { - if (parentScope.beforeScan) { - parentScope.beforeScan(); - } - canvas = document.getElementById('qr-canvas'); - context = canvas.getContext('2d'); - - - video = document.getElementById('qrcode-scanner-video'); - $video = angular.element(video); - canvas.width = 300; - canvas.height = 225; - context.clearRect(0, 0, 300, 225); - - navigator.getUserMedia({ - video: true - }, _successCallback, _videoError); - }, 500); - }; - - $scope.cancel = function() { - _scanStop(); - $modalInstance.dismiss('cancel'); - }; - }; - - var modalInstance = $modal.open({ - templateUrl: 'views/modals/scanner.html', - windowClass: 'full', - controller: ModalInstanceCtrl, - backdrop : 'static', - keyboard: false - }); - modalInstance.result.then(function(data) { - parentScope.onScan({ data: data }); - }); - + qrcode.callback = function(data) { + if (prevResult != data) { + prevResult = data; + return; + } + _scanStop(); + $modalInstance.close(data); }; - $scope.openScanner = function() { - if (isCordova) { - $scope.cordovaOpenScanner(); - } - else { - $scope.modalOpenScanner(); - } + var _successCallback = function(stream) { + video.src = (window.URL && window.URL.createObjectURL(stream)) || stream; + localMediaStream = stream; + video.play(); + $timeout(_scan, 1000); + }; + + var _videoError = function(err) { + $scope.cancel(); + }; + + var setScanner = function() { + navigator.getUserMedia = navigator.getUserMedia || + navigator.webkitGetUserMedia || navigator.mozGetUserMedia || + navigator.msGetUserMedia; + window.URL = window.URL || window.webkitURL || + window.mozURL || window.msURL; + }; + + $scope.init = function() { + setScanner(); + $timeout(function() { + if (parentScope.beforeScan) { + parentScope.beforeScan(); + } + canvas = document.getElementById('qr-canvas'); + context = canvas.getContext('2d'); + + + video = document.getElementById('qrcode-scanner-video'); + $video = angular.element(video); + canvas.width = 300; + canvas.height = 225; + context.clearRect(0, 0, 300, 225); + + navigator.getUserMedia({ + video: true + }, _successCallback, _videoError); + }, 500); + }; + + $scope.cancel = function() { + _scanStop(); + $modalInstance.dismiss('cancel'); }; }; - return { - restrict: 'E', - scope: { - onScan: "&", - beforeScan: "&" - }, - controller: controller, - replace: true, - template: '' + var modalInstance = $modal.open({ + templateUrl: 'views/modals/scanner.html', + windowClass: 'full', + controller: ModalInstanceCtrl, + backdrop: 'static', + keyboard: false + }); + modalInstance.result.then(function(data) { + parentScope.onScan({ + data: data + }); + }); + + }; + + $scope.openScanner = function() { + if (isCordova) { + $scope.cordovaOpenScanner(); + } else { + $scope.modalOpenScanner(); } - } - ]); + }; + }; + + return { + restrict: 'E', + scope: { + onScan: "&", + beforeScan: "&" + }, + controller: controller, + replace: true, + template: '' + } + }); diff --git a/src/js/routes.js b/src/js/routes.js index 2137134fb..419102bcf 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -20,12 +20,12 @@ angular $urlRouterProvider.otherwise('/'); $logProvider.debugEnabled(true); - $provide.decorator('$log', ['$delegate', 'isDevel', - function($delegate, isDevel) { + $provide.decorator('$log', ['$delegate', 'platformInfo', + function($delegate, platformInfo) { var historicLog = historicLogProvider.$get(); ['debug', 'info', 'warn', 'error', 'log'].forEach(function(level) { - if (isDevel && level == 'error') return; + if (platformInfo.isDevel && level == 'error') return; var orig = $delegate[level]; $delegate[level] = function() { @@ -531,7 +531,7 @@ angular url: '/cordova/:status/:fromHome/:fromDisclaimer/:secondBackButtonPress', views: { 'main': { - controller: function($rootScope, $state, $stateParams, $timeout, go, isCordova, gettextCatalog) { + controller: function($rootScope, $state, $stateParams, $timeout, go, platformInfo, gettextCatalog) { switch ($stateParams.status) { case 'resume': @@ -542,7 +542,7 @@ angular if ($stateParams.fromDisclaimer == 'true') navigator.app.exitApp(); - if (isCordova && $stateParams.fromHome == 'true' && !$rootScope.modalOpened) { + if (platformInfo.isCordova && $stateParams.fromHome == 'true' && !$rootScope.modalOpened) { if ($stateParams.secondBackButtonPress == 'true') { navigator.app.exitApp(); } else { @@ -563,16 +563,16 @@ angular 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(); // Register URI handler, not for mobileApp - if (!isCordova) { + if (!platformInfo.isCordova) { uriHandler.register(); } - if (nodeWebkit.isDefined()) { + if (platformInfo.isNW) { var gui = require('nw.gui'); var win = gui.Window.get(); var nativeMenuBar = new gui.Menu({ diff --git a/src/js/services/animationService.js b/src/js/services/animationService.js index d038043b7..7197194cb 100644 --- a/src/js/services/animationService.js +++ b/src/js/services/animationService.js @@ -1,10 +1,12 @@ 'use strict'; -angular.module('copayApp.services').factory('animationService', function(isCordova) { +angular.module('copayApp.services').factory('animationService', function(platformInfo) { var root = {}; - var cachedTransitionState, cachedBackPanel; + var isCordova = platformInfo.isCordova; + + // DISABLE ANIMATION ON DESKTOP root.modalAnimated = { slideUp: isCordova ? 'full animated slideInUp' : 'full', diff --git a/src/js/services/applicationService.js b/src/js/services/applicationService.js index c06cabfe5..0b82bcaf7 100644 --- a/src/js/services/applicationService.js +++ b/src/js/services/applicationService.js @@ -1,11 +1,14 @@ 'use strict'; angular.module('copayApp.services') - .factory('applicationService', function($rootScope, $timeout, isCordova, isChromeApp, nodeWebkit, go) { + .factory('applicationService', function($rootScope, $timeout, platformInfo, go) { var root = {}; + var isChromeApp = platformInfo.isChromeApp; + var isNW = platformInfo.isNW; + root.restart = function() { var hashIndex = window.location.href.indexOf('#/'); - if (isCordova) { + if (platformInfo.isCordova) { window.location = window.location.href.substr(0, hashIndex); $timeout(function() { $rootScope.$digest(); @@ -15,7 +18,7 @@ angular.module('copayApp.services') // Go home reloading the application if (isChromeApp) { chrome.runtime.reload(); - } else if (nodeWebkit.isDefined()) { + } else if (isNW) { go.walletHome(); $timeout(function() { var win = require('nw.gui').Window.get(); diff --git a/src/js/services/coinbaseService.js b/src/js/services/coinbaseService.js index b4bf73447..3827c6651 100644 --- a/src/js/services/coinbaseService.js +++ b/src/js/services/coinbaseService.js @@ -1,8 +1,9 @@ '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 credentials = {}; + var isCordova = platformInfo.isCordova; root.setCredentials = function(network) { credentials.SCOPE = '' diff --git a/src/js/services/confirmDialog.js b/src/js/services/confirmDialog.js index b8242dc5c..90e71f381 100644 --- a/src/js/services/confirmDialog.js +++ b/src/js/services/confirmDialog.js @@ -1,7 +1,7 @@ '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 = {}; @@ -10,7 +10,7 @@ angular.module('copayApp.services').factory('confirmDialog', function($log, $tim var confirmMsg = gettextCatalog.getString('Confirm'); root.show = function(msg, cb) { - if (isCordova) { + if (platformInfo.isCordova) { navigator.notification.confirm( msg, function(buttonIndex) { @@ -24,7 +24,7 @@ angular.module('copayApp.services').factory('confirmDialog', function($log, $tim }, confirmMsg, [acceptMsg, cancelMsg] ); - } else if (isChromeApp) { + } else if (platformInfo.isChromeApp) { // No feedback, alert/confirm not supported. return cb(true); } else { diff --git a/src/js/services/glideraService.js b/src/js/services/glideraService.js index dd13bcd53..15b39dbb4 100644 --- a/src/js/services/glideraService.js +++ b/src/js/services/glideraService.js @@ -1,8 +1,9 @@ '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 credentials = {}; + var isCordova = platformInfo.isCordova; root.setCredentials = function(network) { if (network == 'testnet') { diff --git a/src/js/services/go.js b/src/js/services/go.js index c110d674c..6b5ff3f1b 100644 --- a/src/js/services/go.js +++ b/src/js/services/go.js @@ -1,6 +1,6 @@ '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 hideSidebars = function() { @@ -30,7 +30,7 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope, }; root.openExternalLink = function(url, target) { - if (nodeWebkit.isDefined()) { + if ( platformInfo.isNW) { nodeWebkit.openExternalLink(url); } else { target = target || '_blank'; diff --git a/src/js/services/isChromeApp.js b/src/js/services/isChromeApp.js deleted file mode 100644 index 03194df33..000000000 --- a/src/js/services/isChromeApp.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -angular.module('copayApp.services').factory('isChromeApp', function(nodeWebkit) { - return !!(window.chrome && chrome.runtime && chrome.runtime.id && !nodeWebkit.isDefined()); -}); diff --git a/src/js/services/isCordova.js b/src/js/services/isCordova.js deleted file mode 100644 index 180ace923..000000000 --- a/src/js/services/isCordova.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -angular.module('copayApp.services').value('isCordova', window.cordova ? true : false); diff --git a/src/js/services/isDevel.js b/src/js/services/isDevel.js deleted file mode 100644 index f96ea53e4..000000000 --- a/src/js/services/isDevel.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -angular.module('copayApp.services').factory('isDevel', function(nodeWebkit, isChromeApp, isMobile) { - return !isMobile.any() && !isChromeApp && !nodeWebkit.isDefined(); -}); diff --git a/src/js/services/isMobile.js b/src/js/services/isMobile.js deleted file mode 100644 index 7c2a6b09d..000000000 --- a/src/js/services/isMobile.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; - -// Detect mobile devices -var isMobile = { - Android: function() { - return !!navigator.userAgent.match(/Android/i); - }, - BlackBerry: function() { - return !!navigator.userAgent.match(/BlackBerry/i); - }, - iOS: function() { - return /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; - }, - Opera: function() { - return !!navigator.userAgent.match(/Opera Mini/i); - }, - Windows: function() { - return !!navigator.userAgent.match(/IEMobile/i); - }, - Safari: function() { - return Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0; - }, - any: function() { - return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows()); - } -}; - - -angular.module('copayApp.services').value('isMobile', isMobile); diff --git a/src/js/services/latestReleaseService.js b/src/js/services/latestReleaseService.js index be0527d51..bb9520223 100644 --- a/src/js/services/latestReleaseService.js +++ b/src/js/services/latestReleaseService.js @@ -1,6 +1,6 @@ 'use strict'; angular.module('copayApp.services') - .factory('latestReleaseService', function latestReleaseServiceFactory($log, $http, configService, gettext, nodeWebkit) { + .factory('latestReleaseService', function latestReleaseServiceFactory($log, $http, configService) { var root = {}; diff --git a/src/js/services/legacyImportService.js b/src/js/services/legacyImportService.js index de03c808e..a4103a1d4 100644 --- a/src/js/services/legacyImportService.js +++ b/src/js/services/legacyImportService.js @@ -1,6 +1,6 @@ 'use strict'; 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 wc = bwcService.getClient(); @@ -126,7 +126,7 @@ angular.module('copayApp.services') }; var localStorageGet = function(key, cb) { - if (isChromeApp) { + if (platformInfo.isChromeApp) { chrome.storage.local.get(key, function(data) { return cb(null, data[key]); diff --git a/src/js/services/localStorage.js b/src/js/services/localStorage.js index 853677159..17ab3a27d 100644 --- a/src/js/services/localStorage.js +++ b/src/js/services/localStorage.js @@ -1,20 +1,21 @@ 'use strict'; 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 ls = ((typeof window.localStorage !== "undefined") ? window.localStorage : null); - if (isChromeApp && !nodeWebkit.isDefined() && !ls) { - ls = localStorage = chrome.storage.local; - window.localStorage = chrome.storage.local; + if (isChromeApp && !isNW && !ls) { + ls = chrome.storage.local; } if (!ls) throw new Error('localstorage not available'); root.get = function(k, cb) { - if (isChromeApp && !nodeWebkit.isDefined()) { + if (isChromeApp && !isNW) { chrome.storage.local.get(k, function(data) { //TODO check for errors @@ -40,7 +41,7 @@ angular.module('copayApp.services') }; root.set = function(k, v, cb) { - if (isChromeApp && !nodeWebkit.isDefined()) { + if (isChromeApp && !isNW) { var obj = {}; obj[k] = v; @@ -53,7 +54,7 @@ angular.module('copayApp.services') }; root.remove = function(k, cb) { - if (isChromeApp && !nodeWebkit.isDefined()) { + if (isChromeApp && !isNW) { chrome.storage.local.remove(k, cb); } else { ls.removeItem(k); diff --git a/src/js/services/logHeader.js b/src/js/services/logHeader.js index cec37bf5e..272aec6f0 100644 --- a/src/js/services/logHeader.js +++ b/src/js/services/logHeader.js @@ -1,8 +1,7 @@ 'use strict'; 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('Client: isCordova:', isCordova, 'isChromeApp:', isChromeApp, 'isNodeWebkit:', nodeWebkit.isDefined()); - $log.info('Navigator:', navigator.userAgent); + $log.info('Client: '+ JSON.stringify(platformInfo) ); return {}; }); diff --git a/src/js/services/nodeWebkit.js b/src/js/services/nodeWebkit.js index 580d502eb..c1e13d84b 100644 --- a/src/js/services/nodeWebkit.js +++ b/src/js/services/nodeWebkit.js @@ -14,10 +14,6 @@ angular.module('copayApp.services').factory('nodeWebkit', function nodeWebkitFac } }; - root.isDefined = function() { - return isNodeWebkit(); - }; - root.readFromClipboard = function() { if (!isNodeWebkit()) return; var gui = require('nw.gui'); diff --git a/src/js/services/notifications.js b/src/js/services/notifications.js index 6b63504d0..e6e464c8d 100644 --- a/src/js/services/notifications.js +++ b/src/js/services/notifications.js @@ -1,9 +1,9 @@ 'use strict'; angular.module('copayApp.services'). -factory('notification', ['$timeout','isCordova', - function($timeout, isCordova) { +factory('notification', function($timeout, platformInfo) { + var isCordova = platformInfo.isCordova; var notifications = []; /* @@ -257,7 +257,7 @@ factory('notification', ['$timeout','isCordova', }; } -]).directive('notifications', function(notification, $compile) { +).directive('notifications', function(notification, $compile) { /** * * It should also parse the arguments passed to it that specify diff --git a/src/js/services/platformInfo.js b/src/js/services/platformInfo.js new file mode 100644 index 000000000..2d9a3ae94 --- /dev/null +++ b/src/js/services/platformInfo.js @@ -0,0 +1,40 @@ +'use strict'; + +angular.module('copayApp.services').factory('platformInfo', function($window) { + + 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 isNode = (typeof process !== "undefined" && typeof require !== "undefined"); + if (isNode) { + try { + return (typeof require('nw.gui') !== "undefined"); + } catch (e) { + return false; + } + } + }; + + + // Detect mobile devices + var ret = { + isAndroid: !!ua.match(/Android/i), + isIOS: /iPad|iPhone|iPod/.test(ua) && !$window.MSStream, + isWP: !!ua.match(/IEMobile/i), + isSafari: Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0, + ua: ua, + isCordova: !!$window.cordova, + isNW: isNodeWebkit(), + }; + + ret.isMobile = ret.isAndroid || ret.isIOS || ret.isWP; + ret.isChromeApp = $window.chrome && chrome.runtime && chrome.runtime.id && !ret.isNW; + ret.isDevel = !ret.isMobile && !ret.isChromeApp && !ret.isNW; + + return ret; +}); diff --git a/src/js/services/profileService.js b/src/js/services/profileService.js index 5865af85b..ecea8c747 100644 --- a/src/js/services/profileService.js +++ b/src/js/services/profileService.js @@ -1,10 +1,15 @@ 'use strict'; 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 errors = bwcService.getErrors(); - var usePushNotifications = isCordova && !isMobile.Windows(); + var usePushNotifications = isCordova && !isWP; var FOREGROUND_UPDATE_PERIOD = 5; var BACKGROUND_UPDATE_PERIOD = 30; @@ -73,10 +78,12 @@ angular.module('copayApp.services') root.setBaseURL(credentials.walletId); + $log.debug('Importing wallet:' + credentials.walletId); var client = bwcService.getClient(JSON.stringify(credentials)); root.walletClients[credentials.walletId] = client; if (client.incorrectDerivation) { + $log.warn('Key Derivation failed for wallet:' + credentials.walletId); storageService.clearLastAddress(credentials.walletId, function() {}); } diff --git a/src/js/services/pushNotificationsService.js b/src/js/services/pushNotificationsService.js index d2649e949..f6c621415 100644 --- a/src/js/services/pushNotificationsService.js +++ b/src/js/services/pushNotificationsService.js @@ -1,8 +1,13 @@ 'use strict'; angular.module('copayApp.services') - .factory('pushNotificationsService', function($log, isMobile, storageService, configService, lodash, isCordova) { + .factory('pushNotificationsService', function($log, platformInfo, storageService, configService, lodash) { 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) { var defaults = configService.getDefaults(); @@ -32,7 +37,7 @@ angular.module('copayApp.services') lodash.forEach(walletsClients, function(walletClient) { var opts = {}; - opts.type = isMobile.iOS() ? "ios" : isMobile.Android() ? "android" : null; + opts.type = isIOS ? "ios" : isAndroid ? "android" : null; opts.token = root.token; root.subscribe(opts, walletClient, function(err, response) { if (err) $log.warn('Subscription error: ' + err.message + ': ' + JSON.stringify(opts)); diff --git a/src/js/services/storageService.js b/src/js/services/storageService.js index 28515a004..96176d3e5 100644 --- a/src/js/services/storageService.js +++ b/src/js/services/storageService.js @@ -1,12 +1,12 @@ 'use strict'; 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 = {}; // File storage is not supported for writing according to // 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); diff --git a/src/js/services/txStatus.js b/src/js/services/txStatus.js index 78253c7f1..af73da30a 100644 --- a/src/js/services/txStatus.js +++ b/src/js/services/txStatus.js @@ -1,7 +1,8 @@ 'use strict'; -angular.module('copayApp.services').factory('txStatus', function($modal, lodash, profileService, $timeout, txFormatService, isCordova) { +angular.module('copayApp.services').factory('txStatus', function($modal, lodash, profileService, $timeout, txFormatService, platformInfo) { var root = {}; + var isCordova = platformInfo.isCordova; root.notify = function(txp, cb) { var fc = profileService.focusedClient; diff --git a/test/helpers.js b/test/helpers.js index 5cbd13b30..1709270a0 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -103,6 +103,9 @@ mocks.init = function(fixtures, controllerName, opts, done) { function createHash(method, url, args) { var headers = JSON.stringify(bwc._getHeaders(method, url, args)); + + // Fixes BWC version... TODO + headers=headers.replace(/bwc-\d\.\d\.\d/,'bwc-2.4.0') var x = method + url + JSON.stringify(args) + headers; var sjcl = $delegate.getSJCL(); return sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(x));