Autolock UI

This commit is contained in:
Mo Bitar
2018-11-14 14:06:23 -06:00
parent 091f4cff7f
commit bb8140d89c
7 changed files with 911 additions and 28 deletions

View File

@@ -380,7 +380,6 @@ class AccountMenu {
passcodeManager.getAutoLockInterval().then((interval) => {
$timeout(() => {
$scope.selectedAutoLockInterval = interval;
console.log("selectedAutoLockInterval", $scope.selectedAutoLockInterval);
})
})
}
@@ -407,10 +406,10 @@ class AccountMenu {
return;
}
let fn = $scope.formData.changingPasscode ? passcodeManager.changePasscode : passcodeManager.setPasscode;
let fn = $scope.formData.changingPasscode ? passcodeManager.changePasscode.bind(passcodeManager) : passcodeManager.setPasscode.bind(passcodeManager);
fn(passcode, () => {
$timeout(function(){
$timeout(() => {
$scope.formData.showPasscodeForm = false;
var offline = authManager.offline();

View File

@@ -1,7 +1,8 @@
class PasscodeManager {
constructor(authManager, storageManager) {
document.addEventListener('visibilitychange', () => {
document.addEventListener('visibilitychange', (e) => {
console.log("visibilitychange", e, document.visibilityState);
this.documentVisibilityChanged(document.visibilityState);
});
@@ -13,6 +14,7 @@ class PasscodeManager {
const MillisecondsPerSecond = 1000;
PasscodeManager.AutoLockIntervalNone = 0;
PasscodeManager.AutoLockIntervalFiveSecs = 5 * MillisecondsPerSecond;
PasscodeManager.AutoLockIntervalOneMinute = 60 * MillisecondsPerSecond;
PasscodeManager.AutoLockIntervalFiveMinutes = 300 * MillisecondsPerSecond;
PasscodeManager.AutoLockIntervalOneHour = 3600 * MillisecondsPerSecond;
@@ -26,6 +28,10 @@ class PasscodeManager {
value: PasscodeManager.AutoLockIntervalNone,
label: "None"
},
{
value: PasscodeManager.AutoLockIntervalFiveSecs,
label: "5 Secs"
},
{
value: PasscodeManager.AutoLockIntervalOneMinute,
label: "1 Min"
@@ -51,20 +57,21 @@ class PasscodeManager {
}
async beginAutoLockTimer() {
console.log("beginAutoLockTimer");
var interval = await this.getAutoLockInterval();
if(interval == PasscodeManager.AutoLockIntervalNone) {
return;
}
this.lockTimeout = setTimeout(() => {
this.lockApplication();
}, interval);
}
cancelAutoLockTimer() {
console.log("cancelAutoLockTimer");
clearTimeout(this.lockTimeout);
}
lockApplication() {
console.log("lockApplication");
window.location.reload();
this.cancelAutoLockTimer();
}
@@ -82,14 +89,16 @@ class PasscodeManager {
}
async setAutoLockInterval(interval) {
console.log("Set autolock interval", interval);
return this.storageManager.setItem(PasscodeManager.AutoLockIntervalKey, JSON.stringify(interval), StorageManager.Fixed);
}
async getAutoLockInterval() {
let interval = await this.storageManager.getItem(PasscodeManager.AutoLockIntervalKey, StorageManager.Fixed);
console.log("Got interval", interval);
return interval && JSON.parse(interval);
if(interval) {
return JSON.parse(interval);
} else {
return PasscodeManager.AutoLockIntervalNone;
}
}
passcodeAuthParams() {

View File

@@ -83,7 +83,7 @@ class PrivilegesManager {
resolve(resolvedSingleton);
}, (valueCallback) => {
// Safe to create. Create and return object.
var privs = new Privilege({content_type: prefsContentType});
var privs = new SNPrivileges({content_type: prefsContentType});
this.modelManager.addItem(privs);
privs.setDirty(true);
this.$rootScope.sync();