Merge pull request #3528 from Isira-Seneviratne/PictureInPictureCompat

Reuse PictureInPictureCompat method.
This commit is contained in:
Isira Seneviratne 2023-04-11 18:35:20 +05:30 committed by GitHub
commit 0cce8e4c9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,7 +4,6 @@ import android.annotation.SuppressLint
import android.content.Intent
import android.content.pm.ActivityInfo
import android.content.res.Configuration
import android.os.Build
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
@ -24,6 +23,7 @@ import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.R
import com.github.libretube.compat.PictureInPictureCompat
import com.github.libretube.constants.IntentData
import com.github.libretube.constants.PreferenceKeys
import com.github.libretube.databinding.ActivityMainBinding
@ -370,9 +370,7 @@ class MainActivity : BaseActivity() {
private fun loadIntentData() {
// If activity is running in PiP mode, then start it in front.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N &&
isInPictureInPictureMode
) {
if (PictureInPictureCompat.isInPictureInPictureMode(this)) {
val nIntent = Intent(this, MainActivity::class.java)
nIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)
startActivity(nIntent)