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