Game specific settings

finished initial implmention of game specific settings. all that is left
to do is to delete settings files with games

refs #36

Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
2012-05-04 12:18:37 -04:00
parent 64921d7304
commit 49fb5a8774
4 changed files with 40 additions and 23 deletions

View File

@@ -12,21 +12,25 @@
android:summary="@string/higlight_color_msg" android:summary="@string/higlight_color_msg"
android:title="@string/higlight_color" /> android:title="@string/higlight_color" />
<PreferenceCategory android:title="@string/successes" > <PreferenceCategory
android:key="exalted"
android:title="@string/successes" >
</PreferenceCategory> </PreferenceCategory>
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="true" android:enabled="false"
android:key="tens_count_twice" android:key="tens_count_twice"
android:summary="@string/tens_count_twice_msg" android:summary="@string/tens_count_twice_msg"
android:title="@string/tens_count_twice" /> android:title="@string/tens_count_twice" />
<CheckBoxPreference <CheckBoxPreference
android:enabled="false"
android:key="ones_subtract" android:key="ones_subtract"
android:summary="@string/ones_subtract_msg" android:summary="@string/ones_subtract_msg"
android:title="@string/ones_subtract" /> android:title="@string/ones_subtract" />
<ListPreference <ListPreference
android:defaultValue="7" android:defaultValue="7"
android:enabled="false"
android:entries="@array/success_after" android:entries="@array/success_after"
android:entryValues="@array/success_after" android:entryValues="@array/success_after"
android:key="success_after" android:key="success_after"

View File

@@ -170,7 +170,15 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
Log.i(TAG, "onCreate()"); Log.i(TAG, "onCreate()");
setContentView(R.layout.main); setContentView(R.layout.main);
mSettings = getSharedPreferences(Settings.SETTINGS, Context.MODE_WORLD_WRITEABLE); Intent i = this.getIntent();
if(i != null)
if(i.hasExtra(KEY_GAME_NAME)){
mGameName = i.getStringExtra(KEY_GAME_NAME);
mGameId = i.getLongExtra(KEY_GAME_ID, -1);
this.setTitle(mGameName);
}
mSettings = getSharedPreferences(mGameName, Context.MODE_WORLD_WRITEABLE);
mDiceValues = getResources().getStringArray(R.array.dice_types); mDiceValues = getResources().getStringArray(R.array.dice_types);
mModValues = getResources().getStringArray(R.array.mods); mModValues = getResources().getStringArray(R.array.mods);
@@ -186,14 +194,6 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
} else } else
initCompatPickers(); initCompatPickers();
Intent i = this.getIntent();
if(i != null)
if(i.hasExtra(KEY_GAME_NAME)){
mGameName = i.getStringExtra(KEY_GAME_NAME);
mGameId = i.getLongExtra(KEY_GAME_ID, -1);
this.setTitle(mGameName);
}
mListView = (ListView) findViewById(R.id.list); mListView = (ListView) findViewById(R.id.list);
mListView.setOnItemClickListener(this); mListView.setOnItemClickListener(this);
mListView.setStackFromBottom(true); mListView.setStackFromBottom(true);

View File

@@ -40,7 +40,7 @@ public class RollHistoryDatabaseAdapter extends BaseAdapter {
mDb = db; mDb = db;
mInflater = LayoutInflater.from(context); mInflater = LayoutInflater.from(context);
mCount = mDb.getGameRollCount(mGameId); mCount = mDb.getGameRollCount(mGameId);
mSettings = context.getSharedPreferences(Settings.SETTINGS, Context.MODE_WORLD_WRITEABLE); mSettings = context.getSharedPreferences(mGameName, Context.MODE_WORLD_WRITEABLE);
} }
/** /**

View File

@@ -27,7 +27,6 @@ import android.view.MenuItem;
*/ */
public class Settings extends PreferenceActivity implements OnPreferenceClickListener { public class Settings extends PreferenceActivity implements OnPreferenceClickListener {
public static final String SETTINGS = "settings";
private static final CharSequence EMAIL = "email"; private static final CharSequence EMAIL = "email";
public static final String KEY_ROLL_AGAIN = "roll_again"; public static final String KEY_ROLL_AGAIN = "roll_again";
@@ -35,7 +34,7 @@ public class Settings extends PreferenceActivity implements OnPreferenceClickLis
public static final String KEY_COLOR = "color"; public static final String KEY_COLOR = "color";
public static final String KEY_ONES_SUBRACT = "ones_subtract"; public static final String KEY_ONES_SUBRACT = "ones_subtract";
public static final String KEY_SUCCESS_AFTER = "success_after"; public static final String KEY_SUCCESS_AFTER = "success_after";
// public static final String KEY_ = ""; public static final String KEY_EXALTED = "exalted";
// public static final String KEY_ = ""; // public static final String KEY_ = "";
@@ -76,25 +75,39 @@ public class Settings extends PreferenceActivity implements OnPreferenceClickLis
*/ */
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//load preferences xml. this load relies on only wether the app is full or not. it will show the check license option if full and leave it out if lite
addPreferencesFromResource(R.xml.settings);
/* /*
* The following is for api 11 and up * The following is for api 11 and up
*/ */
if(Integer.valueOf(android.os.Build.VERSION.SDK) > 11){ if(Integer.valueOf(android.os.Build.VERSION.SDK_INT) > 11){
ActionBar actionBar = getActionBar(); ActionBar actionBar = getActionBar();
if(actionBar != null) if(actionBar != null)
actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true);
} }
super.onCreate(savedInstanceState); Intent i = this.getIntent();
//set shared_prefs name if(i != null){
getPreferenceManager().setSharedPreferencesName(SETTINGS); if(i.hasExtra(ExaltedDice.KEY_GAME_NAME))
//set shared_prefs name
getPreferenceManager().setSharedPreferencesName(i.getStringExtra(ExaltedDice.KEY_GAME_NAME));
//load preferences xml. this load relies on only wether the app is full or not. it will show the check license option if full and leave it out if lite if(i.hasExtra(ExaltedDice.KEY_GAME_MODE))
addPreferencesFromResource(R.xml.settings); /*
this.findPreference(EMAIL).setOnPreferenceClickListener(this); * EXALTED
*/
if(i.getStringExtra(ExaltedDice.KEY_GAME_MODE).equals(getString(R.string.game_mode_exalted))){
this.findPreference(KEY_ONES_SUBRACT).setEnabled(true);
this.findPreference(KEY_TENS_COUNT_TWICE).setEnabled(true);
this.findPreference(KEY_SUCCESS_AFTER).setEnabled(true);
}
} }
this.findPreference(EMAIL).setOnPreferenceClickListener(this);
}
/** /**
* Called when a options item has been selected * Called when a options item has been selected
* (non-Javadoc) * (non-Javadoc)