feat: android app list page with search and icons
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user