1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-25 03:16:51 +01:00

Pebble 2: allow to disable/enable HRM in context menu of Workout app

Okay this might be stupid  since Workout seems to work also works without HRM!
I assumed (wrongly) that I will disable Workout by disabling HRM

anyway, better than not being able to toggle it at all!
This commit is contained in:
Andreas Shimokawa 2016-11-15 12:17:51 +01:00
parent 4b7f47ba6c
commit 82a47022fa
5 changed files with 33 additions and 6 deletions

View File

@ -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:

View File

@ -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());

View File

@ -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);

View File

@ -15,6 +15,12 @@
<item
android:id="@+id/appmanager_health_deactivate"
android:title="@string/appmanager_health_deactivate"/>
<item
android:id="@+id/appmanager_hrm_activate"
android:title="@string/appmanager_hrm_activate"/>
<item
android:id="@+id/appmanager_hrm_deactivate"
android:title="@string/appmanager_hrm_deactivate"/>
<item
android:id="@+id/appmanager_app_configure"
android:title="@string/app_configure"/>

View File

@ -28,6 +28,8 @@
<string name="appmanager_app_openinstore">Search in Pebble Appstore</string>
<string name="appmanager_health_activate">Activate</string>
<string name="appmanager_health_deactivate">Deactivate</string>
<string name="appmanager_hrm_activate">Activate HRM</string>
<string name="appmanager_hrm_deactivate">Deactivate HRM</string>
<string name="app_configure">Configure</string>
<string name="app_move_to_top">Move to top</string>