Do not show the configure menu item for non configurable watch apps.

This commit is contained in:
Daniele Gobbetti 2016-03-18 16:47:14 +01:00
parent 1603d60144
commit e69fac9704
2 changed files with 15 additions and 2 deletions

View File

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

View File

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