Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Add Android clear clipboard implementation and disclaimer to settings screen (#881)

Leendert de Borst8e3da4b3816c
diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/nativevaultmanager/NativeVaultManager.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/nativevaultmanager/NativeVaultManager.kt
index 8eef434b6..08023b9d5 100644
--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/nativevaultmanager/NativeVaultManager.kt
+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/nativevaultmanager/NativeVaultManager.kt
@@ -483,6 +483,38 @@ class NativeVaultManager(reactContext: ReactApplicationContext) :
}
}
+ /**
+ * Clear clipboard after a delay.
+ * @param delayInSeconds The delay in seconds after which to clear the clipboard
+ * @param promise The promise to resolve
+ */
+ @ReactMethod
+ override fun clearClipboardAfterDelay(delayInSeconds: Double, promise: Promise?) {
+ Log.d(TAG, "Scheduling clipboard clear after $delayInSeconds seconds")
+
+ if (delayInSeconds <= 0) {
+ Log.d(TAG, "Delay is 0 or negative, not scheduling clipboard clear")
+ promise?.resolve(null)
+ return
+ }
+
+ val handler = android.os.Handler(android.os.Looper.getMainLooper())
+ val delayMs = (delayInSeconds * 1000).toLong()
+
+ handler.postDelayed({
+ try {
+ Log.d(TAG, "Clearing clipboard after $delayInSeconds seconds delay")
+ val clipboardManager = reactApplicationContext.getSystemService(android.content.Context.CLIPBOARD_SERVICE) as android.content.ClipboardManager
+ clipboardManager.clearPrimaryClip()
+ Log.d(TAG, "Clipboard cleared successfully")
+ } catch (e: Exception) {
+ Log.e(TAG, "Error clearing clipboard", e)
+ }
+ }, delayMs)
+
+ promise?.resolve(null)
+ }
+
/**
* Get the auth methods.
* @param promise The promise to resolve
diff --git a/apps/mobile-app/app/(tabs)/settings/clipboard-clear.tsx b/apps/mobile-app/app/(tabs)/settings/clipboard-clear.tsx
index 9acab1098..0d7998850 100644
--- a/apps/mobile-app/app/(tabs)/settings/clipboard-clear.tsx
+++ b/apps/mobile-app/app/(tabs)/settings/clipboard-clear.tsx
@@ -1,6 +1,6 @@
import { Ionicons } from '@expo/vector-icons';
import { useState, useEffect } from 'react';
-import { StyleSheet, View, TouchableOpacity } from 'react-native';
+import { StyleSheet, View, TouchableOpacity, Platform } from 'react-native';
import { useColors } from '@/hooks/useColorScheme';
import { useTranslation } from '@/hooks/useTranslation';
@@ -15,6 +15,7 @@ const TIMEOUT_OPTIONS = [
{ value: 5, label: 'settings.clipboardClearOptions.5seconds' },
{ value: 10, label: 'settings.clipboardClearOptions.10seconds' },
{ value: 15, label: 'settings.clipboardClearOptions.15seconds' },
+ { value: 30, label: 'settings.clipboardClearOptions.30seconds' },
];
/**
@@ -76,6 +77,14 @@ export default function ClipboardClearScreen(): React.ReactNode {
color: colors.primary,
marginLeft: 8,
},
+ warningContainer: {
+ marginTop: 16,
+ },
+ warningDescription: {
+ color: colors.textMuted,
+ fontSize: 13,
+ lineHeight: 20,
+ },
});
return (
@@ -101,6 +110,13 @@ export default function ClipboardClearScreen(): React.ReactNode {
);
})}
</View>
+ {Platform.OS === 'android' && (
+ <View style={styles.warningContainer}>
+ <ThemedText style={styles.warningDescription}>
+ {t('settings.clipboardClearAndroidWarning')}
+ </ThemedText>
+ </View>
+ )}
</ThemedScrollView>
</ThemedContainer>
);
diff --git a/apps/mobile-app/i18n/locales/en.json b/apps/mobile-app/i18n/locales/en.json
index 38d8eda4c..44961dc86 100644
--- a/apps/mobile-app/i18n/locales/en.json
+++ b/apps/mobile-app/i18n/locales/en.json
@@ -195,6 +195,7 @@
"autoLock": "Auto-lock Timeout",
"clipboardClear": "Clear Clipboard",
"clipboardClearDescription": "Automatically clear copied passwords and sensitive information from your clipboard after a specified time period.",
+ "clipboardClearAndroidWarning": "Note: some Android devices have clipboard history enabled, which may keep track of previously copied items, even after AliasVault clears the clipboard. AliasVault can only overwrite the most recent item, but older entries may remain visible in history. For security reasons, we recommend disabling any clipboard history features in your device settings.",
"clipboardClearOptions": {
"never": "Never",
"5seconds": "5 seconds",