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:
GGB
2026-09-27 19:21:02 +02:00
co-authored by Claude Sonnet 5
parent 286872c972
commit d67c2a54de
2 changed files with 24 additions and 2 deletions
+2 -2
View File
@@ -11,8 +11,8 @@ android {
applicationId = "de.ggb.kwabatv" applicationId = "de.ggb.kwabatv"
minSdk = 21 minSdk = 21
targetSdk = 34 targetSdk = 34
versionCode = 1 versionCode = 2
versionName = "1.0" versionName = "1.1.0"
buildConfigField("String", "WEBSITE_URL", "\"https://kwaba-dev.whodovoodoo.pasteaf.de/tv\"") buildConfigField("String", "WEBSITE_URL", "\"https://kwaba-dev.whodovoodoo.pasteaf.de/tv\"")
} }
@@ -1,6 +1,8 @@
package de.ggb.kwabatv package de.ggb.kwabatv
import org.json.JSONArray 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. */ /** A qualifying update found on Gitea: display version and the APK's direct download URL. */
data class UpdateInfo(val version: String, val apkDownloadUrl: String) data class UpdateInfo(val version: String, val apkDownloadUrl: String)
@@ -65,4 +67,24 @@ object UpdateChecker {
} }
return best?.second 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
}
}
} }