From eab2b078395970bfd086710b2dbfb0e1cd5f0efe Mon Sep 17 00:00:00 2001 From: Hrisabh Yadav Date: Sun, 22 Feb 2026 09:19:49 +0530 Subject: [PATCH 1/2] Move 'No Subtitles' option to bottom of subtitle list - Moved 'No Subtitles' from top to bottom of adapter - Adjusted subtitle index calculations (removed +1 offset) - Changed condition from <= 0 to >= size for detecting no subtitle selection --- .../cloudstream3/ui/player/GeneratorPlayer.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt index 7138e8dada..af3943a94a 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt @@ -1162,7 +1162,6 @@ class GeneratorPlayer : FullScreenPlayer() { val subsArrayAdapter = ArrayAdapter(ctx, R.layout.sort_bottom_single_choice) - subsArrayAdapter.add(ctx.getString(R.string.no_subtitles).html()) val subtitlesGrouped = currentSubtitles.groupBy { it.originalName }.map { (key, value) -> @@ -1173,7 +1172,7 @@ class GeneratorPlayer : FullScreenPlayer() { val subtitles = subtitlesGrouped.map { it.key.html() } val subtitleGroupIndexStart = - subtitlesGrouped.keys.indexOf(currentSelectedSubtitles?.originalName) + 1 + subtitlesGrouped.keys.indexOf(currentSelectedSubtitles?.originalName) var subtitleGroupIndex = subtitleGroupIndexStart val subtitleOptionIndexStart = @@ -1182,6 +1181,7 @@ class GeneratorPlayer : FullScreenPlayer() { var subtitleOptionIndex = subtitleOptionIndexStart subsArrayAdapter.addAll(subtitles) + subsArrayAdapter.add(ctx.getString(R.string.no_subtitles).html()) subtitleList.adapter = subsArrayAdapter subtitleList.choiceMode = AbsListView.CHOICE_MODE_SINGLE @@ -1200,7 +1200,7 @@ class GeneratorPlayer : FullScreenPlayer() { val subtitleOptions = subtitlesGroupedList - .getOrNull(subtitleGroupIndex - 1)?.value?.map { subtitle -> + .getOrNull(subtitleGroupIndex)?.value?.map { subtitle -> val nameSuffix = subtitle.nameSuffix.html() nameSuffix.ifBlank { when (subtitle.origin) { @@ -1252,7 +1252,7 @@ class GeneratorPlayer : FullScreenPlayer() { } subtitleOptionList.setOnItemClickListener { _, _, which, _ -> - if (which >= (subtitlesGroupedList.getOrNull(subtitleGroupIndex - 1)?.value?.size + if (which >= (subtitlesGroupedList.getOrNull(subtitleGroupIndex)?.value?.size ?: -1) ) { val child = subtitleOptionList.adapter.getView(which, null, subtitleList) @@ -1337,10 +1337,10 @@ class GeneratorPlayer : FullScreenPlayer() { binding.applyBtt.setOnClickListener { var init = sourceIndex != startSource if (subtitleGroupIndex != subtitleGroupIndexStart || subtitleOptionIndex != subtitleOptionIndexStart) { - init = init or if (subtitleGroupIndex <= 0) { + init = init or if (subtitleGroupIndex >= subtitlesGrouped.size) { noSubtitles() } else { - subtitlesGroupedList.getOrNull(subtitleGroupIndex - 1)?.value?.getOrNull( + subtitlesGroupedList.getOrNull(subtitleGroupIndex)?.value?.getOrNull( subtitleOptionIndex )?.let { setSubtitles(it, true) From 23c1d30a696ec48ca92f475d115cb1302d4dd7f7 Mon Sep 17 00:00:00 2001 From: Hrisabh Yadav Date: Wed, 25 Feb 2026 23:09:01 +0530 Subject: [PATCH 2/2] fix: persist "No Subtitles" checkmark when reopening subtitle dialog When "No Subtitles" was selected, currentSelectedSubtitles was null, causing indexOf to return -1 and setItemChecked(-1, true) to silently no-op. Map null to subtitlesGrouped.size (the adapter position of "No Subtitles") to correctly render the checkmark. --- .../com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt index af3943a94a..6f507832de 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt @@ -1171,8 +1171,11 @@ class GeneratorPlayer : FullScreenPlayer() { val subtitles = subtitlesGrouped.map { it.key.html() } - val subtitleGroupIndexStart = + val subtitleGroupIndexStart = if (currentSelectedSubtitles == null) { + subtitlesGrouped.size + } else { subtitlesGrouped.keys.indexOf(currentSelectedSubtitles?.originalName) + } var subtitleGroupIndex = subtitleGroupIndexStart val subtitleOptionIndexStart =