subtitles fixed

This commit is contained in:
LagradOst 2021-09-16 14:46:21 +02:00
parent 77cd2cbc8e
commit 5ae56a07ad
6 changed files with 58 additions and 5 deletions

View file

@ -17,6 +17,7 @@ import android.media.AudioManager
import android.net.Uri import android.net.Uri
import android.os.* import android.os.*
import android.provider.Settings import android.provider.Settings
import android.util.TypedValue
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.MotionEvent import android.view.MotionEvent
import android.view.View 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.android.synthetic.main.player_custom_layout.*
import kotlinx.coroutines.* import kotlinx.coroutines.*
import java.io.File import java.io.File
import java.lang.reflect.Array.setInt
import javax.net.ssl.HttpsURLConnection import javax.net.ssl.HttpsURLConnection
import javax.net.ssl.SSLContext import javax.net.ssl.SSLContext
import javax.net.ssl.SSLSession import javax.net.ssl.SSLSession
@ -966,6 +966,12 @@ class PlayerFragment : Fragment() {
subStyle = style subStyle = style
subView?.setStyle(ctx.fromSaveToStyle(style)) subView?.setStyle(ctx.fromSaveToStyle(style))
subView?.translationY = -style.elevation.toPx.toFloat() 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 -> context?.let { ctx ->
swipeEnabled = settingsManager.getBoolean(ctx.getString(R.string.swipe_enabled_key), true) swipeEnabled = settingsManager.getBoolean(ctx.getString(R.string.swipe_enabled_key), true)
swipeVerticalEnabled = settingsManager.getBoolean(ctx.getString(R.string.swipe_vertical_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) playerResizeEnabled = settingsManager.getBoolean(ctx.getString(R.string.player_resize_enabled_key), true)
doubleTapEnabled = settingsManager.getBoolean(ctx.getString(R.string.double_tap_enabled_key), false) doubleTapEnabled = settingsManager.getBoolean(ctx.getString(R.string.double_tap_enabled_key), false)
useSystemBrightness = settingsManager.getBoolean(ctx.getString(R.string.use_system_brightness_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("vtt", true) -> MimeTypes.TEXT_VTT
endsWith("srt", true) -> MimeTypes.APPLICATION_SUBRIP endsWith("srt", true) -> MimeTypes.APPLICATION_SUBRIP
endsWith("xml", true) || endsWith("ttml", true) -> MimeTypes.APPLICATION_TTML endsWith("xml", true) || endsWith("ttml", true) -> MimeTypes.APPLICATION_TTML
else -> MimeTypes.TEXT_VTT else -> MimeTypes.APPLICATION_SUBRIP // TODO get request to see
} }
} }

View file

@ -50,6 +50,8 @@ data class SaveCaptionStyle(
var typeface: Int?, var typeface: Int?,
/**in dp**/ /**in dp**/
var elevation: Int, var elevation: Int,
/**in sp**/
var fixedTextSize: Float?,
) )
class SubtitlesFragment : Fragment() { class SubtitlesFragment : Fragment() {
@ -106,6 +108,7 @@ class SubtitlesFragment : Fragment() {
getDefColor(1), getDefColor(1),
null, null,
0, 0,
null,
) )
} }
@ -281,6 +284,44 @@ class SubtitlesFragment : Fragment() {
return@setOnLongClickListener true 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 -> subs_font.setOnClickListener { textView ->
val fontTypes = listOf( val fontTypes = listOf(
Pair(null, "Normal"), Pair(null, "Normal"),

View file

@ -580,7 +580,7 @@ object VideoDownloadManager {
val currentMimeType = when (extension) { val currentMimeType = when (extension) {
"vtt" -> "text/vtt" "vtt" -> "text/vtt"
"mp4" -> "video/mp4" "mp4" -> "video/mp4"
"srt" -> "text/plain" "srt" -> "application/x-subrip"//"text/plain"
else -> null else -> null
} }
val newFile = ContentValues().apply { val newFile = ContentValues().apply {

View file

@ -47,6 +47,11 @@
android:text="@string/subs_font" android:text="@string/subs_font"
style="@style/SettingsItem" style="@style/SettingsItem"
/> />
<TextView
android:id="@+id/subs_font_size"
android:text="@string/subs_font_size"
style="@style/SettingsItem"
/>
<TextView <TextView
android:id="@+id/subs_text_color" android:id="@+id/subs_text_color"
android:text="@string/subs_text_color" android:text="@string/subs_text_color"

View file

@ -123,6 +123,7 @@
<string name="subs_edge_type">Edge Type</string> <string name="subs_edge_type">Edge Type</string>
<string name="subs_subtitle_elevation">Subtitle Elevation</string> <string name="subs_subtitle_elevation">Subtitle Elevation</string>
<string name="subs_font">Font</string> <string name="subs_font">Font</string>
<string name="subs_font_size">Font Size</string>
<string name="search_provider_text_providers">Search using providers</string> <string name="search_provider_text_providers">Search using providers</string>
<string name="search_provider_text_types">Search using types</string> <string name="search_provider_text_types">Search using types</string>

View file

@ -37,7 +37,7 @@
app:key="@string/playback_speed_enabled_key" app:key="@string/playback_speed_enabled_key"
android:title="@string/eigengraumode_settings" android:title="@string/eigengraumode_settings"
android:summary="@string/eigengraumode_settings_des" android:summary="@string/eigengraumode_settings_des"
app:defaultValue="true" app:defaultValue="false"
/> />
<SwitchPreference <SwitchPreference
android:icon="@drawable/ic_baseline_ondemand_video_24" android:icon="@drawable/ic_baseline_ondemand_video_24"