From 3a779c5ad1d147feea2cdcf3c858515fb4c0f5ed Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Thu, 4 Jun 2026 18:47:33 -0600 Subject: [PATCH 1/2] subtitles: migrate to kotlinx serialization --- .../subtitles/ChromecastSubtitlesFragment.kt | 20 +++++---- .../ui/subtitles/SubtitlesFragment.kt | 44 +++++++++---------- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/ChromecastSubtitlesFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/ChromecastSubtitlesFragment.kt index f9b1cb1fe88..da3665b9474 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/ChromecastSubtitlesFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/ChromecastSubtitlesFragment.kt @@ -13,7 +13,6 @@ import android.widget.Toast import androidx.annotation.OptIn import androidx.media3.common.text.Cue import androidx.media3.common.util.UnstableApi -import com.fasterxml.jackson.annotation.JsonProperty import com.google.android.gms.cast.TextTrackStyle.EDGE_TYPE_DEPRESSED import com.google.android.gms.cast.TextTrackStyle.EDGE_TYPE_DROP_SHADOW import com.google.android.gms.cast.TextTrackStyle.EDGE_TYPE_NONE @@ -38,18 +37,21 @@ import com.lagradost.cloudstream3.utils.UIHelper.fixSystemBarsPadding import com.lagradost.cloudstream3.utils.UIHelper.hideSystemUI import com.lagradost.cloudstream3.utils.UIHelper.navigate import com.lagradost.cloudstream3.utils.UIHelper.popCurrentPage +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable const val CHROME_SUBTITLE_KEY = "chome_subtitle_settings" +@Serializable data class SaveChromeCaptionStyle( - @JsonProperty("fontFamily") var fontFamily: String? = null, - @JsonProperty("fontGenericFamily") var fontGenericFamily: Int? = null, - @JsonProperty("backgroundColor") var backgroundColor: Int = 0x00FFFFFF, // transparent - @JsonProperty("edgeColor") var edgeColor: Int = Color.BLACK, // BLACK - @JsonProperty("edgeType") var edgeType: Int = EDGE_TYPE_OUTLINE, - @JsonProperty("foregroundColor") var foregroundColor: Int = Color.WHITE, - @JsonProperty("fontScale") var fontScale: Float = 1.05f, - @JsonProperty("windowColor") var windowColor: Int = Color.TRANSPARENT, + @SerialName("fontFamily") var fontFamily: String? = null, + @SerialName("fontGenericFamily") var fontGenericFamily: Int? = null, + @SerialName("backgroundColor") var backgroundColor: Int = 0x00FFFFFF, // transparent + @SerialName("edgeColor") var edgeColor: Int = Color.BLACK, // BLACK + @SerialName("edgeType") var edgeType: Int = EDGE_TYPE_OUTLINE, + @SerialName("foregroundColor") var foregroundColor: Int = Color.WHITE, + @SerialName("fontScale") var fontScale: Float = 1.05f, + @SerialName("windowColor") var windowColor: Int = Color.TRANSPARENT, ) class ChromecastSubtitlesFragment : BaseFragment( diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/SubtitlesFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/SubtitlesFragment.kt index 5f716cca3f1..fefd44f228b 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/SubtitlesFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/SubtitlesFragment.kt @@ -25,7 +25,6 @@ import androidx.media3.common.util.UnstableApi import androidx.media3.ui.CaptionStyleCompat import androidx.media3.ui.SubtitleView import androidx.preference.PreferenceManager -import com.fasterxml.jackson.annotation.JsonProperty import com.jaredrummler.android.colorpicker.ColorPickerDialog import com.lagradost.cloudstream3.CloudStreamApp.Companion.getKey import com.lagradost.cloudstream3.CloudStreamApp.Companion.setKey @@ -54,40 +53,41 @@ import com.lagradost.cloudstream3.utils.UIHelper.hideSystemUI import com.lagradost.cloudstream3.utils.UIHelper.navigate import com.lagradost.cloudstream3.utils.UIHelper.popCurrentPage import com.lagradost.cloudstream3.utils.UIHelper.toPx +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable import java.io.File const val SUBTITLE_KEY = "subtitle_settings" const val SUBTITLE_AUTO_SELECT_KEY = "subs_auto_select" const val SUBTITLE_DOWNLOAD_KEY = "subs_auto_download" +@Serializable data class SaveCaptionStyle( - @JsonProperty("foregroundColor") var foregroundColor: Int, - @JsonProperty("backgroundColor") var backgroundColor: Int, - @JsonProperty("windowColor") var windowColor: Int, + @SerialName("foregroundColor") var foregroundColor: Int, + @SerialName("backgroundColor") var backgroundColor: Int, + @SerialName("windowColor") var windowColor: Int, @OptIn(UnstableApi::class) - @JsonProperty("edgeType") var edgeType: @CaptionStyleCompat.EdgeType Int, - @JsonProperty("edgeColor") var edgeColor: Int, - @FontRes - @JsonProperty("typeface") var typeface: Int?, - @JsonProperty("typefaceFilePath") var typefaceFilePath: String?, - /**in dp**/ - @JsonProperty("elevation") var elevation: Int, - /**in sp**/ - @JsonProperty("fixedTextSize") var fixedTextSize: Float?, - @Px - @JsonProperty("edgeSize") var edgeSize: Float? = null, - @JsonProperty("removeCaptions") var removeCaptions: Boolean = false, - @JsonProperty("removeBloat") var removeBloat: Boolean = true, + @SerialName("edgeType") var edgeType: @CaptionStyleCompat.EdgeType Int, + @SerialName("edgeColor") var edgeColor: Int, + @FontRes @SerialName("typeface") var typeface: Int?, + @SerialName("typefaceFilePath") var typefaceFilePath: String?, + /** in dp **/ + @SerialName("elevation") var elevation: Int, + /** in sp **/ + @SerialName("fixedTextSize") var fixedTextSize: Float?, + @Px @SerialName("edgeSize") var edgeSize: Float? = null, + @SerialName("removeCaptions") var removeCaptions: Boolean = false, + @SerialName("removeBloat") var removeBloat: Boolean = true, /** Apply caps lock to the text **/ - @JsonProperty("upperCase") var upperCase: Boolean = false, + @SerialName("upperCase") var upperCase: Boolean = false, /** Apply bold to the text **/ - @JsonProperty("bold") var bold: Boolean = false, + @SerialName("bold") var bold: Boolean = false, /** Apply italic to the text **/ - @JsonProperty("italic") var italic: Boolean = false, + @SerialName("italic") var italic: Boolean = false, /** in px, background radius, aka how round the background (backgroundColor) on each row is **/ - @JsonProperty("backgroundRadius") var backgroundRadius: Float? = null, + @SerialName("backgroundRadius") var backgroundRadius: Float? = null, /** The SSA_ALIGNMENT */ - @JsonProperty("alignment") var alignment: Int? = null, + @SerialName("alignment") var alignment: Int? = null, ) const val DEF_SUBS_ELEVATION = 20 From 0fcd6cbcbd403e8a40ce2fb5e87a94ee7c67c014 Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Fri, 5 Jun 2026 11:46:39 -0600 Subject: [PATCH 2/2] Update comments --- .../cloudstream3/ui/subtitles/SubtitlesFragment.kt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/SubtitlesFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/SubtitlesFragment.kt index fefd44f228b..f07b2731cfc 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/SubtitlesFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/subtitles/SubtitlesFragment.kt @@ -71,20 +71,18 @@ data class SaveCaptionStyle( @SerialName("edgeColor") var edgeColor: Int, @FontRes @SerialName("typeface") var typeface: Int?, @SerialName("typefaceFilePath") var typefaceFilePath: String?, - /** in dp **/ - @SerialName("elevation") var elevation: Int, - /** in sp **/ - @SerialName("fixedTextSize") var fixedTextSize: Float?, + @SerialName("elevation") var elevation: Int, // in dp + @SerialName("fixedTextSize") var fixedTextSize: Float?, // in sp @Px @SerialName("edgeSize") var edgeSize: Float? = null, @SerialName("removeCaptions") var removeCaptions: Boolean = false, @SerialName("removeBloat") var removeBloat: Boolean = true, - /** Apply caps lock to the text **/ + /** Apply caps lock to the text */ @SerialName("upperCase") var upperCase: Boolean = false, - /** Apply bold to the text **/ + /** Apply bold to the text */ @SerialName("bold") var bold: Boolean = false, - /** Apply italic to the text **/ + /** Apply italic to the text */ @SerialName("italic") var italic: Boolean = false, - /** in px, background radius, aka how round the background (backgroundColor) on each row is **/ + /** in px, background radius, aka how round the background (backgroundColor) on each row is */ @SerialName("backgroundRadius") var backgroundRadius: Float? = null, /** The SSA_ALIGNMENT */ @SerialName("alignment") var alignment: Int? = null,