package com.peachpasswords.ui.components import android.view.WindowManager import androidx.compose.runtime.Composable import androidx.compose.runtime.DisposableEffect import androidx.compose.ui.platform.LocalContext import androidx.fragment.app.FragmentActivity /** * Sets WindowManager.FLAG_SECURE while this composable is in the composition and * clears it on dispose — blocking screenshots, screen recording, and the recents * thumbnail of screens that display secrets (MN-3: recovery words, export blob, * codex generation). Mirrors the inline effect EntryDetailScreen / NotesModeScreen * already use. */ @Composable fun SecureFlagEffect() { val context = LocalContext.current DisposableEffect(Unit) { val window = (context as? FragmentActivity)?.window window?.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE) onDispose { window?.clearFlags(WindowManager.LayoutParams.FLAG_SECURE) } } }