feat: android project skeleton with immersive home activity
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
id("org.jetbrains.kotlin.android")
|
||||
}
|
||||
android {
|
||||
namespace = "top.yeij.hearth"
|
||||
compileSdk = 35
|
||||
defaultConfig {
|
||||
applicationId = "top.yeij.hearth"
|
||||
minSdk = 30
|
||||
targetSdk = 30
|
||||
versionCode = 1
|
||||
versionName = "0.1.0"
|
||||
}
|
||||
buildTypes { release { isMinifyEnabled = false } }
|
||||
compileOptions { sourceCompatibility = JavaVersion.VERSION_17; targetCompatibility = JavaVersion.VERSION_17 }
|
||||
kotlinOptions { jvmTarget = "17" }
|
||||
}
|
||||
dependencies {
|
||||
implementation("androidx.core:core-ktx:1.13.1")
|
||||
implementation("com.squareup.okhttp3:okhttp:4.12.0")
|
||||
implementation("com.google.code.gson:gson:2.11.0")
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
|
||||
<application
|
||||
android:label="Hearth"
|
||||
android:theme="@android:style/Theme.Material.NoActionBar">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:screenOrientation="landscape">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.HOME" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Hearth</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hearth Launcher</h1>
|
||||
<p>占位页面,后续由 WebView 加载。</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -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