A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
allow changing app lock mode
ammarahm-ede36209c71590
diff --git a/apps/mobile/App.js b/apps/mobile/App.jsindex c40b06f14..1346de21b 100644--- a/apps/mobile/App.js+++ b/apps/mobile/App.js@@ -1,24 +1,23 @@-import React, {useEffect} from 'react';-import {BackHandler} from 'react-native';+import React, { useEffect } from 'react';+import RNExitApp from 'react-native-exit-app';import Orientation from 'react-native-orientation';-import {SafeAreaProvider} from 'react-native-safe-area-context';+import { SafeAreaProvider } from 'react-native-safe-area-context';import SplashScreen from 'react-native-splash-screen';-import {AppRootEvents} from './AppRootEvents';-import {RootView} from './initializer.root';+import { AppRootEvents } from './AppRootEvents';+import { RootView } from './initializer.root';import AppLoader from './src/components/AppLoader';-import {useTracked} from './src/provider';-import {Actions} from './src/provider/Actions';+import { useTracked } from './src/provider';+import { Actions } from './src/provider/Actions';import BiometricService from './src/services/BiometricService';-import {DDS} from './src/services/DeviceDetection';-import RNExitApp from 'react-native-exit-app';+import { DDS } from './src/services/DeviceDetection';import {eSendEvent,eSubscribeEvent,- eUnSubscribeEvent,+ eUnSubscribeEvent} from './src/services/EventManager';import SettingsService from './src/services/SettingsService';-import {db} from './src/utils/DB';-import {eDispatchAction, eOpenSideMenu} from './src/utils/Events';+import { db } from './src/utils/DB';+import { eDispatchAction, eOpenSideMenu } from './src/utils/Events';import EditorRoot from './src/views/Editor/EditorRoot';let initStatus = false;diff --git a/apps/mobile/AppRootEvents.js b/apps/mobile/AppRootEvents.jsindex 7cec1bc13..38a5c9cf2 100644--- a/apps/mobile/AppRootEvents.js+++ b/apps/mobile/AppRootEvents.js@@ -4,10 +4,12 @@ import React, {useEffect} from 'react';import {Appearance, AppState, Linking, Platform, StatusBar} from 'react-native';import * as RNIap from 'react-native-iap';import {enabled} from 'react-native-privacy-snapshot';+import SplashScreen from 'react-native-splash-screen';import {updateEvent} from './src/components/DialogManager/recievers';import {useTracked} from './src/provider';import {Actions} from './src/provider/Actions';import Backup from './src/services/Backup';+import BiometricService from './src/services/BiometricService';import {eSendEvent, ToastEvent} from './src/services/EventManager';import {clearMessage,@@ -32,11 +34,11 @@ import {MMKV} from './src/utils/mmkv';import {sleep} from './src/utils/TimeUtils';import {getNote, getWebviewInit} from './src/views/Editor/Functions';+import RNExitApp from 'react-native-exit-app';let prevTransactionId = null;let subsriptionSuccessListener;let subsriptionErrorListener;-async function storeAppState() {if (editing.currentlyEditing) {let state = JSON.stringify({@@ -82,8 +84,21 @@ async function reconnectSSE(connection) {const onAppStateChanged = async (state) => {if (state === 'active') {updateStatusBarColor();- if (SettingsService.get().privacyScreen) {+ if (+ SettingsService.get().privacyScreen ||+ SettingsService.get().appLockMode !== 'none'+ ) {enabled(false);+ SplashScreen.show();+ let result = await BiometricService.validateUser(+ 'Unlock to access your notes',+ );+ if (result) {+ SplashScreen.hide();+ } else {+ RNExitApp.exitApp();+ return;+ }}await reconnectSSE();await checkIntentState();@@ -91,11 +106,14 @@ const onAppStateChanged = async (state) => {await MMKV.removeItem('appState');}} else {- if (getNote()?.locked) {+ if (getNote()?.locked && SettingsService.get().appLockMode === 'none') {eSendEvent(eClearEditor);}await storeAppState();- if (SettingsService.get().privacyScreen) {+ if (+ SettingsService.get().privacyScreen ||+ SettingsService.get().appLockMode !== 'none'+ ) {enabled(true);}}diff --git a/apps/mobile/src/provider/DefaultState.js b/apps/mobile/src/provider/DefaultState.jsindex 2aba5b86a..b5be7fe54 100644--- a/apps/mobile/src/provider/DefaultState.js+++ b/apps/mobile/src/provider/DefaultState.js@@ -31,7 +31,7 @@ export const defaultState = {sortOrder: 'desc',screenshotMode: true,privacyScreen: false,- appLockMode:'launch'+ appLockMode:'none' //none or // background // launch},currentScreen: 'Notes',deviceMode:null,diff --git a/apps/mobile/src/views/Settings/index.js b/apps/mobile/src/views/Settings/index.jsindex 37dd29fc8..e16eda08d 100644--- a/apps/mobile/src/views/Settings/index.js+++ b/apps/mobile/src/views/Settings/index.js@@ -1028,6 +1028,8 @@ const SettingsAppearanceSection = () => {const SettingsPrivacyAndSecurity = () => {const [state] = useTracked();const {colors, settings} = state;+ const [appLockVisible, setAppLockVisible] = useState(true);+const [vaultStatus, setVaultStatus] = React.useState({exists: false,biometryEnrolled: false,@@ -1068,12 +1070,89 @@ const SettingsPrivacyAndSecurity = () => {};}, []);+ const modes = [+ {+ title: 'None',+ value: 'none',+ desc:+ 'Disable app lock. Notes will be accessible to anyone who opens the app',+ },+ {+ title: 'Secure Mode',+ value: 'launch',+ desc:+ 'Lock app on launch and keep it unlocked when you switch to other apps.',+ },+ {+ title: 'Strict Mode',+ value: 'background',+ desc:+ 'Lock app on launch and also when you switch from other apps or background.',+ },+ ];+return (<>+ {appLockVisible && (+ <BaseDialog visible={true}>+ <DialogContainer height={450}>+ <DialogHeader+ title="App lock mode"+ paragraph="Select the level of security you want to enable."+ />+ <Seperator />+ {modes.map((item) => (+ <PressableButton+ type={+ settings.appLockMode === item.value ? 'accent' : 'transparent'+ }+ onPress={() => {+ setSetting(settings, 'appLockMode', item.value);+ }}+ customStyle={{+ justifyContent: 'flex-start',+ alignItems: 'flex-start',+ paddingHorizontal: 6,+ paddingVertical: 6,+ marginTop: 3,+ marginBottom: 3,+ }}+ style={{+ marginBottom: 10,+ }}>+ <Heading+ color={+ settings.appLockMode === item.value ? 'white' : colors.pri+ }+ style={{maxWidth: '95%'}}+ size={SIZE.md}>+ {item.title}+ </Heading>+ <Paragraph+ color={+ settings.appLockMode === item.value ? 'white' : colors.icon+ }+ style={{maxWidth: '95%'}}+ size={SIZE.sm}>+ {item.desc}+ </Paragraph>+ </PressableButton>+ ))}++ <DialogButtons+ negativeTitle="Cancel"+ onPressNegative={() => {+ setAppLockVisible(false);+ }}+ />+ </DialogContainer>+ </BaseDialog>+ )}+<SectionHeader title="Privacy & Security" /><CustomButtonkey="privacyMode"- title="Privacy Mode"+ title="Privacy mode"tagline="Hide app contents when you switch to other apps. This will also disable screenshot taking in the app."onPress={() => {Platform.OS === 'android'@@ -1093,12 +1172,36 @@ const SettingsPrivacyAndSecurity = () => {}/>+ {vaultStatus.isBiometryAvailable && (+ <CustomButton+ key="appLock"+ title="App lock"+ tagline="Require biometrics to access your notes."+ onPress={() => {+ Platform.OS === 'android'+ ? AndroidModule.setSecureMode(!settings.privacyScreen)+ : enabled(true);+ setSetting(settings, 'privacyScreen', !settings.privacyScreen);+ }}+ maxWidth="90%"+ customComponent={+ <Icon+ size={SIZE.xl}+ color={settings.privacyScreen ? colors.accent : colors.icon}+ name={+ settings.privacyScreen ? 'toggle-switch' : 'toggle-switch-off'+ }+ />+ }+ />+ )}+{vaultStatus.exists ? (<>{vaultStatus.isBiometryAvailable ? (<CustomButtonkey="fingerprintVaultUnlock"- title="Vault Biometic Unlock"+ title="Vault biometrics unlock"tagline="Access notes in vault using biometrics"onPress={() => {openVault({