From 8d300e3efd352bebf4ac0a66c128384c012e144e Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 8 Jul 2023 15:54:30 -0400 Subject: [PATCH] Tweak chapter swipe directions and icon color (cherry picked from commit 8cc42bce5a37c256edbddd4a618787dfec9c2118) # Conflicts: # app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt --- .../kanade/presentation/manga/MangaScreen.kt | 18 +++++++++--------- .../manga/components/MangaChapterListItem.kt | 13 +++++++------ .../settings/screen/SettingsLibraryScreen.kt | 4 ++-- .../kanade/tachiyomi/ui/manga/MangaScreen.kt | 2 +- .../tachiyomi/ui/manga/MangaScreenModel.kt | 4 ++-- .../library/service/LibraryPreferences.kt | 4 ++-- 6 files changed, 23 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt b/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt index 49b3941df..d407ad692 100644 --- a/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/manga/MangaScreen.kt @@ -111,8 +111,8 @@ fun MangaScreen( dateRelativeTime: Int, dateFormat: DateFormat, isTabletUi: Boolean, - chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, chapterSwipeStartAction: LibraryPreferences.ChapterSwipeAction, + chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, onBackClicked: () -> Unit, onChapterClicked: (Chapter) -> Unit, onDownloadChapter: ((List, ChapterDownloadAction) -> Unit)?, @@ -175,8 +175,8 @@ fun MangaScreen( snackbarHostState = snackbarHostState, dateRelativeTime = dateRelativeTime, dateFormat = dateFormat, - chapterSwipeEndAction = chapterSwipeEndAction, chapterSwipeStartAction = chapterSwipeStartAction, + chapterSwipeEndAction = chapterSwipeEndAction, onBackClicked = onBackClicked, onChapterClicked = onChapterClicked, onDownloadChapter = onDownloadChapter, @@ -219,8 +219,8 @@ fun MangaScreen( state = state, snackbarHostState = snackbarHostState, dateRelativeTime = dateRelativeTime, - chapterSwipeEndAction = chapterSwipeEndAction, chapterSwipeStartAction = chapterSwipeStartAction, + chapterSwipeEndAction = chapterSwipeEndAction, dateFormat = dateFormat, onBackClicked = onBackClicked, onChapterClicked = onChapterClicked, @@ -268,8 +268,8 @@ private fun MangaScreenSmallImpl( snackbarHostState: SnackbarHostState, dateRelativeTime: Int, dateFormat: DateFormat, - chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, chapterSwipeStartAction: LibraryPreferences.ChapterSwipeAction, + chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, onBackClicked: () -> Unit, onChapterClicked: (Chapter) -> Unit, onDownloadChapter: ((List, ChapterDownloadAction) -> Unit)?, @@ -547,8 +547,8 @@ private fun MangaScreenSmallImpl( chapters = chapters, dateRelativeTime = dateRelativeTime, dateFormat = dateFormat, - chapterSwipeEndAction = chapterSwipeEndAction, chapterSwipeStartAction = chapterSwipeStartAction, + chapterSwipeEndAction = chapterSwipeEndAction, // SY --> alwaysShowReadingProgress = state.alwaysShowReadingProgress, // SY <-- @@ -569,8 +569,8 @@ fun MangaScreenLargeImpl( snackbarHostState: SnackbarHostState, dateRelativeTime: Int, dateFormat: DateFormat, - chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, chapterSwipeStartAction: LibraryPreferences.ChapterSwipeAction, + chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, onBackClicked: () -> Unit, onChapterClicked: (Chapter) -> Unit, onDownloadChapter: ((List, ChapterDownloadAction) -> Unit)?, @@ -823,8 +823,8 @@ fun MangaScreenLargeImpl( chapters = chapters, dateRelativeTime = dateRelativeTime, dateFormat = dateFormat, - chapterSwipeEndAction = chapterSwipeEndAction, chapterSwipeStartAction = chapterSwipeStartAction, + chapterSwipeEndAction = chapterSwipeEndAction, // SY --> alwaysShowReadingProgress = state.alwaysShowReadingProgress, // SY <-- @@ -888,8 +888,8 @@ private fun LazyListScope.sharedChapterItems( chapters: List, dateRelativeTime: Int, dateFormat: DateFormat, - chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, chapterSwipeStartAction: LibraryPreferences.ChapterSwipeAction, + chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, // SY --> alwaysShowReadingProgress: Boolean, // SY <-- @@ -948,8 +948,8 @@ private fun LazyListScope.sharedChapterItems( downloadIndicatorEnabled = chapters.fastAll { !it.selected }, downloadStateProvider = { chapterItem.downloadState }, downloadProgressProvider = { chapterItem.downloadProgress }, - chapterSwipeEndAction = chapterSwipeEndAction, chapterSwipeStartAction = chapterSwipeStartAction, + chapterSwipeEndAction = chapterSwipeEndAction, onLongClick = { onChapterSelected(chapterItem, !chapterItem.selected, true, true) haptic.performHapticFeedback(HapticFeedbackType.LongPress) diff --git a/app/src/main/java/eu/kanade/presentation/manga/components/MangaChapterListItem.kt b/app/src/main/java/eu/kanade/presentation/manga/components/MangaChapterListItem.kt index cda1b40c7..17bda6ab7 100644 --- a/app/src/main/java/eu/kanade/presentation/manga/components/MangaChapterListItem.kt +++ b/app/src/main/java/eu/kanade/presentation/manga/components/MangaChapterListItem.kt @@ -22,6 +22,7 @@ import androidx.compose.material3.LocalContentColor import androidx.compose.material3.MaterialTheme import androidx.compose.material3.ProvideTextStyle import androidx.compose.material3.Text +import androidx.compose.material3.contentColorFor import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.LaunchedEffect @@ -71,8 +72,8 @@ fun MangaChapterListItem( downloadIndicatorEnabled: Boolean, downloadStateProvider: () -> Download.State, downloadProgressProvider: () -> Int, - chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, chapterSwipeStartAction: LibraryPreferences.ChapterSwipeAction, + chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction, onLongClick: () -> Unit, onClick: () -> Unit, onDownloadClick: ((ChapterDownloadAction) -> Unit)?, @@ -239,19 +240,19 @@ private fun getSwipeAction( onSwipe: () -> Unit, ): me.saket.swipe.SwipeAction? { return when (action) { - LibraryPreferences.ChapterSwipeAction.ToggleRead -> SwipeAction( + LibraryPreferences.ChapterSwipeAction.ToggleRead -> swipeAction( icon = if (!read) Icons.Outlined.Done else Icons.Outlined.RemoveDone, background = background, isUndo = read, onSwipe = onSwipe, ) - LibraryPreferences.ChapterSwipeAction.ToggleBookmark -> SwipeAction( + LibraryPreferences.ChapterSwipeAction.ToggleBookmark -> swipeAction( icon = if (!bookmark) Icons.Outlined.BookmarkAdd else Icons.Outlined.BookmarkRemove, background = background, isUndo = bookmark, onSwipe = onSwipe, ) - LibraryPreferences.ChapterSwipeAction.Download -> SwipeAction( + LibraryPreferences.ChapterSwipeAction.Download -> swipeAction( icon = when (downloadState) { Download.State.NOT_DOWNLOADED, Download.State.ERROR -> Icons.Outlined.Download Download.State.QUEUE, Download.State.DOWNLOADING -> Icons.Outlined.FileDownloadOff @@ -264,7 +265,7 @@ private fun getSwipeAction( } } -private fun SwipeAction( +private fun swipeAction( onSwipe: () -> Unit, icon: ImageVector, background: Color, @@ -275,7 +276,7 @@ private fun SwipeAction( Icon( modifier = Modifier.padding(16.dp), imageVector = icon, - tint = MaterialTheme.colorScheme.onSurface, + tint = contentColorFor(background), contentDescription = null, ) }, diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsLibraryScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsLibraryScreen.kt index 22214ee8e..dde002957 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsLibraryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsLibraryScreen.kt @@ -302,7 +302,7 @@ object SettingsLibraryScreen : SearchableSettings { title = stringResource(R.string.pref_chapter_swipe), preferenceItems = listOf( Preference.PreferenceItem.ListPreference( - pref = libraryPreferences.swipeEndAction(), + pref = libraryPreferences.swipeToStartAction(), title = stringResource(R.string.pref_chapter_swipe_end), entries = mapOf( LibraryPreferences.ChapterSwipeAction.Disabled to stringResource(R.string.disabled), @@ -312,7 +312,7 @@ object SettingsLibraryScreen : SearchableSettings { ), ), Preference.PreferenceItem.ListPreference( - pref = libraryPreferences.swipeStartAction(), + pref = libraryPreferences.swipeToEndAction(), title = stringResource(R.string.pref_chapter_swipe_start), entries = mapOf( LibraryPreferences.ChapterSwipeAction.Disabled to stringResource(R.string.disabled), diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreen.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreen.kt index 02f1edacd..24ec685ae 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreen.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreen.kt @@ -140,8 +140,8 @@ class MangaScreen( dateRelativeTime = screenModel.relativeTime, dateFormat = screenModel.dateFormat, isTabletUi = isTabletUi(), - chapterSwipeEndAction = screenModel.chapterSwipeEndAction, chapterSwipeStartAction = screenModel.chapterSwipeStartAction, + chapterSwipeEndAction = screenModel.chapterSwipeEndAction, onBackClicked = navigator::pop, onChapterClicked = { openChapter(context, it) }, onDownloadChapter = screenModel::runChapterDownloadActions.takeIf { !successState.source.isLocalOrStub() }, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt index 3b4d1fddf..805662532 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt @@ -186,8 +186,8 @@ class MangaInfoScreenModel( private val filteredChapters: List? get() = successState?.processedChapters - val chapterSwipeEndAction = libraryPreferences.swipeEndAction().get() - val chapterSwipeStartAction = libraryPreferences.swipeStartAction().get() + val chapterSwipeStartAction = libraryPreferences.swipeToEndAction().get() + val chapterSwipeEndAction = libraryPreferences.swipeToStartAction().get() val relativeTime by uiPreferences.relativeTime().asState(coroutineScope) val dateFormat by mutableStateOf(UiPreferences.dateFormat(uiPreferences.dateFormat().get())) diff --git a/domain/src/main/java/tachiyomi/domain/library/service/LibraryPreferences.kt b/domain/src/main/java/tachiyomi/domain/library/service/LibraryPreferences.kt index 13525186a..50169f61c 100644 --- a/domain/src/main/java/tachiyomi/domain/library/service/LibraryPreferences.kt +++ b/domain/src/main/java/tachiyomi/domain/library/service/LibraryPreferences.kt @@ -140,9 +140,9 @@ class LibraryPreferences( // region Swipe Actions - fun swipeEndAction() = preferenceStore.getEnum("pref_chapter_swipe_end_action", ChapterSwipeAction.ToggleBookmark) + fun swipeToStartAction() = preferenceStore.getEnum("pref_chapter_swipe_end_action", ChapterSwipeAction.ToggleBookmark) - fun swipeStartAction() = preferenceStore.getEnum("pref_chapter_swipe_start_action", ChapterSwipeAction.ToggleRead) + fun swipeToEndAction() = preferenceStore.getEnum("pref_chapter_swipe_start_action", ChapterSwipeAction.ToggleRead) // endregion