From 45b231e1005ecc1624e301db11aa7fffca1b15b1 Mon Sep 17 00:00:00 2001 From: MM20 <15646950+MM2-0@users.noreply.github.com> Date: Sat, 7 Oct 2023 18:07:56 +0200 Subject: [PATCH] Tweak haptic feedback --- .../de/mm20/launcher2/ui/launcher/PullDownScaffold.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/PullDownScaffold.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/PullDownScaffold.kt index cc3e3620..3362e28b 100644 --- a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/PullDownScaffold.kt +++ b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/PullDownScaffold.kt @@ -63,6 +63,7 @@ import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalHapticFeedback import androidx.compose.ui.platform.LocalLayoutDirection import androidx.compose.ui.platform.LocalSoftwareKeyboardController +import androidx.compose.ui.platform.LocalView import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.Velocity @@ -295,12 +296,13 @@ fun PullDownScaffold( val keyboardController = LocalSoftwareKeyboardController.current val gestureManager = LocalGestureDetector.current val hapticFeedback = LocalHapticFeedback.current + val view = LocalView.current LaunchedEffect(isOverThreshold) { if (isOverThreshold) { - hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress) - } else { - hapticFeedback.performHapticFeedback(HapticFeedbackType.TextHandleMove) + view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY) + } else if (offsetY.value != 0f) { + view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY_RELEASE) } }