Files
EAP_Interface_html/设置页面UI优化/语言设置/implementation_plan.md
T
2026-08-17 14:51:41 +08:00

89 lines
4.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 语言设置页面 — 原生落地图纸 implementation_plan
- **模块**:系统设置 — 语言设置 (`LanguageSettingsActivity`)
- **依据**:同目录 `baseline_ui.html` + `DESIGN_SPEC.md`
- **原始出厂截图**:`./Screenshot_20260812_143341.png`
- **执行角色**:`@coder` (Android 工程师)
---
## 1. CSS → Android Token 映射字典
### 1.1 颜色语义映射
| HTML CSS 变量 | 取值 | Android 语义 Token / 资源 ID | 状态 / 说明 |
| :--- | :--- | :--- | :--- |
| `--color-primary` | `#3949AB` | `?attr/colorPrimary` (`@color/color_primary`) | ✅ 已存在 |
| `--color-on-primary` | `#FFFFFF` | `?attr/colorOnPrimary` | ✅ 已存在 |
| `--color-primary-container` | `#EEF2FF` | `?attr/colorPrimaryContainer` (`@color/color_primary_container`) | ✅ 已存在,选中行底色 |
| `--color-on-primary-container` | `#1A237E` | `?attr/colorOnPrimaryContainer` | ✅ 已存在,选中行主文本 |
| `--color-surface` | `#FFFFFF` | `?attr/colorSurface` (`@color/color_surface`) | ✅ 已存在,卡片背景色 |
| `--color-surface-variant` | `#F8FAFC` | `?attr/colorSurfaceVariant` | ✅ 已存在,左侧底色 |
| `--color-background` | `#F1F5F9` | `?attr/colorBackground` (`@color/color_background`) | ✅ 已存在,页面背景 |
| `--text-primary` | `#0F172A` | `@color/text_primary` | ✅ 已存在,未选中文字 |
| `--text-secondary` | `#64748B` | `@color/text_secondary` | ✅ 已存在,说明副文本 |
| `--divider` | `#E2E8F0` | `@color/divider` | ✅ 已存在,分割线 |
| `--outline` | `#CBD5E1` | `@color/outline` | ✅ 已存在,单选空心圈 |
### 1.2 尺寸与间距 Token 映射
| HTML CSS 变量 | 取值 | Android 推荐 Token | 规范落地建议 |
| :--- | :--- | :--- | :--- |
| `--content-max-width` | 920px | `@dimen/content_max_width_split` (920dp) | 宽屏双栏内容容器上限 |
| `--sidebar-width` | 280px | `@dimen/settings_sidebar_width` (280dp) | 左侧状态面板固定宽度 |
| `--appbar-height` | 60px | `@dimen/appbar_height` (60dp 或复用 56dp) | Toolbar 高度 |
| `--row-height` | 54px | `@dimen/settings_row_height` (54dp) | 语言单行高度 |
| `--corner-md` | 12px | `@dimen/corner_radius_md` (12dp) | 内部组件与徽章圆角 |
| `--corner-lg` | 16px | `@dimen/corner_radius_lg` (16dp) | 外层卡片大圆角 |
| `--spacing-md` | 16px | `@dimen/spacing_md` (16dp) | 元素间距 |
| `--spacing-lg` | 24px | `@dimen/spacing_xl` (24dp) | 双栏间距与安全衬距 |
---
## 2. Android 落地代码清单与改动指南
### 2.1 涉及文件
1. **布局文件 (Layout)**
- `app/src/main/res/layout/activity_language_settings.xml`
2. **逻辑类 (Activity / Adapter)**
- `app/src/main/java/com/umilab/eapmanage/team/ui/settings/subsettings/language/LanguageSettingsActivity.java`
- `app/src/main/java/com/umilab/eapmanage/team/util/LanguageUtils.java`
3. **新增资源 (Drawable / Selector)**
- `app/src/main/res/drawable/selector_language_row_bg.xml` (选中行背景选择器)
- `app/src/main/res/drawable/shape_language_card_bg.xml` (16dp 圆角白色卡片背景)
---
### 2.2 具体实施步骤
#### 步骤 1:重构 `activity_language_settings.xml`
- 顶层由原本铺满的单列列表,重构为 **AppBar + 居中 920dp 水平双栏容器 (`LinearLayout horizontal`)**。
- 左侧增加 `summary-sidebar`(展示图标、标题“系统显示语言”、说明、及 `tv_current_selected_language` 状态卡片)。
- 右侧包裹 `MaterialCardView`(`cardCornerRadius="16dp"`、`cardElevation="2dp"`),内部纵向排布 9 个语言行。
#### 步骤 2:语言行条目优化
- 每个语言项 `row_language_*` 高度设为 `54dp`。
- 背景使用 `selector_language_row_bg.xml`:
```xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:drawable="@color/color_primary_container" />
<item android:state_pressed="true" android:drawable="?attr/colorControlHighlight" />
<item android:drawable="@android:color/transparent" />
</selector>
```
- 选中项高亮文字为 `?attr/colorOnPrimaryContainer`,并显示左侧 4dp 主色指示条。
#### 步骤 3:`LanguageSettingsActivity.java` 状态联动
- 用户点击右侧任一语言项时,执行原有的语言切换逻辑,并即时更新:
1. 当前被选行的 `setSelected(true)`,其余行 `setSelected(false)`;
2. 左侧 `tv_current_selected_language.setText(selectedLanguageName)`。
---
## 3. 验收核验标准
- [ ] 平板横屏下展示为居中双栏布局,无单列右侧过度空白现象。
- [ ] 9 个语种字段文案(`English`, `Français`, `中文`, `日本語`, `한국어`, `Español`, `Italiano`, `Ελληνικά`, `Português`)100% 保留无遗漏。
- [ ] 点击任一行,整行背景与 RadioButton 同步高亮,左侧当前语言状态同步更新。
- [ ] 无任何 XML 硬编码色值,全部引用 Token。