mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-02-17 12:56:48 +01:00
fix saving app notification/pebble blacklist preferences on import
This commit is contained in:
parent
a8da4cf6d1
commit
ed9c746059
@ -454,6 +454,10 @@ public class GBApplication extends Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setAppsNotifBlackList(Set<String> packageNames) {
|
public static void setAppsNotifBlackList(Set<String> packageNames) {
|
||||||
|
setAppsNotifBlackList(packageNames, sharedPrefs.edit());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setAppsNotifBlackList(Set<String> packageNames, SharedPreferences.Editor editor) {
|
||||||
if (packageNames == null) {
|
if (packageNames == null) {
|
||||||
GB.log("Set null apps_notification_blacklist", GB.INFO, null);
|
GB.log("Set null apps_notification_blacklist", GB.INFO, null);
|
||||||
apps_notification_blacklist = new HashSet<>();
|
apps_notification_blacklist = new HashSet<>();
|
||||||
@ -461,7 +465,7 @@ public class GBApplication extends Application {
|
|||||||
apps_notification_blacklist = new HashSet<>(packageNames);
|
apps_notification_blacklist = new HashSet<>(packageNames);
|
||||||
}
|
}
|
||||||
GB.log("New apps_notification_blacklist has " + apps_notification_blacklist.size() + " entries", GB.INFO, null);
|
GB.log("New apps_notification_blacklist has " + apps_notification_blacklist.size() + " entries", GB.INFO, null);
|
||||||
saveAppsNotifBlackList();
|
saveAppsNotifBlackList(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadAppsNotifBlackList() {
|
private static void loadAppsNotifBlackList() {
|
||||||
@ -474,8 +478,11 @@ public class GBApplication extends Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void saveAppsNotifBlackList() {
|
private static void saveAppsNotifBlackList() {
|
||||||
|
saveAppsNotifBlackList(sharedPrefs.edit());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void saveAppsNotifBlackList(SharedPreferences.Editor editor) {
|
||||||
GB.log("Saving apps_notification_blacklist with " + apps_notification_blacklist.size() + " entries", GB.INFO, null);
|
GB.log("Saving apps_notification_blacklist with " + apps_notification_blacklist.size() + " entries", GB.INFO, null);
|
||||||
SharedPreferences.Editor editor = sharedPrefs.edit();
|
|
||||||
if (apps_notification_blacklist.isEmpty()) {
|
if (apps_notification_blacklist.isEmpty()) {
|
||||||
editor.putStringSet(GBPrefs.PACKAGE_BLACKLIST, null);
|
editor.putStringSet(GBPrefs.PACKAGE_BLACKLIST, null);
|
||||||
} else {
|
} else {
|
||||||
@ -506,6 +513,10 @@ public class GBApplication extends Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setAppsPebbleBlackList(Set<String> packageNames) {
|
public static void setAppsPebbleBlackList(Set<String> packageNames) {
|
||||||
|
setAppsPebbleBlackList(packageNames, sharedPrefs.edit());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setAppsPebbleBlackList(Set<String> packageNames, SharedPreferences.Editor editor) {
|
||||||
if (packageNames == null) {
|
if (packageNames == null) {
|
||||||
GB.log("Set null apps_pebblemsg_blacklist", GB.INFO, null);
|
GB.log("Set null apps_pebblemsg_blacklist", GB.INFO, null);
|
||||||
apps_pebblemsg_blacklist = new HashSet<>();
|
apps_pebblemsg_blacklist = new HashSet<>();
|
||||||
@ -513,7 +524,7 @@ public class GBApplication extends Application {
|
|||||||
apps_pebblemsg_blacklist = new HashSet<>(packageNames);
|
apps_pebblemsg_blacklist = new HashSet<>(packageNames);
|
||||||
}
|
}
|
||||||
GB.log("New apps_pebblemsg_blacklist has " + apps_pebblemsg_blacklist.size() + " entries", GB.INFO, null);
|
GB.log("New apps_pebblemsg_blacklist has " + apps_pebblemsg_blacklist.size() + " entries", GB.INFO, null);
|
||||||
saveAppsPebbleBlackList();
|
saveAppsPebbleBlackList(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadAppsPebbleBlackList() {
|
private static void loadAppsPebbleBlackList() {
|
||||||
@ -526,8 +537,11 @@ public class GBApplication extends Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void saveAppsPebbleBlackList() {
|
private static void saveAppsPebbleBlackList() {
|
||||||
|
saveAppsPebbleBlackList(sharedPrefs.edit());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void saveAppsPebbleBlackList(SharedPreferences.Editor editor) {
|
||||||
GB.log("Saving apps_pebblemsg_blacklist with " + apps_pebblemsg_blacklist.size() + " entries", GB.INFO, null);
|
GB.log("Saving apps_pebblemsg_blacklist with " + apps_pebblemsg_blacklist.size() + " entries", GB.INFO, null);
|
||||||
SharedPreferences.Editor editor = sharedPrefs.edit();
|
|
||||||
if (apps_pebblemsg_blacklist.isEmpty()) {
|
if (apps_pebblemsg_blacklist.isEmpty()) {
|
||||||
editor.putStringSet(GBPrefs.PACKAGE_PEBBLEMSG_BLACKLIST, null);
|
editor.putStringSet(GBPrefs.PACKAGE_PEBBLEMSG_BLACKLIST, null);
|
||||||
} else {
|
} else {
|
||||||
|
@ -124,15 +124,15 @@ public class ImportExportSharedPreferences {
|
|||||||
for (int z = 0; z < text.split(",").length; z++) {
|
for (int z = 0; z < text.split(",").length; z++) {
|
||||||
apps_blacklist.add(text.split(",")[z].trim());
|
apps_blacklist.add(text.split(",")[z].trim());
|
||||||
}
|
}
|
||||||
GBApplication.setAppsNotifBlackList(apps_blacklist);
|
GBApplication.setAppsNotifBlackList(apps_blacklist, editor);
|
||||||
break;
|
break;
|
||||||
case GBPrefs.PACKAGE_PEBBLEMSG_BLACKLIST: //TODO: untested
|
case GBPrefs.PACKAGE_PEBBLEMSG_BLACKLIST:
|
||||||
Set<String> apps_pebble_blacklist = new HashSet<>();
|
Set<String> apps_pebble_blacklist = new HashSet<>();
|
||||||
text = text.replace("[", "").replace("]", "");
|
text = text.replace("[", "").replace("]", "");
|
||||||
for (int z = 0; z < text.split(",").length; z++) {
|
for (int z = 0; z < text.split(",").length; z++) {
|
||||||
apps_pebble_blacklist.add(text.split(",")[z].trim());
|
apps_pebble_blacklist.add(text.split(",")[z].trim());
|
||||||
}
|
}
|
||||||
GBApplication.setAppsPebbleBlackList(apps_pebble_blacklist);
|
GBApplication.setAppsPebbleBlackList(apps_pebble_blacklist, editor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (!PREFERENCES.equals(name)) {
|
} else if (!PREFERENCES.equals(name)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user