aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-10-26 14:15:47 -0400
committerGitHub <noreply@github.com>2017-10-26 14:15:47 -0400
commit1cbee7747e6c7df56b1ab493297deec6763dd29c (patch)
treed416f17b04f95e7b01d2abefe9308a40223809b6 /app/src/main
parent27832f1a0081ef423342a3162ce8ed5f0be66d82 (diff)
downloadfrost-1cbee7747e6c7df56b1ab493297deec6763dd29c.tar.gz
frost-1cbee7747e6c7df56b1ab493297deec6763dd29c.tar.bz2
frost-1cbee7747e6c7df56b1ab493297deec6763dd29c.zip
Fix/pip rotation (#450)v1.6.2
* Attempt to redraw video on orientation change * Delete file backup * Update video bounds after rotations * Update changelog
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt42
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt10
-rw-r--r--app/src/main/res/xml/frost_changelog.xml9
4 files changed, 53 insertions, 14 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
index e37c38e9..b347d6a0 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
@@ -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()
+ }
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt
index 9932abae..c5508a4d 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoView.kt
@@ -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()
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt
index 7ba49d3c..bf4df8fe 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostVideoViewer.kt
@@ -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 {
diff --git a/app/src/main/res/xml/frost_changelog.xml b/app/src/main/res/xml/frost_changelog.xml
index 98441a58..65d577e0 100644
--- a/app/src/main/res/xml/frost_changelog.xml
+++ b/app/src/main/res/xml/frost_changelog.xml
@@ -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" />