DEADSOFTWARE

Android: added navigation bar hiding hack
[d2df-sdl.git] / android / src / org / libsdl / app / SDLActivity.java
index 9119473f534fd698aa83970175ab9bd58f43cbd1..585ad30a12ca85d5ee928a18cf1728059259174b 100644 (file)
@@ -4,7 +4,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.util.Arrays;
 import java.lang.reflect.Method;
-import java.util.Objects;
 
 import android.app.*;
 import android.content.*;
@@ -218,6 +217,8 @@ public class SDLActivity extends Activity {
                 SDLActivity.onNativeDropFile(filename);
             }
         }
+
+       hideNavigationBar();
     }
 
     // Events
@@ -242,6 +243,8 @@ public class SDLActivity extends Activity {
         mNextNativeState = NativeState.RESUMED;
         mIsResumedCalled = true;
 
+       hideNavigationBar();
+
         if (SDLActivity.mBrokenLibraries) {
            return;
         }
@@ -457,6 +460,8 @@ public class SDLActivity extends Activity {
                     InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
                     imm.hideSoftInputFromWindow(mTextEdit.getWindowToken(), 0);
                     
+                    hideNavigationBar();
+
                     mScreenKeyboardShown = false;
                 }
                 break;
@@ -542,7 +547,7 @@ public class SDLActivity extends Activity {
     {
       int orientation = -1;
 
-      if (!Objects.equals(hint, "")) {
+      if (hint != null && !hint.equals("")) {
          if (hint.contains("LandscapeRight") && hint.contains("LandscapeLeft")) {
             orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
          } else if (hint.contains("LandscapeRight")) {
@@ -844,6 +849,15 @@ public class SDLActivity extends Activity {
         return messageboxSelection[0];
     }
 
+    public static void hideNavigationBar() {
+        if (Build.VERSION.SDK_INT >= 19) {
+            int opt = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+                    | View.SYSTEM_UI_FLAG_FULLSCREEN
+                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
+            mSingleton.getWindow().getDecorView().setSystemUiVisibility(opt);
+        }
+    }
+
     @Override
     protected Dialog onCreateDialog(int ignore, Bundle args) {