Android Open Source - sudoku Settings






From Project

Back to project page sudoku.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project sudoku 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 com.hao.apps.sudoku;
//  www  . j  a  v a 2s  . co m
import com.hao.apps.sudoku.R;

import android.content.Context;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.preference.Preference.OnPreferenceChangeListener;


public class Settings extends PreferenceActivity {
  private ListPreference lp = null;
  private static final String MUSIC_OPTION = "music";
  private static final boolean MUSIC_OPTION_DEFAULT = true;
  private static final String KEY = "difficultySetting";

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.settings);
    lp = (ListPreference) findPreference(KEY);
    lp.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

      public boolean onPreferenceChange(Preference preference,
          Object newValue) {
        // TODO Auto-generated method stub
        String diffString = newValue.toString();
        Integer which = Integer.parseInt(diffString);
        String value = null;
        switch (which) {
        case Game.DIFFICULTY_EASY:
          value = "easy";
          break;
        case Game.DIFFICULTY_MEDIUM:
          value = "not easy";
          break;
        case Game.DIFFICULTY_HARD:
          value = "absolutely not easy";
          break;
        default:
          break;
        }
        preference.setTitle(value);
        return true;
      }
    });

  }

  public static boolean getMusicState(Context ctx) {

    return PreferenceManager.getDefaultSharedPreferences(ctx).getBoolean(
        MUSIC_OPTION, MUSIC_OPTION_DEFAULT);
  }

  public static String getDiffState(Context ctx) {

    return PreferenceManager.getDefaultSharedPreferences(ctx).getString(
        KEY, "0");
  }

}




Java Source Code List

com.hao.apps.sudoku.About.java
com.hao.apps.sudoku.Game.java
com.hao.apps.sudoku.KeyPad.java
com.hao.apps.sudoku.Music.java
com.hao.apps.sudoku.PuzzleView.java
com.hao.apps.sudoku.Settings.java
com.hao.apps.sudoku.Sudoku.java
com.hao.apps.sudoku.algorithm.SudokuAlgorithm.java
com.hao.apps.sudoku.algorithm.SudokuUtils.java