From 8035846fafb7e5e5dd4fe136c17110af9a61c1ec Mon Sep 17 00:00:00 2001 From: Jason Dreyzehner Date: Tue, 11 Oct 2016 22:26:55 -0400 Subject: [PATCH 1/4] feat(build): use cordova-custom-config, remove unnecessary hooks --- app-template/config-template.xml | 26 +++++++++--------- package.json | 11 +++----- .../add-custom-urls-to-android-manifest.js | 27 ------------------- ...hibit-cloud-backups-in-android-manifest.js | 18 ------------- 4 files changed, 17 insertions(+), 65 deletions(-) delete mode 100644 util/hooks/android/add-custom-urls-to-android-manifest.js delete mode 100644 util/hooks/android/prohibit-cloud-backups-in-android-manifest.js diff --git a/app-template/config-template.xml b/app-template/config-template.xml index 5a72f4560..1629573c3 100644 --- a/app-template/config-template.xml +++ b/app-template/config-template.xml @@ -16,11 +16,6 @@ - - - - - @@ -28,6 +23,13 @@ + + + + + + + @@ -57,8 +59,9 @@ - - + + + @@ -67,9 +70,8 @@ - - + + @@ -87,7 +89,6 @@ - @@ -101,8 +102,7 @@ - - + diff --git a/package.json b/package.json index e474ad514..03b305a7c 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,8 @@ "bitcore-wallet-client": "4.2.1", "bower": "^1.7.9", "chai": "^3.5.0", - "cordova": "5.4.1", "cordova-android": "5.1.1", + "cordova-custom-config": "^3.0.5", "cordova-plugin-qrscanner": "^2.3.1", "coveralls": "^2.11.9", "express": "^4.11.2", @@ -89,12 +89,9 @@ "clean-all": "git clean -dfx && npm install" }, "devDependencies": { - "androidmanifest": "^2.0.0", - "cordova": "^5.4.1", - "globby": "^6.0.0", + "cordova": "^6.3.1", + "grunt": "^1.0.1", "ionic": "^2.1.0", - "plist": "^2.0.1", - "trash-cli": "^1.4.0", - "xcode": "^0.8.2" + "trash-cli": "^1.4.0" } } diff --git a/util/hooks/android/add-custom-urls-to-android-manifest.js b/util/hooks/android/add-custom-urls-to-android-manifest.js deleted file mode 100644 index 6fd5747df..000000000 --- a/util/hooks/android/add-custom-urls-to-android-manifest.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; - -var AndroidManifest = require('androidmanifest'); - -var FILEPATH = 'platforms/android/AndroidManifest.xml'; -var manifest = new AndroidManifest().readFile(FILEPATH); - -var mainActivity = manifest.activity('MainActivity'); - -var customUrls = ['copay', 'bitcoin', 'bitauth']; - -customUrls.forEach(function(url){ - var selector = 'intent-filter > data[android\\:scheme=' + url + ']'; - if(mainActivity.find(selector).length > 0){ - return; - } - - var intentFilter = manifest.$(''); - intentFilter.append(''); - intentFilter.append(''); - intentFilter.append(''); - intentFilter.append(''); - mainActivity.append(intentFilter); -}); - -manifest.writeFile(FILEPATH); -console.log('custome uri schemes written to AndroidManifest'); diff --git a/util/hooks/android/prohibit-cloud-backups-in-android-manifest.js b/util/hooks/android/prohibit-cloud-backups-in-android-manifest.js deleted file mode 100644 index 1f5f4d53a..000000000 --- a/util/hooks/android/prohibit-cloud-backups-in-android-manifest.js +++ /dev/null @@ -1,18 +0,0 @@ -module.exports = function(ctx) { - var fs = ctx.requireCordovaModule('fs'), - path = ctx.requireCordovaModule('path'), - xml = ctx.requireCordovaModule('cordova-common').xmlHelpers; - - var manifestPath = path.join(ctx.opts.projectRoot, '/platforms/android/AndroidManifest.xml'); - var doc = xml.parseElementtreeSync(manifestPath); - if (doc.getroot().tag !== 'manifest') { - throw new Error(manifestPath + ' has incorrect root node name (expected "manifest")'); - } - - doc.getroot().find('./application').attrib['android:allowBackup'] = "false"; - - //write the manifest file - fs.writeFileSync(manifestPath, doc.write({ - indent: 4 - }), 'utf-8'); -}; From 4de3cad7128ae2b2ea1e917ebbf776174ae015c8 Mon Sep 17 00:00:00 2001 From: Jason Dreyzehner Date: Tue, 11 Oct 2016 22:46:07 -0400 Subject: [PATCH 2/4] perf(startupService): remove timers, control splashscreen and statusbar from startupService --- .gitignore | 3 +++ src/js/controllers/onboarding/disclaimer.js | 7 ++++- .../onboarding/welcomeController.js | 6 ++++- src/js/controllers/tab-home.js | 6 ++++- src/js/routes.js | 6 +---- src/js/services/startupService.js | 26 +++++++++++++++++++ 6 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 src/js/services/startupService.js diff --git a/.gitignore b/.gitignore index 54427aba1..16ebb09f3 100644 --- a/.gitignore +++ b/.gitignore @@ -84,6 +84,9 @@ Session.vim .netrwhist *~ +.tags +.tags1 + # SASS src/sass/*.css .sass-cache diff --git a/src/js/controllers/onboarding/disclaimer.js b/src/js/controllers/onboarding/disclaimer.js index 7459b18da..a18be4e6d 100644 --- a/src/js/controllers/onboarding/disclaimer.js +++ b/src/js/controllers/onboarding/disclaimer.js @@ -1,6 +1,11 @@ 'use strict'; -angular.module('copayApp.controllers').controller('disclaimerController', function($scope, $timeout, $state, $log, $ionicModal, profileService, uxLanguage, externalLinkService, storageService, $stateParams) { +angular.module('copayApp.controllers').controller('disclaimerController', function($scope, $timeout, $state, $log, $ionicModal, profileService, uxLanguage, externalLinkService, storageService, $stateParams, startupService) { + + $scope.$on("$ionicView.afterEnter", function() { + startupService.ready(); + }); + $scope.init = function() { $scope.lang = uxLanguage.currentLanguage; $scope.terms = {}; diff --git a/src/js/controllers/onboarding/welcomeController.js b/src/js/controllers/onboarding/welcomeController.js index 6a7154c55..3a1651f75 100644 --- a/src/js/controllers/onboarding/welcomeController.js +++ b/src/js/controllers/onboarding/welcomeController.js @@ -1,9 +1,13 @@ 'use strict'; -angular.module('copayApp.controllers').controller('welcomeController', function($scope, $state, $timeout, $ionicConfig, $log, profileService) { +angular.module('copayApp.controllers').controller('welcomeController', function($scope, $state, $timeout, $ionicConfig, $log, profileService, startupService) { $ionicConfig.views.swipeBackEnabled(false); + $scope.$parent.$on("$ionicView.afterEnter", function() { + startupService.ready(); + }); + $scope.goImport = function(code) { $state.go('onboarding.import', { fromOnboarding: true, diff --git a/src/js/controllers/tab-home.js b/src/js/controllers/tab-home.js index 7cad213aa..c4fa9b106 100644 --- a/src/js/controllers/tab-home.js +++ b/src/js/controllers/tab-home.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('tabHomeController', - function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, gettextCatalog, lodash, popupService, ongoingProcess, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, $window, bitpayCardService) { + function($rootScope, $timeout, $scope, $state, $stateParams, $ionicModal, $ionicScrollDelegate, gettextCatalog, lodash, popupService, ongoingProcess, profileService, walletService, configService, $log, platformInfo, storageService, txpModalService, $window, bitpayCardService, startupService) { var wallet; var listeners = []; var notifications = []; @@ -13,6 +13,10 @@ angular.module('copayApp.controllers').controller('tabHomeController', $scope.homeTip = $stateParams.fromOnboarding; $scope.isCordova = platformInfo.isCordova; + $scope.$on("$ionicView.afterEnter", function() { + startupService.ready(); + }); + if (!$scope.homeTip) { storageService.getHomeTipAccepted(function(error, value) { $scope.homeTip = (value == 'false') ? false : true; diff --git a/src/js/routes.js b/src/js/routes.js index ed29cd0a0..09d99dfae 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -947,16 +947,12 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr }); $ionicPlatform.on('resume', function() { - // Nothing tot do + // Nothing to do }); $ionicPlatform.on('menubutton', function() { window.location = '#/preferences'; }); - - setTimeout(function() { - navigator.splashscreen.hide(); - }, 500); } diff --git a/src/js/services/startupService.js b/src/js/services/startupService.js new file mode 100644 index 000000000..d3d55fc02 --- /dev/null +++ b/src/js/services/startupService.js @@ -0,0 +1,26 @@ +'use strict'; + +angular.module('copayApp.services').service('startupService', function($log) { + + var splashscreenVisible = true; + var statusBarVisible = false; + + function _hideSplash(){ + if(navigator.splashscreen && splashscreenVisible){ + $log.debug('startupService is hiding the splashscreen...'); + navigator.splashscreen.hide(); + splashscreenVisible = false; + } + } + function _showStatusBar(){ + if(StatusBar && !statusBarVisible){ + $log.debug('startupService is showing the StatusBar...'); + StatusBar.show(); + statusBarVisible = true; + } + } + this.ready = function() { + _showStatusBar(); + _hideSplash(); + }; +}); From ec343e4991a63d1247c31eedc26069bfe622dd92 Mon Sep 17 00:00:00 2001 From: Jason Dreyzehner Date: Wed, 12 Oct 2016 13:27:19 -0400 Subject: [PATCH 3/4] perf(startupService): speedup perceived load time by removing animations before the splashscreen hid --- app-template/config-template.xml | 5 +++-- package.json | 3 ++- src/js/routes.js | 3 +++ src/js/services/startupService.js | 6 ++++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app-template/config-template.xml b/app-template/config-template.xml index 1629573c3..1db63c59a 100644 --- a/app-template/config-template.xml +++ b/app-template/config-template.xml @@ -17,14 +17,15 @@ - - + + + diff --git a/package.json b/package.json index 03b305a7c..2d9cd754c 100644 --- a/package.json +++ b/package.json @@ -92,6 +92,7 @@ "cordova": "^6.3.1", "grunt": "^1.0.1", "ionic": "^2.1.0", - "trash-cli": "^1.4.0" + "trash-cli": "^1.4.0", + "lodash": "^4.3.0" } } diff --git a/src/js/routes.js b/src/js/routes.js index 09d99dfae..ec6471742 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -959,6 +959,9 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr $log.info('Init profile...'); // Try to open local profile profileService.loadAndBindProfile(function(err) { + $ionicHistory.nextViewOptions({ + disableAnimate: true + }); if (err) { if (err.message && err.message.match('NOPROFILE')) { $log.debug('No profile... redirecting'); diff --git a/src/js/services/startupService.js b/src/js/services/startupService.js index d3d55fc02..31c1b7460 100644 --- a/src/js/services/startupService.js +++ b/src/js/services/startupService.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.services').service('startupService', function($log) { +angular.module('copayApp.services').service('startupService', function($log, $timeout) { var splashscreenVisible = true; var statusBarVisible = false; @@ -8,7 +8,9 @@ angular.module('copayApp.services').service('startupService', function($log) { function _hideSplash(){ if(navigator.splashscreen && splashscreenVisible){ $log.debug('startupService is hiding the splashscreen...'); - navigator.splashscreen.hide(); + $timeout(function(){ + navigator.splashscreen.hide(); + }, 20); splashscreenVisible = false; } } From 8c992569d5aa41722b7b8005c8d4682f26ccc5b9 Mon Sep 17 00:00:00 2001 From: Jason Dreyzehner Date: Wed, 12 Oct 2016 14:03:36 -0400 Subject: [PATCH 4/4] fix(desktop): fix error if StatusBar is not available --- src/js/services/startupService.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/services/startupService.js b/src/js/services/startupService.js index 31c1b7460..557d51997 100644 --- a/src/js/services/startupService.js +++ b/src/js/services/startupService.js @@ -6,7 +6,7 @@ angular.module('copayApp.services').service('startupService', function($log, $ti var statusBarVisible = false; function _hideSplash(){ - if(navigator.splashscreen && splashscreenVisible){ + if(typeof navigator.splashscreen !== "undefined" && splashscreenVisible){ $log.debug('startupService is hiding the splashscreen...'); $timeout(function(){ navigator.splashscreen.hide(); @@ -15,7 +15,7 @@ angular.module('copayApp.services').service('startupService', function($log, $ti } } function _showStatusBar(){ - if(StatusBar && !statusBarVisible){ + if(typeof StatusBar !== "undefined" && !statusBarVisible){ $log.debug('startupService is showing the StatusBar...'); StatusBar.show(); statusBarVisible = true;