Skip to content

Commit

Permalink
Pip Mode Bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
saikou committed Jan 14, 2024
1 parent 419d877 commit 7ce0e99
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
9 changes: 6 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
~ Created by Azamov X ㋡ on 11/21/23, 2:02 AM
~ Copyright (c) 2023 . All rights reserved.
~ Last modified 11/21/23, 2:02 AM
Expand All @@ -26,9 +25,13 @@
android:usesCleartextTraffic="true">
<activity
android:name=".ui.activity.PlayerActivity"
android:autoRemoveFromRecents="true"
android:configChanges="uiMode|orientation|screenSize|screenLayout|smallestScreenSize|keyboardHidden"
android:excludeFromRecents="true"

android:exported="false"
android:launchMode="singleTask"
android:noHistory="true"
android:resizeableActivity="true"
android:screenOrientation="sensorLandscape"
android:supportsPictureInPicture="true">
Expand All @@ -39,9 +42,9 @@
</activity>
<activity
android:name=".ui.activity.MainActivity"
android:screenOrientation="portrait"
android:configChanges="orientation|screenSize|layoutDirection"
android:exported="true"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package com.azamovhudstc.graphqlanilist.ui.activity
import android.animation.ObjectAnimator
import android.annotation.SuppressLint
import android.app.*
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.content.pm.ActivityInfo
Expand Down Expand Up @@ -40,11 +41,6 @@ import com.azamovhudstc.graphqlanilist.ui.adapter.CustomAdapter
import com.azamovhudstc.graphqlanilist.utils.*
import com.azamovhudstc.graphqlanilist.utils.widgets.DoubleTapPlayerView
import com.azamovhudstc.graphqlanilist.viewmodel.PlayerViewModel
import com.bumptech.glide.Glide
import com.bumptech.glide.request.target.Target
import com.github.rubensousa.previewseekbar.PreviewBar
import com.github.rubensousa.previewseekbar.PreviewLoader
import com.github.rubensousa.previewseekbar.media3.PreviewTimeBar
import com.google.android.exoplayer2.PlaybackParameters
import com.google.android.exoplayer2.ui.AspectRatioFrameLayout
import com.google.android.exoplayer2.ui.CaptionStyleCompat
Expand All @@ -71,6 +67,7 @@ class PlayerActivity : AppCompatActivity() {
private var quality: String = "Auto"
private lateinit var animePlayingDetails: AnimePlayingDetails
private lateinit var binding: ActivityPlayerBinding
private var mBackstackLost =true
private lateinit var exoTopControllers: LinearLayout
private lateinit var exoMiddleControllers: LinearLayout
private lateinit var exoBottomControllers: LinearLayout
Expand Down Expand Up @@ -153,7 +150,7 @@ class PlayerActivity : AppCompatActivity() {
//Initialize
hideSystemBars()
onBackPressedDispatcher.addCallback(this) {
finishAndRemoveTask()
finish()
}


Expand Down Expand Up @@ -434,22 +431,26 @@ class PlayerActivity : AppCompatActivity() {
adapter.setSelected(0)
changeVideoSpeed(0.25f)
}

1 -> {
isNormal = false
adapter.setSelected(1)
changeVideoSpeed(0.5f)
}

2 -> {
isNormal = true

adapter.setSelected(2)
changeVideoSpeed(1f)
}

3 -> {
isNormal = false
adapter.setSelected(3)
changeVideoSpeed(1.5f)
}

else -> {
isNormal = false
adapter.setSelected(4)
Expand Down Expand Up @@ -483,7 +484,8 @@ class PlayerActivity : AppCompatActivity() {
// API >= 26 check
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (status) {
this.enterPictureInPictureMode(PictureInPictureParams.Builder().build())
this.enterPictureInPictureMode(
PictureInPictureParams.Builder().build())
playerView.useController = false
pipStatus = false
} else {
Expand All @@ -510,6 +512,7 @@ class PlayerActivity : AppCompatActivity() {
playerView.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIXED_WIDTH
}
}

1 -> {
playerView.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FILL
}
Expand All @@ -528,6 +531,7 @@ class PlayerActivity : AppCompatActivity() {
playerView.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIXED_WIDTH
}
}

1 -> {
playerView.resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FILL

Expand Down Expand Up @@ -574,6 +578,12 @@ class PlayerActivity : AppCompatActivity() {
handleController()

}
override fun onUserLeaveHint() {
// Handle leaving PiP mode using the home button
finishAndRemoveTask()
}



private fun checkNotch() {
if (notchHeight != 0) {
Expand Down Expand Up @@ -731,6 +741,7 @@ class PlayerActivity : AppCompatActivity() {
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
orientationListener?.disable()
} else {
mBackstackLost = true;
orientationListener?.enable()
}
if (isInit) {
Expand Down Expand Up @@ -863,6 +874,14 @@ class PlayerActivity : AppCompatActivity() {
if (pipStatus) pauseVideo()
}

override fun finish() {
if (mBackstackLost) {
finishAndRemoveTask()
} else {
super.finish()
}
}

override fun onDestroy() {
super.onDestroy()

Expand Down

0 comments on commit 7ce0e99

Please sign in to comment.