Android Open Source - Do-not-get-annoyed Game Settings Editor






From Project

Back to project page Do-not-get-annoyed.

License

The source code is released under:

Apache License

If you think the Android project Do-not-get-annoyed 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 mn100013d.pmu.data;
//  w w  w . j ava 2 s .  c om
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.media.AudioManager;

public class GameSettingsEditor {
  private static final String MUSIC_VOLUME = "mn100013d.pmu.data.MUSIC_VOLUME";
  private static final String SENSITIVITY = "mn100013d.pmu.data.SENSITIVITY";
  private static final int DEFAULT_MUSIC_VOLUME = 50;
  private static final int DEFAULT_SENSITIVITY = 2; 
  private static final String PREFERENCES = "mn100013d.pmu.data.PREFERENCES";
  
  private Context context;
  
  public GameSettingsEditor(Context context){
    this.context = context;
    
  }
  
  public int getVolume() { 
    SharedPreferences sharedPref = ((Activity)context).getSharedPreferences(PREFERENCES,0);
    return sharedPref.getInt(MUSIC_VOLUME, DEFAULT_MUSIC_VOLUME);
  }
  public int getSensitivity() {
    SharedPreferences sharedPref = ((Activity)context).getSharedPreferences(PREFERENCES,0);
    return sharedPref.getInt(SENSITIVITY, DEFAULT_SENSITIVITY);
  }  
  public void setMusicVolume(int volume){
    SharedPreferences sharedPref = ((Activity)context).getSharedPreferences(PREFERENCES,0);
    SharedPreferences.Editor editor = sharedPref.edit();
    editor.putInt(MUSIC_VOLUME, volume);
    editor.commit();
    AudioManager audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
    audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, volume, 0);
  }
  public void setSensitivity(int sensitivity){
    SharedPreferences sharedPref = ((Activity)context).getSharedPreferences(PREFERENCES,0);;
    SharedPreferences.Editor editor = sharedPref.edit();
    editor.putInt(SENSITIVITY, sensitivity);
    editor.commit();
  }
  
  
  
}




Java Source Code List

mn100013d.pmu.BeginingActivity.java
mn100013d.pmu.GameTypeFragment.java
mn100013d.pmu.NewGameActivity.java
mn100013d.pmu.NewGameFragment.java
mn100013d.pmu.PauseFragment.java
mn100013d.pmu.PauseGameFragment.java
mn100013d.pmu.ScoresFragment.java
mn100013d.pmu.SettingsFragment.java
mn100013d.pmu.StartActivity.java
mn100013d.pmu.StartGameFragment.java
mn100013d.pmu.controllers.GameController.java
mn100013d.pmu.data.GameDataDbHelper.java
mn100013d.pmu.data.GameSettingsEditor.java
mn100013d.pmu.data.GameTableContract.java
mn100013d.pmu.exceptions.ContextNotSetException.java
mn100013d.pmu.exceptions.GameExceptions.java
mn100013d.pmu.exceptions.PlayerNotRegisteredException.java
mn100013d.pmu.models.Board.java
mn100013d.pmu.models.CPUGamePlayer.java
mn100013d.pmu.models.Color.java
mn100013d.pmu.models.Dice.java
mn100013d.pmu.models.Field.java
mn100013d.pmu.models.FinishField.java
mn100013d.pmu.models.GamePlayer.java
mn100013d.pmu.models.HomeField.java
mn100013d.pmu.models.HumanGamePlayer.java
mn100013d.pmu.models.PathField.java
mn100013d.pmu.models.Pawn.java
mn100013d.pmu.models.Result.java
mn100013d.pmu.services.FragmentProvider.java
mn100013d.pmu.services.GamePlayerFactory.java
mn100013d.pmu.services.PopupService.java
mn100013d.pmu.services.Randomizer.java
mn100013d.pmu.services.ShakeDetector.java
mn100013d.pmu.services.SoundService.java