Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorMasterWanna <MasterWanna@users.noreply.github.com>2021-05-02 10:58:03 +0300
committerMasterWanna <MasterWanna@users.noreply.github.com>2021-05-02 10:58:03 +0300
commit0483063a10eee6bdbf0c3420daaed9425c52d88e (patch)
treef1c30e9190f1d46069a33b3dbfd4c0dfef942116 /app
parent6c50d5c27cf9355bb5be512c878e8f1ee39a01ad (diff)
Migration is added to enable background sync
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java6
-rw-r--r--app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_21_22.java34
2 files changed, 38 insertions, 2 deletions
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java
index 4f4aaa78..7eb1e630 100644
--- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java
+++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesDatabase.java
@@ -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()
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_21_22.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_21_22.java
new file mode 100644
index 00000000..f9ef9ce4
--- /dev/null
+++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/migration/Migration_21_22.java
@@ -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();
+ }
+}