Skip to content

Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.

Weather add-on: drop the Blizzard label

Suuuiii96f5d88a716d
diff --git a/addons/weather/README.md b/addons/weather/README.md
index b83978219..7d303869f 100644
--- a/addons/weather/README.md
+++ b/addons/weather/README.md
@@ -15,8 +15,6 @@ sky-blue glow; on any other Android TV home it is an ordinary app.
- **Snow, not rain, near freezing.** The models type precipitation by the air temperature and call snow
"light rain" at 1 °C (ICON and GFS did, in a Ulaanbaatar blizzard). The app decides by the wet-bulb
temperature instead, which counts how dry the air is: at 1 °C or below, rain and drizzle are shown as snow.
-- **Blizzard.** Snow with gusts of 50 km/h or more. The gusts are the stronger of ICON's and ECMWF's, as the two
- disagreed most about the wind (26 against 52 to 62 km/h in that storm).
- It reads Open-Meteo only while the page is on screen, every 30 minutes, or 5 minutes after a failure.
- Degrees Celsius, English words; day names follow the TV's language.
diff --git a/addons/weather/app/src/main/java/io/github/sumyabazar1/weather/Forecast.java b/addons/weather/app/src/main/java/io/github/sumyabazar1/weather/Forecast.java
index 287f7f909..4b64211e3 100644
--- a/addons/weather/app/src/main/java/io/github/sumyabazar1/weather/Forecast.java
+++ b/addons/weather/app/src/main/java/io/github/sumyabazar1/weather/Forecast.java
@@ -53,19 +53,16 @@ final class Forecast {
/** The WMO code, rain turned into snow where the air is cold enough for it (see {@link #snowIfCold}). */
final int code;
final boolean day;
- /** Snow with gusts of {@link #BLIZZARD_GUST_KMH} or more. */
- final boolean blizzard;
/** The next days, tomorrow first. */
final List<Day> days;
/** US AQI, or -1 when the air quality read failed. */
final int aqi;
- Report(int tempC, int feelsC, int code, boolean day, boolean blizzard, List<Day> days, int aqi) {
+ Report(int tempC, int feelsC, int code, boolean day, List<Day> days, int aqi) {
this.tempC = tempC;
this.feelsC = feelsC;
this.code = code;
this.day = day;
- this.blizzard = blizzard;
this.days = days;
this.aqi = aqi;
}
@@ -109,22 +106,16 @@ final class Forecast {
// DWD's ICON model: Open-Meteo's default blend called light snow over Ulaanbaatar "overcast" while ICON,
// and Google, had snow falling.
JSONObject reply = get("https://api.open-meteo.com/v1/forecast?" + where + "&models=icon_seamless"
- + "&current=temperature_2m,relative_humidity_2m,apparent_temperature,weather_code,is_day,wind_gusts_10m"
+ + "&current=temperature_2m,relative_humidity_2m,apparent_temperature,weather_code,is_day"
+ "&daily=weather_code,temperature_2m_max,temperature_2m_min&timezone=auto&forecast_days=4");
JSONObject current = reply.getJSONObject("current");
double temp = current.getDouble("temperature_2m");
int code = snowIfCold(current.getInt("weather_code"), temp, current.getDouble("relative_humidity_2m"));
- // The models disagree most about wind: in a Ulaanbaatar blizzard ICON had 26 km/h gusts and ECMWF 52 to 62.
- // Take the stronger of the two, so a storm that one model sees is not called calm.
- double gust = Math.max(current.getDouble("wind_gusts_10m"), ecmwfGustOrZero(where));
return new Report((int) Math.round(temp), (int) Math.round(current.getDouble("apparent_temperature")),
- code, current.getInt("is_day") == 1, isSnow(code) && gust >= BLIZZARD_GUST_KMH,
+ code, current.getInt("is_day") == 1,
days(reply.getJSONObject("daily")), aqiOrUnknown(where));
}
- /** Gusts at or above this, with snow falling, are called a blizzard. */
- static final double BLIZZARD_GUST_KMH = 50;
-
/**
* The models type precipitation by the air temperature, and around freezing they call rain what reaches the
* ground as snow (ICON and GFS: "light rain" at 1 °C in a Ulaanbaatar blizzard). The wet-bulb temperature,
@@ -147,19 +138,6 @@ final class Forecast {
+ 0.00391838 * Math.pow(rh, 1.5) * Math.atan(0.023101 * rh) - 4.686035;
}
- static boolean isSnow(int code) {
- return (code >= 71 && code <= 77) || code == 85 || code == 86;
- }
-
- private static double ecmwfGustOrZero(String where) {
- try {
- return get("https://api.open-meteo.com/v1/forecast?" + where + "&models=ecmwf_ifs025&current=wind_gusts_10m")
- .getJSONObject("current").optDouble("wind_gusts_10m", 0);
- } catch (IOException | JSONException e) {
- return 0;
- }
- }
-
/** Tomorrow and the days after it; today (index 0) is the current reading. */
private static List<Day> days(JSONObject daily) throws JSONException {
JSONArray dates = daily.getJSONArray("time");
@@ -251,11 +229,6 @@ final class Forecast {
return aqiBand(aqi) == 1 ? 0xFF1A1A1A : 0xFFFFFFFF;
}
- /** The words for the weather now: as {@link #sky}, or Blizzard. */
- static int sky(Report r) {
- return r.blizzard ? R.string.sky_blizzard : sky(r.code, r.day);
- }
-
/** A full-screen gradient in the weather's colours, dark at the bottom. */
static Drawable backdrop(int code, boolean day) {
int[] colours;
diff --git a/addons/weather/app/src/main/java/io/github/sumyabazar1/weather/WeatherActivity.java b/addons/weather/app/src/main/java/io/github/sumyabazar1/weather/WeatherActivity.java
index 0a0cd2081..d25aba249 100644
--- a/addons/weather/app/src/main/java/io/github/sumyabazar1/weather/WeatherActivity.java
+++ b/addons/weather/app/src/main/java/io/github/sumyabazar1/weather/WeatherActivity.java
@@ -102,7 +102,7 @@ public final class WeatherActivity extends Activity {
root.setBackground(Forecast.backdrop(r.code, r.day));
((TextView) findViewById(R.id.place)).setText(place.getString("name", ""));
((TextView) findViewById(R.id.temp)).setText(r.tempC + "°");
- ((TextView) findViewById(R.id.sky)).setText(Forecast.sky(r));
+ ((TextView) findViewById(R.id.sky)).setText(Forecast.sky(r.code, r.day));
((TextView) findViewById(R.id.feels)).setText(getString(R.string.feels_like, r.feelsC));
TextView air = findViewById(R.id.airQuality);
diff --git a/addons/weather/app/src/main/res/values/strings.xml b/addons/weather/app/src/main/res/values/strings.xml
index b66d8849d..9984e21eb 100644
--- a/addons/weather/app/src/main/res/values/strings.xml
+++ b/addons/weather/app/src/main/res/values/strings.xml
@@ -43,5 +43,4 @@
<string name="sky_showers">Showers</string>
<string name="sky_snow_showers">Snow showers</string>
<string name="sky_thunderstorm">Thunderstorm</string>
- <string name="sky_blizzard">Blizzard</string>
</resources>