diff options
Diffstat (limited to 'library/src/main')
-rw-r--r-- | library/src/main/kotlin/ca/allanwang/kau/email/EmailBuilder.kt | 25 | ||||
-rw-r--r-- | library/src/main/res/values/strings_commons.xml | 9 |
2 files changed, 27 insertions, 7 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> |