Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into fix/nav_issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dixidroid committed Jan 10, 2024
2 parents 78c6fdc + 42f518a commit 396b09d
Show file tree
Hide file tree
Showing 39 changed files with 393 additions and 193 deletions.
10 changes: 10 additions & 0 deletions app/src/main/java/org/openedx/app/AnalyticsManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ class AnalyticsManager(
logEvent(Event.COOKIE_POLICY_CLICKED)
}

override fun dataSellClickedEvent() {
logEvent(Event.DATE_SELL_CLICKED)
}

override fun faqClickedEvent() {
logEvent(Event.FAQ_CLICKED)
}

override fun emailSupportClickedEvent() {
logEvent(Event.EMAIL_SUPPORT_CLICKED)
}
Expand Down Expand Up @@ -421,6 +429,8 @@ private enum class Event(val eventName: String) {
PRIVACY_POLICY_CLICKED("Privacy_Policy_Clicked"),
TERMS_OF_USE_CLICKED("Terms_Of_Use_Clicked"),
COOKIE_POLICY_CLICKED("Cookie_Policy_Clicked"),
DATE_SELL_CLICKED("Data_Sell_Clicked"),
FAQ_CLICKED("FAQ_Clicked"),
EMAIL_SUPPORT_CLICKED("Email_Support_Clicked"),
COURSE_ENROLL_CLICKED("Course_Enroll_Clicked"),
COURSE_ENROLL_SUCCESS("Course_Enroll_Success"),
Expand Down
10 changes: 2 additions & 8 deletions app/src/main/java/org/openedx/app/AppRouter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.openedx.auth.presentation.restore.RestorePasswordFragment
import org.openedx.auth.presentation.signin.SignInFragment
import org.openedx.auth.presentation.signup.SignUpFragment
import org.openedx.core.FragmentViewType
import org.openedx.core.domain.model.CoursewareAccess
import org.openedx.core.presentation.course.CourseViewMode
import org.openedx.core.presentation.global.app_upgrade.AppUpgradeRouter
import org.openedx.core.presentation.global.app_upgrade.UpgradeRequiredFragment
Expand Down Expand Up @@ -134,14 +133,9 @@ class AppRouter : AuthRouter, DiscoveryRouter, DashboardRouter, CourseRouter, Di

override fun navigateToNoAccess(
fm: FragmentManager,
title: String,
coursewareAccess: CoursewareAccess,
auditAccessExpires: Date?
title: String
) {
replaceFragment(
fm,
NoAccessCourseContainerFragment.newInstance(title, coursewareAccess, auditAccessExpires)
)
replaceFragment(fm, NoAccessCourseContainerFragment.newInstance(title))
}
//endregion

Expand Down
10 changes: 1 addition & 9 deletions app/src/main/java/org/openedx/app/di/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,7 @@ val appModule = module {
DownloadWorkerController(get(), get(), get())
}

single {
val config = get<Config>()
AppData(
BuildConfig.VERSION_NAME,
config.getFeedbackEmailAddress(),
config.getAgreementUrlsConfig().tosUrl,
config.getAgreementUrlsConfig().privacyPolicyUrl
)
}
single { AppData(versionName = BuildConfig.VERSION_NAME) }
factory { (activity: AppCompatActivity) -> AppReviewManager(activity, get(), get()) }

single { TranscriptManager(get()) }
Expand Down
57 changes: 50 additions & 7 deletions core/src/main/java/org/openedx/core/config/AgreementUrlsConfig.kt
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()
}
}
12 changes: 10 additions & 2 deletions core/src/main/java/org/openedx/core/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.google.gson.Gson
import com.google.gson.JsonElement
import com.google.gson.JsonObject
import com.google.gson.JsonParser
import org.openedx.core.domain.model.AgreementUrls
import java.io.InputStreamReader

class Config(context: Context) {
Expand Down Expand Up @@ -34,12 +35,18 @@ class Config(context: Context) {
return getString(TOKEN_TYPE, "")
}

fun getFaqUrl(): String {
return getString(FAQ_URL, "")
}

fun getFeedbackEmailAddress(): String {
return getString(FEEDBACK_EMAIL_ADDRESS, "")
}

fun getAgreementUrlsConfig(): AgreementUrlsConfig {
return getObjectOrNewInstance(AGREEMENT_URLS, AgreementUrlsConfig::class.java)
fun getAgreement(locale: String): AgreementUrls {
val agreement =
getObjectOrNewInstance(AGREEMENT_URLS, AgreementUrlsConfig::class.java).mapToDomain()
return agreement.getAgreementForLocale(locale)
}

fun getFirebaseConfig(): FirebaseConfig {
Expand Down Expand Up @@ -126,6 +133,7 @@ class Config(context: Context) {
private const val API_HOST_URL = "API_HOST_URL"
private const val OAUTH_CLIENT_ID = "OAUTH_CLIENT_ID"
private const val TOKEN_TYPE = "TOKEN_TYPE"
private const val FAQ_URL = "FAQ_URL"
private const val FEEDBACK_EMAIL_ADDRESS = "FEEDBACK_EMAIL_ADDRESS"
private const val AGREEMENT_URLS = "AGREEMENT_URLS"
private const val WHATS_NEW_ENABLED = "WHATS_NEW_ENABLED"
Expand Down
14 changes: 7 additions & 7 deletions core/src/main/java/org/openedx/core/data/api/CourseApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@ import retrofit2.http.*

interface CourseApi {

@GET("/mobile_api_extensions/v1/users/{username}/course_enrollments")
@GET("/api/mobile/v3/users/{username}/course_enrollments/")
suspend fun getEnrolledCourses(
@Header("Cache-Control") cacheControlHeaderParam: String? = null,
@Path("username") username: String,
@Query("org") org: String? = null,
@Query("page") page: Int
): DashboardCourseList
): CourseEnrollments

@GET("/mobile_api_extensions/courses/v1/courses/")
@GET("/api/courses/v1/courses/")
suspend fun getCourseList(
@Query("search_term") searchQuery: String? = null,
@Query("page") page: Int,
@Query("mobile") mobile: Boolean,
@Query("mobile_search") mobileSearch: Boolean,
@Query("username") username: String? = null,
@Query("org") org: String? = null,
@Query("permissions") permission: List<String> = listOf(
Expand All @@ -28,15 +29,14 @@ interface CourseApi {
)
): CourseList

@GET("/mobile_api_extensions/v1/courses/{course_id}")
@GET("/api/courses/v1/courses/{course_id}")
suspend fun getCourseDetail(
@Path("course_id") courseId: String?,
@Query("username") username: String? = null,
@Query("is_enrolled") isEnrolled: Boolean = true,
@Query("username") username: String? = null
): CourseDetails

@GET(
"/mobile_api_extensions/{api_version}/blocks/?" +
"/api/mobile/{api_version}/course_info/blocks/?" +
"depth=all&" +
"requested_fields=contains_gated_content,show_gated_sections,special_exam_info,graded,format,student_view_multi_device,due,completion&" +
"student_view_data=video,discussion&" +
Expand Down
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
)
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ data class CourseStructureModel(
startDisplay = startDisplay ?: "",
startType = startType ?: "",
end = TimeUtils.iso8601ToDate(end ?: ""),
coursewareAccess = coursewareAccess?.mapToDomain()!!,
coursewareAccess = coursewareAccess?.mapToDomain(),
media = media?.mapToDomain(),
certificate = certificate?.mapToDomain(),
isSelfPaced = isSelfPaced ?: false
Expand All @@ -70,7 +70,7 @@ data class CourseStructureModel(
startDisplay = startDisplay ?: "",
startType = startType ?: "",
end = end ?: "",
coursewareAccess = coursewareAccess?.mapToRoomEntity()!!,
coursewareAccess = coursewareAccess?.mapToRoomEntity(),
media = MediaDb.createFrom(media),
certificate = certificate?.mapToRoomEntity(),
isSelfPaced = isSelfPaced ?: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ data class EnrolledCourseData(
end = TimeUtils.iso8601ToDate(end ?: ""),
dynamicUpgradeDeadline = dynamicUpgradeDeadline ?: "",
subscriptionId = subscriptionId ?: "",
coursewareAccess = coursewareAccess?.mapToDomain()!!,
coursewareAccess = coursewareAccess?.mapToDomain(),
media = media?.mapToDomain(),
courseImage = courseImage ?: "",
courseAbout = courseAbout ?: "",
Expand All @@ -86,7 +86,7 @@ data class EnrolledCourseData(
end = end ?: "",
dynamicUpgradeDeadline = dynamicUpgradeDeadline ?: "",
subscriptionId = subscriptionId ?: "",
coursewareAccess = coursewareAccess?.mapToRoomEntity()!!,
coursewareAccess = coursewareAccess?.mapToRoomEntity(),
media = MediaDb.createFrom(media),
courseImage = courseImage ?: "",
courseAbout = courseAbout ?: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ data class CourseStructureEntity(
@ColumnInfo("end")
val end: String?,
@Embedded
val coursewareAccess: CoursewareAccessDb,
val coursewareAccess: CoursewareAccessDb?,
@Embedded
val media: MediaDb?,
@Embedded
Expand All @@ -54,7 +54,7 @@ data class CourseStructureEntity(
startDisplay,
startType,
TimeUtils.iso8601ToDate(end ?: ""),
coursewareAccess.mapToDomain(),
coursewareAccess?.mapToDomain(),
media?.mapToDomain(),
certificate?.mapToDomain(),
isSelfPaced
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ data class EnrolledCourseDataDb(
@ColumnInfo("subscriptionId")
val subscriptionId: String,
@Embedded
val coursewareAccess: CoursewareAccessDb,
val coursewareAccess: CoursewareAccessDb?,
@Embedded
val media: MediaDb?,
@ColumnInfo(name = "course_image_link")
Expand Down Expand Up @@ -93,7 +93,7 @@ data class EnrolledCourseDataDb(
TimeUtils.iso8601ToDate(end),
dynamicUpgradeDeadline,
subscriptionId,
coursewareAccess.mapToDomain(),
coursewareAccess?.mapToDomain(),
media?.mapToDomain(),
courseImage,
courseAbout,
Expand Down
25 changes: 25 additions & 0 deletions core/src/main/java/org/openedx/core/domain/model/AgreementUrls.kt
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(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ data class CourseStructure(
val startDisplay: String,
val startType: String,
val end: Date?,
val coursewareAccess: CoursewareAccess,
val coursewareAccess: CoursewareAccess?,
val media: Media?,
val certificate: Certificate?,
val isSelfPaced: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ data class EnrolledCourseData(
val end: Date?,
val dynamicUpgradeDeadline: String,
val subscriptionId: String,
val coursewareAccess: CoursewareAccess,
val coursewareAccess: CoursewareAccess?,
val media: Media?,
val courseImage: String,
val courseAbout: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@ package org.openedx.core.presentation.global

data class AppData(
val versionName: String,
val feedbackEmailAddress: String,
val tosUrl: String,
val privacyPolicyUrl: String,
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@ package org.openedx.core.presentation.global.webview
import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
import android.webkit.CookieManager
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.core.os.bundleOf
import androidx.fragment.app.Fragment
import org.koin.android.ext.android.inject
import org.openedx.core.config.Config
import org.openedx.core.ui.WebContentScreen
import org.openedx.core.ui.rememberWindowSize
import org.openedx.core.ui.theme.OpenEdXTheme

class WebContentFragment : Fragment() {

private val config: Config by inject()

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
Expand All @@ -22,6 +28,7 @@ class WebContentFragment : Fragment() {
OpenEdXTheme {
val windowSize = rememberWindowSize()
WebContentScreen(
apiHostUrl = config.getApiHostURL(),
windowSize = windowSize,
title = requireArguments().getString(ARG_TITLE, ""),
contentUrl = requireArguments().getString(ARG_URL, ""),
Expand All @@ -32,6 +39,11 @@ class WebContentFragment : Fragment() {
}
}

override fun onDestroy() {
super.onDestroy()
CookieManager.getInstance().flush()
}

companion object {
private const val ARG_TITLE = "argTitle"
private const val ARG_URL = "argUrl"
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<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_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_profile">Profile</string>
<string name="core_cancel">Cancel</string>
Expand Down
Loading

0 comments on commit 396b09d

Please sign in to comment.