diff --git a/.gitmodules b/.gitmodules index 4c058130a..19b292ea4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "fossil-hr-watchface"] path = external/fossil-hr-watchface - url = https://github.com/arjan-s/fossil-hr-watchface + url = https://codeberg.org/Freeyourgadget/fossil-hr-watchface [submodule "jerryscript"] path = external/jerryscript url = https://github.com/jerryscript-project/jerryscript diff --git a/app/src/main/assets/fossil_hr/battery_layout.json b/app/src/main/assets/fossil_hr/battery_layout.json new file mode 100644 index 000000000..4d35d4c85 --- /dev/null +++ b/app/src/main/assets/fossil_hr/battery_layout.json @@ -0,0 +1 @@ +[{"id":0,"type":"complication_background","background":"#background","goal_ring":{"is_enable":"#goal_ring","end_angle":"#fi","is_invert":"#$e"},"dimension":{"type":"rigid","width":"#size.w","height":"#size.h"},"placement":{"type":"absolute","left":"#pos.Ue","top":"#pos.Qe"},"visible":true,"inversion":false},{"id":1,"parent_id":0,"type":"complication_content","icon":"icBattery","text_low":"#ci","dimension":{"type":"rigid","width":76,"height":76},"placement":{"type":"relative"},"visible":true,"inversion":"#$e"},{"id":2,"parent_id":1,"type":"solid","placement":{"type":"absolute","left":29,"top":23},"color":"#nt","dimension":{"type":"rigid","height":6,"width":"#it"},"visible":true,"inversion":false},{"id":3,"parent_id":1,"type":"image","image_name":"icBattCharging","draw_mode":1,"placement":{"type":"absolute","left":34,"top":21},"dimension":{"width":6,"height":9},"visible":"#et","inversion":false}] diff --git a/app/src/main/assets/fossil_hr/complication_layout.json b/app/src/main/assets/fossil_hr/complication_layout.json new file mode 100644 index 000000000..42be572d2 --- /dev/null +++ b/app/src/main/assets/fossil_hr/complication_layout.json @@ -0,0 +1 @@ +[{"id":0,"type":"complication_background","background":"#background","goal_ring":{"is_enable":"#goal_ring","end_angle":"#fi","is_invert":"#$e"},"dimension":{"type":"rigid","width":"#size.w","height":"#size.h"},"placement":{"type":"absolute","left":"#pos.Ue","top":"#pos.Qe"},"visible":true,"inversion":false},{"id":1,"parent_id":0,"type":"complication_content","icon":"#icon","text_high":"#dt","text_low":"#ci","dimension":{"type":"rigid","width":76,"height":76},"placement":{"type":"relative"},"visible":true,"inversion":"#$e"}] \ No newline at end of file diff --git a/app/src/main/assets/fossil_hr/image_layout.json b/app/src/main/assets/fossil_hr/image_layout.json new file mode 100644 index 000000000..1ed732279 --- /dev/null +++ b/app/src/main/assets/fossil_hr/image_layout.json @@ -0,0 +1 @@ +[{"id":0,"type":"container","direction":1,"main_alignment":1,"cross_alignment":1,"dimension":{"type":"rigid","width":240,"height":240},"placement":{"type":"absolute","left":0,"top":0},"visible":true,"inversion":false},{"id":1,"parent_id":0,"type":"image","image_name":"#name","draw_mode":1,"placement":{"type":"absolute","left":"#pos.Ue","top":"#pos.Qe"},"dimension":{"width":"#size.w","height":"#size.h"},"visible":true,"inversion":false}] \ No newline at end of file diff --git a/app/src/main/assets/fossil_hr/menu_layout.json b/app/src/main/assets/fossil_hr/menu_layout.json new file mode 100644 index 000000000..6be3d627d --- /dev/null +++ b/app/src/main/assets/fossil_hr/menu_layout.json @@ -0,0 +1,207 @@ +[ + { + "id": 0, + "type": "container", + "direction": 1, + "main_alignment": 0, + "cross_alignment": 1, + "dimension": { + "type": "rigid", + "width": 240, + "height": 240 + }, + "placement": { + "type": "absolute", + "left": 0, + "top": 0 + }, + "visible": true, + "inversion": false + }, + { + "id": 1, + "parent_id": 0, + "type": "container", + "direction": 1, + "main_alignment": 1, + "cross_alignment": 2, + "dimension": { + "type": "rigid", + "width": 130, + "height": 34 + }, + "placement": { + "type": "absolute", + "left": 75, + "top": 45 + }, + "visible": true, + "inversion": false + }, + { + "id": 2, + "parent_id": 1, + "type": "text", + "text": "#top_short_press_label", + "ppem": 17, + "color": 3, + "placement": { + "type": "relative" + }, + "visible": true, + "inversion": false + }, + { + "id": 3, + "parent_id": 1, + "type": "text", + "text": "#top_long_press_label", + "ppem": 17, + "color": 3, + "ascent": 17, + "placement": { + "type": "relative" + }, + "visible": true, + "inversion": false + }, + { + "id": 4, + "parent_id": 0, + "type": "container", + "direction": 1, + "main_alignment": 1, + "cross_alignment": 2, + "dimension": { + "type": "rigid", + "width": 80, + "height": 34 + }, + "placement": { + "type": "absolute", + "left": 135, + "top": 103 + }, + "visible": true, + "inversion": false + }, + { + "id": 5, + "parent_id": 4, + "type": "text", + "text": "#middle_short_press_label", + "ppem": 17, + "color": 3, + "placement": { + "type": "relative" + }, + "visible": true, + "inversion": false + }, + { + "id": 6, + "parent_id": 4, + "type": "text", + "text": "#middle_long_press_label", + "ppem": 17, + "color": 3, + "ascent": 17, + "placement": { + "type": "relative" + }, + "visible": true, + "inversion": false + }, + { + "id": 7, + "parent_id": 0, + "type": "container", + "direction": 1, + "main_alignment": 1, + "cross_alignment": 2, + "dimension": { + "type": "rigid", + "width": 130, + "height": 34 + }, + "placement": { + "type": "absolute", + "left": 75, + "top": 161 + }, + "visible": true, + "inversion": false + }, + { + "id": 8, + "parent_id": 7, + "type": "text", + "text": "#bottom_short_press_label", + "ppem": 17, + "color": 3, + "placement": { + "type": "relative" + }, + "visible": true, + "inversion": false + }, + { + "id": 9, + "parent_id": 7, + "type": "text", + "text": "#bottom_long_press_label", + "ppem": 17, + "color": 3, + "ascent": 17, + "placement": { + "type": "relative" + }, + "visible": true, + "inversion": false + }, + { + "id": 10, + "parent_id": 0, + "type": "text", + "text": "#menu_title", + "ppem": 25, + "color": 3, + "ascent": 35, + "placement": { + "type": "relative" + }, + "visible": true, + "inversion": false + }, + { + "id": 11, + "parent_id": 0, + "type": "text_page", + "text": "#message_to_display", + "ppem": 17, + "color": 3, + "ascent": 17, + "cross_alignment": 2, + "line_width": [ + 80, + 85, + 90, + 90, + 85, + 80 + ], + "dimension": { + "type": "rigid", + "width": 80, + "height": 100 + }, + "placement": { + "type": "absolute", + "left": 20, + "top": 60 + }, + "visible": true, + "inversion": false + } + ] + \ No newline at end of file diff --git a/app/src/main/assets/fossil_hr/openSourceWatchface.bin b/app/src/main/assets/fossil_hr/openSourceWatchface.bin index e6cbe5917..69b9f5d65 100644 Binary files a/app/src/main/assets/fossil_hr/openSourceWatchface.bin and b/app/src/main/assets/fossil_hr/openSourceWatchface.bin 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 fc8b199c7..8ff214dd5 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 @@ -39,11 +39,11 @@ public class FossilAppWriter { private String version; private LinkedHashMap code; private LinkedHashMap icons; - private LinkedHashMap layout; + private LinkedHashMap layout; private LinkedHashMap displayName; private LinkedHashMap config; - public FossilAppWriter(Context context, String version, LinkedHashMap code, LinkedHashMap icons, LinkedHashMap layout, LinkedHashMap displayName, LinkedHashMap config) { + public FossilAppWriter(Context context, String version, LinkedHashMap code, LinkedHashMap icons, LinkedHashMap layout, LinkedHashMap displayName, LinkedHashMap config) { this.mContext = context; if (this.mContext == null) throw new AssertionError("context cannot be null"); this.version = version; @@ -63,7 +63,7 @@ public class FossilAppWriter { public byte[] getWapp() throws IOException { byte[] codeData = loadFiles(code); byte[] iconsData = loadFiles(icons); - byte[] layoutData = loadStringFiles(layout); + byte[] layoutData = loadFiles(layout); byte[] displayNameData = loadStringFiles(displayName); byte[] configData = loadStringFiles(config); 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 b0cdfd227..3246a3d55 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 @@ -185,22 +185,15 @@ public class HybridHRWatchfaceFactory { } catch (IOException e) { LOG.warn("Unable to read asset file", e); } - LinkedHashMap layout = new LinkedHashMap<>(); - try { - layout.put("complication_layout", getComplicationLayout()); - } catch (JSONException e) { - LOG.warn("Could not generate complication_layout", e); - } - try { - layout.put("image_layout", getImageLayout()); - } catch (JSONException e) { - LOG.warn("Could not generate image_layout", e); - } - try { - if (includeWidget("widgetBattery") > 0) layout.put("battery_layout", getBatteryLayout()); - } catch (JSONException e) { - LOG.warn("Could not generate battery_layout", e); + LinkedHashMap layout = new LinkedHashMap<>(); + layout.put("complication_layout", context.getAssets().open("fossil_hr/complication_layout.json")); + layout.put("image_layout", context.getAssets().open("fossil_hr/image_layout.json")); + layout.put("menu_layout", context.getAssets().open("fossil_hr/menu_layout.json")); + + if (includeWidget("widgetBattery") > 0) { + layout.put("battery_layout", context.getAssets().open("fossil_hr/battery_layout.json")); } + LinkedHashMap displayName = new LinkedHashMap<>(); displayName.put("display_name", watchfaceName); displayName.put("theme_class", "complications");