pull/2725/head
ag2s20150909 2 years ago
parent 4c5d797ee9
commit 47ea44b3ab
  1. 4
      app/build.gradle
  2. 1
      app/src/app/java/io/legado/app/lib/cronet/BodyUploadProvider.kt
  3. 5
      app/src/app/java/io/legado/app/lib/cronet/CronetCoroutineInterceptor.kt
  4. 2
      app/src/main/java/io/legado/app/help/config/AppConfig.kt

@ -100,11 +100,13 @@ android {
app {
dimension "mode"
manifestPlaceholders.put("APP_CHANNEL_VALUE", "app")
buildConfigField "boolean", "isGoogle", "false"
}
google {
dimension "mode"
applicationId "io.legado.play"
manifestPlaceholders.put("APP_CHANNEL_VALUE", "google")
buildConfigField "boolean", "isGoogle", "true"
}
}
compileOptions {
@ -130,7 +132,7 @@ android {
dependencies {
compileOnly "com.android.tools.build:gradle:$agp_version"
//noinspection GradleDependency,GradlePackageUpdate
coreLibraryDesugaring('com.android.tools:desugar_jdk_libs:1.2.2')
coreLibraryDesugaring('com.android.tools:desugar_jdk_libs:2.0.0')
testImplementation('junit:junit:4.13.2')
androidTestImplementation('androidx.test:runner:1.5.2')
androidTestImplementation('androidx.test.espresso:espresso-core:3.5.1')

@ -39,6 +39,7 @@ class BodyUploadProvider(private val body: RequestBody) : UploadDataProvider(),
@Throws(IOException::class)
override fun rewind(uploadDataSink: UploadDataSink) {
check(body.isOneShot()) { "Okhttp RequestBody is oneShot" }
buffer.clear()
body.writeTo(buffer)
uploadDataSink.onRewindSucceeded()

@ -92,7 +92,10 @@ class CronetCoroutineInterceptor : Interceptor {
}
buildRequest(request, callBack)?.start()
val req = buildRequest(request, callBack)?.also { it.start() }
coroutine.invokeOnCancellation {
req?.cancel()
}
}

@ -12,7 +12,7 @@ import splitties.init.appCtx
@Suppress("MemberVisibilityCanBePrivate")
object AppConfig : SharedPreferences.OnSharedPreferenceChangeListener {
val isGooglePlay = appCtx.channel == "google"
const val isGooglePlay = BuildConfig.isGoogle//appCtx.channel == "google"
val isCronet = appCtx.getPrefBoolean(PreferKey.cronet)
val useAntiAlias = appCtx.getPrefBoolean(PreferKey.antiAlias)
var userAgent: String = getPrefUserAgent()

Loading…
Cancel
Save