mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 22:05:59 +00:00
fix: keep the bottom-screen menu and layout editor open when the screen turns off (#2247)
This commit is contained in:
1 parent
5b2f7a9a6d
commit
ef46c011db
3 files changed
+16
-8
No files matched your search
@@ -18,6 +18,8 @@ import androidx.savedstate.setViewTreeSavedStateRegistryOwner
|
||||
|
||||
internal val LocalInputActivity = staticCompositionLocalOf<ComponentActivity?> { null }
|
||||
|
||||
fun ComponentActivity.screenIsOff(): Boolean = getSystemService(android.os.PowerManager::class.java)?.isInteractive == false
|
||||
|
||||
@Composable
|
||||
internal fun InputDisplayContent(host: ComponentActivity, display: Display, onDismiss: () -> Unit, content: @Composable () -> Unit) {
|
||||
val parent = rememberCompositionContext()
|
||||
@@ -58,7 +60,7 @@ internal fun InputDisplayContent(host: ComponentActivity, display: Display, onDi
|
||||
}
|
||||
showPresentation()
|
||||
val observer = LifecycleEventObserver { _, event ->
|
||||
if (event == Lifecycle.Event.ON_STOP) presentation.hide()
|
||||
if (event == Lifecycle.Event.ON_STOP && !host.screenIsOff()) presentation.hide()
|
||||
if (event == Lifecycle.Event.ON_START) showPresentation()
|
||||
}
|
||||
host.lifecycle.addObserver(observer)
|
||||
|
||||
@@ -173,7 +173,7 @@ fun InputSurfaceDialog(profile: String, onDismiss: () -> Unit, onChanged: () ->
|
||||
}
|
||||
runCatching { presentation.show() }.onFailure { failure = it.message }
|
||||
val observer = LifecycleEventObserver { _, event ->
|
||||
if (event == Lifecycle.Event.ON_STOP) presentation.hide()
|
||||
if (event == Lifecycle.Event.ON_STOP && !host.screenIsOff()) presentation.hide()
|
||||
if (event == Lifecycle.Event.ON_START) runCatching { presentation.show() }
|
||||
}
|
||||
host.lifecycle.addObserver(observer)
|
||||
|
||||
Reference in new issue
Block a user