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 anonymousSubscribedUsersData = redditDataRoomDatabase.subscribedUserDao().getAllSubscribedUsersList("-"); + String anonymousSubscribedUsersDataJson = new Gson().toJson(anonymousSubscribedUsersData); + boolean res12 = saveDatabaseTableToFile(anonymousSubscribedUsersDataJson, databaseDirFile.getAbsolutePath(), "/anonymous_subscribed_users.json"); + + List anonymousMultireddits = redditDataRoomDatabase.multiRedditDao().getAllMultiRedditsList("-"); + String anonymousMultiredditsJson = new Gson().toJson(anonymousMultireddits); + boolean res13 = saveDatabaseTableToFile(anonymousMultiredditsJson, databaseDirFile.getAbsolutePath(), "/anonymous_multireddits.json"); + + List anonymousMultiredditSubreddits = redditDataRoomDatabase.anonymousMultiredditSubredditDao().getAllSubreddits(); + String anonymousMultiredditSubredditsJson = new Gson().toJson(anonymousMultiredditSubreddits); + boolean res14 = saveDatabaseTableToFile(anonymousMultiredditSubredditsJson, databaseDirFile.getAbsolutePath(), "/anonymous_multireddit_subreddits.json"); + List 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 postFilters = redditDataRoomDatabase.postFilterDao().getAllPostFilters(); + String postFiltersJson = new Gson().toJson(postFilters); + boolean res16 = saveDatabaseTableToFile(postFiltersJson, databaseDirFile.getAbsolutePath(), "/post_filters.json"); + + List 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 getAllAnonymousMultiRedditSubreddits(String path); + + @Query("SELECT * FROM anonymous_multireddit_subreddits") + List 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> getAllPostFiltersLiveData(); + @Query("SELECT * FROM post_filter") + List 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 getAllPostFilterUsage(String name); + @Query("SELECT * FROM post_filter_usage") + List getAllPostFilterUsageForBackup(); + @Insert(onConflict = OnConflictStrategy.REPLACE) void insertPostFilterUsage(PostFilterUsage postFilterUsage);