mirror of
https://github.com/mihonapp/mihon.git
synced 2025-06-26 11:07:51 +02:00
Don't use reflection for handling backup options as boolean array
Wasn't working correctly in release build, _probably_ because of R8 despite kotlin-reflect shipping with Proguard rules and us already keeping all Tachiyomi classes.
This commit is contained in:
@ -32,7 +32,6 @@ import eu.kanade.tachiyomi.data.backup.restore.BackupRestoreJob
|
||||
import eu.kanade.tachiyomi.data.backup.restore.RestoreOptions
|
||||
import eu.kanade.tachiyomi.util.system.DeviceUtil
|
||||
import kotlinx.coroutines.flow.update
|
||||
import tachiyomi.core.util.lang.anyEnabled
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.LabeledCheckbox
|
||||
import tachiyomi.presentation.core.components.LazyColumnWithAction
|
||||
|
@ -24,8 +24,6 @@ import eu.kanade.tachiyomi.util.system.isRunning
|
||||
import eu.kanade.tachiyomi.util.system.setForegroundSafely
|
||||
import eu.kanade.tachiyomi.util.system.workManager
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.util.lang.asBooleanArray
|
||||
import tachiyomi.core.util.lang.asDataClass
|
||||
import tachiyomi.core.util.system.logcat
|
||||
import tachiyomi.domain.backup.service.BackupPreferences
|
||||
import tachiyomi.domain.storage.service.StorageManager
|
||||
@ -49,7 +47,7 @@ class BackupCreateJob(private val context: Context, workerParams: WorkerParamete
|
||||
|
||||
setForegroundSafely()
|
||||
|
||||
val options: BackupOptions = inputData.getBooleanArray(OPTIONS_KEY)?.asDataClass()
|
||||
val options = inputData.getBooleanArray(OPTIONS_KEY)?.let { BackupOptions.fromBooleanArray(it) }
|
||||
?: BackupOptions()
|
||||
|
||||
return try {
|
||||
|
@ -15,6 +15,17 @@ data class BackupOptions(
|
||||
val privateSettings: Boolean = false,
|
||||
) {
|
||||
|
||||
fun asBooleanArray() = booleanArrayOf(
|
||||
libraryEntries,
|
||||
categories,
|
||||
chapters,
|
||||
tracking,
|
||||
history,
|
||||
appSettings,
|
||||
sourceSettings,
|
||||
privateSettings,
|
||||
)
|
||||
|
||||
companion object {
|
||||
val libraryOptions = persistentListOf(
|
||||
Entry(
|
||||
@ -66,6 +77,17 @@ data class BackupOptions(
|
||||
enabled = { it.appSettings || it.sourceSettings },
|
||||
),
|
||||
)
|
||||
|
||||
fun fromBooleanArray(array: BooleanArray) = BackupOptions(
|
||||
libraryEntries = array[0],
|
||||
categories = array[1],
|
||||
chapters = array[2],
|
||||
tracking = array[3],
|
||||
history = array[4],
|
||||
appSettings = array[5],
|
||||
sourceSettings = array[6],
|
||||
privateSettings = array[7],
|
||||
)
|
||||
}
|
||||
|
||||
data class Entry(
|
||||
|
@ -20,8 +20,6 @@ import eu.kanade.tachiyomi.util.system.workManager
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.i18n.stringResource
|
||||
import tachiyomi.core.util.lang.asBooleanArray
|
||||
import tachiyomi.core.util.lang.asDataClass
|
||||
import tachiyomi.core.util.system.logcat
|
||||
import tachiyomi.i18n.MR
|
||||
|
||||
@ -32,7 +30,7 @@ class BackupRestoreJob(private val context: Context, workerParams: WorkerParamet
|
||||
|
||||
override suspend fun doWork(): Result {
|
||||
val uri = inputData.getString(LOCATION_URI_KEY)?.toUri()
|
||||
val options: RestoreOptions? = inputData.getBooleanArray(OPTIONS_KEY)?.asDataClass()
|
||||
val options = inputData.getBooleanArray(OPTIONS_KEY)?.let { RestoreOptions.fromBooleanArray(it) }
|
||||
|
||||
if (uri == null || options == null) {
|
||||
return Result.failure()
|
||||
|
@ -10,6 +10,14 @@ data class RestoreOptions(
|
||||
val sourceSettings: Boolean = true,
|
||||
) {
|
||||
|
||||
fun asBooleanArray() = booleanArrayOf(
|
||||
library,
|
||||
appSettings,
|
||||
sourceSettings,
|
||||
)
|
||||
|
||||
fun anyEnabled() = library || appSettings || sourceSettings
|
||||
|
||||
companion object {
|
||||
val options = persistentListOf(
|
||||
Entry(
|
||||
@ -28,6 +36,12 @@ data class RestoreOptions(
|
||||
setter = { options, enabled -> options.copy(sourceSettings = enabled) },
|
||||
),
|
||||
)
|
||||
|
||||
fun fromBooleanArray(array: BooleanArray) = RestoreOptions(
|
||||
library = array[0],
|
||||
appSettings = array[1],
|
||||
sourceSettings = array[2],
|
||||
)
|
||||
}
|
||||
|
||||
data class Entry(
|
||||
|
Reference in New Issue
Block a user