aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/Changelog.md5
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/email/EmailBuilder.kt18
-rw-r--r--sample/build.gradle2
3 files changed, 17 insertions, 8 deletions
diff --git a/docs/Changelog.md b/docs/Changelog.md
index 080b100..36e87f5 100644
--- a/docs/Changelog.md
+++ b/docs/Changelog.md
@@ -1,6 +1,11 @@
# Changelog
## v1.4
+* Added about activities
+* Added animated fast item adapter
+* Added chained adapter
+* Added item animators
+* Ported some views over from Plaid
## v1.3
* Added kpref subitems
diff --git a/library/src/main/kotlin/ca/allanwang/kau/email/EmailBuilder.kt b/library/src/main/kotlin/ca/allanwang/kau/email/EmailBuilder.kt
index dff0f07..b03a620 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/email/EmailBuilder.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/email/EmailBuilder.kt
@@ -18,7 +18,7 @@ import ca.allanwang.kau.utils.string
/**
* Created by Allan Wang on 2017-06-20.
*/
-class EmailBuilder(@StringRes val emailId: Int, @StringRes val subjectId: Int) {
+class EmailBuilder(val email: String, val subject: String) {
var message: String = "Write here."
var deviceDetails: Boolean = true
var appInfo: Boolean = true
@@ -33,8 +33,8 @@ class EmailBuilder(@StringRes val emailId: Int, @StringRes val subjectId: Int) {
data class Package(val packageName: String, val appName: String)
fun execute(context: Context) {
- val intent = Intent(Intent.ACTION_VIEW, Uri.parse("mailto:" + context.string(emailId)))
- intent.putExtra(Intent.EXTRA_SUBJECT, context.string(subjectId))
+ val intent = Intent(Intent.ACTION_VIEW, Uri.parse("mailto:$email"))
+ intent.putExtra(Intent.EXTRA_SUBJECT, subject)
val emailBuilder = StringBuilder()
emailBuilder.append(message).append("\n\n")
if (deviceDetails) {
@@ -50,7 +50,7 @@ class EmailBuilder(@StringRes val emailId: Int, @StringRes val subjectId: Int) {
context.windowManager.defaultDisplay.getMetrics(metric)
deviceItems.put("Screen Dimensions", "${metric.widthPixels} x ${metric.heightPixels}")
}
- deviceItems.forEach { k, v -> emailBuilder.append("$k: $v\n") }
+ deviceItems.forEach { (k, v) -> emailBuilder.append("$k: $v\n") }
}
if (appInfo) {
try {
@@ -70,7 +70,7 @@ class EmailBuilder(@StringRes val emailId: Int, @StringRes val subjectId: Int) {
}
if (pairs.isNotEmpty()) emailBuilder.append("\n")
- pairs.forEach { k, v -> emailBuilder.append("$k: $v\n") }
+ pairs.forEach { (k, v) -> emailBuilder.append("$k: $v\n") }
if (footer != null)
emailBuilder.append("\n").append(footer)
@@ -80,8 +80,12 @@ class EmailBuilder(@StringRes val emailId: Int, @StringRes val subjectId: Int) {
}
}
-fun Context.sendEmail(@StringRes emailId: Int, @StringRes subjectId: Int, builder: EmailBuilder.() -> Unit = {}) {
- EmailBuilder(emailId, subjectId).apply {
+fun Context.sendEmail(@StringRes emailId: Int, @StringRes subjectId: Int, builder: EmailBuilder.() -> Unit = {})
+ = sendEmail(string(emailId), string(subjectId), builder)
+
+
+fun Context.sendEmail(email: String, subject: String, builder: EmailBuilder.() -> Unit = {}) {
+ EmailBuilder(email, subject).apply {
builder()
execute(this@sendEmail)
}
diff --git a/sample/build.gradle b/sample/build.gradle
index 78a3802..8429f11 100644
--- a/sample/build.gradle
+++ b/sample/build.gradle
@@ -34,7 +34,7 @@ dependencies {
})
testCompile 'junit:junit:4.12'
compile "com.mikepenz:google-material-typeface:${IICON_GOOGLE}.original@aar"
- compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
+ compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
repositories {
mavenCentral()