This commit is contained in:
ZiemlichUndead 2025-03-26 21:32:45 +01:00 committed by GitHub
commit f134d6963e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 0 deletions

View file

@ -211,6 +211,9 @@ class KeyboardActionListenerImpl(private val latinIME: LatinIME, private val inp
return true
}
}
latinIME.hapticCursorFeedback()
if (inputLogic.moveCursorByAndReturnIfInsideComposingWord(moveSteps)) {
// no need to finish input and restart suggestions if we're still in the word
// this is a noticeable performance improvement

View file

@ -8,6 +8,7 @@ package helium314.keyboard.latin;
import android.content.Context;
import android.media.AudioManager;
import android.os.Build;
import android.os.Vibrator;
import android.view.HapticFeedbackConstants;
import android.view.View;
@ -107,6 +108,23 @@ public final class AudioAndHapticFeedbackManager {
}
}
public void performHapticCursorFeedback(final View viewToPerformHapticFeedbackOn) {
if (!mSettingsValues.mVibrateOn) {
return;
}
if (viewToPerformHapticFeedbackOn != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
viewToPerformHapticFeedbackOn.performHapticFeedback(
HapticFeedbackConstants.TEXT_HANDLE_MOVE,
HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
}else {
viewToPerformHapticFeedbackOn.performHapticFeedback(
HapticFeedbackConstants.CLOCK_TICK,
HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
}
}
}
public void onSettingsChanged(final SettingsValues settingsValues) {
mSettingsValues = settingsValues;
mSoundOn = reevaluateIfSoundIsOn();

View file

@ -1799,6 +1799,12 @@ public class LatinIME extends InputMethodService implements
}
}
public void hapticCursorFeedback() {
final MainKeyboardView keyboardView = mKeyboardSwitcher.getMainKeyboardView();
final AudioAndHapticFeedbackManager feedbackManager = AudioAndHapticFeedbackManager.getInstance();
feedbackManager.performHapticCursorFeedback(keyboardView);
}
public void hapticAndAudioFeedback(final int code, final int repeatCount) {
final MainKeyboardView keyboardView = mKeyboardSwitcher.getMainKeyboardView();
if (keyboardView != null && keyboardView.isInDraggingFinger()) {