Using immersive mode by default

This commit is contained in:
fysx
2015-01-16 20:41:03 +01:00
parent b732d6cc12
commit 535a8256ee
+32 -17
View File
@@ -29,6 +29,7 @@ import android.os.Vibrator;
import android.util.Log; import android.util.Log;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.widget.Toast; import android.widget.Toast;
import android.view.*;
public class GameActivity extends SDLActivity { public class GameActivity extends SDLActivity {
private static DisplayMetrics metrics = new DisplayMetrics(); private static DisplayMetrics metrics = new DisplayMetrics();
@@ -46,14 +47,14 @@ public class GameActivity extends SDLActivity {
Uri game = this.getIntent().getData(); Uri game = this.getIntent().getData();
if (game != null) { if (game != null) {
if (game.getScheme().equals ("file")) { if (game.getScheme().equals ("file")) {
// If we were given the path of a main.lua then use its // If we were given the path of a main.lua then use its
// directory. Otherwise use full path. // directory. Otherwise use full path.
List<String> path_segments = game.getPathSegments(); List<String> path_segments = game.getPathSegments();
if (path_segments.get(path_segments.size() - 1).equals("main.lua")) { if (path_segments.get(path_segments.size() - 1).equals("main.lua")) {
gamePath = game.getPath().substring(0, game.getPath().length() - "main.lua".length()); gamePath = game.getPath().substring(0, game.getPath().length() - "main.lua".length());
} else { } else {
gamePath = game.getPath(); gamePath = game.getPath();
} }
} else { } else {
copyGameToCache (game); copyGameToCache (game);
} }
@@ -66,17 +67,31 @@ public class GameActivity extends SDLActivity {
@Override @Override
protected void onDestroy() { protected void onDestroy() {
Log.d("GameActivity", "Cancelling vibration"); Log.d("GameActivity", "Cancelling vibration");
vibrator.cancel(); vibrator.cancel();
super.onDestroy(); super.onDestroy();
} }
@Override @Override
protected void onPause() { protected void onPause() {
Log.d("GameActivity", "Cancelling vibration"); Log.d("GameActivity", "Cancelling vibration");
vibrator.cancel(); vibrator.cancel();
super.onPause(); super.onPause();
} }
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
}
}
public static String getGamePath() { public static String getGamePath() {
Log.d ("GameActivity", "called getGamePath(), game path = " + gamePath); Log.d ("GameActivity", "called getGamePath(), game path = " + gamePath);