aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/email/EmailBuilder.kt25
-rw-r--r--library/src/main/res/values/strings_commons.xml9
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt2
-rw-r--r--sample/src/main/res/menu/menu_main.xml7
-rw-r--r--sample/src/main/res/values/strings.xml2
5 files changed, 37 insertions, 8 deletions
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 1553757..ed3b928 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/email/EmailBuilder.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/email/EmailBuilder.kt
@@ -1,11 +1,13 @@
package ca.allanwang.kau.email
+import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Build
import android.support.annotation.StringRes
+import android.util.DisplayMetrics
import ca.allanwang.kau.R
import ca.allanwang.kau.logging.KL
import ca.allanwang.kau.utils.isAppInstalled
@@ -20,10 +22,13 @@ class EmailBuilder(@StringRes val emailId: Int, @StringRes val subjectId: Int) {
var deviceDetails: Boolean = true
var appInfo: Boolean = true
var footer: String? = null
+ private val pairs: MutableMap<String, String> = mutableMapOf()
private val packages: MutableList<Package> = mutableListOf()
fun checkPackage(packageName: String, appName: String) = packages.add(Package(packageName, appName))
+ fun addItem(key: String, value: String) = pairs.put(key, value)
+
data class Package(val packageName: String, val appName: String)
fun execute(context: Context) {
@@ -31,31 +36,41 @@ class EmailBuilder(@StringRes val emailId: Int, @StringRes val subjectId: Int) {
intent.putExtra(Intent.EXTRA_SUBJECT, context.string(subjectId))
val emailBuilder = StringBuilder()
emailBuilder.append(message).append("\n\n")
- if (deviceDetails)
+ if (deviceDetails) {
emailBuilder.append("\nOS Version: ").append(System.getProperty("os.version")).append("(").append(Build.VERSION.INCREMENTAL).append(")")
.append("\nOS API Level: ").append(Build.VERSION.SDK_INT)
.append("\nDevice: ").append(Build.DEVICE)
.append("\nManufacturer: ").append(Build.MANUFACTURER)
.append("\nModel (and Product): ").append(Build.MODEL).append(" (").append(Build.PRODUCT).append(")")
- .append("\n")
-
+ if (context is Activity) {
+ val metric = DisplayMetrics()
+ context.windowManager.defaultDisplay.getMetrics(metric)
+ emailBuilder.append("\nScreen Dimensions: ${metric.widthPixels} x ${metric.heightPixels}")
+ }
+ emailBuilder.append("\n")
+ }
if (appInfo) {
try {
val appInfo = context.packageManager.getPackageInfo(context.packageName, 0)
- emailBuilder.append("\nApp Version Name: ").append(appInfo.versionName)
+ emailBuilder.append("\nApp: ").append(context.packageName)
+ .append("\nApp Version Name: ").append(appInfo.versionName)
.append("\nApp Version Code: ").append(appInfo.versionCode).append("\n")
} catch (e: PackageManager.NameNotFoundException) {
KL.e("EmailBuilder packageInfo not found")
}
}
+ if (packages.isNotEmpty()) emailBuilder.append("\n")
packages.forEach {
if (context.isAppInstalled(it.packageName))
emailBuilder.append(String.format("\n%s is installed", it.appName))
}
+ if (pairs.isNotEmpty()) emailBuilder.append("\n")
+ pairs.forEach { k, v -> emailBuilder.append("$k: $v\n") }
+
if (footer != null)
- emailBuilder.append("\n\n").append(footer)
+ emailBuilder.append("\n").append(footer)
intent.putExtra(Intent.EXTRA_TEXT, emailBuilder.toString())
context.startActivity(Intent.createChooser(intent, context.resources.getString(R.string.kau_send_via)))
diff --git a/library/src/main/res/values/strings_commons.xml b/library/src/main/res/values/strings_commons.xml
index 760d22e..2198564 100644
--- a/library/src/main/res/values/strings_commons.xml
+++ b/library/src/main/res/values/strings_commons.xml
@@ -4,21 +4,26 @@ Most resources are verbatim and x represents a formatted item
-->
<resources>
+ <string name="kau_amoled" translatable="false">AMOLED</string>
<string name="kau_back">Back</string>
<string name="kau_cancel">Cancel</string>
<string name="kau_changelog">Changelog</string>
<string name="kau_close">Close</string>
<string name="kau_contact_us">Contact Us</string>
- <string name="kau_done">Done</string>
+ <string name="kau_custom">Custom</string>
+ <string name="kau_dark">Dark</string>
+ <string name="kau_default">Default</string>
<string name="kau_do_not_show_again">Do not show again</string>
+ <string name="kau_done">Done</string>
<string name="kau_error">Error</string>
<string name="kau_exit">Exit</string>
<string name="kau_exit_confirmation">Are you sure you want to exit?</string>
<string name="kau_exit_confirmation_x">Are you sure you want to exit %s?</string>
<string name="kau_great">Great</string>
+ <string name="kau_light">Light</string>
<string name="kau_login">Login</string>
<string name="kau_logout">Logout</string>
- <string name="kau_lorem_ipsum">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</string>
+ <string name="kau_lorem_ipsum" translatable="false">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</string>
<string name="kau_maybe">Maybe</string>
<string name="kau_no">No</string>
<string name="kau_none">None</string>
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
index a03857a..8867a00 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
@@ -3,6 +3,7 @@ package ca.allanwang.kau.sample
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
+import ca.allanwang.kau.email.sendEmail
import ca.allanwang.kau.kpref.KPrefActivity
import ca.allanwang.kau.kpref.KPrefAdapterBuilder
import ca.allanwang.kau.utils.*
@@ -103,6 +104,7 @@ class MainActivity : KPrefActivity() {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.action_settings -> startActivity(AnimActivity::class.java, clearStack = true)
+ R.id.action_email -> sendEmail(R.string.your_email, R.string.your_subject)
else -> return super.onOptionsItemSelected(item)
}
return true
diff --git a/sample/src/main/res/menu/menu_main.xml b/sample/src/main/res/menu/menu_main.xml
index 3725b18..caafd48 100644
--- a/sample/src/main/res/menu/menu_main.xml
+++ b/sample/src/main/res/menu/menu_main.xml
@@ -5,7 +5,12 @@
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
- android:title="Settings"
+ android:title="@string/kau_settings"
+ app:showAsAction="never" />
+ <item
+ android:id="@+id/action_email"
+ android:orderInCategory="2100"
+ android:title="@string/kau_send_feedback"
app:showAsAction="never" />
</menu>
diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml
index 7399593..049a395 100644
--- a/sample/src/main/res/values/strings.xml
+++ b/sample/src/main/res/values/strings.xml
@@ -15,4 +15,6 @@
<string name="color_custom_alpha">This selector allows for custom colors with alpha values</string>
<string name="text">Text Pref</string>
<string name="text_desc">Saves the text</string>
+ <string name="your_email">your.email@here.com</string>
+ <string name="your_subject">Your subject</string>
</resources>