Skip to content

Commit

Permalink
Added string resources for "km" unit
Browse files Browse the repository at this point in the history
  • Loading branch information
woheller69 committed Jan 17, 2021
1 parent 3e042d6 commit 2076d9c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void run() {
sbEdgeLength.setMax(edgeRange);
sbEdgeLength.setProgress(((edgeRange + minEdgeLength) >> 1) - minEdgeLength);
tvEdgeLengthValue.setText(
String.format(FORMAT_EDGE_LENGTH_VALUE, sbEdgeLength.getProgress() + minEdgeLength, prefManager.getDistanceUnit())
String.format(FORMAT_EDGE_LENGTH_VALUE, sbEdgeLength.getProgress() + minEdgeLength, prefManager.getDistanceUnit(getApplicationContext()))
);

sbNumReturns.setMax(numberOfReturnsRange);
Expand Down Expand Up @@ -203,7 +203,7 @@ private class OnSeekBarEdgeLengthChange implements SeekBar.OnSeekBarChangeListen

@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
String text = String.format("%s %s", progress + minEdgeLength, prefManager.getDistanceUnit());
String text = String.format("%s %s", progress + minEdgeLength, prefManager.getDistanceUnit(getApplicationContext()));
tvEdgeLengthValue.setText(text);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,12 @@ public String getWeatherUnit() {

/**
* @return Returns "km" in case kilometer is set and "mi" if miles was selected.
* @param applicationContext
*/
public String getDistanceUnit() {
public String getDistanceUnit(Context applicationContext) {
int prefValue = Integer.parseInt(preferences.getString("distanceUnit", "1"));
if (prefValue == 1) {
return "km";
return applicationContext.getString(R.string.units_km);
} else {
return "mi";
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/card_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
android:layout_column="0"
android:layout_marginBottom="5dp"
android:layout_row="0"
android:text="@string/units_rain60min_prefix"
android:text="@string/card_details_rain60min"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/colorPrimaryDark" />

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@
<string name="chart">Diagramm</string>
<string name="units_rh">%rh</string>
<string name="units_mm">mm</string>
<string name="units_km">km</string>
<string name="units_hPa">hPa</string>
<string name="units_Bft">Bft</string>
<string name="units_rain60min_prefix">☔ 60 min:</string>
<string name="card_details_rain60min">☔ 60 min:</string>
</resources>
7 changes: 4 additions & 3 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,10 @@
<string name="saturday">Суббота</string>
<string name="sunday">Воскресенье</string>
<string name="chart">Диаграмма</string>
<string name="units_rh">%rh</string>
<string name="units_rh">%отн</string>
<string name="units_mm">мм</string>
<string name="units_hPa">hPa</string>
<string name="units_km">км</string>
<string name="units_hPa">гПа</string>
<string name="units_Bft">Bft</string>
<string name="units_rain60min_prefix">☔ 60 min:</string>
<string name="card_details_rain60min">☔ 60 мин:</string>
</resources>
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@
<string name="chart">Chart</string>
<string name="units_rh">%rh</string>
<string name="units_mm">mm</string>
<string name="units_km">km</string>
<string name="units_hPa">hPa</string>
<string name="units_Bft">Bft</string>
<string name="units_rain60min_prefix">☔ 60 min:</string>
<string name="card_details_rain60min">☔ 60 min:</string>
</resources>

0 comments on commit 2076d9c

Please sign in to comment.