1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-25 18:15:49 +01:00

Pebble: In AppManager mark cached apps with (C), installed apps on FW 2.x with (D) and (CD) if both is the case

Also always add pebble health as a system app to the list on devices that have it (no need to enable untested features for that anymore)
This commit is contained in:
Andreas Shimokawa 2016-05-22 22:48:45 +02:00
parent 5a20d7ec81
commit 30883ab244
3 changed files with 40 additions and 12 deletions

View File

@ -22,6 +22,7 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
@ -47,7 +48,6 @@ public class AppManagerActivity extends GBActivity {
if (action.equals(GBApplication.ACTION_QUIT)) {
finish();
} else if (action.equals(ACTION_REFRESH_APPLIST)) {
//appList.clear();
int appCount = intent.getIntExtra("app_count", 0);
for (Integer i = 0; i < appCount; i++) {
String appName = intent.getStringExtra("app_name" + i.toString());
@ -55,11 +55,21 @@ public class AppManagerActivity extends GBActivity {
UUID uuid = UUID.fromString(intent.getStringExtra("app_uuid" + i.toString()));
GBDeviceApp.Type appType = GBDeviceApp.Type.values()[intent.getIntExtra("app_type" + i.toString(), 0)];
appList.add(new GBDeviceApp(uuid, appName, appCreator, "", appType));
boolean found = false;
for (final ListIterator<GBDeviceApp> iter = appList.listIterator(); iter.hasNext(); ) {
final GBDeviceApp app = iter.next();
if (app.getName().equals(appName) && app.getCreator().equals(appCreator)) {
app.setOnDevice(true);
iter.set(app);
found = true;
break;
}
}
if (!found) {
GBDeviceApp app = new GBDeviceApp(uuid, appName, appCreator, "", appType);
app.setOnDevice(true);
appList.add(app);
}
if (prefs.getBoolean("pebble_force_untested", false)) {
appList.addAll(getSystemApps());
}
mGBDeviceAppAdapter.notifyDataSetChanged();
@ -76,8 +86,10 @@ public class AppManagerActivity extends GBActivity {
private List<GBDeviceApp> getSystemApps() {
List<GBDeviceApp> systemApps = new ArrayList<>();
if (prefs.getBoolean("pebble_force_untested", false)) {
systemApps.add(new GBDeviceApp(UUID.fromString("4dab81a6-d2fc-458a-992c-7a1f3b96a970"), "Sports (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM));
systemApps.add(new GBDeviceApp(UUID.fromString("cf1e816a-9db0-4511-bbb8-f60c48ca8fac"), "Golf (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM));
}
if (mGBDevice != null && !"aplite".equals(PebbleUtils.getPlatformName(mGBDevice.getHardwareVersion()))) {
systemApps.add(new GBDeviceApp(PebbleProtocol.UUID_PEBBLE_HEALTH, "Health (System)", "Pebble Inc.", "", GBDeviceApp.Type.APP_SYSTEM));
}
@ -149,9 +161,7 @@ public class AppManagerActivity extends GBActivity {
appList.addAll(getCachedApps());
if (prefs.getBoolean("pebble_force_untested", false)) {
appList.addAll(getSystemApps());
}
IntentFilter filter = new IntentFilter();
filter.addAction(GBApplication.ACTION_QUIT);

View File

@ -41,7 +41,15 @@ public class GBDeviceAppAdapter extends ArrayAdapter<GBDeviceApp> {
ImageView deviceImageView = (ImageView) view.findViewById(R.id.item_image);
deviceAppVersionAuthorLabel.setText(getContext().getString(R.string.appversion_by_creator, deviceApp.getVersion(), deviceApp.getCreator()));
deviceAppNameLabel.setText(deviceApp.getName());
// FIXME: replace with small icons
String appNameLabelText = deviceApp.getName();
if (deviceApp.isInCache() || deviceApp.isOnDevice()) {
appNameLabelText += " (" + (deviceApp.isInCache() ? "C" : "")
+ (deviceApp.isOnDevice() ? "D" : "") + ")";
}
deviceAppNameLabel.setText(appNameLabelText);
switch (deviceApp.getType()) {
case APP_GENERIC:
deviceImageView.setImageResource(R.drawable.ic_watchapp);

View File

@ -12,6 +12,7 @@ public class GBDeviceApp {
private final UUID uuid;
private final Type type;
private final boolean inCache;
private boolean isOnDevice;
private final boolean configurable;
public GBDeviceApp(UUID uuid, String name, String creator, String version, Type type) {
@ -23,6 +24,7 @@ public class GBDeviceApp {
//FIXME: do not assume
this.inCache = false;
this.configurable = false;
this.isOnDevice = false;
}
public GBDeviceApp(JSONObject json, boolean configurable) {
@ -52,10 +54,18 @@ public class GBDeviceApp {
this.configurable = configurable;
}
public void setOnDevice(boolean isOnDevice) {
this.isOnDevice = isOnDevice;
}
public boolean isInCache() {
return inCache;
}
public boolean isOnDevice() {
return isOnDevice;
}
public String getName() {
return name;
}