Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Managing and retrieving the unit system preferences for Temperature u…
Browse files Browse the repository at this point in the history
…nit; #187 - subtask.
  • Loading branch information
habeebdashti committed Nov 17, 2023
1 parent 3e80dc0 commit 55fa4d3
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,19 @@ public static void applyDefaultUnit() {
}
}
}
public static TemperatureUnit getTemperatureUnit() {
final String TEMPERATURE_UNIT_DEFAULT = resources.getString(R.string.temperature_unit_default);

final String VALUE = getString(R.string.temperature_unit_key, TEMPERATURE_UNIT_DEFAULT);
return Arrays.stream(TemperatureUnit.values())
.filter(d -> VALUE.equals(resources.getString(d.getPreferenceId(), TEMPERATURE_UNIT_DEFAULT)))
.findFirst()
.orElse(TemperatureUnit.defaultTemperatureUnit());
}

public static void setTemperatureUnit(TemperatureUnit temperatureUnit) {
setString(R.string.temperature_unit_key, temperatureUnit.getPreferenceId());
}
public static boolean isReportSpeed(String activityTypeLocalized) {
final String STATS_RATE_DEFAULT = resources.getString(R.string.stats_rate_default);
String currentStatsRate = getString(R.string.stats_rate_key, STATS_RATE_DEFAULT);
Expand Down

0 comments on commit 55fa4d3

Please sign in to comment.