-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: agreement urls * fix: tests * fix: according to comments * fix: data sell button text
- Loading branch information
Showing
18 changed files
with
329 additions
and
105 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
57 changes: 50 additions & 7 deletions
57
core/src/main/java/org/openedx/core/config/AgreementUrlsConfig.kt
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 |
---|---|---|
@@ -1,14 +1,57 @@ | ||
package org.openedx.core.config | ||
|
||
import android.net.Uri | ||
import com.google.gson.annotations.SerializedName | ||
import org.openedx.core.domain.model.Agreement | ||
import org.openedx.core.domain.model.AgreementUrls | ||
|
||
data class AgreementUrlsConfig( | ||
internal data class AgreementUrlsConfig( | ||
@SerializedName("PRIVACY_POLICY_URL") | ||
val privacyPolicyUrl: String = "", | ||
|
||
private val privacyPolicyUrl: String = "", | ||
@SerializedName("COOKIE_POLICY_URL") | ||
private val cookiePolicyUrl: String = "", | ||
@SerializedName("DATA_SELL_CONSENT_URL") | ||
private val dataSellConsentUrl: String = "", | ||
@SerializedName("TOS_URL") | ||
val tosUrl: String = "", | ||
private val tosUrl: String = "", | ||
@SerializedName("EULA_URL") | ||
private val eulaUrl: String = "", | ||
@SerializedName("SUPPORTED_LANGUAGES") | ||
private val supportedLanguages: List<String> = emptyList(), | ||
) { | ||
fun mapToDomain(): Agreement { | ||
val defaultAgreementUrls = AgreementUrls( | ||
privacyPolicyUrl = privacyPolicyUrl, | ||
cookiePolicyUrl = cookiePolicyUrl, | ||
dataSellConsentUrl = dataSellConsentUrl, | ||
tosUrl = tosUrl, | ||
eulaUrl = eulaUrl, | ||
supportedLanguages = supportedLanguages, | ||
) | ||
val agreementUrls = if (supportedLanguages.isNotEmpty()) { | ||
supportedLanguages.associateWith { | ||
AgreementUrls( | ||
privacyPolicyUrl = privacyPolicyUrl.appendLocale(it), | ||
cookiePolicyUrl = cookiePolicyUrl.appendLocale(it), | ||
dataSellConsentUrl = dataSellConsentUrl.appendLocale(it), | ||
tosUrl = tosUrl.appendLocale(it), | ||
eulaUrl = eulaUrl.appendLocale(it), | ||
supportedLanguages = supportedLanguages, | ||
) | ||
} | ||
} else { | ||
mapOf() | ||
} | ||
return Agreement(agreementUrls, defaultAgreementUrls) | ||
} | ||
|
||
@SerializedName("CONTACT_US_URL") | ||
val contactUsUrl: String = "", | ||
) | ||
private fun String.appendLocale(locale: String): String { | ||
if (this.isBlank()) return this | ||
val uri = Uri.parse(this) | ||
return Uri.Builder().scheme(uri.scheme) | ||
.authority(uri.authority) | ||
.appendPath(locale + uri.encodedPath) | ||
.build() | ||
.toString() | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
core/src/main/java/org/openedx/core/domain/model/AgreementUrls.kt
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.openedx.core.domain.model | ||
|
||
/** | ||
* Data class with information about user agreements URLs | ||
* | ||
* @param agreementUrls Map with keys from SUPPORTED_LANGUAGES config | ||
* @param defaultAgreementUrls AgreementUrls for default language ('en') | ||
*/ | ||
internal data class Agreement( | ||
private val agreementUrls: Map<String, AgreementUrls> = mapOf(), | ||
private val defaultAgreementUrls: AgreementUrls | ||
) { | ||
fun getAgreementForLocale(locale: String): AgreementUrls { | ||
return agreementUrls.getOrDefault(locale, defaultAgreementUrls) | ||
} | ||
} | ||
|
||
data class AgreementUrls( | ||
val privacyPolicyUrl: String = "", | ||
val cookiePolicyUrl: String = "", | ||
val dataSellConsentUrl: String = "", | ||
val tosUrl: String = "", | ||
val eulaUrl: String = "", | ||
val supportedLanguages: List<String> = emptyList(), | ||
) |
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
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 |
---|---|---|
|
@@ -2,12 +2,17 @@ API_HOST_URL: 'http://localhost:8000' | |
APPLICATION_ID: 'org.openedx.app' | ||
ENVIRONMENT_DISPLAY_NAME: 'Localhost' | ||
FEEDBACK_EMAIL_ADDRESS: '[email protected]' | ||
FAQ_URL: '' | ||
OAUTH_CLIENT_ID: 'OAUTH_CLIENT_ID' | ||
|
||
# Keep empty to hide setting | ||
AGREEMENT_URLS: | ||
PRIVACY_POLICY_URL: 'https://example.com/privacy' | ||
TOS_URL: 'https://example.com/tos' | ||
CONTACT_US_URL: 'https://example.com/contact' | ||
PRIVACY_POLICY_URL: '' | ||
COOKIE_POLICY_URL: '' | ||
DATA_SELL_CONSENT_URL: '' | ||
TOS_URL: '' | ||
EULA_URL: '' | ||
SUPPORTED_LANGUAGES: [ ] #en is defalut language | ||
|
||
DISCOVERY: | ||
TYPE: 'native' | ||
|
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 |
---|---|---|
|
@@ -2,12 +2,17 @@ API_HOST_URL: 'http://localhost:8000' | |
APPLICATION_ID: 'org.openedx.app' | ||
ENVIRONMENT_DISPLAY_NAME: 'Localhost' | ||
FEEDBACK_EMAIL_ADDRESS: '[email protected]' | ||
FAQ_URL: '' | ||
OAUTH_CLIENT_ID: 'OAUTH_CLIENT_ID' | ||
|
||
# Keep empty to hide setting | ||
AGREEMENT_URLS: | ||
PRIVACY_POLICY_URL: 'https://example.com/privacy' | ||
TOS_URL: 'https://example.com/tos' | ||
CONTACT_US_URL: 'https://example.com/contact' | ||
PRIVACY_POLICY_URL: '' | ||
COOKIE_POLICY_URL: '' | ||
DATA_SELL_CONSENT_URL: '' | ||
TOS_URL: '' | ||
EULA_URL: '' | ||
SUPPORTED_LANGUAGES: [ ] #en is defalut language | ||
|
||
DISCOVERY: | ||
TYPE: 'native' | ||
|
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 |
---|---|---|
|
@@ -2,12 +2,17 @@ API_HOST_URL: 'http://localhost:8000' | |
APPLICATION_ID: 'org.openedx.app' | ||
ENVIRONMENT_DISPLAY_NAME: 'Localhost' | ||
FEEDBACK_EMAIL_ADDRESS: '[email protected]' | ||
FAQ_URL: '' | ||
OAUTH_CLIENT_ID: 'OAUTH_CLIENT_ID' | ||
|
||
# Keep empty to hide setting | ||
AGREEMENT_URLS: | ||
PRIVACY_POLICY_URL: 'https://example.com/privacy' | ||
TOS_URL: 'https://example.com/tos' | ||
CONTACT_US_URL: 'https://example.com/contact' | ||
PRIVACY_POLICY_URL: '' | ||
COOKIE_POLICY_URL: '' | ||
DATA_SELL_CONSENT_URL: '' | ||
TOS_URL: '' | ||
EULA_URL: '' | ||
SUPPORTED_LANGUAGES: [ ] #en is defalut language | ||
|
||
DISCOVERY: | ||
TYPE: 'native' | ||
|
16 changes: 16 additions & 0 deletions
16
profile/src/main/java/org/openedx/profile/domain/model/Configuration.kt
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.openedx.profile.domain.model | ||
|
||
import org.openedx.core.domain.model.AgreementUrls | ||
|
||
/** | ||
* @param agreementUrls User agreement urls | ||
* @param faqUrl FAQ url | ||
* @param supportEmail Email address of support | ||
* @param versionName Version of the application (1.0.0) | ||
*/ | ||
data class Configuration( | ||
val agreementUrls: AgreementUrls, | ||
val faqUrl: String, | ||
val supportEmail: String, | ||
val versionName: String, | ||
) |
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
5 changes: 3 additions & 2 deletions
5
profile/src/main/java/org/openedx/profile/presentation/profile/ProfileUIState.kt
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
Oops, something went wrong.