fix: pip zoom start player maximized (#640)

* fix zoom

* update isZoomEnabled inside updateZoomMode

To avoid future issues, I will update `isZoomEnabled` inside `updateZoomMode`.

* Revert " update isZoomEnabled inside updateZoomMode"

This reverts commit 9b539e1830bc76db0c540a51299f05a09c553d00.

* fix: isZoomEnable

* val enableZoom for readability

* lint
This commit is contained in:
Cd16d 2024-02-03 18:22:01 +01:00 committed by GitHub
parent 6051fee681
commit 3ba5a73c74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View file

@ -55,6 +55,7 @@ class PlayerActivity : BasePlayerActivity() {
private var playerGestureHelper: PlayerGestureHelper? = null
override val viewModel: PlayerActivityViewModel by viewModels()
private var previewScrubListener: PreviewScrubListener? = null
private var wasZoom: Boolean = false
private val isPipSupported by lazy {
// Check if device has PiP feature
@ -308,6 +309,7 @@ class PlayerActivity : BasePlayerActivity() {
binding.playerView.useController = false
binding.playerView.findViewById<Button>(R.id.btn_skip_intro).isVisible = false
wasZoom = playerGestureHelper!!.isZoomEnabled
playerGestureHelper?.updateZoomMode(false)
// Brightness mode Auto
@ -327,7 +329,7 @@ class PlayerActivity : BasePlayerActivity() {
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
if (!isInPictureInPictureMode) {
binding.playerView.useController = true
playerGestureHelper?.isZoomEnabled?.let { playerGestureHelper!!.updateZoomMode(it) }
playerGestureHelper?.updateZoomMode(wasZoom)
// Override auto brightness
window.attributes = window.attributes.apply {

View file

@ -330,8 +330,8 @@ class PlayerGestureHelper(
lastScaleEvent = SystemClock.elapsedRealtime()
val scaleFactor = detector.scaleFactor
if (abs(scaleFactor - Constants.ZOOM_SCALE_BASE) > Constants.ZOOM_SCALE_THRESHOLD) {
isZoomEnabled = scaleFactor > 1
updateZoomMode(isZoomEnabled)
val enableZoom = scaleFactor > 1
updateZoomMode(enableZoom)
}
return true
}
@ -346,6 +346,7 @@ class PlayerGestureHelper(
} else {
playerView.resizeMode = if (enabled) AspectRatioFrameLayout.RESIZE_MODE_ZOOM else AspectRatioFrameLayout.RESIZE_MODE_FIT
}
isZoomEnabled = enabled
}
private fun releaseAction(event: MotionEvent) {