Add a Contact Me button in the preferences

This can not be tested on an emulator, requires a full device
This commit is contained in:
Bradlee Speice 2015-01-02 18:12:25 -05:00
parent 27c1c1aa5e
commit 04f6f1f49b
3 changed files with 43 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -11,4 +11,7 @@
<string name="error_book_refresh">Error refreshing. Try again later</string>
<string name="contact_developer_address">bspeice.nc@gmail.com</string>
<string name="contact_developer_subject">MinimalBible Feedback</string>
</resources>

View File

@ -25,4 +25,9 @@ but I will likely want to re-implement this in the future -->
android:key="defaultBookInitials"
android:title="Active Book" />
<org.bspeice.minimalbible.activity.settings.ContactPreference
android:key="null"
android:summary="Let the developers know what you think of the app!"
android:title="Contact Me" />
</PreferenceScreen>