Skip to content

Commit

Permalink
only play sound effects when system setting for that is enabled (fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
westnordost committed Sep 5, 2018
1 parent c2b52e0 commit ca13e6f
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;
import android.provider.Settings;
import android.support.annotation.RawRes;
import android.util.SparseIntArray;

Expand All @@ -28,7 +29,12 @@ public void prepare(@RawRes int resId)

public void play(@RawRes int resId)
{
if(soundIds.get(resId) == 0) prepare(resId);
sounds.play(soundIds.get(resId), 1, 1, 1, 0, 1);
boolean isTouchSoundsEnabled = Settings.System.getInt(context.getContentResolver(),
Settings.System.SOUND_EFFECTS_ENABLED, 1) != 0;
if(isTouchSoundsEnabled)
{
if (soundIds.get(resId) == 0) prepare(resId);
sounds.play(soundIds.get(resId), 1, 1, 1, 0, 1);
}
}
}

0 comments on commit ca13e6f

Please sign in to comment.