diff --git a/app/src/main/java/com/hippo/ehviewer/ui/GalleryInfoBottomSheet.kt b/app/src/main/java/com/hippo/ehviewer/ui/GalleryInfoBottomSheet.kt index a7a6a37fc..928a1171c 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/GalleryInfoBottomSheet.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/GalleryInfoBottomSheet.kt @@ -30,6 +30,7 @@ import com.hippo.ehviewer.client.EhUrl import com.hippo.ehviewer.client.EhUtils import com.hippo.ehviewer.client.data.GalleryDetail import com.hippo.util.addTextToClipboard +import com.hippo.util.tellClipboard class GalleryInfoBottomSheet(detail: GalleryDetail) : BottomSheetDialogFragment() { private var mKeys: ArrayList = arrayListOf() @@ -117,10 +118,7 @@ class GalleryInfoBottomSheet(detail: GalleryDetail) : BottomSheetDialogFragment( if (position == INDEX_PARENT) { UrlOpener.openUrl(context, mValues[position], true) } else { - activity?.addTextToClipboard( - mValues[position], - false, - ) + requireActivity() tellClipboard mValues[position] if (position == INDEX_URL) { // Save it to avoid detect the gallery Settings.putClipboardTextHashCode(mValues[position].hashCode()) diff --git a/app/src/main/java/com/hippo/util/ClipboardUtil.kt b/app/src/main/java/com/hippo/util/ClipboardUtil.kt index 8dc7e664e..f01fec827 100644 --- a/app/src/main/java/com/hippo/util/ClipboardUtil.kt +++ b/app/src/main/java/com/hippo/util/ClipboardUtil.kt @@ -34,6 +34,10 @@ fun Context.getClipboardManager(): ClipboardManager { return getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager } +infix fun Context.tellClipboard(text: String?) { + addTextToClipboard(text, false) +} + fun Context.addTextToClipboard(text: String?, isSensitive: Boolean) { getClipboardManager().apply { setPrimaryClip(ClipData.newPlainText(null, text).apply {