1 |
torben |
481 |
package dk.thoerup.traininfo;
|
2 |
|
|
|
3 |
|
|
import android.app.Activity;
|
4 |
|
|
import android.content.Intent;
|
5 |
torben |
500 |
import android.net.Uri;
|
6 |
torben |
481 |
import android.os.Bundle;
|
7 |
torben |
743 |
import android.os.Handler;
|
8 |
torben |
1159 |
import android.util.Log;
|
9 |
torben |
481 |
import android.view.View;
|
10 |
torben |
482 |
import android.view.Window;
|
11 |
torben |
481 |
import android.view.View.OnClickListener;
|
12 |
|
|
import android.widget.Button;
|
13 |
|
|
|
14 |
torben |
720 |
import com.nullwire.trace.ExceptionHandler;
|
15 |
|
|
|
16 |
torben |
1131 |
import dk.thoerup.androidutils.CheckUpdates;
|
17 |
torben |
1159 |
import dk.thoerup.traininfo.provider.ProviderFactory;
|
18 |
torben |
720 |
|
19 |
torben |
481 |
public class WelcomeScreen extends Activity{
|
20 |
|
|
public enum ListType {
|
21 |
|
|
ListNearest,
|
22 |
|
|
ListSearch,
|
23 |
|
|
ListFavorites
|
24 |
|
|
}
|
25 |
|
|
|
26 |
torben |
743 |
Handler handler = new Handler();
|
27 |
|
|
|
28 |
torben |
481 |
@Override
|
29 |
|
|
public void onCreate(Bundle savedInstanceState) {
|
30 |
torben |
916 |
|
31 |
|
|
super.onCreate(savedInstanceState);
|
32 |
torben |
482 |
requestWindowFeature( Window.FEATURE_NO_TITLE );
|
33 |
torben |
481 |
setContentView(R.layout.welcome);
|
34 |
|
|
|
35 |
|
|
Button nearestButton = (Button) findViewById(R.id.nearest);
|
36 |
|
|
nearestButton.setOnClickListener( new StationListListener(ListType.ListNearest));
|
37 |
|
|
|
38 |
|
|
Button searchButton = (Button) findViewById(R.id.search);
|
39 |
|
|
searchButton.setOnClickListener( new StationListListener(ListType.ListSearch));
|
40 |
|
|
|
41 |
|
|
Button favoritesButton = (Button) findViewById(R.id.favorites);
|
42 |
|
|
favoritesButton.setOnClickListener( new StationListListener(ListType.ListFavorites));
|
43 |
|
|
|
44 |
torben |
1446 |
Button settingsButton = (Button) findViewById(R.id.settings);
|
45 |
|
|
settingsButton.setOnClickListener( new SettingsListener() );
|
46 |
|
|
|
47 |
torben |
481 |
Button aboutButton = (Button) findViewById(R.id.about);
|
48 |
|
|
aboutButton.setOnClickListener( new AboutListener() );
|
49 |
torben |
568 |
|
50 |
|
|
ExceptionHandler.register(this, "http://t-hoerup.dk/android/trace.php");
|
51 |
torben |
720 |
|
52 |
|
|
CheckUpdates update = new CheckUpdates();
|
53 |
torben |
911 |
update.checkForUpdates(this, "http://t-hoerup.dk/android/traininfo/version.txt", "TrainInfo DK", null);
|
54 |
torben |
846 |
/*
|
55 |
torben |
743 |
Runnable r = new Runnable() {
|
56 |
|
|
@Override
|
57 |
|
|
public void run() {
|
58 |
|
|
View splash = findViewById(R.id.splash);
|
59 |
|
|
splash.setVisibility(View.GONE);
|
60 |
|
|
}
|
61 |
|
|
};
|
62 |
|
|
handler.postDelayed(r, 1500);
|
63 |
torben |
846 |
*/
|
64 |
torben |
481 |
}
|
65 |
torben |
1159 |
|
66 |
|
|
|
67 |
torben |
743 |
|
68 |
torben |
1159 |
@Override
|
69 |
|
|
protected void onDestroy() {
|
70 |
|
|
super.onDestroy();
|
71 |
|
|
ProviderFactory.purgeOldEntries(); //exiting application, do some cleanup
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
torben |
481 |
class AboutListener implements OnClickListener {
|
78 |
|
|
|
79 |
|
|
@Override
|
80 |
|
|
public void onClick(View v) {
|
81 |
torben |
500 |
/*
|
82 |
torben |
484 |
String appName = WelcomeScreen.this.getResources().getString(R.string.app_name);
|
83 |
|
|
String ver = WelcomeScreen.this.getResources().getString(R.string.app_version);
|
84 |
|
|
|
85 |
torben |
483 |
StringBuffer message = new StringBuffer();
|
86 |
torben |
484 |
message.append(appName);
|
87 |
|
|
message.append(" v").append(ver).append("\n");
|
88 |
torben |
483 |
message.append("By Torben H. Nielsen\n");
|
89 |
|
|
|
90 |
torben |
500 |
MessageBox.showMessage(WelcomeScreen.this, message.toString());*/
|
91 |
torben |
1393 |
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://t-hoerup.dk/android/traininfo/"));
|
92 |
torben |
500 |
startActivity(browserIntent);
|
93 |
torben |
481 |
}
|
94 |
torben |
483 |
|
95 |
torben |
481 |
}
|
96 |
torben |
1446 |
|
97 |
|
|
class SettingsListener implements OnClickListener{
|
98 |
|
|
|
99 |
|
|
@Override
|
100 |
|
|
public void onClick(View v) {
|
101 |
|
|
Intent intent = new Intent(WelcomeScreen.this, SettingsScreen.class);
|
102 |
|
|
WelcomeScreen.this.startActivity(intent);
|
103 |
|
|
}
|
104 |
|
|
}
|
105 |
torben |
483 |
|
106 |
torben |
481 |
class StationListListener implements OnClickListener{
|
107 |
|
|
ListType launchType;
|
108 |
|
|
StationListListener(ListType type) {
|
109 |
|
|
launchType = type;
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
@Override
|
113 |
|
|
public void onClick(View v) {
|
114 |
|
|
Intent intent = new Intent(WelcomeScreen.this, StationList.class);
|
115 |
|
|
intent.putExtra("type", launchType);
|
116 |
|
|
WelcomeScreen.this.startActivity(intent);
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
}
|
120 |
|
|
}
|