diff --git a/.github/patch_android.py b/.github/patch_android.py
index 14fa9b0..ec82ea3 100644
--- a/.github/patch_android.py
+++ b/.github/patch_android.py
@@ -229,8 +229,8 @@ if os.path.exists(gradle_path):
else:
print(f" WARNING: {gradle_path} not found, skipping version injection")
-# ── 7. 启动页 (Splash Screen) 美化 ───────────────────────────────────────────
-# 创建颜色资源
+# ── 7. 启动页 (Splash Screen) 官方规范适配 ───────────────────────────────────
+# 遵循 Android 12+ SplashScreen API 标准 (Plan A)
os.makedirs("android/app/src/main/res/values", exist_ok=True)
colors_path = "android/app/src/main/res/values/colors.xml"
colors_xml = """
@@ -243,25 +243,9 @@ with open(colors_path, "w", encoding="utf-8") as f:
f.write(colors_xml)
print(" Created colors.xml")
-# 创建 Splash Drawable (Layer-List)
-# 背景纯黑,Logo 居中
-splash_xml = """
-
-
- -
-
-
-
-"""
-with open("android/app/src/main/res/drawable/splash_screen.xml", "w", encoding="utf-8") as f:
- f.write(splash_xml)
-print(" Created splash_screen.xml")
-
-# ── 8. 修改主题 (Themes) 强制黑底 ──────────────────────────────────────────────
-# Capacitor 默认使用 AppTheme.NoActionBarLaunch 作为启动主题
-# 我们将其背景从白色改为我们自定义的黑色启动图
+# ── 8. 修改主题 (Themes) 适配 Google SplashScreen API ────────────────────────
+# 我们将强制主题继承自 Theme.SplashScreen,这是 Android 12+ 的官方标准方法
+# 兼容库 (androidx.core:core-splashscreen) 会负责向下兼容至 Android 6+
themes_dirs = ["android/app/src/main/res/values", "android/app/src/main/res/values-night"]
for t_dir in themes_dirs:
t_path = os.path.join(t_dir, "themes.xml")
@@ -269,32 +253,44 @@ for t_dir in themes_dirs:
with open(t_path, "r", encoding="utf-8") as f:
t_content = f.read()
- # 替换 windowBackground
+ # 1. 强制修改 parent 为 Theme.SplashScreen
t_content = re.sub(
- r'(- )(.*?)(
)',
- r'\1@drawable/splash_screen\3',
+ r'', f'{splash_items} ', 1)
with open(t_path, "w", encoding="utf-8") as f:
f.write(t_content)
- print(f" Patched {t_path} to use splash_screen")
+ print(f" Patched {t_path} to Standard SplashScreen API")
-# ── 9. MainActivity 深度黑化 (防止 WebView 加载瞬间闪白) ───────────────────────
+# ── 9. MainActivity 注入官方启动入口 ──────────────────────────────────────────
with open(main_activity_path, "r", encoding="utf-8") as f:
ma = f.read()
-# 在 onCreate 中设置 WebView 背景颜色
-if "getWebView().setBackgroundColor" not in ma:
+# 注入核心初始化代码 installSplashScreen
+# 这是 Google 规范要求的标准入口,必须在 super.onCreate 之前执行
+if "installSplashScreen" not in ma:
ma = ma.replace(
"super.onCreate(savedInstanceState);",
- "super.onCreate(savedInstanceState);\n // 消除 WebView 初始化时的白屏闪烁\n this.bridge.getWebView().setBackgroundColor(android.graphics.Color.BLACK);"
+ "androidx.core.splashscreen.SplashScreen.installSplashScreen(this);\n super.onCreate(savedInstanceState);\n // 消除衔接瞬间的可能白屏\n this.bridge.getWebView().setBackgroundColor(android.graphics.Color.BLACK);"
)
with open(main_activity_path, "w", encoding="utf-8") as f:
f.write(ma)
-print(" Injected black background to WebView in MainActivity.java")
+print(" Injected installSplashScreen() to MainActivity.java")
print(f"\nPatch complete! ({LANG} version, pkg={PKG_NAME}, v{version_name})")
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index d346390..bce5a39 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -178,9 +178,9 @@ jobs:
- name: Create Release
uses: softprops/action-gh-release@v2
with:
- # 如果是 main 分支,固定使用 latest 标签以便滚动更新
- tag_name: ${{ github.ref_name == 'main' && 'latest' || (github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref_name) }}
- name: ${{ github.ref_name == 'main' && 'Latest Build (Rolling)' || (github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref_name) }}
+ # 如果是 main 分支,固定使用 preview 标签以便滚动更新
+ tag_name: ${{ github.ref_name == 'main' && 'preview' || (github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref_name) }}
+ name: ${{ github.ref_name == 'main' && 'EmbyX Preview' || (github.event_name == 'workflow_dispatch' && inputs.release_tag || github.ref_name) }}
prerelease: ${{ github.ref_name == 'main' }}
draft: false
fail_on_unmatched_files: true