From 541561e247dcbf774694c5c553f1eddc026a0078 Mon Sep 17 00:00:00 2001 From: dakhnod Date: Tue, 31 Dec 2019 03:13:13 +0100 Subject: [PATCH] added menu request --- .../fossil_hr/menu/SetCommuteMenuMessage.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/menu/SetCommuteMenuMessage.java diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/menu/SetCommuteMenuMessage.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/menu/SetCommuteMenuMessage.java new file mode 100644 index 000000000..4366e186e --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/menu/SetCommuteMenuMessage.java @@ -0,0 +1,30 @@ +package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.menu; + +import org.json.JSONException; +import org.json.JSONObject; + +import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil.FossilWatchAdapter; +import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.json.JsonPutRequest; + +public class SetCommuteMenuMessage extends JsonPutRequest { + public SetCommuteMenuMessage(String message, boolean finished, FossilWatchAdapter adapter) { + super((short) 0x0500, createObject(message, finished), adapter); + } + + private static JSONObject createObject(String message, boolean finished) { + try { + return new JSONObject() + .put("push", new JSONObject() + .put("set", new JSONObject() + .put("commuteApp._.config.commute_info", new JSONObject() + .put("message", message) + .put("type", finished ? "end" : "in_progress") + ) + ) + ); + } catch (JSONException e) { + e.printStackTrace(); + } + return null; + } +}