Skip to content

Commit

Permalink
close the FakeComposeView
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurKun21 committed Jan 23, 2024
1 parent 6bb5ef8 commit 7f5c5cc
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ScriptRunnerOverlay @Inject constructor(
private val scriptComponentBuilder: ScriptComponentBuilder
) {
private val layout: ComposeView
private val fakeView: FakedComposeView

private val scriptCtrlBtnLayoutParams = WindowManager.LayoutParams().apply {
type = overlayType
Expand All @@ -53,7 +54,7 @@ class ScriptRunnerOverlay @Inject constructor(
init {
require(service is ScriptRunnerService)

layout = FakedComposeView(service) {
fakeView = FakedComposeView(service) {
ScriptRunnerUI(
state = uiStateHolder.uiState,
prefsCore = prefsCore,
Expand All @@ -62,7 +63,8 @@ class ScriptRunnerOverlay @Inject constructor(
enabled = uiStateHolder.isPlayButtonEnabled,
onDrag = { x, y -> onDrag(x, y) }
)
}.view
}
layout = fakeView.view

// By default put the button on bottom-left corner
val m = display.metrics
Expand Down Expand Up @@ -117,6 +119,7 @@ class ScriptRunnerOverlay @Inject constructor(
if (shown && Settings.canDrawOverlays(service)) {
savePlayButtonLocation()

fakeView.close()
windowManager.removeView(layout)
highlightManager.hide()

Expand Down

0 comments on commit 7f5c5cc

Please sign in to comment.