From f387f7c96b5b6f3408d7dabbc6026983985c1e66 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Thu, 17 Dec 2015 00:05:42 +0100 Subject: [PATCH] increase canned replies from 8 to 16 NOTE: Total allowed bytes for all replies = 512 - (reply count - 1) TODO: - check with Firmware 2.9.1 - remove last reply that exceeds the 512 bytes limit completly (else it will be partly truncated) --- .../service/DeviceCommunicationService.java | 2 +- .../devices/pebble/PebbleProtocol.java | 4 ++-- app/src/main/res/xml/preferences.xml | 24 +++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java index 55c7d9eea..f84014e9b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceCommunicationService.java @@ -232,7 +232,7 @@ public class DeviceCommunicationService extends Service { // I would rather like to save that as an array in ShadredPreferences // this would work but I dont know how to do the same in the Settings Activity's xml ArrayList replies = new ArrayList<>(); - for (int i = 1; i <= 8; i++) { + for (int i = 1; i <= 16; i++) { String reply = sharedPrefs.getString("canned_reply_" + i, null); if (reply != null && !reply.equals("")) { replies.add(reply); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java index 7365ff72d..4a6686b75 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleProtocol.java @@ -581,7 +581,7 @@ public class PebbleProtocol extends GBDeviceProtocol { } - if (cannedReplies != null) { + if (cannedReplies != null && replies_length > 0) { buf.put((byte) 0x05); buf.put((byte) 0x03); // reply action buf.put((byte) 0x02); // number attributes @@ -835,7 +835,7 @@ public class PebbleProtocol extends GBDeviceProtocol { buf.put(mute_string.getBytes()); } - if (cannedReplies != null) { + if (cannedReplies != null && replies_length > 0) { buf.put((byte) 0x05); buf.put((byte) 0x03); // reply action buf.put((byte) 0x02); // number attributes diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index cb0f7082e..eaabe9724 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -93,6 +93,30 @@ + + + + + + + +