diff --git a/app/src/main/assets/fossil_hr/widgetChanceOfRain.bin b/app/src/main/assets/fossil_hr/widgetChanceOfRain.bin index 27e039b8b..f0197d397 100644 Binary files a/app/src/main/assets/fossil_hr/widgetChanceOfRain.bin and b/app/src/main/assets/fossil_hr/widgetChanceOfRain.bin differ diff --git a/app/src/main/assets/fossil_hr/widgetUV.bin b/app/src/main/assets/fossil_hr/widgetUV.bin new file mode 100644 index 000000000..c07b957b0 Binary files /dev/null and b/app/src/main/assets/fossil_hr/widgetUV.bin differ diff --git a/app/src/main/assets/fossil_hr/widgetUV_preview.png b/app/src/main/assets/fossil_hr/widgetUV_preview.png new file mode 100644 index 000000000..38b25d855 Binary files /dev/null and b/app/src/main/assets/fossil_hr/widgetUV_preview.png differ diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/FossilAppWriter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/FossilAppWriter.java index 086b9c211..5368ac84d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/FossilAppWriter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/FossilAppWriter.java @@ -47,7 +47,7 @@ public class FossilAppWriter { this.mContext = context; if (this.mContext == null) throw new AssertionError("context cannot be null"); this.version = version; - if (!this.version.matches("^[0-9]\\.[0-9]$")) throw new AssertionError("Version must be in x.x format"); + if (!this.version.matches("^[0-9]\\.[0-9]+$")) throw new AssertionError("Version must be in x.x format"); this.code = code; if (this.code.size() == 0) throw new AssertionError("At least one code file InputStream must be supplied"); this.icons = icons; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceFactory.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceFactory.java index cb55791b1..5ec20102a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceFactory.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceFactory.java @@ -103,11 +103,12 @@ public class HybridHRWatchfaceFactory { case "widgetCalories": case "widgetActiveMins": case "widgetChanceOfRain": + case "widgetUV": widget.put("type", "comp"); widget.put("name", widgetDesc.getWidgetType()); widget.put("goal_ring", false); widget.put("color", widgetDesc.getColor() == HybridHRWatchfaceWidget.COLOR_WHITE ? "white" : "black"); - if (widgetDesc.getBackground() != "") { + if (!widgetDesc.getBackground().equals("")) { widget.put("bg", widgetDesc.getBackground() + widgetDesc.getColor() + ".rle"); } break; @@ -184,6 +185,7 @@ public class HybridHRWatchfaceFactory { if (includeWidget("widgetCalories") > 0) code.put("widgetCalories", context.getAssets().open("fossil_hr/widgetCalories.bin")); if (includeWidget("widgetActiveMins") > 0) code.put("widgetActiveMins", context.getAssets().open("fossil_hr/widgetActiveMins.bin")); if (includeWidget("widgetChanceOfRain") > 0) code.put("widgetChanceOfRain", context.getAssets().open("fossil_hr/widgetChanceOfRain.bin")); + if (includeWidget("widgetUV") > 0) code.put("widgetUV", context.getAssets().open("fossil_hr/widgetUV.bin")); for (int i=0; i KNOWN_WAPP_VERSIONS = new HashMap() { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java index ea0654a5e..db2b32d35 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/adapter/fossil_hr/FossilHRWatchAdapter.java @@ -1502,6 +1502,46 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter { } } + public void onSendChanceOfRain(WeatherSpec weatherSpec) { + long ts = System.currentTimeMillis(); + ts /= 1000; + try { + JSONObject rainObject = new JSONObject() + .put("res", new JSONObject() + .put("set", new JSONObject() + .put("widgetChanceOfRain._.config.info", new JSONObject() + .put("alive", ts + 60 * 15) + .put("rain", weatherSpec.precipProbability) + ) + ) + ); + + queueWrite(new JsonPutRequest(rainObject, this)); + } catch (JSONException e) { + LOG.error("JSON exception: ", e); + } + } + + public void onSendUVIndex(WeatherSpec weatherSpec) { + long ts = System.currentTimeMillis(); + ts /= 1000; + try { + JSONObject rainObject = new JSONObject() + .put("res", new JSONObject() + .put("set", new JSONObject() + .put("widgetUV._.config.info", new JSONObject() + .put("alive", ts + 60 * 15) + .put("uv", Math.round(weatherSpec.uvIndex)) + ) + ) + ); + + queueWrite(new JsonPutRequest(rainObject, this)); + } catch (JSONException e) { + LOG.error("JSON exception: ", e); + } + } + @Override public void factoryReset() { queueWrite(new FactoryResetRequest()); @@ -1810,6 +1850,22 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter { } else { LOG.info("no weather data available - ignoring request"); } + } else if (request.has("widgetChanceOfRain._.config.info")) { + LOG.info("Got widgetChanceOfRain request"); + WeatherSpec weatherSpec = Weather.getInstance().getWeatherSpec(); + if (weatherSpec != null) { + onSendChanceOfRain(weatherSpec); + } else { + LOG.info("no weather data available - ignoring request"); + } + } else if (request.has("widgetUV._.config.info")) { + LOG.info("Got widgetUV request"); + WeatherSpec weatherSpec = Weather.getInstance().getWeatherSpec(); + if (weatherSpec != null) { + onSendUVIndex(weatherSpec); + } else { + LOG.info("no weather data available - ignoring request"); + } } else if (request.has("commuteApp._.config.commute_info")) { String action = request.getJSONObject("commuteApp._.config.commute_info") .getString("dest"); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f66525a8a..0058ff584 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1779,6 +1779,7 @@ 2nd time zone Active minutes Chance of rain + UV index Power saving Disable display updates while off wrist Disable hands movement while off wrist diff --git a/external/build_fossil_hr_watchface.sh b/external/build_fossil_hr_watchface.sh index 209469192..28a8acf3d 100755 --- a/external/build_fossil_hr_watchface.sh +++ b/external/build_fossil_hr_watchface.sh @@ -16,6 +16,7 @@ $jerry generate -f '' widget_calories.js -o widgetCalories.bin $jerry generate -f '' widget_2nd_tz.js -o widget2ndTZ.bin $jerry generate -f '' widget_activemins.js -o widgetActiveMins.bin $jerry generate -f '' widget_chanceofrain.js -o widgetChanceOfRain.bin +$jerry generate -f '' widget_uv.js -o widgetUV.bin $jerry generate -f '' widget_custom.js -o widgetCustom.bin popd mv fossil-hr-watchface/*.bin ../app/src/main/assets/fossil_hr/ diff --git a/external/fossil-hr-watchface b/external/fossil-hr-watchface index 1a58411e8..b66f0629e 160000 --- a/external/fossil-hr-watchface +++ b/external/fossil-hr-watchface @@ -1 +1 @@ -Subproject commit 1a58411e8fe32d1a1a80982fdc5775b4529cf8d1 +Subproject commit b66f0629e78e87df8cb7c793f972e3bee57cd44d