Android Open Source - SeniorDesign Options Screen






From Project

Back to project page SeniorDesign.

License

The source code is released under:

GNU General Public License

If you think the Android project SeniorDesign listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package fakesetgame.seniordesign;
/*  w w  w. ja v a 2  s  .  co m*/
import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.PreferenceFragment;

/**
 * This is the Activity class for the screen on which
 * a player may change game settings, like difficulty.
 */
public class OptionsScreen extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.options_activity);
    }

    public static class OptionsFragment extends PreferenceFragment
            implements SharedPreferences.OnSharedPreferenceChangeListener {

        ListPreference diff;
        ListPreference sparse;

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            addPreferencesFromResource(R.xml.options);
            diff = (ListPreference) findPreference(getString(R.string.optDiffKey));
            sparse = (ListPreference) findPreference(getString(R.string.optSparseKey));

            getPreferenceScreen().getSharedPreferences()
                    .registerOnSharedPreferenceChangeListener(this);
        }

        @Override
        public void onSharedPreferenceChanged(SharedPreferences sp, String key) {
            if (isAdded()) {
                // If user is selecting easy mode, reduce number of sets to find
                if (key.equals(getString(R.string.optDiffKey))) {
                    if (diff.getValue().equals(getString(R.string.optDiffLowLevelValue))) {
                        sparse.setValue(getString(R.string.optSparseLowLevelValue));
                    }
                    // If user is increasing number of sets, bump them out of easy mode
                } else if (key.equals(getString(R.string.optSparseKey))) {
                    if (!sparse.getValue().equals(getString(R.string.optSparseLowLevelValue))
                            && diff.getValue().equals(getString(R.string.optDiffLowLevelValue))) {
                        diff.setValue(getString(R.string.optDiffMidLevelValue));
                    }
                }

                ListPreference lp = (ListPreference) findPreference(key);
                lp.setSummary(lp.getEntry());
            }
        }
    }

}




Java Source Code List

fakesetgame.seniordesign.BoardTest.java
fakesetgame.seniordesign.GameScreen.java
fakesetgame.seniordesign.GameTest.java
fakesetgame.seniordesign.HomeScreen.java
fakesetgame.seniordesign.OptionsScreen.java
fakesetgame.seniordesign.SettingsTest.java
fakesetgame.seniordesign.SplashScreen.java
fakesetgame.seniordesign.SummaryScreen.java
fakesetgame.seniordesign.TileSetTest.java
fakesetgame.seniordesign.data.FoundSetRecord.java
fakesetgame.seniordesign.data.GameOutcome.java
fakesetgame.seniordesign.data.GameSummaryListItemCursorAdapter.java
fakesetgame.seniordesign.data.OptionsHelper.java
fakesetgame.seniordesign.data.PlayerDataDbHelper.java
fakesetgame.seniordesign.data.Setting.java
fakesetgame.seniordesign.data.package-info.java
fakesetgame.seniordesign.model.BoardSize.java
fakesetgame.seniordesign.model.Board.java
fakesetgame.seniordesign.model.Color.java
fakesetgame.seniordesign.model.GameOverEvent.java
fakesetgame.seniordesign.model.GameOverListener.java
fakesetgame.seniordesign.model.Game.java
fakesetgame.seniordesign.model.HintProvider.java
fakesetgame.seniordesign.model.Modifier.java
fakesetgame.seniordesign.model.Shading.java
fakesetgame.seniordesign.model.Shape.java
fakesetgame.seniordesign.model.TileSet.java
fakesetgame.seniordesign.model.Tile.java
fakesetgame.seniordesign.model.package-info.java
fakesetgame.seniordesign.view.GameSummaryListItemView.java
fakesetgame.seniordesign.view.ShadedImageView.java
fakesetgame.seniordesign.view.package-info.java
fakesetgame.seniordesign.package-info.java