Update kotlinx-serialization-protobuf to match Kotlin version at MangaPlus (#6747)

* Update kotlinx-serialization-protobuf to match Kotlin version.

* Removed unused import.

* Removed unused serializer.
This commit is contained in:
Alessandro Jean 2021-04-28 18:21:27 -03:00 committed by GitHub
parent 50bf2a56e5
commit f0c4083f24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 10 deletions

View File

@ -6,12 +6,12 @@ ext {
extName = 'MANGA Plus by SHUEISHA' extName = 'MANGA Plus by SHUEISHA'
pkgNameSuffix = 'all.mangaplus' pkgNameSuffix = 'all.mangaplus'
extClass = '.MangaPlusFactory' extClass = '.MangaPlusFactory'
extVersionCode = 16 extVersionCode = 17
libVersion = '1.2' libVersion = '1.2'
} }
dependencies { dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-protobuf:1.0.1' implementation 'org.jetbrains.kotlinx:kotlinx-serialization-protobuf:1.2.0'
} }
apply from: "$rootDir/common.gradle" apply from: "$rootDir/common.gradle"

View File

@ -14,6 +14,7 @@ import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.source.online.HttpSource
import kotlinx.serialization.decodeFromByteArray
import kotlinx.serialization.protobuf.ProtoBuf import kotlinx.serialization.protobuf.ProtoBuf
import okhttp3.Headers import okhttp3.Headers
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
@ -422,11 +423,11 @@ abstract class MangaPlus(
private fun Response.asProto(): MangaPlusResponse { private fun Response.asProto(): MangaPlusResponse {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M)
return ProtoBuf.decodeFromByteArray(MangaPlusSerializer, body!!.bytes()) return ProtoBuf.decodeFromByteArray(body!!.bytes())
// The kotlinx.serialization library eventually always have some issues with // The kotlinx.serialization library eventually always have some issues with
// devices with Android version below Nougat. So, if the device is running Marshmallow // devices with Android version below Nougat. So, if the device is running Android 6.x,
// or lower, the deserialization is done using ProtobufJS + Duktape + Gson. // the deserialization is done using ProtobufJS + Duktape + Gson.
val bytes = body!!.bytes() val bytes = body!!.bytes()
val messageBytes = "var BYTE_ARR = new Uint8Array([${bytes.joinToString()}]);" val messageBytes = "var BYTE_ARR = new Uint8Array([${bytes.joinToString()}]);"
@ -445,7 +446,7 @@ abstract class MangaPlus(
companion object { companion object {
private const val API_URL = "https://jumpg-webapi.tokyo-cdn.com/api" private const val API_URL = "https://jumpg-webapi.tokyo-cdn.com/api"
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " + private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " +
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36" "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36"
private val HEX_GROUP = "(.{1,2})".toRegex() private val HEX_GROUP = "(.{1,2})".toRegex()

View File

@ -2,12 +2,8 @@ package eu.kanade.tachiyomi.extension.all.mangaplus
import com.google.gson.annotations.SerializedName import com.google.gson.annotations.SerializedName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.Serializer
import kotlinx.serialization.protobuf.ProtoNumber import kotlinx.serialization.protobuf.ProtoNumber
@Serializer(forClass = MangaPlusResponse::class)
object MangaPlusSerializer
@Serializable @Serializable
data class MangaPlusResponse( data class MangaPlusResponse(
@ProtoNumber(1) val success: SuccessResult? = null, @ProtoNumber(1) val success: SuccessResult? = null,