From f2e4b2fc9996d475c7f35a6550cefc6893ca6ecf Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 5 Jun 2021 18:30:04 -0400 Subject: [PATCH] Get appropriate download link based on CPU ABI --- .../kanade/tachiyomi/data/updater/GithubRelease.kt | 14 ++++++++++++-- .../eu/kanade/tachiyomi/data/updater/UpdaterJob.kt | 2 +- .../eu/kanade/tachiyomi/ui/more/AboutController.kt | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/GithubRelease.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/GithubRelease.kt index 9f669aa75..099ae3359 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/GithubRelease.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/GithubRelease.kt @@ -1,5 +1,6 @@ package eu.kanade.tachiyomi.data.updater +import android.os.Build import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -22,8 +23,17 @@ class GithubRelease( * Get download link of latest release from the assets. * @return download link of latest release. */ - val downloadLink: String - get() = assets[0].downloadLink + fun getDownloadLink(): String { + val apkVariant = when (Build.SUPPORTED_ABIS[0]) { + "arm64-v8a" -> "-arm64-v8a" + "armeabi-v7a" -> "-armeabi-v7a" + "x86", "x86_64" -> "-x86" + else -> "" + } + + return assets.find { it.downloadLink.contains("tachiyomi$apkVariant-") }?.downloadLink + ?: assets[0].downloadLink + } /** * Assets class containing download url. diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterJob.kt b/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterJob.kt index 316ddc8b9..8abfc8566 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterJob.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/updater/UpdaterJob.kt @@ -21,7 +21,7 @@ class UpdaterJob(private val context: Context, workerParams: WorkerParameters) : val result = GithubUpdateChecker().checkForUpdate() if (result is GithubUpdateResult.NewUpdate) { - UpdaterNotifier(context).promptUpdate(result.release.downloadLink) + UpdaterNotifier(context).promptUpdate(result.release.getDownloadLink()) } Result.success() } catch (e: Exception) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt index 1f8e902fe..0f880a541 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt @@ -110,7 +110,7 @@ class AboutController : SettingsController(), NoToolbarElevationController { when (val result = updateChecker.checkForUpdate()) { is GithubUpdateResult.NewUpdate -> { val body = result.release.info - val url = result.release.downloadLink + val url = result.release.getDownloadLink() // Create confirmation window NewUpdateDialogController(body, url).showDialog(router)