From dbeded8d04451ca70e81ef285c5eb2e2fb2763a3 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sun, 20 Mar 2016 17:53:55 +0100 Subject: [PATCH] In Control Center, do not show alarm configuration in context menu if device does not support it --- .../gadgetbridge/activities/ControlCenter.java | 3 +++ .../gadgetbridge/devices/DeviceCoordinator.java | 7 +++++++ .../gadgetbridge/devices/UnknownDeviceCoordinator.java | 5 +++++ .../gadgetbridge/devices/miband/MiBandCoordinator.java | 5 +++++ .../gadgetbridge/devices/pebble/PebbleCoordinator.java | 5 +++++ 5 files changed, 25 insertions(+) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ControlCenter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ControlCenter.java index e4b04a6b..13b04486 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ControlCenter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ControlCenter.java @@ -212,6 +212,9 @@ public class ControlCenter extends Activity { if (!coordinator.supportsScreenshots()) { menu.removeItem(R.id.controlcenter_take_screenshot); } + if (!coordinator.supportsAlarmConfiguration()) { + menu.removeItem(R.id.controlcenter_configure_alarms); + } if (selectedDevice.getState() == GBDevice.State.NOT_CONNECTED) { menu.removeItem(R.id.controlcenter_disconnect); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/DeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/DeviceCoordinator.java index fc5ea93e..e1bfe822 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/DeviceCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/DeviceCoordinator.java @@ -100,4 +100,11 @@ public interface DeviceCoordinator { * @return */ boolean supportsScreenshots(); + + /** + * Returns true if this device/coordinator supports settig alarms. + * + * @return + */ + boolean supportsAlarmConfiguration(); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/UnknownDeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/UnknownDeviceCoordinator.java index 052c1730..7d9b88d8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/UnknownDeviceCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/UnknownDeviceCoordinator.java @@ -83,4 +83,9 @@ public class UnknownDeviceCoordinator extends AbstractDeviceCoordinator { public boolean supportsScreenshots() { return false; } + + @Override + public boolean supportsAlarmConfiguration() { + return false; + } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandCoordinator.java index 868cda13..3ecf4c65 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandCoordinator.java @@ -74,6 +74,11 @@ public class MiBandCoordinator extends AbstractDeviceCoordinator { return false; } + @Override + public boolean supportsAlarmConfiguration() { + return true; + } + public static boolean hasValidUserInfo() { String dummyMacAddress = MiBandService.MAC_ADDRESS_FILTER_1_1A + ":00:00:00"; try { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PebbleCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PebbleCoordinator.java index a76534d1..f7017d7b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PebbleCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pebble/PebbleCoordinator.java @@ -76,4 +76,9 @@ public class PebbleCoordinator extends AbstractDeviceCoordinator { public boolean supportsScreenshots() { return true; } + + @Override + public boolean supportsAlarmConfiguration() { + return false; + } }