better setting export

This commit is contained in:
rebelonion 2024-02-03 00:43:20 -06:00
parent 54b53dbe56
commit aa8d41eecf
5 changed files with 135 additions and 88 deletions

View file

@ -5,6 +5,7 @@ import android.content.SharedPreferences
import android.util.Base64
import ani.dantotsu.settings.saving.internal.Compat
import ani.dantotsu.settings.saving.internal.Location
import ani.dantotsu.settings.saving.internal.PreferencePackager
import ani.dantotsu.snackString
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
@ -237,18 +238,10 @@ object PrefManager {
fun getAnimeDownloadPreferences(): SharedPreferences = animeDownloadsPreferences!! //needs to be used externally
fun exportAllPrefs(prefLocation: Location): Map<String, *>{
val pref = getPrefLocation(prefLocation)
val typedMap = mutableMapOf<String, Any>()
pref.all.forEach { (key, value) ->
val typeValueMap = mapOf(
"type" to value?.javaClass?.kotlin?.qualifiedName,
"value" to value
)
typedMap[key] = typeValueMap
}
return typedMap
fun exportAllPrefs(prefLocation: List<Location>): String {
return PreferencePackager.pack(
prefLocation.associateWith { getPrefLocation(it) }
)
}
@Suppress("UNCHECKED_CAST")