1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-08 20:12:39 +01:00

Fix/pip rotation (#450)

* Attempt to redraw video on orientation change

* Delete file backup

* Update video bounds after rotations

* Update changelog
This commit is contained in:
Allan Wang 2017-10-26 14:15:47 -04:00 committed by GitHub
parent 27832f1a00
commit 1cbee7747e
6 changed files with 59 additions and 5002 deletions

View File

@ -5,6 +5,7 @@ import android.app.AlarmManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.graphics.PointF
import android.graphics.drawable.ColorDrawable
import android.net.Uri
@ -495,4 +496,9 @@ class MainActivity : BaseActivity(),
L.d("Video view released")
videoViewer = null
}
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
videoViewer?.updateLocation()
}
}

View File

@ -68,23 +68,42 @@ class FrostVideoView @JvmOverloads constructor(
}
} else {
hideControls()
val scale = Math.min(height / 4f / videoDimensions.y, width / 2.3f / videoDimensions.x)
val desiredHeight = scale * videoDimensions.y
val desiredWidth = scale * videoDimensions.x
val padding = containerContract.lowerVideoPadding
val offsetX = width - MINIMIZED_PADDING - desiredWidth
val offsetY = height - MINIMIZED_PADDING - desiredHeight
val translationX = offsetX / 2 - padding.x
val translationY = offsetY / 2 - padding.y
videoBounds.set(offsetX, offsetY, width.toFloat(), height.toFloat())
videoBounds.offset(padding.x, padding.y)
animate().scaleXY(scale).translationX(translationX).translationY(translationY).setDuration(ANIMATION_DURATION).withStartAction {
val (scale, tX, tY) = mapBounds()
animate().scaleXY(scale).translationX(tX).translationY(tY).setDuration(ANIMATION_DURATION).withStartAction {
backgroundView?.animate()?.alpha(0f)?.setDuration(ANIMATION_DURATION)
viewerContract.onFade(0f, ANIMATION_DURATION)
}
}
}
/**
* Store the boundaries of the minimized video,
* and return the necessary transitions to get there
*/
private fun mapBounds(): Triple<Float, Float, Float> {
val portrait = height > width
val scale = Math.min(height / (if (portrait) 4f else 2.3f) / videoDimensions.y, width / (if (portrait) 2.3f else 4f) / videoDimensions.x)
val desiredHeight = scale * videoDimensions.y
val desiredWidth = scale * videoDimensions.x
val padding = containerContract.lowerVideoPadding
val offsetX = width - MINIMIZED_PADDING - desiredWidth
val offsetY = height - MINIMIZED_PADDING - desiredHeight
val tX = offsetX / 2 - padding.x
val tY = offsetY / 2 - padding.y
videoBounds.set(offsetX, offsetY, width.toFloat(), height.toFloat())
videoBounds.offset(padding.x, padding.y)
L.v("Video bounds: fullwidth $width, fullheight $height, scale $scale, tX $tX, tY $tY")
return Triple(scale, tX, tY)
}
fun updateLocation() {
L.d("Update video location")
val (scale, tX, tY) = if (isExpanded) Triple(1f, 0f, 0f) else mapBounds()
scaleXY = scale
translationX = tX
translationY = tY
}
init {
setOnPreparedListener {
start()
@ -103,7 +122,6 @@ class FrostVideoView @JvmOverloads constructor(
fun jumpToStart() {
pause()
videoControls?.hide()
v.seekTo(0)
videoControls?.finishLoading()
}

View File

@ -9,6 +9,7 @@ import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.view.ViewTreeObserver
import android.widget.FrameLayout
import android.widget.ImageView
import ca.allanwang.kau.utils.*
@ -124,6 +125,15 @@ class FrostVideoViewer @JvmOverloads constructor(
restarter.fadeIn()
}
fun updateLocation() {
viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
override fun onGlobalLayout() {
video.updateLocation()
viewTreeObserver.removeOnGlobalLayoutListener(this)
}
})
}
}
interface FrostVideoViewerContract {

View File

@ -6,7 +6,13 @@
<item text="" />
-->
<version title="v1.6.1" />
<version title="v1.6.2" />
<item text="Fix search update from Facebook" />
<item text="Fix url parsing errors again" />
<item text="Fix pip for bottom bar" />
<item text="Fix pip after rotation" />
<version title="v1.6.0" />
<item text="Add Spanish translations" />
<item text="Add French translations" />
<item text="Add German translations" />
@ -15,7 +21,6 @@
<item text="Add video downloader" />
<item text="Fix bugs with parsing url queries" />
<item text="Fix search update from Facebook" />
<item text="" />
<version title="v1.5.9" />
<item text="Add notification support for Android O" />

View File

@ -1,6 +1,11 @@
# Changelog
## v1.6.1
## v1.6.2
* Fix search update from Facebook
* Fix url parsing errors again
* Fix pip for bottom bar (rotation still has issues)
## v1.6.0
* Add Spanish translations
* Add French translations
* Add German translations

File diff suppressed because it is too large Load Diff