Permalink
Browse files

Merge pull request #526 from mupen64plus-ae/immersive_mode_issue

Immersive mode issue
  • Loading branch information...
fzurita committed Dec 14, 2015
2 parents 096ca47 + 406640b commit 7163b5c2c61c7341048395fa4bdee74a68084e50
@@ -214,6 +214,7 @@ protected void onCreate( Bundle savedInstanceState )
// Enable full-screen mode
window.setFlags( LayoutParams.FLAG_FULLSCREEN, LayoutParams.FLAG_FULLSCREEN );
+ window.setFlags(LayoutParams.FLAG_LAYOUT_IN_SCREEN, LayoutParams.FLAG_LAYOUT_IN_SCREEN);
// Keep screen from going to sleep
window.setFlags( LayoutParams.FLAG_KEEP_SCREEN_ON, LayoutParams.FLAG_KEEP_SCREEN_ON );
@@ -266,7 +267,7 @@ protected void onCreate( Bundle savedInstanceState )
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mSurface.getLayoutParams();
params.width = Math.round ( (float) mGlobalPrefs.videoSurfaceWidth * ( (float) mGamePrefs.videoSurfaceZoom / 100.f ) );
params.height = Math.round ( (float) mGlobalPrefs.videoSurfaceHeight * ( (float) mGamePrefs.videoSurfaceZoom / 100.f ) );
-
+
if( (mGlobalPrefs.displayOrientation & 1) == 1 )
params.gravity = mGlobalPrefs.displayPosition | Gravity.CENTER_HORIZONTAL;
else
@@ -835,17 +836,20 @@ private void initControllers( View inputSource )
@SuppressLint( "InlinedApi" )
private void hideSystemBars()
{
- View view = mSurface.getRootView();
- if( view != null )
+ if( mDrawerLayout != null )
{
if( AppData.IS_KITKAT && mGlobalPrefs.isImmersiveModeEnabled )
- view.setSystemUiVisibility( View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
- | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_FULLSCREEN
- | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
- | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN );
+ {
+ mDrawerLayout.setSystemUiVisibility( View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
+ | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN );
+ }
else
- view.setSystemUiVisibility( View.SYSTEM_UI_FLAG_LOW_PROFILE ); // == STATUS_BAR_HIDDEN for Honeycomb
+ {
+ mDrawerLayout.setSystemUiVisibility( View.SYSTEM_UI_FLAG_LOW_PROFILE ); // == STATUS_BAR_HIDDEN for Honeycomb
+ }
}
}
@@ -79,6 +79,12 @@
{ /** True if device is running Jellybean or later (16 - Android 4.1.x) */
public static final boolean IS_JELLY_BEAN = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
+ /** True if device is running Jellybean or later (17 - Android 4.1.x) */
+ public static final boolean IS_JELLY_BEAN_MR1 = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1;
+
+ /** True if device is running Jellybean or later (18 - Android 4.1.x) */
+ public static final boolean IS_JELLY_BEAN_MR2 = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2;
+
/** True if device is running KitKat or later (19 - Android 4.4.x) */
public static final boolean IS_KITKAT = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
@@ -324,8 +324,8 @@ public GamePrefs( Context context, String romMd5, String crc, String headerName,
videoRenderHeight = 120;
break;
default:
- videoRenderWidth = globalPrefs.videoSurfaceWidth;
- videoRenderHeight = globalPrefs.videoSurfaceHeight;
+ videoRenderWidth = globalPrefs.videoSurfaceWidthOriginal;
+ videoRenderHeight = globalPrefs.videoSurfaceHeightOriginal;
break;
}
@@ -41,9 +41,9 @@
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.res.Configuration;
+import android.graphics.Point;
import android.support.v7.preference.PreferenceManager;
import android.text.TextUtils;
-import android.util.DisplayMetrics;
import android.view.Display;
import android.view.Gravity;
import android.view.KeyEvent;
@@ -175,6 +175,12 @@
/** The height of the viewing surface, in pixels. */
public final int videoSurfaceHeight;
+ /** The width of the viewing surface, in pixels with the correct aspect ratio. */
+ public final int videoSurfaceWidthOriginal;
+
+ /** The height of the viewing surface, in pixels with the correct aspect ratio. */
+ public final int videoSurfaceHeightOriginal;
+
/** The action bar transparency value. */
public final int displayActionBarTransparency;
@@ -289,7 +295,6 @@ public int getResourceString()
* @param context
* The application context.
*/
- @SuppressWarnings( "deprecation" )
@TargetApi( 17 )
public GlobalPrefs( Context context, AppData appData )
{
@@ -439,17 +444,20 @@ else if( navMode.equals( "standard" ) )
{
stretchWidth = stretchHeight = 0;
}
+ //Kit Kat (19) adds support for immersive mode
else if( AppData.IS_KITKAT && isImmersiveModeEnabled )
{
- DisplayMetrics metrics = new DisplayMetrics();
- display.getRealMetrics( metrics );
- stretchWidth = metrics.widthPixels;
- stretchHeight = metrics.heightPixels;
+ Point dimensions = new Point();
+ display.getRealSize(dimensions);
+ stretchWidth = dimensions.x;
+ stretchHeight = dimensions.y;
}
else
{
- stretchWidth = display.getWidth();
- stretchHeight = display.getHeight();
+ Point dimensions = new Point();
+ display.getSize(dimensions);
+ stretchWidth = dimensions.x;
+ stretchHeight = dimensions.y;
}
float aspect = 0.75f; // TODO: Handle PAL
@@ -458,6 +466,9 @@ else if( AppData.IS_KITKAT && isImmersiveModeEnabled )
int originalHeight = isLetterboxed ? Math.round( (float) stretchWidth * aspect ) : stretchHeight;
String scaling = mPreferences.getString( "displayScaling", "original" );
+
+ videoSurfaceWidthOriginal = originalWidth;
+ videoSurfaceHeightOriginal = originalHeight;
// Native resolution
if( scaling.equals( "stretch" ) )
@@ -467,8 +478,8 @@ else if( AppData.IS_KITKAT && isImmersiveModeEnabled )
}
else // scaling.equals( "original")
{
- videoSurfaceWidth = originalWidth;
- videoSurfaceHeight = originalHeight;
+ videoSurfaceWidth = videoSurfaceWidthOriginal;
+ videoSurfaceHeight = videoSurfaceHeightOriginal;
}
}
}

0 comments on commit 7163b5c

Please sign in to comment.