Key click sound volume fix
bug: 5145886 Change-Id: Ic599373ee17423ef9c61b3dd5177c3763aa31015main
parent
c122cfc8fd
commit
bf7dd47329
|
@ -190,8 +190,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
private long mLastKeyTime;
|
||||
|
||||
private AudioManager mAudioManager;
|
||||
// Align sound effect volume on music volume
|
||||
private static final float FX_VOLUME = -1.0f;
|
||||
private static float mFxVolume = -1.0f; // just a default value to be updated runtime
|
||||
private boolean mSilentModeOn; // System-wide current configuration
|
||||
|
||||
// TODO: Move this flag to VoiceProxy
|
||||
|
@ -510,6 +509,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
if (null == mSubtypeSwitcher) mSubtypeSwitcher = SubtypeSwitcher.getInstance();
|
||||
mSettingsValues = new Settings.Values(mPrefs, this, mSubtypeSwitcher.getInputLocaleStr());
|
||||
resetContactsDictionary(null == mSuggest ? null : mSuggest.getContactsDictionary());
|
||||
updateSoundEffectVolume();
|
||||
}
|
||||
|
||||
private void initSuggest() {
|
||||
|
@ -2068,15 +2068,25 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
}
|
||||
};
|
||||
|
||||
// update sound effect volume
|
||||
private void updateSoundEffectVolume() {
|
||||
if (mAudioManager == null) {
|
||||
mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
||||
if (mAudioManager == null) return;
|
||||
}
|
||||
// This aligns with the current media volume minus 6dB
|
||||
mFxVolume = (float) mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC)
|
||||
/ (float) mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC) / 4.0f;
|
||||
}
|
||||
|
||||
// update flags for silent mode
|
||||
private void updateRingerMode() {
|
||||
if (mAudioManager == null) {
|
||||
mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
||||
if (mAudioManager == null) return;
|
||||
}
|
||||
if (mAudioManager != null) {
|
||||
mSilentModeOn = (mAudioManager.getRingerMode() != AudioManager.RINGER_MODE_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
private void playKeyClick(int primaryCode) {
|
||||
// if mAudioManager is null, we don't have the ringer state yet
|
||||
|
@ -2087,8 +2097,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
}
|
||||
}
|
||||
if (isSoundOn()) {
|
||||
// FIXME: Volume and enable should come from UI settings
|
||||
// FIXME: These should be triggered after auto-repeat logic
|
||||
int sound = AudioManager.FX_KEYPRESS_STANDARD;
|
||||
switch (primaryCode) {
|
||||
case Keyboard.CODE_DELETE:
|
||||
|
@ -2101,7 +2109,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
|||
sound = AudioManager.FX_KEYPRESS_SPACEBAR;
|
||||
break;
|
||||
}
|
||||
mAudioManager.playSoundEffect(sound, FX_VOLUME);
|
||||
mAudioManager.playSoundEffect(sound, mFxVolume);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue