Start the published version at 0.001.
This commit is contained in:
1 parent
119f9b9554
commit
ffad275e13
2 files changed
+12
-3
No files matched your search
@@ -13,8 +13,8 @@ android {
|
||||
applicationId = "com.racingapp.pitlog"
|
||||
minSdk = 26
|
||||
targetSdk = 36
|
||||
versionCode = 5
|
||||
versionName = "1.4"
|
||||
versionCode = 1
|
||||
versionName = "0.001"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
|
||||
@@ -67,7 +67,7 @@ private fun fetchLatest(): PostedRelease? {
|
||||
|
||||
private fun parseRelease(body: String): PostedRelease? {
|
||||
val json = JSONObject(body)
|
||||
val versionCode = json.optString("tag_name").removePrefix("v").toLongOrNull() ?: return null
|
||||
val versionCode = versionCodeOf(json.optString("tag_name")) ?: return null
|
||||
val assets = json.optJSONArray("assets") ?: return null
|
||||
for (index in 0 until assets.length()) {
|
||||
val asset = assets.optJSONObject(index) ?: continue
|
||||
@@ -80,6 +80,15 @@ private fun parseRelease(body: String): PostedRelease? {
|
||||
return null
|
||||
}
|
||||
|
||||
private fun versionCodeOf(tag: String): Long? {
|
||||
val raw = tag.removePrefix("v")
|
||||
raw.toLongOrNull()?.let { return it }
|
||||
if (!raw.matches(Regex("""\d+\.\d{3}"""))) return null
|
||||
val whole = raw.substringBefore('.').toLong()
|
||||
val fraction = raw.substringAfter('.').toLong()
|
||||
return whole * 1000 + fraction
|
||||
}
|
||||
|
||||
private fun downloadApk(context: Context, apkUrl: String): File? {
|
||||
val connection = open(apkUrl) ?: return null
|
||||
return try {
|
||||
|
||||
Reference in new issue
Block a user