From af1d0dfee1dff8f82bd8c3970e915608b4e19083 Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Thu, 4 Jun 2026 11:26:09 -0600 Subject: [PATCH 1/2] InAppUpdater: migrate to kotlinx serialization --- .../cloudstream3/utils/InAppUpdater.kt | 46 +++++++++++-------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/InAppUpdater.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/InAppUpdater.kt index b01f6e07e27..743bf99bd60 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/InAppUpdater.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/InAppUpdater.kt @@ -12,7 +12,6 @@ import androidx.core.content.ContextCompat import androidx.core.content.FileProvider import androidx.core.content.edit import androidx.preference.PreferenceManager -import com.fasterxml.jackson.annotation.JsonProperty import com.lagradost.cloudstream3.BuildConfig import com.lagradost.cloudstream3.CommonActivity.showToast import com.lagradost.cloudstream3.MainActivity.Companion.deleteFileOnExit @@ -27,6 +26,8 @@ import com.lagradost.cloudstream3.utils.Coroutines.ioSafe import com.lagradost.cloudstream3.utils.GitInfo.currentCommitHash import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import okio.BufferedSink import okio.buffer import okio.sink @@ -42,38 +43,43 @@ object InAppUpdater { private const val PRERELEASE_PACKAGE_NAME = "com.lagradost.cloudstream3.prerelease" private const val LOG_TAG = "InAppUpdater" + @Serializable private data class GithubAsset( - @JsonProperty("name") val name: String, - @JsonProperty("size") val size: Int, // Size in bytes - @JsonProperty("browser_download_url") val browserDownloadUrl: String, - @JsonProperty("content_type") val contentType: String, // application/vnd.android.package-archive + @SerialName("name") val name: String, + @SerialName("size") val size: Int, // Size in bytes + @SerialName("browser_download_url") val browserDownloadUrl: String, + @SerialName("content_type") val contentType: String, // application/vnd.android.package-archive ) + @Serializable private data class GithubRelease( - @JsonProperty("tag_name") val tagName: String, // Version code - @JsonProperty("body") val body: String, // Description - @JsonProperty("assets") val assets: List, - @JsonProperty("target_commitish") val targetCommitish: String, // Branch - @JsonProperty("prerelease") val prerelease: Boolean, - @JsonProperty("node_id") val nodeId: String, + @SerialName("tag_name") val tagName: String, // Version code + @SerialName("body") val body: String, // Description + @SerialName("assets") val assets: List, + @SerialName("target_commitish") val targetCommitish: String, // Branch + @SerialName("prerelease") val prerelease: Boolean, + @SerialName("node_id") val nodeId: String, ) + @Serializable private data class GithubObject( - @JsonProperty("sha") val sha: String, // SHA-256 hash - @JsonProperty("type") val type: String, - @JsonProperty("url") val url: String, + @SerialName("sha") val sha: String, // SHA-256 hash + @SerialName("type") val type: String, + @SerialName("url") val url: String, ) + @Serializable private data class GithubTag( - @JsonProperty("object") val githubObject: GithubObject, + @SerialName("object") val githubObject: GithubObject, ) + @Serializable private data class Update( - @JsonProperty("shouldUpdate") val shouldUpdate: Boolean, - @JsonProperty("updateURL") val updateURL: String?, - @JsonProperty("updateVersion") val updateVersion: String?, - @JsonProperty("changelog") val changelog: String?, - @JsonProperty("updateNodeId") val updateNodeId: String?, + @SerialName("shouldUpdate") val shouldUpdate: Boolean, + @SerialName("updateURL") val updateURL: String?, + @SerialName("updateVersion") val updateVersion: String?, + @SerialName("changelog") val changelog: String?, + @SerialName("updateNodeId") val updateNodeId: String?, ) private suspend fun Activity.getAppUpdate(installPrerelease: Boolean): Update { From fe50a8efc5f090554293850f7fdc3f63076c365a Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Mon, 8 Jun 2026 11:54:10 -0600 Subject: [PATCH 2/2] Keep JsonProperty where different than variable name --- .../lagradost/cloudstream3/utils/InAppUpdater.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/InAppUpdater.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/InAppUpdater.kt index 743bf99bd60..f2c53c87a1f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/InAppUpdater.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/InAppUpdater.kt @@ -12,6 +12,7 @@ import androidx.core.content.ContextCompat import androidx.core.content.FileProvider import androidx.core.content.edit import androidx.preference.PreferenceManager +import com.fasterxml.jackson.annotation.JsonProperty import com.lagradost.cloudstream3.BuildConfig import com.lagradost.cloudstream3.CommonActivity.showToast import com.lagradost.cloudstream3.MainActivity.Companion.deleteFileOnExit @@ -47,18 +48,18 @@ object InAppUpdater { private data class GithubAsset( @SerialName("name") val name: String, @SerialName("size") val size: Int, // Size in bytes - @SerialName("browser_download_url") val browserDownloadUrl: String, - @SerialName("content_type") val contentType: String, // application/vnd.android.package-archive + @JsonProperty("browser_download_url") @SerialName("browser_download_url") val browserDownloadUrl: String, + @JsonProperty("content_type") @SerialName("content_type") val contentType: String, // application/vnd.android.package-archive ) @Serializable private data class GithubRelease( - @SerialName("tag_name") val tagName: String, // Version code + @JsonProperty("tag_name") @SerialName("tag_name") val tagName: String, // Version code @SerialName("body") val body: String, // Description @SerialName("assets") val assets: List, - @SerialName("target_commitish") val targetCommitish: String, // Branch + @JsonProperty("target_commitish") @SerialName("target_commitish") val targetCommitish: String, // Branch @SerialName("prerelease") val prerelease: Boolean, - @SerialName("node_id") val nodeId: String, + @JsonProperty("node_id") @SerialName("node_id") val nodeId: String, ) @Serializable @@ -70,7 +71,7 @@ object InAppUpdater { @Serializable private data class GithubTag( - @SerialName("object") val githubObject: GithubObject, + @JsonProperty("object") @SerialName("object") val githubObject: GithubObject, ) @Serializable