Skip to content

Commit

Permalink
Vault: Set secure mode while viewing
Browse files Browse the repository at this point in the history
Hides the gallery screen in the recents apps or in screenrecording (and screenshots) to protect users privacy to their hidden content

Signed-off-by: IacobIonut01 <paulionut2003@gmail.com>
  • Loading branch information
IacobIonut01 committed Jun 25, 2024
1 parent 85e160e commit 4dc487c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ android {
applicationId = "com.dot.gallery"
minSdk = 30
targetSdk = 34
versionCode = 30005
versionCode = 30006
versionName = "3.0.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
package com.dot.gallery.feature_node.presentation.vault

import android.app.Activity
import android.os.Build
import android.view.WindowManager
import androidx.annotation.RequiresApi
import androidx.biometric.BiometricManager.Authenticators.BIOMETRIC_STRONG
import androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTIAL
import androidx.biometric.BiometricPrompt.PromptInfo
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.dot.gallery.R
Expand All @@ -28,6 +32,14 @@ fun VaultScreen(
navigate: (route: String) -> Unit,
vm: VaultViewModel
) {
val window = (LocalContext.current as Activity).window

DisposableEffect(Unit) {
window.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
onDispose {
window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
}
}

val vaults by vm.vaults.collectAsStateWithLifecycle()
val currentVault by vm.currentVault.collectAsStateWithLifecycle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package com.dot.gallery.feature_node.presentation.vault.encryptedmediaview

import android.app.Activity
import android.view.WindowManager
import androidx.activity.compose.BackHandler
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.FastOutLinearInEasing
Expand All @@ -23,6 +25,7 @@ import androidx.compose.foundation.pager.PagerDefaults
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
Expand Down Expand Up @@ -76,6 +79,14 @@ fun EncryptedMediaViewScreen(
restoreMedia: (Vault, EncryptedMedia) -> Unit,
deleteMedia: (Vault, EncryptedMedia) -> Unit
) {
val window = (LocalContext.current as Activity).window

DisposableEffect(Unit) {
window.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
onDispose {
window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
}
}
var runtimeMediaId by rememberSaveable(mediaId) { mutableLongStateOf(mediaId) }
val state by mediaState.collectAsStateWithLifecycle()
val initialPage = rememberSaveable(runtimeMediaId) {
Expand Down

0 comments on commit 4dc487c

Please sign in to comment.