From aff724c8d51e714217b91192e822e6f9e7e248e6 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 18 Dec 2015 02:23:16 -0500 Subject: [PATCH] v0.3.3: added the ability to flip the screen in landscape/portrait --- AndroidManifest.xml | 2 +- .../shatteredpixeldungeon/ShatteredPixelDungeon.java | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 7b4a40f8e..dc2aac11a 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -29,7 +29,7 @@ android:label="@string/app_name" android:name=".ShatteredPixelDungeon" android:configChanges="keyboardHidden|orientation|screenSize" - android:screenOrientation="portrait"> + android:screenOrientation="sensorPortrait"> diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java b/src/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java index 8b79f0a54..3a90494c8 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java @@ -207,9 +207,15 @@ public class ShatteredPixelDungeon extends Game { */ public static void landscape( boolean value ) { - Game.instance.setRequestedOrientation( value ? - ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : - ActivityInfo.SCREEN_ORIENTATION_PORTRAIT ); + if (android.os.Build.VERSION.SDK_INT >= 9) { + Game.instance.setRequestedOrientation(value ? + ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : + ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); + } else { + Game.instance.setRequestedOrientation(value ? + ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : + ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + } Preferences.INSTANCE.put( Preferences.KEY_LANDSCAPE, value ); }