add fingerprint option - add lock app view and options
This commit is contained in:
parent
d4c8576032
commit
824362af7c
7 changed files with 121 additions and 26 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('advancedSettingsController', function($scope, $timeout, $state, $log, $window, $ionicModal, lodash, configService, uxLanguage, platformInfo, pushNotificationsService, profileService, feeService, storageService, $ionicHistory, $ionicScrollDelegate) {
|
||||
angular.module('copayApp.controllers').controller('advancedSettingsController', function($scope, $log, configService, platformInfo) {
|
||||
|
||||
var updateConfig = function() {
|
||||
var config = configService.getSync();
|
||||
|
|
@ -52,13 +52,6 @@ angular.module('copayApp.controllers').controller('advancedSettingsController',
|
|||
});
|
||||
};
|
||||
|
||||
$scope.usePincodeChange = function() {
|
||||
$state.go('tabs.pincode', {
|
||||
fromSettings: true,
|
||||
locking: $scope.usePincode.enabled
|
||||
});
|
||||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.isCordova = platformInfo.isCordova;
|
||||
updateConfig();
|
||||
|
|
|
|||
65
src/js/controllers/lockapp.js
Normal file
65
src/js/controllers/lockapp.js
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('lockappController', function($state, $scope, $log, configService, popupService, gettextCatalog, appConfigService) {
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event) {
|
||||
var config = configService.getSync();
|
||||
$scope.fingerprintAvailable = true;
|
||||
// $scope.fingerprintAvailable = fingerprintService.isAvailable();
|
||||
|
||||
$scope.usePincode = {
|
||||
enabled: config.lockapp ? config.lockapp.pincode.enabled : false
|
||||
};
|
||||
$scope.useFingerprint = {
|
||||
enabled: config.lockapp ? config.lockapp.fingerprint.enabled : false
|
||||
};
|
||||
});
|
||||
|
||||
$scope.usePincodeChange = function() {
|
||||
$state.go('tabs.lockapp.pincode', {
|
||||
fromSettings: true,
|
||||
locking: $scope.usePincode.enabled
|
||||
});
|
||||
};
|
||||
|
||||
$scope.useFingerprintChange = function() {
|
||||
if ($scope.usePincode.enabled) {
|
||||
var message = gettextCatalog.getString('{{appName}} is protected by Pin Code. Are you sure you want to disable it?', {
|
||||
appName: appConfigService.nameCase
|
||||
});
|
||||
var okText = gettextCatalog.getString('Yes');
|
||||
var cancelText = gettextCatalog.getString('Cancel');
|
||||
popupService.showConfirm(null, message, okText, cancelText, function(ok) {
|
||||
if (!ok) {
|
||||
$scope.useFingerprint = {
|
||||
enabled: false
|
||||
};
|
||||
return;
|
||||
}
|
||||
saveConfig();
|
||||
});
|
||||
} else
|
||||
saveConfig();
|
||||
|
||||
function saveConfig() {
|
||||
$scope.usePincode = {
|
||||
enabled: false
|
||||
};
|
||||
var opts = {
|
||||
lockapp: {
|
||||
pincode: {
|
||||
enabled: false,
|
||||
value: ''
|
||||
},
|
||||
fingerprint: {
|
||||
enabled: $scope.useFingerprint.enabled
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
configService.set(opts, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
};
|
||||
};
|
||||
});
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('pincodeController', function($state, $stateParams, $ionicHistory, $timeout, $scope, $log, $window, configService) {
|
||||
angular.module('copayApp.controllers').controller('pincodeController', function($state, $stateParams, $ionicHistory, $timeout, $scope, $log, configService) {
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event) {
|
||||
$scope.currentPincode = $scope.newPincode = '';
|
||||
|
|
@ -35,7 +35,7 @@ angular.module('copayApp.controllers').controller('pincodeController', function(
|
|||
$scope.save = function() {
|
||||
if (!isComplete()) return;
|
||||
var config = configService.getSync();
|
||||
var match = config.pincode.value == $scope.currentPincode ? true : false;
|
||||
var match = config.lockapp.pincode.value == $scope.currentPincode ? true : false;
|
||||
|
||||
if (!$scope.locking) {
|
||||
if (match) {
|
||||
|
|
@ -61,9 +61,14 @@ angular.module('copayApp.controllers').controller('pincodeController', function(
|
|||
|
||||
function saveSettings(enabled, value) {
|
||||
var opts = {
|
||||
pincode: {
|
||||
enabled: enabled,
|
||||
value: value
|
||||
lockapp: {
|
||||
pincode: {
|
||||
enabled: enabled,
|
||||
value: value
|
||||
},
|
||||
fingerprint: {
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -451,11 +451,20 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
}
|
||||
}
|
||||
})
|
||||
.state('tabs.pincode', {
|
||||
.state('tabs.lockapp', {
|
||||
url: '/lockapp',
|
||||
views: {
|
||||
'tab-settings@tabs': {
|
||||
controller: 'lockappController',
|
||||
templateUrl: 'views/lockapp.html',
|
||||
}
|
||||
}
|
||||
})
|
||||
.state('tabs.lockapp.pincode', {
|
||||
url: '/pincode/:fromSettings/:locking',
|
||||
views: {
|
||||
'tab-settings@tabs': {
|
||||
controller: 'pincodeController',
|
||||
controller: 'lockappController',
|
||||
templateUrl: 'views/pincode.html',
|
||||
cache: false
|
||||
}
|
||||
|
|
@ -1224,14 +1233,12 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
|||
});
|
||||
configService.whenAvailable(function(config) {
|
||||
startupService.ready();
|
||||
if (platformInfo.isCordova && config.pincode && config.pincode.enabled) {
|
||||
if (platformInfo.isCordova && config.lockapp.pincode && config.lockapp.pincode.enabled) {
|
||||
$state.transitionTo('pincode').then(function() {
|
||||
// Clear history
|
||||
$ionicHistory.clearHistory();
|
||||
});
|
||||
} else {
|
||||
$state.transitionTo('tabs.home').then(function() {
|
||||
// Clear history
|
||||
$ionicHistory.clearHistory();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,9 +53,14 @@ angular.module('copayApp.services').factory('configService', function(storageSer
|
|||
}
|
||||
},
|
||||
|
||||
pincode: {
|
||||
enabled: false,
|
||||
value: '',
|
||||
lockapp: {
|
||||
pincode: {
|
||||
enabled: false,
|
||||
value: '',
|
||||
},
|
||||
fingerprint: {
|
||||
enabled: false
|
||||
}
|
||||
},
|
||||
|
||||
// External services
|
||||
|
|
|
|||
|
|
@ -29,13 +29,14 @@
|
|||
<span class="toggle-label" translate>Hide Next Steps Card</span>
|
||||
</ion-toggle>
|
||||
|
||||
<div ng-if="isCordova">
|
||||
<!-- <div ng-if="isCordova"> -->
|
||||
<div class="item item-divider"></div>
|
||||
|
||||
<ion-toggle ng-model="usePincode.enabled" toggle-class="toggle-balanced" ng-change="usePincodeChange()">
|
||||
<span class="toggle-label" translate>Use pin to lock/unlock the app</span>
|
||||
</ion-toggle>
|
||||
</div>
|
||||
<a class="item item-icon-right" ui-sref="tabs.lockapp">
|
||||
<span translate>Lock App</span>
|
||||
<i class="icon bp-arrow-right"></i>
|
||||
</a>
|
||||
<!-- </div> -->
|
||||
</div>
|
||||
</ion-content>
|
||||
</ion-view>
|
||||
|
|
|
|||
19
www/views/lockapp.html
Normal file
19
www/views/lockapp.html
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<ion-view class="settings">
|
||||
<ion-nav-bar class="bar-royal">
|
||||
<ion-nav-title>{{'Lock App' | translate}}</ion-nav-title>
|
||||
<ion-nav-back-button>
|
||||
</ion-nav-back-button>
|
||||
</ion-nav-bar>
|
||||
|
||||
<ion-content>
|
||||
<ion-toggle ng-model="usePincode.enabled" toggle-class="toggle-balanced" ng-change="usePincodeChange()">
|
||||
<span class="toggle-label" translate>Enable Pin Code</span>
|
||||
</ion-toggle>
|
||||
|
||||
<div ng-show="fingerprintAvailable">
|
||||
<ion-toggle ng-model="useFingerprint.enabled" toggle-class="toggle-balanced" ng-change="useFingerprintChange()">
|
||||
<span class="toggle-label" translate>Enable Fingerprint</span>
|
||||
</ion-toggle>
|
||||
</div>
|
||||
</ion-content>
|
||||
</ion-view>
|
||||
Loading…
Add table
Add a link
Reference in a new issue