diff options
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt index ca3e90b..ece10e1 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt @@ -163,4 +163,11 @@ fun Context.copyToClipboard(text: String, label: String = "Copied Text", showToa val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager clipboard.primaryClip = ClipData.newPlainText(label, text) if (showToast) toast(R.string.kau_text_copied) +} + +fun Context.shareText(text: String) { + val intent = Intent(Intent.ACTION_SEND) + intent.type = "text/plain" + intent.putExtra(Intent.EXTRA_TEXT, text) + startActivity(Intent.createChooser(intent, string(R.string.kau_share))) }
\ No newline at end of file |