1 package net.minetest.minetest;
3 import android.app.NativeActivity;
4 import android.content.Intent;
5 import android.os.Bundle;
6 import android.util.Log;
7 import android.view.WindowManager;
9 public class MtNativeActivity extends NativeActivity {
11 public void onCreate(Bundle savedInstanceState) {
12 super.onCreate(savedInstanceState);
13 m_MessagReturnCode = -1;
14 m_MessageReturnValue = "";
19 public void onDestroy() {
23 public void copyAssets() {
24 Intent intent = new Intent(this, MinetestAssetCopy.class);
25 startActivity(intent);
28 public void showDialog(String acceptButton, String hint, String current,
31 Intent intent = new Intent(this, MinetestTextEntry.class);
32 Bundle params = new Bundle();
33 params.putString("acceptButton", acceptButton);
34 params.putString("hint", hint);
35 params.putString("current", current);
36 params.putInt("editType", editType);
37 intent.putExtras(params);
38 startActivityForResult(intent, 101);
39 m_MessageReturnValue = "";
40 m_MessagReturnCode = -1;
43 public static native void putMessageBoxResult(String text);
45 /* ugly code to workaround putMessageBoxResult not beeing found */
46 public int getDialogState() {
47 return m_MessagReturnCode;
50 public String getDialogValue() {
51 m_MessagReturnCode = -1;
52 return m_MessageReturnValue;
55 public float getDensity() {
56 return getResources().getDisplayMetrics().density;
59 public int getDisplayWidth() {
60 return getResources().getDisplayMetrics().widthPixels;
63 public int getDisplayHeight() {
64 return getResources().getDisplayMetrics().heightPixels;
68 protected void onActivityResult(int requestCode, int resultCode,
70 if (requestCode == 101) {
71 if (resultCode == RESULT_OK) {
72 String text = data.getStringExtra("text");
73 m_MessagReturnCode = 0;
74 m_MessageReturnValue = text;
77 m_MessagReturnCode = 1;
83 System.loadLibrary("openal");
84 System.loadLibrary("ogg");
85 System.loadLibrary("vorbis");
86 System.loadLibrary("ssl");
87 System.loadLibrary("crypto");
88 System.loadLibrary("gmp");
89 System.loadLibrary("iconv");
91 // We don't have to load libminetest.so ourselves,
92 // but if we do, we get nicer logcat errors when
94 System.loadLibrary("minetest");
97 private int m_MessagReturnCode;
98 private String m_MessageReturnValue;