Tell irrlicht if we handle a key or not.
[oweals/minetest.git] / build / android / src / main / java / net.minetest.minetest / MtNativeActivity.java
1 package net.minetest.minetest;
2
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;
8
9 public class MtNativeActivity extends NativeActivity {
10         @Override
11         public void onCreate(Bundle savedInstanceState) {
12                 super.onCreate(savedInstanceState);
13                 m_MessagReturnCode = -1;
14                 m_MessageReturnValue = "";
15
16         }
17
18         @Override
19         public void onDestroy() {
20                 super.onDestroy();
21         }
22
23         public void copyAssets() {
24                 Intent intent = new Intent(this, MinetestAssetCopy.class);
25                 startActivity(intent);
26         }
27
28         public void showDialog(String acceptButton, String hint, String current,
29                         int editType) {
30
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;
41         }
42
43         public static native void putMessageBoxResult(String text);
44
45         /* ugly code to workaround putMessageBoxResult not beeing found */
46         public int getDialogState() {
47                 return m_MessagReturnCode;
48         }
49
50         public String getDialogValue() {
51                 m_MessagReturnCode = -1;
52                 return m_MessageReturnValue;
53         }
54
55         public float getDensity() {
56                 return getResources().getDisplayMetrics().density;
57         }
58
59         public int getDisplayWidth() {
60                 return getResources().getDisplayMetrics().widthPixels;
61         }
62
63         public int getDisplayHeight() {
64                 return getResources().getDisplayMetrics().heightPixels;
65         }
66
67         @Override
68         protected void onActivityResult(int requestCode, int resultCode,
69                         Intent data) {
70                 if (requestCode == 101) {
71                         if (resultCode == RESULT_OK) {
72                                 String text = data.getStringExtra("text");
73                                 m_MessagReturnCode = 0;
74                                 m_MessageReturnValue = text;
75                         }
76                         else {
77                                 m_MessagReturnCode = 1;
78                         }
79                 }
80         }
81
82         static {
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");
90
91                 // We don't have to load libminetest.so ourselves,
92                 // but if we do, we get nicer logcat errors when
93                 // loading fails.
94                 System.loadLibrary("minetest");
95         }
96
97         private int m_MessagReturnCode;
98         private String m_MessageReturnValue;
99 }