Upgrade after importing

This commit is contained in:
M66B 2015-11-24 12:00:22 +01:00
parent bd0aef5a34
commit 87769405f3
2 changed files with 10 additions and 17 deletions

View File

@ -363,15 +363,14 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
xmlImport(handler.application, prefs);
xmlImport(handler.wifi, getSharedPreferences("wifi", Context.MODE_PRIVATE));
xmlImport(handler.mobile, getSharedPreferences("other", Context.MODE_PRIVATE));
if (handler.unused.size() > 0) {
xmlImport(handler.unused, getSharedPreferences("screen_wifi", Context.MODE_PRIVATE));
xmlImport(handler.unused, getSharedPreferences("screen_other", Context.MODE_PRIVATE));
} else {
xmlImport(handler.screen_wifi, getSharedPreferences("screen_wifi", Context.MODE_PRIVATE));
xmlImport(handler.screen_other, getSharedPreferences("screen_other", Context.MODE_PRIVATE));
}
xmlImport(handler.unused, getSharedPreferences("unused", Context.MODE_PRIVATE));
xmlImport(handler.screen_wifi, getSharedPreferences("screen_wifi", Context.MODE_PRIVATE));
xmlImport(handler.screen_other, getSharedPreferences("screen_other", Context.MODE_PRIVATE));
xmlImport(handler.roaming, getSharedPreferences("roaming", Context.MODE_PRIVATE));
// Upgrade imported settings
Receiver.upgrade(true, this);
// Refresh UI
prefs.edit().putBoolean("imported", true).apply();
}
@ -388,11 +387,7 @@ public class ActivitySettings extends AppCompatActivity implements SharedPrefere
for (String key : settings.keySet()) {
Object value = settings.get(key);
if (value instanceof Boolean)
if ("unused".equals(key)) {
editor.putBoolean("screen_wifi", (Boolean) value);
editor.putBoolean("screen_other", (Boolean) value);
} else
editor.putBoolean(key, (Boolean) value);
editor.putBoolean(key, (Boolean) value);
else if (value instanceof Integer)
editor.putInt(key, (Integer) value);
else

View File

@ -79,11 +79,9 @@ public class Receiver extends BroadcastReceiver {
if (initialized) {
if (oldVersion < 38) {
Log.i(TAG, "Converting screen wifi/mobile");
SharedPreferences.Editor edit = prefs.edit();
edit.putBoolean("screen_wifi", prefs.getBoolean("unused", false));
edit.putBoolean("screen_other", prefs.getBoolean("unused", false));
edit.remove("unused");
edit.apply();
editor.putBoolean("screen_wifi", prefs.getBoolean("unused", false));
editor.putBoolean("screen_other", prefs.getBoolean("unused", false));
editor.remove("unused");
SharedPreferences unused = context.getSharedPreferences("unused", Context.MODE_PRIVATE);
SharedPreferences screen_wifi = context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE);