Permalink
Browse files

no longer allow launching in landscape if screen is too small

  • Loading branch information...
Lawrence D'Oliveiro
Lawrence D'Oliveiro committed Sep 30, 2012
1 parent 7e02064 commit 140b5c045ed45316b50d8f562acba2e298e6c2fc
Showing with 17 additions and 9 deletions.
  1. +17 −9 src/Main.java
View
@@ -1260,6 +1260,21 @@ public void PostRun()
} /*if*/
} /*onActivityResult*/
+ void CheckDisplayOrientation()
+ /* ensures that landscape orientation is only allowed on screens that
+ are tall enough. */
+ {
+ final android.view.Display MainDisplay = getWindowManager().getDefaultDisplay();
+ final android.util.DisplayMetrics MainMetrics = new android.util.DisplayMetrics();
+ MainDisplay.getMetrics(MainMetrics);
+ if (MainMetrics.heightPixels / MainMetrics.densityDpi * 160.0f <= 640.0f)
+ {
+ /* Lock to portrait orientation on phone-sized screens. Note once I do this,
+ I stop getting further notifications of orientation change. */
+ setRequestedOrientation(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+ } /*if*/
+ } /*CheckDisplayOrientation*/
+
void PostNotification
(
int MsgID,
@@ -1332,6 +1347,7 @@ public void run()
} /*if*/
} /*run*/
} /*Runnable*/;
+ CheckDisplayOrientation();
} /*onCreate*/
@Override
@@ -1420,15 +1436,7 @@ public void PostRun()
)
{
super.onConfigurationChanged(NewConfig);
- final android.view.Display MainDisplay = getWindowManager().getDefaultDisplay();
- final android.util.DisplayMetrics MainMetrics = new android.util.DisplayMetrics();
- MainDisplay.getMetrics(MainMetrics);
- if (MainMetrics.heightPixels / MainMetrics.densityDpi * 160.0f <= 640.0f)
- {
- /* Lock to portrait orientation on phone-sized screens. Note once I do this,
- I stop getting further notifications of orientation change. */
- setRequestedOrientation(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
- } /*if*/
+ CheckDisplayOrientation();
} /*onConfigurationChanged*/
@Override

0 comments on commit 140b5c0

Please sign in to comment.