Minor refactor

This commit is contained in:
tarsin committed 2022-12-23 19:12:39 +08:00
1 parent 70be405032
commit e43cd0a039
2 files changed
+6 -4

No files matched your search

@@ -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<String> = 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())
@@ -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 {