diff --git a/src/js/controllers/tab-home.js b/src/js/controllers/tab-home.js index a7332cb76..825959464 100644 --- a/src/js/controllers/tab-home.js +++ b/src/js/controllers/tab-home.js @@ -56,7 +56,7 @@ angular.module('copayApp.controllers').controller('tabHomeController', $scope.newReleaseNotes = newReleaseData.releaseNotes; } }); - }; + } function onEnter(event, data) { $ionicNavBarDelegate.showBar(true); @@ -108,13 +108,13 @@ angular.module('copayApp.controllers').controller('tabHomeController', $scope.$apply(); }, 10); }); - }; + } function onLeave (event, data) { lodash.each(listeners, function(x) { x(); }); - }; + } $scope.createdWithinPastDay = function(time) { return timeService.withinPastDay(time); @@ -123,16 +123,10 @@ angular.module('copayApp.controllers').controller('tabHomeController', $scope.startFreshSend = function() { sendFlowService.clear(); $state.go('tabs.send'); - } + }; - $scope.openExternalLink = function() { - var url = 'https://github.com/Bitcoin-com/Wallet/releases/latest'; - var optIn = true; - var title = gettextCatalog.getString('Update Available'); - var message = gettextCatalog.getString('An update to this app is available. For your security, please update to the latest version.'); - var okText = gettextCatalog.getString('View Update'); - var cancelText = gettextCatalog.getString('Go Back'); - externalLinkService.open(url, optIn, title, message, okText, cancelText); + $scope.showUpdatePopup = function() { + latestReleaseService.showUpdatePopup(); }; $scope.openBannerUrl = function() { diff --git a/src/js/services/latestReleaseService.js b/src/js/services/latestReleaseService.js index 96614715d..fbcf01ada 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, platformInfo) { + .factory('latestReleaseService', function latestReleaseServiceFactory($log, $http, $ionicPopup, configService, externalLinkService, gettextCatalog, platformInfo) { var root = {}; @@ -65,7 +65,7 @@ angular.module('copayApp.services') function verifyTagFormat(tag) { var regex = /^v?\d+\.\d+(\.\d+)?(-rc\d)?$/i; return regex.exec(tag); - }; + } function formatTagNumber(tag) { var label = false; @@ -79,9 +79,9 @@ angular.module('copayApp.services') major: +(formattedNumber[0]?+formattedNumber[0]:0), minor: +(formattedNumber[1]?+formattedNumber[1]:0), patch: +(formattedNumber[2]?+formattedNumber[2]:0), - label: label /* XX SP: we can use this in a later stage (with for example 1.0.0-rc2 the value will be "rc2" and false if there is no label) */ + label: label /* XX SP: Maybe we can use this in a later stage (with for example 1.0.0-rc2 the value will be "rc2" and false if there is no label) */ }; - }; + } }; function requestLatestRelease(releaseURL, cb) { @@ -99,6 +99,56 @@ angular.module('copayApp.services') }, function(err) { return cb('Cannot get the release information: ' + err); }); + } + + root.showUpdatePopup = function () { + var buttons = [{ + text: "GitHub", + type: 'button-positive', + onTap: function () { + var url = 'https://github.com/Bitcoin-com/Wallet/releases/latest'; + externalLinkService.open(url, false); + } + }]; + + if (platformInfo.isAndroid) { + buttons.unshift({ + text: "Google Play Store", + type: 'button-positive', + onTap: function () { + var url = 'https://play.google.com/store/apps/details?id=com.bitcoin.mwallet'; + externalLinkService.open(url, false); + } + }); + } + if (platformInfo.isIOS) { + buttons.unshift({ + text: "App Store", + type: 'button-positive', + onTap: function () { + var url = 'https://itunes.apple.com/app/bitcoin-com-wallet/id1383072453'; + externalLinkService.open(url, false); + } + }); + } + + if (buttons.length === 1) { // There is only one source to download (probably on desktop, so open GitHub release page..) + buttons[0].onTap(); + } else { + buttons.push({ + text: gettextCatalog.getString('Go Back'), + type: 'button-positive', + onTap: function () { + return true; + } + }); + $ionicPopup.show({ + title: gettextCatalog.getString('Update Available'), + subTitle: gettextCatalog.getString('An update to this app is available. For your security, please update to the latest version.'), + cssClass: 'popup-update', + buttons: buttons + }); + } }; return root; diff --git a/src/sass/views/tab-home.scss b/src/sass/views/tab-home.scss index 4cc5ce5ed..c4b3a3ec4 100644 --- a/src/sass/views/tab-home.scss +++ b/src/sass/views/tab-home.scss @@ -195,3 +195,13 @@ top:11px; } } +.popup-update { + .popup-buttons { + display: block; + } + .popup-buttons .button{ + display:block; + min-width: 100% !important; + margin-top: 4px; + } +} \ No newline at end of file diff --git a/www/views/tab-home.html b/www/views/tab-home.html index 01182f09d..7191c1c16 100644 --- a/www/views/tab-home.html +++ b/www/views/tab-home.html @@ -19,7 +19,7 @@