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:
@@ -12,21 +12,25 @@
|
||||
android:summary="@string/higlight_color_msg"
|
||||
android:title="@string/higlight_color" />
|
||||
|
||||
<PreferenceCategory android:title="@string/successes" >
|
||||
<PreferenceCategory
|
||||
android:key="exalted"
|
||||
android:title="@string/successes" >
|
||||
</PreferenceCategory>
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:enabled="false"
|
||||
android:key="tens_count_twice"
|
||||
android:summary="@string/tens_count_twice_msg"
|
||||
android:title="@string/tens_count_twice" />
|
||||
<CheckBoxPreference
|
||||
android:enabled="false"
|
||||
android:key="ones_subtract"
|
||||
android:summary="@string/ones_subtract_msg"
|
||||
android:title="@string/ones_subtract" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="7"
|
||||
android:enabled="false"
|
||||
android:entries="@array/success_after"
|
||||
android:entryValues="@array/success_after"
|
||||
android:key="success_after"
|
||||
|
||||
@@ -170,7 +170,15 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
Log.i(TAG, "onCreate()");
|
||||
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);
|
||||
mModValues = getResources().getStringArray(R.array.mods);
|
||||
@@ -186,14 +194,6 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
||||
} else
|
||||
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.setOnItemClickListener(this);
|
||||
mListView.setStackFromBottom(true);
|
||||
|
||||
@@ -40,7 +40,7 @@ public class RollHistoryDatabaseAdapter extends BaseAdapter {
|
||||
mDb = db;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mCount = mDb.getGameRollCount(mGameId);
|
||||
mSettings = context.getSharedPreferences(Settings.SETTINGS, Context.MODE_WORLD_WRITEABLE);
|
||||
mSettings = context.getSharedPreferences(mGameName, Context.MODE_WORLD_WRITEABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,7 +27,6 @@ import android.view.MenuItem;
|
||||
*/
|
||||
public class Settings extends PreferenceActivity implements OnPreferenceClickListener {
|
||||
|
||||
public static final String SETTINGS = "settings";
|
||||
private static final CharSequence EMAIL = "email";
|
||||
|
||||
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_ONES_SUBRACT = "ones_subtract";
|
||||
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_ = "";
|
||||
|
||||
|
||||
@@ -76,25 +75,39 @@ public class Settings extends PreferenceActivity implements OnPreferenceClickLis
|
||||
*/
|
||||
@Override
|
||||
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
|
||||
*/
|
||||
if(Integer.valueOf(android.os.Build.VERSION.SDK) > 11){
|
||||
if(Integer.valueOf(android.os.Build.VERSION.SDK_INT) > 11){
|
||||
ActionBar actionBar = getActionBar();
|
||||
if(actionBar != null)
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
//set shared_prefs name
|
||||
getPreferenceManager().setSharedPreferencesName(SETTINGS);
|
||||
Intent i = this.getIntent();
|
||||
if(i != null){
|
||||
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
|
||||
addPreferencesFromResource(R.xml.settings);
|
||||
this.findPreference(EMAIL).setOnPreferenceClickListener(this);
|
||||
if(i.hasExtra(ExaltedDice.KEY_GAME_MODE))
|
||||
/*
|
||||
* 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
|
||||
* (non-Javadoc)
|
||||
|
||||
Reference in New Issue
Block a user