Subversion Repositories Projects

Rev

Rev 212 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
212 ligi 1
 
2
package org.ligi.android;
3
 
4
import android.app.ListActivity;
5
import android.content.Intent;
6
import android.content.pm.PackageManager;
7
import android.content.pm.ResolveInfo;
8
import android.os.Bundle;
9
import android.view.View;
10
import android.widget.ListView;
11
import android.widget.SimpleAdapter;
12
 
13
 
14
import android.util.Log;
15
 
16
import android.app.Activity;
17
import android.os.Bundle;
18
 
19
 
20
import android.view.View;
21
import android.widget.ListView;
22
import android.widget.SimpleAdapter;
23
 
24
import java.text.Collator;
25
import java.util.ArrayList;
26
import java.util.Collections;
27
import java.util.Comparator;
28
import java.util.HashMap;
29
import java.util.List;
30
import java.util.Map;
31
import android.net.Uri;
32
 
33
import java.net.URISyntaxException;
34
import android.widget.ArrayAdapter;
35
import android.content.DialogInterface;
36
import android.content.Context.*;
37
import android.widget.EditText;
38
import android.text.method.NumberKeyListener;
39
 
40
 
41
import com.google.android.maps.MapView;
42
 
43
import          android.app.AlertDialog.*;
44
import          android.app.AlertDialog;
45
 
46
import android.content.SharedPreferences;
47
 
48
import org.ligi.ufo.*;
49
 
50
public class DUBwise extends ListActivity
51
{
52
 
53
 
54
    DUBwiseView canvas;
55
    boolean do_sound;
56
    boolean fullscreen;
57
    MKCommunicator mk;
219 ligi 58
    String[] menu_items = new String[]{"Settings","Connection", "Old Interface" , "View On Maps", "Flight Settings","RCData","Motor Test", "About","Quit"};
59
    int[] menu_actions= new int[]{ACTIONID_SETTINGS,ACTIONID_CONN , ACTIONID_OLDINTERFACE , ACTIONID_MAPS ,ACTIONID_FLIGHTSETTINGS,ACTIONID_RCDATA,ACTIONID_MOTORTEST, ACTIONID_ABOUT , ACTIONID_QUIT };
212 ligi 60
 
61
    public final static int ACTIONID_CONN=0;
62
    public final static int ACTIONID_MAPS=1;
63
    public final static int ACTIONID_ABOUT=2;
64
    public final static int ACTIONID_OLDINTERFACE=3;
65
    public final static int ACTIONID_FLIGHTSETTINGS=4;
66
    public final static int ACTIONID_MOTORTEST=5;
67
    public final static int ACTIONID_RCDATA=6;
219 ligi 68
    public final static int ACTIONID_SETTINGS=7;
212 ligi 69
    public final static int ACTIONID_QUIT=100;
70
 
71
    SharedPreferences settings;
72
    //    public MapView map;
73
    /** Called when the activity is first created. */
74
    @Override
75
    public void onCreate(Bundle savedInstanceState)
76
    {
77
        super.onCreate(savedInstanceState);
78
 
79
        settings = getSharedPreferences("DUBwise", 0);
80
        //      menu_items[0]=settings.getString("conn_host","--");
81
        //      mk=new MKCommunicator();        
82
        this.setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menu_items));
83
    }
84
 
85
 
86
 
87
 
88
    public void log(String msg)
89
    {
90
        Log.d("DUWISE",msg);
91
    }
92
 
93
    public void quit()
94
    {
95
        this.setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menu_items));
96
        //      setContentView(this);
97
    }
98
 
99
@Override
100
    protected void onListItemClick(ListView l, View v, int position, long id){
101
     super.onListItemClick(l, v, position, id);
102
 
103
     // Get the item that was clicked
104
     Object o = this.getListAdapter().getItem(position);
105
     //String keyword = o.toString();
106
 
107
     // Create an VIEW intent
108
     Intent myIntent = null;
109
 
110
     try {
111
 
112
 
113
         switch(menu_actions[position])
114
             {
115
 
219 ligi 116
             case ACTIONID_SETTINGS:
117
                 //              setContentView(new ConnectionView(this));
118
 
119
                 startActivity(new Intent(this, SettingsActivity.class));
120
                 break;
121
 
212 ligi 122
             case ACTIONID_CONN:
123
                 //              setContentView(new ConnectionView(this));
124
 
125
                 startActivity(new Intent(this, ConnectionActivity.class));
126
                 break;
127
             case ACTIONID_MOTORTEST:
128
                 //              setContentView(new ConnectionView(this));
129
                 startActivity(new Intent(this, MotorTestActivity.class));
130
 
131
                 break;
132
 
133
             case ACTIONID_RCDATA:
134
                 //              setContentView(new ConnectionView(this));
135
                 startActivity(new Intent(this, RCDataActivity.class));
136
 
137
                 break;
138
             case ACTIONID_FLIGHTSETTINGS:
139
                 //              setContentView(new ConnectionView(this));
140
                 startActivity(new Intent(this, FlightSettingsActivity.class));
141
 
142
 
143
 
144
                 /*              EditText edit_host=(EditText)findViewById( R.id.edit_host);
145
                 edit_host.setKeyListener(new NumberKeyListener(){
146
   @Override
147
   protected char[] getAcceptedChars() {
148
      char[] numberChars = {'1','2','3'};
149
      return numberChars;
150
   }
151
   });*/
152
 
153
 
154
                 //              edit_host.setText("foobar");
155
                 break;
156
             case ACTIONID_OLDINTERFACE:
157
                 mk.connect_to(settings.getString("conn_host","10.0.2.2")+":"+(settings.getString("conn_port","9876")),"unnamed");
158
                 canvas=new DUBwiseView(this);
159
                 setContentView(canvas);
160
                 break;
161
             case ACTIONID_MAPS:
162
                 //              setActivity(new DUBwiseMapActivity(this));
163
                 startActivity(new Intent(this, DUBwiseMapActivity.class));
164
 
165
 
166
                 // new AlertDialog.Builder(this).setTitle("foo").setMessage("bar").setPositiveButton("OK",null).create().show();
167
 
168
                 //              showAlert("A funny title", "MessageBoxes rule extremely!", "Hit Me!", false);
169
                 /*
170
               // The intent will open our anddev.org-board and search for the keyword clicked.
171
               myIntent = new Intent("android.intent.action.DUBWISEMAP",
172
                    Uri.parse("http://www.ligi.de/"));
173
                    startActivity(myIntent);*/
174
                 break;
175
 
176
             case ACTIONID_ABOUT:
177
                 startActivity( new Intent("android.intent.action.VIEW", Uri.parse("http://www.ligi.de/")));
178
                 break;
179
 
180
             case ACTIONID_QUIT:
181
                 finish();
182
                 break;
183
             }
184
          } catch (Exception e) {
185
               e.printStackTrace();
186
          }
187
          // Start the activity
188
 
189
    }
190
 
191
 
192
 
193
}