feat: android project skeleton with immersive home activity
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package top.yeij.hearth
|
||||
|
||||
import android.app.Activity
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.WindowInsets
|
||||
import android.view.WindowInsetsController
|
||||
|
||||
// HOME 桌面 activity,后续 Task 挂载 WebView 与 JsBridge
|
||||
// HOME launcher activity; later tasks mount WebView and JsBridge
|
||||
class MainActivity : Activity() {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "HearthMainActivity"
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
Log.d(TAG, "onCreate: enter immersive mode")
|
||||
enterImmersive()
|
||||
}
|
||||
|
||||
// 进入沉浸式全屏:隐藏状态栏与导航栏,滑动可临时唤出
|
||||
// Enter immersive fullscreen: hide status/navigation bars, swipe to reveal transiently
|
||||
private fun enterImmersive() {
|
||||
window.insetsController?.let { ctrl ->
|
||||
ctrl.hide(WindowInsets.Type.statusBars() or WindowInsets.Type.navigationBars())
|
||||
ctrl.systemBarsBehavior =
|
||||
WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||
}
|
||||
}
|
||||
|
||||
// Back 键桌面态屏蔽(webAPP 打开时由 WebAppContainer 接管)
|
||||
// Swallow Back key on desktop state (WebAppContainer takes over when a webAPP is open)
|
||||
@Suppress("DEPRECATION")
|
||||
override fun onBackPressed() {
|
||||
// 桌面态:吞掉,不响应
|
||||
// Desktop state: consume the event, do not respond
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user