mirror of
https://git.mihon.tech/mihonapp/mihon
synced 2024-11-21 12:45:44 +03:00
Add Copy Tracker URL on icon long press (#1101)
* Add Copy Tracker URL on icon long press Signed-off-by: Catt0s <5874051+mm12@users.noreply.github.com> * Add 'Copy To Clipboard' to tracker item menu Signed-off-by: Catt0s <5874051+mm12@users.noreply.github.com> * Add 'Copy link' to locales. Signed-off-by: Catt0s <5874051+mm12@users.noreply.github.com> * Implement code review suggestions > > Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> Signed-off-by: Catt0s <5874051+mm12@users.noreply.github.com> * Update app/src/main/java/eu/kanade/presentation/track/components/TrackLogoIcon.kt --------- Signed-off-by: Catt0s <5874051+mm12@users.noreply.github.com> Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
This commit is contained in:
parent
b1b15a93ee
commit
200d39e023
5 changed files with 28 additions and 1 deletions
|
@ -72,6 +72,7 @@ fun TrackInfoDialogHome(
|
|||
onNewSearch: (TrackItem) -> Unit,
|
||||
onOpenInBrowser: (TrackItem) -> Unit,
|
||||
onRemoved: (TrackItem) -> Unit,
|
||||
onCopyLink: (TrackItem) -> Unit,
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
|
@ -116,6 +117,7 @@ fun TrackInfoDialogHome(
|
|||
onNewSearch = { onNewSearch(item) },
|
||||
onOpenInBrowser = { onOpenInBrowser(item) },
|
||||
onRemoved = { onRemoved(item) },
|
||||
onCopyLink = { onCopyLink(item) },
|
||||
)
|
||||
} else {
|
||||
TrackInfoItemEmpty(
|
||||
|
@ -144,6 +146,7 @@ private fun TrackInfoItem(
|
|||
onNewSearch: () -> Unit,
|
||||
onOpenInBrowser: () -> Unit,
|
||||
onRemoved: () -> Unit,
|
||||
onCopyLink: () -> Unit,
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
Column {
|
||||
|
@ -153,6 +156,7 @@ private fun TrackInfoItem(
|
|||
TrackLogoIcon(
|
||||
tracker = tracker,
|
||||
onClick = onOpenInBrowser,
|
||||
onLongClick = onCopyLink,
|
||||
)
|
||||
Box(
|
||||
modifier = Modifier
|
||||
|
@ -179,6 +183,7 @@ private fun TrackInfoItem(
|
|||
TrackInfoItemMenu(
|
||||
onOpenInBrowser = onOpenInBrowser,
|
||||
onRemoved = onRemoved,
|
||||
onCopyLink = onCopyLink,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -287,6 +292,7 @@ private fun TrackInfoItemEmpty(
|
|||
private fun TrackInfoItemMenu(
|
||||
onOpenInBrowser: () -> Unit,
|
||||
onRemoved: () -> Unit,
|
||||
onCopyLink: () -> Unit,
|
||||
) {
|
||||
var expanded by remember { mutableStateOf(false) }
|
||||
Box(modifier = Modifier.wrapContentSize(Alignment.TopStart)) {
|
||||
|
@ -307,6 +313,13 @@ private fun TrackInfoItemMenu(
|
|||
expanded = false
|
||||
},
|
||||
)
|
||||
DropdownMenuItem(
|
||||
text = { Text(stringResource(MR.strings.action_copy_link)) },
|
||||
onClick = {
|
||||
onCopyLink()
|
||||
expanded = false
|
||||
},
|
||||
)
|
||||
DropdownMenuItem(
|
||||
text = { Text(stringResource(MR.strings.action_remove)) },
|
||||
onClick = {
|
||||
|
|
|
@ -56,6 +56,7 @@ internal class TrackInfoDialogHomePreviewProvider :
|
|||
onNewSearch = {},
|
||||
onOpenInBrowser = {},
|
||||
onRemoved = {},
|
||||
onCopyLink = {},
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -71,6 +72,7 @@ internal class TrackInfoDialogHomePreviewProvider :
|
|||
onNewSearch = {},
|
||||
onOpenInBrowser = {},
|
||||
onRemoved = {},
|
||||
onCopyLink = {},
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,10 @@ import tachiyomi.presentation.core.util.clickableNoIndication
|
|||
fun TrackLogoIcon(
|
||||
tracker: Tracker,
|
||||
onClick: (() -> Unit)? = null,
|
||||
onLongClick: (() -> Unit)? = null,
|
||||
) {
|
||||
val modifier = if (onClick != null) {
|
||||
Modifier.clickableNoIndication(onClick = onClick)
|
||||
Modifier.clickableNoIndication(onClick = onClick, onLongClick = onLongClick)
|
||||
} else {
|
||||
Modifier
|
||||
}
|
||||
|
@ -53,6 +54,7 @@ private fun TrackLogoIconPreviews(
|
|||
TrackLogoIcon(
|
||||
tracker = tracker,
|
||||
onClick = null,
|
||||
onLongClick = null,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ import eu.kanade.tachiyomi.data.track.Tracker
|
|||
import eu.kanade.tachiyomi.data.track.TrackerManager
|
||||
import eu.kanade.tachiyomi.data.track.model.TrackSearch
|
||||
import eu.kanade.tachiyomi.util.lang.convertEpochMillisZone
|
||||
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
||||
import eu.kanade.tachiyomi.util.system.openInBrowser
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
@ -170,6 +171,7 @@ data class TrackInfoDialogHomeScreen(
|
|||
),
|
||||
)
|
||||
},
|
||||
onCopyLink = { context.copyTrackerLink(it) },
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -183,6 +185,13 @@ data class TrackInfoDialogHomeScreen(
|
|||
}
|
||||
}
|
||||
|
||||
private fun Context.copyTrackerLink(trackItem: TrackItem) {
|
||||
val url = trackItem.track?.remoteUrl ?: return
|
||||
if (url.isNotBlank()) {
|
||||
copyToClipboard(url, url)
|
||||
}
|
||||
}
|
||||
|
||||
private class Model(
|
||||
private val mangaId: Long,
|
||||
private val sourceId: Long,
|
||||
|
|
|
@ -110,6 +110,7 @@
|
|||
<string name="action_open_in_browser">Open in browser</string>
|
||||
<string name="action_show_manga">Show entry</string>
|
||||
<string name="action_copy_to_clipboard">Copy to clipboard</string>
|
||||
<string name="action_copy_link">Copy link</string>
|
||||
<!-- Do not translate "WebView" -->
|
||||
<string name="action_open_in_web_view">Open in WebView</string>
|
||||
<string name="action_web_view" translatable="false">WebView</string>
|
||||
|
|
Loading…
Reference in a new issue