SecureFlagEffect.kt

978 B · raw

1package com.peachpasswords.ui.components23import android.view.WindowManager4import androidx.compose.runtime.Composable5import androidx.compose.runtime.DisposableEffect6import androidx.compose.ui.platform.LocalContext7import androidx.fragment.app.FragmentActivity89/**10 * Sets WindowManager.FLAG_SECURE while this composable is in the composition and11 * clears it on dispose — blocking screenshots, screen recording, and the recents12 * thumbnail of screens that display secrets (MN-3: recovery words, export blob,13 * codex generation). Mirrors the inline effect EntryDetailScreen / NotesModeScreen14 * already use.15 */16@Composable17fun SecureFlagEffect() {18    val context = LocalContext.current19    DisposableEffect(Unit) {20        val window = (context as? FragmentActivity)?.window21        window?.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)22        onDispose { window?.clearFlags(WindowManager.LayoutParams.FLAG_SECURE) }23    }24}