mirror of
https://github.com/SimpleMobileTools/Simple-Keyboard.git
synced 2025-06-05 21:49:26 +02:00
vibrate on pressing top toolbar buttons too
This commit is contained in:
@ -8,9 +8,7 @@ import android.view.View
|
|||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
import android.view.inputmethod.EditorInfo.IME_ACTION_NONE
|
import android.view.inputmethod.EditorInfo.IME_ACTION_NONE
|
||||||
import android.view.inputmethod.ExtractedTextRequest
|
import android.view.inputmethod.ExtractedTextRequest
|
||||||
import com.simplemobiletools.commons.extensions.performHapticFeedback
|
|
||||||
import com.simplemobiletools.keyboard.R
|
import com.simplemobiletools.keyboard.R
|
||||||
import com.simplemobiletools.keyboard.extensions.config
|
|
||||||
import com.simplemobiletools.keyboard.helpers.MyKeyboard
|
import com.simplemobiletools.keyboard.helpers.MyKeyboard
|
||||||
import com.simplemobiletools.keyboard.helpers.SHIFT_OFF
|
import com.simplemobiletools.keyboard.helpers.SHIFT_OFF
|
||||||
import com.simplemobiletools.keyboard.helpers.SHIFT_ON_ONE_CHAR
|
import com.simplemobiletools.keyboard.helpers.SHIFT_ON_ONE_CHAR
|
||||||
@ -48,8 +46,8 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onPress(primaryCode: Int) {
|
override fun onPress(primaryCode: Int) {
|
||||||
if (primaryCode != 0 && baseContext.config.vibrateOnKeypress) {
|
if (primaryCode != 0) {
|
||||||
keyboardView?.performHapticFeedback()
|
keyboardView?.vibrateIfNeeded()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,6 +323,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
mToolbarHolder!!.apply {
|
mToolbarHolder!!.apply {
|
||||||
settings_cog.setOnLongClickListener { context.toast(R.string.settings); true; }
|
settings_cog.setOnLongClickListener { context.toast(R.string.settings); true; }
|
||||||
settings_cog.setOnClickListener {
|
settings_cog.setOnClickListener {
|
||||||
|
vibrateIfNeeded()
|
||||||
Intent(context, SettingsActivity::class.java).apply {
|
Intent(context, SettingsActivity::class.java).apply {
|
||||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
context.startActivity(this)
|
context.startActivity(this)
|
||||||
@ -331,11 +332,13 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
|
|
||||||
pinned_clipboard_items.setOnLongClickListener { context.toast(R.string.clipboard); true; }
|
pinned_clipboard_items.setOnLongClickListener { context.toast(R.string.clipboard); true; }
|
||||||
pinned_clipboard_items.setOnClickListener {
|
pinned_clipboard_items.setOnClickListener {
|
||||||
|
vibrateIfNeeded()
|
||||||
mClipboardManagerHolder!!.clipboard_manager_holder.beVisible()
|
mClipboardManagerHolder!!.clipboard_manager_holder.beVisible()
|
||||||
}
|
}
|
||||||
|
|
||||||
clipboard_clear.setOnLongClickListener { context.toast(R.string.clear_clipboard_data); true; }
|
clipboard_clear.setOnLongClickListener { context.toast(R.string.clear_clipboard_data); true; }
|
||||||
clipboard_clear.setOnClickListener {
|
clipboard_clear.setOnClickListener {
|
||||||
|
vibrateIfNeeded()
|
||||||
clearClipboardContent()
|
clearClipboardContent()
|
||||||
toggleClipboardVisibility(false)
|
toggleClipboardVisibility(false)
|
||||||
}
|
}
|
||||||
@ -351,11 +354,18 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
|
|
||||||
mClipboardManagerHolder!!.apply {
|
mClipboardManagerHolder!!.apply {
|
||||||
clipboard_manager_close.setOnClickListener {
|
clipboard_manager_close.setOnClickListener {
|
||||||
|
vibrateIfNeeded()
|
||||||
mClipboardManagerHolder!!.clipboard_manager_holder.beGone()
|
mClipboardManagerHolder!!.clipboard_manager_holder.beGone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun vibrateIfNeeded() {
|
||||||
|
if (context.config.vibrateOnKeypress) {
|
||||||
|
performHapticFeedback()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the state of the shift key of the keyboard, if any.
|
* Sets the state of the shift key of the keyboard, if any.
|
||||||
* @param shifted whether or not to enable the state of the shift key
|
* @param shifted whether or not to enable the state of the shift key
|
||||||
@ -575,10 +585,7 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
removeUnderlines()
|
removeUnderlines()
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
mOnKeyboardActionListener!!.onText(clipboardContent.toString())
|
mOnKeyboardActionListener!!.onText(clipboardContent.toString())
|
||||||
|
vibrateIfNeeded()
|
||||||
if (context.config.vibrateOnKeypress) {
|
|
||||||
performHapticFeedback()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1277,8 +1284,8 @@ class MyKeyboardView @JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
private fun repeatKey(initialCall: Boolean): Boolean {
|
private fun repeatKey(initialCall: Boolean): Boolean {
|
||||||
val key = mKeys[mRepeatKeyIndex]
|
val key = mKeys[mRepeatKeyIndex]
|
||||||
if (!initialCall && key.code == KEYCODE_SPACE) {
|
if (!initialCall && key.code == KEYCODE_SPACE) {
|
||||||
if (!mIsLongPressingSpace && context.config.vibrateOnKeypress) {
|
if (!mIsLongPressingSpace) {
|
||||||
performHapticFeedback()
|
vibrateIfNeeded()
|
||||||
}
|
}
|
||||||
|
|
||||||
mIsLongPressingSpace = true
|
mIsLongPressingSpace = true
|
||||||
|
Reference in New Issue
Block a user