aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2021-10-16 02:06:47 +0000
committerAlex Ning <chineseperson5@gmail.com>2021-10-16 02:06:47 +0000
commitf1dfadecb6bb985f646959ac3680f95f5cddfc78 (patch)
treee2ce1fedc810e30eeb4fff4be94d02846a7db888 /app/src
parent192de06e168530e7b0a3a8d1486ce51a07fcb508 (diff)
downloadinfinity-for-reddit-f1dfadecb6bb985f646959ac3680f95f5cddfc78.tar
infinity-for-reddit-f1dfadecb6bb985f646959ac3680f95f5cddfc78.tar.gz
infinity-for-reddit-f1dfadecb6bb985f646959ac3680f95f5cddfc78.tar.bz2
infinity-for-reddit-f1dfadecb6bb985f646959ac3680f95f5cddfc78.tar.lz
infinity-for-reddit-f1dfadecb6bb985f646959ac3680f95f5cddfc78.tar.xz
infinity-for-reddit-f1dfadecb6bb985f646959ac3680f95f5cddfc78.tar.zst
infinity-for-reddit-f1dfadecb6bb985f646959ac3680f95f5cddfc78.zip
Backup anonymously subscribed users and multireddits. Backup post filters.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/BackupSettings.java30
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/multireddit/AnonymousMultiredditSubredditDao.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterDao.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterUsageDao.java3
4 files changed, 37 insertions, 2 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 7d708298..1b79fe3c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/BackupSettings.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/asynctasks/BackupSettings.java
@@ -32,7 +32,12 @@ import ml.docilealligator.infinityforreddit.BuildConfig;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.customtheme.CustomTheme;
+import ml.docilealligator.infinityforreddit.multireddit.AnonymousMultiredditSubreddit;
+import ml.docilealligator.infinityforreddit.multireddit.MultiReddit;
+import ml.docilealligator.infinityforreddit.postfilter.PostFilter;
+import ml.docilealligator.infinityforreddit.postfilter.PostFilterUsage;
import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubredditData;
+import ml.docilealligator.infinityforreddit.subscribeduser.SubscribedUserData;
import ml.docilealligator.infinityforreddit.utils.CustomThemeSharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
@@ -94,9 +99,29 @@ public class BackupSettings {
String anonymousSubscribedSubredditsDataJson = new Gson().toJson(anonymousSubscribedSubredditsData);
boolean res11 = saveDatabaseTableToFile(anonymousSubscribedSubredditsDataJson, databaseDirFile.getAbsolutePath(), "/anonymous_subscribed_subreddits.json");
+ List<SubscribedUserData> anonymousSubscribedUsersData = redditDataRoomDatabase.subscribedUserDao().getAllSubscribedUsersList("-");
+ String anonymousSubscribedUsersDataJson = new Gson().toJson(anonymousSubscribedUsersData);
+ boolean res12 = saveDatabaseTableToFile(anonymousSubscribedUsersDataJson, databaseDirFile.getAbsolutePath(), "/anonymous_subscribed_users.json");
+
+ List<MultiReddit> anonymousMultireddits = redditDataRoomDatabase.multiRedditDao().getAllMultiRedditsList("-");
+ String anonymousMultiredditsJson = new Gson().toJson(anonymousMultireddits);
+ boolean res13 = saveDatabaseTableToFile(anonymousMultiredditsJson, databaseDirFile.getAbsolutePath(), "/anonymous_multireddits.json");
+
+ List<AnonymousMultiredditSubreddit> anonymousMultiredditSubreddits = redditDataRoomDatabase.anonymousMultiredditSubredditDao().getAllSubreddits();
+ String anonymousMultiredditSubredditsJson = new Gson().toJson(anonymousMultiredditSubreddits);
+ boolean res14 = saveDatabaseTableToFile(anonymousMultiredditSubredditsJson, databaseDirFile.getAbsolutePath(), "/anonymous_multireddit_subreddits.json");
+
List<CustomTheme> customThemes = redditDataRoomDatabase.customThemeDao().getAllCustomThemesList();
String customThemesJson = new Gson().toJson(customThemes);
- boolean res12 = saveDatabaseTableToFile(customThemesJson, databaseDirFile.getAbsolutePath(), "/custom_themes.json");
+ boolean res15 = saveDatabaseTableToFile(customThemesJson, databaseDirFile.getAbsolutePath(), "/custom_themes.json");
+
+ List<PostFilter> postFilters = redditDataRoomDatabase.postFilterDao().getAllPostFilters();
+ String postFiltersJson = new Gson().toJson(postFilters);
+ boolean res16 = saveDatabaseTableToFile(postFiltersJson, databaseDirFile.getAbsolutePath(), "/post_filters.json");
+
+ List<PostFilterUsage> postFilterUsage = redditDataRoomDatabase.postFilterUsageDao().getAllPostFilterUsageForBackup();
+ String postFilterUsageJson = new Gson().toJson(postFilterUsage);
+ boolean res17 = saveDatabaseTableToFile(postFilterUsageJson, databaseDirFile.getAbsolutePath(), "/post_filter_usage.json");
boolean zipRes = zipAndMoveToDestinationDir(context, contentResolver, destinationDirUri);
@@ -107,7 +132,8 @@ public class BackupSettings {
}
handler.post(() -> {
- boolean finalResult = res && res1 && res2 && res3 && res4 && res5 && res6 && res7 && res8 && res9 && res10 && res11 && res12 && zipRes;
+ boolean finalResult = res && res1 && res2 && res3 && res4 && res5 && res6 && res7 && res8
+ && res9 && res10 && res11 && res12 && res13 && res14 && res15 && res16 && res17 && zipRes;
if (finalResult) {
backupSettingsListener.success();
} else {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/multireddit/AnonymousMultiredditSubredditDao.java b/app/src/main/java/ml/docilealligator/infinityforreddit/multireddit/AnonymousMultiredditSubredditDao.java
index dfc7a7ed..1ec94bc8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/multireddit/AnonymousMultiredditSubredditDao.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/multireddit/AnonymousMultiredditSubredditDao.java
@@ -17,4 +17,7 @@ public interface AnonymousMultiredditSubredditDao {
@Query("SELECT * FROM anonymous_multireddit_subreddits WHERE path = :path ORDER BY subreddit_name COLLATE NOCASE ASC")
List<AnonymousMultiredditSubreddit> getAllAnonymousMultiRedditSubreddits(String path);
+
+ @Query("SELECT * FROM anonymous_multireddit_subreddits")
+ List<AnonymousMultiredditSubreddit> getAllSubreddits();
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterDao.java b/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterDao.java
index 55b65bab..5dc37da9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterDao.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterDao.java
@@ -29,6 +29,9 @@ public interface PostFilterDao {
@Query("SELECT * FROM post_filter ORDER BY name")
LiveData<List<PostFilter>> getAllPostFiltersLiveData();
+ @Query("SELECT * FROM post_filter")
+ List<PostFilter> getAllPostFilters();
+
@Query("SELECT * FROM post_filter WHERE post_filter.name IN " +
"(SELECT post_filter_usage.name FROM post_filter_usage WHERE (usage = :usage AND name_of_usage = :nameOfUsage) " +
"OR (usage =:usage AND name_of_usage = '--'))")
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterUsageDao.java b/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterUsageDao.java
index c94a67f7..652fa04c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterUsageDao.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/postfilter/PostFilterUsageDao.java
@@ -17,6 +17,9 @@ public interface PostFilterUsageDao {
@Query("SELECT * FROM post_filter_usage WHERE name = :name")
List<PostFilterUsage> getAllPostFilterUsage(String name);
+ @Query("SELECT * FROM post_filter_usage")
+ List<PostFilterUsage> getAllPostFilterUsageForBackup();
+
@Insert(onConflict = OnConflictStrategy.REPLACE)
void insertPostFilterUsage(PostFilterUsage postFilterUsage);