Prevent PIP from opening in mini player

This commit is contained in:
janisslsm 2022-05-14 14:31:33 +03:00
parent b34e09c628
commit f261ca8b45
2 changed files with 10 additions and 9 deletions

View File

@ -319,12 +319,8 @@ class MainActivity : AppCompatActivity() {
override fun onUserLeaveHint() {
super.onUserLeaveHint()
for(fragment in supportFragmentManager.fragments)
{
if(fragment is PlayerFragment)
{
fragment.onUserLeaveHint();
}
supportFragmentManager.fragments.forEach { fragment ->
(fragment as? PlayerFragment)?.onUserLeaveHint()
}
}

View File

@ -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
@ -816,6 +815,8 @@ class PlayerFragment : Fragment() {
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
} else {
with(motionLayout) {
getConstraintSet(R.id.start).constrainHeight(R.id.player, 0)
@ -828,7 +829,11 @@ class PlayerFragment : Fragment() {
}
fun onUserLeaveHint() {
if (SDK_INT >= Build.VERSION_CODES.N && exoPlayer.isPlaying) {
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()
};
}