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 import com.peachpasswords.BuildConfig /** * 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. * * Skipped only when BuildConfig.DEBUG is true AND [QaFlags.disableSecureCaptureForQa] * was explicitly opted into (see that file) — automated visual QA needs to capture * these screens too. Always enforced in release builds regardless of the flag. */ @Composable fun SecureFlagEffect() { val context = LocalContext.current DisposableEffect(Unit) { if (BuildConfig.DEBUG && QaFlags.disableSecureCaptureForQa) { return@DisposableEffect onDispose { } } val window = (context as? FragmentActivity)?.window window?.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE) onDispose { window?.clearFlags(WindowManager.LayoutParams.FLAG_SECURE) } } }