refactor(#78): extract UI strings for logs, system, model, and sessions/history screens
This commit is contained in:
1 parent
cdad31b555
commit
dcb23ba0a3
5 files changed
+92
-33
No files matched your search
@@ -18,11 +18,13 @@ import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.m57.hermescontrol.R
|
||||
import com.m57.hermescontrol.theme.LocalSpacing
|
||||
import com.m57.hermescontrol.ui.common.EmptyState
|
||||
import com.m57.hermescontrol.ui.common.ErrorState
|
||||
@@ -59,7 +61,7 @@ fun LogsScreen(
|
||||
}
|
||||
|
||||
HermesScaffold(
|
||||
title = { Text("Logs") },
|
||||
title = { Text(stringResource(R.string.screen_logs)) },
|
||||
onOpenDrawer = onOpenDrawer,
|
||||
isRefreshing = state.isLoading,
|
||||
onRefresh = { viewModel.loadLogs() },
|
||||
@@ -71,7 +73,7 @@ fun LogsScreen(
|
||||
|
||||
state.errorMessage != null -> {
|
||||
ErrorState(
|
||||
message = state.errorMessage ?: "Unknown error",
|
||||
message = state.errorMessage ?: stringResource(R.string.error_unknown),
|
||||
onRetry = { viewModel.loadLogs() },
|
||||
)
|
||||
}
|
||||
@@ -80,8 +82,8 @@ fun LogsScreen(
|
||||
// B5 (Jun 18 2026, kanban t_2322818d): proper empty-state using
|
||||
// the shared EmptyState component instead of a bare Text.
|
||||
EmptyState(
|
||||
title = "No logs available",
|
||||
subtitle = "Log output from Hermes will appear here.",
|
||||
title = stringResource(R.string.logs_empty_title),
|
||||
subtitle = stringResource(R.string.logs_empty_desc),
|
||||
icon = Icons.Filled.HistoryEdu,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -35,10 +35,12 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.m57.hermescontrol.R
|
||||
import com.m57.hermescontrol.ui.common.EmptyState
|
||||
import com.m57.hermescontrol.ui.common.ErrorState
|
||||
import com.m57.hermescontrol.ui.common.HermesScaffold
|
||||
@@ -67,7 +69,7 @@ fun ModelScreen(
|
||||
}
|
||||
|
||||
HermesScaffold(
|
||||
title = { Text("Models") },
|
||||
title = { Text(stringResource(R.string.screen_models)) },
|
||||
onOpenDrawer = onOpenDrawer,
|
||||
isRefreshing = state.isLoading,
|
||||
onRefresh = { viewModel.loadModelOptions() },
|
||||
@@ -87,10 +89,10 @@ fun ModelScreen(
|
||||
|
||||
state.providers.isEmpty() -> {
|
||||
EmptyState(
|
||||
title = "No model providers reported",
|
||||
subtitle = "Verify configuration or retry",
|
||||
title = stringResource(R.string.model_empty_title),
|
||||
subtitle = stringResource(R.string.model_empty_desc),
|
||||
onAction = { viewModel.loadModelOptions() },
|
||||
actionLabel = "Refresh",
|
||||
actionLabel = stringResource(R.string.content_desc_refresh),
|
||||
modifier = Modifier.padding(paddingValues),
|
||||
)
|
||||
}
|
||||
@@ -107,7 +109,10 @@ fun ModelScreen(
|
||||
Text(text = state.errorMessage ?: "", color = MaterialTheme.colorScheme.error)
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
IconButton(onClick = { viewModel.loadModelOptions() }) {
|
||||
Icon(imageVector = Icons.Filled.Refresh, contentDescription = "Retry")
|
||||
Icon(
|
||||
imageVector = Icons.Filled.Refresh,
|
||||
contentDescription = stringResource(R.string.action_retry),
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -153,7 +158,7 @@ fun ModelScreen(
|
||||
fontWeight = FontWeight.Bold,
|
||||
)
|
||||
Text(
|
||||
text = "Slug: ${provider.slug}",
|
||||
text = stringResource(R.string.model_label_slug, provider.slug),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
@@ -161,7 +166,7 @@ fun ModelScreen(
|
||||
|
||||
if (isCurrent) {
|
||||
Text(
|
||||
text = "CURRENT",
|
||||
text = stringResource(R.string.model_status_current),
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
fontWeight = FontWeight.Bold,
|
||||
@@ -183,7 +188,7 @@ fun ModelScreen(
|
||||
AnimatedVisibility(visible = isExpanded) {
|
||||
Column(modifier = Modifier.padding(top = 16.dp)) {
|
||||
Text(
|
||||
text = "Available Models:",
|
||||
text = stringResource(R.string.model_label_available),
|
||||
style = MaterialTheme.typography.titleSmall,
|
||||
fontWeight = FontWeight.SemiBold,
|
||||
modifier = Modifier.padding(bottom = 8.dp),
|
||||
@@ -192,7 +197,7 @@ fun ModelScreen(
|
||||
val models = provider.models.orEmpty()
|
||||
if (models.isEmpty()) {
|
||||
Text(
|
||||
text = "No models reported or provider needs authentication.",
|
||||
text = stringResource(R.string.model_no_models),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
@@ -262,7 +267,10 @@ fun ModelScreen(
|
||||
if (isActive) {
|
||||
Icon(
|
||||
imageVector = Icons.Filled.Check,
|
||||
contentDescription = "Active Model",
|
||||
contentDescription =
|
||||
stringResource(
|
||||
R.string.content_desc_active_model,
|
||||
),
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -21,11 +21,13 @@ import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.m57.hermescontrol.ChatScreen
|
||||
import com.m57.hermescontrol.NavigationController
|
||||
import com.m57.hermescontrol.R
|
||||
import com.m57.hermescontrol.theme.LocalSpacing
|
||||
import com.m57.hermescontrol.ui.common.EmptyState
|
||||
import com.m57.hermescontrol.ui.common.ErrorState
|
||||
@@ -48,7 +50,7 @@ fun SessionsScreen(
|
||||
}
|
||||
|
||||
HermesScaffold(
|
||||
title = { Text("History") },
|
||||
title = { Text(stringResource(R.string.screen_history)) },
|
||||
onOpenDrawer = onOpenDrawer,
|
||||
isRefreshing = state.isLoading,
|
||||
onRefresh = { viewModel.loadSessions() },
|
||||
@@ -61,15 +63,15 @@ fun SessionsScreen(
|
||||
|
||||
state.errorMessage != null -> {
|
||||
ErrorState(
|
||||
message = state.errorMessage ?: "Unknown error",
|
||||
message = state.errorMessage ?: stringResource(R.string.error_unknown),
|
||||
onRetry = { viewModel.loadSessions() },
|
||||
)
|
||||
}
|
||||
|
||||
state.sessions.isEmpty() -> {
|
||||
EmptyState(
|
||||
title = "No history",
|
||||
subtitle = "Previous chat sessions from Hermes will appear here.",
|
||||
title = stringResource(R.string.history_empty_title),
|
||||
subtitle = stringResource(R.string.history_empty_desc),
|
||||
icon = Icons.Filled.History,
|
||||
)
|
||||
}
|
||||
@@ -98,7 +100,7 @@ fun SessionsScreen(
|
||||
modifier = Modifier.padding(spacing.md),
|
||||
) {
|
||||
Text(
|
||||
text = session.title ?: "Untitled",
|
||||
text = session.title ?: stringResource(R.string.history_untitled),
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
fontWeight = FontWeight.Bold,
|
||||
)
|
||||
@@ -107,7 +109,11 @@ fun SessionsScreen(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Text(
|
||||
text = "${session.message_count ?: 0} messages",
|
||||
text =
|
||||
stringResource(
|
||||
R.string.history_message_count,
|
||||
session.message_count ?: 0,
|
||||
),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
|
||||
@@ -27,8 +27,10 @@ import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.m57.hermescontrol.R
|
||||
import com.m57.hermescontrol.theme.LocalHermesStatusColors
|
||||
import com.m57.hermescontrol.theme.LocalSpacing
|
||||
import com.m57.hermescontrol.ui.common.EmptyState
|
||||
@@ -65,7 +67,7 @@ fun SystemScreen(
|
||||
}
|
||||
|
||||
HermesScaffold(
|
||||
title = { Text("System") },
|
||||
title = { Text(stringResource(R.string.screen_system)) },
|
||||
onOpenDrawer = onOpenDrawer,
|
||||
isRefreshing = state.isLoading,
|
||||
onRefresh = { viewModel.loadSystemData() },
|
||||
@@ -77,15 +79,15 @@ fun SystemScreen(
|
||||
|
||||
state.errorMessage != null -> {
|
||||
ErrorState(
|
||||
message = state.errorMessage ?: "Unknown error",
|
||||
message = state.errorMessage ?: stringResource(R.string.error_unknown),
|
||||
onRetry = { viewModel.loadSystemData() },
|
||||
)
|
||||
}
|
||||
|
||||
state.stats == null && state.doctorReport == null -> {
|
||||
EmptyState(
|
||||
title = "No system data",
|
||||
subtitle = "Tap refresh to load system diagnostics.",
|
||||
title = stringResource(R.string.system_empty_title),
|
||||
subtitle = stringResource(R.string.system_empty_desc),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -102,7 +104,7 @@ fun SystemScreen(
|
||||
// Stats row
|
||||
state.stats?.let { stats ->
|
||||
item {
|
||||
SectionHeader(title = "Performance")
|
||||
SectionHeader(title = stringResource(R.string.system_sec_performance))
|
||||
}
|
||||
item {
|
||||
FlowRow(
|
||||
@@ -111,7 +113,7 @@ fun SystemScreen(
|
||||
) {
|
||||
stats.cpuPercent?.let { cpu ->
|
||||
StatCard(
|
||||
label = "CPU Usage",
|
||||
label = stringResource(R.string.system_metric_cpu),
|
||||
value = "$cpu%",
|
||||
icon = Icons.Filled.Speed,
|
||||
modifier = Modifier.weight(1f),
|
||||
@@ -119,7 +121,7 @@ fun SystemScreen(
|
||||
}
|
||||
stats.memoryPercent?.let { mem ->
|
||||
StatCard(
|
||||
label = "Memory",
|
||||
label = stringResource(R.string.system_metric_memory),
|
||||
value = "$mem%",
|
||||
icon = Icons.Filled.Memory,
|
||||
modifier = Modifier.weight(1f),
|
||||
@@ -132,7 +134,7 @@ fun SystemScreen(
|
||||
// Doctor diagnostics
|
||||
state.doctorReport?.let { report ->
|
||||
item {
|
||||
SectionHeader(title = "Doctor")
|
||||
SectionHeader(title = stringResource(R.string.system_sec_doctor))
|
||||
}
|
||||
item {
|
||||
Card(
|
||||
@@ -158,7 +160,12 @@ fun SystemScreen(
|
||||
},
|
||||
)
|
||||
StatusBadge(
|
||||
text = if (report.ok) "Running" else "Failed",
|
||||
text =
|
||||
if (report.ok) {
|
||||
stringResource(R.string.system_status_running)
|
||||
} else {
|
||||
stringResource(R.string.system_status_failed)
|
||||
},
|
||||
status =
|
||||
if (report.ok) {
|
||||
StatusBadgeType.SUCCESS
|
||||
@@ -169,10 +176,13 @@ fun SystemScreen(
|
||||
}
|
||||
Spacer(modifier = Modifier.height(spacing.sm))
|
||||
report.pid?.let { pid ->
|
||||
InfoRow(label = "Process PID", value = pid.toString())
|
||||
InfoRow(
|
||||
label = stringResource(R.string.system_info_pid),
|
||||
value = pid.toString(),
|
||||
)
|
||||
}
|
||||
report.name?.let { name ->
|
||||
InfoRow(label = "Process Name", value = name)
|
||||
InfoRow(label = stringResource(R.string.system_info_proc_name), value = name)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,7 +191,7 @@ fun SystemScreen(
|
||||
|
||||
// Admin actions
|
||||
item {
|
||||
SectionHeader(title = "Administration")
|
||||
SectionHeader(title = stringResource(R.string.system_sec_admin))
|
||||
}
|
||||
item {
|
||||
Card(
|
||||
@@ -201,7 +211,7 @@ fun SystemScreen(
|
||||
contentDescription = null,
|
||||
modifier = Modifier.padding(end = spacing.xs),
|
||||
)
|
||||
Text("Trigger System Backup")
|
||||
Text(stringResource(R.string.system_action_backup))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,4 +195,37 @@
|
||||
<string name="action_discard">Discard</string>
|
||||
<string name="content_desc_edit_skill">Edit Skill File</string>
|
||||
<string name="content_desc_save_changes">Save Changes</string>
|
||||
|
||||
<!-- Logs Screen -->
|
||||
<string name="logs_empty_title">No logs available</string>
|
||||
<string name="logs_empty_desc">Log output from Hermes will appear here.</string>
|
||||
|
||||
<!-- System Screen -->
|
||||
<string name="system_empty_title">No system data</string>
|
||||
<string name="system_empty_desc">Tap refresh to load system diagnostics.</string>
|
||||
<string name="system_sec_performance">Performance</string>
|
||||
<string name="system_metric_cpu">CPU Usage</string>
|
||||
<string name="system_metric_memory">Memory</string>
|
||||
<string name="system_sec_doctor">Doctor</string>
|
||||
<string name="system_status_running">Running</string>
|
||||
<string name="system_status_failed">Failed</string>
|
||||
<string name="system_info_pid">Process PID</string>
|
||||
<string name="system_info_proc_name">Process Name</string>
|
||||
<string name="system_sec_admin">Administration</string>
|
||||
<string name="system_action_backup">Trigger System Backup</string>
|
||||
|
||||
<!-- Model Screen -->
|
||||
<string name="model_empty_title">No model providers reported</string>
|
||||
<string name="model_empty_desc">Verify configuration or retry</string>
|
||||
<string name="model_label_slug">Slug: %1$s</string>
|
||||
<string name="model_status_current">CURRENT</string>
|
||||
<string name="model_label_available">Available Models:</string>
|
||||
<string name="model_no_models">No models reported or provider needs authentication.</string>
|
||||
<string name="content_desc_active_model">Active Model</string>
|
||||
|
||||
<!-- Sessions (History) Screen -->
|
||||
<string name="history_empty_title">No history</string>
|
||||
<string name="history_empty_desc">Previous chat sessions from Hermes will appear here.</string>
|
||||
<string name="history_untitled">Untitled</string>
|
||||
<string name="history_message_count">%1$d messages</string>
|
||||
</resources>
|
||||
Reference in new issue
Block a user