feat(socket): update smart socket defaults (#12)
## Summary - change the default socket device name from Zigbee插座控制器 to 智能插座 - update new default scenes, in-memory defaults, and Local Experience simulation data to use the new gateway name - remove the duplicated Direct control section from the smart socket detail screen, keeping the main power control - remove the unused direct-control strings ## Data behavior - existing configured devices are not renamed - existing persisted scenes are not migrated - only newly created default content uses 智能插座 ## Verification - ./gradlew.bat :android:app:assembleDebug --no-daemon - installed on mulator-5554 - confirmed the Local Experience device card shows 智能插座 - confirmed the socket detail screen has no Direct control section or duplicate ON/OFF buttons Automated tests were not run. Reviewed-on: #12 Co-authored-by: KremeCN <3265494849@qq.com>
This commit was merged in pull request #12.
This commit is contained in:
+1
-1
@@ -49,7 +49,7 @@ class ABoxDefaultContentInitializer @Inject constructor(
|
||||
is DomainResult.Failure -> return false
|
||||
}
|
||||
val defaults = listOf(
|
||||
DeviceName("Zigbee插座控制器") to DeviceType.SOCKET,
|
||||
DeviceName("智能插座") to DeviceType.SOCKET,
|
||||
DeviceName("温湿度传感器") to DeviceType.TEMPERATURE_HUMIDITY,
|
||||
DeviceName("红外控制器") to DeviceType.INFRARED,
|
||||
)
|
||||
|
||||
@@ -13,7 +13,6 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
@@ -24,7 +23,6 @@ import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Text
|
||||
@@ -208,42 +206,11 @@ fun SocketScreen(
|
||||
}
|
||||
}
|
||||
|
||||
Text(
|
||||
text = stringResource(R.string.socket_direct_control),
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
modifier = Modifier.fillMaxWidth().padding(bottom = 10.dp),
|
||||
)
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
) {
|
||||
OutlinedButton(
|
||||
onClick = { onEvent(SocketUiEvent.SetPower(SocketPowerState.ON)) },
|
||||
enabled = state.isActionEnabled && state.powerState != SocketPowerState.ON,
|
||||
modifier = Modifier.weight(1f).height(56.dp),
|
||||
) {
|
||||
ABoxIcon(ABoxIconKey.POWER, "开启插座", modifier = Modifier.size(20.dp))
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text(stringResource(R.string.socket_action_turn_on))
|
||||
}
|
||||
|
||||
OutlinedButton(
|
||||
onClick = { onEvent(SocketUiEvent.SetPower(SocketPowerState.OFF)) },
|
||||
enabled = state.isActionEnabled && state.powerState != SocketPowerState.OFF,
|
||||
modifier = Modifier.weight(1f).height(56.dp),
|
||||
) {
|
||||
ABoxIcon(ABoxIconKey.POWER, "关闭插座", modifier = Modifier.size(20.dp))
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text(stringResource(R.string.socket_action_turn_off))
|
||||
}
|
||||
}
|
||||
|
||||
Text(
|
||||
text = stringResource(R.string.socket_confirmation_hint),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier.fillMaxWidth().padding(top = 14.dp),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,8 +223,6 @@
|
||||
<string name="socket_status_offline">已离线</string>
|
||||
<string name="socket_status_unknown">未知状态</string>
|
||||
<string name="socket_action_toggle">切换电源</string>
|
||||
<string name="socket_action_turn_on">开启插座</string>
|
||||
<string name="socket_action_turn_off">关闭插座</string>
|
||||
<string name="socket_operating_label">正在切换状态…</string>
|
||||
<string name="socket_confirmed_at">已于 %1$s 确认状态</string>
|
||||
|
||||
@@ -361,7 +359,6 @@
|
||||
<string name="gateway_device_name_socket_desc">用于匹配和控制网关设备,必须与网关中的名称完全一致。</string>
|
||||
<string name="gateway_device_name_sensor_desc">用于匹配和读取网关设备,必须与网关中的名称完全一致。</string>
|
||||
<string name="action_save_device_name">保存设备名称</string>
|
||||
<string name="socket_direct_control">直接控制</string>
|
||||
<string name="socket_confirmation_hint">指令只有在网关回读到结果状态后才会确认。等待确认时可使用刷新操作。</string>
|
||||
<string name="sensor_current_readings">当前读数</string>
|
||||
<string name="sensor_monitoring_title">实时环境监控</string>
|
||||
|
||||
@@ -223,8 +223,6 @@
|
||||
<string name="socket_status_offline">Offline</string>
|
||||
<string name="socket_status_unknown">Unknown</string>
|
||||
<string name="socket_action_toggle">Toggle Power</string>
|
||||
<string name="socket_action_turn_on">Turn ON</string>
|
||||
<string name="socket_action_turn_off">Turn OFF</string>
|
||||
<string name="socket_operating_label">Updating socket state…</string>
|
||||
<string name="socket_confirmed_at">Confirmed at %1$s</string>
|
||||
|
||||
@@ -361,7 +359,6 @@
|
||||
<string name="gateway_device_name_socket_desc">Used to match and control the gateway device. It must exactly match the gateway name.</string>
|
||||
<string name="gateway_device_name_sensor_desc">Used to match and read the gateway device. It must exactly match the gateway name.</string>
|
||||
<string name="action_save_device_name">Save device name</string>
|
||||
<string name="socket_direct_control">Direct control</string>
|
||||
<string name="socket_confirmation_hint">A command is confirmed only after the gateway reports the resulting state. Refresh while confirmation is pending.</string>
|
||||
<string name="sensor_current_readings">Current readings</string>
|
||||
<string name="sensor_monitoring_title">Live environment monitoring</string>
|
||||
|
||||
+6
-6
@@ -99,14 +99,14 @@ class RoomSceneRepository(
|
||||
|
||||
private fun defaultScenes(profileId: ProviderProfileId): List<Scene> = listOf(
|
||||
Scene(
|
||||
SceneId("${profileId.value}:scene-arriving-home"), profileId, "回家模式", "开启 Zigbee 插座控制器",
|
||||
SceneId("${profileId.value}:scene-arriving-home"), profileId, "回家模式", "开启智能插座",
|
||||
AutomationType.MANUAL, true, SceneIcon.HOME, SceneColor("#4CAF50"),
|
||||
actions = listOf(SceneAction.SocketPower(SceneActionId("${profileId.value}:arrive:socket"), profileId, DeviceName("Zigbee插座控制器"), SocketPowerState.ON)),
|
||||
actions = listOf(SceneAction.SocketPower(SceneActionId("${profileId.value}:arrive:socket"), profileId, DeviceName("智能插座"), SocketPowerState.ON)),
|
||||
),
|
||||
Scene(
|
||||
SceneId("${profileId.value}:scene-leaving-home"), profileId, "离家模式", "关闭 Zigbee 插座控制器",
|
||||
SceneId("${profileId.value}:scene-leaving-home"), profileId, "离家模式", "关闭智能插座",
|
||||
AutomationType.MANUAL, true, SceneIcon.AWAY, SceneColor("#FF8A65"),
|
||||
actions = listOf(SceneAction.SocketPower(SceneActionId("${profileId.value}:leave:socket"), profileId, DeviceName("Zigbee插座控制器"), SocketPowerState.OFF)),
|
||||
actions = listOf(SceneAction.SocketPower(SceneActionId("${profileId.value}:leave:socket"), profileId, DeviceName("智能插座"), SocketPowerState.OFF)),
|
||||
),
|
||||
Scene(
|
||||
SceneId("${profileId.value}:scene-temperature-alert"), profileId, "高温提醒", "室温高于 28°C 时发送提醒",
|
||||
@@ -118,8 +118,8 @@ class RoomSceneRepository(
|
||||
SceneId("${profileId.value}:scene-cooling-auto"), profileId, "高温自动降温", "当室温高于 28°C 时开启插座",
|
||||
AutomationType.AUTOMATIC, true, SceneIcon.THERMOSTAT, SceneColor("#26A69A"),
|
||||
triggers = listOf(SceneTrigger.Temperature(SceneTriggerId("${profileId.value}:cooling-temp"), DeviceName("温湿度传感器"), ComparisonOperator.GREATER_THAN, 28.0, "温度高于 28°C")),
|
||||
conditions = listOf(SceneCondition.SocketPower(SceneConditionId("${profileId.value}:cooling-socket"), DeviceName("Zigbee插座控制器"), SocketPowerState.OFF)),
|
||||
actions = listOf(SceneAction.SocketPower(SceneActionId("${profileId.value}:cooling:on"), profileId, DeviceName("Zigbee插座控制器"), SocketPowerState.ON)),
|
||||
conditions = listOf(SceneCondition.SocketPower(SceneConditionId("${profileId.value}:cooling-socket"), DeviceName("智能插座"), SocketPowerState.OFF)),
|
||||
actions = listOf(SceneAction.SocketPower(SceneActionId("${profileId.value}:cooling:on"), profileId, DeviceName("智能插座"), SocketPowerState.ON)),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user