Skip to content

Commit

Permalink
Move terms and privacy URLs to single source of truth
Browse files Browse the repository at this point in the history
  • Loading branch information
hueachilles committed Mar 11, 2024
1 parent 3b0f0b6 commit 585f2ef
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/com/crisiscleanup/MainActivityViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ class MainActivityViewModel @Inject constructor(
var isAccountExpired by mutableStateOf(false)
private set

val termsOfServiceUrl = "${appSettingsProvider.baseUrl}/terms?view=plain"
val privacyPolicyUrl = "${appSettingsProvider.baseUrl}/privacy?view=plain"
val termsOfServiceUrl = appSettingsProvider.termsOfServiceUrl
val privacyPolicyUrl = appSettingsProvider.privacyPolicyUrl
var hasAcceptedTerms by mutableStateOf(false)
private set
var isAcceptingTerms by mutableStateOf(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ interface AppSettingsProvider {
val baseUrl: String
val mapsApiKey: String

val termsOfServiceUrl: String
val privacyPolicyUrl: String

val debugEmail: String
val debugPassword: String
}
Expand All @@ -19,6 +22,9 @@ class SecretsAppSettingsProvider @Inject constructor() : AppSettingsProvider {
override val mapsApiKey: String
get() = BuildConfig.MAPS_API_KEY

override val termsOfServiceUrl = "$baseUrl/terms?view=plain"
override val privacyPolicyUrl = "$baseUrl/privacy?view=plain"

override val debugEmail: String
get() = BuildConfig.DEBUG_EMAIL_ADDRESS
override val debugPassword: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,13 @@ internal fun MenuScreen(
t("publicNav.terms"),
Modifier
.listItemPadding()
.clickable { uriHandler.openUri("https://crisiscleanup.org/terms") },
.clickable { uriHandler.openUri(viewModel.termsOfServiceUrl) },
)
Text(
t("nav.privacy"),
Modifier
.listItemPadding()
.clickable { uriHandler.openUri("https://crisiscleanup.org/privacy") },
.clickable { uriHandler.openUri(viewModel.privacyPolicyUrl) },
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.crisiscleanup.feature.menu
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.crisiscleanup.core.common.AppEnv
import com.crisiscleanup.core.common.AppSettingsProvider
import com.crisiscleanup.core.common.AppVersionProvider
import com.crisiscleanup.core.common.DatabaseVersionProvider
import com.crisiscleanup.core.common.KeyResourceTranslator
Expand Down Expand Up @@ -42,6 +43,7 @@ class MenuViewModel @Inject constructor(
private val accountDataRefresher: AccountDataRefresher,
private val appVersionProvider: AppVersionProvider,
private val appPreferencesRepository: LocalAppPreferencesRepository,
appSettingsProvider: AppSettingsProvider,
private val appEnv: AppEnv,
private val syncPuller: SyncPuller,
private val databaseVersionProvider: DatabaseVersionProvider,
Expand All @@ -51,6 +53,9 @@ class MenuViewModel @Inject constructor(
val isDebuggable = appEnv.isDebuggable
val isNotProduction = appEnv.isNotProduction

val termsOfServiceUrl = appSettingsProvider.termsOfServiceUrl
val privacyPolicyUrl = appSettingsProvider.privacyPolicyUrl

val loadSelectIncidents = LoadSelectIncidents(
incidentsRepository = incidentsRepository,
accountDataRepository = accountDataRepository,
Expand Down

0 comments on commit 585f2ef

Please sign in to comment.