From 5ae56a07ad8c0bfac19375c5bf29337d2424ec73 Mon Sep 17 00:00:00 2001 From: LagradOst Date: Thu, 16 Sep 2021 14:46:21 +0200 Subject: [PATCH] subtitles fixed --- .../cloudstream3/ui/player/PlayerFragment.kt | 12 ++++-- .../ui/subtitles/SubtitlesFragment.kt | 41 +++++++++++++++++++ .../utils/VideoDownloadManager.kt | 2 +- app/src/main/res/layout/subtitle_settings.xml | 5 +++ app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/settings.xml | 2 +- 6 files changed, 58 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt index a3b925b4..27011db2 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt @@ -17,6 +17,7 @@ import android.media.AudioManager import android.net.Uri import android.os.* import android.provider.Settings +import android.util.TypedValue import android.view.LayoutInflater import android.view.MotionEvent import android.view.View @@ -107,7 +108,6 @@ import kotlinx.android.synthetic.main.fragment_player.* import kotlinx.android.synthetic.main.player_custom_layout.* import kotlinx.coroutines.* import java.io.File -import java.lang.reflect.Array.setInt import javax.net.ssl.HttpsURLConnection import javax.net.ssl.SSLContext import javax.net.ssl.SSLSession @@ -966,6 +966,12 @@ class PlayerFragment : Fragment() { subStyle = style subView?.setStyle(ctx.fromSaveToStyle(style)) subView?.translationY = -style.elevation.toPx.toFloat() + + if (style.fixedTextSize != null) { + subView?.setFixedTextSize(TypedValue.COMPLEX_UNIT_SP, style.fixedTextSize!!) + } else { + subView?.setUserDefaultTextSize() + } } } @@ -1014,7 +1020,7 @@ class PlayerFragment : Fragment() { context?.let { ctx -> swipeEnabled = settingsManager.getBoolean(ctx.getString(R.string.swipe_enabled_key), true) swipeVerticalEnabled = settingsManager.getBoolean(ctx.getString(R.string.swipe_vertical_enabled_key), true) - playBackSpeedEnabled = settingsManager.getBoolean(ctx.getString(R.string.playback_speed_enabled_key), true) + playBackSpeedEnabled = settingsManager.getBoolean(ctx.getString(R.string.playback_speed_enabled_key), false) playerResizeEnabled = settingsManager.getBoolean(ctx.getString(R.string.player_resize_enabled_key), true) doubleTapEnabled = settingsManager.getBoolean(ctx.getString(R.string.double_tap_enabled_key), false) useSystemBrightness = settingsManager.getBoolean(ctx.getString(R.string.use_system_brightness_key), false) @@ -1739,7 +1745,7 @@ class PlayerFragment : Fragment() { endsWith("vtt", true) -> MimeTypes.TEXT_VTT endsWith("srt", true) -> MimeTypes.APPLICATION_SUBRIP endsWith("xml", true) || endsWith("ttml", true) -> MimeTypes.APPLICATION_TTML - else -> MimeTypes.TEXT_VTT + else -> MimeTypes.APPLICATION_SUBRIP // TODO get request to see } } 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 4a2d4b32..691623c6 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 @@ -50,6 +50,8 @@ data class SaveCaptionStyle( var typeface: Int?, /**in dp**/ var elevation: Int, + /**in sp**/ + var fixedTextSize: Float?, ) class SubtitlesFragment : Fragment() { @@ -106,6 +108,7 @@ class SubtitlesFragment : Fragment() { getDefColor(1), null, 0, + null, ) } @@ -281,6 +284,44 @@ class SubtitlesFragment : Fragment() { return@setOnLongClickListener true } + subs_font_size.setOnClickListener { textView -> + val suffix = "sp" + val fontSizes = listOf( + Pair(null, "Normal"), + Pair(6f,"6$suffix"), + Pair(8f,"8$suffix"), + Pair(9f,"9$suffix"), + Pair(10f,"10$suffix"), + Pair(11f,"11$suffix"), + Pair(12f,"12$suffix"), + Pair(14f,"14$suffix"), + Pair(18f,"18$suffix"), + Pair(24f,"24$suffix"), + Pair(30f,"30$suffix"), + Pair(36f,"36$suffix"), + Pair(48f,"48$suffix"), + Pair(60f,"60$suffix"), + ) + + textView.context.showBottomDialog( + fontSizes.map { it.second }, + fontSizes.map { it.first }.indexOf(state.fixedTextSize), + (textView as TextView).text.toString(), + false, + dismissCallback + ) { index -> + state.fixedTextSize = fontSizes.map { it.first }[index] + //textView.context.updateState() // font size not changed + } + } + + subs_font_size.setOnLongClickListener { _ -> + state.fixedTextSize = null + //textView.context.updateState() // font size not changed + showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT) + return@setOnLongClickListener true + } + subs_font.setOnClickListener { textView -> val fontTypes = listOf( Pair(null, "Normal"), diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadManager.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadManager.kt index 2ff4533d..f663c362 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadManager.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadManager.kt @@ -580,7 +580,7 @@ object VideoDownloadManager { val currentMimeType = when (extension) { "vtt" -> "text/vtt" "mp4" -> "video/mp4" - "srt" -> "text/plain" + "srt" -> "application/x-subrip"//"text/plain" else -> null } val newFile = ContentValues().apply { diff --git a/app/src/main/res/layout/subtitle_settings.xml b/app/src/main/res/layout/subtitle_settings.xml index d76e5ea1..9937fd07 100644 --- a/app/src/main/res/layout/subtitle_settings.xml +++ b/app/src/main/res/layout/subtitle_settings.xml @@ -47,6 +47,11 @@ android:text="@string/subs_font" style="@style/SettingsItem" /> + Edge Type Subtitle Elevation Font + Font Size Search using providers Search using types diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml index df19d139..4d559c8c 100644 --- a/app/src/main/res/xml/settings.xml +++ b/app/src/main/res/xml/settings.xml @@ -37,7 +37,7 @@ app:key="@string/playback_speed_enabled_key" android:title="@string/eigengraumode_settings" android:summary="@string/eigengraumode_settings_des" - app:defaultValue="true" + app:defaultValue="false" />