fix: auto-updater download (#175)

* update endpoint link
This commit is contained in:
auth 2023-08-06 22:03:43 +02:00 committed by GitHub
parent 4182f53f23
commit 7ddc43d0a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 7 deletions

View File

@ -1,13 +1,13 @@
package me.rhunk.snapenhance.features.impl
import android.annotation.SuppressLint
import android.app.AlertDialog
import android.app.DownloadManager
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.net.Uri
import android.os.Build
import android.os.Environment
import me.rhunk.snapenhance.BuildConfig
import me.rhunk.snapenhance.Logger
@ -43,6 +43,11 @@ class AutoUpdater : Feature("AutoUpdater", loadParams = FeatureLoadParams.ACTIVI
}
}
@Suppress("DEPRECATION")
private fun getCPUArchitecture(): String {
return Build.CPU_ABI
}
@SuppressLint("UnspecifiedRegisterReceiverFlag")
fun checkForUpdates(): String? {
val endpoint = Request.Builder().url("https://api.github.com/repos/rhunk/SnapEnhance/releases").build()
@ -58,8 +63,15 @@ class AutoUpdater : Feature("AutoUpdater", loadParams = FeatureLoadParams.ACTIVI
val latestVersion = latestRelease.getString("tag_name")
if (latestVersion.removePrefix("v") == BuildConfig.VERSION_NAME) return null
val architectureName = when (getCPUArchitecture()) {
"armeabi-v7a" -> "armv7"
"armeabi" -> "armv7"
"arm64-v8a" -> "armv8"
else -> { throw Throwable("Failed getting architecture") }
}
val releaseContentBody = latestRelease.getString("body")
val downloadEndpoint = latestRelease.getJSONArray("assets").getJSONObject(0).getString("browser_download_url")
val downloadEndpoint = "https://github.com/rhunk/SnapEnhance/releases/download/${latestVersion}/app-${latestVersion.removePrefix("v")}-${architectureName}-release-signed.apk"
context.runOnUiThread {
ViewAppearanceHelper.newAlertDialogBuilder(context.mainActivity)
@ -104,7 +116,6 @@ class AutoUpdater : Feature("AutoUpdater", loadParams = FeatureLoadParams.ACTIVI
))
}.show()
}
return latestVersion
}
}

View File

@ -2,11 +2,11 @@
agp = "8.1.0"
junit = "4.13.2"
kotlin = "1.8.21"
kotlinx-coroutines-android = "1.7.2"
kotlin-reflect = "1.8.21"
recyclerview = "1.3.0"
kotlinx-coroutines-android = "1.7.3"
kotlin-reflect = "1.9.0"
recyclerview = "1.3.1"
gson = "2.10.1"
ffmpeg-kit = "5.1.LTS"
ffmpeg-kit = "5.1"
osmdroid-android = "6.1.16"
okhttp = "5.0.0-alpha.11"
dexlib2 = "2.5.2"