[Android] ICS: fix video size when the system bar appears & disappears
Sébastien Toque
git at videolan.org
Wed Jul 18 01:27:03 CEST 2012
android | branch: master | Sébastien Toque <xilasz at gmail.com> | Wed Jul 18 01:22:21 2012 +0200| [9e72ac932d54ef5ed489063fe75271ade9f860e3] | committer: Sébastien Toque
ICS: fix video size when the system bar appears & disappears
> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=9e72ac932d54ef5ed489063fe75271ade9f860e3
---
.../videolan/vlc/gui/video/VideoPlayerActivity.java | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 5eb716e..c1c8c5b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -151,7 +151,10 @@ public class VideoPlayerActivity extends Activity {
getWindow().getDecorView().findViewById(android.R.id.content).setOnSystemUiVisibilityChangeListener(
new OnSystemUiVisibilityChangeListener() {
public void onSystemUiVisibilityChange(int visibility) {
- if (visibility == View.SYSTEM_UI_FLAG_VISIBLE && !mShowing && visibility != mUiVisibility) {
+ if (visibility == mUiVisibility)
+ return;
+ setSurfaceSize(mVideoWidth, mVideoHeight);
+ if (visibility == View.SYSTEM_UI_FLAG_VISIBLE && !mShowing) {
showOverlay();
mHandler.sendMessageDelayed(mHandler.obtainMessage(HIDE_NAV), OVERLAY_TIMEOUT);
}
@@ -505,8 +508,18 @@ public class VideoPlayerActivity extends Activity {
private void changeSurfaceSize() {
// get screen size
- int dw = getWindowManager().getDefaultDisplay().getWidth();
- int dh = getWindowManager().getDefaultDisplay().getHeight();
+ int dw = getWindow().getDecorView().getWidth();
+ int dh = getWindow().getDecorView().getHeight();
+
+ // getWindow().getDecorView() doesn't always take orientation into account, we have to correct the values
+ boolean isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
+ if (dw > dh && isPortrait || dw < dh && !isPortrait) {
+ int d = dw;
+ dw = dh;
+ dh = d;
+ }
+ if (dw * dh == 0)
+ return;
// calculate aspect ratio
double ar = (double) mVideoWidth / (double) mVideoHeight;
More information about the Android
mailing list