X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/FreeShisen/blobdiff_plain/d0e04237b00df7c11616f359200255a8b47e79d7..29a0130122c0a33e33b12cfff5bc89e18168b738:/src/de/cwde/shisensho/ShisenSho.java diff --git a/src/de/cwde/shisensho/ShisenSho.java b/src/de/cwde/shisensho/ShisenSho.java index 8fe7d30..00f959e 100644 --- a/src/de/cwde/shisensho/ShisenSho.java +++ b/src/de/cwde/shisensho/ShisenSho.java @@ -1,7 +1,8 @@ package de.cwde.shisensho; import android.app.Application; -import android.os.Bundle; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; import android.util.Log; public class ShisenSho extends Application { @@ -11,7 +12,7 @@ public class ShisenSho extends Application { public Board board; public int[] boardSize=new int[2]; - public int difficulty=1; // 1=Hard, 2=Easy + public int difficulty=1; // 1=Easy, 2=Hard public int size=3; // 1=Small, 2=Medium, 3=Big public boolean gravity=true; public boolean timeCounter=true; @@ -67,25 +68,20 @@ public class ShisenSho extends Application { } /** Called when the activity is first created. */ - @Override - public void onCreate() { - super.onCreate(); - } - - public Bundle getOptions() { - Bundle options = new Bundle(); - options.putInt("size", size); - options.putInt("difficulty", difficulty); - options.putBoolean("gravity", gravity); - options.putBoolean("timeCounter", timeCounter); - return options; + @Override + public void onCreate() { + super.onCreate(); + PreferenceManager.setDefaultValues(this, R.xml.preferences, false); + setOptions(); } - public void setOptions(Bundle options) { - int size = options.getInt("size"); - int difficulty = options.getInt("difficulty"); - boolean gravity = options.getBoolean("gravity"); - boolean timeCounter = options.getBoolean("timeCounter"); + public void setOptions() { + SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); + + int size = sharedPref.getInt("size", 1); + int difficulty = sharedPref.getInt("difficulty", 1); + boolean gravity = sharedPref.getBoolean("gravity", true); + boolean timeCounter = sharedPref.getBoolean("timeCounter", true); boolean needsReset = false; @@ -109,7 +105,7 @@ public class ShisenSho extends Application { view.onTimeCounterActivate(); } - if (needsReset) { + if (needsReset && (view != null)) { view.reset(); } }