public static void migrateAllowedSources() { SharedPreferences prefs = DDGApplication.getSharedPreferences(); if (PreferencesManager.shouldMigrateSources()) { Set<String> oldAllowed = DDGUtils.loadSet(prefs, "sourceset"); DDGUtils.deleteSet(prefs, "sourceset"); saveUserAllowedSources(oldAllowed); Set<String> cachedSources = DDGUtils.getCachedSources(); // XXX cachedSources is not expected to be null during a migration // since before APP VERSION_CODE 43, source response is always cached if (cachedSources != null) { Set<String> oldDisallowed = new HashSet<String>(cachedSources); oldDisallowed.removeAll(oldAllowed); saveUserDisallowedSources(oldDisallowed); } sourcesWereMigratedRightNow = true; } }
public static boolean saveUserDisallowedSources(Set<String> userSources) { return DDGUtils.saveSet(DDGApplication.getSharedPreferences(), userSources, "disallowset"); }
public static Set<String> getUserDisallowedSources() { return DDGUtils.loadSet(DDGApplication.getSharedPreferences(), "disallowset"); }
public static Set<String> getDefaultSources() { return DDGUtils.loadSet(DDGApplication.getSharedPreferences(), "defaultsources"); }
public static boolean saveDefaultSources(Set<String> sources) { return DDGUtils.saveSet(DDGApplication.getSharedPreferences(), sources, "defaultsources"); }