mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-10 12:09:27 +01:00
Pebble: allow to delete apps from pbw cache
Also remove delete entries from all system apps' context menus (not only health)
This commit is contained in:
parent
30883ab244
commit
80cf9fa8fe
@ -58,7 +58,7 @@ public class AppManagerActivity extends GBActivity {
|
|||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (final ListIterator<GBDeviceApp> iter = appList.listIterator(); iter.hasNext(); ) {
|
for (final ListIterator<GBDeviceApp> iter = appList.listIterator(); iter.hasNext(); ) {
|
||||||
final GBDeviceApp app = iter.next();
|
final GBDeviceApp app = iter.next();
|
||||||
if (app.getName().equals(appName) && app.getCreator().equals(appCreator)) {
|
if (app.getUUID().equals(uuid)) {
|
||||||
app.setOnDevice(true);
|
app.setOnDevice(true);
|
||||||
iter.set(app);
|
iter.set(app);
|
||||||
found = true;
|
found = true;
|
||||||
@ -181,11 +181,13 @@ public class AppManagerActivity extends GBActivity {
|
|||||||
|
|
||||||
if (!selectedApp.isInCache()) {
|
if (!selectedApp.isInCache()) {
|
||||||
menu.removeItem(R.id.appmanager_app_reinstall);
|
menu.removeItem(R.id.appmanager_app_reinstall);
|
||||||
|
menu.removeItem(R.id.appmanager_app_delete_cache);
|
||||||
}
|
}
|
||||||
if (!PebbleProtocol.UUID_PEBBLE_HEALTH.equals(selectedApp.getUUID())) {
|
if (!PebbleProtocol.UUID_PEBBLE_HEALTH.equals(selectedApp.getUUID())) {
|
||||||
menu.removeItem(R.id.appmanager_health_activate);
|
menu.removeItem(R.id.appmanager_health_activate);
|
||||||
menu.removeItem(R.id.appmanager_health_deactivate);
|
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);
|
menu.removeItem(R.id.appmanager_app_delete);
|
||||||
}
|
}
|
||||||
if (!selectedApp.isConfigurable()) {
|
if (!selectedApp.isConfigurable()) {
|
||||||
@ -194,19 +196,45 @@ public class AppManagerActivity extends GBActivity {
|
|||||||
menu.setHeaderTitle(selectedApp.getName());
|
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
|
@Override
|
||||||
public boolean onContextItemSelected(MenuItem item) {
|
public boolean onContextItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.appmanager_health_deactivate:
|
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:
|
case R.id.appmanager_app_delete:
|
||||||
GBApplication.deviceService().onAppDelete(selectedApp.getUUID());
|
UUID uuid = selectedApp.getUUID();
|
||||||
|
GBApplication.deviceService().onAppDelete(uuid);
|
||||||
|
removeAppFromList(uuid);
|
||||||
return true;
|
return true;
|
||||||
case R.id.appmanager_app_reinstall:
|
case R.id.appmanager_app_reinstall:
|
||||||
File cachePath;
|
File cachePath;
|
||||||
try {
|
try {
|
||||||
cachePath = new File(FileUtils.getExternalFilesDir().getPath() + "/pbw-cache/" + selectedApp.getUUID() + ".pbw");
|
cachePath = new File(FileUtils.getExternalFilesDir().getPath() + "/pbw-cache/" + selectedApp.getUUID() + ".pbw");
|
||||||
} catch (IOException e) {
|
} 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;
|
return true;
|
||||||
}
|
}
|
||||||
GBApplication.deviceService().onInstallApp(Uri.fromFile(cachePath));
|
GBApplication.deviceService().onInstallApp(Uri.fromFile(cachePath));
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
<item
|
<item
|
||||||
android:id="@+id/appmanager_app_delete"
|
android:id="@+id/appmanager_app_delete"
|
||||||
android:title="@string/appmananger_app_delete"/>
|
android:title="@string/appmananger_app_delete"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/appmanager_app_delete_cache"
|
||||||
|
android:title="@string/appmananger_app_delete_cache"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/appmanager_health_activate"
|
android:id="@+id/appmanager_health_activate"
|
||||||
android:title="@string/appmanager_health_activate"/>
|
android:title="@string/appmanager_health_activate"/>
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
<!-- Strings related to AppManager -->
|
<!-- Strings related to AppManager -->
|
||||||
<string name="title_activity_appmanager">App Manager</string>
|
<string name="title_activity_appmanager">App Manager</string>
|
||||||
<string name="appmananger_app_delete">Delete</string>
|
<string name="appmananger_app_delete">Delete</string>
|
||||||
|
<string name="appmananger_app_delete_cache">Delete and remove from cache</string>
|
||||||
|
|
||||||
<!-- Strings related to AppBlacklist -->
|
<!-- Strings related to AppBlacklist -->
|
||||||
<string name="title_activity_appblacklist">Notification Blacklist</string>
|
<string name="title_activity_appblacklist">Notification Blacklist</string>
|
||||||
@ -251,5 +252,4 @@
|
|||||||
<string name="charts_legend_heartrate">Heart Rate</string>
|
<string name="charts_legend_heartrate">Heart Rate</string>
|
||||||
<string name="live_activity_heart_rate">Heart Rate</string>
|
<string name="live_activity_heart_rate">Heart Rate</string>
|
||||||
<string name="pref_title_general_autocreonnect">Reconnect automatically</string>
|
<string name="pref_title_general_autocreonnect">Reconnect automatically</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user