Merge branch 'fix/image-management-cleanup' into main

图片资源管理优化: 清理无用资源、消除硬编码、补齐 Adaptive Icon、校正文档

7 个提交:
- 删除 app/assets 中无引用的 app_icon PNG (设备 -516KB)
- 删除 core/assets/gifs/.omc 工具残留 (gitignored, 物理清理)
- gifs/→animations/、AnimatedGif→AnimatedWebp (名实相符)
- WebP 文件列表改构建期 BuildConfig 注入 + 测试守卫 (消除 (1..152) 硬编码)
- 新增 Adaptive Icon (anydpi-v26, 修复 API 26+ 启动器裁切)
- 校正 4 份 assets/AGENTS.md (消除 GIF/镜像错误描述)
- 修复审查发现 (README 坏链 + 原图归宿说明)

验证:
- 146 单元测试 0 失败
- :app:assembleDebug + spotlessCheck 全过
- APK -489KB (24,416,752 → 23,915,583)
- Adaptive Icon 模拟器实机验证 (圆形遮罩下背景填满、主体居中无裁切)
- Task 4 守卫突变验证 (硬编码 1..150 时测试立即 FAIL)
This commit is contained in:
xfy 2026-06-15 14:15:49 +08:00
commit aba2086c22
175 changed files with 185 additions and 108 deletions

View File

@ -3,7 +3,7 @@
纯 Android + Jetpack Compose 日历应用,支持农历/节气/节日、个人班次排期,提供月/周/年三种视图。 纯 Android + Jetpack Compose 日历应用,支持农历/节气/节日、个人班次排期,提供月/周/年三种视图。
<div> <div>
<img src="app/src/main/assets/app_icon.png" /> <img src="core/src/main/assets/app_icon.webp" width="128" height="128" />
</div> </div>
## 特性 ## 特性

View File

@ -1,25 +1,25 @@
<!-- Parent: ../AGENTS.md --> <!-- Parent: ../AGENTS.md -->
<!-- Generated: 2026-05-22 | Updated: 2026-05-22 --> <!-- Generated: 2026-05-22 | Updated: 2026-06-15 -->
# assets # assets
## Purpose ## Purpose
原始资产文件目录,存放不需要 Android 资源系统处理的二进制文件。当前包含 GIF 动画资源 `:app` 模块原始资产文件目录。当前为空2026-06 清理后)
## Key Files ## Key Files
顶层文件
## Subdirectories ## Subdirectories
| Directory | Purpose | 无(原 `gifs/` 子目录的镜像说明已删除 —— 实际 UI/WebP 资源只在 `:core`
|-----------|---------|
| `gifs/` | GIF 动画资源(见 `gifs/AGENTS.md` |
## For AI Agents ## For AI Agents
### Working In This Directory ### Working In This Directory
- 新增原始资源文件直接放入此目录或其子目录 - 历史上此目录曾放 `app_icon.png`/`app_icon_original.png` 作图标源,因无代码引用已于 2026-06 删除
- 通过 `AssetManager` 在运行时访问 - 应用内图标用 `core/src/main/assets/app_icon.webp``Platform.kt`
- 启动器图标用 `app/src/main/res/mipmap-*/`(含 Adaptive Icon
- **不要再把图标源 PNG 放这里**:会被打进 APK。原图 `app_icon_original.png` (2048px) 保留在 git 历史commit `a36f6c4`),重新生成 foreground 时用 `git show a36f6c4:app/src/main/assets/app_icon_original.png` 恢复,生成脚本见 `docs/superpowers/plans/2026-06-15-image-management-optimization.md` Task 5
<!-- MANUAL: --> <!-- MANUAL: -->

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 457 KiB

View File

@ -1,33 +0,0 @@
<!-- Parent: ../AGENTS.md -->
<!-- Generated: 2026-05-22 | Updated: 2026-05-22 -->
# gifs
## Purpose
GIF 动画资源目录,存放应用使用的动画 GIF 文件001.gif ~ 152.gif`AnimatedGif` Composable 组件通过 `sketch` 库加载显示。
## Key Files
| File | Description |
|------|-------------|
| `001.gif` ~ `152.gif` | 应用动画 GIF 资源 |
## Subdirectories
## For AI Agents
### Working In This Directory
- 替换或新增 GIF 时保持连续编号
- GIF 文件较大,注意 APK 体积影响
- `AnimatedGif` 组件使用 `sketch` 库异步加载和播放
## Dependencies
### Internal
- `core/src/main/kotlin/plus/rua/project/ui/AnimatedGif.kt` — GIF 显示组件
### External
- `sketch` 4.4.0GIF 解码和播放)
<!-- MANUAL: -->

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Adaptive Icon 背景: 纯色块, 取自原图四角采样 RGB(131,208,241) -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#83D0F1"
android:pathData="M0,0h108v108h-108z" />
</vector>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Adaptive Icon 前景: 引用 mipmap 中密度分桶的 foreground 位图,
避免矢量化位图主体的质量损失。
-->
<mipmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@mipmap/ic_launcher_foreground" />

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Adaptive Icon (API 26+): 系统按 OEM 启动器形状自动裁切背景+前景。
monochrome 让 Android 13+ 主题化图标生效。
-->
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Adaptive Icon 圆形版 (API 26+), 内容与 ic_launcher.xml 一致 -->
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -12,6 +12,21 @@ android {
defaultConfig { defaultConfig {
minSdk = libs.versions.android.minSdk.get().toInt() minSdk = libs.versions.android.minSdk.get().toInt()
consumerProguardFiles("proguard-rules.pro") consumerProguardFiles("proguard-rules.pro")
// 构建期扫描 assets/animations/ 生成 WebP 文件列表,避免运行期硬编码 (1..152)
// 与 assets/ 目录耦合却不校验,导致增删文件后隐性 bug
val webpFiles = layout.projectDirectory
.dir("src/main/assets/animations")
.asFile
.listFiles { f -> f.extension.equals("webp", ignoreCase = true) }
?.map { it.name }
?.sorted()
?: emptyList()
require(webpFiles.isNotEmpty()) { "assets/animations/ 不应为空,请检查目录" }
// 拼成 Java 数组字面量: new String[]{"001.webp","002.webp",...}
val quoted = webpFiles.joinToString(",") { name -> "\"$name\"" }
val arrayLiteral = "new String[]{$quoted}"
buildConfigField("String[]", "WEBP_FILES", arrayLiteral)
} }
buildTypes { buildTypes {

View File

@ -1,25 +1,28 @@
<!-- Parent: ../AGENTS.md --> <!-- Parent: ../AGENTS.md -->
<!-- Generated: 2026-05-22 | Updated: 2026-05-22 --> <!-- Generated: 2026-05-22 | Updated: 2026-06-15 -->
# assets # assets
## Purpose ## Purpose
核心模块原始资产文件目录,`app/src/main/assets/` 镜像,包含 GIF 动画资源供 `AnimatedGif` Composable 组件加载 核心模块原始资产文件目录,通过 `AssetManager` 在运行时访问。包含应用内图标和动画 WebP 资源
## Key Files ## Key Files
无顶层文件 | File | Description |
|------|-------------|
| `app_icon.webp` | 应用内展示用的图标(`Platform.kt``getAppIconUri()` 引用) |
## Subdirectories ## Subdirectories
| Directory | Purpose | | Directory | Purpose |
|-----------|---------| |-----------|---------|
| `gifs/` | GIF 动画资源(见 `gifs/AGENTS.md` | | `animations/` | 动画 WebP 资源(见 `animations/AGENTS.md` |
## For AI Agents ## For AI Agents
### Working In This Directory ### Working In This Directory
- 此目录与 `app/src/main/assets/` 内容同步 - 新增原始资源文件直接放入此目录或其子目录
- 通过 `AssetManager` 在运行时访问 - **不与 `app/src/main/assets/` 镜像**:启动器图标在 `:app`UI/WebP 资源在 `:core`
- 通过 `file:///android_asset/<path>` URI 在运行时访问
<!-- MANUAL: --> <!-- MANUAL: -->

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

View File

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 46 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 9.8 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 43 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View File

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 41 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

View File

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

View File

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

View File

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 75 KiB

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 69 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View File

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 45 KiB

View File

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Some files were not shown because too many files have changed in this diff Show More