1 package net.minetest.minetest;
3 import android.app.NativeActivity;
4 import android.content.Intent;
5 import android.os.Build;
6 import android.os.Bundle;
7 import android.view.View;
8 import android.view.WindowManager;
10 public class MtNativeActivity extends NativeActivity {
13 System.loadLibrary("c++_shared");
14 System.loadLibrary("openal");
15 System.loadLibrary("ogg");
16 System.loadLibrary("vorbis");
17 System.loadLibrary("gmp");
18 System.loadLibrary("iconv");
19 System.loadLibrary("minetest");
22 private int m_MessagReturnCode;
23 private String m_MessageReturnValue;
25 public static native void putMessageBoxResult(String text);
28 public void onCreate(Bundle savedInstanceState) {
29 super.onCreate(savedInstanceState);
30 getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
31 m_MessagReturnCode = -1;
32 m_MessageReturnValue = "";
36 protected void onResume() {
41 public void makeFullScreen() {
42 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
43 this.getWindow().getDecorView().setSystemUiVisibility(
44 View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
50 public void onWindowFocusChanged(boolean hasFocus) {
51 super.onWindowFocusChanged(hasFocus);
57 public void copyAssets() {
58 Intent intent = new Intent(this, MinetestAssetCopy.class);
59 startActivity(intent);
62 public void showDialog(String acceptButton, String hint, String current,
65 Intent intent = new Intent(this, MinetestTextEntry.class);
66 Bundle params = new Bundle();
67 params.putString("acceptButton", acceptButton);
68 params.putString("hint", hint);
69 params.putString("current", current);
70 params.putInt("editType", editType);
71 intent.putExtras(params);
72 startActivityForResult(intent, 101);
73 m_MessageReturnValue = "";
74 m_MessagReturnCode = -1;
77 /* ugly code to workaround putMessageBoxResult not beeing found */
78 public int getDialogState() {
79 return m_MessagReturnCode;
82 public String getDialogValue() {
83 m_MessagReturnCode = -1;
84 return m_MessageReturnValue;
87 public float getDensity() {
88 return getResources().getDisplayMetrics().density;
91 public int getDisplayWidth() {
92 return getResources().getDisplayMetrics().widthPixels;
95 public int getDisplayHeight() {
96 return getResources().getDisplayMetrics().heightPixels;
100 protected void onActivityResult(int requestCode, int resultCode,
102 if (requestCode == 101) {
103 if (resultCode == RESULT_OK) {
104 String text = data.getStringExtra("text");
105 m_MessagReturnCode = 0;
106 m_MessageReturnValue = text;
108 m_MessagReturnCode = 1;