Disable subs toggle

This commit is contained in:
AbdullahM0hamed 2023-01-13 19:00:00 +00:00
parent 06c2cf86ec
commit 1dcdfbaca7
3 changed files with 36 additions and 3 deletions

View file

@ -44,6 +44,7 @@ import java.io.File
const val SUBTITLE_KEY = "subtitle_settings" const val SUBTITLE_KEY = "subtitle_settings"
const val SUBTITLE_AUTO_SELECT_KEY = "subs_auto_select" const val SUBTITLE_AUTO_SELECT_KEY = "subs_auto_select"
const val SUBTITLE_DOWNLOAD_KEY = "subs_auto_download" const val SUBTITLE_DOWNLOAD_KEY = "subs_auto_download"
const val PRIOR_SUB_LANGUAGE = "prior_sub_language"
data class SaveCaptionStyle( data class SaveCaptionStyle(
@JsonProperty("foregroundColor") var foregroundColor: Int, @JsonProperty("foregroundColor") var foregroundColor: Int,
@ -60,6 +61,7 @@ data class SaveCaptionStyle(
@JsonProperty("fixedTextSize") var fixedTextSize: Float?, @JsonProperty("fixedTextSize") var fixedTextSize: Float?,
@JsonProperty("removeCaptions") var removeCaptions: Boolean = false, @JsonProperty("removeCaptions") var removeCaptions: Boolean = false,
@JsonProperty("removeBloat") var removeBloat: Boolean = true, @JsonProperty("removeBloat") var removeBloat: Boolean = true,
@JsonProperty("removeSubs") var removeSubs: Boolean = false,
/** Apply caps lock to the text **/ /** Apply caps lock to the text **/
@JsonProperty("upperCase") var upperCase: Boolean = false, @JsonProperty("upperCase") var upperCase: Boolean = false,
) )
@ -415,6 +417,23 @@ class SubtitlesFragment : Fragment() {
} }
} }
subtitles_disable_subs?.isChecked = state.removeSubs
subtitles_disable_subs?.setOnCheckedChangeListener { _, b ->
state.removeSubs = b
if (b) {
setKey(
PRIOR_SUB_LANGUAGE,
getKey(SUBTITLE_AUTO_SELECT_KEY) ?: "en"
)
setKey(SUBTITLE_AUTO_SELECT_KEY, "")
} else {
setKey(
SUBTITLE_AUTO_SELECT_KEY,
getKey(PRIOR_SUB_LANGUAGE) ?: "en"
)
}
}
subtitles_remove_bloat?.isChecked = state.removeBloat subtitles_remove_bloat?.isChecked = state.removeBloat
subtitles_remove_bloat?.setOnCheckedChangeListener { _, b -> subtitles_remove_bloat?.setOnCheckedChangeListener { _, b ->
state.removeBloat = b state.removeBloat = b

View file

@ -140,9 +140,22 @@
android:nextFocusRight="@id/cancel_btt" android:nextFocusRight="@id/cancel_btt"
android:nextFocusUp="@id/subs_auto_select_language" android:nextFocusUp="@id/subs_auto_select_language"
android:nextFocusDown="@id/subtitles_remove_bloat" android:nextFocusDown="@id/subtitles_disable_subs"
android:text="@string/subs_download_languages" /> android:text="@string/subs_download_languages" />
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/subtitles_disable_subs"
style="@style/SettingsItem"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="@font/google_sans"
android:nextFocusLeft="@id/apply_btt"
android:nextFocusRight="@id/cancel_btt"
android:nextFocusUp="@id/subs_download_languages"
android:nextFocusDown="@id/subtitles_remove_bloat"
android:text="@string/subtitles_disable_subs"
app:drawableEndCompat="@null" />
<com.google.android.material.switchmaterial.SwitchMaterial <com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/subtitles_remove_bloat" android:id="@+id/subtitles_remove_bloat"
style="@style/SettingsItem" style="@style/SettingsItem"
@ -151,7 +164,7 @@
android:fontFamily="@font/google_sans" android:fontFamily="@font/google_sans"
android:nextFocusLeft="@id/apply_btt" android:nextFocusLeft="@id/apply_btt"
android:nextFocusRight="@id/cancel_btt" android:nextFocusRight="@id/cancel_btt"
android:nextFocusUp="@id/subs_download_languages" android:nextFocusUp="@id/subtitles_disable_subs"
android:nextFocusDown="@id/subtitles_remove_captions" android:nextFocusDown="@id/subtitles_remove_captions"
android:text="@string/subtitles_remove_bloat" android:text="@string/subtitles_remove_bloat"
app:drawableEndCompat="@null" /> app:drawableEndCompat="@null" />
@ -245,4 +258,4 @@
android:text="@string/sort_cancel" /> android:text="@string/sort_cancel" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>

View file

@ -521,6 +521,7 @@
<string name="error_invalid_url">Invalid URL</string> <string name="error_invalid_url">Invalid URL</string>
<string name="error">Error</string> <string name="error">Error</string>
<string name="subtitles_remove_captions">Remove closed captions from subtitles</string> <string name="subtitles_remove_captions">Remove closed captions from subtitles</string>
<string name="subtitles_disable_subs">Disable subtitles</string>
<string name="subtitles_remove_bloat">Remove bloat from subtitles</string> <string name="subtitles_remove_bloat">Remove bloat from subtitles</string>
<string name="subtitles_filter_lang">Filter by preferred media language</string> <string name="subtitles_filter_lang">Filter by preferred media language</string>
<string name="extras">Extras</string> <string name="extras">Extras</string>