From ef03dfed5c802a855c4655204eee39a8769cfed7 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Mon, 6 Jun 2022 17:00:58 +0200 Subject: [PATCH] Remove the vibration settings Instead of using the vibrator directly, use performHapticFeedback, which will integrate better with the system settings. --- res/values-de/strings.xml | 4 ---- res/values-es/strings.xml | 4 ---- res/values-fr/strings.xml | 4 ---- res/values-ko/strings.xml | 4 ---- res/values-lv/strings.xml | 4 ---- res/values-pt/strings.xml | 4 ---- res/values-tr/strings.xml | 4 ---- res/values-zh-rCN/strings.xml | 4 ---- res/values/strings.xml | 4 ---- res/xml/settings.xml | 4 ---- srcs/juloo.keyboard2/Config.java | 6 ------ srcs/juloo.keyboard2/Keyboard2View.java | 15 ++++----------- 12 files changed, 4 insertions(+), 57 deletions(-) diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 39621b4..585fd5a 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -15,10 +15,6 @@ Abstand der Zeichen in den Ecken der Tasten (%s) Zeitüberschreitung bei Tastenwiederholung Intervall der Tastenwiederholung - Vibration - Vibration - Vibration bei Tastendruck ein-/ausschalten - Dauer Präzise Cursorsteuerung Geschwindigkeit der Tastenwiederholung durch weniger oder mehr Wischen anpassen Sperrbare Hilfstasten diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index bc5827b..2688b64 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -13,10 +13,6 @@ Distancia de caracteres en las esquinas de las letras (%s) Tiempo de espera de repetición de tecla Intervalo de repetición de tecla - Vibración - Vibración - Habilitar/deshabilitar vibración al presionar una tecla - Duración Movimientos de cursor preciso Modular la velocidad de repetición de teclas según si se desliza más o menos Bloqueo de teclas modificadoras diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index d37ec15..02ff1ff 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -13,10 +13,6 @@ La distance des caractères dans les coins (%s) Délai avant répétition Écart entre répétitions - Vibration - Vibreur - Vibration a chaque touche - Durée Mouvement précis du curseur Modifier la vitesse de répétition en bougeant le doigt Style diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml index a230c30..41058d1 100644 --- a/res/values-ko/strings.xml +++ b/res/values-ko/strings.xml @@ -13,10 +13,6 @@ 키 모서리 문자의 입력 범위 (%s) 키 길게 누르기 지연 키 반복 간격 - 진동 - 진동 - 키 누를 때 진동 키거/끄기 - 지속 시간 정확한 커서 움직임 더 많거나 적은 스와이프로 키 반복 조절 스타일 diff --git a/res/values-lv/strings.xml b/res/values-lv/strings.xml index d8a92e5..275a4dc 100644 --- a/res/values-lv/strings.xml +++ b/res/values-lv/strings.xml @@ -17,10 +17,6 @@ Taustiņu stūros esošo rakstzīmju attālums (%s) Taustiņa atkārtošanās ātrums Taustiņa atkārtošanās aizture - Trīcēšana - Trīcēšana - Iespējot/atspējot taustiņa piespiešanas trīcēšanu - Ilgums Pielāgojama kursora kustība Mainīt taustiņa atkārtošanās ātrumu ar pavilkšanas attālumu Slēdzami pārveidotājtaustiņi diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml index 1f88fd3..e3dbd4e 100644 --- a/res/values-pt/strings.xml +++ b/res/values-pt/strings.xml @@ -17,10 +17,6 @@ Distância até acionar os cantos das teclas (%s) Tempo até repetir tecla Intervalo de repetição de tecla - Vibração - Vibração - Ativar/desativar vibração ao digitar - Duração Precisão nos movimentos do cursor Varia a velocidade de repetição a depender do quanto deslizar Teclas traváveis diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index 1f72a74..8cffb2a 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -17,10 +17,6 @@ Tuşların köşelerindeki karakterlerin uzaklıkları (%s) Tuş tekrarlama beklemesi Tuş tekrarlama aralığı - Titreşim - Titreşim - Tuşa basıldığında titreşimi etkinleştir - Süre İmleç hareketini ayarla Tuş tekrar hızını az ya da çok kaydırarak ayarla Sabitlenebilir değiştiriciler diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 474c6938..eb0cf48 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -15,10 +15,6 @@ 输入按键四角的符号需要滑动的距离 (%s) 长按到开始重复输入的时间 长按后每次重复输入的时间间隔 - 振动 - 振动 - 启用或者禁用按下按键时振动 - 每次振动持续的时间 精确控制光标移速 按键重复按下速度由手指滑动的距离决定 组合键锁定 diff --git a/res/values/strings.xml b/res/values/strings.xml index 741a9e2..58292a6 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -17,10 +17,6 @@ Distance of characters in the corners of the keys (%s) Key repeat timeout Key repeat interval - Vibration - Vibration - Enable/disable vibration on keypress - Duration Precise cursor movements Modulate key repeat speed by swiping more or less Lockable modifiers diff --git a/res/xml/settings.xml b/res/xml/settings.xml index 5d7072c..3293f91 100644 --- a/res/xml/settings.xml +++ b/res/xml/settings.xml @@ -21,10 +21,6 @@ - - - - diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index 39d1c25..2c68c92 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -26,8 +26,6 @@ final class Config public int layout; // Or '-1' for the system defaults public int programming_layout; // Or '-1' for none public float swipe_dist_px; - public boolean vibrateEnabled; - public long vibrateDuration; public long longPressTimeout; public long longPressInterval; public float marginBottom; @@ -62,8 +60,6 @@ final class Config // default values layout = -1; programming_layout = -1; - vibrateEnabled = true; - vibrateDuration = 20; longPressTimeout = 600; longPressInterval = 65; marginBottom = res.getDimension(R.dimen.margin_bottom); @@ -119,8 +115,6 @@ final class Config // Take the mean of both dimensions as an approximation of the diagonal. float physical_scaling = (dm.widthPixels + dm.heightPixels) / (dm.xdpi + dm.ydpi); swipe_dist_px = Float.valueOf(prefs.getString("swipe_dist", "15")) * physical_scaling;; - vibrateEnabled = prefs.getBoolean("vibrate_enabled", vibrateEnabled); - vibrateDuration = prefs.getInt("vibrate_duration", (int)vibrateDuration); longPressTimeout = prefs.getInt("longpress_timeout", (int)longPressTimeout); longPressInterval = prefs.getInt("longpress_interval", (int)longPressInterval); marginBottom = getDipPref(dm, prefs, "margin_bottom", marginBottom); diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java index 0aa911b..7938f18 100644 --- a/srcs/juloo.keyboard2/Keyboard2View.java +++ b/srcs/juloo.keyboard2/Keyboard2View.java @@ -7,9 +7,9 @@ import android.graphics.Paint; import android.graphics.RectF; import android.inputmethodservice.InputMethodService; import android.os.Build.VERSION; -import android.os.Vibrator; import android.util.AttributeSet; import android.util.DisplayMetrics; +import android.view.HapticFeedbackConstants; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; @@ -26,7 +26,6 @@ public class Keyboard2View extends View private Pointers.Modifiers _mods; - private Vibrator _vibratorService; private long _lastVibration = 0; private static int _currentWhat = 0; @@ -49,7 +48,6 @@ public class Keyboard2View extends View public Keyboard2View(Context context, AttributeSet attrs) { super(context, attrs); - _vibratorService = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE); _theme = new Theme(getContext(), attrs); _config = Config.globalConfig(); _pointers = new Pointers(this, _config); @@ -191,19 +189,14 @@ public class Keyboard2View extends View private void vibrate() { - if (!_config.vibrateEnabled) - return ; long now = System.currentTimeMillis(); if ((now - _lastVibration) > VIBRATE_MIN_INTERVAL) { _lastVibration = now; - try + if (VERSION.SDK_INT >= 5) { - _vibratorService.vibrate(_config.vibrateDuration); - } - catch (Exception e) - { - e.printStackTrace(); + performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, + HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); } } }