Android Open Source - android-chess Chess Preferences






From Project

Back to project page android-chess.

License

The source code is released under:

MIT License

If you think the Android project android-chess 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 jwtc.android.chess;
//  www .j  av  a2 s  .  com
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.preference.Preference.OnPreferenceClickListener;
import android.util.Log;
import jwtc.android.chess.ics.CustomCommands;


public class ChessPreferences extends PreferenceActivity {
  
  private static int REQUEST_SOUND = 1;
  private Uri _uriNotification;
  private int _colorScheme;
  
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        PreferenceManager pm = getPreferenceManager();
        pm.setSharedPreferencesName("ChessPlayer");
        
        final SharedPreferences prefs = pm.getSharedPreferences();
        final SharedPreferences.Editor editor = prefs.edit();
        _colorScheme = prefs.getInt("ColorScheme", 0); 
        
        addPreferencesFromResource(R.xml.globalprefs);
        
        Preference prefColor = (Preference) findPreference("colorSchemeHandle");
        prefColor.setOnPreferenceClickListener(new OnPreferenceClickListener() {
          public boolean onPreferenceClick(Preference preference) {
            
            final String[] items = getResources().getStringArray(R.array.colorschemes);
        
        AlertDialog.Builder builder = new AlertDialog.Builder(ChessPreferences.this);
        builder.setTitle(R.string.title_pick_colorscheme);
        builder.setSingleChoiceItems(items, _colorScheme, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int item) {
              
              _colorScheme = item;
                editor.putInt("ColorScheme", _colorScheme);
                editor.commit();
              
              dialog.dismiss();
            }
        });
        AlertDialog alert = builder.create();
        alert.show();
        
        return true;
          }
        });
        
        Preference prefSound = (Preference) findPreference("soundHandle");
        prefSound.setOnPreferenceClickListener(new OnPreferenceClickListener() {
          public boolean onPreferenceClick(Preference preference) {
            Intent intent = new Intent( RingtoneManager.ACTION_RINGTONE_PICKER);
            intent.putExtra( RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
            intent.putExtra( RingtoneManager.EXTRA_RINGTONE_TITLE, "Notification tone");
            if( _uriNotification == null)
            {
              intent.putExtra( RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri)null);
            }
            else
            {
              intent.putExtra( RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, _uriNotification);
            }
            startActivityForResult( intent, REQUEST_SOUND);
            return true;
          }
        });
        
        Preference prefCustomCommand = (Preference) findPreference("icscustomcommandHandle");
        prefCustomCommand.setOnPreferenceClickListener(new OnPreferenceClickListener() {
          public boolean onPreferenceClick(Preference preference) {
            Intent intent = new Intent(ChessPreferences.this, CustomCommands.class);
            
            startActivity( intent);
            return true;
          }
        });
        //
    }
    
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      if(requestCode == REQUEST_SOUND){
          if (resultCode == RESULT_OK) {
            _uriNotification = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
          
            SharedPreferences.Editor editor = getSharedPreferences("ChessPlayer", MODE_PRIVATE).edit();
            if(_uriNotification == null){
              editor.putString("NotificationUri", null);
            }
            else{
              editor.putString("NotificationUri", _uriNotification.toString());
            }
            editor.commit();
            Log.i("onActivityResult", "Sound " + _uriNotification);
          }
        }
    }
}




Java Source Code List

jwtc.android.chess.ChessFieldView.java
jwtc.android.chess.ChessImageView.java
jwtc.android.chess.ChessPreferences.java
jwtc.android.chess.ChessViewBase.java
jwtc.android.chess.ChessView.java
jwtc.android.chess.GamesListView.java
jwtc.android.chess.HtmlActivity.java
jwtc.android.chess.ImageCacheObject.java
jwtc.android.chess.MyBaseActivity.java
jwtc.android.chess.MyPGNProvider.java
jwtc.android.chess.PGNView.java
jwtc.android.chess.SaveGameDlg.java
jwtc.android.chess.UI.java
jwtc.android.chess.convergence.Connection.java
jwtc.android.chess.convergence.ConvergenceActivity.java
jwtc.android.chess.convergence.RestServer.java
jwtc.android.chess.iconifiedlist.IconifiedTextListAdapter.java
jwtc.android.chess.iconifiedlist.IconifiedTextView.java
jwtc.android.chess.iconifiedlist.IconifiedText.java
jwtc.android.chess.ics.CustomCommands.java
jwtc.android.chess.ics.ICSChatDlg.java
jwtc.android.chess.ics.ICSChessView.java
jwtc.android.chess.ics.ICSClient.java
jwtc.android.chess.ics.ICSConfirmDlg.java
jwtc.android.chess.ics.ICSMatchDlg.java
jwtc.android.chess.ics.TelnetSocket.java
jwtc.android.chess.ics.TimesealInputStream.java
jwtc.android.chess.ics.TimesealOutputStream.java
jwtc.android.chess.ics.TimesealPipe.java
jwtc.android.chess.ics.TimesealingSocket.java
jwtc.android.chess.puzzle.ChessViewPractice.java
jwtc.android.chess.puzzle.ChessViewPuzzle.java
jwtc.android.chess.puzzle.MyPuzzleProvider.java
jwtc.android.chess.puzzle.practice.java
jwtc.android.chess.puzzle.puzzle.java
jwtc.android.chess.tools.FileListView.java
jwtc.android.chess.tools.PGNProcessor.java
jwtc.android.chess.tools.importactivity.java
jwtc.android.chess.tools.pgntool.java
jwtc.android.chess.main.java
jwtc.android.chess.options.java
jwtc.android.chess.setup.java
jwtc.android.chess.start.java
jwtc.android.timeseal.TimesealingSocket.java
jwtc.android.timeseal.streams.a.java
jwtc.android.timeseal.streams.b.java
jwtc.android.timeseal.streams.c.java
jwtc.chess.ChessPuzzleProvider.java
jwtc.chess.GameControl.java
jwtc.chess.JNI.java
jwtc.chess.Move.java
jwtc.chess.PGNColumns.java
jwtc.chess.PGNEntry.java
jwtc.chess.PGNProvider.java
jwtc.chess.Pos.java
jwtc.chess.Valuation.java
jwtc.chess.algorithm.SearchAlgorithmRunner.java
jwtc.chess.algorithm.UCIWrapper.java
jwtc.chess.board.BoardConstants.java
jwtc.chess.board.BoardHashKeys.java
jwtc.chess.board.BoardMembers.java
jwtc.chess.board.BoardStatics.java
jwtc.chess.board.ChessBoard.java