From c2582e1e1fe372476b43a2fc36307dc19a6a57de Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Mon, 22 Jun 2015 22:16:19 +0200 Subject: [PATCH] Not not display useless menu items when device is not connected Also remove "fetch activity data" from pebble context menu, which currently does nothing Closes #75 --- .../gadgetbridge/ControlCenter.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ControlCenter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ControlCenter.java index 64a6b6f7d..9d506abb8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ControlCenter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/ControlCenter.java @@ -1,7 +1,6 @@ package nodomain.freeyourgadget.gadgetbridge; import android.app.Activity; -import android.app.AlertDialog; import android.app.ProgressDialog; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; @@ -170,8 +169,17 @@ public class ControlCenter extends Activity { // no context menu when device is busy return; } - getMenuInflater().inflate( - R.menu.controlcenter_context, menu); + getMenuInflater().inflate(R.menu.controlcenter_context, menu); + + if (!selectedDevice.isConnected() || selectedDevice.getType() == DeviceType.PEBBLE) { + menu.removeItem(R.id.controlcenter_fetch_activity_data); + } + + if (!selectedDevice.isConnected()) { + menu.removeItem(R.id.controlcenter_disconnect); + menu.removeItem(R.id.controlcenter_find_device); + } + menu.setHeaderTitle(selectedDevice.getName()); } @@ -212,7 +220,7 @@ public class ControlCenter extends Activity { new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { - findDevice(false); + findDevice(false); } }); }