aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-07-07 22:48:15 -0700
committerAllan Wang <me@allanwang.ca>2017-07-07 22:48:15 -0700
commitbb8ea417554d65ced6b3d4edab10ae54083228eb (patch)
tree17e7235f2b1ca19b5825b23e4439d7c73f52972d /core/src/main/kotlin
parentde194b96a8af2d13c15337be7ef092d9c4b6a098 (diff)
downloadkau-bb8ea417554d65ced6b3d4edab10ae54083228eb.tar.gz
kau-bb8ea417554d65ced6b3d4edab10ae54083228eb.tar.bz2
kau-bb8ea417554d65ced6b3d4edab10ae54083228eb.zip
Add share text fun
Diffstat (limited to 'core/src/main/kotlin')
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt7
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