Skip to content

Commit

Permalink
feat: Feedback Form button on the Settings Screen (#21)
Browse files Browse the repository at this point in the history
Fixes: LEARNER-10132
  • Loading branch information
HamzaIsrar12 authored Jul 26, 2024
1 parent c041655 commit d21009c
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 1 deletion.
4 changes: 4 additions & 0 deletions core/src/main/java/org/openedx/core/data/model/AppConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ data class AppConfig(

@SerializedName("iap_config")
val iapConfig: IAPConfig = IAPConfig(),

@SerializedName("feedback_form_url")
val feedbackFormUrl: String = "",
) {
fun mapToDomain(): DomainAppConfig {
return DomainAppConfig(
courseDatesCalendarSync = calendarSyncConfig.mapToDomain(),
iapConfig = iapConfig.mapToDomain(),
feedbackFormUrl = feedbackFormUrl,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import java.io.Serializable
data class AppConfig(
val courseDatesCalendarSync: CourseDatesCalendarSync,
val iapConfig: IAPConfig = IAPConfig(),
val feedbackFormUrl: String = "",
) : Serializable

data class CourseDatesCalendarSync(
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
<string name="core_error_unknown_error">Something went wrong</string>
<string name="core_error_try_again">Try again</string>
<string name="core_privacy_policy">Privacy Policy</string>
<string name="core_cookie_policy" translatable="false">Cookie policy</string>
<string name="core_cookie_policy" translatable="false">Cookie Policy</string>
<string name="core_data_sell" translatable="false">Do not sell my personal information</string>
<string name="core_faq" translatable="false">View FAQ</string>
<string name="core_terms_of_use">Terms of Use</string>
<string name="core_help_us_improve">Help us Improve</string>
<string name="core_profile">Profile</string>
<string name="core_cancel">Cancel</string>
<string name="core_search">Search</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import org.openedx.core.domain.model.AgreementUrls
* @param isIAPEnabled In App Purchase is enabled or not
* @param agreementUrls User agreement urls
* @param faqUrl FAQ url
* @param feedbackFormUrl URL of the learner feedback form
* @param supportEmail Email address of support
* @param versionName Version of the application (1.0.0)
*/
data class Configuration(
val isIAPEnabled: Boolean,
val agreementUrls: AgreementUrls,
val faqUrl: String,
val feedbackFormUrl: String,
val supportEmail: String,
val versionName: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ enum class ProfileAnalyticsEvent(val eventName: String, val biValue: String) {
"Profile:FAQ Clicked",
"edx.bi.app.profile.faq.clicked"
),
FEEDBACK_FORM_CLICKED(
"Profile:Feedback Form Clicked",
"edx.bi.app.profile.feedback_form.clicked"
),
TERMS_OF_USE_CLICKED(
"Profile:Terms of Use Clicked",
"edx.bi.app.profile.terms_of_use.clicked"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ class SettingsFragment : Fragment() {
SettingsScreenAction.RestorePurchaseClick -> {
viewModel.restorePurchase()
}

SettingsScreenAction.FeedbackFormClick -> {
viewModel.feedbackFormClick()
}
}
},
onIAPAction = { action, iapException ->
Expand Down Expand Up @@ -162,5 +166,6 @@ internal interface SettingsScreenAction {
object ManageAccountClick : SettingsScreenAction
object CalendarSettingsClick : SettingsScreenAction
object RestorePurchaseClick : SettingsScreenAction
object FeedbackFormClick : SettingsScreenAction
}

Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,17 @@ private fun SupportInfoSection(
backgroundColor = MaterialTheme.appColors.cardViewBackground
) {
Column(Modifier.fillMaxWidth()) {
if (uiState.configuration.feedbackFormUrl.isNotBlank()) {
val uriHandler = LocalUriHandler.current
SettingsItem(
text = stringResource(id = R.string.core_help_us_improve),
external = true,
) {
uriHandler.openUri(uiState.configuration.feedbackFormUrl)
onAction(SettingsScreenAction.FeedbackFormClick)
}
SettingsDivider()
}
if (uiState.configuration.supportEmail.isNotBlank()) {
SettingsItem(text = stringResource(id = R.string.core_contact_support)) {
onAction(SettingsScreenAction.SupportClick)
Expand Down Expand Up @@ -717,6 +728,7 @@ private val mockConfiguration = Configuration(
agreementUrls = AgreementUrls(),
faqUrl = "https://example.com/faq",
supportEmail = "[email protected]",
feedbackFormUrl = "www.feedback.com",
versionName = mockAppData.versionName,
isIAPEnabled = true,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class SettingsViewModel(
isIAPEnabled = corePreferences.appConfig.iapConfig.isEnabled,
agreementUrls = config.getAgreement(Locale.current.language),
faqUrl = config.getFaqUrl(),
feedbackFormUrl = corePreferences.appConfig.feedbackFormUrl,
supportEmail = config.getFeedbackEmailAddress(),
versionName = appData.versionName,
)
Expand Down Expand Up @@ -184,6 +185,10 @@ class SettingsViewModel(
logProfileEvent(ProfileAnalyticsEvent.FAQ_CLICKED)
}

fun feedbackFormClick() {
logProfileEvent(ProfileAnalyticsEvent.FEEDBACK_FORM_CLICKED)
}

fun termsOfUseClicked(fragmentManager: FragmentManager) {
router.navigateToWebContent(
fm = fragmentManager,
Expand Down

0 comments on commit d21009c

Please sign in to comment.