Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d675900f authored by James Nylen's avatar James Nylen Committed by Steve Kondik
Browse files

LatinIME: Add setting to obey system haptic feedback setting

Use case: when I'm talking on the phone, the vibrator apparently makes
terrible noises for the other person.  This change lets me make the
keyboard obey a Tasker profile that disables haptic feedback during
calls.

Change-Id: I0c560c13d4bb083b9ba8bec7170275db4c3571c3
parent e0c33fa1
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -28,6 +28,12 @@
    <!-- Option to provide vibrate/haptic feedback on keypress -->
    <string name="vibrate_on_keypress">Vibrate on keypress</string>

    <!-- Option to obey system haptic feedback setting -->
    <string name="obey_haptic_feedback">Obey haptic feedback</string>

    <!-- Description for obey_haptic_feedback -->
    <string name="obey_haptic_feedback_summary">Don\'t vibrate if haptic feedback is disabled in system settings</string>

    <!-- Option to play back sound on keypress in soft keyboard -->
    <string name="sound_on_keypress">Sound on keypress</string>

+7 −0
Original line number Diff line number Diff line
@@ -24,6 +24,13 @@
            android:persistent="true"
            />

    <CheckBoxPreference
            android:key="obey_haptic"
            android:title="@string/obey_haptic_feedback"
            android:summary="@string/obey_haptic_feedback_summary"
            android:persistent="true"
            />

    <CheckBoxPreference
            android:key="sound_on"
            android:title="@string/sound_on_keypress"
+6 −1
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ public class LatinIME extends InputMethodService
    static final boolean ENABLE_VOICE_BUTTON = true;

    private static final String PREF_VIBRATE_ON = "vibrate_on";
    private static final String PREF_OBEY_HAPTIC = "obey_haptic";
    private static final String PREF_SOUND_ON = "sound_on";
    private static final String PREF_POPUP_ON = "popup_on";
    private static final String PREF_AUTO_CAP = "auto_cap";
@@ -199,6 +200,7 @@ public class LatinIME extends InputMethodService
    private boolean mCapsLock;
    private boolean mPasswordText;
    private boolean mVibrateOn;
    private boolean mObeyHapticFeedback;
    private boolean mSoundOn;
    private boolean mPopupOn;
    private boolean mAutoCap;
@@ -360,6 +362,7 @@ public class LatinIME extends InputMethodService
        }
        mReCorrectionEnabled = prefs.getBoolean(PREF_RECORRECTION_ENABLED,
                getResources().getBoolean(R.bool.default_recorrection_enabled));
        mObeyHapticFeedback = prefs.getBoolean(PREF_OBEY_HAPTIC, false);

        LatinIMEUtil.GCUtils.getInstance().reset();
        boolean tryGC = true;
@@ -2259,6 +2262,8 @@ public class LatinIME extends InputMethodService
        } else if (PREF_RECORRECTION_ENABLED.equals(key)) {
            mReCorrectionEnabled = sharedPreferences.getBoolean(PREF_RECORRECTION_ENABLED,
                    getResources().getBoolean(R.bool.default_recorrection_enabled));
        } else if (PREF_OBEY_HAPTIC.equals(key)) {
            mObeyHapticFeedback = sharedPreferences.getBoolean(PREF_OBEY_HAPTIC, false);
        }
    }

@@ -2388,7 +2393,7 @@ public class LatinIME extends InputMethodService
        if (mKeyboardSwitcher.getInputView() != null) {
            mKeyboardSwitcher.getInputView().performHapticFeedback(
                    HapticFeedbackConstants.KEYBOARD_TAP,
                    HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
                    mObeyHapticFeedback ? 0 : HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
        }
    }