diff options
author | Maksim <MoNTE48@mail.ua> | 2018-12-03 00:39:35 +0100 |
---|---|---|
committer | Paramat <paramat@users.noreply.github.com> | 2018-12-02 23:39:35 +0000 |
commit | f70f7875e2a2e49f80470832ae97e73f171d6460 (patch) | |
tree | 6620b45d2e0dd0b5e910120d6f17bcb471370c46 /build/android/src/main/java/net.minetest.minetest/MtNativeActivity.java | |
parent | 1b0fd195c614ffa1b04d687e7793fb5bb266c535 (diff) | |
download | minetest-f70f7875e2a2e49f80470832ae97e73f171d6460.tar.gz minetest-f70f7875e2a2e49f80470832ae97e73f171d6460.tar.bz2 minetest-f70f7875e2a2e49f80470832ae97e73f171d6460.zip |
Update Android java code (#7820)
Targets SDK 26 as required by the playstore.
Fixes screen auto-rotation closing game.
Hides on-screen navigation bar if present.
Update gradlew.
Fix display aspect on 18+/:9 displays (like a Samsung Galaxy S9).
Remove small app icons, not required.
Fix xml in unpacking activity.
Support Android permission: On Android 6.0+ you need to manually give write
permission (as required by google).
Background during unpacking (just a demo for now).
Material Design: no more Android 2 interface.
Immersive mode (Android 4.4+ - hide NavBar for fullscreen mode).
Diffstat (limited to 'build/android/src/main/java/net.minetest.minetest/MtNativeActivity.java')
-rw-r--r-- | build/android/src/main/java/net.minetest.minetest/MtNativeActivity.java | 65 |
1 files changed, 39 insertions, 26 deletions
diff --git a/build/android/src/main/java/net.minetest.minetest/MtNativeActivity.java b/build/android/src/main/java/net.minetest.minetest/MtNativeActivity.java index dd611158f..f76634c20 100644 --- a/build/android/src/main/java/net.minetest.minetest/MtNativeActivity.java +++ b/build/android/src/main/java/net.minetest.minetest/MtNativeActivity.java @@ -2,23 +2,55 @@ package net.minetest.minetest; import android.app.NativeActivity; import android.content.Intent; +import android.os.Build; import android.os.Bundle; -import android.util.Log; +import android.view.View; import android.view.WindowManager; public class MtNativeActivity extends NativeActivity { + + static { + System.loadLibrary("openal"); + System.loadLibrary("ogg"); + System.loadLibrary("vorbis"); + System.loadLibrary("gmp"); + System.loadLibrary("iconv"); + System.loadLibrary("minetest"); + } + + private int m_MessagReturnCode; + private String m_MessageReturnValue; + + public static native void putMessageBoxResult(String text); + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); m_MessagReturnCode = -1; m_MessageReturnValue = ""; + } + + @Override + protected void onResume() { + super.onResume(); + makeFullScreen(); + } + public void makeFullScreen() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + this.getWindow().getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY + ); + } } @Override - public void onDestroy() { - super.onDestroy(); + public void onWindowFocusChanged(boolean hasFocus) { + super.onWindowFocusChanged(hasFocus); + if (hasFocus) { + makeFullScreen(); + } } public void copyAssets() { @@ -27,7 +59,7 @@ public class MtNativeActivity extends NativeActivity { } public void showDialog(String acceptButton, String hint, String current, - int editType) { + int editType) { Intent intent = new Intent(this, MinetestTextEntry.class); Bundle params = new Bundle(); @@ -38,11 +70,9 @@ public class MtNativeActivity extends NativeActivity { intent.putExtras(params); startActivityForResult(intent, 101); m_MessageReturnValue = ""; - m_MessagReturnCode = -1; + m_MessagReturnCode = -1; } - public static native void putMessageBoxResult(String text); - /* ugly code to workaround putMessageBoxResult not beeing found */ public int getDialogState() { return m_MessagReturnCode; @@ -67,32 +97,15 @@ public class MtNativeActivity extends NativeActivity { @Override protected void onActivityResult(int requestCode, int resultCode, - Intent data) { + Intent data) { if (requestCode == 101) { if (resultCode == RESULT_OK) { String text = data.getStringExtra("text"); m_MessagReturnCode = 0; m_MessageReturnValue = text; - } - else { + } else { m_MessagReturnCode = 1; } } } - - static { - System.loadLibrary("openal"); - System.loadLibrary("ogg"); - System.loadLibrary("vorbis"); - System.loadLibrary("gmp"); - System.loadLibrary("iconv"); - - // We don't have to load libminetest.so ourselves, - // but if we do, we get nicer logcat errors when - // loading fails. - System.loadLibrary("minetest"); - } - - private int m_MessagReturnCode; - private String m_MessageReturnValue; } |