From 1cbee7747e6c7df56b1ab493297deec6763dd29c Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Thu, 26 Oct 2017 14:15:47 -0400 Subject: [PATCH] Fix/pip rotation (#450) * Attempt to redraw video on orientation change * Delete file backup * Update video bounds after rotations * Update changelog --- .../frost/activities/MainActivity.kt | 6 + .../pitchedapps/frost/views/FrostVideoView.kt | 42 +- .../frost/views/FrostVideoViewer.kt | 10 + app/src/main/res/xml/frost_changelog.xml | 9 +- docs/Changelog.md | 7 +- projectFilesBackup/.idea/workspace.xml | 4987 ----------------- 6 files changed, 59 insertions(+), 5002 deletions(-) delete mode 100644 projectFilesBackup/.idea/workspace.xml 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 e37c38e9b..b347d6a0f 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 9932abaec..c5508a4dd 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 { + 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 7ba49d3c6..bf4df8fed 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 98441a58a..65d577e0d 100644 --- a/app/src/main/res/xml/frost_changelog.xml +++ b/app/src/main/res/xml/frost_changelog.xml @@ -6,7 +6,13 @@ --> - + + + + + + + @@ -15,7 +21,6 @@ - diff --git a/docs/Changelog.md b/docs/Changelog.md index 4ac020b0f..4d4198391 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -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 diff --git a/projectFilesBackup/.idea/workspace.xml b/projectFilesBackup/.idea/workspace.xml deleted file mode 100644 index d1ab613b0..000000000 --- a/projectFilesBackup/.idea/workspace.xml +++ /dev/null @@ -1,4987 +0,0 @@ - - - - - - - - - - - - - - - com.mikepenz - community-material-typeface - 1.5.54.2 - JCenter - - - com.davemorrissey.labs - subsampling-scale-image-view - 3.6.0 - JCenter - - - com.github.pwittchen - reactivenetwork-rx2 - 0.11.0 - JCenter - - - junit - junit - 4.12 - JCenter - - - com.mikepenz - material-design-iconic-typeface - 2.2.0.2 - JCenter - - - com.anjlab.android.iab.v3 - library - 1.0.44 - JCenter - - - com.squareup.okhttp3 - okhttp - 3.8.1 - JCenter - - - org.apache.commons - commons-text - 1.1 - JCenter - - - org.jsoup - jsoup - 1.10.3 - JCenter - - - com.android.support.test - runner - 0.6-alpha - Android Repository - - - org.jetbrains.kotlin - kotlin-test-junit - 1.1.4-2 - JCenter - - - com.sothree.slidinguppanel - library - 3.3.1 - JCenter - - - org.jetbrains.kotlin - kotlin-stdlib - 1.1.4-2 - JCenter - - - com.android.support.test - rules - 0.6-alpha - Android Repository - - - 1503250555256 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - contentDisposition - restarter - onsing - r.layout - loading - seekto - setico - parent - videoViewImpl - s - searchview - browser - setc - onba - show - onfinishli - ?. - upperMinimizedY - lowerVideoPadding - onFade - setontou - videoDimensions - setont - shouldpa - c - control - setcontrol - pause - logPurchase - video. - - - implementation - api - &apos; - frost_name - String - L.d - c - Implementation - FACEBOOK_BLUE - - finish - context - "\\\\$1 " to "%$1" - "\\\\$1 " to "%$1", - % - "\\$1 " $2, - "\\\\$1 " $2, - Night }, - Night: Int by - ColorNight - _night", - ThemePrefs - u003C - Triple<List<FrostThread>, FrostLink?, List<FrostLink>> - event.rawX - event.rawY - ValueCallback<Array<Uri>?> - - - C:\Users\User7681\.gradle\caches\transforms-1\files-1.1\core-c2dd5d6.aar\4503508a24ede5e6e4c95d7a75c442e7\jars\classes.jar!\ca\allanwang\kau\utils - C:\Users\User7681\PA\Frost-for-Facebook\app\src\main\kotlin\com\pitchedapps\frost\services - C:\Users\User7681\PA\Frost-for-Facebook\app\src\main\kotlin\com\pitchedapps\frost\settings - C:\Users\User7681\PA\Frost-for-Facebook - C:\Users\User7681\PA\Frost-for-Facebook\app\src\main\res\values-de - C:\Users\User7681\PA\Frost-for-Facebook\app\src\main\res\values - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1497996592535 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/ca.allanwang.kau/core/e803969433/ed1651c9d290aa246e52b6733264cfba1b67b2b3/core-e803969433-sources.jar!/ca/allanwang/kau/swipe/SwipeBackPage.kt - 55 - - - - jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp/3.8.1/fc70ffa234e7e77741867d38b341d162ec1ec01e/okhttp-3.8.1-sources.jar!/okhttp3/Request.java - 141 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file