1 |
package dk.thoerup.traininfo; |
package dk.thoerup.traininfo; |
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
import java.util.ArrayList; |
6 |
|
|
7 |
import android.app.Activity; |
import android.app.Activity; |
8 |
import android.app.ProgressDialog; |
import android.app.ProgressDialog; |
9 |
import android.content.Intent; |
import android.content.Intent; |
10 |
import android.content.SharedPreferences; |
import android.content.SharedPreferences; |
11 |
import android.content.SharedPreferences.Editor; |
import android.content.SharedPreferences.Editor; |
12 |
|
import android.location.Location; |
13 |
import android.net.Uri; |
import android.net.Uri; |
14 |
import android.os.AsyncTask; |
import android.os.AsyncTask; |
15 |
import android.os.Bundle; |
import android.os.Bundle; |
16 |
import android.os.Handler; |
import android.os.Handler; |
17 |
import android.util.Log; |
import android.util.Log; |
18 |
|
import android.view.Menu; |
19 |
|
import android.view.MenuItem; |
20 |
import android.view.View; |
import android.view.View; |
21 |
import android.view.View.OnClickListener; |
import android.view.View.OnClickListener; |
22 |
import android.view.Window; |
import android.view.Window; |
25 |
|
|
26 |
import com.nullwire.trace.ExceptionHandler; |
import com.nullwire.trace.ExceptionHandler; |
27 |
|
|
28 |
|
import dk.thoerup.android.traininfo.common.StationEntry; |
29 |
import dk.thoerup.androidutils.CheckUpdates; |
import dk.thoerup.androidutils.CheckUpdates; |
30 |
import dk.thoerup.traininfo.provider.OfflineStationProvider; |
import dk.thoerup.traininfo.provider.OfflineStationProvider; |
31 |
import dk.thoerup.traininfo.provider.ProviderFactory; |
import dk.thoerup.traininfo.provider.ProviderFactory; |
32 |
import dk.thoerup.traininfo.provider.StationProvider; |
import dk.thoerup.traininfo.provider.StationProvider; |
33 |
|
import dk.thoerup.traininfo.stationmap.GeoPair; |
34 |
|
import dk.thoerup.traininfo.stationmap.StationMapView; |
35 |
|
import dk.thoerup.traininfo.util.MessageBox; |
36 |
|
|
37 |
public class WelcomeScreen extends Activity{ |
public class WelcomeScreen extends Activity{ |
38 |
|
|
39 |
final static String stationsreload = "stationsreload"; |
final static String stationsreload = "stationsreload"; |
40 |
|
final static int MENU_SETTINGS = 1; |
41 |
|
final static int MENU_RELOAD = 2; |
42 |
|
|
43 |
|
|
44 |
public enum ListType { |
public enum ListType { |
45 |
ListNearest, |
ListNearest, |
70 |
Button favoritesButton = (Button) findViewById(R.id.favorites); |
Button favoritesButton = (Button) findViewById(R.id.favorites); |
71 |
favoritesButton.setOnClickListener( new StationListListener(ListType.ListFavorites)); |
favoritesButton.setOnClickListener( new StationListListener(ListType.ListFavorites)); |
72 |
|
|
|
Button settingsButton = (Button) findViewById(R.id.settings); |
|
|
settingsButton.setOnClickListener( new SettingsListener() ); |
|
|
|
|
73 |
Button aboutButton = (Button) findViewById(R.id.about); |
Button aboutButton = (Button) findViewById(R.id.about); |
74 |
aboutButton.setOnClickListener( new AboutListener() ); |
aboutButton.setOnClickListener( new AboutListener() ); |
75 |
|
|
123 |
} |
} |
124 |
|
|
125 |
|
|
126 |
|
@Override |
127 |
|
public boolean onCreateOptionsMenu(Menu menu) { |
128 |
|
MenuItem item; |
129 |
|
|
130 |
|
item = menu.add(0, MENU_SETTINGS, 0, getString(R.string.welcome_settings) ); |
131 |
|
item.setIcon(android.R.drawable.ic_menu_preferences); |
132 |
|
|
133 |
|
item = menu.add(0, MENU_RELOAD, 0, getString(R.string.welcome_reloadstations)); |
134 |
|
item.setIcon(android.R.drawable.ic_menu_rotate); |
135 |
|
|
136 |
|
return true; |
137 |
|
} |
138 |
|
|
139 |
|
@Override |
140 |
|
public boolean onOptionsItemSelected(MenuItem item) { |
141 |
|
boolean retval = true; |
142 |
|
|
143 |
|
switch (item.getItemId()) { |
144 |
|
case MENU_SETTINGS: |
145 |
|
Intent intent = new Intent(WelcomeScreen.this, SettingsScreen.class); |
146 |
|
WelcomeScreen.this.startActivity(intent); |
147 |
|
break; |
148 |
|
|
149 |
|
case MENU_RELOAD: |
150 |
|
OfflineStationProvider osp = (OfflineStationProvider) ProviderFactory.getStationProvider(); |
151 |
|
new StationLoader(osp).execute( (Void)null); |
152 |
|
break; |
153 |
|
|
154 |
|
default: |
155 |
|
retval = super.onOptionsItemSelected(item); |
156 |
|
} |
157 |
|
|
158 |
|
return retval; |
159 |
|
} |
160 |
|
|
161 |
|
|
162 |
class AboutListener implements OnClickListener { |
class AboutListener implements OnClickListener { |
163 |
|
|
179 |
|
|
180 |
} |
} |
181 |
|
|
|
class SettingsListener implements OnClickListener{ |
|
|
|
|
|
@Override |
|
|
public void onClick(View v) { |
|
|
Intent intent = new Intent(WelcomeScreen.this, SettingsScreen.class); |
|
|
WelcomeScreen.this.startActivity(intent); |
|
|
} |
|
|
} |
|
182 |
|
|
183 |
class StationListListener implements OnClickListener{ |
class StationListListener implements OnClickListener{ |
184 |
ListType launchType; |
ListType launchType; |