mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-25 10:05:49 +01:00
Merge branch 'master' into feature-sunrise
This commit is contained in:
commit
efe5e546fd
@ -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));
|
||||
}
|
||||
|
||||
if (prefs.getBoolean("pebble_force_untested", false)) {
|
||||
appList.addAll(getSystemApps());
|
||||
boolean found = false;
|
||||
for (final ListIterator<GBDeviceApp> iter = appList.listIterator(); iter.hasNext(); ) {
|
||||
final GBDeviceApp app = iter.next();
|
||||
if (app.getUUID().equals(uuid)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
mGBDeviceAppAdapter.notifyDataSetChanged();
|
||||
@ -76,8 +86,10 @@ public class AppManagerActivity extends GBActivity {
|
||||
|
||||
private List<GBDeviceApp> getSystemApps() {
|
||||
List<GBDeviceApp> systemApps = new ArrayList<>();
|
||||
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 (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());
|
||||
}
|
||||
appList.addAll(getSystemApps());
|
||||
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(GBApplication.ACTION_QUIT);
|
||||
@ -171,11 +181,13 @@ public class AppManagerActivity extends GBActivity {
|
||||
|
||||
if (!selectedApp.isInCache()) {
|
||||
menu.removeItem(R.id.appmanager_app_reinstall);
|
||||
menu.removeItem(R.id.appmanager_app_delete_cache);
|
||||
}
|
||||
if (!PebbleProtocol.UUID_PEBBLE_HEALTH.equals(selectedApp.getUUID())) {
|
||||
menu.removeItem(R.id.appmanager_health_activate);
|
||||
menu.removeItem(R.id.appmanager_health_deactivate);
|
||||
} else if (PebbleProtocol.UUID_PEBBLE_HEALTH.equals(selectedApp.getUUID())) {
|
||||
}
|
||||
if (selectedApp.getType() == GBDeviceApp.Type.APP_SYSTEM) {
|
||||
menu.removeItem(R.id.appmanager_app_delete);
|
||||
}
|
||||
if (!selectedApp.isConfigurable()) {
|
||||
@ -184,19 +196,45 @@ public class AppManagerActivity extends GBActivity {
|
||||
menu.setHeaderTitle(selectedApp.getName());
|
||||
}
|
||||
|
||||
private void removeAppFromList(UUID uuid) {
|
||||
for (final ListIterator<GBDeviceApp> iter = appList.listIterator(); iter.hasNext(); ) {
|
||||
final GBDeviceApp app = iter.next();
|
||||
if (app.getUUID().equals(uuid)) {
|
||||
iter.remove();
|
||||
mGBDeviceAppAdapter.notifyDataSetChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.appmanager_health_deactivate:
|
||||
case R.id.appmanager_app_delete_cache:
|
||||
File cachedFile = null;
|
||||
boolean deleteSuccess = true;
|
||||
try {
|
||||
cachedFile = new File(FileUtils.getExternalFilesDir().getPath() + "/pbw-cache/" + selectedApp.getUUID() + ".pbw");
|
||||
deleteSuccess = cachedFile.delete();
|
||||
} catch (IOException e) {
|
||||
LOG.warn("could not get external dir while trying to access pbw cache.");
|
||||
}
|
||||
if (!deleteSuccess) {
|
||||
LOG.warn("could not delete file from pbw cache: " + cachedFile.toString());
|
||||
}
|
||||
// fall through
|
||||
case R.id.appmanager_app_delete:
|
||||
GBApplication.deviceService().onAppDelete(selectedApp.getUUID());
|
||||
UUID uuid = selectedApp.getUUID();
|
||||
GBApplication.deviceService().onAppDelete(uuid);
|
||||
removeAppFromList(uuid);
|
||||
return true;
|
||||
case R.id.appmanager_app_reinstall:
|
||||
File cachePath;
|
||||
try {
|
||||
cachePath = new File(FileUtils.getExternalFilesDir().getPath() + "/pbw-cache/" + selectedApp.getUUID() + ".pbw");
|
||||
} catch (IOException e) {
|
||||
LOG.warn("could not get external dir while reading pbw cache.");
|
||||
LOG.warn("could not get external dir while trying to access pbw cache.");
|
||||
return true;
|
||||
}
|
||||
GBApplication.deviceService().onInstallApp(Uri.fromFile(cachePath));
|
||||
|
@ -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);
|
||||
|
@ -129,10 +129,6 @@ public class PBWInstallHandler implements InstallHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!device.getFirmwareVersion().startsWith("v3")) {
|
||||
return;
|
||||
}
|
||||
|
||||
File destDir;
|
||||
GBDeviceApp app = mPBWReader.getGBDeviceApp();
|
||||
try {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -6,6 +6,9 @@
|
||||
<item
|
||||
android:id="@+id/appmanager_app_delete"
|
||||
android:title="@string/appmananger_app_delete"/>
|
||||
<item
|
||||
android:id="@+id/appmanager_app_delete_cache"
|
||||
android:title="@string/appmananger_app_delete_cache"/>
|
||||
<item
|
||||
android:id="@+id/appmanager_health_activate"
|
||||
android:title="@string/appmanager_health_activate"/>
|
||||
|
@ -17,6 +17,7 @@
|
||||
<!-- Strings related to AppManager -->
|
||||
<string name="title_activity_appmanager">App Manager</string>
|
||||
<string name="appmananger_app_delete">Delete</string>
|
||||
<string name="appmananger_app_delete_cache">Delete and remove from cache</string>
|
||||
|
||||
<!-- Strings related to AppBlacklist -->
|
||||
<string name="title_activity_appblacklist">Notification Blacklist</string>
|
||||
@ -255,5 +256,5 @@
|
||||
<string name="updatefirmwareoperation_firmware_not_sent">Firmware not sent</string>
|
||||
<string name="charts_legend_heartrate">Heart Rate</string>
|
||||
<string name="live_activity_heart_rate">Heart Rate</string>
|
||||
|
||||
<string name="pref_title_general_autocreonnect">Reconnect automatically</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user