From 38c6702b8f88c4e9b0920804df769b86aafd336f Mon Sep 17 00:00:00 2001 From: zbue <108109611+zbue@users.noreply.github.com> Date: Tue, 1 Nov 2022 05:23:00 +0800 Subject: [PATCH] Perform haptic feedback where appropriate (#8378) --- .../presentation/components/ChapterDownloadIndicator.kt | 9 ++++++++- .../java/eu/kanade/presentation/library/LibraryScreen.kt | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/components/ChapterDownloadIndicator.kt b/app/src/main/java/eu/kanade/presentation/components/ChapterDownloadIndicator.kt index e17fe46759..1ccda54aa5 100644 --- a/app/src/main/java/eu/kanade/presentation/components/ChapterDownloadIndicator.kt +++ b/app/src/main/java/eu/kanade/presentation/components/ChapterDownloadIndicator.kt @@ -26,6 +26,8 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.composed import androidx.compose.ui.graphics.Color +import androidx.compose.ui.hapticfeedback.HapticFeedbackType +import androidx.compose.ui.platform.LocalHapticFeedback import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.Role @@ -239,9 +241,14 @@ private fun Modifier.commonClickable( onLongClick: () -> Unit, onClick: () -> Unit, ) = composed { + val haptic = LocalHapticFeedback.current + this.combinedClickable( enabled = enabled, - onLongClick = onLongClick, + onLongClick = { + onLongClick() + haptic.performHapticFeedback(HapticFeedbackType.LongPress) + }, onClick = onClick, role = Role.Button, interactionSource = remember { MutableInteractionSource() }, diff --git a/app/src/main/java/eu/kanade/presentation/library/LibraryScreen.kt b/app/src/main/java/eu/kanade/presentation/library/LibraryScreen.kt index c9efd2e7c2..1fc4799943 100644 --- a/app/src/main/java/eu/kanade/presentation/library/LibraryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/library/LibraryScreen.kt @@ -6,6 +6,8 @@ import androidx.compose.material.icons.outlined.HelpOutline import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier +import androidx.compose.ui.hapticfeedback.HapticFeedbackType +import androidx.compose.ui.platform.LocalHapticFeedback import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.util.fastAll import eu.kanade.domain.category.model.Category @@ -40,6 +42,8 @@ fun LibraryScreen( onClickRefresh: (Category?) -> Boolean, onClickOpenRandomManga: () -> Unit, ) { + val haptic = LocalHapticFeedback.current + Scaffold( topBar = { scrollBehavior -> val title by presenter.getToolbarTitle() @@ -101,7 +105,10 @@ fun LibraryScreen( onChangeCurrentPage = { presenter.activeCategory = it }, onMangaClicked = onMangaClicked, onToggleSelection = { presenter.toggleSelection(it) }, - onToggleRangeSelection = { presenter.toggleRangeSelection(it) }, + onToggleRangeSelection = { + presenter.toggleRangeSelection(it) + haptic.performHapticFeedback(HapticFeedbackType.LongPress) + }, onRefresh = onClickRefresh, onGlobalSearchClicked = onGlobalSearchClicked, getNumberOfMangaForCategory = { presenter.getMangaCountForCategory(it) },