From 04f6f1f49b544ebc1219880c25ead98bd6e14c70 Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Fri, 2 Jan 2015 18:12:25 -0500 Subject: [PATCH] Add a Contact Me button in the preferences This can not be tested on an emulator, requires a full device --- .../activity/settings/ContactPreference.kt | 35 +++++++++++++++++++ app/src/main/res/values/strings.xml | 3 ++ app/src/main/res/xml/preferences.xml | 5 +++ 3 files changed, 43 insertions(+) create mode 100644 app/src/main/kotlin/org/bspeice/minimalbible/activity/settings/ContactPreference.kt diff --git a/app/src/main/kotlin/org/bspeice/minimalbible/activity/settings/ContactPreference.kt b/app/src/main/kotlin/org/bspeice/minimalbible/activity/settings/ContactPreference.kt new file mode 100644 index 0000000..ae50da0 --- /dev/null +++ b/app/src/main/kotlin/org/bspeice/minimalbible/activity/settings/ContactPreference.kt @@ -0,0 +1,35 @@ +package org.bspeice.minimalbible.activity.settings + +import android.content.Context +import android.util.AttributeSet +import android.preference.Preference +import android.content.Intent +import org.bspeice.minimalbible.R +import android.os.Build +import android.net.Uri + +class ContactPreference(val ctx: Context, val attrs: AttributeSet) +: Preference(ctx, attrs), Preference.OnPreferenceClickListener { + + { + setOnPreferenceClickListener(this); + } + + override fun onPreferenceClick(preference: Preference?): Boolean { + val address = ctx.getString(R.string.contact_developer_address) + val pInfo = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0) + + + val i = Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", address, null)) + i.putExtra(Intent.EXTRA_SUBJECT, ctx.getString(R.string.contact_developer_subject)) + i.putExtra(Intent.EXTRA_TEXT, """ + +Useful information for the developer: +Build code: ${pInfo.versionCode} +Build name: ${pInfo.versionName} +Android SDK: ${Build.VERSION.SDK_INT}""") + ctx.startActivity(i) + + return true; + } +} diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index baa503e..a6ed412 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -11,4 +11,7 @@ Error refreshing. Try again later + bspeice.nc@gmail.com + MinimalBible Feedback + diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 71fd5b8..c2d2d14 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -25,4 +25,9 @@ but I will likely want to re-implement this in the future --> android:key="defaultBookInitials" android:title="Active Book" /> + + \ No newline at end of file