refactor: extract more hardcoded strings (#1814)

This commit is contained in:
James Rich 2025-05-01 19:05:32 -05:00 committed by GitHub
parent e9588c74b4
commit 9648d0af77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 33 additions and 22 deletions

View file

@ -439,7 +439,7 @@ private fun EditChannelUrl(
},
modifier = modifier.fillMaxWidth(),
enabled = enabled,
label = { Text("URL") },
label = { Text(stringResource(R.string.url)) },
isError = isError,
trailingIcon = {
val isUrlEqual = valueState == channelUrl

View file

@ -466,14 +466,14 @@ private fun EnvironmentMetrics(
if (hasTemperature()) {
InfoCard(
icon = Icons.Default.Thermostat,
text = "Temperature",
text = stringResource(R.string.temperature),
value = temperature.toTempString(isFahrenheit)
)
}
if (hasRelativeHumidity()) {
InfoCard(
icon = Icons.Default.WaterDrop,
text = "Humidity",
text = stringResource(R.string.humidity),
value = "%.0f%%".format(relativeHumidity)
)
}
@ -481,56 +481,56 @@ private fun EnvironmentMetrics(
val dewPoint = calculateDewPoint(temperature, relativeHumidity)
InfoCard(
icon = ImageVector.vectorResource(R.drawable.ic_outlined_dew_point_24),
text = "Dew Point",
text = stringResource(R.string.dew_point),
value = dewPoint.toTempString(isFahrenheit)
)
}
if (hasBarometricPressure()) {
InfoCard(
icon = Icons.Default.Speed,
text = "Pressure",
text = stringResource(R.string.pressure),
value = "%.0f hPa".format(barometricPressure)
)
}
if (hasGasResistance()) {
InfoCard(
icon = Icons.Default.BlurOn,
text = "Gas Resistance",
text = stringResource(R.string.gas_resistance),
value = "%.0f MΩ".format(gasResistance)
)
}
if (hasVoltage()) {
InfoCard(
icon = Icons.Default.Bolt,
text = "Voltage",
text = stringResource(R.string.voltage),
value = "%.2fV".format(voltage)
)
}
if (hasCurrent()) {
InfoCard(
icon = Icons.Default.Power,
text = "Current",
text = stringResource(R.string.current),
value = "%.1fmA".format(current)
)
}
if (hasIaq()) {
InfoCard(
icon = Icons.Default.Air,
text = "IAQ",
text = stringResource(R.string.iaq),
value = iaq.toString()
)
}
if (hasDistance()) {
InfoCard(
icon = Icons.Default.Height,
text = "Distance",
text = stringResource(R.string.distance),
value = "%.0f mm".format(distance)
)
}
if (hasLux()) {
InfoCard(
icon = Icons.Default.LightMode,
text = "Lux",
text = stringResource(R.string.lux),
value = "%.0f lx".format(lux)
)
}
@ -539,7 +539,7 @@ private fun EnvironmentMetrics(
val normalizedBearing = (windDirection % 360 + 360) % 360
InfoCard(
icon = Icons.Outlined.Navigation,
text = "Wind",
text = stringResource(R.string.wind),
value = windSpeed.toSpeedString(),
rotateIcon = normalizedBearing.toFloat(),
)
@ -547,14 +547,14 @@ private fun EnvironmentMetrics(
if (hasWeight()) {
InfoCard(
icon = Icons.Default.Scale,
text = "Weight",
text = stringResource(R.string.weight),
value = "%.2f kg".format(weight)
)
}
if (hasRadiation()) {
InfoCard(
icon = ImageVector.vectorResource(R.drawable.ic_filled_radioactive_24),
text = "Radiation",
text = stringResource(R.string.radiation),
value = "%.1f µR/h".format(radiation)
)
}
@ -595,12 +595,12 @@ private fun PowerMetrics(node: Node) = with(node.powerMetrics) {
Column {
InfoCard(
icon = Icons.Default.Bolt,
text = "Channel 1",
text = stringResource(R.string.channel_1),
value = "%.2fV".format(ch1Voltage)
)
InfoCard(
icon = Icons.Default.Power,
text = "Channel 1",
text = stringResource(R.string.channel_1),
value = "%.1fmA".format(ch1Current)
)
}
@ -609,12 +609,12 @@ private fun PowerMetrics(node: Node) = with(node.powerMetrics) {
Column {
InfoCard(
icon = Icons.Default.Bolt,
text = "Channel 2",
text = stringResource(R.string.channel_2),
value = "%.2fV".format(ch2Voltage)
)
InfoCard(
icon = Icons.Default.Power,
text = "Channel 2",
text = stringResource(R.string.channel_2),
value = "%.1fmA".format(ch2Current)
)
}
@ -623,12 +623,12 @@ private fun PowerMetrics(node: Node) = with(node.powerMetrics) {
Column {
InfoCard(
icon = Icons.Default.Bolt,
text = "Channel 3",
text = stringResource(R.string.channel_3),
value = "%.2fV".format(ch3Voltage)
)
InfoCard(
icon = Icons.Default.Power,
text = "Channel 3",
text = stringResource(R.string.channel_3),
value = "%.1fmA".format(ch3Current)
)
}

View file

@ -217,7 +217,7 @@ fun IAQScale(modifier: Modifier = Modifier) {
horizontalAlignment = Alignment.Start
) {
Text(
text = "Indoor Air Quality (IAQ)",
text = stringResource(R.string.indoor_air_quality_iaq),
style = MaterialTheme.typography.h6.copy(
fontWeight = FontWeight.Bold,
textAlign = TextAlign.Center,

View file

@ -77,7 +77,7 @@ fun StoreForwardConfigItemList(
LazyColumn(
modifier = Modifier.fillMaxSize()
) {
item { PreferenceCategory(text = "Store & Forward Config") }
item { PreferenceCategory(text = stringResource(R.string.store_forward_config)) }
item {
SwitchPreference(