Skip to content

Commit

Permalink
feat: Make email clickable to send feedbacks (#189)
Browse files Browse the repository at this point in the history
Signed-off-by: starry-shivam <[email protected]>
  • Loading branch information
starry-shivam authored Jun 28, 2024
1 parent cee017d commit 0fbbd0d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/com/starry/myne/helpers/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ object Constants {
const val UNKNOWN_ERR = "unknown-error"

// URLs
const val DEV_EMAIL = "[email protected]"
const val DEV_GITHUB_URL = "https://github.com/starry-shivam"
const val DEV_TELEGRAM_URL = "https://t.me/starryboi"
const val PROJECT_CONTRIBUTORS = "https://github.com/Pool-Of-Tears/Myne/graphs/contributors"
Expand Down
21 changes: 21 additions & 0 deletions app/src/main/java/com/starry/myne/helpers/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,27 @@ object Utils {
}
}

/**
* Opens an email client with the specified email address and subject.
*
* @param context The context to use.
* @param email The email address to send the email to.
* @param subject The subject of the email.
*/
fun openEmail(context: Context, email: String, subject: String) {
val emailIntent = Intent(Intent.ACTION_SENDTO).apply {
data = Uri.parse("mailto:")
putExtra(Intent.EXTRA_EMAIL, arrayOf(email))
putExtra(Intent.EXTRA_SUBJECT, subject)
}
try {
context.startActivity(emailIntent)
} catch (exc: ActivityNotFoundException) {
exc.printStackTrace()
context.getString(R.string.error).toToast(context)
}
}

/**
* Check if the device is running on MIUI.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,18 @@ private fun DeveloperCard(context: Context) {
Spacer(modifier = Modifier.height(4.dp))

Text(
text = stringResource(id = R.string.dev_email),
text = Constants.DEV_EMAIL,
fontSize = 16.sp,
fontFamily = figeronaFont,
fontWeight = FontWeight.Medium,
color = MaterialTheme.colorScheme.onBackground,
modifier = Modifier.clickable {
Utils.openEmail(
context = context,
email = Constants.DEV_EMAIL,
subject = "Myne Feedback (v${BuildConfig.VERSION_NAME})"
)
}
)

Spacer(modifier = Modifier.height(6.dp))
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@
<string name="about_desc">A Free &amp; Open Source Android application to download ebooks from the Project Gutenberg.</string>
<string name="developed_by">Developed By</string>
<string name="dev_name" translatable="false">Starry Shivam</string>
<string name="dev_email" translatable="false">[email protected]</string>
<string name="project_contributors">Project Contributors</string>
<string name="project_contributors_desc">Meet our wonderful contributors.</string>
<string name="useful_links">Useful Links</string>
Expand Down

0 comments on commit 0fbbd0d

Please sign in to comment.