Merge "Get the view for haptic feedback as a parameter (A6)"
This commit is contained in:
commit
663aabca0c
2 changed files with 11 additions and 15 deletions
|
@ -21,11 +21,10 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.view.HapticFeedbackConstants;
|
import android.view.HapticFeedbackConstants;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import com.android.inputmethod.compat.VibratorCompatWrapper;
|
import com.android.inputmethod.compat.VibratorCompatWrapper;
|
||||||
import com.android.inputmethod.keyboard.Keyboard;
|
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.
|
* This class gathers audio feedback and haptic feedback functions.
|
||||||
|
@ -35,22 +34,21 @@ import com.android.inputmethod.keyboard.LatinKeyboardView;
|
||||||
*/
|
*/
|
||||||
public class AudioAndHapticFeedbackManager extends BroadcastReceiver {
|
public class AudioAndHapticFeedbackManager extends BroadcastReceiver {
|
||||||
final private SettingsValues mSettingsValues;
|
final private SettingsValues mSettingsValues;
|
||||||
final private KeyboardSwitcher mKeyboardSwitcher;
|
|
||||||
final private AudioManager mAudioManager;
|
final private AudioManager mAudioManager;
|
||||||
final private VibratorCompatWrapper mVibrator;
|
final private VibratorCompatWrapper mVibrator;
|
||||||
private boolean mSoundOn;
|
private boolean mSoundOn;
|
||||||
|
|
||||||
public AudioAndHapticFeedbackManager(final LatinIME latinIme,
|
public AudioAndHapticFeedbackManager(final LatinIME latinIme,
|
||||||
final SettingsValues settingsValues, final KeyboardSwitcher keyboardSwitcher) {
|
final SettingsValues settingsValues) {
|
||||||
mSettingsValues = settingsValues;
|
mSettingsValues = settingsValues;
|
||||||
mKeyboardSwitcher = keyboardSwitcher;
|
|
||||||
mVibrator = VibratorCompatWrapper.getInstance(latinIme);
|
mVibrator = VibratorCompatWrapper.getInstance(latinIme);
|
||||||
mAudioManager = (AudioManager) latinIme.getSystemService(Context.AUDIO_SERVICE);
|
mAudioManager = (AudioManager) latinIme.getSystemService(Context.AUDIO_SERVICE);
|
||||||
mSoundOn = reevaluateIfSoundIsOn();
|
mSoundOn = reevaluateIfSoundIsOn();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hapticAndAudioFeedback(final int primaryCode) {
|
public void hapticAndAudioFeedback(final int primaryCode,
|
||||||
vibrate();
|
final View viewToPerformHapticFeedbackOn) {
|
||||||
|
vibrate(viewToPerformHapticFeedbackOn);
|
||||||
playKeyClick(primaryCode);
|
playKeyClick(primaryCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,15 +84,14 @@ public class AudioAndHapticFeedbackManager extends BroadcastReceiver {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: make this private when LatinIME does not call it any more
|
// TODO: make this private when LatinIME does not call it any more
|
||||||
public void vibrate() {
|
public void vibrate(final View viewToPerformHapticFeedbackOn) {
|
||||||
if (!mSettingsValues.mVibrateOn) {
|
if (!mSettingsValues.mVibrateOn) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mSettingsValues.mKeypressVibrationDuration < 0) {
|
if (mSettingsValues.mKeypressVibrationDuration < 0) {
|
||||||
// Go ahead with the system default
|
// Go ahead with the system default
|
||||||
LatinKeyboardView inputView = mKeyboardSwitcher.getKeyboardView();
|
if (viewToPerformHapticFeedbackOn != null) {
|
||||||
if (inputView != null) {
|
viewToPerformHapticFeedbackOn.performHapticFeedback(
|
||||||
inputView.performHapticFeedback(
|
|
||||||
HapticFeedbackConstants.KEYBOARD_TAP,
|
HapticFeedbackConstants.KEYBOARD_TAP,
|
||||||
HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
|
HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
|
||||||
}
|
}
|
||||||
|
|
|
@ -557,8 +557,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
/* package */ void loadSettings() {
|
/* package */ void loadSettings() {
|
||||||
if (null == mPrefs) mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
if (null == mPrefs) mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
mSettingsValues = new SettingsValues(mPrefs, this, mSubtypeSwitcher.getInputLocaleStr());
|
mSettingsValues = new SettingsValues(mPrefs, this, mSubtypeSwitcher.getInputLocaleStr());
|
||||||
mFeedbackManager = new AudioAndHapticFeedbackManager(this, mSettingsValues,
|
mFeedbackManager = new AudioAndHapticFeedbackManager(this, mSettingsValues);
|
||||||
mKeyboardSwitcher);
|
|
||||||
resetContactsDictionary(null == mSuggest ? null : mSuggest.getContactsDictionary());
|
resetContactsDictionary(null == mSuggest ? null : mSuggest.getContactsDictionary());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2322,7 +2321,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hapticAndAudioFeedback(final int primaryCode) {
|
public void hapticAndAudioFeedback(final int primaryCode) {
|
||||||
mFeedbackManager.hapticAndAudioFeedback(primaryCode);
|
mFeedbackManager.hapticAndAudioFeedback(primaryCode, mKeyboardSwitcher.getKeyboardView());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2360,7 +2359,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
|
|
||||||
// TODO: remove this method when VoiceProxy has been removed
|
// TODO: remove this method when VoiceProxy has been removed
|
||||||
public void vibrate() {
|
public void vibrate() {
|
||||||
mFeedbackManager.vibrate();
|
mFeedbackManager.vibrate(mKeyboardSwitcher.getKeyboardView());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAutoCapitalized() {
|
public boolean isAutoCapitalized() {
|
||||||
|
|
Loading…
Reference in a new issue