-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #950 from Automattic/update/direct-to-forums
Direct free users to support forums
- Loading branch information
Showing
4 changed files
with
48 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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>() | ||
|
||
|
@@ -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 | ||
} | ||
|
@@ -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" | ||
|
@@ -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( | ||
|
@@ -227,7 +262,5 @@ class HelpFragment : Fragment(), HasBackstack, Toolbar.OnMenuItemClickListener { | |
UiUtil.displayDialogNoEmailApp(context) | ||
} | ||
} | ||
|
||
FirebaseAnalyticsTracker.userGuideEmailSupport() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters