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 e997d1018..13eb4808b 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 @@ -13,6 +13,7 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import java.io.FileInputStream; import java.io.IOException; import java.nio.BufferOverflowException; import java.nio.ByteBuffer; @@ -24,6 +25,7 @@ import java.util.TimeZone; import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.Widget; import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.HRConfigActivity; +import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.NotificationConfiguration; import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.NotificationHRConfiguration; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec; @@ -34,6 +36,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.foss import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.RequestMtuRequest; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.SetDeviceStateRequest; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.configuration.ConfigurationPutRequest.TimeConfigItem; +import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.file.FileCloseRequest; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.file.FileDeleteRequest; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.notification.PlayNotificationRequest; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.authentication.VerifyPrivateKeyRequest; @@ -49,6 +52,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fos import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.music.MusicControlRequest; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.music.MusicInfoSetRequest; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.notification.NotificationFilterPutHRRequest; +import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.notification.NotificationImage; +import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.notification.NotificationImagePutRequest; +import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.notification.PlayNotificationHRRequest; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.widget.CustomWidget; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.widget.CustomWidgetElement; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.utils.StringUtils; @@ -64,9 +70,12 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter { CustomWidget[] widgets = new CustomWidget[0]; + NotificationHRConfiguration[] notificationConfigurations; + private MusicSpec currentSpec = null; int imageNameIndex = 0; + private byte jsonIndex = 0; public FossilHRWatchAdapter(QHybridSupport deviceSupport) { super(deviceSupport); @@ -86,21 +95,43 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter { // icons - // queueWrite(new NotificationFilterPutHRRequest(new NotificationHRConfiguration[]{ - // new NotificationHRConfiguration("com.whatsapp", -1), - // new NotificationHRConfiguration("asdasdasdasdasd", -1), - // // new NotificationHRConfiguration("twitter", -1), - // }, this)); + loadNotificationConfigurations(); + // queueWrite(new NotificationFilterPutHRRequest(this.notificationConfigurations,this)); - // queueWrite(new PlayNotificationRequest("com.whatsapp", "WhatsAp", "wHATSaPP", this)); - // queueWrite(new PlayNotificationRequest("twitterrrr", "Twitterr", "tWITTER", this));queueWrite(new NotificationFilterPutRequest( - // new NotificationConfiguration[]{ - // new NotificationConfiguration((short) -1, (short) -1, "generic", "", false, PlayNotificationRequest.VibrationType.SINGLE_LONG, 0) - // }, + String[] appNames = {"instagram", "snapchat", "line", "whatsapp"}; + String[] paths = { + "/storage/emulated/0/Q/images/icInstagram.icon", + "/storage/emulated/0/Q/images/icSnapchat.icon", + "/storage/emulated/0/Q/images/icLine.icon", + "/storage/emulated/0/Q/images/icWhatsapp.icon" + }; + /*NotificationHRConfiguration[] configs = new NotificationHRConfiguration[4]; + NotificationImage[] images = new NotificationImage[4]; - queueWrite(new NotificationFilterPutHRRequest(new NotificationHRConfiguration[]{ - new NotificationHRConfiguration("generic", 0) - },this)); + + try { + for(int i = 0; i < 4; i++){ + FileInputStream fis = new FileInputStream(paths[i]); + byte[] imageData = new byte[fis.available()]; + fis.read(imageData); + fis.close(); + configs[i] = new NotificationHRConfiguration(appNames[i], i); + images[i] = new NotificationImage(appNames[i], imageData); + } + queueWrite(new NotificationImagePutRequest(images, this)); + queueWrite(new NotificationFilterPutHRRequest(configs, this)); + } catch (Exception e) { + e.printStackTrace(); + } + + for(String appName : appNames){ + queueWrite(new PlayNotificationHRRequest( + appName, + appName.toUpperCase(), + "this is some strange message", + this + )); + }*/ syncSettings(); @@ -109,33 +140,18 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter { overwriteButtons(null); loadWidgets(); - renderWidgets(); + // renderWidgets(); // dunno if there is any point in doing this at start since when no watch is connected the QHybridSupport will not receive any intents anyway - /*try { - queueWrite(new AssetFilePutRequest(new AssetImage[]{ - AssetImageFactory.createAssetImage("0D58BD24", new byte[]{(byte) 0x18, (byte) 0x18, (byte) 0x1D, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x01, (byte) 0x14, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x12, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x10, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x0E, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x0D, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x05, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x03, (byte) 0x0D, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x0E, (byte) 0x00, (byte) 0x02, (byte) 0x03, (byte) 0x03, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x0F, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x00, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x10, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x11, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x10, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x03, (byte) 0x00, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x05, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x01, (byte) 0x09, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x09, (byte) 0x00, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x09, (byte) 0x00, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x00, (byte) 0x04, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x08, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x08, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x05, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x09, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x07, (byte) 0x00, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x0B, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x0D, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x10, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x05, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x13, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x1D, (byte) 0x00, (byte) 0xFF, (byte) 0xFF}, 0, 0, 0), - AssetImageFactory.createAssetImage("AD365776", new byte[]{(byte) 0x18, (byte) 0x18, (byte) 0x1D, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x01, (byte) 0x14, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x0B, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x06, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x09, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x07, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x05, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x05, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x05, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x06, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x08, (byte) 0x00, (byte) 0x02, (byte) 0x03, (byte) 0x03, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x09, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x00, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x0A, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x0C, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x0D, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x03, (byte) 0x00, (byte) 0x04, (byte) 0x03, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x01, (byte) 0x09, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x00, (byte) 0x03, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x09, (byte) 0x00, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x09, (byte) 0x00, (byte) 0x04, (byte) 0x03, (byte) 0x03, (byte) 0x00, (byte) 0x03, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x08, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x06, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x05, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x05, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x05, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x03, (byte) 0x00, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x07, (byte) 0x00, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x06, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x05, (byte) 0x00, (byte) 0x02, (byte) 0x03, (byte) 0x09, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x05, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x13, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x1D, (byte) 0x00, (byte) 0xFF, (byte) 0xFF}, 0, 0, 0), - AssetImageFactory.createAssetImage("C3F69363", new byte[]{(byte) 0x18, (byte) 0x18, (byte) 0x1E, (byte) 0x00, (byte) 0x0C, (byte) 0x01, (byte) 0x09, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x10, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x05, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x03, (byte) 0x0E, (byte) 0x02, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x0E, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x10, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x10, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x10, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x10, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x10, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x10, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x10, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x10, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x10, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x00, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x0B, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x02, (byte) 0x04, (byte) 0x00, (byte) 0x0D, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x03, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x05, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x09, (byte) 0x02, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x0F, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x10, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x11, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x12, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x13, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x14, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x01, (byte) 0x16, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x08, (byte) 0x00, (byte) 0xFF, (byte) 0xFF}, 0, 0, 0), - AssetImageFactory.createAssetImage("7251C82B", new byte[]{(byte) 0x18, (byte) 0x18, (byte) 0x3B, (byte) 0x0C, (byte) 0x02, (byte) 0x0D, (byte) 0x16, (byte) 0x0C, (byte) 0x02, (byte) 0x07, (byte) 0x16, (byte) 0x0C, (byte) 0x02, (byte) 0x03, (byte) 0x15, (byte) 0x0C, (byte) 0x01, (byte) 0x0A, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x0A, (byte) 0x14, (byte) 0x0C, (byte) 0x04, (byte) 0x03, (byte) 0x13, (byte) 0x0C, (byte) 0x01, (byte) 0x09, (byte) 0x01, (byte) 0x03, (byte) 0x02, (byte) 0x0A, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x09, (byte) 0x0F, (byte) 0x0C, (byte) 0x02, (byte) 0x0D, (byte) 0x01, (byte) 0x09, (byte) 0x02, (byte) 0x03, (byte) 0x02, (byte) 0x0C, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x09, (byte) 0x02, (byte) 0x0D, (byte) 0x08, (byte) 0x0C, (byte) 0x01, (byte) 0x0A, (byte) 0x07, (byte) 0x03, (byte) 0x01, (byte) 0x06, (byte) 0x02, (byte) 0x0C, (byte) 0x01, (byte) 0x06, (byte) 0x07, (byte) 0x03, (byte) 0x01, (byte) 0x0A, (byte) 0x05, (byte) 0x0C, (byte) 0x01, (byte) 0x06, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x06, (byte) 0x02, (byte) 0x09, (byte) 0x01, (byte) 0x0D, (byte) 0x04, (byte) 0x0C, (byte) 0x01, (byte) 0x0D, (byte) 0x01, (byte) 0x09, (byte) 0x01, (byte) 0x0A, (byte) 0x01, (byte) 0x06, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x06, (byte) 0x07, (byte) 0x0C, (byte) 0x01, (byte) 0x0A, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x0D, (byte) 0x08, (byte) 0x0C, (byte) 0x01, (byte) 0x0D, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x0A, (byte) 0x09, (byte) 0x0C, (byte) 0x01, (byte) 0x09, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x09, (byte) 0x06, (byte) 0x0C, (byte) 0x01, (byte) 0x09, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x09, (byte) 0x0B, (byte) 0x0C, (byte) 0x01, (byte) 0x0D, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x0D, (byte) 0x05, (byte) 0x0C, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x0D, (byte) 0x0D, (byte) 0x0C, (byte) 0x01, (byte) 0x07, (byte) 0x01, (byte) 0x03, (byte) 0x06, (byte) 0x0C, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x07, (byte) 0x0E, (byte) 0x0C, (byte) 0x02, (byte) 0x03, (byte) 0x02, (byte) 0x0C, (byte) 0x02, (byte) 0x09, (byte) 0x02, (byte) 0x0C, (byte) 0x01, (byte) 0x07, (byte) 0x01, (byte) 0x03, (byte) 0x0D, (byte) 0x0C, (byte) 0x01, (byte) 0x0D, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x06, (byte) 0x01, (byte) 0x0D, (byte) 0x01, (byte) 0x07, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x07, (byte) 0x01, (byte) 0x0D, (byte) 0x01, (byte) 0x06, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x0D, (byte) 0x0C, (byte) 0x0C, (byte) 0x01, (byte) 0x09, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x07, (byte) 0x02, (byte) 0x03, (byte) 0x02, (byte) 0x06, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x07, (byte) 0x01, (byte) 0x03, (byte) 0x01, (byte) 0x09, (byte) 0x0C, (byte) 0x0C, (byte) 0x01, (byte) 0x06, (byte) 0x03, (byte) 0x03, (byte) 0x01, (byte) 0x0D, (byte) 0x02, (byte) 0x0C, (byte) 0x01, (byte) 0x0D, (byte) 0x03, (byte) 0x03, (byte) 0x01, (byte) 0x06, (byte) 0x0C, (byte) 0x0C, (byte) 0x02, (byte) 0x03, (byte) 0x01, (byte) 0x0A, (byte) 0x06, (byte) 0x0C, (byte) 0x01, (byte) 0x0A, (byte) 0x02, (byte) 0x03, (byte) 0x0C, (byte) 0x0C, (byte) 0x01, (byte) 0x06, (byte) 0x0A, (byte) 0x0C, (byte) 0x01, (byte) 0x06, (byte) 0x4E, (byte) 0x0C, (byte) 0xFF, (byte) 0xFF}, 0, 0, 0), - }, this)); - } catch (IOException e) { - e.printStackTrace(); - }*/ - - /*queueWrite(new ImagesSetRequest( - new AssetImage[]{ - AssetImageFactory.createAssetImage("0D58BD24", null, 0, 60, 1), - AssetImageFactory.createAssetImage("AD365776", null, 90, 60, 1), - AssetImageFactory.createAssetImage("C3F69363", null, 180, 60, 1), - AssetImageFactory.createAssetImage("7251C82B", null, 270, 60, 1), - }, - this - )); -*/ queueWrite(new SetDeviceStateRequest(GBDevice.State.INITIALIZED)); } + private void loadNotificationConfigurations(){ + this.notificationConfigurations = new NotificationHRConfiguration[]{ + new NotificationHRConfiguration("generic", 0), + }; + } + private void loadWidgets() { CustomWidget ethWidget = new CustomWidget(0, 63); ethWidget.addElement(new CustomWidgetElement(CustomWidgetElement.WidgetElementType.TYPE_TEXT, "date", "-", CustomWidgetElement.X_CENTER, CustomWidgetElement.Y_UPPER_HALF)); @@ -306,6 +322,12 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter { String sender = notificationSpec.sender; if (sender == null) sender = notificationSpec.sourceName; try { + for (NotificationHRConfiguration configuration : this.notificationConfigurations){ + if(configuration.getPackageName().equals(notificationSpec.sourceAppId)){ + queueWrite(new PlayNotificationRequest(notificationSpec.sourceAppId, notificationSpec.sourceName, notificationSpec.body, this)); + return true; + } + } queueWrite(new PlayNotificationRequest("generic", notificationSpec.sourceName, notificationSpec.body, this)); }catch (Exception e){ e.printStackTrace(); @@ -437,4 +459,8 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter { public void setCommuteMenuMessage(String message, boolean finished) { queueWrite(new SetCommuteMenuMessage(message, finished, this)); } + + public byte getJsonIndex() { + return jsonIndex++; + } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/buttons/ButtonConfigurationPutRequest.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/buttons/ButtonConfigurationPutRequest.java index 043a63eeb..8e6f77b85 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/buttons/ButtonConfigurationPutRequest.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/buttons/ButtonConfigurationPutRequest.java @@ -7,12 +7,13 @@ 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.adapter.fossil_hr.FossilHRWatchAdapter; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.json.JsonPutRequest; import nodomain.freeyourgadget.gadgetbridge.util.GB; public class ButtonConfigurationPutRequest extends JsonPutRequest { - public ButtonConfigurationPutRequest(String[] menuItems, FossilWatchAdapter adapter) { - super((short) 0x0500, createObject(menuItems), adapter); + public ButtonConfigurationPutRequest(String[] menuItems, FossilHRWatchAdapter adapter) { + super(createObject(menuItems), adapter); } private static JSONObject createObject(String[] menuItems) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/image/ImagesSetRequest.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/image/ImagesSetRequest.java index e7abf0050..bf854b85c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/image/ImagesSetRequest.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/image/ImagesSetRequest.java @@ -5,11 +5,12 @@ 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.adapter.fossil_hr.FossilHRWatchAdapter; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.json.JsonPutRequest; public class ImagesSetRequest extends JsonPutRequest { - public ImagesSetRequest(AssetImage[] images, FossilWatchAdapter adapter) { - super((short) 0x0503, prepareObject(images), adapter); + public ImagesSetRequest(AssetImage[] images, FossilHRWatchAdapter adapter) { + super(prepareObject(images), adapter); } private static JSONObject prepareObject(AssetImage[] images){ diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/json/JsonPutRequest.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/json/JsonPutRequest.java index 5359355cf..40edc79c8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/json/JsonPutRequest.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/json/JsonPutRequest.java @@ -3,11 +3,12 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fo import org.json.JSONObject; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil.FossilWatchAdapter; +import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil_hr.FossilHRWatchAdapter; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.file.FilePutRequest; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.file.FilePutRawRequest; public class JsonPutRequest extends FilePutRawRequest { - public JsonPutRequest(short handle, JSONObject object, FossilWatchAdapter adapter) { - super(handle, object.toString().getBytes(), adapter); + public JsonPutRequest(JSONObject object, FossilHRWatchAdapter adapter) { + super((short)(0x0500 | adapter.getJsonIndex()), object.toString().getBytes(), adapter); } } 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 index 4366e186e..8c6533eac 100644 --- 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 @@ -4,11 +4,12 @@ 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.adapter.fossil_hr.FossilHRWatchAdapter; 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); + public SetCommuteMenuMessage(String message, boolean finished, FossilHRWatchAdapter adapter) { + super(createObject(message, finished), adapter); } private static JSONObject createObject(String message, boolean finished) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/widget/WidgetsPutRequest.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/widget/WidgetsPutRequest.java index 5553cd8e4..d911b274f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/widget/WidgetsPutRequest.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/widget/WidgetsPutRequest.java @@ -5,12 +5,13 @@ 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.adapter.fossil_hr.FossilHRWatchAdapter; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.file.FilePutRawRequest; import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.json.JsonPutRequest; public class WidgetsPutRequest extends JsonPutRequest { - public WidgetsPutRequest(Widget[] widgets, FossilWatchAdapter adapter) { - super((short) 0x0501, prepareFile(widgets), adapter); + public WidgetsPutRequest(Widget[] widgets, FossilHRWatchAdapter adapter) { + super(prepareFile(widgets), adapter); } private static JSONObject prepareFile(Widget[] widgets){