aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-07-06 15:03:29 -0700
committerAllan Wang <me@allanwang.ca>2017-07-06 15:03:29 -0700
commit6555a738c44d8734a8043e36711a6765c5c8d948 (patch)
treeeb057d78a9b73b5885dd86c5ce366c6c95f78208 /core/src
parentf0731069057bb52614ba184389eb1432d9ba7e16 (diff)
downloadkau-6555a738c44d8734a8043e36711a6765c5c8d948.tar.gz
kau-6555a738c44d8734a8043e36711a6765c5c8d948.tar.bz2
kau-6555a738c44d8734a8043e36711a6765c5c8d948.zip
Add copy to clipboard
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt10
-rw-r--r--core/src/main/res/values/strings_commons.xml14
2 files changed, 17 insertions, 7 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 21021e2..bc01919 100644
--- a/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt
+++ b/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt
@@ -2,6 +2,8 @@ package ca.allanwang.kau.utils
import android.app.Activity
import android.app.ActivityOptions
+import android.content.ClipData
+import android.content.ClipboardManager
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
@@ -162,4 +164,10 @@ inline val Context.isNavBarOnBottom: Boolean
return !canMove || dm.widthPixels < dm.heightPixels
}
-fun Context.hasPermission(permissions: String) = !buildIsMarshmallowAndUp || ContextCompat.checkSelfPermission(this, permissions) == PackageManager.PERMISSION_GRANTED \ No newline at end of file
+fun Context.hasPermission(permissions: String) = !buildIsMarshmallowAndUp || ContextCompat.checkSelfPermission(this, permissions) == PackageManager.PERMISSION_GRANTED
+
+fun Context.copyToClipboard(text: String, label: String = "Copied Text", showToast: Boolean = true) {
+ val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
+ clipboard.primaryClip = ClipData.newPlainText(label, text)
+ if (showToast) toast(R.string.kau_text_copied)
+} \ No newline at end of file
diff --git a/core/src/main/res/values/strings_commons.xml b/core/src/main/res/values/strings_commons.xml
index 0ca785d..fba49fe 100644
--- a/core/src/main/res/values/strings_commons.xml
+++ b/core/src/main/res/values/strings_commons.xml
@@ -4,6 +4,8 @@ Most resources are verbatim and x represents a formatted item
-->
<resources>
+ <string name="kau_about_app">About App</string>
+ <string name="kau_about_x">About %s</string>
<string name="kau_add_account">Add Account</string>
<string name="kau_amoled" translatable="false">AMOLED</string>
<string name="kau_back">Back</string>
@@ -33,6 +35,7 @@ Most resources are verbatim and x represents a formatted item
<string name="kau_maybe">Maybe</string>
<string name="kau_menu">Menu</string>
<string name="kau_no">No</string>
+ <string name="kau_no_results_found">No Results Found</string>
<string name="kau_none">None</string>
<string name="kau_ok">@android:string/ok</string>
<string name="kau_one_day">1 day</string>
@@ -40,18 +43,17 @@ Most resources are verbatim and x represents a formatted item
<string name="kau_play_store">Play Store</string>
<string name="kau_rate">Rate</string>
<string name="kau_report_bug">Report A Bug</string>
+ <string name="kau_search">Search</string>
<string name="kau_send_feedback">Send Feedback</string>
+ <string name="kau_send_via">Send via</string>
<string name="kau_settings">Settings</string>
+ <string name="kau_share">Share</string>
<string name="kau_thank_you">Thank You</string>
<string name="kau_uh_oh">Uh Oh</string>
+ <string name="kau_warning">Warning</string>
<string name="kau_x_days">%d days</string>
<string name="kau_x_hours">%d hours</string>
<string name="kau_x_minutes">%d minutes</string>
- <string name="kau_warning">Warning</string>
<string name="kau_yes">Yes</string>
- <string name="kau_search">Search</string>
- <string name="kau_no_results_found">No Results Found</string>
- <string name="kau_about_app">About App</string>
- <string name="kau_send_via">Send via</string>
- <string name="kau_about_x">About %s</string>
+ <string name="kau_text_copied">Text copied to clipboard.</string>
</resources>