mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-24 01:25:50 +01:00
Fossil/Skagen Hybrids: Add UV index and chance of rain widgets
Note: this needs support from weather apps, for example: https://github.com/TylerWilliamson/QuickWeather/pull/69
This commit is contained in:
parent
ff563022f5
commit
2081463a4f
Binary file not shown.
BIN
app/src/main/assets/fossil_hr/widgetUV.bin
Normal file
BIN
app/src/main/assets/fossil_hr/widgetUV.bin
Normal file
Binary file not shown.
BIN
app/src/main/assets/fossil_hr/widgetUV_preview.png
Normal file
BIN
app/src/main/assets/fossil_hr/widgetUV_preview.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
@ -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;
|
||||
|
@ -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<includeWidget("widget2ndTZ"); i++) {
|
||||
code.put("widget2ndTZ" + i, context.getAssets().open("fossil_hr/widget2ndTZ.bin"));
|
||||
}
|
||||
|
@ -76,8 +76,9 @@ public class HybridHRWatchfaceWidget implements Serializable {
|
||||
widgetTypes.put("widgetCalories", context.getString(R.string.watchface_widget_type_calories));
|
||||
widgetTypes.put("widget2ndTZ", context.getString(R.string.watchface_widget_type_2nd_tz));
|
||||
widgetTypes.put("widgetActiveMins", context.getString(R.string.watchface_widget_type_active_mins));
|
||||
widgetTypes.put("widgetChanceOfRain", context.getString(R.string.watchface_widget_type_chance_rain));
|
||||
widgetTypes.put("widgetUV", context.getString(R.string.watchface_widget_type_uv_index));
|
||||
widgetTypes.put("widgetCustom", context.getString(R.string.watchface_widget_type_custom));
|
||||
// widgetTypes.put("widgetChanceOfRain", context.getString(R.string.watchface_widget_type_chance_rain)); // Disabled due to missing support in Gadgetbridge
|
||||
return widgetTypes;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ import java.util.Map;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
|
||||
|
||||
public final class QHybridConstants {
|
||||
public static final String HYBRIDHR_WATCHFACE_VERSION = "1.9";
|
||||
public static final String HYBRIDHR_WATCHFACE_VERSION = "1.10";
|
||||
public static final int HYBRID_HR_WATCHFACE_WIDGET_SIZE = 76;
|
||||
|
||||
public static Map<String, String> KNOWN_WAPP_VERSIONS = new HashMap<String, String>() {
|
||||
|
@ -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");
|
||||
|
@ -1779,6 +1779,7 @@
|
||||
<string name="watchface_widget_type_2nd_tz">2nd time zone</string>
|
||||
<string name="watchface_widget_type_active_mins">Active minutes</string>
|
||||
<string name="watchface_widget_type_chance_rain">Chance of rain</string>
|
||||
<string name="watchface_widget_type_uv_index">UV index</string>
|
||||
<string name="watchface_setting_title_power_saving">Power saving</string>
|
||||
<string name="watchface_setting_power_saving_display">Disable display updates while off wrist</string>
|
||||
<string name="watchface_setting_power_saving_hands">Disable hands movement while off wrist</string>
|
||||
|
1
external/build_fossil_hr_watchface.sh
vendored
1
external/build_fossil_hr_watchface.sh
vendored
@ -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/
|
||||
|
2
external/fossil-hr-watchface
vendored
2
external/fossil-hr-watchface
vendored
@ -1 +1 @@
|
||||
Subproject commit 1a58411e8fe32d1a1a80982fdc5775b4529cf8d1
|
||||
Subproject commit b66f0629e78e87df8cb7c793f972e3bee57cd44d
|
Loading…
Reference in New Issue
Block a user