diff --git a/app/src/main/java/org/openedx/app/data/networking/HeadersInterceptor.kt b/app/src/main/java/org/openedx/app/data/networking/HeadersInterceptor.kt index c91b27184..bdc7c6284 100644 --- a/app/src/main/java/org/openedx/app/data/networking/HeadersInterceptor.kt +++ b/app/src/main/java/org/openedx/app/data/networking/HeadersInterceptor.kt @@ -36,4 +36,4 @@ class HeadersInterceptor( }.build() ) } -} \ No newline at end of file +} diff --git a/app/src/main/java/org/openedx/app/di/AppModule.kt b/app/src/main/java/org/openedx/app/di/AppModule.kt index 1f88bea73..817f05ffd 100644 --- a/app/src/main/java/org/openedx/app/di/AppModule.kt +++ b/app/src/main/java/org/openedx/app/di/AppModule.kt @@ -71,6 +71,7 @@ import org.openedx.whatsnew.WhatsNewManager import org.openedx.whatsnew.WhatsNewRouter import org.openedx.whatsnew.data.storage.WhatsNewPreferences import org.openedx.whatsnew.presentation.WhatsNewAnalytics +import org.openedx.core.R as CoreR val appModule = module { @@ -167,7 +168,14 @@ val appModule = module { DownloadWorkerController(get(), get(), get()) } - single { AppData(versionName = BuildConfig.VERSION_NAME) } + single { + val resourceManager = get() + AppData( + appName = resourceManager.getString(CoreR.string.app_name), + versionName = BuildConfig.VERSION_NAME, + applicationId = BuildConfig.APPLICATION_ID, + ) + } factory { (activity: AppCompatActivity) -> AppReviewManager(activity, get(), get()) } single { TranscriptManager(get()) } diff --git a/app/src/main/java/org/openedx/app/di/ScreenModule.kt b/app/src/main/java/org/openedx/app/di/ScreenModule.kt index d8d02314b..630441f33 100644 --- a/app/src/main/java/org/openedx/app/di/ScreenModule.kt +++ b/app/src/main/java/org/openedx/app/di/ScreenModule.kt @@ -466,7 +466,7 @@ val screenModule = module { get(), ) } - viewModel { HtmlUnitViewModel(get(), get(), get(), get()) } + viewModel { HtmlUnitViewModel(get(), get(), get(), get(), get()) } viewModel { ProgramViewModel(get(), get(), get(), get(), get(), get(), get()) } diff --git a/core/src/main/java/org/openedx/core/presentation/global/AppData.kt b/core/src/main/java/org/openedx/core/presentation/global/AppData.kt index 324d3325a..fab1a72e7 100644 --- a/core/src/main/java/org/openedx/core/presentation/global/AppData.kt +++ b/core/src/main/java/org/openedx/core/presentation/global/AppData.kt @@ -1,5 +1,9 @@ package org.openedx.core.presentation.global data class AppData( + val appName: String, + val applicationId: String, val versionName: String, -) +) { + val appUserAgent get() = "$appName/$applicationId/$versionName" +} diff --git a/course/src/main/java/org/openedx/course/presentation/unit/html/HtmlUnitFragment.kt b/course/src/main/java/org/openedx/course/presentation/unit/html/HtmlUnitFragment.kt index b9d8fc49b..bdf6394f0 100644 --- a/course/src/main/java/org/openedx/course/presentation/unit/html/HtmlUnitFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/unit/html/HtmlUnitFragment.kt @@ -36,7 +36,6 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip -import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalContext @@ -130,6 +129,7 @@ class HtmlUnitFragment : Fragment() { url = blockUrl, cookieManager = viewModel.cookieManager, apiHostURL = viewModel.apiHostURL, + userAgent = viewModel.appUserAgent, isLoading = uiState is HtmlUnitUIState.Loading, injectJSList = injectJSList, onCompletionSet = { @@ -200,6 +200,7 @@ private fun HTMLContentView( url: String, cookieManager: AppCookieManager, apiHostURL: String, + userAgent: String, isLoading: Boolean, injectJSList: List, onCompletionSet: () -> Unit, @@ -307,7 +308,7 @@ private fun HTMLContentView( setSupportZoom(true) loadsImagesAutomatically = true domStorageEnabled = true - + userAgentString = "$userAgentString $userAgent" } isVerticalScrollBarEnabled = false isHorizontalScrollBarEnabled = false diff --git a/course/src/main/java/org/openedx/course/presentation/unit/html/HtmlUnitViewModel.kt b/course/src/main/java/org/openedx/course/presentation/unit/html/HtmlUnitViewModel.kt index 07ffe18c0..cb7506aa7 100644 --- a/course/src/main/java/org/openedx/course/presentation/unit/html/HtmlUnitViewModel.kt +++ b/course/src/main/java/org/openedx/course/presentation/unit/html/HtmlUnitViewModel.kt @@ -8,6 +8,7 @@ import kotlinx.coroutines.launch import org.openedx.core.BaseViewModel import org.openedx.core.config.Config import org.openedx.core.extension.readAsText +import org.openedx.core.presentation.global.AppData import org.openedx.core.presentation.global.ErrorType import org.openedx.core.system.AppCookieManager import org.openedx.core.system.connection.NetworkConnection @@ -16,6 +17,7 @@ import org.openedx.core.system.notifier.CourseNotifier class HtmlUnitViewModel( private val config: Config, + private val appData: AppData, private val edxCookieManager: AppCookieManager, private val networkConnection: NetworkConnection, private val notifier: CourseNotifier @@ -31,6 +33,7 @@ class HtmlUnitViewModel( val isCourseUnitProgressEnabled get() = config.getCourseUIConfig().isCourseUnitProgressEnabled val apiHostURL get() = config.getApiHostURL() val cookieManager get() = edxCookieManager + val appUserAgent get() = appData.appUserAgent fun onWebPageLoading() { _uiState.value = HtmlUnitUIState.Loading diff --git a/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsScreenUI.kt b/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsScreenUI.kt index ccf5228e3..a51044bda 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsScreenUI.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsScreenUI.kt @@ -706,7 +706,9 @@ fun AppVersionItemUpgradeRequired( } private val mockAppData = AppData( + appName = "openedx", versionName = "1.0.0", + applicationId = "org.example.com" ) private val mockConfiguration = Configuration(