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() {
24 public void copyAssets() {
25 Intent intent = new Intent(this, MinetestAssetCopy.class);
26 startActivity(intent);
29 public void showDialog(String acceptButton, String hint, String current,
32 Intent intent = new Intent(this, MinetestTextEntry.class);
33 Bundle params = new Bundle();
34 params.putString("acceptButton", acceptButton);
35 params.putString("hint", hint);
36 params.putString("current", current);
37 params.putInt("editType", editType);
38 intent.putExtras(params);
39 startActivityForResult(intent, 101);
40 m_MessageReturnValue = "";
41 m_MessagReturnCode = -1;
44 public static native void putMessageBoxResult(String text);
46 /* ugly code to workaround putMessageBoxResult not beeing found */
47 public int getDialogState() {
48 return m_MessagReturnCode;
51 public String getDialogValue() {
52 m_MessagReturnCode = -1;
53 return m_MessageReturnValue;
56 public float getDensity() {
57 return getResources().getDisplayMetrics().density;
60 public int getDisplayWidth() {
61 return getResources().getDisplayMetrics().widthPixels;
64 public int getDisplayHeight() {
65 return getResources().getDisplayMetrics().heightPixels;
69 protected void onActivityResult(int requestCode, int resultCode,
71 if (requestCode == 101) {
72 if (resultCode == RESULT_OK) {
73 String text = data.getStringExtra("text");
74 m_MessagReturnCode = 0;
75 m_MessageReturnValue = text;
78 m_MessagReturnCode = 1;
84 System.loadLibrary("openal");
85 System.loadLibrary("ogg");
86 System.loadLibrary("vorbis");
87 System.loadLibrary("ssl");
88 System.loadLibrary("crypto");
91 private int m_MessagReturnCode;
92 private String m_MessageReturnValue;