diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/activities/SettingsActivity.kt
index 055eb3c..fb302e8 100644
--- a/app/src/main/kotlin/com/simplemobiletools/keyboard/activities/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/activities/SettingsActivity.kt
@@ -22,7 +22,8 @@ class SettingsActivity : SimpleActivity() {
setupPurchaseThankYou()
setupCustomizeColors()
setupUseEnglish()
- setupClipboard()
+ setupVibrateOnKeypress()
+ setupShowPopupOnKeypress()
updateTextColors(settings_scrollview)
@@ -65,7 +66,7 @@ class SettingsActivity : SimpleActivity() {
settings_use_english.isChecked = config.useEnglish
if (settings_use_english_holder.isGone() && settings_purchase_thank_you_holder.isGone()) {
- settings_show_clipboard_holder.background = resources.getDrawable(R.drawable.ripple_all_corners, theme)
+ settings_vibrate_on_keypress_holder.background = resources.getDrawable(R.drawable.ripple_top_corners, theme)
}
settings_use_english_holder.setOnClickListener {
@@ -75,11 +76,19 @@ class SettingsActivity : SimpleActivity() {
}
}
- private fun setupClipboard() {
- settings_show_clipboard.isChecked = config.showClipboard
- settings_show_clipboard_holder.setOnClickListener {
- settings_show_clipboard.toggle()
- config.showClipboard = settings_show_clipboard.isChecked
+ private fun setupVibrateOnKeypress() {
+ settings_vibrate_on_keypress.isChecked = config.vibrateOnKeypress
+ settings_vibrate_on_keypress_holder.setOnClickListener {
+ settings_vibrate_on_keypress.toggle()
+ config.vibrateOnKeypress = settings_vibrate_on_keypress.isChecked
+ }
+ }
+
+ private fun setupShowPopupOnKeypress() {
+ settings_show_popup_on_keypress.isChecked = config.showPopupOnKeypress
+ settings_show_popup_on_keypress_holder.setOnClickListener {
+ settings_show_popup_on_keypress.toggle()
+ config.showPopupOnKeypress = settings_show_popup_on_keypress.isChecked
}
}
}
diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Config.kt
index 7c5a12e..8bd4e7a 100644
--- a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Config.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Config.kt
@@ -8,7 +8,11 @@ class Config(context: Context) : BaseConfig(context) {
fun newInstance(context: Context) = Config(context)
}
- var showClipboard: Boolean
- get() = prefs.getBoolean(SHOW_CLIPBOARD, true)
- set(showClipboard) = prefs.edit().putBoolean(SHOW_CLIPBOARD, showClipboard).apply()
+ var vibrateOnKeypress: Boolean
+ get() = prefs.getBoolean(VIBRATE_ON_KEYPRESS, true)
+ set(vibrateOnKeypress) = prefs.edit().putBoolean(VIBRATE_ON_KEYPRESS, vibrateOnKeypress).apply()
+
+ var showPopupOnKeypress: Boolean
+ get() = prefs.getBoolean(SHOW_POPUP_ON_KEYPRESS, true)
+ set(showPopupOnKeypress) = prefs.edit().putBoolean(SHOW_POPUP_ON_KEYPRESS, showPopupOnKeypress).apply()
}
diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Constants.kt
index cb22b9b..03d33cb 100644
--- a/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Constants.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/helpers/Constants.kt
@@ -8,4 +8,5 @@ const val SHIFT_ON_PERMANENT = 2
const val MAX_KEYS_PER_MINI_ROW = 5
// shared prefs
-const val SHOW_CLIPBOARD = "show_clipboard"
+const val VIBRATE_ON_KEYPRESS = "vibrate_on_keypress"
+const val SHOW_POPUP_ON_KEYPRESS = "show_popup_on_keypress"
diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt
index 736192a..95f476b 100644
--- a/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/services/SimpleKeyboardIME.kt
@@ -10,6 +10,7 @@ import android.view.inputmethod.EditorInfo.IME_ACTION_NONE
import android.view.inputmethod.ExtractedTextRequest
import com.simplemobiletools.commons.extensions.performHapticFeedback
import com.simplemobiletools.keyboard.R
+import com.simplemobiletools.keyboard.extensions.config
import com.simplemobiletools.keyboard.helpers.MyKeyboard
import com.simplemobiletools.keyboard.helpers.SHIFT_OFF
import com.simplemobiletools.keyboard.helpers.SHIFT_ON_ONE_CHAR
@@ -47,7 +48,7 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL
}
override fun onPress(primaryCode: Int) {
- if (primaryCode != 0) {
+ if (primaryCode != 0 && baseContext.config.vibrateOnKeypress) {
keyboardView?.performHapticFeedback()
}
}
diff --git a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt
index a31b1be..c2c1620 100644
--- a/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt
+++ b/app/src/main/kotlin/com/simplemobiletools/keyboard/views/MyKeyboardView.kt
@@ -551,8 +551,9 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
}
private fun handleClipboard() {
- if (context.config.showClipboard && mToolbarHolder != null && mPopupParent.id != R.id.mini_keyboard_view) {
- val clipboardContent = (context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager).primaryClip?.getItemAt(0)?.text?.trim()
+ if (mToolbarHolder != null && mPopupParent.id != R.id.mini_keyboard_view) {
+ val clipboardManager = (context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager)
+ val clipboardContent = clipboardManager.primaryClip?.getItemAt(0)?.text?.trim()
if (clipboardContent?.isNotEmpty() == true) {
mToolbarHolder?.apply {
clipboard_value.apply {
@@ -560,7 +561,10 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
removeUnderlines()
setOnClickListener {
mOnKeyboardActionListener!!.onText(clipboardContent.toString())
- performHapticFeedback()
+
+ if (context.config.vibrateOnKeypress) {
+ performHapticFeedback()
+ }
}
}
@@ -692,6 +696,10 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
}
private fun showPreview(keyIndex: Int) {
+ if (!context.config.showPopupOnKeypress) {
+ return
+ }
+
val oldKeyIndex = mCurrentKeyIndex
val previewPopup = mPreviewPopup
mCurrentKeyIndex = keyIndex
@@ -1255,6 +1263,10 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
private fun repeatKey(initialCall: Boolean): Boolean {
val key = mKeys[mRepeatKeyIndex]
if (!initialCall && key.code == KEYCODE_SPACE) {
+ if (!mIsLongPressingSpace && context.config.vibrateOnKeypress) {
+ performHapticFeedback()
+ }
+
mIsLongPressingSpace = true
} else {
detectAndSendKey(mCurrentKey, key.x, key.y, mLastTapTime)
diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml
index ace534c..df1de90 100644
--- a/app/src/main/res/layout/activity_settings.xml
+++ b/app/src/main/res/layout/activity_settings.xml
@@ -90,18 +90,34 @@
+
+
+
+
+
+
+ android:text="@string/show_popup" />