diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index 552d06f..b02c056 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -67,6 +67,11 @@ + + + + + Další Dokončit Spustit diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index bbaf594..4cccd3a 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -67,6 +67,11 @@ Erweitert Eigenes Layout Bitte Sourcecode ansehen. Diese Option ist nicht zur Verwendung vorgesehen. + + + + + Nächstes Fertig Los diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index 41f53ba..b1908fd 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -67,6 +67,11 @@ + + + + + Siguiente Hecho Ir diff --git a/res/values-fa/strings.xml b/res/values-fa/strings.xml index 84399e9..93d0310 100644 --- a/res/values-fa/strings.xml +++ b/res/values-fa/strings.xml @@ -67,6 +67,11 @@ پیشرفته طرح شخصی کد منبع را ببینید. این گزینه قرار نیست استفاده شود. + + + + + بعدی اتمام برو diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 8ea5379..428b4ff 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -67,6 +67,11 @@ Avancé Disposition personnalisée Cette option n\'est pas faite pour être utilisée. + + + + + Suiv. Fin Aller diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index 2774c6c..893500c 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -67,6 +67,11 @@ + + + + + Prossimo Fatto Vai diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml index 63d57b6..7a9d001 100644 --- a/res/values-ko/strings.xml +++ b/res/values-ko/strings.xml @@ -67,6 +67,11 @@ + + + + + 다음 확인 Go diff --git a/res/values-lv/strings.xml b/res/values-lv/strings.xml index f59e234..aa89788 100644 --- a/res/values-lv/strings.xml +++ b/res/values-lv/strings.xml @@ -67,6 +67,11 @@ Papildu Pielāgots izkārtojums Skatīt pirmkodu. Šī iespēja nav paredzēta izmantošanai. + + + + + Nākamais Darīts Aiziet diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index 0b2edb1..697a104 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -67,6 +67,11 @@ Zaawansowane Własny układ Zobacz kod źródłowy. Ta opcja nie jest przeznaczona do użycia. + + + + + Dalej OK Przejdź diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml index 6b92f44..8add41d 100644 --- a/res/values-pt/strings.xml +++ b/res/values-pt/strings.xml @@ -67,6 +67,11 @@ Avançado Layout personalizado Veja o código-fonte. Esta opção não deve ser usada. + + + + + Próximo Pronto Ir diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index 3ff8235..66e17d3 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -67,6 +67,11 @@ Расширенные настройки Пользовательская раскладка Откройте исходный код. Эта параметр не предназначен для использования. + + + + + Далее Ввод Go diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index 4e5a420..236f368 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -67,6 +67,11 @@ + + + + + İleri Bitti İlerle diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml index 2f00ac3..be2d515 100644 --- a/res/values-vi/strings.xml +++ b/res/values-vi/strings.xml @@ -69,6 +69,11 @@ Nâng cao Tùy chỉnh bố cục Hãy xem mã nguồn. Lựa chọn này không có mục đích sử dụng. + + + + + Tiếp Xong Đi diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index fc1d70a..e5bd4d4 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -67,6 +67,11 @@ + + + + + 下一项 完成 前往 diff --git a/res/values/arrays.xml b/res/values/arrays.xml index 51c5940..cf66614 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -134,4 +134,18 @@ 25 35 + + @string/pref_vibration_e_disabled + @string/pref_vibration_e_system + @string/pref_vibration_e_strong + @string/pref_vibration_e_medium + @string/pref_vibration_e_light + + + disabled + system + strong + medium + light + diff --git a/res/values/strings.xml b/res/values/strings.xml index 7b6e0df..94eb47d 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -67,6 +67,11 @@ Advanced Custom layout See the source code. This option is not meant to be used. + Disabled + System + Strong + Medium + Light Next Done Go diff --git a/res/xml/settings.xml b/res/xml/settings.xml index fafc174..322bf4d 100644 --- a/res/xml/settings.xml +++ b/res/xml/settings.xml @@ -55,7 +55,7 @@ - + diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java index 1abef6b..9fa6593 100644 --- a/srcs/juloo.keyboard2/Config.java +++ b/srcs/juloo.keyboard2/Config.java @@ -31,7 +31,7 @@ final class Config public boolean number_row; public float swipe_dist_px; public float slide_step_px; - public boolean vibrateEnabled; + public VibratorCompat.VibrationBehavior vibration_behavior; public long longPressTimeout; public long longPressInterval; public float margin_bottom; @@ -123,7 +123,8 @@ final class Config float swipe_dist_value = Float.valueOf(_prefs.getString("swipe_dist", "15")); swipe_dist_px = swipe_dist_value / 25.f * swipe_scaling; slide_step_px = swipe_dist_px / 4.f; - vibrateEnabled = _prefs.getBoolean("vibrate_enabled", true); + vibration_behavior = + VibratorCompat.VibrationBehavior.of_string(_prefs.getString("vibration_behavior", "system")); longPressTimeout = _prefs.getInt("longpress_timeout", 600); longPressInterval = _prefs.getInt("longpress_interval", 65); margin_bottom = get_dip_pref(dm, oriented_pref("margin_bottom"), diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java index 65098d0..f4053f2 100644 --- a/srcs/juloo.keyboard2/Keyboard2View.java +++ b/srcs/juloo.keyboard2/Keyboard2View.java @@ -10,7 +10,6 @@ import android.inputmethodservice.InputMethodService; import android.os.Build.VERSION; import android.util.AttributeSet; import android.util.DisplayMetrics; -import android.view.HapticFeedbackConstants; import android.view.MotionEvent; import android.view.View; import android.view.Window; @@ -231,13 +230,7 @@ public class Keyboard2View extends View private void vibrate() { - if (!_config.vibrateEnabled) - return ; - if (VERSION.SDK_INT >= 5) - { - performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, - HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); - } + VibratorCompat.vibrate(this, _config.vibration_behavior); } @Override diff --git a/srcs/juloo.keyboard2/VibratorCompat.java b/srcs/juloo.keyboard2/VibratorCompat.java new file mode 100644 index 0000000..99ff5f5 --- /dev/null +++ b/srcs/juloo.keyboard2/VibratorCompat.java @@ -0,0 +1,81 @@ +package juloo.keyboard2; + +import android.content.Context; +import android.os.Build.VERSION; +import android.os.Vibrator; +import android.view.HapticFeedbackConstants; +import android.view.View; + +public final class VibratorCompat +{ + public static void vibrate(View v, VibrationBehavior b) + { + switch (b) + { + 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, 50); + break; + case MEDIUM: + vibrator_vibrate(v, 20); + break; + case LIGHT: + vibrator_vibrate(v, 10); + break; + } + } + + /** 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) + { + try + { + get_vibrator(v).vibrate(duration); + } + catch (Exception e) {} + } + + static Vibrator vibrator_service = null; + + static Vibrator get_vibrator(View v) + { + if (vibrator_service == null) + { + vibrator_service = + (Vibrator)v.getContext().getSystemService(Context.VIBRATOR_SERVICE); + } + 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; + } + } + } +}