mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +05:30
Merge pull request #687 from Bnyro/master
Fullscreen Player Rotation + UI fixes
This commit is contained in:
commit
6c30959ddb
@ -21,7 +21,6 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.constraintlayout.motion.widget.MotionLayout
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.net.toUri
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.view.isVisible
|
||||
@ -76,7 +75,6 @@ import com.google.android.exoplayer2.upstream.DataSource
|
||||
import com.google.android.exoplayer2.upstream.DefaultDataSource
|
||||
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.button.MaterialButton
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.squareup.picasso.Picasso
|
||||
@ -284,7 +282,24 @@ class PlayerFragment : Fragment() {
|
||||
scaleFactor = 1.3F
|
||||
|
||||
val mainActivity = activity as MainActivity
|
||||
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
|
||||
val fullscreenOrientationPref = PreferenceHelper
|
||||
.getString(requireContext(), "fullscreen_orientation", "ratio")
|
||||
Log.e(TAG, fullscreenOrientationPref.toString())
|
||||
val orientation = when (fullscreenOrientationPref) {
|
||||
"ratio" -> {
|
||||
val videoSize = exoPlayer.videoSize
|
||||
// probably a youtube shorts video
|
||||
Log.e(TAG, videoSize.height.toString() + " " + videoSize.width.toString())
|
||||
if (videoSize.height > videoSize.width) ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||
// a video with normal aspect ratio
|
||||
else ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
|
||||
}
|
||||
"auto" -> ActivityInfo.SCREEN_ORIENTATION_USER
|
||||
"landscape" -> ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
|
||||
"portrait" -> ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||
else -> ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
|
||||
}
|
||||
mainActivity.requestedOrientation = orientation
|
||||
} else {
|
||||
// leave fullscreen mode
|
||||
with(binding.playerMotionLayout) {
|
||||
@ -689,6 +704,7 @@ class PlayerFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
override fun onVideoSizeChanged(
|
||||
videoSize: VideoSize
|
||||
) {
|
||||
@ -703,6 +719,7 @@ class PlayerFragment : Fragment() {
|
||||
}
|
||||
binding.mainContainer.requestLayout()
|
||||
}
|
||||
*/
|
||||
|
||||
@Deprecated(message = "Deprecated", level = DeprecationLevel.HIDDEN)
|
||||
override fun onPlayerStateChanged(
|
||||
@ -1214,7 +1231,7 @@ class PlayerFragment : Fragment() {
|
||||
enableTransition(R.id.yt_transition, false)
|
||||
}
|
||||
binding.mainContainer.isClickable = true
|
||||
|
||||
|
||||
val mainActivity = activity as MainActivity
|
||||
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||
isFullScreen = false
|
||||
|
@ -1,7 +1,7 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="@android:color/white"
|
||||
android:tint="?android:attr/colorControlNormal"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
|
@ -240,13 +240,16 @@
|
||||
android:id="@id/exo_rew_with_amount"
|
||||
style="@style/ExoStyledControls.Button.Center.RewWithAmount"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="20dp" />
|
||||
android:layout_marginStart="20dp"
|
||||
android:paddingLeft="4dp"
|
||||
android:paddingRight="4dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@id/exo_play_pause"
|
||||
style="@style/ExoStyledControls.Button.Center.PlayPause" />
|
||||
style="@style/ExoStyledControls.Button.Center.PlayPause"
|
||||
app:tint="@android:color/white" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
@ -258,7 +261,9 @@
|
||||
android:id="@id/exo_ffwd_with_amount"
|
||||
style="@style/ExoStyledControls.Button.Center.FfwdWithAmount"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginRight="20dp" />
|
||||
android:layout_marginEnd="20dp"
|
||||
android:paddingLeft="4dp"
|
||||
android:paddingRight="4dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -694,4 +694,17 @@
|
||||
<item>30</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="fullscreenOrientation">
|
||||
<item>@string/aspect_ratio</item>
|
||||
<item>@string/auto_rotation</item>
|
||||
<item>@string/landscape</item>
|
||||
<item>@string/portrait</item>
|
||||
</string-array>
|
||||
<string-array name="fullscreenOrientationValues">
|
||||
<item>ratio</item>
|
||||
<item>auto</item>
|
||||
<item>landscape</item>
|
||||
<item>portrait</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
@ -143,7 +143,7 @@
|
||||
<string name="no_update_available">You are running the latest version.</string>
|
||||
<string name="playback_speed">Default playback speed</string>
|
||||
<string name="advanced">Advanced</string>
|
||||
<string name="player">Audio and video</string>
|
||||
<string name="player">Player</string>
|
||||
<string name="appearance_summary">Adjust the app to your liking.</string>
|
||||
<string name="advanced_summary">Downloads, history</string>
|
||||
<string name="live">Live</string>
|
||||
@ -215,4 +215,10 @@
|
||||
<string name="auth_instances">Choose an auth instance</string>
|
||||
<string name="hls">Auto</string>
|
||||
<string name="github">GitHub</string>
|
||||
<string name="audio_video">Audio and video</string>
|
||||
<string name="fullscreen_orientation">Fullscreen orientation</string>
|
||||
<string name="aspect_ratio">Video aspect ratio</string>
|
||||
<string name="auto_rotation">Auto rotation</string>
|
||||
<string name="landscape">Landscape</string>
|
||||
<string name="portrait">Portrait</string>
|
||||
</resources>
|
@ -24,7 +24,7 @@
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory app:title="@string/behavior">
|
||||
<PreferenceCategory app:title="@string/player">
|
||||
|
||||
<ListPreference
|
||||
android:icon="@drawable/ic_speed"
|
||||
@ -53,6 +53,10 @@
|
||||
app:summary="@string/buffering_goal_summary"
|
||||
app:title="@string/buffering_goal" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory app:title="@string/behavior">
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:icon="@drawable/ic_play_filled"
|
||||
android:summary="@string/autoplay_summary"
|
||||
@ -65,6 +69,15 @@
|
||||
app:key="pause_screen_off"
|
||||
app:title="@string/pauseOnScreenOff" />
|
||||
|
||||
<ListPreference
|
||||
android:icon="@drawable/ic_fullscreen"
|
||||
app:defaultValue="ratio"
|
||||
app:entries="@array/fullscreenOrientation"
|
||||
app:entryValues="@array/fullscreenOrientationValues"
|
||||
app:key="fullscreen_orientation"
|
||||
app:title="@string/fullscreen_orientation"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
Loading…
x
Reference in New Issue
Block a user