diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt index b79e783dd0..12b95d7619 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt @@ -167,17 +167,20 @@ inline fun ExtendedFloatingActionButton.shrinkOnScroll(recycler: RecyclerView): * * @param items List of strings that are shown as individual chips. * @param onClick Optional on click listener for each chip. + * @param onLongClick Optional on long click listener for each chip. */ inline fun ChipGroup.setChips( items: List?, - noinline onClick: (item: String) -> Unit = {} + noinline onClick: ((item: String) -> Unit)? = null, + noinline onLongClick: ((item: String) -> Unit)? = null ) { removeAllViews() items?.forEach { item -> val chip = Chip(context).apply { text = item - setOnClickListener { onClick(item) } + if (onClick != null) { setOnClickListener { onClick(item) } } + if (onLongClick != null) { setOnLongClickListener { onLongClick(item); true } } } addView(chip) diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/MangaSummaryView.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/MangaSummaryView.kt index d16b814d51..39adc161c8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/MangaSummaryView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/MangaSummaryView.kt @@ -64,8 +64,9 @@ class MangaSummaryView @JvmOverloads constructor( } fun setTags(items: List?, onClick: (item: String) -> Unit) { - binding.tagChipsShrunk.setChips(items, onClick) - binding.tagChipsExpanded.setChips(items, onClick) + listOfNotNull(binding.tagChipsShrunk, binding.tagChipsExpanded).forEach { chips -> + chips.setChips(items, onClick) { tag -> context.copyToClipboard(tag, tag) } + } } private fun updateExpandState() = binding.apply {