Update popup

This commit is contained in:
Sebastiaan Pasma 2018-08-30 14:10:46 +02:00
commit d65e4401dd
No known key found for this signature in database
GPG key ID: 9A2B0C8B95A1D26F
4 changed files with 71 additions and 17 deletions

View file

@ -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() {

View file

@ -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;

View file

@ -195,3 +195,13 @@
top:11px;
}
}
.popup-update {
.popup-buttons {
display: block;
}
.popup-buttons .button{
display:block;
min-width: 100% !important;
margin-top: 4px;
}
}

View file

@ -19,7 +19,7 @@
<div class="item release-notes" ng-if="newReleaseNotes"><span ng-bind-html="newReleaseNotes"></span></div>
<div class="button" ng-click="openExternalLink()">
<div class="button" ng-click="showUpdatePopup()">
<span translate>Download</span>
</div>
</div>