Compare commits
18
Commits
1.14.3
...
1.8.9.6-gms
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13f255529b | ||
|
|
16e912c9ae | ||
|
|
01742ac6b9 | ||
|
|
e94424a83e | ||
|
|
56d30aa413 | ||
|
|
a6d215a0bf | ||
|
|
cf9441adb5 | ||
|
|
36b16d7be8 | ||
|
|
fab5532407 | ||
|
|
8ad4e8640f | ||
|
|
5b5a2a9a33 | ||
|
|
7719312355 | ||
|
|
48f1b0a958 | ||
|
|
9abeba6b15 | ||
|
|
75bec4314e | ||
|
|
b767c041b9 | ||
|
|
4e916731b3 | ||
|
|
6c24407fb7 |
No files matched your search
@@ -45,6 +45,10 @@ android {
|
||||
enableV4Signing = true
|
||||
}
|
||||
|
||||
val branch = providers.exec {
|
||||
commandLine = "git branch --show-current".split(' ')
|
||||
}.standardOutput.asText.get().trim()
|
||||
|
||||
val commitSha = providers.exec {
|
||||
commandLine = "git rev-parse --short=7 HEAD".split(' ')
|
||||
}.standardOutput.asText.get().trim()
|
||||
@@ -64,7 +68,7 @@ android {
|
||||
minSdk = 28
|
||||
targetSdk = 34
|
||||
versionCode = 180043
|
||||
versionName = "1.8.10.0-SNAPSHOT"
|
||||
versionName = "1.8.9.6-gms"
|
||||
resourceConfigurations.addAll(
|
||||
listOf(
|
||||
"zh",
|
||||
@@ -81,6 +85,7 @@ android {
|
||||
"nb-rNO",
|
||||
),
|
||||
)
|
||||
buildConfigField("String", "BRANCH", "\"$branch\"")
|
||||
buildConfigField("String", "COMMIT_SHA", "\"$commitSha\"")
|
||||
buildConfigField("String", "BUILD_TIME", "\"$buildTime\"")
|
||||
buildConfigField("String", "REPO_NAME", "\"$repoName\"")
|
||||
@@ -250,6 +255,9 @@ dependencies {
|
||||
implementation("io.ktor:ktor-io-jvm:$ktor")
|
||||
implementation("io.ktor:ktor-utils-jvm:$ktor")
|
||||
|
||||
implementation("org.chromium.net:cronet-api:113.5672.61")
|
||||
implementation("com.google.android.gms:play-services-cronet:18.0.1")
|
||||
|
||||
val serialization = "1.6.0"
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-cbor:$serialization")
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$serialization")
|
||||
|
||||
@@ -25,6 +25,7 @@ import androidx.lifecycle.coroutineScope
|
||||
import coil.ImageLoaderFactory
|
||||
import coil.decode.ImageDecoderDecoder
|
||||
import coil.util.DebugLogger
|
||||
import com.google.android.gms.net.CronetProviderInstaller
|
||||
import com.hippo.ehviewer.client.EhCookieStore
|
||||
import com.hippo.ehviewer.client.EhTagDatabase
|
||||
import com.hippo.ehviewer.client.data.GalleryDetail
|
||||
@@ -77,6 +78,7 @@ class EhApplication : Application(), ImageLoaderFactory {
|
||||
handler?.uncaughtException(t, e)
|
||||
}
|
||||
super.onCreate()
|
||||
CronetProviderInstaller.installProvider(appCtx)
|
||||
System.loadLibrary("ehviewer")
|
||||
System.loadLibrary("ehviewer_rust")
|
||||
ReadableTime.initialize(this)
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
@file:Suppress("BlockingMethodInNonBlockingContext")
|
||||
@file:RequiresExtension(extension = Build.VERSION_CODES.S, version = 7)
|
||||
|
||||
package com.hippo.ehviewer.coil
|
||||
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.webkit.MimeTypeMap
|
||||
import androidx.annotation.RequiresExtension
|
||||
import coil.ComponentRegistry
|
||||
import coil.ImageLoader
|
||||
import coil.decode.DataSource
|
||||
@@ -30,7 +27,7 @@ class CronetHttpUriFetcher(private val data: String, private val options: Option
|
||||
val diskCache = requireNotNull(imageLoader.diskCache)
|
||||
val snapshot = diskCache.openSnapshot(diskCacheKey) ?: run {
|
||||
val success = cronetRequest(data) {
|
||||
setCacheDisabled(true)
|
||||
disableCache()
|
||||
}.execute {
|
||||
diskCache.suspendEdit(diskCacheKey) {
|
||||
RandomAccessFile(data.toFile(), "rw").use {
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
@file:RequiresExtension(extension = Build.VERSION_CODES.S, version = 7)
|
||||
|
||||
package com.hippo.ehviewer.cronet
|
||||
|
||||
import android.net.http.HttpEngine
|
||||
import android.net.http.HttpException
|
||||
import android.net.http.UrlRequest
|
||||
import android.net.http.UrlResponseInfo
|
||||
import android.os.Build
|
||||
import androidx.annotation.RequiresExtension
|
||||
import com.hippo.ehviewer.EhApplication
|
||||
import com.hippo.ehviewer.client.CHROME_ACCEPT
|
||||
import com.hippo.ehviewer.client.CHROME_ACCEPT_LANGUAGE
|
||||
@@ -20,6 +12,10 @@ import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okio.Path.Companion.toOkioPath
|
||||
import org.chromium.net.CronetEngine
|
||||
import org.chromium.net.CronetException
|
||||
import org.chromium.net.UrlRequest
|
||||
import org.chromium.net.UrlResponseInfo
|
||||
import splitties.init.appCtx
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.channels.FileChannel
|
||||
@@ -32,23 +28,24 @@ import kotlin.coroutines.resumeWithException
|
||||
private const val TAG = "CronetRequest"
|
||||
val pool = DirectByteBufferPool(32)
|
||||
|
||||
val cronetHttpClient: HttpEngine = HttpEngine.Builder(appCtx).apply {
|
||||
setEnableBrotli(true)
|
||||
val cronetHttpClient: CronetEngine = CronetEngine.Builder(appCtx).apply {
|
||||
enableBrotli(true)
|
||||
val cache = (appCtx.cacheDir.toOkioPath() / "http_cache").toFile().apply { mkdirs() }
|
||||
setStoragePath(cache.absolutePath)
|
||||
setEnableHttpCache(HttpEngine.Builder.HTTP_CACHE_DISK_NO_HTTP, 100 * 1024)
|
||||
enableHttpCache(CronetEngine.Builder.HTTP_CACHE_DISK_NO_HTTP, 100 * 1024)
|
||||
setUserAgent(CHROME_USER_AGENT)
|
||||
}.build()
|
||||
|
||||
val cronetHttpClientExecutor = EhApplication.baseOkHttpClient.dispatcher.executorService
|
||||
|
||||
// TODO: Rewrite this to use android.net.http.HttpEngine and make it Android 14 only when released
|
||||
class CronetRequest {
|
||||
lateinit var consumer: (ByteBuffer) -> Unit
|
||||
lateinit var onResponse: CronetRequest.(UrlResponseInfo) -> Unit
|
||||
lateinit var request: UrlRequest
|
||||
lateinit var onError: (Throwable) -> Unit
|
||||
lateinit var readerCont: Continuation<Unit>
|
||||
val callback = object : UrlRequest.Callback {
|
||||
val callback = object : UrlRequest.Callback() {
|
||||
override fun onRedirectReceived(req: UrlRequest, info: UrlResponseInfo, url: String) {
|
||||
logcat(tag = TAG) { "Redirected to $url" }
|
||||
req.followRedirect()
|
||||
@@ -67,18 +64,14 @@ class CronetRequest {
|
||||
readerCont.resume(Unit)
|
||||
}
|
||||
|
||||
override fun onFailed(req: UrlRequest, info: UrlResponseInfo?, e: HttpException) {
|
||||
override fun onFailed(req: UrlRequest, info: UrlResponseInfo?, e: CronetException) {
|
||||
onError(e)
|
||||
}
|
||||
|
||||
override fun onCanceled(req: UrlRequest, info: UrlResponseInfo?) {
|
||||
// No-op
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline fun cronetRequest(url: String, referer: String? = null, conf: UrlRequest.Builder.() -> Unit = {}) = CronetRequest().apply {
|
||||
request = cronetHttpClient.newUrlRequestBuilder(url, cronetHttpClientExecutor, callback).apply {
|
||||
request = cronetHttpClient.newUrlRequestBuilder(url, callback, cronetHttpClientExecutor).apply {
|
||||
addHeader("Cookie", EhCookieStore.getCookieHeader(url.toHttpUrl()))
|
||||
addHeader("Accept", CHROME_ACCEPT)
|
||||
addHeader("Accept-Language", CHROME_ACCEPT_LANGUAGE)
|
||||
|
||||
@@ -135,9 +135,9 @@ class SpiderDen(mGalleryInfo: GalleryInfo) {
|
||||
): Boolean {
|
||||
return if (isCronetSupported) {
|
||||
cronetRequest(url, referer) {
|
||||
setCacheDisabled(true)
|
||||
disableCache()
|
||||
}.execute { info ->
|
||||
val headers = info.headers.asMap
|
||||
val headers = info.allHeaders
|
||||
val type = headers["Content-Type"]?.first()?.toMediaType()?.subtype ?: "jpg"
|
||||
val length = headers["Content-Length"]!!.first().toLong()
|
||||
saveResponseMeta(index, type, length) { file ->
|
||||
|
||||
@@ -9,7 +9,6 @@ import io.ktor.util.encodeBase64
|
||||
import moe.tarsin.coroutines.runSuspendCatching
|
||||
import okhttp3.Request
|
||||
import okio.sink
|
||||
import org.json.JSONObject
|
||||
import tachiyomi.data.release.GithubArtifacts
|
||||
import tachiyomi.data.release.GithubCommitComparison
|
||||
import tachiyomi.data.release.GithubRelease
|
||||
@@ -20,7 +19,9 @@ import java.time.temporal.ChronoUnit
|
||||
import java.util.zip.ZipInputStream
|
||||
|
||||
private const val API_URL = "https://api.github.com/repos/${BuildConfig.REPO_NAME}"
|
||||
private const val LATEST_RELEASE_URL = "$API_URL/releases/latest"
|
||||
private const val RELEASE_URL = "$API_URL/releases"
|
||||
private const val LATEST_RELEASE_URL = "$RELEASE_URL/latest"
|
||||
private const val GMS_SUFFIX = "-gms"
|
||||
|
||||
object AppUpdater {
|
||||
suspend fun checkForUpdate(forceCheck: Boolean = false): Release? {
|
||||
@@ -31,10 +32,7 @@ object AppUpdater {
|
||||
Settings.lastUpdateDay = now.epochSecond
|
||||
if (Settings.useCIUpdateChannel) {
|
||||
val curSha = BuildConfig.COMMIT_SHA
|
||||
val branch = ghRequest(API_URL).execute {
|
||||
JSONObject(body.string()).getString("default_branch")
|
||||
}
|
||||
val workflowRunsUrl = "$API_URL/actions/workflows/ci.yml/runs?branch=$branch&status=success&per_page=1"
|
||||
val workflowRunsUrl = "$API_URL/actions/workflows/ci.yml/runs?branch=${BuildConfig.BRANCH}&status=success&per_page=1"
|
||||
val workflowRun = ghRequest(workflowRunsUrl).executeAndParseAs<GithubWorkflowRuns>().workflowRuns[0]
|
||||
val shortSha = workflowRun.headSha.take(7)
|
||||
if (shortSha != curSha) {
|
||||
@@ -51,10 +49,11 @@ object AppUpdater {
|
||||
} else {
|
||||
val curVersion = BuildConfig.VERSION_NAME
|
||||
val release = ghRequest(LATEST_RELEASE_URL).executeAndParseAs<GithubRelease>()
|
||||
val latestVersion = release.version
|
||||
val latestVersion = release.version + GMS_SUFFIX
|
||||
val description = release.info
|
||||
val downloadUrl = release.getDownloadLink()
|
||||
if (latestVersion != curVersion) {
|
||||
val downloadUrl = ghRequest("$RELEASE_URL/tags/$latestVersion")
|
||||
.executeAndParseAs<GithubRelease>().getDownloadLink()
|
||||
return Release(latestVersion, description, downloadUrl)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.hippo.ehviewer.util
|
||||
|
||||
import android.os.Build
|
||||
import androidx.annotation.ChecksSdkIntAtLeast
|
||||
import com.google.android.gms.net.CronetProviderInstaller
|
||||
|
||||
@get:ChecksSdkIntAtLeast(Build.VERSION_CODES.S, extension = 7)
|
||||
val isCronetSupported: Boolean
|
||||
get() = isAtLeastSExtension7
|
||||
get() = isAtLeastQ && CronetProviderInstaller.isInstalled()
|
||||
@@ -1,8 +1,5 @@
|
||||
package com.hippo.ehviewer.util
|
||||
|
||||
import android.os.Build
|
||||
import android.os.ext.SdkExtensions
|
||||
|
||||
val isAtLeastQ = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
|
||||
val isAtLeastR = Build.VERSION.SDK_INT >= Build.VERSION_CODES.R
|
||||
val isAtLeastSExtension7 = isAtLeastR && SdkExtensions.getExtensionVersion(Build.VERSION_CODES.S) >= 7
|
||||
Reference in new issue
Block a user