Distinguish between locked and protected notes

This commit is contained in:
Mo Bitar
2018-12-13 13:03:25 -06:00
parent bc634ca7da
commit 0e4a6d718b
14 changed files with 59 additions and 23 deletions

View File

@@ -422,6 +422,11 @@ angular.module('app')
this.changesMade({dontUpdateClientModified: true, dontUpdatePreviews: true});
}
this.toggleProtectNote = function() {
this.note.content.protected = !this.note.content.protected;
this.changesMade({dontUpdateClientModified: true, dontUpdatePreviews: true});
}
this.toggleNotePreview = function() {
this.note.content.hidePreview = !this.note.content.hidePreview;
this.changesMade({dontUpdateClientModified: true, dontUpdatePreviews: true});

View File

@@ -218,8 +218,8 @@ angular.module('app')
})
}
if(note.locked && await privilegesManager.actionRequiresPrivilege(PrivilegesManager.ActionViewLockedNotes)) {
privilegesManager.presentPrivilegesModal(PrivilegesManager.ActionViewLockedNotes, () => {
if(note.content.protected && await privilegesManager.actionRequiresPrivilege(PrivilegesManager.ActionViewProtectedNotes)) {
privilegesManager.presentPrivilegesModal(PrivilegesManager.ActionViewProtectedNotes, () => {
run();
});
} else {

View File

@@ -44,7 +44,7 @@ class AuthManager extends SFAuthManager {
this.storageManager.setItemsMode(StorageManager.Ephemeral);
} else {
this.storageManager.setModelStorageMode(StorageManager.Fixed);
this.storageManager.setItemsMode(this.storageManager.hasPasscode() ? StorageManager.FixedEncrypted : StorageManager.Fixed);
this.storageManager.setItemsMode(this.storageManager.bestStorageMode());
this.storageManager.setItem("ephemeral", JSON.stringify(false), StorageManager.Fixed);
}
}

View File

@@ -16,7 +16,7 @@ class PrivilegesManager {
PrivilegesManager.ActionManageExtensions = "ActionManageExtensions";
PrivilegesManager.ActionManageBackups = "ActionManageBackups";
PrivilegesManager.ActionViewLockedNotes = "ActionViewLockedNotes";
PrivilegesManager.ActionViewProtectedNotes = "ActionViewProtectedNotes";
PrivilegesManager.ActionManagePrivileges = "ActionManagePrivileges";
PrivilegesManager.ActionManagePasscode = "ActionManagePasscode";
PrivilegesManager.ActionDeleteNote = "ActionDeleteNote";
@@ -34,7 +34,7 @@ class PrivilegesManager {
PrivilegesManager.ActionManageExtensions,
PrivilegesManager.ActionManageBackups,
PrivilegesManager.ActionManagePasscode,
PrivilegesManager.ActionViewLockedNotes,
PrivilegesManager.ActionViewProtectedNotes,
PrivilegesManager.ActionDeleteNote
]
@@ -174,8 +174,8 @@ class PrivilegesManager {
label: "Download/Import Backups"
};
metadata[PrivilegesManager.ActionViewLockedNotes] = {
label: "View Locked Notes"
metadata[PrivilegesManager.ActionViewProtectedNotes] = {
label: "View Protected Notes"
};
metadata[PrivilegesManager.ActionManagePrivileges] = {
@@ -224,8 +224,8 @@ class PrivilegesManager {
let expiresAt = addToNow(length);
return Promise.all([
this.storageManager.setItem(PrivilegesManager.SessionExpiresAtKey, JSON.stringify(expiresAt), StorageManager.FixedEncrypted),
this.storageManager.setItem(PrivilegesManager.SessionLengthKey, JSON.stringify(length), StorageManager.FixedEncrypted),
this.storageManager.setItem(PrivilegesManager.SessionExpiresAtKey, JSON.stringify(expiresAt), this.storageManager.bestStorageMode()),
this.storageManager.setItem(PrivilegesManager.SessionLengthKey, JSON.stringify(length), this.storageManager.bestStorageMode()),
])
}
@@ -234,7 +234,7 @@ class PrivilegesManager {
}
async getSelectedSessionLength() {
let length = await this.storageManager.getItem(PrivilegesManager.SessionLengthKey, StorageManager.FixedEncrypted);
let length = await this.storageManager.getItem(PrivilegesManager.SessionLengthKey, this.storageManager.bestStorageMode());
if(length) {
return JSON.parse(length);
} else {
@@ -243,7 +243,7 @@ class PrivilegesManager {
}
async getSessionExpirey() {
let expiresAt = await this.storageManager.getItem(PrivilegesManager.SessionExpiresAtKey, StorageManager.FixedEncrypted);
let expiresAt = await this.storageManager.getItem(PrivilegesManager.SessionExpiresAtKey, this.storageManager.bestStorageMode());
if(expiresAt) {
return new Date(JSON.parse(expiresAt));
} else {

View File

@@ -174,6 +174,10 @@ class StorageManager extends SFStorageManager {
return this.getItemSync("encryptedStorage", StorageManager.Fixed) !== null;
}
bestStorageMode() {
return this.hasPasscode() ? StorageManager.FixedEncrypted : StorageManager.Fixed;
}
/*
Model Storage

View File

@@ -17,7 +17,10 @@
.ion-bookmark:before,
.ion-locked:before,
.ion-arrow-return-left:before,
.ion-arrow-return-right:before
.ion-arrow-return-right:before,
.ion-key:before,
.ion-lock-combination:before,
.ion-eye-disabled:before
{
display: inline-block; font-family: "Ionicons"; speak: none; font-style: normal; font-weight: normal; font-variant: normal; text-transform: none; text-rendering: auto; line-height: 1; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
@@ -32,4 +35,10 @@
.ion-arrow-return-right:before { content: "\f266"; }
.ion-key:before { content: "\f296"; }
.ion-lock-combination:before { content: "\f4d4"; }
.ion-eye-disabled:before { content: "\f306"; }
/*# sourceMappingURL=ionicons.css.map */

View File

@@ -153,13 +153,16 @@
opacity: 0.6;
}
.note-flag {
color: var(--sn-stylekit-info-color);
}
.note-flags {
display: flex;
flex-direction: row;
align-items: center;
.pinned, .archived {
color: var(--sn-stylekit-info-color);
.note-flag {
margin-right: 10px;
}
}
@@ -181,7 +184,7 @@
background-color: var(--sn-stylekit-info-color);
color: var(--sn-stylekit-info-contrast-color);
.pinned, .archived {
.note-flag {
color: var(--sn-stylekit-info-contrast-color);
}

View File

@@ -24,8 +24,8 @@
%input{"type" => "checkbox", "ng-disabled" => "!credentialDisplayInfo[credential].availability", "ng-checked" => "isCredentialRequiredForAction(action, credential)", "ng-click" => "checkboxValueChanged(action, credential)"}
.sk-panel-section{"ng-if" => "sessionExpirey && !sessionExpired"}
.sk-p You will not be asked to authenticate until {{sessionExpirey}}.
%a.sk-a {"ng-click" => "clearSession()"} Clear Session
.sk-p.sk-panel-row You will not be asked to authenticate until {{sessionExpirey}}.
%a.sk-a.sk-panel-row.info{"ng-click" => "clearSession()"} Clear Session
.sk-panel-footer
.sk-h2 About Privileges
.sk-panel-section.no-bottom-pad

View File

@@ -34,6 +34,7 @@
%menu-row{"label" => "ctrl.note.pinned ? 'Unpin' : 'Pin'", "action" => "ctrl.selectedMenuItem(true); ctrl.togglePin()", "desc" => "'Pin or unpin a note from the top of your list'"}
%menu-row{"label" => "ctrl.note.archived ? 'Unarchive' : 'Archive'", "action" => "ctrl.selectedMenuItem(true); ctrl.toggleArchiveNote()", "desc" => "'Archive or unarchive a note from your Archived system tag'"}
%menu-row{"label" => "ctrl.note.locked ? 'Unlock' : 'Lock'", "action" => "ctrl.selectedMenuItem(true); ctrl.toggleLockNote()", "desc" => "'Locking notes prevents unintentional editing'"}
%menu-row{"label" => "ctrl.note.content.protected ? 'Unprotect' : 'Protect'", "action" => "ctrl.selectedMenuItem(true); ctrl.toggleProtectNote()", "desc" => "'Protecting a note will require credentials to view it (Manage Privileges via Account menu)'"}
%menu-row{"label" => "'Preview'", "circle" => "ctrl.note.content.hidePreview ? 'danger' : 'success'", "circle-align" => "'right'", "action" => "ctrl.selectedMenuItem(true); ctrl.toggleNotePreview()", "desc" => "'Hide or unhide the note preview from the list of notes'"}
%menu-row{"label" => "'Delete'", "action" => "ctrl.selectedMenuItem(); ctrl.deleteNote()", "desc" => "'Delete this note permanently from all your devices'"}

View File

@@ -50,11 +50,11 @@
%strong.red.medium-text{"ng-if" => "note.errorDecrypting"} Unable to Decrypt
.note-flags
.pinned{"ng-if" => "note.pinned"}
.pinned.note-flag{"ng-if" => "note.pinned"}
%i.icon.ion-bookmark
%strong.medium-text Pinned
.archived{"ng-if" => "note.archived && !ctrl.tag.isSmartTag()"}
.archived.note-flag{"ng-if" => "note.archived && !ctrl.tag.isSmartTag()"}
%i.icon.ion-ios-box
%strong.medium-text Archived
@@ -62,8 +62,10 @@
.faded {{note.savedTagsString || note.tagsString()}}
.name{"ng-if" => "note.title"}
%span.locked.tinted{"ng-if" => "note.locked", "ng-class" => "{'tinted-selected' : ctrl.selectedNote == note}"}
%span.note-flag{"ng-show" => "note.locked"}
%i.icon.ion-locked.medium-text
%span.note-flag{"ng-show" => "note.content.protected"}
%i.icon.ion-eye-disabled
{{note.title}}
.note-preview{"ng-if" => "!ctrl.hideNotePreview && !note.content.hidePreview && !note.locked"}