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