In Control Center, do not show alarm configuration in context menu if device does not support it

This commit is contained in:
Andreas Shimokawa 2016-03-20 17:53:55 +01:00
parent c5a7ca4b5b
commit dbeded8d04
5 changed files with 25 additions and 0 deletions

View File

@ -212,6 +212,9 @@ public class ControlCenter extends Activity {
if (!coordinator.supportsScreenshots()) { if (!coordinator.supportsScreenshots()) {
menu.removeItem(R.id.controlcenter_take_screenshot); menu.removeItem(R.id.controlcenter_take_screenshot);
} }
if (!coordinator.supportsAlarmConfiguration()) {
menu.removeItem(R.id.controlcenter_configure_alarms);
}
if (selectedDevice.getState() == GBDevice.State.NOT_CONNECTED) { if (selectedDevice.getState() == GBDevice.State.NOT_CONNECTED) {
menu.removeItem(R.id.controlcenter_disconnect); menu.removeItem(R.id.controlcenter_disconnect);

View File

@ -100,4 +100,11 @@ public interface DeviceCoordinator {
* @return * @return
*/ */
boolean supportsScreenshots(); boolean supportsScreenshots();
/**
* Returns true if this device/coordinator supports settig alarms.
*
* @return
*/
boolean supportsAlarmConfiguration();
} }

View File

@ -83,4 +83,9 @@ public class UnknownDeviceCoordinator extends AbstractDeviceCoordinator {
public boolean supportsScreenshots() { public boolean supportsScreenshots() {
return false; return false;
} }
@Override
public boolean supportsAlarmConfiguration() {
return false;
}
} }

View File

@ -74,6 +74,11 @@ public class MiBandCoordinator extends AbstractDeviceCoordinator {
return false; return false;
} }
@Override
public boolean supportsAlarmConfiguration() {
return true;
}
public static boolean hasValidUserInfo() { public static boolean hasValidUserInfo() {
String dummyMacAddress = MiBandService.MAC_ADDRESS_FILTER_1_1A + ":00:00:00"; String dummyMacAddress = MiBandService.MAC_ADDRESS_FILTER_1_1A + ":00:00:00";
try { try {

View File

@ -76,4 +76,9 @@ public class PebbleCoordinator extends AbstractDeviceCoordinator {
public boolean supportsScreenshots() { public boolean supportsScreenshots() {
return true; return true;
} }
@Override
public boolean supportsAlarmConfiguration() {
return false;
}
} }