--- android/TrainInfo/src/dk/thoerup/traininfo/WelcomeScreen.java 2009/10/29 10:49:14 483 +++ android/TrainInfo/src/dk/thoerup/traininfo/WelcomeScreen.java 2011/05/04 20:25:15 1446 @@ -1,14 +1,21 @@ package dk.thoerup.traininfo; -import dk.thoerup.traininfo.util.MessageBox; import android.app.Activity; import android.content.Intent; +import android.net.Uri; import android.os.Bundle; +import android.os.Handler; +import android.util.Log; import android.view.View; import android.view.Window; import android.view.View.OnClickListener; import android.widget.Button; +import com.nullwire.trace.ExceptionHandler; + +import dk.thoerup.androidutils.CheckUpdates; +import dk.thoerup.traininfo.provider.ProviderFactory; + public class WelcomeScreen extends Activity{ public enum ListType { ListNearest, @@ -16,10 +23,13 @@ ListFavorites } + Handler handler = new Handler(); + @Override public void onCreate(Bundle savedInstanceState) { - requestWindowFeature( Window.FEATURE_NO_TITLE ); + super.onCreate(savedInstanceState); + requestWindowFeature( Window.FEATURE_NO_TITLE ); setContentView(R.layout.welcome); Button nearestButton = (Button) findViewById(R.id.nearest); @@ -31,24 +41,67 @@ Button favoritesButton = (Button) findViewById(R.id.favorites); favoritesButton.setOnClickListener( new StationListListener(ListType.ListFavorites)); + Button settingsButton = (Button) findViewById(R.id.settings); + settingsButton.setOnClickListener( new SettingsListener() ); + Button aboutButton = (Button) findViewById(R.id.about); aboutButton.setOnClickListener( new AboutListener() ); + + ExceptionHandler.register(this, "http://t-hoerup.dk/android/trace.php"); + + CheckUpdates update = new CheckUpdates(); + update.checkForUpdates(this, "http://t-hoerup.dk/android/traininfo/version.txt", "TrainInfo DK", null); + /* + Runnable r = new Runnable() { + @Override + public void run() { + View splash = findViewById(R.id.splash); + splash.setVisibility(View.GONE); + } + }; + handler.postDelayed(r, 1500); + */ } + + + @Override + protected void onDestroy() { + super.onDestroy(); + ProviderFactory.purgeOldEntries(); //exiting application, do some cleanup + } + + + + class AboutListener implements OnClickListener { @Override public void onClick(View v) { - - String ver = WelcomeScreen.this.getResources().getString(R.string.app_version); + /* + String appName = WelcomeScreen.this.getResources().getString(R.string.app_name); + String ver = WelcomeScreen.this.getResources().getString(R.string.app_version); + StringBuffer message = new StringBuffer(); - message.append("TrainInfo DK v").append(ver).append("\n"); + message.append(appName); + message.append(" v").append(ver).append("\n"); message.append("By Torben H. Nielsen\n"); - MessageBox.showMessage(WelcomeScreen.this, message.toString()); + MessageBox.showMessage(WelcomeScreen.this, message.toString());*/ + Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://t-hoerup.dk/android/traininfo/")); + startActivity(browserIntent); } } + + class SettingsListener implements OnClickListener{ + + @Override + public void onClick(View v) { + Intent intent = new Intent(WelcomeScreen.this, SettingsScreen.class); + WelcomeScreen.this.startActivity(intent); + } + } class StationListListener implements OnClickListener{ ListType launchType;