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.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
}
}

View File

@ -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"),

View File

@ -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 {

View File

@ -47,6 +47,11 @@
android:text="@string/subs_font"
style="@style/SettingsItem"
/>
<TextView
android:id="@+id/subs_font_size"
android:text="@string/subs_font_size"
style="@style/SettingsItem"
/>
<TextView
android:id="@+id/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_subtitle_elevation">Subtitle Elevation</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_types">Search using types</string>

View File

@ -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"
/>
<SwitchPreference
android:icon="@drawable/ic_baseline_ondemand_video_24"