mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +05:30
add resize mode pref
This commit is contained in:
parent
109f47f43f
commit
6694eb972e
@ -1,7 +1,7 @@
|
||||
package com.github.libretube.util
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
import java.util.*
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class ResettableLazyManager {
|
||||
// we synchronize to make sure the timing of a reset() call and new inits do not collide
|
||||
|
@ -92,7 +92,6 @@ import com.google.android.exoplayer2.upstream.DefaultHttpDataSource
|
||||
import com.google.android.exoplayer2.util.RepeatModeUtil
|
||||
import com.google.android.exoplayer2.video.VideoSize
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import kotlin.math.abs
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
@ -100,6 +99,7 @@ import org.chromium.net.CronetEngine
|
||||
import retrofit2.HttpException
|
||||
import java.io.IOException
|
||||
import java.util.concurrent.Executors
|
||||
import kotlin.math.abs
|
||||
|
||||
class PlayerFragment : BaseFragment() {
|
||||
|
||||
@ -168,6 +168,7 @@ class PlayerFragment : BaseFragment() {
|
||||
private var sponsorBlockNotifications = true
|
||||
private var skipButtonsEnabled = false
|
||||
private var pipEnabled = true
|
||||
private var resizeModePref = "fit"
|
||||
|
||||
/**
|
||||
* for autoplay
|
||||
@ -336,6 +337,11 @@ class PlayerFragment : BaseFragment() {
|
||||
PreferenceKeys.PICTURE_IN_PICTURE,
|
||||
true
|
||||
)
|
||||
|
||||
resizeModePref = PreferenceHelper.getString(
|
||||
PreferenceKeys.PLAYER_RESIZE_MODE,
|
||||
"fit"
|
||||
)
|
||||
}
|
||||
|
||||
private fun initializeTransitionLayout() {
|
||||
@ -513,13 +519,9 @@ class PlayerFragment : BaseFragment() {
|
||||
.show()
|
||||
}
|
||||
|
||||
override fun onAspectRatioClicked() {
|
||||
override fun onResizeModeClicked() {
|
||||
// switching between original aspect ratio (black bars) and zoomed to fill device screen
|
||||
val aspectRatioModeNames = arrayOf(
|
||||
context?.getString(R.string.resize_mode_fit),
|
||||
context?.getString(R.string.resize_mode_zoom),
|
||||
context?.getString(R.string.resize_mode_fill)
|
||||
)
|
||||
val aspectRatioModeNames = context?.resources?.getStringArray(R.array.resizeMode)
|
||||
|
||||
val aspectRatioModes = arrayOf(
|
||||
AspectRatioFrameLayout.RESIZE_MODE_FIT,
|
||||
@ -605,7 +607,7 @@ class PlayerFragment : BaseFragment() {
|
||||
context.getString(R.string.repeat_mode_none)
|
||||
} else context.getString(R.string.repeat_mode_current)
|
||||
// set the aspect ratio mode
|
||||
currentAspectRatio = when (exoPlayerView.resizeMode) {
|
||||
currentResizeMode = when (exoPlayerView.resizeMode) {
|
||||
AspectRatioFrameLayout.RESIZE_MODE_FIT -> context.getString(R.string.resize_mode_fit)
|
||||
AspectRatioFrameLayout.RESIZE_MODE_FILL -> context.getString(R.string.resize_mode_fill)
|
||||
else -> context.getString(R.string.resize_mode_zoom)
|
||||
@ -979,6 +981,11 @@ class PlayerFragment : BaseFragment() {
|
||||
controllerHideOnTouch = true
|
||||
useController = false
|
||||
player = exoPlayer
|
||||
resizeMode = when (resizeModePref) {
|
||||
"fill" -> AspectRatioFrameLayout.RESIZE_MODE_FILL
|
||||
"zoom" -> AspectRatioFrameLayout.RESIZE_MODE_ZOOM
|
||||
else -> AspectRatioFrameLayout.RESIZE_MODE_FIT
|
||||
}
|
||||
}
|
||||
|
||||
if (useSystemCaptionStyle) {
|
||||
|
@ -10,7 +10,7 @@ interface PlayerOptionsInterface {
|
||||
|
||||
fun onPlaybackSpeedClicked()
|
||||
|
||||
fun onAspectRatioClicked()
|
||||
fun onResizeModeClicked()
|
||||
|
||||
fun onRepeatModeClicked()
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ object PreferenceKeys {
|
||||
const val DEFAULT_SUBTITLE = "default_subtitle"
|
||||
const val SKIP_BUTTONS = "skip_buttons"
|
||||
const val PICTURE_IN_PICTURE = "picture_in_picture"
|
||||
const val PLAYER_RESIZE_MODE = "player_resize_mode"
|
||||
|
||||
/**
|
||||
* Background mode
|
||||
|
@ -25,7 +25,7 @@ class PlayerOptionsBottomSheet : BottomSheetDialogFragment() {
|
||||
var currentAutoplayMode: String? = null
|
||||
var currentRepeatMode: String? = null
|
||||
var currentQuality: String? = null
|
||||
var currentAspectRatio: String? = null
|
||||
var currentResizeMode: String? = null
|
||||
var currentCaptions: String? = null
|
||||
|
||||
override fun onCreateView(
|
||||
@ -67,10 +67,10 @@ class PlayerOptionsBottomSheet : BottomSheetDialogFragment() {
|
||||
|
||||
binding.repeatMode.updateText(currentRepeatMode)
|
||||
|
||||
binding.aspectRatio.updateText(currentAspectRatio)
|
||||
binding.resizeMode.updateText(currentResizeMode)
|
||||
|
||||
binding.aspectRatio.setOnClickListener {
|
||||
playerOptionsInterface.onAspectRatioClicked()
|
||||
binding.resizeMode.setOnClickListener {
|
||||
playerOptionsInterface.onResizeModeClicked()
|
||||
this.dismiss()
|
||||
}
|
||||
|
||||
|
10
app/src/main/res/drawable/ic_zoom.xml
Normal file
10
app/src/main/res/drawable/ic_zoom.xml
Normal 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="48"
|
||||
android:viewportHeight="48">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M6,42L6,30.5h3v6.35l7.4,-7.4 2.15,2.15 -7.4,7.4h6.35v3ZM30.5,42v-3h6.35l-7.35,-7.35 2.15,-2.15L39,36.85L39,30.5h3L42,42ZM16.35,18.5 L9,11.15v6.35L6,17.5L6,6h11.5v3h-6.35l7.35,7.35ZM31.65,18.5 L29.5,16.35L36.85,9L30.5,9L30.5,6L42,6v11.5h-3v-6.35Z" />
|
||||
</vector>
|
@ -39,8 +39,8 @@
|
||||
app:drawableStartCompat="@drawable/ic_repeat" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/aspectRatio"
|
||||
android:id="@+id/resizeMode"
|
||||
style="@style/BottomSheetItem"
|
||||
android:text="@string/aspect_ratio"
|
||||
android:text="@string/player_resize_mode"
|
||||
app:drawableStartCompat="@drawable/ic_aspect_ratio" />
|
||||
</LinearLayout>
|
@ -846,4 +846,16 @@
|
||||
<item>120</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="resizeMode">
|
||||
<item>@string/resize_mode_fit</item>
|
||||
<item>@string/resize_mode_zoom</item>
|
||||
<item>@string/resize_mode_fill</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="resizeModeValues">
|
||||
<item>fit</item>
|
||||
<item>zoom</item>
|
||||
<item>fill</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
@ -313,4 +313,5 @@
|
||||
<string name="backup_restore">Backup & restore</string>
|
||||
<string name="backup">Backup</string>
|
||||
<string name="picture_in_picture">Picture in Picture</string>
|
||||
<string name="player_resize_mode">Resize mode</string>
|
||||
</resources>
|
||||
|
@ -77,6 +77,15 @@
|
||||
app:key="default_subtitle"
|
||||
app:title="@string/default_subtitle_language" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="fit"
|
||||
android:entries="@array/resizeMode"
|
||||
android:entryValues="@array/resizeModeValues"
|
||||
android:icon="@drawable/ic_zoom"
|
||||
app:key="player_resize_mode"
|
||||
app:title="@string/player_resize_mode"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:icon="@drawable/ic_next"
|
||||
|
Loading…
Reference in New Issue
Block a user