manager: Update secondary interface status and optimize WebView interface

This commit is contained in:
ShirkNeko
2025-05-17 17:09:47 +08:00
parent 377ea183a7
commit d4682fb06e
2 changed files with 18 additions and 13 deletions

View File

@@ -61,6 +61,12 @@ fun WebUIXTheme(
ThemeConfig.backgroundImageLoaded = false ThemeConfig.backgroundImageLoaded = false
} }
} }
// 更新二级界面状态
LaunchedEffect(isSecondaryScreen) {
WebViewInterface.updateSecondaryScreenState(isSecondaryScreen)
}
val colorScheme = when { val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
if (darkTheme) { if (darkTheme) {
@@ -235,14 +241,6 @@ fun WebUIXTheme(
} }
} }
/**
* 获取当前界面是否为二级界面
*/
@Composable
fun isSecondaryScreen(): Boolean {
return LocalIsSecondaryScreen.current
}
/** /**
* 配置WebUI的系统栏样式 * 配置WebUI的系统栏样式
*/ */
@@ -272,4 +270,4 @@ private fun ConfigureSystemBars(
} }
) )
} }
} }

View File

@@ -7,6 +7,9 @@ import android.text.TextUtils
import android.view.Window import android.view.Window
import android.webkit.JavascriptInterface import android.webkit.JavascriptInterface
import android.widget.Toast import android.widget.Toast
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.core.view.WindowInsetsCompat import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat import androidx.core.view.WindowInsetsControllerCompat
import com.dergoogler.mmrl.webui.interfaces.WXOptions import com.dergoogler.mmrl.webui.interfaces.WXOptions
@@ -24,7 +27,6 @@ import com.sukisu.ultra.ui.util.controlKpmModule
import com.sukisu.ultra.ui.util.listKpmModules import com.sukisu.ultra.ui.util.listKpmModules
import java.io.File import java.io.File
import java.util.concurrent.CompletableFuture import java.util.concurrent.CompletableFuture
import androidx.compose.runtime.Composable
class WebViewInterface( class WebViewInterface(
wxOptions: WXOptions, wxOptions: WXOptions,
@@ -32,15 +34,20 @@ class WebViewInterface(
override var name: String = "ksu" override var name: String = "ksu"
companion object { companion object {
private var isSecondaryScreenState by mutableStateOf(false)
fun factory() = JavaScriptInterface(WebViewInterface::class.java) fun factory() = JavaScriptInterface(WebViewInterface::class.java)
fun updateSecondaryScreenState(isSecondary: Boolean) {
isSecondaryScreenState = isSecondary
}
} }
private val modDir get() = "/data/adb/modules/${modId.id}" private val modDir get() = "/data/adb/modules/${modId.id}"
@Composable
@JavascriptInterface @JavascriptInterface
fun isSecondaryPage(): Boolean { fun isSecondaryPage(): Boolean {
return isSecondaryScreen() return isSecondaryScreenState
} }
@JavascriptInterface @JavascriptInterface
@@ -233,4 +240,4 @@ fun hideSystemUI(window: Window) =
} }
fun showSystemUI(window: Window) = fun showSystemUI(window: Window) =
WindowInsetsControllerCompat(window, window.decorView).show(WindowInsetsCompat.Type.systemBars()) WindowInsetsControllerCompat(window, window.decorView).show(WindowInsetsCompat.Type.systemBars())