Add real Gitea release fetch; bump version to 1.1.0
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LHgWjmEJXsJEi1EVAoTp4K
This commit is contained in:
@@ -11,8 +11,8 @@ android {
|
||||
applicationId = "de.ggb.kwabatv"
|
||||
minSdk = 21
|
||||
targetSdk = 34
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
versionCode = 2
|
||||
versionName = "1.1.0"
|
||||
buildConfigField("String", "WEBSITE_URL", "\"https://kwaba-dev.whodovoodoo.pasteaf.de/tv\"")
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package de.ggb.kwabatv
|
||||
|
||||
import org.json.JSONArray
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
|
||||
/** A qualifying update found on Gitea: display version and the APK's direct download URL. */
|
||||
data class UpdateInfo(val version: String, val apkDownloadUrl: String)
|
||||
@@ -65,4 +67,24 @@ object UpdateChecker {
|
||||
}
|
||||
return best?.second
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the releases list and returns the newest qualifying update, or null - including
|
||||
* on any failure (network unreachable, non-200 response, malformed body). An update check
|
||||
* is a nice-to-have; it must never be able to crash or visibly disrupt normal app use.
|
||||
*/
|
||||
fun checkForUpdate(currentVersion: String): UpdateInfo? {
|
||||
return try {
|
||||
val connection = URL(RELEASES_API_URL).openConnection() as HttpURLConnection
|
||||
connection.connectTimeout = 8000
|
||||
connection.readTimeout = 8000
|
||||
connection.requestMethod = "GET"
|
||||
connection.setRequestProperty("Accept", "application/json")
|
||||
if (connection.responseCode != 200) return null
|
||||
val body = connection.inputStream.bufferedReader().use { it.readText() }
|
||||
pickUpdate(body, currentVersion)
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user