Fix: Fixed the UpdateManager so that it can now get the apkUrl correctly
Signed-off-by: HeCodes2Much <wayne6324@gmail.com>
This commit is contained in:
@@ -46,21 +46,26 @@ class UpdateManagerHelper(private val fragment: Fragment) {
|
|||||||
val tagName = jsonObject.getString("tag_name")
|
val tagName = jsonObject.getString("tag_name")
|
||||||
val latestVersion = tagName.replace("v", "")
|
val latestVersion = tagName.replace("v", "")
|
||||||
val assets = jsonObject.getJSONArray("assets")
|
val assets = jsonObject.getJSONArray("assets")
|
||||||
val apkUrl = (assets.get(1) as JSONObject).getString("browser_download_url")
|
|
||||||
|
|
||||||
Log.d("UpdateManager", "Latest version: $latestVersion | Current version: $currentVersion")
|
// Check if assets array has elements
|
||||||
|
if (assets.length() > 0) {
|
||||||
|
val apkUrl = (assets.get(0) as JSONObject).getString("browser_download_url")
|
||||||
|
Log.d("UpdateManager", "APK URL: $apkUrl | Latest version: $latestVersion | Current version: $currentVersion")
|
||||||
|
|
||||||
if (latestVersion > currentVersion) {
|
if (latestVersion > currentVersion) {
|
||||||
val declinedVersion = sharedPreferences.getString("declined_version", "")
|
val declinedVersion = sharedPreferences.getString("declined_version", "")
|
||||||
|
|
||||||
Log.d("UpdateManager", "Declined version: $declinedVersion")
|
Log.d("UpdateManager", "Declined version: $declinedVersion")
|
||||||
|
|
||||||
if (latestVersion != declinedVersion) {
|
if (latestVersion != declinedVersion) {
|
||||||
// Ask the user if they want to update
|
// Ask the user if they want to update
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
showUpdateDialog(latestVersion, apkUrl)
|
showUpdateDialog(latestVersion, apkUrl)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Log.e("UpdateManager", "Assets array is empty")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user