mirror of
https://github.com/MinimalBible/MinimalBible
synced 2025-07-04 15:25:14 -04:00
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:
@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user