mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 12:47:26 +01:00
Backup anonymously subscribed users and multireddits. Backup post filters.
This commit is contained in:
parent
192de06e16
commit
f1dfadecb6
@ -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 {
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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 = '--'))")
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user