diff --git a/app/src/main/java/com/github/libretube/obj/update/UpdateInfo.kt b/app/src/main/java/com/github/libretube/obj/update/UpdateInfo.kt index 33100ef07..175d54a7e 100644 --- a/app/src/main/java/com/github/libretube/obj/update/UpdateInfo.kt +++ b/app/src/main/java/com/github/libretube/obj/update/UpdateInfo.kt @@ -1,10 +1,13 @@ package com.github.libretube.obj.update +import android.os.Parcelable +import kotlinx.parcelize.Parcelize import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @Serializable +@Parcelize data class UpdateInfo( @SerialName("html_url") val htmlUrl: String, val name: String -) +) : Parcelable diff --git a/app/src/main/java/com/github/libretube/ui/dialogs/UpdateAvailableDialog.kt b/app/src/main/java/com/github/libretube/ui/dialogs/UpdateAvailableDialog.kt index a439889b0..33594a4ef 100644 --- a/app/src/main/java/com/github/libretube/ui/dialogs/UpdateAvailableDialog.kt +++ b/app/src/main/java/com/github/libretube/ui/dialogs/UpdateAvailableDialog.kt @@ -7,19 +7,16 @@ import androidx.core.net.toUri import androidx.fragment.app.DialogFragment import com.github.libretube.R import com.github.libretube.constants.IntentData +import com.github.libretube.extensions.parcelable import com.github.libretube.obj.update.UpdateInfo import com.google.android.material.dialog.MaterialAlertDialogBuilder -import kotlinx.serialization.json.Json class UpdateAvailableDialog : DialogFragment() { private lateinit var updateInfo: UpdateInfo override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - arguments?.let { - val encodedString = it.getString(IntentData.updateInfo)!! - updateInfo = Json.decodeFromString(encodedString) - } + updateInfo = requireArguments().parcelable(IntentData.updateInfo)!! } override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { diff --git a/app/src/main/java/com/github/libretube/ui/preferences/MainSettings.kt b/app/src/main/java/com/github/libretube/ui/preferences/MainSettings.kt index 91b5edc87..0d6c7de7d 100644 --- a/app/src/main/java/com/github/libretube/ui/preferences/MainSettings.kt +++ b/app/src/main/java/com/github/libretube/ui/preferences/MainSettings.kt @@ -52,10 +52,9 @@ class MainSettings : BasePreferenceFragment() { if (BuildConfig.VERSION_NAME != updateInfo.name) { // show the UpdateAvailableDialog if there's an update available - val encodedUpdateInfo = Json.encodeToString(updateInfo) val newUpdateAvailableDialog = UpdateAvailableDialog() newUpdateAvailableDialog.arguments = - bundleOf(IntentData.updateInfo to encodedUpdateInfo) + bundleOf(IntentData.updateInfo to updateInfo) newUpdateAvailableDialog.show( childFragmentManager, UpdateAvailableDialog::class.java.name