feat(infrared): add infrared control, learning, and virtual remote module (#9)
### 概述 / Summary 完整实现红外控制与学习模块(`:android:feature:infrared`),支持红外设备按键学习、实体发射、Room 本地持久化,以及空调 (AC) / 电视 (TV) 虚拟遥控器面板。 ### 核心变更 / Key Changes 1. **领域模型与用例 (`:domain`)**: - 实现按键学习流程:`LearnInfraredKey`、`ManageInfraredKey`、`InfraredKeyFactory`; - 增加虚拟遥控器模型与用例:`CreateVirtualRemote`、`LearnVirtualRemoteKey`、`SendVirtualRemoteAction`、`AcCodeGenerator` 与预置码库 `PresetCodeLibrary`。 2. **数据持久化与仓储 (`:android:feature:infrared`)**: - 引入 Room 数据库 `InfraredDatabase` 及 DAO,提供 `RoomInfraredKeyRepository` 与 `RoomVirtualRemoteRepository`; - 支持多配置隔离(`ProviderProfileId`)、按键状态管理(`LEARNING` / `READY` / `FAILED`)。 3. **UI 与 ViewModel (`:android:feature:infrared`)**: - `InfraredControlScreen`:红外学习与按键调试列表; - `RemotePanelScreen` / `AcRemotePanel` / `TvRemotePanel`:空调/电视专属可视化遥控面板; - `InfraredHubScreen`:红外中枢与多遥控器管理入口; - 在认证后导航栈中将 `DeviceListScreen` 的红外入口无缝对接到 `InfraredHubRoute`。 4. **测试与文档**: - 补齐用例、Fakes、Repository、ViewModel 以及 Compose UI 自动化测试; - 补充红外控制设计规范与真机硬件验收清单。 Reviewed-on: #9 Co-authored-by: mxhsnd <2049295946@qq.com> Co-authored-by: KremeCN <3265494849@qq.com>
This commit is contained in:
@@ -64,6 +64,7 @@ dependencies {
|
||||
implementation(project(":domain"))
|
||||
implementation(project(":android:core:designsystem"))
|
||||
implementation(project(":android:core:session"))
|
||||
implementation(project(":android:feature:infrared"))
|
||||
implementation(project(":absdk-bridge"))
|
||||
implementation(project(":runtime:simulation"))
|
||||
debugImplementation(project(":testing:fakes"))
|
||||
|
||||
@@ -11,9 +11,20 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.navigation.NavType
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import androidx.navigation.navArgument
|
||||
import com.flagship.abox.manager.designsystem.ABoxLoadingIndicator
|
||||
import com.flagship.abox.manager.designsystem.ABoxSurface
|
||||
import com.flagship.abox.manager.designsystem.ABoxTheme
|
||||
import com.flagship.abox.manager.domain.ProviderProfile
|
||||
import com.flagship.abox.manager.domain.Username
|
||||
import com.flagship.abox.manager.infrared.hub.InfraredHubRoute
|
||||
import com.flagship.abox.manager.infrared.panel.RemotePanelRoute
|
||||
import com.flagship.abox.manager.infrared.ui.InfraredControlRoute
|
||||
import com.flagship.abox.manager.ui.devicecontrollist.DeviceListScreen
|
||||
import com.flagship.abox.manager.ui.login.LoginRoute
|
||||
import com.flagship.abox.manager.ui.login.LoginViewModel
|
||||
import com.flagship.abox.manager.ui.provider.ProviderSelectionRoute
|
||||
@@ -57,18 +68,93 @@ fun ABoxManagerApp(
|
||||
onSwitchProvider = sessionActionsViewModel::switchProvider,
|
||||
viewModel = loginViewModel,
|
||||
)
|
||||
is AppSessionUiState.Authenticated -> MainAppShell(
|
||||
userName = state.username.value,
|
||||
providerName = state.profile.displayName,
|
||||
onLogout = sessionActionsViewModel::logout,
|
||||
is AppSessionUiState.Authenticated -> AuthenticatedNavHost(
|
||||
username = state.username,
|
||||
profile = state.profile,
|
||||
actionInProgress = actionState.inProgress,
|
||||
errorMessage = actionState.errorMessage,
|
||||
onLogout = sessionActionsViewModel::logout,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AuthenticatedNavHost(
|
||||
username: Username,
|
||||
profile: ProviderProfile,
|
||||
actionInProgress: Boolean,
|
||||
errorMessage: String?,
|
||||
onLogout: () -> Unit,
|
||||
) {
|
||||
val navController = rememberNavController()
|
||||
NavHost(
|
||||
navController = navController,
|
||||
startDestination = "home",
|
||||
) {
|
||||
composable("home") {
|
||||
MainAppShell(
|
||||
userName = username.value,
|
||||
providerName = profile.displayName,
|
||||
onLogout = onLogout,
|
||||
actionInProgress = actionInProgress,
|
||||
errorMessage = errorMessage,
|
||||
devicesSlot = {
|
||||
val encodedProfileId = android.net.Uri.encode(profile.id.value)
|
||||
DeviceListScreen(
|
||||
onInfraredClick = {
|
||||
navController.navigate("infrared_hub/$encodedProfileId")
|
||||
},
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
composable(
|
||||
route = "infrared_hub/{profileId}",
|
||||
arguments = listOf(
|
||||
navArgument("profileId") { type = NavType.StringType },
|
||||
),
|
||||
) {
|
||||
val encodedProfileId = android.net.Uri.encode(profile.id.value)
|
||||
InfraredHubRoute(
|
||||
onBack = { navController.popBackStack() },
|
||||
onOpenRemote = { remoteId ->
|
||||
val encodedRemoteId = android.net.Uri.encode(remoteId)
|
||||
navController.navigate("infrared_panel/$encodedProfileId/$encodedRemoteId")
|
||||
},
|
||||
onOpenSettings = {
|
||||
navController.navigate("infrared_settings/$encodedProfileId")
|
||||
},
|
||||
onSessionInvalid = onLogout,
|
||||
)
|
||||
}
|
||||
composable(
|
||||
route = "infrared_panel/{profileId}/{remoteId}",
|
||||
arguments = listOf(
|
||||
navArgument("profileId") { type = NavType.StringType },
|
||||
navArgument("remoteId") { type = NavType.StringType },
|
||||
),
|
||||
) {
|
||||
RemotePanelRoute(
|
||||
onBack = { navController.popBackStack() },
|
||||
onSessionInvalid = onLogout,
|
||||
)
|
||||
}
|
||||
composable(
|
||||
route = "infrared_settings/{profileId}",
|
||||
arguments = listOf(
|
||||
navArgument("profileId") { type = NavType.StringType },
|
||||
),
|
||||
) {
|
||||
InfraredControlRoute(
|
||||
onBack = { navController.popBackStack() },
|
||||
onSessionInvalid = onLogout,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun AppSessionUiState.screenKey(): String = when (this) {
|
||||
AppSessionUiState.Loading -> "loading"
|
||||
AppSessionUiState.ProviderSelection -> "providers"
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
<string name="action_switch_provider">切换提供方</string>
|
||||
<string name="authenticated_title">已连接到 %1$s</string>
|
||||
<string name="authenticated_description">登录后入口已经就绪,设备导航将由对应模块负责人接入。</string>
|
||||
|
||||
<!-- 认证后壳层 -->
|
||||
<string name="tab_devices">设备</string>
|
||||
<string name="tab_scenes">情景</string>
|
||||
@@ -52,4 +51,6 @@
|
||||
<string name="device_temperature_humidity_description">进入温湿度状态相关功能。</string>
|
||||
<string name="device_infrared_title">红外控制器</string>
|
||||
<string name="device_infrared_description">进入红外控制器相关功能。</string>
|
||||
<string name="infrared_control_action">红外控制</string>
|
||||
<string name="infrared_session_invalid_message">ABox 会话未认证,请先登录。</string>
|
||||
</resources>
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
<string name="action_switch_provider">Switch provider</string>
|
||||
<string name="authenticated_title">Connected to %1$s</string>
|
||||
<string name="authenticated_description">The authenticated route is ready. Device navigation will be added by its module owner.</string>
|
||||
|
||||
<!-- Authenticated shell -->
|
||||
<string name="tab_devices">Devices</string>
|
||||
<string name="tab_scenes">Scenes</string>
|
||||
@@ -52,4 +51,6 @@
|
||||
<string name="device_temperature_humidity_description">View temperature and humidity status.</string>
|
||||
<string name="device_infrared_title">Infrared Controller</string>
|
||||
<string name="device_infrared_description">Access infrared controller features.</string>
|
||||
<string name="infrared_control_action">Infrared Control</string>
|
||||
<string name="infrared_session_invalid_message">ABox session is not authenticated. Please log in first.</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user