Add haptic feedback before actions (#1636)

* perform haptic before doing action

* Perform haptic feedback call in UI/main thread instead of IO

* Haptic feedback on both cases of long press action
This commit is contained in:
Cuong-Tran 2026-05-13 14:22:35 +07:00 committed by GitHub
parent 21cb1921a3
commit 19f8fa203d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 8 additions and 8 deletions

View file

@ -142,8 +142,8 @@ private fun LibraryUpdateErrorUiItem(
.combinedClickable( .combinedClickable(
onClick = onClick, onClick = onClick,
onLongClick = { onLongClick = {
onLongClick()
haptic.performHapticFeedback(HapticFeedbackType.LongPress) haptic.performHapticFeedback(HapticFeedbackType.LongPress)
onLongClick()
}, },
) )
.padding(horizontal = MaterialTheme.padding.medium), .padding(horizontal = MaterialTheme.padding.medium),

View file

@ -1372,8 +1372,8 @@ private fun LazyListScope.sharedChapterItems(
chapterSwipeStartAction = chapterSwipeStartAction, chapterSwipeStartAction = chapterSwipeStartAction,
chapterSwipeEndAction = chapterSwipeEndAction, chapterSwipeEndAction = chapterSwipeEndAction,
onLongClick = { onLongClick = {
onChapterSelected(item, !item.selected, true)
haptic.performHapticFeedback(HapticFeedbackType.LongPress) haptic.performHapticFeedback(HapticFeedbackType.LongPress)
onChapterSelected(item, !item.selected, true)
}, },
onClick = { onClick = {
onChapterItemClick( onChapterItemClick(

View file

@ -43,8 +43,8 @@ fun BaseMangaListItem(
onClick = onClickItem, onClick = onClickItem,
// KMK --> // KMK -->
onLongClick = { onLongClick = {
onLongClick()
haptic.performHapticFeedback(HapticFeedbackType.LongPress) haptic.performHapticFeedback(HapticFeedbackType.LongPress)
onLongClick()
}, },
// KMK <-- // KMK <--
) )

View file

@ -286,8 +286,8 @@ private fun UpdatesUiItem(
.combinedClickable( .combinedClickable(
onClick = onClick, onClick = onClick,
onLongClick = { onLongClick = {
onLongClick()
haptic.performHapticFeedback(HapticFeedbackType.LongPress) haptic.performHapticFeedback(HapticFeedbackType.LongPress)
onLongClick()
}, },
) )
.padding(top = if (isLeader) MaterialTheme.padding.small else 0.dp) .padding(top = if (isLeader) MaterialTheme.padding.small else 0.dp)

View file

@ -375,6 +375,7 @@ data class BrowseSourceScreen(
}, },
onMangaLongClick = { manga -> onMangaLongClick = { manga ->
// KMK --> // KMK -->
haptic.performHapticFeedback(HapticFeedbackType.LongPress)
if (bulkFavoriteState.selectionMode) { if (bulkFavoriteState.selectionMode) {
navigator.push(MangaScreen(manga.id, true)) navigator.push(MangaScreen(manga.id, true))
} else { } else {
@ -388,7 +389,6 @@ data class BrowseSourceScreen(
) )
else -> screenModel.addFavorite(manga) else -> screenModel.addFavorite(manga)
} }
haptic.performHapticFeedback(HapticFeedbackType.LongPress)
} }
} }
}, },

View file

@ -329,8 +329,8 @@ data object LibraryTab : Tab {
}.takeIf { state.showMangaContinueButton }, }.takeIf { state.showMangaContinueButton },
onToggleSelection = screenModel::toggleSelection, onToggleSelection = screenModel::toggleSelection,
onToggleRangeSelection = { category, manga -> onToggleRangeSelection = { category, manga ->
screenModel.toggleRangeSelection(category, manga)
haptic.performHapticFeedback(HapticFeedbackType.LongPress) haptic.performHapticFeedback(HapticFeedbackType.LongPress)
screenModel.toggleRangeSelection(category, manga)
}, },
onRefresh = { onClickRefresh(state.activeCategory) }, onRefresh = { onClickRefresh(state.activeCategory) },
onGlobalSearchClicked = { onGlobalSearchClicked = {

View file

@ -278,8 +278,8 @@ class MangaScreen(
onChapterClicked = { openChapter(context, it) }, onChapterClicked = { openChapter(context, it) },
onDownloadChapter = screenModel::runChapterDownloadActions.takeIf { !successState.source.isLocalOrStub() }, onDownloadChapter = screenModel::runChapterDownloadActions.takeIf { !successState.source.isLocalOrStub() },
onAddToLibraryClicked = { onAddToLibraryClicked = {
screenModel.toggleFavorite()
haptic.performHapticFeedback(HapticFeedbackType.LongPress) haptic.performHapticFeedback(HapticFeedbackType.LongPress)
screenModel.toggleFavorite()
}, },
// SY --> // SY -->
onWebViewClicked = { onWebViewClicked = {

View file

@ -127,6 +127,7 @@ class MangaDexFollowsScreen(private val sourceId: Long) : Screen() {
}, },
onMangaLongClick = { manga -> onMangaLongClick = { manga ->
// KMK --> // KMK -->
haptic.performHapticFeedback(HapticFeedbackType.LongPress)
if (bulkFavoriteState.selectionMode) { if (bulkFavoriteState.selectionMode) {
navigator.push(MangaScreen(manga.id, true)) navigator.push(MangaScreen(manga.id, true))
} else { } else {
@ -140,7 +141,6 @@ class MangaDexFollowsScreen(private val sourceId: Long) : Screen() {
) )
else -> screenModel.addFavorite(manga) else -> screenModel.addFavorite(manga)
} }
haptic.performHapticFeedback(HapticFeedbackType.LongPress)
} }
} }
}, },