diff --git a/android-project/src/org/libsdl/app/SDLActivity.java b/android-project/src/org/libsdl/app/SDLActivity.java index f40bbcc16..4e516528e 100644 --- a/android-project/src/org/libsdl/app/SDLActivity.java +++ b/android-project/src/org/libsdl/app/SDLActivity.java @@ -27,6 +27,7 @@ import android.graphics.*; import android.graphics.drawable.Drawable; import android.media.*; import android.hardware.*; +import android.content.pm.ActivityInfo; /** SDL Activity @@ -1062,6 +1063,42 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, SDLActivity.onNativeResize(width, height, sdlFormat, mDisplay.getRefreshRate()); Log.v("SDL", "Window size: " + width + "x" + height); + + boolean skip = false; + int requestedOrientation = SDLActivity.mSingleton.getRequestedOrientation(); + + if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) + { + // Accept any + } + else if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) + { + if (mWidth > mHeight) { + skip = true; + } + } else if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) { + if (mWidth < mHeight) { + skip = true; + } + } + + // Special Patch for Square Resolution: Black Berry Passport + if (skip) { + double min = Math.min(mWidth, mHeight); + double max = Math.max(mWidth, mHeight); + + if (max / min < 1.20) { + Log.v("SDL", "Don't skip on such aspect-ratio. Could be a square resolution."); + skip = false; + } + } + + if (skip) { + Log.v("SDL", "Skip .. Surface is not ready."); + return; + } + + // Set mIsSurfaceReady to 'true' *before* making a call to handleResume SDLActivity.mIsSurfaceReady = true; SDLActivity.onNativeSurfaceChanged(); @@ -1093,6 +1130,10 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, }, "SDLThreadListener"); SDLActivity.mSDLThread.start(); } + + if (SDLActivity.mHasFocus) { + SDLActivity.handleResume(); + } } // unused