mirror of
https://github.com/encounter/SDL.git
synced 2025-12-08 13:15:10 +00:00
On Android show the system UI when an SDL window is windowed, hide the system UI when it's fullscreen, like we do on iOS.
We're increasing the Android SDK minimum version to API 19, this doesn't increase the minimum target API, which is API 14.
This commit is contained in:
@@ -8,14 +8,14 @@ else {
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 16
|
||||
compileSdkVersion 19
|
||||
buildToolsVersion "26.0.1"
|
||||
defaultConfig {
|
||||
if (buildAsApplication) {
|
||||
applicationId "org.libsdl.app"
|
||||
}
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 16
|
||||
targetSdkVersion 19
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
externalNativeBuild {
|
||||
@@ -65,4 +65,4 @@ dependencies {
|
||||
exclude group: 'com.android.support', module: 'support-annotations'
|
||||
})
|
||||
testCompile 'junit:junit:4.12'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,5 +5,5 @@
|
||||
|
||||
APP_ABI := armeabi-v7a arm64-v8a x86 x86_64
|
||||
|
||||
# Min SDK level
|
||||
# Min runtime API level
|
||||
APP_PLATFORM=android-14
|
||||
|
||||
@@ -213,19 +213,7 @@ public class SDLActivity extends Activity {
|
||||
|
||||
setContentView(mLayout);
|
||||
|
||||
/*
|
||||
* Per SDL_androidwindow.c, Android will only ever have one window, and that window
|
||||
* is always flagged SDL_WINDOW_FULLSCREEN. Let's treat it as an immersive fullscreen
|
||||
* window for Android UI purposes, as a result.
|
||||
*/
|
||||
int iFlags =
|
||||
//View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | // Only available since API 19
|
||||
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
|
||||
View.SYSTEM_UI_FLAG_FULLSCREEN;
|
||||
|
||||
getWindow().getDecorView().setSystemUiVisibility(iFlags);
|
||||
setWindowStyle(false);
|
||||
|
||||
// Get filename from "Open with" of another application
|
||||
Intent intent = getIntent();
|
||||
@@ -408,7 +396,7 @@ public class SDLActivity extends Activity {
|
||||
|
||||
// Messages from the SDLMain thread
|
||||
static final int COMMAND_CHANGE_TITLE = 1;
|
||||
static final int COMMAND_UNUSED = 2;
|
||||
static final int COMMAND_CHANGE_WINDOW_STYLE = 2;
|
||||
static final int COMMAND_TEXTEDIT_HIDE = 3;
|
||||
static final int COMMAND_SET_KEEP_SCREEN_ON = 5;
|
||||
|
||||
@@ -447,6 +435,29 @@ public class SDLActivity extends Activity {
|
||||
Log.e(TAG, "error handling message, getContext() returned no Activity");
|
||||
}
|
||||
break;
|
||||
case COMMAND_CHANGE_WINDOW_STYLE:
|
||||
if (context instanceof Activity) {
|
||||
Window window = ((Activity) context).getWindow();
|
||||
if (window != null) {
|
||||
if ((msg.obj instanceof Integer) && (((Integer) msg.obj).intValue() != 0)) {
|
||||
int flags = 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;
|
||||
window.getDecorView().setSystemUiVisibility(flags);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
} else {
|
||||
int flags = View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
|
||||
window.getDecorView().setSystemUiVisibility(flags);
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "error handling message, getContext() returned no Activity");
|
||||
}
|
||||
break;
|
||||
case COMMAND_TEXTEDIT_HIDE:
|
||||
if (mTextEdit != null) {
|
||||
// Note: On some devices setting view to GONE creates a flicker in landscape.
|
||||
@@ -524,6 +535,14 @@ public class SDLActivity extends Activity {
|
||||
return mSingleton.sendCommand(COMMAND_CHANGE_TITLE, title);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
*/
|
||||
public static void setWindowStyle(boolean fullscreen) {
|
||||
// Called from SDLMain() thread and can't directly affect the view
|
||||
mSingleton.sendCommand(COMMAND_CHANGE_WINDOW_STYLE, fullscreen ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called by SDL using JNI.
|
||||
* This is a static method for JNI convenience, it calls a non-static method
|
||||
@@ -637,7 +656,7 @@ public class SDLActivity extends Activity {
|
||||
if (bundle == null) {
|
||||
return false;
|
||||
}
|
||||
String prefix = "SDL_ENV.";
|
||||
String prefix = "SDL_ENV.";
|
||||
final int trimLength = prefix.length();
|
||||
for (String key : bundle.keySet()) {
|
||||
if (key.startsWith(prefix)) {
|
||||
|
||||
Reference in New Issue
Block a user