Subversion Repositories Projects

Rev

Rev 212 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
212 ligi 1
package org.ligi.android;
2
import android.os.Bundle;
3
import com.google.android.maps.*;
4
 
5
import android.content.Context;
6
import android.graphics.Paint;
7
import android.util.AttributeSet;
8
import java.util.Map;
9
import android.view.Menu;
10
import android.view.MenuItem;
11
 
12
import android.view.*;
13
import android.content.SharedPreferences;
14
 
15
public class DUBwiseMapActivity extends MapActivity implements Runnable,MapKey
16
{
17
 
18
    //MapView mMapView; 
19
 
20
 
21
    MapView     map;
22
    MapController mc ;
23
 @Override
24
     public boolean onCreateOptionsMenu(Menu menu) {
25
          boolean supRetVal = super.onCreateOptionsMenu(menu);
26
 
27
          menu.add(0, 0,0, getString(R.string.map_menu_zoom_in));
28
          menu.add(0, 1,0, getString(R.string.map_menu_zoom_out));
29
          menu.add(0, 2,0, getString(R.string.map_menu_toggle_street_satellite));
30
          menu.add(0, 3,0, R.string.map_menu_back_to_list);
31
          return supRetVal;
32
     }
33
 
34
 
35
 
36
 
37
 @Override
38
     public boolean onOptionsItemSelected(MenuItem item){
39
         switch (item.getItemId()) {
40
              case 0:
41
               // Zoom not closer than possible
42
                   this.mc.setZoom(Math.min(21, map.getZoomLevel() + 1));
43
                  //              map.displayZoomControls(true);
44
                  return true;
45
              case 1:
46
               // Zoom not farer than possible
47
                  this.mc.setZoom(Math.max(1, map.getZoomLevel() - 1));
48
                  return true;
49
              case 2:
50
               // Switch to satellite view
51
                  map.setSatellite(!map.isSatellite());
52
                  return true;
53
              case 3:
54
               this.finish();
55
                  return true;
56
         }
57
         return false;
58
     }
59
 
60
 
61
    AndroidMKCommunicator mk;
62
 
63
 
64
    public void run()
65
    {
66
        /*
67
        int i=0;
68
        while(true)
69
            {
70
                try {
71
 
72
 
73
                this.setTitle("UBATT:no");
74
                    this.setTitle("UBATT:" + mk.UBatt() + " stats:" + mk.stats.debug_data_count + "--" + i);
75
                    i++;
76
                    //              Thread.sleep(1000);
77
 
78
                    this.setTitle("UBATT2:" + mk.UBatt() + " stats:" + mk.stats.debug_data_count + "--" + i);
79
 
80
                }
81
 
82
                catch (Exception e)
83
                    {
84
                                    this.setTitle(e.toString());
85
}
86
            }
87
 
88
*/
89
    }
90
 
91
   @Override
92
       public boolean onKeyDown(int keyCode, KeyEvent event)
93
    {
94
 
95
        this.setTitle("UBATT2:" + mk.UBatt() + " stats:" + mk.stats.version_data_count + "--" );
96
        return true;
97
    }
98
 
99
   @Override
100
    public void onCreate(Bundle savedInstanceState) {
101
        super.onCreate(savedInstanceState);
102
 
103
        map=new MapView(this,MapKey);
104
        map.setClickable(true);
105
 
106
 
107
        //////////////////////////////////////////////////////////////////////////////this.overlay = this.map.createOverlayController(); 
108
 
109
 
110
 
111
        mc = map.getController();
112
        //mc.setZoom(20);
113
        setContentView(map);
114
 
115
 
116
        mk=new AndroidMKCommunicator(this
117
                                );
118
 
119
 
120
        //      this.setTitle("test");
121
        //
122
        new Thread( this ).start(); // fire up main Thread      
123
   }
124
 
125
   @Override
126
    protected void onDestroy()
127
    {
128
        mk.close_connections(true);
129
        mk=null;
130
        super.onDestroy();
131
 
132
    }
133
 
134
        @Override
135
        protected boolean isRouteDisplayed() {
136
                return false;
137
        }
138
 
139
 
140
 
141
}