-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into fix/nav_issues
- Loading branch information
Showing
39 changed files
with
393 additions
and
193 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
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
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
8 changes: 8 additions & 0 deletions
8
core/src/main/java/org/openedx/core/data/model/CourseEnrollments.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,8 @@ | ||
package org.openedx.core.data.model | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class CourseEnrollments( | ||
@SerializedName("enrollments") | ||
val enrollments: DashboardCourseList | ||
) |
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
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
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.