diff options
author | 3gg <3gg@shellblade.net> | 2025-08-30 16:53:58 -0700 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2025-08-30 16:53:58 -0700 |
commit | 6aaedb813fa11ba0679c3051bc2eb28646b9506c (patch) | |
tree | 34acbfc9840e02cb4753e6306ea7ce978bf8b58e /src/contrib/SDL-3.2.20/test/android/cmake/SDLEntryTestActivity.java.cmake | |
parent | 8f228ade99dd3d4c8da9b78ade1815c9adf85c8f (diff) |
Update to SDL3
Diffstat (limited to 'src/contrib/SDL-3.2.20/test/android/cmake/SDLEntryTestActivity.java.cmake')
-rw-r--r-- | src/contrib/SDL-3.2.20/test/android/cmake/SDLEntryTestActivity.java.cmake | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/src/contrib/SDL-3.2.20/test/android/cmake/SDLEntryTestActivity.java.cmake b/src/contrib/SDL-3.2.20/test/android/cmake/SDLEntryTestActivity.java.cmake new file mode 100644 index 0000000..f8d08f1 --- /dev/null +++ b/src/contrib/SDL-3.2.20/test/android/cmake/SDLEntryTestActivity.java.cmake | |||
@@ -0,0 +1,121 @@ | |||
1 | package @ANDROID_MANIFEST_PACKAGE@; | ||
2 | |||
3 | import android.app.Activity; | ||
4 | import android.app.AlertDialog; | ||
5 | import android.content.Context; | ||
6 | import android.content.DialogInterface; | ||
7 | import android.content.Intent; | ||
8 | import android.os.Bundle; | ||
9 | import android.util.Log; | ||
10 | |||
11 | import org.libsdl.app.SDL; | ||
12 | import org.libsdl.app.SDLActivity; | ||
13 | |||
14 | import android.widget.Button; | ||
15 | import android.widget.EditText; | ||
16 | import android.widget.TextView; | ||
17 | |||
18 | import android.view.View; | ||
19 | import android.view.ViewGroup; | ||
20 | import android.view.LayoutInflater; | ||
21 | |||
22 | public class SDLEntryTestActivity extends Activity { | ||
23 | |||
24 | public String MODIFY_ARGUMENTS = "@ANDROID_MANIFEST_PACKAGE@.MODIFY_ARGUMENTS"; | ||
25 | boolean isModifyingArguments; | ||
26 | |||
27 | @Override | ||
28 | protected void onCreate(Bundle savedInstanceState) { | ||
29 | Log.v("SDL", "SDLEntryTestActivity onCreate"); | ||
30 | super.onCreate(savedInstanceState); | ||
31 | |||
32 | String intent_action = getIntent().getAction(); | ||
33 | Log.v("SDL", "SDLEntryTestActivity intent.action = " + intent_action); | ||
34 | |||
35 | if (intent_action == MODIFY_ARGUMENTS) { | ||
36 | isModifyingArguments = true; | ||
37 | createArgumentLayout(); | ||
38 | } else { | ||
39 | startChildActivityAndFinish(); | ||
40 | } | ||
41 | } | ||
42 | |||
43 | protected void createArgumentLayout() { | ||
44 | LayoutInflater inflater = getLayoutInflater(); | ||
45 | View view = inflater.inflate(R.layout.arguments_layout, null); | ||
46 | setContentView(view); | ||
47 | |||
48 | Button button = (Button)requireViewById(R.id.arguments_start_button); | ||
49 | button.setOnClickListener(new View.OnClickListener() { | ||
50 | public void onClick(View v) { | ||
51 | startChildActivityAndFinish(); | ||
52 | } | ||
53 | }); | ||
54 | } | ||
55 | |||
56 | protected String[] getArguments() { | ||
57 | if (!isModifyingArguments) { | ||
58 | return new String[0]; | ||
59 | } | ||
60 | EditText editText = (EditText)findViewById(R.id.arguments_edit); | ||
61 | String text = editText.getText().toString(); | ||
62 | String new_text = text.replace("[ \t]*[ \t\n]+[ \t]+", "\n").strip(); | ||
63 | Log.v("SDL", "text = " + text + "\n becomes \n" + new_text); | ||
64 | return new_text.split("\n", 0); | ||
65 | } | ||
66 | |||
67 | @Override | ||
68 | protected void onStart() { | ||
69 | Log.v("SDL", "SDLEntryTestActivity onStart"); | ||
70 | super.onStart(); | ||
71 | } | ||
72 | |||
73 | @Override | ||
74 | protected void onResume() { | ||
75 | Log.v("SDL", "SDLEntryTestActivity onResume"); | ||
76 | super.onResume(); | ||
77 | } | ||
78 | |||
79 | @Override | ||
80 | protected void onPause() { | ||
81 | Log.v("SDL", "SDLEntryTestActivity onPause"); | ||
82 | super.onPause(); | ||
83 | } | ||
84 | |||
85 | @Override | ||
86 | protected void onStop() { | ||
87 | Log.v("SDL", "SDLEntryTestActivity onStop"); | ||
88 | super.onStop(); | ||
89 | } | ||
90 | |||
91 | @Override | ||
92 | protected void onDestroy() { | ||
93 | Log.v("SDL", "SDLEntryTestActivity onDestroy"); | ||
94 | super.onDestroy(); | ||
95 | } | ||
96 | |||
97 | @Override | ||
98 | protected void onRestoreInstanceState(Bundle savedInstanceState) { | ||
99 | Log.v("SDL", "SDLEntryTestActivity onRestoreInstanceState"); | ||
100 | super.onRestoreInstanceState(savedInstanceState); | ||
101 | EditText editText = (EditText)findViewById(R.id.arguments_edit); | ||
102 | editText.setText(savedInstanceState.getCharSequence("args", ""), TextView.BufferType.EDITABLE); | ||
103 | } | ||
104 | |||
105 | @Override | ||
106 | protected void onSaveInstanceState(Bundle outState) { | ||
107 | Log.v("SDL", "SDLEntryTestActivity onSaveInstanceState"); | ||
108 | EditText editText = (EditText)findViewById(R.id.arguments_edit); | ||
109 | outState.putCharSequence("args", editText.getText()); | ||
110 | super.onSaveInstanceState(outState); | ||
111 | } | ||
112 | |||
113 | private void startChildActivityAndFinish() { | ||
114 | Intent intent = new Intent(Intent.ACTION_MAIN); | ||
115 | intent.addCategory(Intent.CATEGORY_LAUNCHER); | ||
116 | intent.setClassName("@ANDROID_MANIFEST_PACKAGE@", "@ANDROID_MANIFEST_PACKAGE@.SDLTestActivity"); | ||
117 | intent.putExtra("arguments", getArguments()); | ||
118 | startActivity(intent); | ||
119 | finish(); | ||
120 | } | ||
121 | } | ||