Skip to content

Commit

Permalink
Replace HapticFeedbackConstants.VIRTUAL_KEY with HapticFeedbackConsta…
Browse files Browse the repository at this point in the history
…nts.KEYBOARD_TAP
  • Loading branch information
bingzheung committed Sep 8, 2024
1 parent c8dab9d commit 58f7e25
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fun BackspaceKey(modifier: Modifier) {
},
onTap = {
view.playSoundEffect(SoundEffectConstants.CLICK)
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP)
context.backspace()
}
)
Expand All @@ -103,7 +103,7 @@ fun BackspaceKey(modifier: Modifier) {
offsetX += dragAmount
if (offsetX < -44f) {
view.playSoundEffect(SoundEffectConstants.CLICK)
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_RELEASE)
context.clearBuffer()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fun CangjieKey(letter: Char, modifier: Modifier) {
modifier = modifier
.clickable(interactionSource = interactionSource, indication = null) {
view.playSoundEffect(SoundEffectConstants.CLICK)
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP)
context.process(keyLetter)
}
.fillMaxSize(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fun GlobeKey(modifier: Modifier) {
modifier = modifier
.clickable(interactionSource = interactionSource, indication = null) {
view.playSoundEffect(SoundEffectConstants.CLICK)
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP)
val manager = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
manager.showInputMethodPicker()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fun LeftKey(modifier: Modifier) {
modifier = modifier
.clickable(interactionSource = interactionSource, indication = null) {
view.playSoundEffect(SoundEffectConstants.CLICK)
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP)
context.leftKey()
}
.fillMaxSize(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fun LetterKey(letter: String, modifier: Modifier) {
modifier = modifier
.clickable(interactionSource = interactionSource, indication = null) {
view.playSoundEffect(SoundEffectConstants.CLICK)
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP)
val text: String = if (keyboardCase.value.isLowercased()) letter else letter.uppercase()
context.process(text)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jyutping.jyutping.keyboard

import android.os.Build
import android.view.HapticFeedbackConstants
import android.view.SoundEffectConstants
import androidx.compose.foundation.background
Expand Down Expand Up @@ -40,7 +41,11 @@ fun ReturnKey(modifier: Modifier) {
modifier = modifier
.clickable(interactionSource = interactionSource, indication = null) {
view.playSoundEffect(SoundEffectConstants.CLICK)
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
view.performHapticFeedback(HapticFeedbackConstants.CONFIRM)
} else {
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP)
}
context.performReturn()
}
.fillMaxSize(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fun RightKey(modifier: Modifier) {
modifier = modifier
.clickable(interactionSource = interactionSource, indication = null) {
view.playSoundEffect(SoundEffectConstants.CLICK)
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP)
context.rightKey()
}
.fillMaxSize(),
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/jyutping/jyutping/keyboard/ShiftKey.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ fun ShiftKey(modifier: Modifier) {
detectTapGestures(
onDoubleTap = {
view.playSoundEffect(SoundEffectConstants.CLICK)
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP)
context.doubleShift()
},
onTap = {
view.playSoundEffect(SoundEffectConstants.CLICK)
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP)
context.shift()
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fun SpaceKey(modifier: Modifier) {
modifier = modifier
.clickable(interactionSource = interactionSource, indication = null) {
view.playSoundEffect(SoundEffectConstants.CLICK)
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP)
context.space()
}
.fillMaxSize(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fun StrokeKey(letter: Char, modifier: Modifier) {
modifier = modifier
.clickable(interactionSource = interactionSource, indication = null) {
view.playSoundEffect(SoundEffectConstants.CLICK)
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP)
context.process(keyLetter)
}
.fillMaxSize(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fun SymbolKey(symbol: String, modifier: Modifier) {
modifier = modifier
.clickable(interactionSource = interactionSource, indication = null) {
view.playSoundEffect(SoundEffectConstants.CLICK)
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP)
context.input(symbol)
}
.fillMaxSize(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fun TransformKey(destination: KeyboardForm, modifier: Modifier) {
modifier = modifier
.clickable(interactionSource = interactionSource, indication = null) {
view.playSoundEffect(SoundEffectConstants.CLICK)
view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY)
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP)
context.transformTo(destination)
}
.fillMaxSize(),
Expand Down

0 comments on commit 58f7e25

Please sign in to comment.