Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import android.content.Context;
import android.media.AudioManager;
import android.os.Build;
import android.os.Vibrator;
import android.view.HapticFeedbackConstants;
import android.view.View;
Expand Down Expand Up @@ -105,6 +106,23 @@ public void performHapticFeedback(final View viewToPerformHapticFeedbackOn) {
HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
}
}

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}else {
} else {

viewToPerformHapticFeedbackOn.performHapticFeedback(
HapticFeedbackConstants.CLOCK_TICK,
HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
}
}
}

public void onSettingsChanged(final SettingsValues settingsValues) {
mSettingsValues = settingsValues;
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/helium314/keyboard/latin/LatinIME.java
Original file line number Diff line number Diff line change
Expand Up @@ -1747,6 +1747,12 @@ private void updateStateAfterInputTransaction(final InputTransaction inputTransa
}
}

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()) {
Expand Down