20
20
21
21
package net .minetest .minetest ;
22
22
23
- import android .app .NativeActivity ;
23
+ import org .libsdl .app .SDLActivity ;
24
+
24
25
import android .content .Intent ;
25
26
import android .net .Uri ;
26
27
import android .os .Bundle ;
32
33
import android .view .inputmethod .InputMethodManager ;
33
34
import android .widget .Button ;
34
35
import android .widget .LinearLayout ;
36
+ import android .content .res .Configuration ;
35
37
36
38
import androidx .annotation .Keep ;
37
39
import androidx .appcompat .app .AlertDialog ;
45
47
// This annotation prevents the minifier/Proguard from mangling them.
46
48
@ Keep
47
49
@ SuppressWarnings ("unused" )
48
- public class GameActivity extends NativeActivity {
49
- static {
50
- System .loadLibrary ("c++_shared" );
51
- System .loadLibrary ("minetest" );
52
- }
53
-
54
- enum DialogType { TEXT_INPUT , SELECTION_INPUT }
55
- enum DialogState { DIALOG_SHOWN , DIALOG_INPUTTED , DIALOG_CANCELED }
56
-
57
- private DialogType lastDialogType = DialogType .TEXT_INPUT ;
58
- private DialogState inputDialogState = DialogState .DIALOG_CANCELED ;
59
- private String messageReturnValue = "" ;
60
- private int selectionReturnValue = 0 ;
61
-
50
+ public class GameActivity extends SDLActivity {
62
51
@ Override
63
- public void onCreate (Bundle savedInstanceState ) {
64
- super .onCreate (savedInstanceState );
65
- getWindow ().addFlags (WindowManager .LayoutParams .FLAG_KEEP_SCREEN_ON );
52
+ protected String getMainSharedObject () {
53
+ return getContext ().getApplicationInfo ().nativeLibraryDir + "/libminetest.so" ;
66
54
}
67
55
68
- private void makeFullScreen () {
69
- this .getWindow ().getDecorView ().setSystemUiVisibility (
70
- View .SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
71
- View .SYSTEM_UI_FLAG_HIDE_NAVIGATION |
72
- View .SYSTEM_UI_FLAG_IMMERSIVE_STICKY );
56
+ @ Override
57
+ protected String getMainFunction () {
58
+ return "SDL_Main" ;
73
59
}
74
60
75
61
@ Override
76
- public void onWindowFocusChanged ( boolean hasFocus ) {
77
- super . onWindowFocusChanged ( hasFocus );
78
- if ( hasFocus )
79
- makeFullScreen () ;
62
+ protected String [] getLibraries ( ) {
63
+ return new String [] {
64
+ "minetest"
65
+ } ;
80
66
}
81
67
68
+ // Prevent SDL from changing orientation settings since we already set the
69
+ // correct orientation in our AndroidManifest.xml
82
70
@ Override
83
- protected void onResume () {
84
- super .onResume ();
85
- makeFullScreen ();
86
- }
71
+ public void setOrientationBis (int w , int h , boolean resizable , String hint ) {}
72
+
73
+ enum DialogType { TEXT_INPUT , SELECTION_INPUT }
74
+ enum DialogState { DIALOG_SHOWN , DIALOG_INPUTTED , DIALOG_CANCELED }
75
+
76
+ private DialogType lastDialogType = DialogType .TEXT_INPUT ;
77
+ private DialogState inputDialogState = DialogState .DIALOG_CANCELED ;
78
+ private String messageReturnValue = "" ;
79
+ private int selectionReturnValue = 0 ;
87
80
88
81
private native void saveSettings ();
89
82
@@ -96,11 +89,6 @@ protected void onStop() {
96
89
saveSettings ();
97
90
}
98
91
99
- @ Override
100
- public void onBackPressed () {
101
- // Ignore the back press so Minetest can handle it
102
- }
103
-
104
92
public void showTextInputDialog (String hint , String current , int editType ) {
105
93
runOnUiThread (() -> showTextInputDialogUI (hint , current , editType ));
106
94
}
@@ -265,4 +253,8 @@ public String getLanguage() {
265
253
266
254
return langCode ;
267
255
}
256
+
257
+ public boolean hasPhysicalKeyboard () {
258
+ return getContext ().getResources ().getConfiguration ().keyboard != Configuration .KEYBOARD_NOKEYS ;
259
+ }
268
260
}
0 commit comments