Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add clipboard clear settings page (#881)
Leendert de Borsta75392c57328
diff --git a/apps/mobile-app/app/(tabs)/settings/_layout.tsx b/apps/mobile-app/app/(tabs)/settings/_layout.tsxindex f4641af38..5844cdbe9 100644--- a/apps/mobile-app/app/(tabs)/settings/_layout.tsx+++ b/apps/mobile-app/app/(tabs)/settings/_layout.tsx@@ -59,6 +59,14 @@ export default function SettingsLayout(): React.ReactNode {...defaultHeaderOptions,}}/>+ <Stack.Screen+ name="clipboard-clear"+ options={{+ title: t('settings.clipboardClear'),+ headerBackTitle: t('settings.title'),+ ...defaultHeaderOptions,+ }}+ /><Stack.Screenname="identity-generator"options={{diff --git a/apps/mobile-app/app/(tabs)/settings/clipboard-clear.tsx b/apps/mobile-app/app/(tabs)/settings/clipboard-clear.tsxnew file mode 100644index 000000000..9acab1098--- /dev/null+++ b/apps/mobile-app/app/(tabs)/settings/clipboard-clear.tsx@@ -0,0 +1,107 @@+import { Ionicons } from '@expo/vector-icons';+import { useState, useEffect } from 'react';+import { StyleSheet, View, TouchableOpacity } from 'react-native';++import { useColors } from '@/hooks/useColorScheme';+import { useTranslation } from '@/hooks/useTranslation';++import { ThemedContainer } from '@/components/themed/ThemedContainer';+import { ThemedScrollView } from '@/components/themed/ThemedScrollView';+import { ThemedText } from '@/components/themed/ThemedText';+import { useAuth } from '@/context/AuthContext';++const TIMEOUT_OPTIONS = [+ { value: 0, label: 'settings.clipboardClearOptions.never' },+ { value: 5, label: 'settings.clipboardClearOptions.5seconds' },+ { value: 10, label: 'settings.clipboardClearOptions.10seconds' },+ { value: 15, label: 'settings.clipboardClearOptions.15seconds' },+];++/**+ * Clipboard clear settings screen.+ */+export default function ClipboardClearScreen(): React.ReactNode {+ const colors = useColors();+ const { t } = useTranslation();+ const { getClipboardClearTimeout, setClipboardClearTimeout } = useAuth();+ const [selectedTimeout, setSelectedTimeout] = useState<number>(10);++ useEffect(() => {+ /**+ * Load the current clipboard clear timeout.+ */+ const loadCurrentTimeout = async (): Promise<void> => {+ const timeout = await getClipboardClearTimeout();+ setSelectedTimeout(timeout);+ };++ loadCurrentTimeout();+ }, [getClipboardClearTimeout]);++ /**+ * Handle timeout change.+ */+ const handleTimeoutChange = async (timeout: number): Promise<void> => {+ await setClipboardClearTimeout(timeout);+ setSelectedTimeout(timeout);+ };++ const styles = StyleSheet.create({+ headerText: {+ color: colors.textMuted,+ fontSize: 13,+ },+ option: {+ alignItems: 'center',+ borderBottomColor: colors.accentBorder,+ borderBottomWidth: StyleSheet.hairlineWidth,+ flexDirection: 'row',+ paddingHorizontal: 16,+ paddingVertical: 14,+ },+ optionContainer: {+ backgroundColor: colors.accentBackground,+ borderRadius: 10,+ marginTop: 16,+ },+ optionLast: {+ borderBottomWidth: 0,+ },+ optionText: {+ color: colors.text,+ flex: 1,+ fontSize: 16,+ },+ selectedIcon: {+ color: colors.primary,+ marginLeft: 8,+ },+ });++ return (+ <ThemedContainer>+ <ThemedScrollView>+ <ThemedText style={styles.headerText}>+ {t('settings.clipboardClearDescription')}+ </ThemedText>+ <View style={styles.optionContainer}>+ {TIMEOUT_OPTIONS.map((option, index) => {+ const isLast = index === TIMEOUT_OPTIONS.length - 1;+ return (+ <TouchableOpacity+ key={option.value}+ style={[styles.option, isLast && styles.optionLast]}+ onPress={() => handleTimeoutChange(option.value)}+ >+ <ThemedText style={styles.optionText}>{t(option.label)}</ThemedText>+ {selectedTimeout === option.value && (+ <Ionicons name="checkmark" size={20} style={styles.selectedIcon} />+ )}+ </TouchableOpacity>+ );+ })}+ </View>+ </ThemedScrollView>+ </ThemedContainer>+ );+}\ No newline at end of filediff --git a/apps/mobile-app/app/(tabs)/settings/index.tsx b/apps/mobile-app/app/(tabs)/settings/index.tsxindex e8b44f7a4..1f0353274 100644--- a/apps/mobile-app/app/(tabs)/settings/index.tsx+++ b/apps/mobile-app/app/(tabs)/settings/index.tsx@@ -27,11 +27,12 @@ export default function SettingsScreen() : React.ReactNode {const colors = useColors();const { t } = useTranslation();const { getAuthMethodDisplayKey, shouldShowAutofillReminder } = useAuth();- const { getAutoLockTimeout } = useAuth();+ const { getAutoLockTimeout, getClipboardClearTimeout } = useAuth();const { loadApiUrl, getDisplayUrl } = useApiUrl();const scrollY = useRef(new Animated.Value(0)).current;const scrollViewRef = useRef<ScrollView>(null);const [autoLockDisplay, setAutoLockDisplay] = useState<string>('');+ const [clipboardClearDisplay, setClipboardClearDisplay] = useState<string>('');const [authMethodDisplay, setAuthMethodDisplay] = useState<string>('');const [isFirstLoad, setIsFirstLoad] = useMinDurationLoading(true, 100);@@ -65,6 +66,24 @@ export default function SettingsScreen() : React.ReactNode {setAutoLockDisplay(display);};+ /**+ * Load the clipboard clear display.+ */+ const loadClipboardClearDisplay = async () : Promise<void> => {+ const clipboardTimeout = await getClipboardClearTimeout();+ let display = t('common.never');++ if (clipboardTimeout === 5) {+ display = t('settings.clipboardClearOptions.5seconds');+ } else if (clipboardTimeout === 10) {+ display = t('settings.clipboardClearOptions.10seconds');+ } else if (clipboardTimeout === 15) {+ display = t('settings.clipboardClearOptions.15seconds');+ }++ setClipboardClearDisplay(display);+ };+/*** Load the auth method display.*/@@ -77,7 +96,7 @@ export default function SettingsScreen() : React.ReactNode {* Load all settings data.*/const loadData = async () : Promise<void> => {- await Promise.all([loadAutoLockDisplay(), loadAuthMethodDisplay(), loadApiUrl()]);+ await Promise.all([loadAutoLockDisplay(), loadClipboardClearDisplay(), loadAuthMethodDisplay(), loadApiUrl()]);setIsFirstLoad(false);};@@ -143,6 +162,13 @@ export default function SettingsScreen() : React.ReactNode {router.push('/(tabs)/settings/identity-generator');};+ /**+ * Handle the clipboard clear settings press.+ */+ const handleClipboardClearPress = () : void => {+ router.push('/(tabs)/settings/clipboard-clear');+ };+/*** Handle the language settings press.*/@@ -374,6 +400,24 @@ export default function SettingsScreen() : React.ReactNode {</View></TouchableOpacity><View style={styles.separator} />+ <TouchableOpacity+ style={styles.settingItem}+ onPress={handleClipboardClearPress}+ >+ <View style={styles.settingItemIcon}>+ <Ionicons name="clipboard-outline" size={20} color={colors.text} />+ </View>+ <View style={styles.settingItemContent}>+ <ThemedText style={styles.settingItemText}>{t('settings.clipboardClear')}</ThemedText>+ {isFirstLoad ? (+ <InlineSkeletonLoader width={80} style={styles.skeletonLoader} />+ ) : (+ <ThemedText style={styles.settingItemValue}>{clipboardClearDisplay}</ThemedText>+ )}+ <Ionicons name="chevron-forward" size={20} color={colors.textMuted} />+ </View>+ </TouchableOpacity>+ <View style={styles.separator} /><TouchableOpacitystyle={styles.settingItem}onPress={handleLanguagePress}diff --git a/apps/mobile-app/context/AuthContext.tsx b/apps/mobile-app/context/AuthContext.tsxindex 6ae639242..36ec8c545 100644--- a/apps/mobile-app/context/AuthContext.tsx+++ b/apps/mobile-app/context/AuthContext.tsx@@ -30,6 +30,8 @@ type AuthContextType = {getAuthMethodDisplayKey: () => Promise<string>;getAutoLockTimeout: () => Promise<number>;setAutoLockTimeout: (timeout: number) => Promise<void>;+ getClipboardClearTimeout: () => Promise<number>;+ setClipboardClearTimeout: (timeout: number) => Promise<void>;getBiometricDisplayNameKey: () => Promise<string>;isBiometricsEnabledOnDevice: () => Promise<boolean>;setOfflineMode: (isOffline: boolean) => void;@@ -44,6 +46,7 @@ type AuthContextType = {}const AUTOFILL_CONFIGURED_KEY = 'autofill_configured';+const CLIPBOARD_TIMEOUT_KEY = 'clipboard_clear_timeout';/*** Auth context.@@ -265,6 +268,30 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ children}}, []);+ /**+ * Get the clipboard clear timeout from AsyncStorage+ */+ const getClipboardClearTimeout = useCallback(async (): Promise<number> => {+ try {+ const timeoutStr = await AsyncStorage.getItem(CLIPBOARD_TIMEOUT_KEY);+ return timeoutStr ? parseInt(timeoutStr, 10) : 10;+ } catch (error) {+ console.error('Failed to get clipboard clear timeout:', error);+ return 10;+ }+ }, []);++ /**+ * Set the clipboard clear timeout in AsyncStorage+ */+ const setClipboardClearTimeout = useCallback(async (timeout: number): Promise<void> => {+ try {+ await AsyncStorage.setItem(CLIPBOARD_TIMEOUT_KEY, timeout.toString());+ } catch (error) {+ console.error('Failed to set clipboard clear timeout:', error);+ }+ }, []);+/*** Check if the vault is unlocked.*/@@ -406,6 +433,8 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ childrenisBiometricsEnabledOnDevice,getAutoLockTimeout,setAutoLockTimeout,+ getClipboardClearTimeout,+ setClipboardClearTimeout,getBiometricDisplayNameKey,markAutofillConfigured,setReturnUrl,@@ -430,6 +459,8 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({ childrenisBiometricsEnabledOnDevice,getAutoLockTimeout,setAutoLockTimeout,+ getClipboardClearTimeout,+ setClipboardClearTimeout,getBiometricDisplayNameKey,markAutofillConfigured,setReturnUrl,diff --git a/apps/mobile-app/i18n/locales/en.json b/apps/mobile-app/i18n/locales/en.jsonindex 39524c56a..7d66ab8eb 100644--- a/apps/mobile-app/i18n/locales/en.json+++ b/apps/mobile-app/i18n/locales/en.json@@ -11,7 +11,7 @@"error": "Error","success": "Success","never": "Never",- "copied": "Copied",+ "copied": "Copied to clipboard","loadMore": "Load more","use": "Use"},@@ -193,6 +193,14 @@},"vaultUnlock": "Vault Unlock Method","autoLock": "Auto-lock Timeout",+ "clipboardClear": "Clear Clipboard",+ "clipboardClearDescription": "Automatically clear copied passwords and sensitive information from your clipboard after a specified time period.",+ "clipboardClearOptions": {+ "never": "Never",+ "5seconds": "5 seconds",+ "10seconds": "10 seconds",+ "15seconds": "15 seconds"+ },"identityGenerator": "Identity Generator","security": "Security","appVersion": "App version {{version}} ({{url}})",