summaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorByteHamster <info@bytehamster.com>2018-01-06 13:20:02 +0100
committerByteHamster <info@bytehamster.com>2018-01-09 08:00:22 +0100
commit7e72ff0b0e96cfb009146892c5db20dfa60d63c7 (patch)
tree8e6d92bc5a0f417627f9dbb2e2612b0c983a6ee3 /app/src/main
parentbad964508adf6145cc1c788b6540cd114dc5eef1 (diff)
downloadAntennaPod-7e72ff0b0e96cfb009146892c5db20dfa60d63c7.zip
Fixed scaling of video
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java11
-rw-r--r--app/src/main/java/de/danoeh/antennapod/view/AspectRatioVideoView.java23
2 files changed, 31 insertions, 3 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java
index 80288af24..bf1cc5b7e 100644
--- a/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java
+++ b/app/src/main/java/de/danoeh/antennapod/activity/VideoplayerActivity.java
@@ -8,8 +8,10 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.view.WindowCompat;
+import android.util.DisplayMetrics;
import android.util.Log;
import android.util.Pair;
+import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
@@ -382,7 +384,14 @@ public class VideoplayerActivity extends MediaplayerActivity {
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
- //TODO
+
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB_MR2) {
+ // This is only relevant for picture in picture
+ DisplayMetrics dm = getResources().getDisplayMetrics();
+ float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, newConfig.screenWidthDp, dm);
+ float py = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, newConfig.screenHeightDp, dm);
+ videoview.setAvailableSize(px, py);
+ }
}
private static class VideoControlsHider extends Handler {
diff --git a/app/src/main/java/de/danoeh/antennapod/view/AspectRatioVideoView.java b/app/src/main/java/de/danoeh/antennapod/view/AspectRatioVideoView.java
index f930c912a..138fbff00 100644
--- a/app/src/main/java/de/danoeh/antennapod/view/AspectRatioVideoView.java
+++ b/app/src/main/java/de/danoeh/antennapod/view/AspectRatioVideoView.java
@@ -25,6 +25,8 @@ public class AspectRatioVideoView extends VideoView {
private int mVideoWidth;
private int mVideoHeight;
+ private float mAvailableWidth = -1;
+ private float mAvailableHeight = -1;
public AspectRatioVideoView(Context context) {
this(context, null);
@@ -48,8 +50,13 @@ public class AspectRatioVideoView extends VideoView {
return;
}
- float heightRatio = (float) mVideoHeight / (float) getHeight();
- float widthRatio = (float) mVideoWidth / (float) getWidth();
+ if (mAvailableWidth < 0 || mAvailableHeight < 0) {
+ mAvailableWidth = getWidth();
+ mAvailableHeight = getHeight();
+ }
+
+ float heightRatio = (float) mVideoHeight / mAvailableHeight;
+ float widthRatio = (float) mVideoWidth / mAvailableWidth;
int scaledHeight;
int scaledWidth;
@@ -94,4 +101,16 @@ public class AspectRatioVideoView extends VideoView {
invalidate();
}
+ /**
+ * Sets the maximum size that the view might expand to
+ * @param width
+ * @param height
+ */
+ public void setAvailableSize(float width, float height) {
+ mAvailableWidth = width;
+ mAvailableHeight = height;
+ requestLayout();
+ invalidate();
+ }
+
}