Merge pull request #2115 from Bnyro/captions-size

add a preference for the captions text size
This commit is contained in:
Bnyro 2022-11-27 17:50:31 +01:00 committed by GitHub
commit 2c783cadb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 1 deletions

View File

@ -85,6 +85,7 @@ object PreferenceKeys {
const val QUEUE_AUTO_INSERT_RELATED = "queue_insert_related_videos" const val QUEUE_AUTO_INSERT_RELATED = "queue_insert_related_videos"
const val PLAYER_SWIPE_CONTROLS = "player_swipe_controls" const val PLAYER_SWIPE_CONTROLS = "player_swipe_controls"
const val PLAYER_SCREEN_BRIGHTNESS = "player_screen_brightness" const val PLAYER_SCREEN_BRIGHTNESS = "player_screen_brightness"
const val CAPTIONS_SIZE = "captions_size"
/** /**
* Background mode * Background mode

View File

@ -729,7 +729,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions {
val captionStyle = PlayerHelper.getCaptionStyle(requireContext()) val captionStyle = PlayerHelper.getCaptionStyle(requireContext())
exoPlayerView.subtitleView?.apply { exoPlayerView.subtitleView?.apply {
setApplyEmbeddedFontSizes(false) setApplyEmbeddedFontSizes(false)
setFixedTextSize(TEXT_SIZE_TYPE_ABSOLUTE, 18F) setFixedTextSize(TEXT_SIZE_TYPE_ABSOLUTE, PlayerHelper.captionsTextSize)
if (!PlayerHelper.useSystemCaptionStyle) return if (!PlayerHelper.useSystemCaptionStyle) return
setApplyEmbeddedStyles(captionStyle == CaptionStyleCompat.DEFAULT) setApplyEmbeddedStyles(captionStyle == CaptionStyleCompat.DEFAULT)
setStyle(captionStyle) setStyle(captionStyle)

View File

@ -300,6 +300,12 @@ object PlayerHelper {
true true
) )
val captionsTextSize: Float
get() = PreferenceHelper.getString(
PreferenceKeys.CAPTIONS_SIZE,
"18"
).toFloat()
fun getDefaultResolution(context: Context): String { fun getDefaultResolution(context: Context): String {
return if (NetworkHelper.isNetworkMobile(context)) { return if (NetworkHelper.isNetworkMobile(context)) {
PreferenceHelper.getString( PreferenceHelper.getString(

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M2.5,4v3h5v12h3V7h5V4H2.5zM21.5,9h-9v3h3v7h3v-7h3V9z" />
</vector>

View File

@ -398,6 +398,7 @@
<string name="pop_up">Pop-Up</string> <string name="pop_up">Pop-Up</string>
<string name="comments_disabled">Comments are disabled by the uploader.</string> <string name="comments_disabled">Comments are disabled by the uploader.</string>
<string name="no_comments_available">This video has no comments available.</string> <string name="no_comments_available">This video has no comments available.</string>
<string name="captions_size">Captions size</string>
<!-- Notification channel strings --> <!-- Notification channel strings -->
<string name="download_channel_name">Download Service</string> <string name="download_channel_name">Download Service</string>

View File

@ -62,6 +62,15 @@
app:summary="@string/buffering_goal_summary" app:summary="@string/buffering_goal_summary"
app:title="@string/buffering_goal" /> app:title="@string/buffering_goal" />
<com.github.libretube.ui.views.SliderPreference
android:icon="@drawable/ic_text"
android:key="captions_size"
android:title="@string/captions_size"
app:defValue="18"
app:stepSize="1"
app:valueFrom="8"
app:valueTo="30" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory app:title="@string/appearance"> <PreferenceCategory app:title="@string/appearance">