fix: query status bar height on Android, closes #943 (#947)

This commit is contained in:
Huang Xin 2025-04-23 20:01:37 +08:00 committed by GitHub
parent ad551a04a1
commit 172ab382bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 148 additions and 20 deletions

View file

@ -227,4 +227,22 @@ class NativeBridgePlugin(private val activity: Activity): Plugin(activity) {
}
invoke.resolve(ret)
}
@Command
fun get_status_bar_height(invoke: Invoke) {
val ret = JSObject()
try {
val resourceId = activity.resources.getIdentifier("status_bar_height", "dimen", "android")
val height = if (resourceId > 0) {
activity.resources.getDimensionPixelSize(resourceId)
} else {
0
}
ret.put("height", height)
} catch (e: Exception) {
ret.put("height", -1)
ret.put("error", e.message)
}
invoke.resolve(ret)
}
}