X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=src%2Forg%2Fpileus%2Fspades%2FMain.java;h=568d617afe0f1121d3699447dfb464a205d8d142;hb=0faf3ef54ec1c06b23dc5c5a9bf0912e9e7b4395;hp=56691e403306cd11426593676d7deae4468996f8;hpb=81697889e9eb195779cf2f0126b05dcfa7b8672a;p=~andy%2Fspades diff --git a/src/org/pileus/spades/Main.java b/src/org/pileus/spades/Main.java index 56691e4..568d617 100644 --- a/src/org/pileus/spades/Main.java +++ b/src/org/pileus/spades/Main.java @@ -5,6 +5,7 @@ import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.Messenger; +import android.preference.PreferenceManager; import android.text.Html; import android.text.method.ScrollingMovementMethod; import android.text.format.DateFormat; @@ -192,9 +193,13 @@ public class Main extends Activity .putExtra("Command", Task.DISCONNECT)); } - private void exit() + private void quit() { stopService(new Intent(this, Task.class)); + Intent intent = new Intent(Intent.ACTION_MAIN); + intent.addCategory(Intent.CATEGORY_HOME); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); } /* Widget callback functions */ @@ -217,6 +222,9 @@ public class Main extends Activity super.onCreate(savedInstanceState); Os.debug("Main: onCreate"); + // Setup preferences + PreferenceManager.setDefaultValues(this, R.xml.prefs, false); + // Setup main layout this.setContentView(R.layout.main); @@ -257,14 +265,16 @@ public class Main extends Activity .setContent(R.id.debug)); // Setup Spades game and cards view - this.game = new Spades(); + this.game = new Spades(PreferenceManager + .getDefaultSharedPreferences(this) + .getString("pref_referee", "rhawk")); this.cards = new Cards(this); this.game.cards = this.cards; this.cards.game = this.game; this.spades.addView(cards); - + // Attach to background service this.register(); @@ -345,9 +355,8 @@ public class Main extends Activity case R.id.settings: this.startActivity(new Intent(this, Prefs.class)); return true; - case R.id.exit: - this.exit(); - this.finish(); + case R.id.quit: + this.quit(); return true; default: return false;