feat: android app list page with search and icons

This commit is contained in:
2026-08-16 16:20:10 +08:00
parent bd56d89cf3
commit 0153ec38ae
6 changed files with 98 additions and 1 deletions
@@ -1,12 +1,14 @@
package top.yeij.hearth.webview
import android.util.Log
import top.yeij.hearth.app.AppRepository
class JsBridge(
private val deviceWidthPx: Int,
private val deviceHeightPx: Int,
private val density: Float,
private val darkMode: Boolean,
private val appRepository: AppRepository? = null,
) {
private val gson = com.google.gson.Gson()
@@ -22,4 +24,14 @@ class JsBridge(
)
)
}
// 返回已安装应用列表 JSON(无仓库时返回空数组)
// Return installed app list JSON (empty array when no repository wired)
@android.webkit.JavascriptInterface
fun listApps(): String = appRepository?.listApps() ?: "[]"
// 启动指定包名应用,成功返回 true(无仓库时返回 false)
// Launch an app by package name, true on success (false when no repository wired)
@android.webkit.JavascriptInterface
fun launchApp(packageName: String): Boolean = appRepository?.launchApp(packageName) ?: false
}