Merge "Make a condition positive (A3)"

This commit is contained in:
Jean Chalard 2012-03-08 02:32:07 -08:00 committed by Android (Google) Code Review
commit d2b5ea2084

View file

@ -39,14 +39,14 @@ public class AudioAndHapticFeedbackManager extends BroadcastReceiver {
final private KeyboardSwitcher mKeyboardSwitcher; final private KeyboardSwitcher mKeyboardSwitcher;
final private AudioManager mAudioManager; final private AudioManager mAudioManager;
final private VibratorCompatWrapper mVibrator; final private VibratorCompatWrapper mVibrator;
private boolean mSilentModeOn; private boolean mSoundOn;
public AudioAndHapticFeedbackManager(final LatinIME latinIme, public AudioAndHapticFeedbackManager(final LatinIME latinIme,
final SettingsValues settingsValues, final KeyboardSwitcher keyboardSwitcher) { final SettingsValues settingsValues, final KeyboardSwitcher keyboardSwitcher) {
mLatinIme = latinIme; mLatinIme = latinIme;
mSettingsValues = settingsValues; mSettingsValues = settingsValues;
mKeyboardSwitcher = keyboardSwitcher; mKeyboardSwitcher = keyboardSwitcher;
mSilentModeOn = true; mSoundOn = false;
mVibrator = VibratorCompatWrapper.getInstance(mLatinIme); mVibrator = VibratorCompatWrapper.getInstance(mLatinIme);
mAudioManager = (AudioManager) mLatinIme.getSystemService(Context.AUDIO_SERVICE); mAudioManager = (AudioManager) mLatinIme.getSystemService(Context.AUDIO_SERVICE);
updateRingerMode(); updateRingerMode();
@ -58,15 +58,15 @@ public class AudioAndHapticFeedbackManager extends BroadcastReceiver {
} }
private boolean isSoundOn() { private boolean isSoundOn() {
return mSettingsValues.mSoundOn && !mSilentModeOn; return mSettingsValues.mSoundOn && mSoundOn;
} }
// update flags for silent mode // update flags for silent mode
private void updateRingerMode() { private void updateRingerMode() {
if (!mSettingsValues.mSoundOn || mAudioManager == null) { if (!mSettingsValues.mSoundOn || mAudioManager == null) {
mSilentModeOn = true; mSoundOn = false;
} else { } else {
mSilentModeOn = (mAudioManager.getRingerMode() != AudioManager.RINGER_MODE_NORMAL); mSoundOn = (mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_NORMAL);
} }
} }