Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/gradle/androidx.core-core-ktx-1.15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cooltey authored Nov 4, 2024
2 parents 6da7a6c + 6f2e9e6 commit 6a0ac80
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
7 changes: 7 additions & 0 deletions app/src/main/java/org/wikipedia/page/LinkHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.wikipedia.bridge.CommunicationBridge.JSEventListener
import org.wikipedia.dataclient.WikiSite
import org.wikipedia.page.LinkMovementMethodExt.UrlHandlerWithText
import org.wikipedia.places.PlacesActivity
import org.wikipedia.util.FeedbackUtil
import org.wikipedia.util.StringUtil
import org.wikipedia.util.UriUtil
import org.wikipedia.util.log.L
Expand All @@ -31,6 +32,12 @@ abstract class LinkHandler(protected val context: Context) : JSEventListener, Ur

override fun onUrlClick(url: String, titleString: String?, linkText: String) {
var href = url
if (href.startsWith("mailto:")) {
val emailAddress = href.removePrefix("mailto:")
FeedbackUtil.composeEmail(context, emailAddress = emailAddress)
return
}

if (href.startsWith("//")) {
// for URLs without an explicit scheme, add our default scheme explicitly.
href = wikiSite.scheme() + ":" + href
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ internal class SettingsPreferenceLoader(fragment: PreferenceFragmentCompat) : Ba
}
findPreference(R.string.preference_key_send_feedback).onPreferenceClickListener =
Preference.OnPreferenceClickListener {
FeedbackUtil.composeFeedbackEmail(
FeedbackUtil.composeEmail(
activity,
"Android App ${BuildConfig.VERSION_NAME} Feedback",
deviceInformation()
subject = "Android App ${BuildConfig.VERSION_NAME} Feedback",
body = deviceInformation()
)
true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,9 @@ class SuggestedEditsImageRecsFragment : SuggestedEditsItemFragment(), MenuProvid
R.id.menu_report_feature -> {
ImageRecommendationsEvent.logAction("report_problem", "recommendedimagetoolbar",
getActionStringForAnalytics(), viewModel.langCode)
FeedbackUtil.composeFeedbackEmail(requireContext(),
getString(R.string.email_report_image_recommendations_subject),
getString(R.string.email_report_image_recommendations_body))
FeedbackUtil.composeEmail(requireContext(),
subject = getString(R.string.email_report_image_recommendations_subject),
body = getString(R.string.email_report_image_recommendations_body))
true
}
else -> false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ class SuggestedEditsRecentEditsFragment : Fragment(), MenuProvider {
}
R.id.menu_report_feature -> {
sendPatrollerExperienceEvent("top_menu_feedback_click", "pt_recent_changes")
FeedbackUtil.composeFeedbackEmail(requireContext(),
getString(R.string.email_report_patroller_tasks_subject),
getString(R.string.email_report_patroller_tasks_body))
FeedbackUtil.composeEmail(requireContext(),
subject = getString(R.string.email_report_patroller_tasks_subject),
body = getString(R.string.email_report_patroller_tasks_body))
true
}
else -> false
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/org/wikipedia/util/FeedbackUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,13 @@ object FeedbackUtil {
UriUtil.visitInExternalBrowser(context, Uri.parse(context.getString(urlStr)))
}

fun composeFeedbackEmail(context: Context, subject: String, body: String = "") {
fun composeEmail(context: Context,
emailAddress: String = context.getString(R.string.support_email),
subject: String = "",
body: String = "") {
val intent = Intent()
.setAction(Intent.ACTION_SENDTO)
.setData(Uri.parse("mailto:${context.getString(R.string.support_email)}?subject=${Uri.encode(subject)}&body=${Uri.encode(body)}"))
.setData(Uri.parse("mailto:$emailAddress?subject=${Uri.encode(subject)}&body=${Uri.encode(body)}"))
try {
context.startActivity(intent)
} catch (e: Exception) {
Expand Down

0 comments on commit 6a0ac80

Please sign in to comment.