mirror of
https://github.com/nextcloud/notes-android.git
synced 2024-11-26 06:47:03 +03:00
Migration is added to enable background sync
This commit is contained in:
parent
6c50d5c27c
commit
0483063a10
2 changed files with 38 additions and 2 deletions
|
@ -32,6 +32,7 @@ import it.niedermann.owncloud.notes.persistence.migration.Migration_17_18;
|
|||
import it.niedermann.owncloud.notes.persistence.migration.Migration_18_19;
|
||||
import it.niedermann.owncloud.notes.persistence.migration.Migration_19_20;
|
||||
import it.niedermann.owncloud.notes.persistence.migration.Migration_20_21;
|
||||
import it.niedermann.owncloud.notes.persistence.migration.Migration_21_22;
|
||||
import it.niedermann.owncloud.notes.persistence.migration.Migration_9_10;
|
||||
|
||||
@Database(
|
||||
|
@ -41,7 +42,7 @@ import it.niedermann.owncloud.notes.persistence.migration.Migration_9_10;
|
|||
CategoryOptions.class,
|
||||
SingleNoteWidgetData.class,
|
||||
NotesListWidgetData.class
|
||||
}, version = 21
|
||||
}, version = 22
|
||||
)
|
||||
@TypeConverters({Converters.class})
|
||||
public abstract class NotesDatabase extends RoomDatabase {
|
||||
|
@ -74,7 +75,8 @@ public abstract class NotesDatabase extends RoomDatabase {
|
|||
new Migration_17_18(),
|
||||
new Migration_18_19(context),
|
||||
new Migration_19_20(context),
|
||||
new Migration_20_21()
|
||||
new Migration_20_21(),
|
||||
new Migration_21_22(context)
|
||||
)
|
||||
.fallbackToDestructiveMigrationOnDowngrade()
|
||||
.fallbackToDestructiveMigration()
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
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;
|
||||
|
||||
// CS304 issue link : https://github.com/stefan-niedermann/nextcloud-notes/issues/1168
|
||||
|
||||
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 Set backgroundSync to every 15 minutes, and wifiOnly to true
|
||||
* @param database no use just implement
|
||||
*/
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
editor.putBoolean("wifiOnly", true);
|
||||
editor.putString("backgroundSync", "15_minutes");
|
||||
editor.apply();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue