Skip to content

Commit

Permalink
fix #9: replae degrees sign for kelvin temperatures with a 'K'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sander Baas committed Sep 15, 2018
1 parent 80ea627 commit 92a4e71
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/src/main/java/nl/implode/weer/ForecastWidgetService.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ private void processForecasts(JSONObject forecast, Integer widgetId) {
Double temp = Double.valueOf(dayForecast.getJSONObject("main").getString("temp"));
Boolean isFreezing = temp < 273.15;

String tempSuffix = "" + (char) 0x00B0;
if (prefTempScale.equals("0")) {
// celsius
temp = temp - 273.15;
Expand All @@ -219,11 +220,15 @@ private void processForecasts(JSONObject forecast, Integer widgetId) {
Double factor = (double)9/(double)5;
temp = factor * (temp - 273.15) + 32;
}
if (prefTempScale.equals("2")) {
// kelvin
tempSuffix = "" + (char) 0x004B;
}

int tempColor = getLayout(isFreezing ? "color_temp_freezing" : "color_temp");

RemoteViews forecastView = new RemoteViews(gContext.getPackageName(), getLayout("forecast"));
forecastView.setTextViewText(R.id.forecast_temp, String.valueOf(Math.round(temp)) + (char) 0x00B0);
forecastView.setTextViewText(R.id.forecast_temp, String.valueOf(Math.round(temp)) + tempSuffix);

forecastView.setTextColor(R.id.forecast_temp, tempColor);
String rain = "";
Expand Down

0 comments on commit 92a4e71

Please sign in to comment.