Implement copying of Manga URL to Clipboard (#8587)

feat: Implement copying of Manga URL to Clipboard
This commit is contained in:
Joseph Olugbohunmi 2022-11-22 05:09:23 +01:00 committed by GitHub
parent 2a2c6cee5f
commit ef3a6c80a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 0 deletions

View File

@ -80,6 +80,7 @@ fun MangaScreen(
onDownloadChapter: ((List<ChapterItem>, ChapterDownloadAction) -> Unit)?, onDownloadChapter: ((List<ChapterItem>, ChapterDownloadAction) -> Unit)?,
onAddToLibraryClicked: () -> Unit, onAddToLibraryClicked: () -> Unit,
onWebViewClicked: (() -> Unit)?, onWebViewClicked: (() -> Unit)?,
onWebViewLongClicked: (() -> Unit)?,
onTrackingClicked: (() -> Unit)?, onTrackingClicked: (() -> Unit)?,
onTagClicked: (String) -> Unit, onTagClicked: (String) -> Unit,
onFilterButtonClicked: () -> Unit, onFilterButtonClicked: () -> Unit,
@ -116,6 +117,7 @@ fun MangaScreen(
onDownloadChapter = onDownloadChapter, onDownloadChapter = onDownloadChapter,
onAddToLibraryClicked = onAddToLibraryClicked, onAddToLibraryClicked = onAddToLibraryClicked,
onWebViewClicked = onWebViewClicked, onWebViewClicked = onWebViewClicked,
onWebViewLongClicked = onWebViewLongClicked,
onTrackingClicked = onTrackingClicked, onTrackingClicked = onTrackingClicked,
onTagClicked = onTagClicked, onTagClicked = onTagClicked,
onFilterClicked = onFilterButtonClicked, onFilterClicked = onFilterButtonClicked,
@ -144,6 +146,7 @@ fun MangaScreen(
onDownloadChapter = onDownloadChapter, onDownloadChapter = onDownloadChapter,
onAddToLibraryClicked = onAddToLibraryClicked, onAddToLibraryClicked = onAddToLibraryClicked,
onWebViewClicked = onWebViewClicked, onWebViewClicked = onWebViewClicked,
onWebViewLongClicked = onWebViewLongClicked,
onTrackingClicked = onTrackingClicked, onTrackingClicked = onTrackingClicked,
onTagClicked = onTagClicked, onTagClicked = onTagClicked,
onFilterButtonClicked = onFilterButtonClicked, onFilterButtonClicked = onFilterButtonClicked,
@ -175,6 +178,7 @@ private fun MangaScreenSmallImpl(
onDownloadChapter: ((List<ChapterItem>, ChapterDownloadAction) -> Unit)?, onDownloadChapter: ((List<ChapterItem>, ChapterDownloadAction) -> Unit)?,
onAddToLibraryClicked: () -> Unit, onAddToLibraryClicked: () -> Unit,
onWebViewClicked: (() -> Unit)?, onWebViewClicked: (() -> Unit)?,
onWebViewLongClicked: (() -> Unit)?,
onTrackingClicked: (() -> Unit)?, onTrackingClicked: (() -> Unit)?,
onTagClicked: (String) -> Unit, onTagClicked: (String) -> Unit,
onFilterClicked: () -> Unit, onFilterClicked: () -> Unit,
@ -332,6 +336,7 @@ private fun MangaScreenSmallImpl(
trackingCount = state.trackingCount, trackingCount = state.trackingCount,
onAddToLibraryClicked = onAddToLibraryClicked, onAddToLibraryClicked = onAddToLibraryClicked,
onWebViewClicked = onWebViewClicked, onWebViewClicked = onWebViewClicked,
onWebViewLongClicked = onWebViewLongClicked,
onTrackingClicked = onTrackingClicked, onTrackingClicked = onTrackingClicked,
onEditCategory = onEditCategoryClicked, onEditCategory = onEditCategoryClicked,
) )
@ -381,6 +386,7 @@ fun MangaScreenLargeImpl(
onDownloadChapter: ((List<ChapterItem>, ChapterDownloadAction) -> Unit)?, onDownloadChapter: ((List<ChapterItem>, ChapterDownloadAction) -> Unit)?,
onAddToLibraryClicked: () -> Unit, onAddToLibraryClicked: () -> Unit,
onWebViewClicked: (() -> Unit)?, onWebViewClicked: (() -> Unit)?,
onWebViewLongClicked: (() -> Unit)?,
onTrackingClicked: (() -> Unit)?, onTrackingClicked: (() -> Unit)?,
onTagClicked: (String) -> Unit, onTagClicked: (String) -> Unit,
onFilterButtonClicked: () -> Unit, onFilterButtonClicked: () -> Unit,
@ -525,6 +531,7 @@ fun MangaScreenLargeImpl(
trackingCount = state.trackingCount, trackingCount = state.trackingCount,
onAddToLibraryClicked = onAddToLibraryClicked, onAddToLibraryClicked = onAddToLibraryClicked,
onWebViewClicked = onWebViewClicked, onWebViewClicked = onWebViewClicked,
onWebViewLongClicked = onWebViewLongClicked,
onTrackingClicked = onTrackingClicked, onTrackingClicked = onTrackingClicked,
onEditCategory = onEditCategoryClicked, onEditCategory = onEditCategoryClicked,
) )

View File

@ -162,6 +162,7 @@ fun MangaActionRow(
trackingCount: Int, trackingCount: Int,
onAddToLibraryClicked: () -> Unit, onAddToLibraryClicked: () -> Unit,
onWebViewClicked: (() -> Unit)?, onWebViewClicked: (() -> Unit)?,
onWebViewLongClicked: (() -> Unit)?,
onTrackingClicked: (() -> Unit)?, onTrackingClicked: (() -> Unit)?,
onEditCategory: (() -> Unit)?, onEditCategory: (() -> Unit)?,
) { ) {
@ -196,6 +197,7 @@ fun MangaActionRow(
icon = Icons.Outlined.Public, icon = Icons.Outlined.Public,
color = defaultActionButtonColor, color = defaultActionButtonColor,
onClick = onWebViewClicked, onClick = onWebViewClicked,
onLongClick = onWebViewLongClicked,
) )
} }
} }

View File

@ -61,6 +61,7 @@ import eu.kanade.tachiyomi.ui.manga.track.TrackInfoDialogHomeScreen
import eu.kanade.tachiyomi.ui.reader.ReaderActivity import eu.kanade.tachiyomi.ui.reader.ReaderActivity
import eu.kanade.tachiyomi.ui.updates.UpdatesController import eu.kanade.tachiyomi.ui.updates.UpdatesController
import eu.kanade.tachiyomi.ui.webview.WebViewActivity import eu.kanade.tachiyomi.ui.webview.WebViewActivity
import eu.kanade.tachiyomi.util.system.copyToClipboard
import eu.kanade.tachiyomi.util.system.toShareIntent import eu.kanade.tachiyomi.util.system.toShareIntent
import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.system.toast
@ -101,6 +102,7 @@ class MangaScreen(
haptic.performHapticFeedback(HapticFeedbackType.LongPress) haptic.performHapticFeedback(HapticFeedbackType.LongPress)
}, },
onWebViewClicked = { openMangaInWebView(context, screenModel.manga, screenModel.source) }.takeIf { isHttpSource }, onWebViewClicked = { openMangaInWebView(context, screenModel.manga, screenModel.source) }.takeIf { isHttpSource },
onWebViewLongClicked = { copyMangaUrl(context, screenModel.manga, screenModel.source) }.takeIf { isHttpSource },
onTrackingClicked = screenModel::showTrackDialog.takeIf { successState.trackingAvailable }, onTrackingClicked = screenModel::showTrackDialog.takeIf { successState.trackingAvailable },
onTagClicked = { performGenreSearch(router, it, screenModel.source!!) }, onTagClicked = { performGenreSearch(router, it, screenModel.source!!) },
onFilterButtonClicked = screenModel::showSettingsDialog, onFilterButtonClicked = screenModel::showSettingsDialog,
@ -326,4 +328,14 @@ class MangaScreen(
val controller = SearchController(manga) val controller = SearchController(manga)
router.pushController(controller) router.pushController(controller)
} }
/**
* Copy Manga URL to Clipboard
*/
private fun copyMangaUrl(context: Context, manga_: Manga?, source_: Source?) {
val manga = manga_ ?: return
val source = source_ as? HttpSource ?: return
val url = source.getMangaUrl(manga.toSManga())
context.copyToClipboard(url, url)
}
} }