Skip to content

Commit

Permalink
Merge pull request #104 from CrisisCleanup/localizations
Browse files Browse the repository at this point in the history
Add TOS and Privacy localizations
  • Loading branch information
hueachilles authored Feb 26, 2024
2 parents b551f76 + c011cb8 commit 11f241c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
7 changes: 4 additions & 3 deletions app/src/main/java/com/crisiscleanup/MainActivityViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class MainActivityViewModel @Inject constructor(
private set

val termsOfServiceUrl = "${appSettingsProvider.baseUrl}/terms?view=plain"
val privacyPolicyUrl = "${appSettingsProvider.baseUrl}/privacy?view=plain"
var hasAcceptedTerms by mutableStateOf(false)
private set
var isAcceptingTerms by mutableStateOf(false)
Expand Down Expand Up @@ -271,7 +272,7 @@ class MainActivityViewModel @Inject constructor(

if (!isAcceptingTerms) {
acceptTermsErrorMessage =
translator("~~You must check the box accepting the terms of service.")
translator("termsConditionsModal.must_check_box")
return
}

Expand All @@ -286,9 +287,9 @@ class MainActivityViewModel @Inject constructor(
accountDataRefresher.updateAcceptedTerms()
} else {
val errorMessage = if (networkMonitor.isOnline.first()) {
translator("~~Something went wrong. Please try again later.")
translator("termsConditionsModal.online_but_error")
} else {
translator("~~Connect to the internet and try again.")
translator("termsConditionsModal.offline_error")
}
acceptTermsErrorMessage = errorMessage
}
Expand Down
14 changes: 8 additions & 6 deletions app/src/main/java/com/crisiscleanup/ui/AcceptTermsView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import com.crisiscleanup.core.designsystem.LocalAppTranslator
import com.crisiscleanup.core.designsystem.component.BusyButton
import com.crisiscleanup.core.designsystem.component.CrisisCleanupAlertDialog
import com.crisiscleanup.core.designsystem.component.CrisisCleanupTextButton
import com.crisiscleanup.core.designsystem.component.LinkifyUrlText
import com.crisiscleanup.core.designsystem.component.LinkifyHtmlText
import com.crisiscleanup.core.designsystem.component.cancelButtonColors
import com.crisiscleanup.core.designsystem.theme.LocalFontStyles
import com.crisiscleanup.core.designsystem.theme.listItemModifier
Expand All @@ -34,6 +34,7 @@ import com.crisiscleanup.core.designsystem.theme.primaryRedColor
@Composable
internal fun AcceptTermsView(
termsOfServiceUrl: String,
privacyPolicyUrl: String,
isLoading: Boolean,
isAcceptingTerms: Boolean,
setAcceptingTerms: (Boolean) -> Unit,
Expand All @@ -51,7 +52,7 @@ internal fun AcceptTermsView(
Box {
Column(modifier) {
Text(
t("~~Using the Crisis Cleanup mobile app requires agreement with the following terms."),
t("termsConditionsModal.must_agree_to_use_ccu"),
// TODO Common dimensions
Modifier
.padding(16.dp)
Expand Down Expand Up @@ -90,9 +91,10 @@ internal fun AcceptTermsView(
modifier = Modifier.testTag("acceptTermsAcceptToggle"),
enabled = enable,
)
val acceptText = t("~~I accept the terms of service from {terms_url}")
val acceptText = t("termsConditionsModal.accept_toc_privacy")
.replace("{terms_url}", termsOfServiceUrl)
LinkifyUrlText(
.replace("{privacy_url}", privacyPolicyUrl)
LinkifyHtmlText(
acceptText,
Modifier.testTag("acceptTermsAcceptText"),
)
Expand Down Expand Up @@ -148,10 +150,10 @@ private fun ConfirmRejectTermsDialog(
) {
val t = LocalAppTranslator.current
CrisisCleanupAlertDialog(
title = t("~~Review decision"),
title = t("termsConditionsModal.are_you_sure"),
textContent = {
Text(
t("~~Rejecting the terms of service will log you out from the app. You will not be able to use the app unless you log back in and accept the terms of service."),
t("termsConditionsModal.if_reject_cannot_use"),
Modifier.testTag("rejectTermsConfirmText"),
)
},
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/crisiscleanup/ui/CrisisCleanupApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ private fun BoxScope.LoadedContent(
AcceptTermsContent(
snackbarHostState,
viewModel.termsOfServiceUrl,
viewModel.privacyPolicyUrl,
isLoading,
viewModel.isAcceptingTerms,
setAcceptingTerms,
Expand Down Expand Up @@ -261,6 +262,7 @@ private fun AuthenticateContent(
private fun AcceptTermsContent(
snackbarHostState: SnackbarHostState,
termsOfServiceUrl: String,
privacyPolicyUrl: String,
isLoading: Boolean,
isAcceptingTerms: Boolean,
setAcceptingTerms: (Boolean) -> Unit,
Expand All @@ -279,6 +281,7 @@ private fun AcceptTermsContent(
) { padding ->
AcceptTermsView(
termsOfServiceUrl,
privacyPolicyUrl,
isLoading,
isAcceptingTerms = isAcceptingTerms,
setAcceptingTerms = setAcceptingTerms,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ class LoginWithPhoneViewModel @Inject constructor(

InitiatePhoneLoginResult.PhoneNotRegistered -> {
errorMessage =
translator("~~$phoneNumber is not registered. Enter a registered phone number and try again.")
translator("loginWithPhone.phone_number_not_registered")
.replace("phoneNumber", phoneNumber)
}

else -> {
Expand Down

0 comments on commit 11f241c

Please sign in to comment.