]> git.lizzy.rs Git - minetest.git/blob - build/android/src/org/minetest/minetest/MtNativeActivity.java
Android: fix package name in JAVA sources
[minetest.git] / build / android / src / org / 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         
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("ssl");
88                 System.loadLibrary("crypto");
89         }
90         
91         private int m_MessagReturnCode;
92         private String m_MessageReturnValue;
93 }