Android build fixes for c++11
[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                 getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
14                 m_MessagReturnCode = -1;
15                 m_MessageReturnValue = "";
16
17         }
18
19         @Override
20         public void onDestroy() {
21                 super.onDestroy();
22         }
23
24         public void copyAssets() {
25                 Intent intent = new Intent(this, MinetestAssetCopy.class);
26                 startActivity(intent);
27         }
28
29         public void showDialog(String acceptButton, String hint, String current,
30                         int editType) {
31
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;
42         }
43
44         public static native void putMessageBoxResult(String text);
45
46         /* ugly code to workaround putMessageBoxResult not beeing found */
47         public int getDialogState() {
48                 return m_MessagReturnCode;
49         }
50
51         public String getDialogValue() {
52                 m_MessagReturnCode = -1;
53                 return m_MessageReturnValue;
54         }
55
56         public float getDensity() {
57                 return getResources().getDisplayMetrics().density;
58         }
59
60         public int getDisplayWidth() {
61                 return getResources().getDisplayMetrics().widthPixels;
62         }
63
64         public int getDisplayHeight() {
65                 return getResources().getDisplayMetrics().heightPixels;
66         }
67
68         @Override
69         protected void onActivityResult(int requestCode, int resultCode,
70                         Intent data) {
71                 if (requestCode == 101) {
72                         if (resultCode == RESULT_OK) {
73                                 String text = data.getStringExtra("text");
74                                 m_MessagReturnCode = 0;
75                                 m_MessageReturnValue = text;
76                         }
77                         else {
78                                 m_MessagReturnCode = 1;
79                         }
80                 }
81         }
82
83         static {
84                 System.loadLibrary("openal");
85                 System.loadLibrary("ogg");
86                 System.loadLibrary("vorbis");
87                 System.loadLibrary("gmp");
88                 System.loadLibrary("iconv");
89
90                 // We don't have to load libminetest.so ourselves,
91                 // but if we do, we get nicer logcat errors when
92                 // loading fails.
93                 System.loadLibrary("minetest");
94         }
95
96         private int m_MessagReturnCode;
97         private String m_MessageReturnValue;
98 }