Skip to content

Commit 9648d0a

Browse files
authored
refactor: extract more hardcoded strings (#1814)
1 parent e9588c7 commit 9648d0a

File tree

5 files changed

+33
-22
lines changed

5 files changed

+33
-22
lines changed

app/src/main/java/com/geeksville/mesh/ui/ChannelFragment.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ private fun EditChannelUrl(
439439
},
440440
modifier = modifier.fillMaxWidth(),
441441
enabled = enabled,
442-
label = { Text("URL") },
442+
label = { Text(stringResource(R.string.url)) },
443443
isError = isError,
444444
trailingIcon = {
445445
val isUrlEqual = valueState == channelUrl

app/src/main/java/com/geeksville/mesh/ui/NodeDetail.kt

+19-19
Original file line numberDiff line numberDiff line change
@@ -466,71 +466,71 @@ private fun EnvironmentMetrics(
466466
if (hasTemperature()) {
467467
InfoCard(
468468
icon = Icons.Default.Thermostat,
469-
text = "Temperature",
469+
text = stringResource(R.string.temperature),
470470
value = temperature.toTempString(isFahrenheit)
471471
)
472472
}
473473
if (hasRelativeHumidity()) {
474474
InfoCard(
475475
icon = Icons.Default.WaterDrop,
476-
text = "Humidity",
476+
text = stringResource(R.string.humidity),
477477
value = "%.0f%%".format(relativeHumidity)
478478
)
479479
}
480480
if (hasTemperature() && hasRelativeHumidity()) {
481481
val dewPoint = calculateDewPoint(temperature, relativeHumidity)
482482
InfoCard(
483483
icon = ImageVector.vectorResource(R.drawable.ic_outlined_dew_point_24),
484-
text = "Dew Point",
484+
text = stringResource(R.string.dew_point),
485485
value = dewPoint.toTempString(isFahrenheit)
486486
)
487487
}
488488
if (hasBarometricPressure()) {
489489
InfoCard(
490490
icon = Icons.Default.Speed,
491-
text = "Pressure",
491+
text = stringResource(R.string.pressure),
492492
value = "%.0f hPa".format(barometricPressure)
493493
)
494494
}
495495
if (hasGasResistance()) {
496496
InfoCard(
497497
icon = Icons.Default.BlurOn,
498-
text = "Gas Resistance",
498+
text = stringResource(R.string.gas_resistance),
499499
value = "%.0f MΩ".format(gasResistance)
500500
)
501501
}
502502
if (hasVoltage()) {
503503
InfoCard(
504504
icon = Icons.Default.Bolt,
505-
text = "Voltage",
505+
text = stringResource(R.string.voltage),
506506
value = "%.2fV".format(voltage)
507507
)
508508
}
509509
if (hasCurrent()) {
510510
InfoCard(
511511
icon = Icons.Default.Power,
512-
text = "Current",
512+
text = stringResource(R.string.current),
513513
value = "%.1fmA".format(current)
514514
)
515515
}
516516
if (hasIaq()) {
517517
InfoCard(
518518
icon = Icons.Default.Air,
519-
text = "IAQ",
519+
text = stringResource(R.string.iaq),
520520
value = iaq.toString()
521521
)
522522
}
523523
if (hasDistance()) {
524524
InfoCard(
525525
icon = Icons.Default.Height,
526-
text = "Distance",
526+
text = stringResource(R.string.distance),
527527
value = "%.0f mm".format(distance)
528528
)
529529
}
530530
if (hasLux()) {
531531
InfoCard(
532532
icon = Icons.Default.LightMode,
533-
text = "Lux",
533+
text = stringResource(R.string.lux),
534534
value = "%.0f lx".format(lux)
535535
)
536536
}
@@ -539,22 +539,22 @@ private fun EnvironmentMetrics(
539539
val normalizedBearing = (windDirection % 360 + 360) % 360
540540
InfoCard(
541541
icon = Icons.Outlined.Navigation,
542-
text = "Wind",
542+
text = stringResource(R.string.wind),
543543
value = windSpeed.toSpeedString(),
544544
rotateIcon = normalizedBearing.toFloat(),
545545
)
546546
}
547547
if (hasWeight()) {
548548
InfoCard(
549549
icon = Icons.Default.Scale,
550-
text = "Weight",
550+
text = stringResource(R.string.weight),
551551
value = "%.2f kg".format(weight)
552552
)
553553
}
554554
if (hasRadiation()) {
555555
InfoCard(
556556
icon = ImageVector.vectorResource(R.drawable.ic_filled_radioactive_24),
557-
text = "Radiation",
557+
text = stringResource(R.string.radiation),
558558
value = "%.1f µR/h".format(radiation)
559559
)
560560
}
@@ -595,12 +595,12 @@ private fun PowerMetrics(node: Node) = with(node.powerMetrics) {
595595
Column {
596596
InfoCard(
597597
icon = Icons.Default.Bolt,
598-
text = "Channel 1",
598+
text = stringResource(R.string.channel_1),
599599
value = "%.2fV".format(ch1Voltage)
600600
)
601601
InfoCard(
602602
icon = Icons.Default.Power,
603-
text = "Channel 1",
603+
text = stringResource(R.string.channel_1),
604604
value = "%.1fmA".format(ch1Current)
605605
)
606606
}
@@ -609,12 +609,12 @@ private fun PowerMetrics(node: Node) = with(node.powerMetrics) {
609609
Column {
610610
InfoCard(
611611
icon = Icons.Default.Bolt,
612-
text = "Channel 2",
612+
text = stringResource(R.string.channel_2),
613613
value = "%.2fV".format(ch2Voltage)
614614
)
615615
InfoCard(
616616
icon = Icons.Default.Power,
617-
text = "Channel 2",
617+
text = stringResource(R.string.channel_2),
618618
value = "%.1fmA".format(ch2Current)
619619
)
620620
}
@@ -623,12 +623,12 @@ private fun PowerMetrics(node: Node) = with(node.powerMetrics) {
623623
Column {
624624
InfoCard(
625625
icon = Icons.Default.Bolt,
626-
text = "Channel 3",
626+
text = stringResource(R.string.channel_3),
627627
value = "%.2fV".format(ch3Voltage)
628628
)
629629
InfoCard(
630630
icon = Icons.Default.Power,
631-
text = "Channel 3",
631+
text = stringResource(R.string.channel_3),
632632
value = "%.1fmA".format(ch3Current)
633633
)
634634
}

app/src/main/java/com/geeksville/mesh/ui/components/IndoorAirQuality.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ fun IAQScale(modifier: Modifier = Modifier) {
217217
horizontalAlignment = Alignment.Start
218218
) {
219219
Text(
220-
text = "Indoor Air Quality (IAQ)",
220+
text = stringResource(R.string.indoor_air_quality_iaq),
221221
style = MaterialTheme.typography.h6.copy(
222222
fontWeight = FontWeight.Bold,
223223
textAlign = TextAlign.Center,

app/src/main/java/com/geeksville/mesh/ui/radioconfig/components/StoreForwardConfigItemList.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fun StoreForwardConfigItemList(
7777
LazyColumn(
7878
modifier = Modifier.fillMaxSize()
7979
) {
80-
item { PreferenceCategory(text = "Store & Forward Config") }
80+
item { PreferenceCategory(text = stringResource(R.string.store_forward_config)) }
8181

8282
item {
8383
SwitchPreference(

app/src/main/res/values/strings.xml

+11
Original file line numberDiff line numberDiff line change
@@ -581,4 +581,15 @@
581581
<string name="short_name">Short name</string>
582582
<string name="hardware_model">Hardware model</string>
583583
<string name="licensed_amateur_radio">Licensed amateur radio</string>
584+
<string name="dew_point">Dew Point</string>
585+
<string name="pressure">Pressure</string>
586+
<string name="gas_resistance">Gas Resistance</string>
587+
<string name="distance">Distance</string>
588+
<string name="lux">Lux</string>
589+
<string name="wind">Wind</string>
590+
<string name="weight">Weight</string>
591+
<string name="radiation">Radiation</string>
592+
<string name="store_forward_config"><![CDATA[Store & Forward Config]]></string>
593+
<string name="indoor_air_quality_iaq">Indoor Air Quality (IAQ)</string>
594+
<string name="url">URL</string>
584595
</resources>

0 commit comments

Comments
 (0)