Feat: 支持 MiotLayout & 窗帘#61
Merged
Merged
Conversation
- **WidgetProcessor**:
- 引入构造函数映射 (`CONSTRUCTOR_MAP_TYPE`),支持通过反射调用构造函数。
- 在生成的注册表中新增 `create` 方法,支持通过 `Pair` 或 `service`/`type` 字符串动态创建 `MiwuWidget` 实例。
- **DeviceProcessor**:
- 将注册表中的 `Class` 替换为 `KClass` 以符合 Kotlin 习惯。
- **SpecProcessor**:
- 优化常量生成逻辑,将所有 Spec 类型集中在 `MiotSpec` 对象下,减少顶层文件数量。
- **MockProcessor**:
- 调整 Mock 注册逻辑,改为基于设备 `model` 名称映射到 Mock 客户端类。
- 完善 `createMockClient` 方法,提供默认的 `DefaultMockMiotDeviceClient` 回退机制。
- 更新相关包路径(如 `miwu.support.mock`)。
- **MiwuProcessor**:
- 在基类中提取 `MiwuDevice` 和 `MiwuWidget` 的公共 `ClassName` 定义。
- **架构重构与包路径优化**
- 将 `MiwuWidget`, `MiwuDevice`, `MiwuWrapper` 等核心基类从 `miwu.support.base` 迁移至 `miwu.support`。
- 将 `MiwuLayout` 重命名为 `MiwuWidgetLayout` 以更准确描述其用途。
- 清理并删除冗余类 `MiwuPanel` 与 `CurtainLayout` (迁移至新路径)。
- **增强 `MiwuWidget` 与 `MiwuWrapper` 功能**
- 引入 `piidList` 和 `aiidList` 用于支持多属性/多动作监听。
- 重命名 `register` 为 `registerProperty` 和 `registerAction`,并支持回调中传递 `SpecProperty` 和 `SpecAction` 对象。
- 优化 `BaseMiwuWidget` 中的服务、属性和动作查找逻辑,使用 `name` 替代 `type` 进行匹配。
- **引入 Mock 设备模拟系统**
- 新增 `MockMiotDeviceClient` 及其配套体系,支持在测试环境下模拟设备行为。
- 在 `MiotDeviceManager` 中集成 `MockRegistry`,支持通过特定的 `MOCK_PREFIX` 前缀加载模拟设备。
- 为 `Curtain` 设备添加 `CurtainMockClient` 实现。
- **优化 `MiotDeviceManagerImpl` 逻辑**
- 改进属性刷新与更新机制,支持批量处理 `piidList` 中的属性。
- 增强 Action 执行后的回调分发逻辑。
- 完善缓存 key 的使用,统一采用 `deviceSpecType`。
- **其他变更**
- 规范化多个设备类(如 `Curtain`, `Fan`, `Light` 等)的继承关系。
- 补充并完善 KDoc 文档注释。
- **新增 `MiotWidgetListButtonBinding` 扩展**:提取通用的 `icon`、`title`、`onClick` 和 `updateState` 逻辑以简化代码。
- **重构 `CurtainLayoutWrapper`**:
- 实现窗帘状态(Opening/Closing/Stop)的监听与维护。
- 改进 UI 交互逻辑:点击相同状态按钮时触发“暂停”指令。
- 更新导入路径并适配新的 `MiotSpec` 常量。
- **优化 `ViewMiwuWrapper`**:将 `setIcon` 移至 `companion object` 供全局扩展使用,并统一 `MiwuWrapper` 的继承路径。
- **修复与重构 `VacuumButtonWrapper`**:适配新的 `registerProperty` 回调接口,并使用统一的 `updateState` 管理按钮背景。
- **依赖迁移**:将所有 `miwu.support.base.MiwuWidget` 引用迁移至 `miwu.support.MiwuWidget`。
- **其他调整**:将 `miot_layout_wrapper.xml` 的默认可见性设为 `visible`。
- 为 `Service`、`Action` 和 `Property` 类添加基于 `Urn` 解析的 `name` 属性。 - 为 `SpecAtt` 内部类定义类型别名:`SpecService`、`SpecAction` 和 `SpecProperty`。 - 在 `Property` 类中新增 `firstValueOrNull` 扩展方法,支持根据描述查找值。 - 清理了 `SpecAtt.kt` 中冗余的导入语句。
- 更新 `MiwuWidget`、`MiwuWrapper` 及相关 Registry 的包路径。 - 将 Mock 相关类迁移至 `miwu.support.mock` 包。 - 简化 `DeviceViewModel` 逻辑:移除手动处理 `MOCK_PREFIX` 的代码,统一由 `MiotDeviceManager` 内部处理。 - 清理 `EditFavoriteActivity` 中未使用的导入。
- 新增 `WidgetLoader` 类,负责从 `SpecAtt` 中发现、创建、配置 widgets 并将其分配到布局。 - 迁移 widget 解析、实例化及配置逻辑(包括 `ValueList` 处理和位置注解匹配)至 `WidgetLoader`。 - 简化 `MiotDeviceManagerImpl`,将 widget 加载职责委托给 `WidgetLoader`。 - 为 `MiotDeviceManagerImpl` 及其关键方法补充了详细的 KDoc 注释。 - 优化了设备初始化、属性轮询及资源回收的内部交互流程。
- **改进 KSP 处理器**:
- 将 `WrapperProcessor` 的映射逻辑从 `Map<ClassName, ClassName>` 改为包含泛型参数信息的 `List<WrapperInfo>`。
- 新增 `extractWidgetTypeArg` 用于从构造函数中提取 `MiwuWidget<T>` 的泛型参数 `T`。
- 更新 `WrapperRegistry` 生成逻辑,新增 `constructor` 映射表。
- `WrapperRegistry` 现在通过 `Function2` lambda 表达式存储构造逻辑,避免运行时反射。
- **优化客户端调用**:
- 在 `DeviceActivity` 中使用新生成的 `WrapperRegistry.create` 方法替代原有的反射构造逻辑。
- **清理代码**:
- 移除不必要的 `SymbolProcessor` 别名与遗留的注解提取扩展函数。
- 增强错误日志输出,包含堆栈信息。
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.