Subversion Repositories Projects

Rev

Go to most recent revision | Details | 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;
58
    String[] menu_items = new String[]{"Connection", "Old Interface" , "View On Maps", "Flight Settings","RCData","Motor Test", "About","Quit"};
59
    int[] menu_actions= new int[]{ACTIONID_CONN , ACTIONID_OLDINTERFACE , ACTIONID_MAPS ,ACTIONID_FLIGHTSETTINGS,ACTIONID_RCDATA,ACTIONID_MOTORTEST, ACTIONID_ABOUT , ACTIONID_QUIT };
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;
68
    public final static int ACTIONID_QUIT=100;
69
 
70
    SharedPreferences settings;
71
    //    public MapView map;
72
    /** Called when the activity is first created. */
73
    @Override
74
    public void onCreate(Bundle savedInstanceState)
75
    {
76
        super.onCreate(savedInstanceState);
77
 
78
        settings = getSharedPreferences("DUBwise", 0);
79
        //      menu_items[0]=settings.getString("conn_host","--");
80
        //      mk=new MKCommunicator();        
81
        this.setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menu_items));
82
    }
83
 
84
 
85
 
86
 
87
    public void log(String msg)
88
    {
89
        Log.d("DUWISE",msg);
90
    }
91
 
92
    public void quit()
93
    {
94
        this.setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, menu_items));
95
        //      setContentView(this);
96
    }
97
 
98
@Override
99
    protected void onListItemClick(ListView l, View v, int position, long id){
100
     super.onListItemClick(l, v, position, id);
101
 
102
     // Get the item that was clicked
103
     Object o = this.getListAdapter().getItem(position);
104
     //String keyword = o.toString();
105
 
106
     // Create an VIEW intent
107
     Intent myIntent = null;
108
 
109
     try {
110
 
111
 
112
         switch(menu_actions[position])
113
             {
114
 
115
             case ACTIONID_CONN:
116
                 //              setContentView(new ConnectionView(this));
117
 
118
                 startActivity(new Intent(this, ConnectionActivity.class));
119
                 break;
120
             case ACTIONID_MOTORTEST:
121
                 //              setContentView(new ConnectionView(this));
122
                 startActivity(new Intent(this, MotorTestActivity.class));
123
 
124
                 break;
125
 
126
             case ACTIONID_RCDATA:
127
                 //              setContentView(new ConnectionView(this));
128
                 startActivity(new Intent(this, RCDataActivity.class));
129
 
130
                 break;
131
             case ACTIONID_FLIGHTSETTINGS:
132
                 //              setContentView(new ConnectionView(this));
133
                 startActivity(new Intent(this, FlightSettingsActivity.class));
134
 
135
 
136
 
137
                 /*              EditText edit_host=(EditText)findViewById( R.id.edit_host);
138
                 edit_host.setKeyListener(new NumberKeyListener(){
139
   @Override
140
   protected char[] getAcceptedChars() {
141
      char[] numberChars = {'1','2','3'};
142
      return numberChars;
143
   }
144
   });*/
145
 
146
 
147
                 //              edit_host.setText("foobar");
148
                 break;
149
             case ACTIONID_OLDINTERFACE:
150
                 mk.connect_to(settings.getString("conn_host","10.0.2.2")+":"+(settings.getString("conn_port","9876")),"unnamed");
151
                 canvas=new DUBwiseView(this);
152
                 setContentView(canvas);
153
                 break;
154
             case ACTIONID_MAPS:
155
                 //              setActivity(new DUBwiseMapActivity(this));
156
                 startActivity(new Intent(this, DUBwiseMapActivity.class));
157
 
158
 
159
                 // new AlertDialog.Builder(this).setTitle("foo").setMessage("bar").setPositiveButton("OK",null).create().show();
160
 
161
                 //              showAlert("A funny title", "MessageBoxes rule extremely!", "Hit Me!", false);
162
                 /*
163
               // The intent will open our anddev.org-board and search for the keyword clicked.
164
               myIntent = new Intent("android.intent.action.DUBWISEMAP",
165
                    Uri.parse("http://www.ligi.de/"));
166
                    startActivity(myIntent);*/
167
                 break;
168
 
169
             case ACTIONID_ABOUT:
170
                 startActivity( new Intent("android.intent.action.VIEW", Uri.parse("http://www.ligi.de/")));
171
                 break;
172
 
173
             case ACTIONID_QUIT:
174
                 finish();
175
                 break;
176
             }
177
          } catch (Exception e) {
178
               e.printStackTrace();
179
          }
180
          // Start the activity
181
 
182
    }
183
 
184
 
185
 
186
}