diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/appmanager/AbstractAppManagerFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/appmanager/AbstractAppManagerFragment.java index 451d505e6..50b86cedb 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/appmanager/AbstractAppManagerFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/appmanager/AbstractAppManagerFragment.java @@ -283,6 +283,10 @@ public abstract class AbstractAppManagerFragment extends Fragment { menu.removeItem(R.id.appmanager_health_activate); menu.removeItem(R.id.appmanager_health_deactivate); } + if (!PebbleProtocol.UUID_WORKOUT.equals(selectedApp.getUUID())) { + menu.removeItem(R.id.appmanager_hrm_activate); + menu.removeItem(R.id.appmanager_hrm_deactivate); + } if (selectedApp.getType() == GBDeviceApp.Type.APP_SYSTEM || selectedApp.getType() == GBDeviceApp.Type.WATCHFACE_SYSTEM) { menu.removeItem(R.id.appmanager_app_delete); } @@ -355,7 +359,11 @@ public abstract class AbstractAppManagerFragment extends Fragment { case R.id.appmanager_health_activate: GBApplication.deviceService().onInstallApp(Uri.parse("fake://health")); return true; + case R.id.appmanager_hrm_activate: + GBApplication.deviceService().onInstallApp(Uri.parse("fake://hrm")); + return true; case R.id.appmanager_health_deactivate: + case R.id.appmanager_hrm_deactivate: GBApplication.deviceService().onAppDelete(selectedApp.getUUID()); return true; case R.id.appmanager_app_configure: diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java index a67d44f12..32238019d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java @@ -596,6 +596,10 @@ class PebbleIoThread extends GBDeviceIoThread { write(mPebbleProtocol.encodeSetSaneDistanceUnit(true)); return; } + if (uri.equals(Uri.parse("fake://hrm"))) { + write(mPebbleProtocol.encodeActivateHRM(true)); + return; + } String platformName = PebbleUtils.getPlatformName(gbDevice.getModel()); 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 34c85a6dc..530badcd6 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 @@ -721,10 +721,8 @@ public class PebbleProtocol extends GBDeviceProtocol { return buf.array(); } - public byte[] encodeActivateHealth(boolean activate) { + byte[] encodeActivateHealth(boolean activate) { byte[] blob; - byte command; - command = BLOBDB_INSERT; if (activate) { ByteBuffer buf = ByteBuffer.allocate(9); @@ -744,10 +742,10 @@ public class PebbleProtocol extends GBDeviceProtocol { } else { blob = new byte[]{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; } - return encodeBlobdb("activityPreferences", command, BLOBDB_PREFERENCES, blob); + return encodeBlobdb("activityPreferences", BLOBDB_INSERT, BLOBDB_PREFERENCES, blob); } - public byte[] encodeSetSaneDistanceUnit(boolean sane) { + byte[] encodeSetSaneDistanceUnit(boolean sane) { byte value; if (sane) { value = 0x00; @@ -757,7 +755,13 @@ public class PebbleProtocol extends GBDeviceProtocol { return encodeBlobdb("unitsDistance", BLOBDB_INSERT, BLOBDB_PREFERENCES, new byte[]{value}); } - public byte[] encodeReportDataLogSessions() { + + byte[] encodeActivateHRM(boolean activate) { + return encodeBlobdb("hrmPreferences", BLOBDB_INSERT, BLOBDB_PREFERENCES, + activate ? new byte[]{0x01} : new byte[]{0x00}); + } + + byte[] encodeReportDataLogSessions() { return encodeSimpleMessage(ENDPOINT_DATALOG, DATALOG_REPORTSESSIONS); } @@ -1249,6 +1253,9 @@ public class PebbleProtocol extends GBDeviceProtocol { if (UUID_PEBBLE_HEALTH.equals(uuid)) { return encodeActivateHealth(false); } + if (UUID_WORKOUT.equals(uuid)) { + return encodeActivateHRM(false); + } return encodeBlobdb(uuid, BLOBDB_DELETE, BLOBDB_APP, null); } else { ByteBuffer buf = ByteBuffer.allocate(LENGTH_PREFIX + LENGTH_REMOVEAPP_2X); diff --git a/app/src/main/res/menu/appmanager_context.xml b/app/src/main/res/menu/appmanager_context.xml index 8a2cadca5..436454388 100644 --- a/app/src/main/res/menu/appmanager_context.xml +++ b/app/src/main/res/menu/appmanager_context.xml @@ -15,6 +15,12 @@ + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7981aa246..330d0ad78 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -28,6 +28,8 @@ Search in Pebble Appstore Activate Deactivate + Activate HRM + Deactivate HRM Configure Move to top