From b5e183b09f4cb2f2177ff0dbc18448971f65ee26 Mon Sep 17 00:00:00 2001 From: FunkyMuse Date: Thu, 14 Sep 2023 12:05:45 +0200 Subject: [PATCH] feat: add on 2nd long press selection haptic feedback --- .../commons/compose/screens/ManageBlockedNumbersScreen.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/compose/screens/ManageBlockedNumbersScreen.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/compose/screens/ManageBlockedNumbersScreen.kt index 9171668b6..44dc4c9c7 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/compose/screens/ManageBlockedNumbersScreen.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/compose/screens/ManageBlockedNumbersScreen.kt @@ -26,6 +26,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.toArgb +import androidx.compose.ui.hapticfeedback.HapticFeedbackType import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalHapticFeedback import androidx.compose.ui.res.stringResource @@ -85,6 +86,7 @@ internal fun ManageBlockedNumbersScreen( ) { val startingPadding = remember { Modifier.padding(horizontal = 4.dp) } val selectedIds: MutableState> = rememberSaveable { mutableStateOf(emptySet()) } + val hapticFeedback = LocalHapticFeedback.current val isInActionMode by remember { derivedStateOf { selectedIds.value.isNotEmpty() } } val clearSelection = remember { { selectedIds.value = emptySet() } @@ -235,12 +237,14 @@ internal fun ManageBlockedNumbersScreen( when { indexOfLastValueInSelection == index -> {} indexOfLastValueInSelection < index -> { + hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress) selectedIds.value += blockedNumbers .subList(indexOfLastValueInSelection, index) .map { number -> number.id } } else -> { + hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress) selectedIds.value += blockedNumbers .subList(index, indexOfLastValueInSelection) .map { number -> number.id }