diff options
author | Allan Wang <me@allanwang.ca> | 2017-07-07 22:48:15 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-07-07 22:48:15 -0700 |
commit | bb8ea417554d65ced6b3d4edab10ae54083228eb (patch) | |
tree | 17e7235f2b1ca19b5825b23e4439d7c73f52972d /core/src/main | |
parent | de194b96a8af2d13c15337be7ef092d9c4b6a098 (diff) | |
download | kau-bb8ea417554d65ced6b3d4edab10ae54083228eb.tar.gz kau-bb8ea417554d65ced6b3d4edab10ae54083228eb.tar.bz2 kau-bb8ea417554d65ced6b3d4edab10ae54083228eb.zip |
Add share text fun
Diffstat (limited to 'core/src/main')
-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 |