Feat: 支持 dehumidifier (除湿器)#65
Merged
Merged
Conversation
- **新增设备支持**:
- 新增 `Dehumidifier` (除湿机) 设备类,配置了 `ModeButton`、`FanController`、`SwitchBar` 等组件。
- 在 `GetSortedDevicesUseCase` 中添加了 NWT 智能除湿机的 Mock 数据,方便调试。
- **新增及优化 Widget**:
- 新增 `NumberValueController` 及其 Android 端 Wrapper 实现,用于统一处理温度、湿度等数值调节。
- 将 `AirConditioner` 中的温度控制器由 `DoubleValueController` 替换为 `NumberValueController`。
- 扩展 `SwitchBar`、`FanController`、`ModeButton` 和 `Text` 组件,支持 `dehumidifier` 及相关环境属性的绑定。
- **资源与国际化**:
- 新增 `ic_custom` 和 `ic_close` 矢量图标。
- 在 `icons.txt` 中新增多个图标映射规则(如 `Clothes Drying`、`Smart`、`Custom` 等)。
- 更新 `strings.xml` 和 `AndroidTranslateHelper`,增加“烘衣”与“智能”模式的翻译支持。
- **底层逻辑优化**:
- **MiwuWrapper**: 优化 `onActionCallback` 和 `onUpdateValue` 的匹配逻辑,改用 `Pair` 比较以提升准确性。
- **IconsProcessor**: 增强 `snake-case` 和 `kebab-case` 转换逻辑,支持处理带空格的字符串。
- **Extension**: 优化 JSON 解析逻辑,改用 `when` 表达式提高可读性。
- **重构布局区域注解**:
- 移除旧有的 `@SubHeader` 和 `@SubFooter` 注解。
- 引入更精确的 `@HeaderPanel`、`@ControlPanel` 和 `@FooterPanel` 注解。
- 更新 `MiwuWidgetLayout` 及其相关逻辑(如 `WidgetLoader` 和 `DeviceActivity`)以支持新的布局区域。
- **更新组件注解**:
- 将 `CurtainLayout`、`AirerLayout`、`NumberValueController` 等多个组件的注解从 `@SubHeader` 迁移至 `@ControlPanel`。
- 将 `SwitchBar` 的注解从 `@SubHeader` 迁移至 `@HeaderPanel`。
- **改进 IconsProcessor**:
- 在生成图标映射时,对 `name` 参数执行 `replace(" ", "")`,增强对包含空格名称的兼容性。
- **图标映射调整**:
- 在 `icons.txt` 中将 `Clothes Drying` 的映射目标从 `Hot` 修改为 `Heat`。
- **UI 布局更新**:
- 同步更新 `activity_device.xml` 中的 `LinearLayout` ID(如 `header_panel`、`control_panel`、`footer_panel`)以符合新的命名规范。
- **新增 Mock 设备配置**:
- 添加 `app/mock-devices.yaml`,支持通过配置文件定义 Mock 设备的名称、型号、`specType`、房间映射等信息。
- **新增 `MockDeviceListProcessor`**:
- 开发 KSP 处理器,用于解析 `mock-devices.yaml` 并自动生成 `GeneratedMockDevices` Kotlin 对象。
- 支持 YAML 解析逻辑,包括注释处理、引号脱钩及基础类型转换。
- 自动生成设备列表(`devices`)和房间映射(`rooms`)的代码块。
- **优化 `GetSortedDevicesUseCase`**:
- 集成生成的 `GeneratedMockDevices`,在 Debug 模式且开启 Mock 时自动加载设备。
- 改进设备获取与过滤逻辑,支持将 Mock 设备合并至真实设备列表或按房间进行过滤。
- 自动将 Mock 设备的图标和房间信息同步至 `CacheRepository`。
- **构建配置更新**:
- 在 `app/build.gradle.kts` 中配置 KSP 参数(`miwu.mock.enabled`, `miwu.mock.filePath`)。
- 将 `mock-devices.yaml` 设为 KSP 任务的输入文件,确保配置变更时能触发重新编译。
- 注册 `MockDeviceListProcessorProvider` 到 KSP 服务发现机制。
Feat: 引入基于 YAML 配置的 Mock 设备自动生成机制
- **ViewMiwuWrapper 优化**:
- 新增 `ic_default.xml` 矢量图标。
- 在 `ViewMiwuWrapper` 中,当图标类型为 `NoneIcon` 时,不再设置图片为空,而是显示默认的 `ic_default` 图标。
- **UI 与适配器改进**:
- **MainViewPagerAdapter**: 在构造函数中显式指定 `BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT`,以优化 Fragment 生命周期管理。
- **布局调整**: 在 `fragment_main_scene.xml` 的 `SmoothRecyclerView` 中添加 `<requestFocus />`,并微调了布局 XML 格式。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.