1 |
package dk.thoerup.traininfo;
|
2 |
|
3 |
import android.app.Activity;
|
4 |
import android.content.Intent;
|
5 |
import android.net.Uri;
|
6 |
import android.os.Bundle;
|
7 |
import android.view.View;
|
8 |
import android.view.Window;
|
9 |
import android.view.View.OnClickListener;
|
10 |
import android.widget.Button;
|
11 |
|
12 |
import com.nullwire.trace.ExceptionHandler;
|
13 |
|
14 |
import dk.thoerup.checkupdates.CheckUpdates;
|
15 |
|
16 |
public class WelcomeScreen extends Activity{
|
17 |
public enum ListType {
|
18 |
ListNearest,
|
19 |
ListSearch,
|
20 |
ListFavorites
|
21 |
}
|
22 |
|
23 |
@Override
|
24 |
public void onCreate(Bundle savedInstanceState) {
|
25 |
requestWindowFeature( Window.FEATURE_NO_TITLE );
|
26 |
super.onCreate(savedInstanceState);
|
27 |
setContentView(R.layout.welcome);
|
28 |
|
29 |
Button nearestButton = (Button) findViewById(R.id.nearest);
|
30 |
nearestButton.setOnClickListener( new StationListListener(ListType.ListNearest));
|
31 |
|
32 |
Button searchButton = (Button) findViewById(R.id.search);
|
33 |
searchButton.setOnClickListener( new StationListListener(ListType.ListSearch));
|
34 |
|
35 |
Button favoritesButton = (Button) findViewById(R.id.favorites);
|
36 |
favoritesButton.setOnClickListener( new StationListListener(ListType.ListFavorites));
|
37 |
|
38 |
Button aboutButton = (Button) findViewById(R.id.about);
|
39 |
aboutButton.setOnClickListener( new AboutListener() );
|
40 |
|
41 |
ExceptionHandler.register(this, "http://t-hoerup.dk/android/trace.php");
|
42 |
|
43 |
CheckUpdates update = new CheckUpdates();
|
44 |
update.checkForUpdates(this, "http://t-hoerup.dk/android/traininfo/version.txt", "TrainInfo DK");
|
45 |
}
|
46 |
|
47 |
class AboutListener implements OnClickListener {
|
48 |
|
49 |
@Override
|
50 |
public void onClick(View v) {
|
51 |
/*
|
52 |
String appName = WelcomeScreen.this.getResources().getString(R.string.app_name);
|
53 |
String ver = WelcomeScreen.this.getResources().getString(R.string.app_version);
|
54 |
|
55 |
StringBuffer message = new StringBuffer();
|
56 |
message.append(appName);
|
57 |
message.append(" v").append(ver).append("\n");
|
58 |
message.append("By Torben H. Nielsen\n");
|
59 |
|
60 |
MessageBox.showMessage(WelcomeScreen.this, message.toString());*/
|
61 |
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.t-hoerup.dk/android/traininfo/"));
|
62 |
startActivity(browserIntent);
|
63 |
}
|
64 |
|
65 |
}
|
66 |
|
67 |
class StationListListener implements OnClickListener{
|
68 |
ListType launchType;
|
69 |
StationListListener(ListType type) {
|
70 |
launchType = type;
|
71 |
}
|
72 |
|
73 |
@Override
|
74 |
public void onClick(View v) {
|
75 |
Intent intent = new Intent(WelcomeScreen.this, StationList.class);
|
76 |
intent.putExtra("type", launchType);
|
77 |
WelcomeScreen.this.startActivity(intent);
|
78 |
}
|
79 |
|
80 |
}
|
81 |
}
|