Skip to content

Commit

Permalink
Merge pull request #950 from Automattic/update/direct-to-forums
Browse files Browse the repository at this point in the history
Direct free users to support forums
  • Loading branch information
ashiagr authored May 12, 2023
2 parents f45f1ad + 70d764d commit 1684a2d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
* Added the ability to see ratings for podcasts
([#951](https://github.com/Automattic/pocket-casts-android/pull/951)).

* Updates
* Link users to support forum from within the app
([#950](https://github.com/Automattic/pocket-casts-android/pull/950)).

7.38
-----
* Updates:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@ import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.Button
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.widget.Toolbar
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import au.com.shiftyjelly.pocketcasts.analytics.AnalyticsEvent
import au.com.shiftyjelly.pocketcasts.analytics.AnalyticsTrackerWrapper
import au.com.shiftyjelly.pocketcasts.analytics.FirebaseAnalyticsTracker
import au.com.shiftyjelly.pocketcasts.models.to.SubscriptionStatus
import au.com.shiftyjelly.pocketcasts.preferences.Settings
import au.com.shiftyjelly.pocketcasts.repositories.subscription.SubscriptionManager
import au.com.shiftyjelly.pocketcasts.repositories.support.Support
import au.com.shiftyjelly.pocketcasts.settings.status.StatusFragment
import au.com.shiftyjelly.pocketcasts.settings.viewmodel.HelpViewModel
Expand All @@ -42,9 +47,11 @@ import au.com.shiftyjelly.pocketcasts.views.R as VR
@AndroidEntryPoint
class HelpFragment : Fragment(), HasBackstack, Toolbar.OnMenuItemClickListener {

@Inject lateinit var analyticsTracker: AnalyticsTrackerWrapper
@Inject lateinit var settings: Settings
@Inject lateinit var theme: Theme
@Inject lateinit var subscriptionManager: SubscriptionManager
@Inject lateinit var support: Support
@Inject lateinit var theme: Theme

val viewModel by viewModels<HelpViewModel>()

Expand Down Expand Up @@ -98,7 +105,9 @@ class HelpFragment : Fragment(), HasBackstack, Toolbar.OnMenuItemClickListener {
loadingView = view.findViewById(VR.id.progress_circle)
layoutError = view.findViewById(VR.id.layoutLoadingError)

view.findViewById<Button>(VR.id.btnContactSupport).setOnClickListener { sendSupportEmail() }
view.findViewById<Button>(VR.id.btnContactSupport).setOnClickListener {
contactSupport()
}

return view
}
Expand Down Expand Up @@ -148,7 +157,9 @@ class HelpFragment : Fragment(), HasBackstack, Toolbar.OnMenuItemClickListener {

when {
url.lowercase(Locale.ROOT).contains("feedback") -> sendFeedbackEmail()
url.startsWith("mailto:[email protected]") || url.startsWith("mailto:[email protected]") -> sendSupportEmail()
url.startsWith("mailto:[email protected]") || url.startsWith("mailto:[email protected]") -> {
contactSupport()
}
url.startsWith("https://support.pocketcasts.com") -> {
if (!url.contains("device=android")) {
url += (if (url.contains("?")) "&" else "?") + "device=android"
Expand Down Expand Up @@ -208,12 +219,36 @@ class HelpFragment : Fragment(), HasBackstack, Toolbar.OnMenuItemClickListener {
}
}

analyticsTracker.track(AnalyticsEvent.SETTINGS_LEAVE_FEEDBACK)
FirebaseAnalyticsTracker.userGuideEmailFeedback()
}

private fun sendSupportEmail() {
private fun contactSupport() {
when (subscriptionManager.getCachedStatus()) {
null, is SubscriptionStatus.Free -> useForumPopup()
is SubscriptionStatus.Plus -> sendSupportEmail()
}

analyticsTracker.track(AnalyticsEvent.SETTINGS_GET_SUPPORT)
FirebaseAnalyticsTracker.userGuideEmailSupport()
}

private fun useForumPopup() {
val context = context ?: return
val forumUrl = "https://forums.pocketcasts.com/"
AlertDialog.Builder(context)
.setTitle(LR.string.settings_forums)
.setMessage(context.getString(LR.string.settings_forums_description, forumUrl))
.setPositiveButton(LR.string.settings_take_me_there) { _, _ ->
val intent =
Intent(Intent.ACTION_VIEW, Uri.parse(forumUrl))
startActivity(intent)
}
.show()
}

private fun sendSupportEmail() {
val context = context ?: return
viewLifecycleOwner.lifecycleScope.launch {
try {
val intent = support.shareLogs(
Expand All @@ -227,7 +262,5 @@ class HelpFragment : Fragment(), HasBackstack, Toolbar.OnMenuItemClickListener {
UiUtil.displayDialogNoEmailApp(context)
}
}

FirebaseAnalyticsTracker.userGuideEmailSupport()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,8 @@ enum class AnalyticsEvent(val key: String) {

/* Settings - Help */
SETTINGS_HELP_SHOWN("settings_help_shown"),
SETTINGS_LEAVE_FEEDBACK("settings_leave_feedback"),
SETTINGS_GET_SUPPORT("settings_get_support"),

/* Settings - Import - Export */
SETTINGS_IMPORT_SHOWN("settings_import_shown"),
Expand Down
3 changes: 3 additions & 0 deletions modules/services/localization/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,9 @@
<string name="settings_status_service_hosts_help">The most common cause is that you have an ad-blocker configured on your phone or network. You’ll need to unblock this domain to download podcasts. Please note Pocket Casts doesn’t host or choose where podcasts are hosted, that’s up to the author of the show and is out of our control.</string>
<string name="settings_status_service_support">Support</string>
<string name="settings_status_service_support_summary">Access to the support FAQ and contact us.</string>
<string name="settings_forums">Pocket Casts Forums</string>
<string name="settings_forums_description">Please go to Pocket Casts\' forums (%1$s) where our support team can help you.</string>
<string name="settings_take_me_there">Take me there</string>
<string name="settings_about_share_with_friends">Share with friends</string>
<string name="settings_about_share_with_friends_message">Hey! Here is a link to download the Pocket Casts app. I\'m really enjoying it and thought you might too. \nhttps://www.pocketcasts.com</string>
<string name="settings_about_rate_us">Rate us</string>
Expand Down

0 comments on commit 1684a2d

Please sign in to comment.