Эх сурвалжийг харах

Get appropriate download link based on CPU ABI

arkon 3 жил өмнө
parent
commit
f2e4b2fc99

+ 12 - 2
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.

+ 1 - 1
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) {

+ 1 - 1
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)