mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
commit
69309840c7
@ -33,7 +33,8 @@
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:configChanges="orientation|screenSize"
|
||||
android:supportsPictureInPicture="true"
|
||||
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
|
||||
android:hardwareAccelerated="true"
|
||||
android:screenOrientation="portrait"
|
||||
>
|
||||
|
@ -317,6 +317,13 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onUserLeaveHint() {
|
||||
super.onUserLeaveHint()
|
||||
supportFragmentManager.fragments.forEach { fragment ->
|
||||
(fragment as? PlayerFragment)?.onUserLeaveHint()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
fun Fragment.hideKeyboard() {
|
||||
view?.let { activity?.hideKeyboard(it) }
|
||||
|
@ -2,12 +2,12 @@ package com.github.libretube
|
||||
|
||||
import android.Manifest
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.Rect
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Build.VERSION.SDK_INT
|
||||
@ -15,7 +15,6 @@ import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import android.text.Html
|
||||
import android.util.Log
|
||||
import android.util.TypedValue
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -804,4 +803,39 @@ class PlayerFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean) {
|
||||
super.onPictureInPictureModeChanged(isInPictureInPictureMode)
|
||||
if (isInPictureInPictureMode) {
|
||||
exoPlayerView.hideController()
|
||||
with(motionLayout) {
|
||||
getConstraintSet(R.id.start).constrainHeight(R.id.player, -1)
|
||||
enableTransition(R.id.yt_transition, false)
|
||||
}
|
||||
view?.findViewById<ConstraintLayout>(R.id.main_container)?.isClickable = true
|
||||
view?.findViewById<LinearLayout>(R.id.linLayout)?.visibility = View.GONE
|
||||
view?.findViewById<FrameLayout>(R.id.top_bar)?.visibility = View.GONE
|
||||
val mainActivity = activity as MainActivity
|
||||
mainActivity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||
isFullScreen = false;
|
||||
} else {
|
||||
with(motionLayout) {
|
||||
getConstraintSet(R.id.start).constrainHeight(R.id.player, 0)
|
||||
enableTransition(R.id.yt_transition, true)
|
||||
}
|
||||
view?.findViewById<ConstraintLayout>(R.id.main_container)?.isClickable = false
|
||||
view?.findViewById<LinearLayout>(R.id.linLayout)?.visibility = View.VISIBLE
|
||||
view?.findViewById<FrameLayout>(R.id.top_bar)?.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
fun onUserLeaveHint() {
|
||||
val bounds = Rect()
|
||||
val scrollView = view?.findViewById<ScrollView>(R.id.player_scrollView)
|
||||
scrollView?.getHitRect(bounds)
|
||||
|
||||
if (SDK_INT >= Build.VERSION_CODES.N && exoPlayer.isPlaying && (scrollView?.getLocalVisibleRect(bounds) == true || isFullScreen)) {
|
||||
requireActivity().enterPictureInPictureMode()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user