feat(ui): allow phone to be locked while still showing AOD, bump minSDK to 27
This commit is contained in:
@@ -31,7 +31,7 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "org.nsh07.pomodoro"
|
applicationId = "org.nsh07.pomodoro"
|
||||||
minSdk = 26
|
minSdk = 27
|
||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
versionCode = 13
|
versionCode = 13
|
||||||
versionName = "1.5.0"
|
versionName = "1.5.0"
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
package org.nsh07.pomodoro.ui
|
package org.nsh07.pomodoro.ui
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
import android.view.WindowManager
|
||||||
|
import androidx.activity.compose.LocalActivity
|
||||||
import androidx.compose.animation.SharedTransitionLayout
|
import androidx.compose.animation.SharedTransitionLayout
|
||||||
import androidx.compose.animation.SharedTransitionScope
|
import androidx.compose.animation.SharedTransitionScope
|
||||||
import androidx.compose.animation.animateColorAsState
|
import androidx.compose.animation.animateColorAsState
|
||||||
@@ -61,19 +63,29 @@ fun SharedTransitionScope.AlwaysOnDisplay(
|
|||||||
var sharedElementTransitionComplete by remember { mutableStateOf(false) }
|
var sharedElementTransitionComplete by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
val view = LocalView.current
|
val view = LocalView.current
|
||||||
|
val activity = LocalActivity.current
|
||||||
val window = remember { (view.context as Activity).window }
|
val window = remember { (view.context as Activity).window }
|
||||||
val insetsController = remember { WindowCompat.getInsetsController(window, view) }
|
val insetsController = remember { WindowCompat.getInsetsController(window, view) }
|
||||||
|
|
||||||
DisposableEffect(Unit) {
|
DisposableEffect(Unit) {
|
||||||
view.keepScreenOn = true
|
window.addFlags(
|
||||||
|
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON or
|
||||||
|
WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
|
||||||
|
)
|
||||||
|
activity?.setShowWhenLocked(true)
|
||||||
insetsController.apply {
|
insetsController.apply {
|
||||||
hide(WindowInsetsCompat.Type.statusBars())
|
hide(WindowInsetsCompat.Type.statusBars())
|
||||||
hide(WindowInsetsCompat.Type.navigationBars())
|
hide(WindowInsetsCompat.Type.navigationBars())
|
||||||
systemBarsBehavior =
|
systemBarsBehavior =
|
||||||
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||||
}
|
}
|
||||||
|
|
||||||
onDispose {
|
onDispose {
|
||||||
view.keepScreenOn = false
|
window.clearFlags(
|
||||||
|
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON or
|
||||||
|
WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
|
||||||
|
)
|
||||||
|
activity?.setShowWhenLocked(false)
|
||||||
insetsController.apply {
|
insetsController.apply {
|
||||||
show(WindowInsetsCompat.Type.statusBars())
|
show(WindowInsetsCompat.Type.statusBars())
|
||||||
show(WindowInsetsCompat.Type.navigationBars())
|
show(WindowInsetsCompat.Type.navigationBars())
|
||||||
|
|||||||
Reference in New Issue
Block a user