feat: Allow user to backup sensitive settings

This commit is contained in:
Ahmad Ansori Palembani 2024-06-10 07:34:21 +07:00
parent 6213604278
commit 842b3d3d1e
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
4 changed files with 8 additions and 3 deletions

View file

@ -64,11 +64,11 @@ class BackupCreator(
sourcesBackupCreator.backupExtensionInfo(databaseManga),
if (options.appPrefs)
preferenceBackupCreator.backupAppPreferences(false)
preferenceBackupCreator.backupAppPreferences(options.includePrivate)
else emptyList(),
if (options.sourcePrefs)
preferenceBackupCreator.backupSourcePreferences(false)
preferenceBackupCreator.backupSourcePreferences(options.includePrivate)
else emptyList(),
)
}

View file

@ -12,6 +12,7 @@ data class BackupOptions(
val sourcePrefs: Boolean = true,
val customInfo: Boolean = true,
val readManga: Boolean = true,
val includePrivate: Boolean = false,
) {
fun asBooleanArray() = booleanArrayOf(
libraryEntries,
@ -23,6 +24,7 @@ data class BackupOptions(
sourcePrefs,
customInfo,
readManga,
includePrivate,
)
companion object {
@ -36,6 +38,7 @@ data class BackupOptions(
R.string.source_settings,
R.string.custom_manga_info,
R.string.all_read_manga,
R.string.backup_private_pref,
)
fun fromBooleanArray(array: BooleanArray): BackupOptions = BackupOptions(
@ -48,6 +51,7 @@ data class BackupOptions(
array[6],
array[7],
array[8],
array[9],
)
}
}

View file

@ -303,7 +303,7 @@ class SettingsDataController : SettingsLegacyController() {
.setTitle(R.string.what_should_backup)
.setMultiChoiceItems(
options.toTypedArray(),
options.map { true }.toBooleanArray(),
BackupOptions().asBooleanArray(),
) { dialog, position, _ ->
if (position == 0) {
val listView = (dialog as AlertDialog).listView

View file

@ -846,6 +846,7 @@
<item quantity="other">Done in %1$s with %2$s errors</item>
</plurals>
<string name="not_logged_into_">Not logged into %1$s</string>
<string name="backup_private_pref">Include sensitivve settings (e.g. tracker login tokens)</string>
<!-- Advanced section -->
<string name="clear_chapter_cache">Clear chapter cache</string>