Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Make email clickable to send feedbacks #189

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading