3 import android
.app
.Activity
;
4 import android
.os
.Bundle
;
5 import android
.util
.Log
;
7 import android
.content
.*;
10 import android
.widget
.*;
11 import android
.text
.*;
17 public class Launcher
extends Activity
{
19 static final String preferences
= "org.d2df.app.PREF";
20 static final String prefArgs
= "CommandLine";
22 private EditText cmdline
;
24 private void saveCommandLine () {
25 String s
= cmdline
.getText().toString();
26 SharedPreferences sh
= getSharedPreferences(preferences
, MODE_PRIVATE
);
27 SharedPreferences
.Editor ed
= sh
.edit();
28 ed
.putString(prefArgs
, s
);
32 private String
loadCommandLine () {
33 SharedPreferences sh
= getSharedPreferences(preferences
, MODE_PRIVATE
);
34 return sh
.getString(prefArgs
, "");
37 private class CmdLineWatcher
implements TextWatcher
{
40 public void beforeTextChanged (CharSequence s
, int start
, int count
,int after
) {
44 public void onTextChanged (CharSequence s
, int start
, int before
, int count
) {
48 public void afterTextChanged (Editable s
) {
53 private View
.OnClickListener StartVavoomEvent
= new View
.OnClickListener () {
55 public void onClick (View view
) {
56 Intent intent
= new Intent(Launcher
.this, Doom2DF
.class);
57 String s
= Launcher
.this.cmdline
.getText().toString();
58 intent
.putExtra(prefArgs
, s
);
59 Launcher
.this.startActivity(intent
);
63 private void addImage (ViewGroup g
, int id
) {
64 ImageView v
= new ImageView(this);
65 v
.setImageResource(id
);
69 private void addText (ViewGroup g
, String s
) {
70 TextView v
= new TextView(this);
76 private EditText
addTextField (ViewGroup g
, String s
, TextWatcher w
) {
77 EditText v
= new EditText(this);
79 v
.addTextChangedListener(w
);
84 private void addButton (ViewGroup g
, String s
, View
.OnClickListener c
) {
85 Button v
= new Button(this);
87 v
.setOnClickListener(c
);
91 private void rebuild () {
92 LinearLayout layout
= new LinearLayout(this);
93 layout
.setOrientation(LinearLayout
.VERTICAL
);
94 // addImage(layout, R.drawable.doom2df_logo);
95 addText(layout
, "Command line:");
96 cmdline
= addTextField(layout
, loadCommandLine(), new CmdLineWatcher());
97 addButton(layout
, "Start", StartVavoomEvent
);
98 setContentView(layout
);
102 public void onCreate (Bundle savedInstanceState
) {
103 super.onCreate(savedInstanceState
);
104 requestWindowFeature(Window
.FEATURE_NO_TITLE
);