Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: enable privacy screen with applock

Ammar Ahmedae7c538ad7d0
diff --git a/apps/mobile/app/components/app-lock-overlay/index.tsx b/apps/mobile/app/components/app-lock-overlay/index.tsx
index a6f04c28b..13074814b 100644
--- a/apps/mobile/app/components/app-lock-overlay/index.tsx
+++ b/apps/mobile/app/components/app-lock-overlay/index.tsx
@@ -188,11 +188,7 @@ const AppLockedOverlay = () => {
enabled(false);
} else {
SettingsService.appEnteredBackground();
-
- if (
- SettingsService.get().privacyScreen ||
- SettingsService.getProperty("appLockEnabled")
- ) {
+ if (SettingsService.get().privacyScreen) {
enabled(true);
}
}
diff --git a/apps/mobile/app/screens/settings/settings-data.tsx b/apps/mobile/app/screens/settings/settings-data.tsx
index f74d8266f..0568570e1 100644
--- a/apps/mobile/app/screens/settings/settings-data.tsx
+++ b/apps/mobile/app/screens/settings/settings-data.tsx
@@ -871,6 +871,9 @@ export const settingsGroups: SettingSection[] = [
type: "switch",
property: "appLockEnabled",
onChange: () => {
+ SettingsService.set({
+ privacyScreen: true
+ });
SettingsService.setPrivacyScreen(SettingsService.get());
},
onVerify: async () => {
diff --git a/apps/mobile/app/services/settings.ts b/apps/mobile/app/services/settings.ts
index 0260eebf1..73e6fa790 100644
--- a/apps/mobile/app/services/settings.ts
+++ b/apps/mobile/app/services/settings.ts
@@ -76,6 +76,17 @@ function migrateAppLock() {
DatabaseLogger.debug("App lock Migrated");
}
+function migrateSettings(settings: SettingStore["settings"]) {
+ const version = settings.settingsVersion;
+ if (!version) {
+ settings.settingsVersion = 1;
+ settings.privacyScreen = settings.appLockEnabled
+ ? true
+ : settings.privacyScreen;
+ MMKV.setString("appSettings", JSON.stringify(settings));
+ }
+}
+
function init() {
scale.fontScale = 1;
const settingsJson = MMKV.getString("appSettings");
@@ -83,14 +94,17 @@ function init() {
if (!settingsJson) {
MMKV.setString("appSettings", JSON.stringify(settings));
} else {
+ const settingsParsed = JSON.parse(settingsJson);
+ migrateSettings(settingsParsed);
settings = {
...settings,
- ...JSON.parse(settingsJson)
+ ...settingsParsed
};
}
if (settings.fontScale) {
scale.fontScale = settings.fontScale;
}
+
setTimeout(() => setPrivacyScreen(settings), 1);
updateSize();
useSettingStore.getState().setSettings({ ...settings });
@@ -98,7 +112,7 @@ function init() {
}
function setPrivacyScreen(settings: SettingStore["settings"]) {
- if (settings.privacyScreen || settings.appLockEnabled) {
+ if (settings.privacyScreen) {
if (Platform.OS === "android") {
NotesnookModule.setSecureMode(true);
} else {
diff --git a/apps/mobile/app/stores/use-setting-store.ts b/apps/mobile/app/stores/use-setting-store.ts
index ef0136105..b5e54fa79 100644
--- a/apps/mobile/app/stores/use-setting-store.ts
+++ b/apps/mobile/app/stores/use-setting-store.ts
@@ -81,6 +81,7 @@ export type Settings = {
biometricsAuthEnabled?: boolean;
backgroundSync?: boolean;
applockKeyboardType: "numeric" | "default";
+ settingsVersion?: number;
};
type DimensionsType = {
@@ -169,7 +170,8 @@ export const defaultSettings: SettingStore["settings"] = {
markdownShortcuts: true,
biometricsAuthEnabled: false,
appLockHasPasswordSecurity: false,
- backgroundSync: true
+ backgroundSync: true,
+ settingsVersion: 0
};
export const useSettingStore = create<SettingStore>((set, get) => ({