commit 284417b87da057a05f51878ad4c12fbd3966e673 parent 5d370776a55bc4f0be02813426fe3002cd93eaab Author: rhunk <101876869+rhunk@users.noreply.github.com> Date: Sun, 26 Nov 2023 12:31:14 +0100 fix: dialog overlay not showing Diffstat:
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/RemoteSideContext.kt b/app/src/main/kotlin/me/rhunk/snapenhance/RemoteSideContext.kt @@ -113,7 +113,7 @@ class RemoteSideContext( } scriptManager.runtime.eachModule { - callFunction("module.onManagerLoad",androidContext) + callFunction("module.onManagerLoad", androidContext) } } diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/SharedContextHolder.kt b/app/src/main/kotlin/me/rhunk/snapenhance/SharedContextHolder.kt @@ -1,5 +1,6 @@ package me.rhunk.snapenhance +import android.app.Activity import android.content.Context import java.lang.ref.WeakReference @@ -8,7 +9,9 @@ object SharedContextHolder { fun remote(context: Context): RemoteSideContext { if (!::_remoteSideContext.isInitialized || _remoteSideContext.get() == null) { - _remoteSideContext = WeakReference(RemoteSideContext(context)) + _remoteSideContext = WeakReference(RemoteSideContext(context.let { + if (it is Activity) it.applicationContext else it + })) _remoteSideContext.get()?.reload() } diff --git a/app/src/main/kotlin/me/rhunk/snapenhance/ui/util/AndroidDialogCustom.kt b/app/src/main/kotlin/me/rhunk/snapenhance/ui/util/AndroidDialogCustom.kt @@ -82,7 +82,6 @@ fun Dialog( properties: DialogProperties = DialogProperties(), content: @Composable () -> Unit ) { - val context = LocalContext.current val view = LocalView.current val density = LocalDensity.current val layoutDirection = LocalLayoutDirection.current @@ -112,7 +111,7 @@ fun Dialog( DisposableEffect(dialog) { // Set the dialog's window type to TYPE_APPLICATION_OVERLAY so it's compatible with compose overlays - if (Settings.canDrawOverlays(view.context) && context !is Activity) { + if (Settings.canDrawOverlays(view.context) && view.context !is Activity) { dialog.window?.setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY) } dialog.show()