blob: 101cbdd46948d32c32e9109255f892fa9456c07d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
package it.niedermann.owncloud.notes.persistence.migration;
import android.content.Context;
import android.content.SharedPreferences;
import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager;
import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase;
public class Migration_21_22 extends Migration {
@NonNull
private final Context context;
public Migration_21_22(@NonNull Context context) {
super(21, 22);
this.context = context;
}
/**
* Enabling backgroundSync, set from {@link String} values to {@link Boolean} value true
* https://github.com/stefan-niedermann/nextcloud-deck/issues/531
*/
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = sharedPreferences.edit();
if (sharedPreferences.contains("backgroundSync")) {
if (sharedPreferences.getString("backgroundSync", "on").equals("off")) {
editor.remove("backgroundSync");
editor.putBoolean("backgroundSync", false);
} else {
editor.remove("backgroundSync");
editor.putBoolean("backgroundSync", true);
}
} else {
editor.putBoolean("backgroundSync", true);
}
editor.apply();
}
}
|