From e69fac9704afac2774cbce6be0273ae576e557e0 Mon Sep 17 00:00:00 2001 From: Daniele Gobbetti Date: Fri, 18 Mar 2016 16:47:14 +0100 Subject: [PATCH] Do not show the configure menu item for non configurable watch apps. --- .../gadgetbridge/activities/AppManagerActivity.java | 8 +++++++- .../freeyourgadget/gadgetbridge/impl/GBDeviceApp.java | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppManagerActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppManagerActivity.java index 5955ce24..d7297120 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppManagerActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/AppManagerActivity.java @@ -102,11 +102,14 @@ public class AppManagerActivity extends Activity { for (File file : files) { if (file.getName().endsWith(".pbw")) { String baseName = file.getName().substring(0, file.getName().length() - 4); + //metadata File jsonFile = new File(cachePath, baseName + ".json"); + //configuration + File configFile = new File(cachePath, baseName + "_config.js"); try { String jsonstring = FileUtils.getStringFromFile(jsonFile); JSONObject json = new JSONObject(jsonstring); - cachedAppList.add(new GBDeviceApp(json)); + cachedAppList.add(new GBDeviceApp(json, configFile.exists())); } catch (Exception e) { LOG.warn("could not read json file for " + baseName, e.getMessage(), e); cachedAppList.add(new GBDeviceApp(UUID.fromString(baseName), baseName, "N/A", "", GBDeviceApp.Type.UNKNOWN)); @@ -178,6 +181,9 @@ public class AppManagerActivity extends Activity { } else if (PebbleProtocol.UUID_PEBBLE_HEALTH.equals(selectedApp.getUUID())) { menu.removeItem(R.id.appmanager_app_delete); } + if (!selectedApp.isConfigurable()) { + menu.removeItem(R.id.appmanager_app_configure); + } menu.setHeaderTitle(selectedApp.getName()); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBDeviceApp.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBDeviceApp.java index 9743a083..d2280d17 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBDeviceApp.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBDeviceApp.java @@ -12,6 +12,7 @@ public class GBDeviceApp { private final UUID uuid; private final Type type; private final boolean inCache; + private final boolean configurable; public GBDeviceApp(UUID uuid, String name, String creator, String version, Type type) { this.uuid = uuid; @@ -21,9 +22,10 @@ public class GBDeviceApp { this.type = type; //FIXME: do not assume this.inCache = false; + this.configurable = false; } - public GBDeviceApp(JSONObject json) { + public GBDeviceApp(JSONObject json, boolean configurable) { UUID uuid = UUID.fromString("00000000-0000-0000-0000-000000000000"); String name = ""; String creator = ""; @@ -47,6 +49,7 @@ public class GBDeviceApp { this.type = type; //FIXME: do not assume this.inCache = true; + this.configurable = configurable; } public boolean isInCache() { @@ -94,4 +97,8 @@ public class GBDeviceApp { } return json; } + + public boolean isConfigurable() { + return configurable; + } }