-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'prepare-for-compose-navigation-droid-442'
- Loading branch information
Showing
5 changed files
with
44 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/util/SecureScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package net.mullvad.mullvadvpn.compose.util | ||
|
||
import android.app.Activity | ||
import android.view.WindowManager | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.DisposableEffect | ||
import androidx.compose.runtime.saveable.rememberSaveable | ||
import androidx.compose.ui.platform.LocalContext | ||
import net.mullvad.mullvadvpn.BuildConfig | ||
|
||
@Composable | ||
fun SecureScreenWhileInView() { | ||
if (BuildConfig.DEBUG) { | ||
return | ||
} | ||
val context = LocalContext.current | ||
val window = (context as Activity).window | ||
val secureScreenWasEnabled = rememberSaveable { | ||
window.attributes.flags and WindowManager.LayoutParams.FLAG_SECURE != 0 | ||
} | ||
|
||
DisposableEffect(Unit) { | ||
window.addFlags(WindowManager.LayoutParams.FLAG_SECURE) | ||
onDispose { | ||
if (!secureScreenWasEnabled) { | ||
window.clearFlags(WindowManager.LayoutParams.FLAG_SECURE) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters