]> Pileus Git - ~andy/spades/blobdiff - src/org/pileus/spades/Main.java
Change Exit to Quit and return to home screen
[~andy/spades] / src / org / pileus / spades / Main.java
index 56691e403306cd11426593676d7deae4468996f8..568d617afe0f1121d3699447dfb464a205d8d142 100644 (file)
@@ -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;