@@ -0,0 +1,2870 @@
+package anabalica.github.io.meowletters.utils;%0A%0Aimport android.content.Context;%0Aimport android.content.SharedPreferences;%0Aimport android.media.AudioManager;%0Aimport android.media.SoundPool;%0Aimport android.os.Build;%0Aimport android.preference.PreferenceManager;%0Aimport android.util.Log;%0A%0Aimport com.squareup.otto.Subscribe;%0A%0Aimport anabalica.github.io.meowletters.R;%0Aimport anabalica.github.io.meowletters.SettingsActivity;%0A%0A/**%0A * Cla%0A *%0A * @author Ana Balica%0A */%0Apublic class SoundManager %7B%0A    SoundPool soundPool;%0A    int menuButtonSoundId;%0A    int letterButtonSoundId;%0A    int penaltySoundId;%0A    int timerOutSoundId;%0A    int gameOverSoundId;%0A%0A    public final static String MENU_BUTTON_SOUND = %22anabalica.github.io.meowletters.menu_button_sound%22;%0A    public final static String LETTER_SOUND = %22anabalica.github.io.meowletters.letter_sound%22;%0A    public final static String PENALTY_SOUND = %22anabalica.github.io.meowletters.penalty_sound%22;%0A    public final static String TIMER_OUT_SOUND = %22anabalica.github.io.meowletters.timer_out_sound%22;%0A    public final static String GAME_OVER_SOUND = %22anabalica.github.io.meowletters.game_over_sound%22;%0A%0A    SharedPreferences sharedPrefs;%0A%0A    public SoundManager(Context context) %7B%0A        // Initialize the sound pool%0A        if (Build.VERSION.SDK_INT %3C Build.VERSION_CODES.LOLLIPOP) %7B%0A            soundPool = new SoundPool(10, AudioManager.STREAM_MUSIC, 0);%0A        %7D else %7B%0A            SoundPool.Builder soundPoolBuilder = new SoundPool.Builder();%0A            soundPool = soundPoolBuilder.build();%0A        %7D%0A%0A        // Load sounds%0A        menuButtonSoundId = soundPool.load(context, R.raw.menu_click, 1);%0A        letterButtonSoundId = soundPool.load(context, R.raw.letter_tap, 1);%0A        timerOutSoundId = soundPool.load(context, R.raw.timer_out, 1);%0A        gameOverSoundId = soundPool.load(context, R.raw.game_over, 1);%0A        penaltySoundId = soundPool.load(context, R.raw.penalty, 1);%0A%0A        sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context);%0A    %7D%0A%0A    @Subscribe public void playSound(String event) %7B%0A        boolean sounds = sharedPrefs.getBoolean(SettingsActivity.PREF_SOUND, true);%0A        if (!sounds) %7B%0A            return;%0A        %7D%0A%0A        if (event.equals(MENU_BUTTON_SOUND)) %7B%0A            soundPool.play(menuButtonSoundId, 1, 1, 0, 0, 1);%0A        %7D else if (event.equals(LETTER_SOUND)) %7B%0A            soundPool.play(letterButtonSoundId, 1, 1, 0, 0, 1);%0A        %7D else if (event.equals(PENALTY_SOUND)) %7B%0A            soundPool.play(penaltySoundId, 1, 1, 0, 0, 1);%0A        %7D  else if (event.equals(TIMER_OUT_SOUND)) %7B%0A            soundPool.play(timerOutSoundId, 1, 1, 0, 0, 1);%0A        %7D else if (event.equals(GAME_OVER_SOUND)) %7B%0A            soundPool.play(gameOverSoundId, 1, 1, 0, 0, 1);%0A        %7D else %7B%0A            Log.w(this.getClass().toString(), %22Unknown sound name%22);%0A        %7D%0A    %7D%0A%7D%0A

create a sound manager class that acts as a subscriber