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';
|
'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 updateConfig = function() {
|
||||||
var config = configService.getSync();
|
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.$on("$ionicView.beforeEnter", function(event, data) {
|
||||||
$scope.isCordova = platformInfo.isCordova;
|
$scope.isCordova = platformInfo.isCordova;
|
||||||
updateConfig();
|
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';
|
'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.$on("$ionicView.beforeEnter", function(event) {
|
||||||
$scope.currentPincode = $scope.newPincode = '';
|
$scope.currentPincode = $scope.newPincode = '';
|
||||||
|
|
@ -35,7 +35,7 @@ angular.module('copayApp.controllers').controller('pincodeController', function(
|
||||||
$scope.save = function() {
|
$scope.save = function() {
|
||||||
if (!isComplete()) return;
|
if (!isComplete()) return;
|
||||||
var config = configService.getSync();
|
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 (!$scope.locking) {
|
||||||
if (match) {
|
if (match) {
|
||||||
|
|
@ -61,9 +61,14 @@ angular.module('copayApp.controllers').controller('pincodeController', function(
|
||||||
|
|
||||||
function saveSettings(enabled, value) {
|
function saveSettings(enabled, value) {
|
||||||
var opts = {
|
var opts = {
|
||||||
pincode: {
|
lockapp: {
|
||||||
enabled: enabled,
|
pincode: {
|
||||||
value: value
|
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',
|
url: '/pincode/:fromSettings/:locking',
|
||||||
views: {
|
views: {
|
||||||
'tab-settings@tabs': {
|
'tab-settings@tabs': {
|
||||||
controller: 'pincodeController',
|
controller: 'lockappController',
|
||||||
templateUrl: 'views/pincode.html',
|
templateUrl: 'views/pincode.html',
|
||||||
cache: false
|
cache: false
|
||||||
}
|
}
|
||||||
|
|
@ -1224,14 +1233,12 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
||||||
});
|
});
|
||||||
configService.whenAvailable(function(config) {
|
configService.whenAvailable(function(config) {
|
||||||
startupService.ready();
|
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() {
|
$state.transitionTo('pincode').then(function() {
|
||||||
// Clear history
|
|
||||||
$ionicHistory.clearHistory();
|
$ionicHistory.clearHistory();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$state.transitionTo('tabs.home').then(function() {
|
$state.transitionTo('tabs.home').then(function() {
|
||||||
// Clear history
|
|
||||||
$ionicHistory.clearHistory();
|
$ionicHistory.clearHistory();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,9 +53,14 @@ angular.module('copayApp.services').factory('configService', function(storageSer
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
pincode: {
|
lockapp: {
|
||||||
enabled: false,
|
pincode: {
|
||||||
value: '',
|
enabled: false,
|
||||||
|
value: '',
|
||||||
|
},
|
||||||
|
fingerprint: {
|
||||||
|
enabled: false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// External services
|
// External services
|
||||||
|
|
|
||||||
|
|
@ -29,13 +29,14 @@
|
||||||
<span class="toggle-label" translate>Hide Next Steps Card</span>
|
<span class="toggle-label" translate>Hide Next Steps Card</span>
|
||||||
</ion-toggle>
|
</ion-toggle>
|
||||||
|
|
||||||
<div ng-if="isCordova">
|
<!-- <div ng-if="isCordova"> -->
|
||||||
<div class="item item-divider"></div>
|
<div class="item item-divider"></div>
|
||||||
|
|
||||||
<ion-toggle ng-model="usePincode.enabled" toggle-class="toggle-balanced" ng-change="usePincodeChange()">
|
<a class="item item-icon-right" ui-sref="tabs.lockapp">
|
||||||
<span class="toggle-label" translate>Use pin to lock/unlock the app</span>
|
<span translate>Lock App</span>
|
||||||
</ion-toggle>
|
<i class="icon bp-arrow-right"></i>
|
||||||
</div>
|
</a>
|
||||||
|
<!-- </div> -->
|
||||||
</div>
|
</div>
|
||||||
</ion-content>
|
</ion-content>
|
||||||
</ion-view>
|
</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