Atlas - SDLEntryTestActivity.java.cmake
Home / ext / SDL / test / android / cmake Lines: 6 | Size: 3823 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)][FILE BEGIN]1package @ANDROID_MANIFEST_PACKAGE@; 2 3import android.app.Activity; 4import android.app.AlertDialog; 5import android.content.Context; 6import android.content.DialogInterface; 7import android.content.Intent; 8import android.os.Bundle; 9import android.util.Log; 10 11import org.libsdl.app.SDLActivity; 12 13import android.widget.Button; 14import android.widget.EditText; 15import android.widget.TextView; 16 17import android.view.View; 18import android.view.ViewGroup; 19import android.view.LayoutInflater; 20 21public class SDLEntryTestActivity extends Activity { 22 23 public String MODIFY_ARGUMENTS = "@[email protected]_ARGUMENTS"; 24 boolean isModifyingArguments; 25 26 @Override 27 protected void onCreate(Bundle savedInstanceState) { 28 Log.v("SDL", "SDLEntryTestActivity onCreate"); 29 super.onCreate(savedInstanceState); 30 31 String intent_action = getIntent().getAction(); 32 Log.v("SDL", "SDLEntryTestActivity intent.action = " + intent_action); 33 34 if (intent_action == MODIFY_ARGUMENTS) { 35 isModifyingArguments = true; 36 createArgumentLayout(); 37 } else { 38 startChildActivityAndFinish(); 39 } 40 } 41 42 protected void createArgumentLayout() { 43 LayoutInflater inflater = getLayoutInflater(); 44 View view = inflater.inflate(R.layout.arguments_layout, null); 45 setContentView(view); 46 47 Button button = (Button)requireViewById(R.id.arguments_start_button); 48 button.setOnClickListener(new View.OnClickListener() { 49 public void onClick(View v) { 50 startChildActivityAndFinish(); 51 } 52 }); 53 } 54 55 protected String[] getArguments() { 56 if (!isModifyingArguments) { 57 return new String[0]; 58 } 59 EditText editText = (EditText)findViewById(R.id.arguments_edit); 60 String text = editText.getText().toString(); 61 String new_text = text.replace("[ \t]*[ \t\n]+[ \t]+", "\n").strip(); 62 Log.v("SDL", "text = " + text + "\n becomes \n" + new_text); 63 return new_text.split("\n", 0); 64 } 65 66 @Override 67 protected void onStart() { 68 Log.v("SDL", "SDLEntryTestActivity onStart"); 69 super.onStart(); 70 } 71 72 @Override 73 protected void onResume() { 74 Log.v("SDL", "SDLEntryTestActivity onResume"); 75 super.onResume(); 76 } 77 78 @Override 79 protected void onPause() { 80 Log.v("SDL", "SDLEntryTestActivity onPause"); 81 super.onPause(); 82 } 83 84 @Override 85 protected void onStop() { 86 Log.v("SDL", "SDLEntryTestActivity onStop"); 87 super.onStop(); 88 } 89 90 @Override 91 protected void onDestroy() { 92 Log.v("SDL", "SDLEntryTestActivity onDestroy"); 93 super.onDestroy(); 94 } 95 96 @Override 97 protected void onRestoreInstanceState(Bundle savedInstanceState) { 98 Log.v("SDL", "SDLEntryTestActivity onRestoreInstanceState"); 99 super.onRestoreInstanceState(savedInstanceState); 100 EditText editText = (EditText)findViewById(R.id.arguments_edit); 101 editText.setText(savedInstanceState.getCharSequence("args", ""), TextView.BufferType.EDITABLE); 102 } 103 104 @Override 105 protected void onSaveInstanceState(Bundle outState) { 106 Log.v("SDL", "SDLEntryTestActivity onSaveInstanceState"); 107 EditText editText = (EditText)findViewById(R.id.arguments_edit); 108 outState.putCharSequence("args", editText.getText()); 109 super.onSaveInstanceState(outState); 110 } 111 112 private void startChildActivityAndFinish() { 113 Intent intent = new Intent(Intent.ACTION_MAIN); 114 intent.addCategory(Intent.CATEGORY_LAUNCHER); 115 intent.setClassName("@ANDROID_MANIFEST_PACKAGE@", "@[email protected]"); 116 intent.putExtra("arguments", getArguments()); 117 startActivity(intent); 118 finish(); 119 } 120} 121[FILE END](C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.