aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/BackupSettings.java13
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/RestoreSettings.java13
2 files changed, 25 insertions, 1 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/BackupSettings.java b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/BackupSettings.java
index 2e353b06..1a6baf22 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/BackupSettings.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/BackupSettings.java
@@ -32,6 +32,8 @@ import ml.docilealligator.infinityforreddit.BuildConfig;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.account.Account;
+import ml.docilealligator.infinityforreddit.commentfilter.CommentFilter;
+import ml.docilealligator.infinityforreddit.commentfilter.CommentFilterUsage;
import ml.docilealligator.infinityforreddit.customtheme.CustomTheme;
import ml.docilealligator.infinityforreddit.multireddit.AnonymousMultiredditSubreddit;
import ml.docilealligator.infinityforreddit.multireddit.MultiReddit;
@@ -124,6 +126,14 @@ public class BackupSettings {
String postFilterUsageJson = new Gson().toJson(postFilterUsage);
boolean res17 = saveDatabaseTableToFile(postFilterUsageJson, databaseDirFile.getAbsolutePath(), "/post_filter_usage.json");
+ List<CommentFilter> commentFilters = redditDataRoomDatabase.commentFilterDao().getAllCommentFilters();
+ String commentFiltersJson = new Gson().toJson(commentFilters);
+ boolean res18 = saveDatabaseTableToFile(commentFiltersJson, databaseDirFile.getAbsolutePath(), "/comment_filters.json");
+
+ List<CommentFilterUsage> commentFilterUsage = redditDataRoomDatabase.commentFilterUsageDao().getAllCommentFilterUsageForBackup();
+ String commentFilterUsageJson = new Gson().toJson(commentFilterUsage);
+ boolean res19 = saveDatabaseTableToFile(commentFilterUsageJson, databaseDirFile.getAbsolutePath(), "/comment_filter_usage.json");
+
boolean zipRes = zipAndMoveToDestinationDir(context, contentResolver, destinationDirUri);
try {
@@ -134,7 +144,8 @@ public class BackupSettings {
handler.post(() -> {
boolean finalResult = res && res1 && res2 && res3 && res4 && res5 && res6 && res7 && res8
- && res9 && res10 && res11 && res12 && res13 && res14 && res15 && res16 && res17 && zipRes;
+ && res9 && res10 && res11 && res12 && res13 && res14 && res15 && res16 && res17
+ && res18 && res19 && zipRes;
if (finalResult) {
backupSettingsListener.success();
} else {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/RestoreSettings.java b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/RestoreSettings.java
index a14e93d3..10671ecc 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/RestoreSettings.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/RestoreSettings.java
@@ -32,6 +32,8 @@ import java.util.concurrent.Executor;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.account.Account;
+import ml.docilealligator.infinityforreddit.commentfilter.CommentFilter;
+import ml.docilealligator.infinityforreddit.commentfilter.CommentFilterUsage;
import ml.docilealligator.infinityforreddit.customtheme.CustomTheme;
import ml.docilealligator.infinityforreddit.multireddit.AnonymousMultiredditSubreddit;
import ml.docilealligator.infinityforreddit.multireddit.MultiReddit;
@@ -132,6 +134,8 @@ public class RestoreSettings {
File customThemesFile = new File(f.getAbsolutePath() + "/custom_themes.json");
File postFiltersFile = new File(f.getAbsolutePath() + "/post_filters.json");
File postFilterUsageFile = new File(f.getAbsolutePath() + "/post_filter_usage.json");
+ File commentFiltersFile = new File(f.getAbsolutePath() + "/comment_filters.json");
+ File commentFilterUsageFile = new File(f.getAbsolutePath() + "/comment_filter_usage.json");
if (anonymousSubscribedSubredditsFile.exists()) {
List<SubscribedSubredditData> anonymousSubscribedSubreddits = getListFromFile(anonymousSubscribedSubredditsFile, new TypeToken<List<SubscribedSubredditData>>() {}.getType());
@@ -163,6 +167,15 @@ public class RestoreSettings {
redditDataRoomDatabase.postFilterUsageDao().insertAll(postFilterUsage);
}
}
+ if (commentFiltersFile.exists()) {
+ List<CommentFilter> commentFilters = getListFromFile(commentFiltersFile, new TypeToken<List<CommentFilter>>() {}.getType());
+ redditDataRoomDatabase.commentFilterDao().insertAll(commentFilters);
+
+ if (commentFilterUsageFile.exists()) {
+ List<CommentFilterUsage> commentFilterUsage = getListFromFile(commentFilterUsageFile, new TypeToken<List<CommentFilterUsage>>() {}.getType());
+ redditDataRoomDatabase.commentFilterUsageDao().insertAll(commentFilterUsage);
+ }
+ }
}
}
} else {