Migrate to ktor 2.0
This commit is contained in:
@@ -86,11 +86,11 @@ android {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.aar"))))
|
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.aar"))))
|
||||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0")
|
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1")
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2")
|
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2")
|
||||||
|
|
||||||
implementation("androidx.activity:activity-compose:1.4.0")
|
implementation("androidx.activity:activity-compose:1.4.0")
|
||||||
implementation("androidx.navigation:navigation-compose:2.4.1")
|
implementation("androidx.navigation:navigation-compose:2.4.2")
|
||||||
|
|
||||||
implementation(JetpackCompose.FOUNDATION)
|
implementation(JetpackCompose.FOUNDATION)
|
||||||
implementation(JetpackCompose.UI)
|
implementation(JetpackCompose.UI)
|
||||||
@@ -110,9 +110,10 @@ dependencies {
|
|||||||
|
|
||||||
implementation("io.coil-kt:coil-compose:1.4.0")
|
implementation("io.coil-kt:coil-compose:1.4.0")
|
||||||
|
|
||||||
implementation("io.ktor:ktor-client-core:1.6.8")
|
implementation("io.ktor:ktor-client-core:2.0.0")
|
||||||
implementation("io.ktor:ktor-client-okhttp:1.6.8")
|
implementation("io.ktor:ktor-client-okhttp:2.0.0")
|
||||||
implementation("io.ktor:ktor-client-serialization:1.6.8")
|
implementation("io.ktor:ktor-client-content-negotiation:2.0.0")
|
||||||
|
implementation("io.ktor:ktor-serialization-kotlinx-json:2.0.0")
|
||||||
|
|
||||||
implementation("androidx.room:room-runtime:2.4.2")
|
implementation("androidx.room:room-runtime:2.4.2")
|
||||||
annotationProcessor("androidx.room:room-compiler:2.4.2")
|
annotationProcessor("androidx.room:room-compiler:2.4.2")
|
||||||
@@ -137,7 +138,7 @@ dependencies {
|
|||||||
|
|
||||||
implementation("ru.noties.markwon:core:3.1.0")
|
implementation("ru.noties.markwon:core:3.1.0")
|
||||||
|
|
||||||
implementation("xyz.quaver.pupil.sources:core:0.0.1-alpha01-DEV25")
|
implementation("xyz.quaver.pupil.sources:core:0.0.1-alpha01-DEV26")
|
||||||
|
|
||||||
implementation("xyz.quaver:documentfilex:0.7.2")
|
implementation("xyz.quaver:documentfilex:0.7.2")
|
||||||
implementation("xyz.quaver:subsampledimage:0.0.1-alpha19-SNAPSHOT")
|
implementation("xyz.quaver:subsampledimage:0.0.1-alpha19-SNAPSHOT")
|
||||||
|
|||||||
@@ -29,12 +29,7 @@ import com.google.android.gms.common.GooglePlayServicesRepairableException
|
|||||||
import com.google.android.gms.security.ProviderInstaller
|
import com.google.android.gms.security.ProviderInstaller
|
||||||
import io.ktor.client.*
|
import io.ktor.client.*
|
||||||
import io.ktor.client.engine.okhttp.*
|
import io.ktor.client.engine.okhttp.*
|
||||||
import io.ktor.client.features.*
|
import io.ktor.client.plugins.contentnegotiation.*
|
||||||
import io.ktor.client.features.cache.*
|
|
||||||
import io.ktor.client.features.json.*
|
|
||||||
import io.ktor.client.features.json.serializer.*
|
|
||||||
import io.ktor.http.*
|
|
||||||
import okhttp3.Protocol
|
|
||||||
import org.kodein.di.*
|
import org.kodein.di.*
|
||||||
import org.kodein.di.android.x.androidXModule
|
import org.kodein.di.android.x.androidXModule
|
||||||
import xyz.quaver.pupil.sources.core.NetworkCache
|
import xyz.quaver.pupil.sources.core.NetworkCache
|
||||||
@@ -53,10 +48,7 @@ class Pupil : Application(), DIAware {
|
|||||||
|
|
||||||
bind { singleton {
|
bind { singleton {
|
||||||
HttpClient(OkHttp) {
|
HttpClient(OkHttp) {
|
||||||
install(JsonFeature) {
|
install(ContentNegotiation)
|
||||||
serializer = KotlinxSerializer()
|
|
||||||
accept(ContentType("text", "plain"))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} }
|
} }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ import com.google.accompanist.insets.ui.BottomNavigation
|
|||||||
import com.google.accompanist.insets.ui.Scaffold
|
import com.google.accompanist.insets.ui.Scaffold
|
||||||
import com.google.accompanist.insets.ui.TopAppBar
|
import com.google.accompanist.insets.ui.TopAppBar
|
||||||
import io.ktor.client.*
|
import io.ktor.client.*
|
||||||
|
import io.ktor.client.call.*
|
||||||
import io.ktor.client.request.*
|
import io.ktor.client.request.*
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
@@ -181,7 +182,7 @@ fun Explore() {
|
|||||||
while (true) {
|
while (true) {
|
||||||
delay(1000)
|
delay(1000)
|
||||||
value = withContext(Dispatchers.IO) {
|
value = withContext(Dispatchers.IO) {
|
||||||
client.get<Map<String, RemoteSourceInfo>>("https://raw.githubusercontent.com/tom5079/PupilSources/master/versions.json")
|
client.get("https://raw.githubusercontent.com/tom5079/PupilSources/master/versions.json").body()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,23 +20,16 @@ package xyz.quaver.pupil.util
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.util.Log
|
|
||||||
import android.webkit.MimeTypeMap
|
import android.webkit.MimeTypeMap
|
||||||
import androidx.core.content.FileProvider
|
import androidx.core.content.FileProvider
|
||||||
import io.ktor.client.*
|
import io.ktor.client.*
|
||||||
import io.ktor.client.call.*
|
|
||||||
import io.ktor.client.features.*
|
|
||||||
import io.ktor.client.request.*
|
import io.ktor.client.request.*
|
||||||
import io.ktor.client.statement.*
|
import io.ktor.client.statement.*
|
||||||
import io.ktor.http.*
|
import io.ktor.http.*
|
||||||
import io.ktor.util.cio.*
|
|
||||||
import io.ktor.utils.io.*
|
|
||||||
import io.ktor.utils.io.core.*
|
import io.ktor.utils.io.core.*
|
||||||
import io.ktor.utils.io.jvm.javaio.*
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.flow
|
import kotlinx.coroutines.flow.flow
|
||||||
import kotlinx.coroutines.flow.flowOn
|
import kotlinx.coroutines.flow.flowOn
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.io.use
|
import kotlin.io.use
|
||||||
|
|
||||||
@@ -49,8 +42,8 @@ class ApkDownloadManager(private val context: Context, private val client: HttpC
|
|||||||
it.delete()
|
it.delete()
|
||||||
}
|
}
|
||||||
|
|
||||||
client.get<HttpStatement>(url).execute { response ->
|
client.prepareGet(url).execute { response ->
|
||||||
val channel: ByteReadChannel = response.receive()
|
val channel = response.bodyAsChannel()
|
||||||
val contentLength = response.contentLength() ?: -1
|
val contentLength = response.contentLength() ?: -1
|
||||||
var readBytes = 0f
|
var readBytes = 0f
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user