Get the view for haptic feedback as a parameter (A6)

It's rather annoying (and possibly dangerous) to keep this as a member.
Get it from outside.

Change-Id: I00c42db96395fb65204fb140aeedc82bf312a86e
main
Jean Chalard 2012-03-07 13:11:58 +09:00
parent 29d967fdcb
commit 544c3c2952
2 changed files with 11 additions and 15 deletions

View File

@ -21,11 +21,10 @@ import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
import android.view.HapticFeedbackConstants;
import android.view.View;
import com.android.inputmethod.compat.VibratorCompatWrapper;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardSwitcher;
import com.android.inputmethod.keyboard.LatinKeyboardView;
/**
* This class gathers audio feedback and haptic feedback functions.
@ -35,22 +34,21 @@ import com.android.inputmethod.keyboard.LatinKeyboardView;
*/
public class AudioAndHapticFeedbackManager extends BroadcastReceiver {
final private SettingsValues mSettingsValues;
final private KeyboardSwitcher mKeyboardSwitcher;
final private AudioManager mAudioManager;
final private VibratorCompatWrapper mVibrator;
private boolean mSoundOn;
public AudioAndHapticFeedbackManager(final LatinIME latinIme,
final SettingsValues settingsValues, final KeyboardSwitcher keyboardSwitcher) {
final SettingsValues settingsValues) {
mSettingsValues = settingsValues;
mKeyboardSwitcher = keyboardSwitcher;
mVibrator = VibratorCompatWrapper.getInstance(latinIme);
mAudioManager = (AudioManager) latinIme.getSystemService(Context.AUDIO_SERVICE);
mSoundOn = reevaluateIfSoundIsOn();
}
public void hapticAndAudioFeedback(final int primaryCode) {
vibrate();
public void hapticAndAudioFeedback(final int primaryCode,
final View viewToPerformHapticFeedbackOn) {
vibrate(viewToPerformHapticFeedbackOn);
playKeyClick(primaryCode);
}
@ -86,15 +84,14 @@ public class AudioAndHapticFeedbackManager extends BroadcastReceiver {
}
// TODO: make this private when LatinIME does not call it any more
public void vibrate() {
public void vibrate(final View viewToPerformHapticFeedbackOn) {
if (!mSettingsValues.mVibrateOn) {
return;
}
if (mSettingsValues.mKeypressVibrationDuration < 0) {
// Go ahead with the system default
LatinKeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
if (inputView != null) {
inputView.performHapticFeedback(
if (viewToPerformHapticFeedbackOn != null) {
viewToPerformHapticFeedbackOn.performHapticFeedback(
HapticFeedbackConstants.KEYBOARD_TAP,
HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
}

View File

@ -557,8 +557,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
/* package */ void loadSettings() {
if (null == mPrefs) mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
mSettingsValues = new SettingsValues(mPrefs, this, mSubtypeSwitcher.getInputLocaleStr());
mFeedbackManager = new AudioAndHapticFeedbackManager(this, mSettingsValues,
mKeyboardSwitcher);
mFeedbackManager = new AudioAndHapticFeedbackManager(this, mSettingsValues);
resetContactsDictionary(null == mSuggest ? null : mSuggest.getContactsDictionary());
}
@ -2324,7 +2323,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
}
public void hapticAndAudioFeedback(final int primaryCode) {
mFeedbackManager.hapticAndAudioFeedback(primaryCode);
mFeedbackManager.hapticAndAudioFeedback(primaryCode, mKeyboardSwitcher.getKeyboardView());
}
@Override
@ -2362,7 +2361,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
// TODO: remove this method when VoiceProxy has been removed
public void vibrate() {
mFeedbackManager.vibrate();
mFeedbackManager.vibrate(mKeyboardSwitcher.getKeyboardView());
}
public boolean isAutoCapitalized() {