Updated serialization library
This commit is contained in:
@@ -46,7 +46,7 @@ dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.1'
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.1'
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.11.0"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.14.0"
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'androidx.preference:preference:1.1.0'
|
||||
@@ -60,7 +60,7 @@ dependencies {
|
||||
implementation "com.daimajia.swipelayout:library:1.2.0@aar"
|
||||
implementation 'com.google.android.material:material:1.2.0-alpha02'
|
||||
implementation 'com.google.firebase:firebase-core:17.2.1'
|
||||
implementation 'com.google.firebase:firebase-perf:19.0.2'
|
||||
implementation 'com.google.firebase:firebase-perf:19.0.3'
|
||||
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
|
||||
implementation 'com.github.arimorty:floatingsearchview:2.1.1'
|
||||
implementation 'com.github.clans:fab:1.6.4'
|
||||
|
||||
@@ -38,6 +38,7 @@ import xyz.quaver.hiyobi.getReader
|
||||
import xyz.quaver.hiyobi.user_agent
|
||||
import xyz.quaver.pupil.ui.LockActivity
|
||||
import xyz.quaver.pupil.util.getDownloadDirectory
|
||||
import xyz.quaver.pupil.util.updateOldReaderGalleries
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
import javax.net.ssl.HttpsURLConnection
|
||||
@@ -108,4 +109,11 @@ class ExampleInstrumentedTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test_updateOldReader() {
|
||||
val context = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
|
||||
updateOldReaderGalleries(context)
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,8 @@
|
||||
package xyz.quaver.pupil.util
|
||||
|
||||
import android.content.Context
|
||||
import kotlinx.serialization.ImplicitReflectionSerializer
|
||||
import kotlinx.serialization.InternalSerializationApi
|
||||
import kotlinx.serialization.internal.EnumSerializer
|
||||
import kotlinx.serialization.json.*
|
||||
import xyz.quaver.availableInHiyobi
|
||||
import xyz.quaver.hitomi.Reader
|
||||
@@ -91,7 +92,7 @@ fun getOldReaderGalleries(context: Context) : List<File> {
|
||||
return oldGallery
|
||||
}
|
||||
|
||||
@UseExperimental(ImplicitReflectionSerializer::class)
|
||||
@UseExperimental(InternalSerializationApi::class)
|
||||
fun updateOldReaderGalleries(context: Context) {
|
||||
|
||||
val json = Json(JsonConfiguration.Stable)
|
||||
@@ -100,11 +101,13 @@ fun updateOldReaderGalleries(context: Context) {
|
||||
val reader = json.parseJson(File(gallery, "reader.json").readText())
|
||||
.jsonObject.toMutableMap()
|
||||
|
||||
val codeSerializer = EnumSerializer(Reader.Code::class)
|
||||
|
||||
reader["code"] = when {
|
||||
(File(gallery, "images").list()?.
|
||||
all { !it.endsWith("webp") } ?: return@forEach) &&
|
||||
availableInHiyobi(gallery.name.toInt()) -> json.toJson(Reader.Code.HIYOBI)
|
||||
else -> json.toJson(Reader.Code.HITOMI)
|
||||
availableInHiyobi(gallery.name.toInt()) -> json.toJson(codeSerializer, Reader.Code.HIYOBI)
|
||||
else -> json.toJson(codeSerializer, Reader.Code.HITOMI)
|
||||
}
|
||||
|
||||
File(gallery, "reader.json").writeText(JsonObject(reader).toString())
|
||||
|
||||
@@ -6,7 +6,7 @@ dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.1'
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.11.0"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.14.0"
|
||||
implementation 'org.jsoup:jsoup:1.11.3'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user