diff options
| author | Jules Aguillon | 2024-01-09 00:43:28 +0100 |
|---|---|---|
| committer | Jules Aguillon | 2024-01-09 00:43:28 +0100 |
| commit | 73267d68fb3ba04a5233a605a10969a8a9052961 (patch) | |
| tree | 632a6b81fe9360f0de7a8215b52548330d2b35ee /srcs/juloo.keyboard2/VibratorCompat.java | |
| parent | 3f2f3177dafab4e44a827f8614f3731a177ae281 (diff) | |
| download | unexpected-keyboard-73267d68fb3ba04a5233a605a10969a8a9052961.tar.gz unexpected-keyboard-73267d68fb3ba04a5233a605a10969a8a9052961.zip | |
Revert "Remove the vibration settings"
This reverts commits ef03dfed5c802a855c4655204eee39a8769cfed7 and
ff01678ba688778d67f824a0be56634974c1b0e8.
The "vibration duration" slider is bought back.
The "vibration enabled" option is replaced by "custom vibration", which switch between the system haptic feedback or the custom vibration.
The slider is greyed when "custom vibration" is unchecked and is
allowed to have a value of 0 to disable vibrations within the app.
The intermediate values "light", "medium" and "strong" are removed and
no migration of the setting is made.
Diffstat (limited to 'srcs/juloo.keyboard2/VibratorCompat.java')
| -rw-r--r-- | srcs/juloo.keyboard2/VibratorCompat.java | 55 |
1 files changed, 11 insertions, 44 deletions
diff --git a/srcs/juloo.keyboard2/VibratorCompat.java b/srcs/juloo.keyboard2/VibratorCompat.java index 2795c71..4a9debe 100644 --- a/srcs/juloo.keyboard2/VibratorCompat.java +++ b/srcs/juloo.keyboard2/VibratorCompat.java @@ -8,32 +8,24 @@ import android.view.View; public final class VibratorCompat { - public static void vibrate(View v, VibrationBehavior b) + public static void vibrate(View v, Config config) { - switch (b) + if (config.vibrate_custom) { - case DISABLED: - break; - case SYSTEM: - if (VERSION.SDK_INT >= 8) - v.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, - HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); - break; - case STRONG: - vibrator_vibrate(v, 90); - break; - case MEDIUM: - vibrator_vibrate(v, 45); - break; - case LIGHT: - vibrator_vibrate(v, 20); - break; + if (config.vibrate_duration > 0) + vibrator_vibrate(v, config.vibrate_duration); + } + else + { + if (VERSION.SDK_INT >= 8) + v.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, + HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); } } /** Use the older [Vibrator] when the newer API is not available or the user wants more control. */ - static void vibrator_vibrate(View v, int duration) + static void vibrator_vibrate(View v, long duration) { try { @@ -53,29 +45,4 @@ public final class VibratorCompat } return vibrator_service; } - - public static enum VibrationBehavior - { - DISABLED, - SYSTEM, - STRONG, - MEDIUM, - LIGHT; - - VibrationBehavior() {} - - /** Defaults [SYSTEM] for unrecognized strings. */ - public static VibrationBehavior of_string(String s) - { - switch (s) - { - case "disabled": return DISABLED; - case "system": return SYSTEM; - case "strong": return STRONG; - case "medium": return MEDIUM; - case "light": return LIGHT; - default: return SYSTEM; - } - } - } } |
