Revert temp fixes, add serialization progurd rules
This reverts commit 543e089982e9b774c5cfbcc4d0eddb5f21373928.
This commit is contained in:
parent
13196a68b1
commit
f3fc479020
35
app/proguard-rules.pro
vendored
35
app/proguard-rules.pro
vendored
@ -30,6 +30,41 @@
|
||||
<init>();
|
||||
}
|
||||
|
||||
# Kotlin Serialization
|
||||
-keepattributes *Annotation*, InnerClasses
|
||||
-dontnote kotlinx.serialization.AnnotationsKt # core serialization annotations
|
||||
|
||||
# kotlinx-serialization-json specific. Add this if you have java.lang.NoClassDefFoundError kotlinx.serialization.json.JsonObjectSerializer
|
||||
-keepclassmembers class kotlinx.serialization.json.** {
|
||||
*** Companion;
|
||||
}
|
||||
-keepclasseswithmembers class kotlinx.serialization.json.** {
|
||||
kotlinx.serialization.KSerializer serializer(...);
|
||||
}
|
||||
|
||||
-keep,includedescriptorclasses class eu.kanade.tachiyomi.**$$serializer { *; }
|
||||
-keepclassmembers class eu.kanade.tachiyomi.** {
|
||||
*** Companion;
|
||||
}
|
||||
-keepclasseswithmembers class eu.kanade.tachiyomi.** {
|
||||
kotlinx.serialization.KSerializer serializer(...);
|
||||
}
|
||||
-keep,includedescriptorclasses class exh.**$$serializer { *; }
|
||||
-keepclassmembers class exh.** {
|
||||
*** Companion;
|
||||
}
|
||||
-keepclasseswithmembers class exh.** {
|
||||
kotlinx.serialization.KSerializer serializer(...);
|
||||
}
|
||||
|
||||
-keep,includedescriptorclasses class xyz.nulldev.ts.api.http.serializer.**$$serializer { *; }
|
||||
-keepclassmembers class xyz.nulldev.ts.api.http.serializer.** {
|
||||
*** Companion;
|
||||
}
|
||||
-keepclasseswithmembers class xyz.nulldev.ts.api.http.serializer.** {
|
||||
kotlinx.serialization.KSerializer serializer(...);
|
||||
}
|
||||
|
||||
# Madokami extension username and password crash fix
|
||||
-keepclassmembers class androidx.preference.EditTextPreference {
|
||||
*** mOnBindEditTextListener;
|
||||
|
@ -164,7 +164,7 @@ class FullBackupManager(val context: Context) : AbstractBackupManager() {
|
||||
private fun backupSavedSearches(): List<BackupSavedSearch> {
|
||||
return preferences.eh_savedSearches().get().map {
|
||||
val sourceId = it.substringBefore(':').toLong()
|
||||
val content = JsonSavedSearch.fromJsonObject(Json.decodeFromString(it.substringAfter(':')))
|
||||
val content = Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':'))
|
||||
BackupSavedSearch(
|
||||
content.name,
|
||||
content.query,
|
||||
@ -490,7 +490,7 @@ class FullBackupManager(val context: Context) : AbstractBackupManager() {
|
||||
internal fun restoreSavedSearches(backupSavedSearches: List<BackupSavedSearch>) {
|
||||
val currentSavedSearches = preferences.eh_savedSearches().get().map {
|
||||
val sourceId = it.substringBefore(':').toLong()
|
||||
val content = JsonSavedSearch.fromJsonObject(Json.decodeFromString(it.substringAfter(':')))
|
||||
val content = Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':'))
|
||||
BackupSavedSearch(
|
||||
content.name,
|
||||
content.query,
|
||||
|
@ -549,7 +549,7 @@ class LegacyBackupManager(val context: Context, version: Int = CURRENT_VERSION)
|
||||
val newSavedSearches = backupSavedSearches.mapNotNull {
|
||||
try {
|
||||
val id = it.substringBefore(':').toLong()
|
||||
val content = JsonSavedSearch.fromJsonObject(Json.decodeFromString(it.substringAfter(':')))
|
||||
val content = Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':'))
|
||||
id to content
|
||||
} catch (t: RuntimeException) {
|
||||
// Load failed
|
||||
@ -564,7 +564,7 @@ class LegacyBackupManager(val context: Context, version: Int = CURRENT_VERSION)
|
||||
newSavedSearches += preferences.eh_savedSearches().get().mapNotNull {
|
||||
try {
|
||||
val id = it.substringBefore(':').toLong()
|
||||
val content = JsonSavedSearch.fromJsonObject(Json.decodeFromString(it.substringAfter(':')))
|
||||
val content = Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':'))
|
||||
id to content
|
||||
} catch (t: RuntimeException) {
|
||||
// Load failed
|
||||
|
@ -8,8 +8,6 @@ import eu.kanade.tachiyomi.extension.util.ExtensionLoader
|
||||
import exh.source.BlacklistedSources
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonArray
|
||||
import kotlinx.serialization.json.int
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
@ -25,8 +23,7 @@ internal class ExtensionGithubApi {
|
||||
val service: ExtensionGithubService = ExtensionGithubService.create()
|
||||
|
||||
return withContext(Dispatchers.IO) {
|
||||
val response = Json.decodeFromString<JsonArray>(service.getRepo().toString())
|
||||
|
||||
val response = service.getRepo()
|
||||
parseResponse(response)
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package eu.kanade.tachiyomi.extension.api
|
||||
|
||||
import com.google.gson.JsonArray
|
||||
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
|
||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonArray
|
||||
import okhttp3.MediaType.Companion.toMediaType
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.converter.gson.GsonConverterFactory
|
||||
import retrofit2.http.GET
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
@ -29,7 +31,7 @@ interface ExtensionGithubService {
|
||||
fun create(): ExtensionGithubService {
|
||||
val adapter = Retrofit.Builder()
|
||||
.baseUrl(ExtensionGithubApi.BASE_URL)
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType()))
|
||||
.client(client)
|
||||
.build()
|
||||
|
||||
|
@ -461,7 +461,7 @@ open class BrowseSourcePresenter(
|
||||
try {
|
||||
val id = it.substringBefore(':').toLong()
|
||||
if (id != source.id) return@map null
|
||||
val content = JsonSavedSearch.fromJsonObject(Json.decodeFromString(it.substringAfter(':')))
|
||||
val content = Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':'))
|
||||
val originalFilters = source.getFilterList()
|
||||
filterSerializer.deserialize(originalFilters, content.filters)
|
||||
EXHSavedSearch(
|
||||
|
@ -231,7 +231,7 @@ open class IndexPresenter(
|
||||
try {
|
||||
val id = it.substringBefore(':').toLong()
|
||||
if (id != source.id) return@map null
|
||||
val content = JsonSavedSearch.fromJsonObject(Json.decodeFromString(it.substringAfter(':')))
|
||||
val content = Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':'))
|
||||
val originalFilters = source.getFilterList()
|
||||
filterSerializer.deserialize(originalFilters, content.filters)
|
||||
EXHSavedSearch(
|
||||
|
@ -239,7 +239,7 @@ object DebugFunctions {
|
||||
try {
|
||||
val id = it.substringBefore(':').toLong()
|
||||
if (id != source.id) return@mapNotNull null
|
||||
JsonSavedSearch.fromJsonObject(Json.decodeFromString(it.substringAfter(':')))
|
||||
Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':'))
|
||||
} catch (t: RuntimeException) {
|
||||
// Load failed
|
||||
XLog.e("Failed to load saved search!", t)
|
||||
@ -251,7 +251,7 @@ object DebugFunctions {
|
||||
try {
|
||||
val id = it.substringBefore(':').toLong()
|
||||
if (id != newSource.id) return@mapNotNull null
|
||||
JsonSavedSearch.fromJsonObject(Json.decodeFromString(it.substringAfter(':')))
|
||||
Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':'))
|
||||
} catch (t: RuntimeException) {
|
||||
// Load failed
|
||||
XLog.e("Failed to load saved search!", t)
|
||||
@ -278,7 +278,7 @@ object DebugFunctions {
|
||||
try {
|
||||
val id = it.substringBefore(':').toLong()
|
||||
if (id != source.id) return@mapNotNull null
|
||||
JsonSavedSearch.fromJsonObject(Json.decodeFromString(it.substringAfter(':')))
|
||||
Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':'))
|
||||
} catch (t: RuntimeException) {
|
||||
// Load failed
|
||||
XLog.e("Failed to load saved search!", t)
|
||||
@ -290,7 +290,7 @@ object DebugFunctions {
|
||||
try {
|
||||
val id = it.substringBefore(':').toLong()
|
||||
if (id != newSource.id) return@mapNotNull null
|
||||
JsonSavedSearch.fromJsonObject(Json.decodeFromString(it.substringAfter(':')))
|
||||
Json.decodeFromString<JsonSavedSearch>(it.substringAfter(':'))
|
||||
} catch (t: RuntimeException) {
|
||||
// Load failed
|
||||
XLog.e("Failed to load saved search!", t)
|
||||
|
@ -2,23 +2,10 @@ package exh.savedsearches
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.JsonArray
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.jsonArray
|
||||
import kotlinx.serialization.json.jsonPrimitive
|
||||
|
||||
@Serializable
|
||||
data class JsonSavedSearch(
|
||||
val name: String,
|
||||
val query: String,
|
||||
val filters: JsonArray
|
||||
) {
|
||||
companion object {
|
||||
fun fromJsonObject(json: JsonObject): JsonSavedSearch {
|
||||
return JsonSavedSearch(
|
||||
json["name"]!!.jsonPrimitive.content,
|
||||
json["query"]!!.jsonPrimitive.content,
|
||||
json["filters"]!!.jsonArray,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user