From e61523ec975da2a06b7fac465e1375e761e55121 Mon Sep 17 00:00:00 2001 From: PavloNetrebchuk <141041606+PavloNetrebchuk@users.noreply.github.com> Date: Mon, 4 Nov 2024 09:57:14 +0200 Subject: [PATCH] feat: foundation lib and analytic plugin implementation (#395) --- Documentation/ConfigurationManagement.md | 2 - app/build.gradle | 41 ++---- app/proguard-rules.pro | 2 - .../java/org/openedx/app/AnalyticsManager.kt | 46 ++----- .../main/java/org/openedx/app/AppActivity.kt | 6 +- .../main/java/org/openedx/app/AppViewModel.kt | 10 +- .../java/org/openedx/app/MainViewModel.kt | 2 +- .../main/java/org/openedx/app/OpenEdXApp.kt | 10 ++ .../java/org/openedx/app/PluginManager.kt | 12 ++ .../org/openedx/app/analytics/Analytics.kt | 7 - .../app/analytics/FirebaseAnalytics.kt | 36 ----- .../app/analytics/FullstoryAnalytics.kt | 41 ------ .../openedx/app/analytics/SegmentAnalytics.kt | 56 -------- .../app/data/storage/PreferencesManager.kt | 2 +- .../main/java/org/openedx/app/di/AppModule.kt | 20 ++- .../java/org/openedx/app/di/ScreenModule.kt | 2 +- .../test/java/org/openedx/AppViewModelTest.kt | 4 +- auth/build.gradle | 19 +-- .../auth/presentation/AgreementProvider.kt | 2 +- .../logistration/LogistrationViewModel.kt | 4 +- .../restore/RestorePasswordFragment.kt | 10 +- .../restore/RestorePasswordViewModel.kt | 12 +- .../presentation/signin/SignInFragment.kt | 2 +- .../presentation/signin/SignInViewModel.kt | 10 +- .../presentation/signin/compose/SignInView.kt | 8 +- .../presentation/signup/SignUpFragment.kt | 2 +- .../presentation/signup/SignUpViewModel.kt | 8 +- .../presentation/signup/compose/SignUpView.kt | 11 +- .../presentation/sso/FacebookAuthHelper.kt | 2 +- .../presentation/sso/MicrosoftAuthHelper.kt | 2 +- .../openedx/auth/presentation/ui/AuthUI.kt | 7 +- .../restore/RestorePasswordViewModelTest.kt | 4 +- .../signin/SignInViewModelTest.kt | 5 +- .../signup/SignUpViewModelTest.kt | 4 +- build.gradle | 45 ++---- core/build.gradle | 75 ++-------- .../java/org/openedx/core/BaseViewModel.kt | 6 - .../org/openedx/core/SingleEventLiveData.kt | 39 ------ .../main/java/org/openedx/core/UIMessage.kt | 12 -- .../openedx/core/config/AnalyticsSource.kt | 11 -- .../java/org/openedx/core/config/Config.kt | 10 -- .../org/openedx/core/config/FirebaseConfig.kt | 9 +- .../openedx/core/config/FullstoryConfig.kt | 11 -- .../org/openedx/core/config/SegmentConfig.kt | 11 -- .../org/openedx/core/extension/AssetExt.kt | 15 -- .../org/openedx/core/extension/BundleExt.kt | 34 ----- .../openedx/core/extension/ContinuationExt.kt | 12 -- .../openedx/core/extension/FlowExtension.kt | 18 --- .../org/openedx/core/extension/FragmentExt.kt | 28 ---- .../org/openedx/core/extension/GsonExt.kt | 9 -- .../core/extension/ImageUploaderExtension.kt | 17 --- .../java/org/openedx/core/extension/IntExt.kt | 5 - .../org/openedx/core/extension/ListExt.kt | 30 ---- .../org/openedx/core/extension/LongExt.kt | 18 --- .../java/org/openedx/core/extension/MapExt.kt | 13 -- .../org/openedx/core/extension/StringExt.kt | 44 ------ .../openedx/core/extension/ThrowableExt.kt | 8 -- .../java/org/openedx/core/extension/UriExt.kt | 15 -- .../org/openedx/core/extension/ViewExt.kt | 59 -------- .../org/openedx/core/module/DownloadWorker.kt | 5 +- .../openedx/core/module/TranscriptManager.kt | 5 +- .../module/download/BaseDownloadViewModel.kt | 2 +- .../core/module/download/DownloadHelper.kt | 3 +- .../dialog/alert/ActionDialogFragment.kt | 2 +- .../appreview/BaseAppReviewDialogFragment.kt | 2 +- .../SelectBottomDialogFragment.kt | 4 +- .../SelectDialogViewModel.kt | 4 +- .../presentation/global/WindowSizeHolder.kt | 4 +- .../global/webview/WebContentFragment.kt | 2 +- .../calendarsync/CalendarSyncDialog.kt | 4 +- .../settings/video/VideoQualityFragment.kt | 14 +- .../settings/video/VideoQualityViewModel.kt | 2 +- .../core/system/PreviewFragmentManager.kt | 5 - .../openedx/core/system/ResourceManager.kt | 43 ------ .../java/org/openedx/core/ui/ComposeCommon.kt | 58 ++++---- .../org/openedx/core/ui/WebContentScreen.kt | 8 +- .../java/org/openedx/core/ui/WindowSize.kt | 55 -------- .../java/org/openedx/core/utils/FileUtil.kt | 128 +++--------------- .../java/org/openedx/core/utils/TimeUtils.kt | 2 +- .../java/org/openedx/core/utils/UrlUtils.kt | 67 --------- course/build.gradle | 11 +- .../openedx/course/DatesShiftedSnackBar.kt | 2 +- .../course/data/storage/CourseConverter.kt | 2 +- .../presentation/ChapterEndFragmentDialog.kt | 2 +- .../container/CollapsingLayout.kt | 2 +- .../container/CourseContainerFragment.kt | 9 +- .../container/CourseContainerViewModel.kt | 14 +- .../presentation/container/HeaderContent.kt | 2 +- .../NoAccessCourseContainerFragment.kt | 27 +++- .../presentation/dates/CourseDatesScreen.kt | 77 +---------- .../dates/CourseDatesViewModel.kt | 8 +- .../download/DownloadConfirmDialogFragment.kt | 6 +- .../download/DownloadErrorDialogFragment.kt | 4 +- .../DownloadStorageErrorDialogFragment.kt | 6 +- .../presentation/download/DownloadView.kt | 2 +- .../presentation/handouts/HandoutsScreen.kt | 6 +- .../handouts/HandoutsViewModel.kt | 2 +- .../handouts/HandoutsWebViewFragment.kt | 6 +- .../offline/CourseOfflineScreen.kt | 8 +- .../offline/CourseOfflineViewModel.kt | 4 +- .../outline/CourseOutlineScreen.kt | 10 +- .../outline/CourseOutlineViewModel.kt | 8 +- .../section/CourseSectionFragment.kt | 22 +-- .../section/CourseSectionViewModel.kt | 10 +- .../course/presentation/ui/CourseUI.kt | 8 +- .../course/presentation/ui/CourseVideosUI.kt | 16 ++- .../unit/NotAvailableUnitFragment.kt | 8 +- .../container/CourseUnitContainerFragment.kt | 2 +- .../container/CourseUnitContainerViewModel.kt | 6 +- .../unit/html/HtmlUnitFragment.kt | 10 +- .../unit/html/HtmlUnitViewModel.kt | 7 +- .../unit/video/BaseVideoViewModel.kt | 2 +- .../unit/video/VideoFullScreenFragment.kt | 2 +- .../unit/video/VideoUnitFragment.kt | 10 +- .../video/YoutubeVideoFullScreenFragment.kt | 2 +- .../unit/video/YoutubeVideoUnitFragment.kt | 8 +- .../videos/CourseVideoViewModel.kt | 6 +- .../download/DownloadQueueFragment.kt | 8 +- .../openedx/course/utils}/ImageProcessor.kt | 2 +- .../container/CourseContainerViewModelTest.kt | 4 +- .../dates/CourseDatesViewModelTest.kt | 4 +- .../outline/CourseOutlineViewModelTest.kt | 6 +- .../section/CourseSectionViewModelTest.kt | 4 +- .../videos/CourseVideoViewModelTest.kt | 6 +- dashboard/build.gradle | 11 +- .../presentation/AllEnrolledCoursesView.kt | 8 +- .../AllEnrolledCoursesViewModel.kt | 8 +- .../presentation/DashboardGalleryView.kt | 6 +- .../presentation/DashboardGalleryViewModel.kt | 12 +- .../data/repository/DashboardRepository.kt | 2 +- .../presentation/DashboardListFragment.kt | 12 +- .../presentation/DashboardListViewModel.kt | 12 +- .../learn/presentation/LearnFragment.kt | 4 +- .../learn/presentation/LearnViewModel.kt | 2 +- .../DashboardListViewModelTest.kt | 4 +- default_config/dev/config.yaml | 11 +- default_config/prod/config.yaml | 9 -- default_config/stage/config.yaml | 9 -- discovery/build.gradle | 15 +- .../presentation/NativeDiscoveryFragment.kt | 10 +- .../presentation/NativeDiscoveryViewModel.kt | 10 +- .../presentation/WebViewDiscoveryFragment.kt | 8 +- .../presentation/WebViewDiscoveryViewModel.kt | 4 +- .../presentation/catalog/CatalogWebView.kt | 2 +- .../catalog/DefaultWebViewClient.kt | 2 +- .../presentation/catalog/WebViewLink.kt | 2 +- .../detail/CourseDetailsFragment.kt | 14 +- .../detail/CourseDetailsViewModel.kt | 10 +- .../presentation/info/CourseInfoFragment.kt | 10 +- .../presentation/info/CourseInfoViewModel.kt | 8 +- .../presentation/program/ProgramFragment.kt | 12 +- .../presentation/program/ProgramUIState.kt | 2 +- .../presentation/program/ProgramViewModel.kt | 8 +- .../search/CourseSearchFragment.kt | 10 +- .../search/CourseSearchViewModel.kt | 10 +- .../discovery/presentation/ui/DiscoveryUI.kt | 10 +- .../NativeDiscoveryViewModelTest.kt | 4 +- .../detail/CourseDetailsViewModelTest.kt | 4 +- .../search/CourseSearchViewModelTest.kt | 4 +- discussion/build.gradle | 9 +- .../data/repository/DiscussionRepository.kt | 2 +- .../comments/DiscussionCommentsFragment.kt | 55 ++++++-- .../comments/DiscussionCommentsViewModel.kt | 12 +- .../responses/DiscussionResponsesFragment.kt | 54 ++++++-- .../responses/DiscussionResponsesViewModel.kt | 12 +- .../search/DiscussionSearchThreadFragment.kt | 51 +++++-- .../search/DiscussionSearchThreadViewModel.kt | 10 +- .../threads/DiscussionAddThreadFragment.kt | 10 +- .../threads/DiscussionAddThreadViewModel.kt | 12 +- .../threads/DiscussionThreadsFragment.kt | 58 +++++++- .../threads/DiscussionThreadsViewModel.kt | 10 +- .../topics/DiscussionTopicsScreen.kt | 8 +- .../topics/DiscussionTopicsViewModel.kt | 8 +- .../DiscussionCommentsViewModelTest.kt | 39 ++++-- .../DiscussionResponsesViewModelTest.kt | 31 +++-- .../DiscussionSearchThreadViewModelTest.kt | 27 ++-- .../DiscussionAddThreadViewModelTest.kt | 32 +++-- .../threads/DiscussionThreadsViewModelTest.kt | 4 +- .../topics/DiscussionTopicsViewModelTest.kt | 4 +- gradle/wrapper/gradle-wrapper.properties | 2 +- profile/build.gradle | 9 +- .../AnothersProfileFragment.kt | 10 +- .../AnothersProfileViewModel.kt | 8 +- .../presentation/calendar/CalendarFragment.kt | 4 +- .../calendar/CalendarSetUpView.kt | 6 +- .../calendar/CalendarSettingsView.kt | 6 +- .../calendar/CalendarViewModel.kt | 2 +- .../calendar/CoursesToSyncFragment.kt | 8 +- .../calendar/CoursesToSyncViewModel.kt | 8 +- .../DisableCalendarSyncDialogFragment.kt | 2 +- .../DisableCalendarSyncDialogViewModel.kt | 2 +- .../calendar/NewCalendarDialogFragment.kt | 4 +- .../calendar/NewCalendarDialogViewModel.kt | 4 +- .../delete/DeleteProfileFragment.kt | 10 +- .../delete/DeleteProfileViewModel.kt | 8 +- .../presentation/edit/EditProfileFragment.kt | 22 ++- .../presentation/edit/EditProfileViewModel.kt | 8 +- .../manageaccount/ManageAccountFragment.kt | 2 +- .../manageaccount/ManageAccountViewModel.kt | 8 +- .../compose/ManageAccountView.kt | 8 +- .../presentation/profile/ProfileFragment.kt | 2 +- .../presentation/profile/ProfileViewModel.kt | 8 +- .../profile/compose/ProfileView.kt | 8 +- .../presentation/settings/SettingsFragment.kt | 2 +- .../presentation/settings/SettingsScreenUI.kt | 6 +- .../settings/SettingsViewModel.kt | 8 +- .../profile/presentation/ui/SettingsUI.kt | 2 +- .../video/VideoSettingsFragment.kt | 8 +- .../video/VideoSettingsViewModel.kt | 2 +- .../edit/EditProfileViewModelTest.kt | 4 +- .../profile/AnothersProfileViewModelTest.kt | 4 +- .../profile/ProfileViewModelTest.kt | 4 +- settings.gradle | 11 +- whatsnew/build.gradle | 10 +- .../presentation/whatsnew/WhatsNewFragment.kt | 9 +- .../whatsnew/WhatsNewViewModel.kt | 2 +- 216 files changed, 917 insertions(+), 1786 deletions(-) create mode 100644 app/src/main/java/org/openedx/app/PluginManager.kt delete mode 100644 app/src/main/java/org/openedx/app/analytics/Analytics.kt delete mode 100644 app/src/main/java/org/openedx/app/analytics/FirebaseAnalytics.kt delete mode 100644 app/src/main/java/org/openedx/app/analytics/FullstoryAnalytics.kt delete mode 100644 app/src/main/java/org/openedx/app/analytics/SegmentAnalytics.kt delete mode 100644 core/src/main/java/org/openedx/core/BaseViewModel.kt delete mode 100644 core/src/main/java/org/openedx/core/SingleEventLiveData.kt delete mode 100644 core/src/main/java/org/openedx/core/UIMessage.kt delete mode 100644 core/src/main/java/org/openedx/core/config/AnalyticsSource.kt delete mode 100644 core/src/main/java/org/openedx/core/config/FullstoryConfig.kt delete mode 100644 core/src/main/java/org/openedx/core/config/SegmentConfig.kt delete mode 100644 core/src/main/java/org/openedx/core/extension/AssetExt.kt delete mode 100644 core/src/main/java/org/openedx/core/extension/BundleExt.kt delete mode 100644 core/src/main/java/org/openedx/core/extension/ContinuationExt.kt delete mode 100644 core/src/main/java/org/openedx/core/extension/FlowExtension.kt delete mode 100644 core/src/main/java/org/openedx/core/extension/FragmentExt.kt delete mode 100644 core/src/main/java/org/openedx/core/extension/GsonExt.kt delete mode 100644 core/src/main/java/org/openedx/core/extension/ImageUploaderExtension.kt delete mode 100644 core/src/main/java/org/openedx/core/extension/IntExt.kt delete mode 100644 core/src/main/java/org/openedx/core/extension/LongExt.kt delete mode 100644 core/src/main/java/org/openedx/core/extension/MapExt.kt delete mode 100644 core/src/main/java/org/openedx/core/extension/ThrowableExt.kt delete mode 100644 core/src/main/java/org/openedx/core/extension/UriExt.kt delete mode 100644 core/src/main/java/org/openedx/core/system/PreviewFragmentManager.kt delete mode 100644 core/src/main/java/org/openedx/core/system/ResourceManager.kt delete mode 100644 core/src/main/java/org/openedx/core/ui/WindowSize.kt delete mode 100644 core/src/main/java/org/openedx/core/utils/UrlUtils.kt rename {core/src/main/java/org/openedx/core => course/src/main/java/org/openedx/course/utils}/ImageProcessor.kt (98%) diff --git a/Documentation/ConfigurationManagement.md b/Documentation/ConfigurationManagement.md index 0e8456ed0..548e84759 100644 --- a/Documentation/ConfigurationManagement.md +++ b/Documentation/ConfigurationManagement.md @@ -49,7 +49,6 @@ TOKEN_TYPE: "JWT" FIREBASE: ENABLED: false - ANALYTICS_SOURCE: '' CLOUD_MESSAGING_ENABLED: false PROJECT_NUMBER: '' PROJECT_ID: '' @@ -82,7 +81,6 @@ android: - **Facebook:** Sign in and Sign up via Facebook - **Branch:** Deeplinks - **Braze:** Cloud Messaging -- **SegmentIO:** Analytics ## Available Feature Flags - **PRE_LOGIN_EXPERIENCE_ENABLED:** Enables the pre login courses discovery experience. diff --git a/app/build.gradle b/app/build.gradle index 3c017ee0b..baabb18d2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,17 +3,12 @@ def appId = config.getOrDefault("APPLICATION_ID", "org.openedx.app") def themeDirectory = config.getOrDefault("THEME_DIRECTORY", "openedx") def firebaseConfig = config.get('FIREBASE') def firebaseEnabled = firebaseConfig?.getOrDefault('ENABLED', false) -def fullstoryConfig = config.get("FULLSTORY") -def fullstoryEnabled = fullstoryConfig?.getOrDefault('ENABLED', false) apply plugin: 'com.android.application' apply plugin: 'org.jetbrains.kotlin.android' apply plugin: 'kotlin-parcelize' -apply plugin: 'kotlin-kapt' - -if (fullstoryEnabled) { - apply plugin: 'fullstory' -} +apply plugin: 'com.google.devtools.ksp' +apply plugin: 'org.jetbrains.kotlin.plugin.compose' if (firebaseEnabled) { apply plugin: 'com.google.gms.google-services' @@ -32,18 +27,6 @@ if (firebaseEnabled) { preBuild.dependsOn(removeGoogleServicesJson) } -if (fullstoryEnabled) { - def fullstoryOrgId = fullstoryConfig?.get("ORG_ID") - - fullstory { - org fullstoryOrgId - composeEnabled true - composeSelectorVersion 4 - enabledVariants 'debug|release' - logcatLevel 'error' - } -} - android { compileSdk 34 @@ -117,9 +100,6 @@ android { compose true buildConfig true } - composeOptions { - kotlinCompilerExtensionVersion = "$compose_compiler_version" - } bundle { language { enableSplit = false @@ -146,29 +126,24 @@ dependencies { implementation project(path: ':discussion') implementation project(path: ':whatsnew') - kapt "androidx.room:room-compiler:$room_version" + ksp "androidx.room:room-compiler:$room_version" implementation 'androidx.core:core-splashscreen:1.0.1' api platform("com.google.firebase:firebase-bom:$firebase_version") api "com.google.firebase:firebase-messaging" - // Segment Library - implementation "com.segment.analytics.kotlin:android:1.14.2" - // Segment's Firebase integration - implementation 'com.segment.analytics.kotlin.destinations:firebase:1.5.2' // Braze SDK Integration - implementation "com.braze:braze-segment-kotlin:1.4.2" implementation "com.braze:android-sdk-ui:30.2.0" - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" - debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version" + // Plugins + implementation("com.github.openedx:openedx-app-firebase-analytics-android:1.0.0") + + androidTestImplementation 'androidx.test.ext:junit:1.2.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' testImplementation "junit:junit:$junit_version" testImplementation "io.mockk:mockk:$mockk_version" testImplementation "io.mockk:mockk-android:$mockk_version" - testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version" testImplementation "androidx.arch.core:core-testing:$android_arch_version" } diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 373a73186..825176c61 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -46,8 +46,6 @@ -dontwarn com.google.crypto.tink.subtle.Ed25519Sign -dontwarn com.google.crypto.tink.subtle.Ed25519Verify -dontwarn com.google.crypto.tink.subtle.X25519 --dontwarn com.segment.analytics.kotlin.core.platform.plugins.logger.LogFilterKind --dontwarn com.segment.analytics.kotlin.core.platform.plugins.logger.LogTargetKt -dontwarn edu.umd.cs.findbugs.annotations.NonNull -dontwarn edu.umd.cs.findbugs.annotations.Nullable -dontwarn edu.umd.cs.findbugs.annotations.SuppressFBWarnings diff --git a/app/src/main/java/org/openedx/app/AnalyticsManager.kt b/app/src/main/java/org/openedx/app/AnalyticsManager.kt index 9d8169863..aa78f8d04 100644 --- a/app/src/main/java/org/openedx/app/AnalyticsManager.kt +++ b/app/src/main/java/org/openedx/app/AnalyticsManager.kt @@ -1,70 +1,46 @@ package org.openedx.app -import android.content.Context -import org.openedx.app.analytics.Analytics -import org.openedx.app.analytics.FirebaseAnalytics -import org.openedx.app.analytics.FullstoryAnalytics -import org.openedx.app.analytics.SegmentAnalytics import org.openedx.auth.presentation.AuthAnalytics -import org.openedx.core.config.Config import org.openedx.core.presentation.CoreAnalytics import org.openedx.core.presentation.dialog.appreview.AppReviewAnalytics import org.openedx.course.presentation.CourseAnalytics import org.openedx.dashboard.presentation.DashboardAnalytics import org.openedx.discovery.presentation.DiscoveryAnalytics import org.openedx.discussion.presentation.DiscussionAnalytics +import org.openedx.foundation.interfaces.Analytics import org.openedx.profile.presentation.ProfileAnalytics import org.openedx.whatsnew.presentation.WhatsNewAnalytics -class AnalyticsManager( - context: Context, - config: Config, -) : AppAnalytics, AppReviewAnalytics, AuthAnalytics, CoreAnalytics, CourseAnalytics, - DashboardAnalytics, DiscoveryAnalytics, DiscussionAnalytics, ProfileAnalytics, - WhatsNewAnalytics { +class AnalyticsManager : AppAnalytics, AppReviewAnalytics, AuthAnalytics, CoreAnalytics, + CourseAnalytics, DashboardAnalytics, DiscoveryAnalytics, DiscussionAnalytics, + ProfileAnalytics, WhatsNewAnalytics { - private val services: ArrayList = arrayListOf() + private val analytics: MutableList = mutableListOf() - init { - // Initialise all the analytics libraries here - if (config.getFirebaseConfig().enabled) { - addAnalyticsTracker(FirebaseAnalytics(context = context)) - } - - val segmentConfig = config.getSegmentConfig() - if (segmentConfig.enabled && segmentConfig.segmentWriteKey.isNotBlank()) { - addAnalyticsTracker(SegmentAnalytics(context = context, config = config)) - } - - if (config.getFullstoryConfig().isEnabled) { - addAnalyticsTracker(FullstoryAnalytics()) - } - } - - private fun addAnalyticsTracker(analytic: Analytics) { - services.add(analytic) + fun addAnalyticsTracker(analytic: Analytics) { + analytics.add(analytic) } private fun logEvent(event: Event, params: Map = mapOf()) { - services.forEach { analytics -> + analytics.forEach { analytics -> analytics.logEvent(event.eventName, params) } } override fun logScreenEvent(screenName: String, params: Map) { - services.forEach { analytics -> + analytics.forEach { analytics -> analytics.logScreenEvent(screenName, params) } } override fun logEvent(event: String, params: Map) { - services.forEach { analytics -> + analytics.forEach { analytics -> analytics.logEvent(event, params) } } private fun setUserId(userId: Long) { - services.forEach { analytics -> + analytics.forEach { analytics -> analytics.logUserId(userId) } } diff --git a/app/src/main/java/org/openedx/app/AppActivity.kt b/app/src/main/java/org/openedx/app/AppActivity.kt index b75825048..b736e937c 100644 --- a/app/src/main/java/org/openedx/app/AppActivity.kt +++ b/app/src/main/java/org/openedx/app/AppActivity.kt @@ -25,14 +25,14 @@ import org.openedx.app.deeplink.DeepLink import org.openedx.auth.presentation.logistration.LogistrationFragment import org.openedx.auth.presentation.signin.SignInFragment import org.openedx.core.data.storage.CorePreferences -import org.openedx.core.extension.requestApplyInsetsWhenAttached import org.openedx.core.presentation.global.InsetHolder import org.openedx.core.presentation.global.WindowSizeHolder -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.utils.Logger import org.openedx.core.worker.CalendarSyncScheduler import org.openedx.course.presentation.download.DownloadDialogManager +import org.openedx.foundation.extension.requestApplyInsetsWhenAttached +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType import org.openedx.profile.presentation.ProfileRouter import org.openedx.whatsnew.WhatsNewManager import org.openedx.whatsnew.presentation.whatsnew.WhatsNewFragment diff --git a/app/src/main/java/org/openedx/app/AppViewModel.kt b/app/src/main/java/org/openedx/app/AppViewModel.kt index 69fc3a9d9..e191a49c6 100644 --- a/app/src/main/java/org/openedx/app/AppViewModel.kt +++ b/app/src/main/java/org/openedx/app/AppViewModel.kt @@ -18,8 +18,6 @@ import org.openedx.app.deeplink.DeepLink import org.openedx.app.deeplink.DeepLinkRouter import org.openedx.app.system.push.RefreshFirebaseTokenWorker import org.openedx.app.system.push.SyncFirebaseTokenWorker -import org.openedx.core.BaseViewModel -import org.openedx.core.SingleEventLiveData import org.openedx.core.config.Config import org.openedx.core.data.model.User import org.openedx.core.data.storage.CorePreferences @@ -28,8 +26,10 @@ import org.openedx.core.system.notifier.DownloadNotifier import org.openedx.core.system.notifier.app.AppNotifier import org.openedx.core.system.notifier.app.LogoutEvent import org.openedx.core.system.notifier.app.SignInEvent -import org.openedx.core.utils.FileUtil - +import org.openedx.core.utils.Directories +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.SingleEventLiveData +import org.openedx.foundation.utils.FileUtil @SuppressLint("StaticFieldLeak") class AppViewModel( @@ -104,7 +104,7 @@ class AppViewModel( } private fun resetAppDirectory() { - fileUtil.deleteOldAppDirectory() + fileUtil.deleteOldAppDirectory(Directories.VIDEOS.name) preferencesManager.canResetAppDirectory = false } diff --git a/app/src/main/java/org/openedx/app/MainViewModel.kt b/app/src/main/java/org/openedx/app/MainViewModel.kt index 5cef29361..ff24f4ff8 100644 --- a/app/src/main/java/org/openedx/app/MainViewModel.kt +++ b/app/src/main/java/org/openedx/app/MainViewModel.kt @@ -10,11 +10,11 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach -import org.openedx.core.BaseViewModel import org.openedx.core.config.Config import org.openedx.core.system.notifier.DiscoveryNotifier import org.openedx.core.system.notifier.NavigationToDiscovery import org.openedx.discovery.presentation.DiscoveryNavigator +import org.openedx.foundation.presentation.BaseViewModel class MainViewModel( private val config: Config, diff --git a/app/src/main/java/org/openedx/app/OpenEdXApp.kt b/app/src/main/java/org/openedx/app/OpenEdXApp.kt index ccf20d5b2..6524cde5d 100644 --- a/app/src/main/java/org/openedx/app/OpenEdXApp.kt +++ b/app/src/main/java/org/openedx/app/OpenEdXApp.kt @@ -14,10 +14,12 @@ import org.openedx.app.di.appModule import org.openedx.app.di.networkingModule import org.openedx.app.di.screenModule import org.openedx.core.config.Config +import org.openedx.firebase.OEXFirebaseAnalytics class OpenEdXApp : Application() { private val config by inject() + private val pluginManager by inject() override fun onCreate() { super.onCreate() @@ -58,5 +60,13 @@ class OpenEdXApp : Application() { BrazeDeeplinkHandler.setBrazeDeeplinkHandler(BranchBrazeDeeplinkHandler()) } } + + initPlugins() + } + + private fun initPlugins() { + if (config.getFirebaseConfig().enabled) { + pluginManager.addPlugin(OEXFirebaseAnalytics(context = this)) + } } } diff --git a/app/src/main/java/org/openedx/app/PluginManager.kt b/app/src/main/java/org/openedx/app/PluginManager.kt new file mode 100644 index 000000000..651dbc8cb --- /dev/null +++ b/app/src/main/java/org/openedx/app/PluginManager.kt @@ -0,0 +1,12 @@ +package org.openedx.app + +import org.openedx.foundation.interfaces.Analytics + +class PluginManager( + private val analyticsManager: AnalyticsManager +) { + + fun addPlugin(analytics: Analytics) { + analyticsManager.addAnalyticsTracker(analytics) + } +} diff --git a/app/src/main/java/org/openedx/app/analytics/Analytics.kt b/app/src/main/java/org/openedx/app/analytics/Analytics.kt deleted file mode 100644 index 01ac01860..000000000 --- a/app/src/main/java/org/openedx/app/analytics/Analytics.kt +++ /dev/null @@ -1,7 +0,0 @@ -package org.openedx.app.analytics - -interface Analytics { - fun logScreenEvent(screenName: String, params: Map) - fun logEvent(eventName: String, params: Map) - fun logUserId(userId: Long) -} diff --git a/app/src/main/java/org/openedx/app/analytics/FirebaseAnalytics.kt b/app/src/main/java/org/openedx/app/analytics/FirebaseAnalytics.kt deleted file mode 100644 index 17d3b3b62..000000000 --- a/app/src/main/java/org/openedx/app/analytics/FirebaseAnalytics.kt +++ /dev/null @@ -1,36 +0,0 @@ -package org.openedx.app.analytics - -import android.content.Context -import com.google.firebase.analytics.FirebaseAnalytics -import org.openedx.core.extension.toBundle -import org.openedx.core.utils.Logger - -class FirebaseAnalytics(context: Context) : Analytics { - - private val logger = Logger(TAG) - private var tracker: FirebaseAnalytics - - init { - tracker = FirebaseAnalytics.getInstance(context) - logger.d { "Firebase Analytics Builder Initialised" } - } - - override fun logScreenEvent(screenName: String, params: Map) { - tracker.logEvent(screenName, params.toBundle()) - logger.d { "Firebase Analytics log Screen Event: $screenName + $params" } - } - - override fun logEvent(eventName: String, params: Map) { - tracker.logEvent(eventName, params.toBundle()) - logger.d { "Firebase Analytics log Event $eventName: $params" } - } - - override fun logUserId(userId: Long) { - tracker.setUserId(userId.toString()) - logger.d { "Firebase Analytics User Id log Event" } - } - - private companion object { - const val TAG = "FirebaseAnalytics" - } -} diff --git a/app/src/main/java/org/openedx/app/analytics/FullstoryAnalytics.kt b/app/src/main/java/org/openedx/app/analytics/FullstoryAnalytics.kt deleted file mode 100644 index bb3473844..000000000 --- a/app/src/main/java/org/openedx/app/analytics/FullstoryAnalytics.kt +++ /dev/null @@ -1,41 +0,0 @@ -package org.openedx.app.analytics - -import com.fullstory.FS -import com.fullstory.FSSessionData -import org.openedx.core.utils.Logger - -class FullstoryAnalytics : Analytics { - - private val logger = Logger(TAG) - - init { - FS.setReadyListener { sessionData: FSSessionData -> - val sessionUrl = sessionData.currentSessionURL - logger.d { "FullStory Session URL is: $sessionUrl" } - } - } - - override fun logScreenEvent(screenName: String, params: Map) { - logger.d { "Page : $screenName $params" } - FS.page(screenName, params).start() - } - - override fun logEvent(eventName: String, params: Map) { - logger.d { "Event: $eventName $params" } - FS.event(eventName, params) - } - - override fun logUserId(userId: Long) { - logger.d { "Identify: $userId" } - FS.identify( - userId.toString(), mapOf( - DISPLAY_NAME to userId - ) - ) - } - - private companion object { - const val TAG = "FullstoryAnalytics" - private const val DISPLAY_NAME = "displayName" - } -} diff --git a/app/src/main/java/org/openedx/app/analytics/SegmentAnalytics.kt b/app/src/main/java/org/openedx/app/analytics/SegmentAnalytics.kt deleted file mode 100644 index 3a9532a71..000000000 --- a/app/src/main/java/org/openedx/app/analytics/SegmentAnalytics.kt +++ /dev/null @@ -1,56 +0,0 @@ -package org.openedx.app.analytics - -import android.content.Context -import com.segment.analytics.kotlin.destinations.braze.BrazeDestination -import com.segment.analytics.kotlin.destinations.firebase.FirebaseDestination -import org.openedx.app.BuildConfig -import org.openedx.core.config.Config -import org.openedx.core.utils.Logger -import com.segment.analytics.kotlin.android.Analytics as SegmentAnalyticsBuilder -import com.segment.analytics.kotlin.core.Analytics as SegmentTracker - -class SegmentAnalytics(context: Context, config: Config) : Analytics { - - private val logger = Logger(TAG) - private var tracker: SegmentTracker - - init { - // Create an analytics client with the given application context and Segment write key. - tracker = SegmentAnalyticsBuilder(config.getSegmentConfig().segmentWriteKey, context) { - // Automatically track Lifecycle events - trackApplicationLifecycleEvents = true - flushAt = 20 - flushInterval = 30 - } - if (config.getFirebaseConfig().isSegmentAnalyticsSource()) { - tracker.add(plugin = FirebaseDestination(context = context)) - } - - if (config.getFirebaseConfig() - .isSegmentAnalyticsSource() && config.getBrazeConfig().isEnabled - ) { - tracker.add(plugin = BrazeDestination(context)) - } - SegmentTracker.debugLogsEnabled = BuildConfig.DEBUG - logger.d { "Segment Analytics Builder Initialised" } - } - - override fun logScreenEvent(screenName: String, params: Map) { - logger.d { "Segment Analytics log Screen Event: $screenName + $params" } - tracker.screen(screenName, params) - } - - override fun logEvent(eventName: String, params: Map) { - logger.d { "Segment Analytics log Event $eventName: $params" } - tracker.track(eventName, params) - } - - override fun logUserId(userId: Long) { - logger.d { "Segment Analytics User Id log Event: $userId" } - tracker.identify(userId.toString()) - } - - private companion object { - const val TAG = "SegmentAnalytics" - } -} diff --git a/app/src/main/java/org/openedx/app/data/storage/PreferencesManager.kt b/app/src/main/java/org/openedx/app/data/storage/PreferencesManager.kt index 1a4974a19..ab18b7e23 100644 --- a/app/src/main/java/org/openedx/app/data/storage/PreferencesManager.kt +++ b/app/src/main/java/org/openedx/app/data/storage/PreferencesManager.kt @@ -10,9 +10,9 @@ import org.openedx.core.data.storage.InAppReviewPreferences import org.openedx.core.domain.model.AppConfig import org.openedx.core.domain.model.VideoQuality import org.openedx.core.domain.model.VideoSettings -import org.openedx.core.extension.replaceSpace import org.openedx.core.system.CalendarManager import org.openedx.course.data.storage.CoursePreferences +import org.openedx.foundation.extension.replaceSpace import org.openedx.profile.data.model.Account import org.openedx.profile.data.storage.ProfilePreferences import org.openedx.whatsnew.data.storage.WhatsNewPreferences 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 7cd9d7093..79d70208f 100644 --- a/app/src/main/java/org/openedx/app/di/AppModule.kt +++ b/app/src/main/java/org/openedx/app/di/AppModule.kt @@ -14,6 +14,7 @@ import org.openedx.app.AnalyticsManager import org.openedx.app.AppAnalytics import org.openedx.app.AppRouter import org.openedx.app.BuildConfig +import org.openedx.app.PluginManager import org.openedx.app.data.storage.PreferencesManager import org.openedx.app.deeplink.DeepLinkRouter import org.openedx.app.room.AppDatabase @@ -27,7 +28,7 @@ import org.openedx.auth.presentation.sso.GoogleAuthHelper import org.openedx.auth.presentation.sso.MicrosoftAuthHelper import org.openedx.auth.presentation.sso.OAuthHelper import org.openedx.core.CalendarRouter -import org.openedx.core.ImageProcessor +import org.openedx.core.R import org.openedx.core.config.Config import org.openedx.core.data.model.CourseEnrollments import org.openedx.core.data.storage.CalendarPreferences @@ -45,7 +46,6 @@ import org.openedx.core.presentation.global.WhatsNewGlobalManager import org.openedx.core.presentation.global.app_upgrade.AppUpgradeRouter import org.openedx.core.system.AppCookieManager import org.openedx.core.system.CalendarManager -import org.openedx.core.system.ResourceManager import org.openedx.core.system.connection.NetworkConnection import org.openedx.core.system.notifier.CourseNotifier import org.openedx.core.system.notifier.DiscoveryNotifier @@ -53,12 +53,12 @@ import org.openedx.core.system.notifier.DownloadNotifier import org.openedx.core.system.notifier.VideoNotifier import org.openedx.core.system.notifier.app.AppNotifier import org.openedx.core.system.notifier.calendar.CalendarNotifier -import org.openedx.core.utils.FileUtil import org.openedx.core.worker.CalendarSyncScheduler import org.openedx.course.data.storage.CoursePreferences import org.openedx.course.presentation.CourseAnalytics import org.openedx.course.presentation.CourseRouter import org.openedx.course.presentation.download.DownloadDialogManager +import org.openedx.course.utils.ImageProcessor import org.openedx.course.worker.OfflineProgressSyncScheduler import org.openedx.dashboard.presentation.DashboardAnalytics import org.openedx.dashboard.presentation.DashboardRouter @@ -67,6 +67,8 @@ import org.openedx.discovery.presentation.DiscoveryRouter import org.openedx.discussion.presentation.DiscussionAnalytics import org.openedx.discussion.presentation.DiscussionRouter import org.openedx.discussion.system.notifier.DiscussionNotifier +import org.openedx.foundation.system.ResourceManager +import org.openedx.foundation.utils.FileUtil import org.openedx.profile.data.storage.ProfilePreferences import org.openedx.profile.presentation.ProfileAnalytics import org.openedx.profile.presentation.ProfileRouter @@ -181,11 +183,10 @@ val appModule = module { single { AppData(versionName = BuildConfig.VERSION_NAME) } factory { (activity: AppCompatActivity) -> AppReviewManager(activity, get(), get()) } - single { TranscriptManager(get()) } + single { TranscriptManager(get(), get()) } single { WhatsNewManager(get(), get(), get(), get()) } single { get() } - single { AnalyticsManager(get(), get()) } single { get() } single { get() } single { get() } @@ -203,10 +204,17 @@ val appModule = module { factory { MicrosoftAuthHelper() } factory { OAuthHelper(get(), get(), get()) } - factory { FileUtil(get()) } + factory { FileUtil(get(), get().getString(R.string.app_name)) } single { DownloadHelper(get(), get()) } factory { OfflineProgressSyncScheduler(get()) } single { CalendarSyncScheduler(get()) } + + single { AnalyticsManager() } + single { + PluginManager( + analyticsManager = 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 15ef16498..86d9b3dfe 100644 --- a/app/src/main/java/org/openedx/app/di/ScreenModule.kt +++ b/app/src/main/java/org/openedx/app/di/ScreenModule.kt @@ -16,7 +16,6 @@ import org.openedx.core.domain.interactor.CalendarInteractor import org.openedx.core.presentation.dialog.selectorbottomsheet.SelectDialogViewModel import org.openedx.core.presentation.settings.video.VideoQualityViewModel import org.openedx.core.repository.CalendarRepository -import org.openedx.core.ui.WindowSize import org.openedx.course.data.repository.CourseRepository import org.openedx.course.domain.interactor.CourseInteractor import org.openedx.course.presentation.container.CourseContainerViewModel @@ -55,6 +54,7 @@ import org.openedx.discussion.presentation.search.DiscussionSearchThreadViewMode import org.openedx.discussion.presentation.threads.DiscussionAddThreadViewModel import org.openedx.discussion.presentation.threads.DiscussionThreadsViewModel import org.openedx.discussion.presentation.topics.DiscussionTopicsViewModel +import org.openedx.foundation.presentation.WindowSize import org.openedx.learn.presentation.LearnViewModel import org.openedx.profile.data.repository.ProfileRepository import org.openedx.profile.domain.interactor.ProfileInteractor diff --git a/app/src/test/java/org/openedx/AppViewModelTest.kt b/app/src/test/java/org/openedx/AppViewModelTest.kt index d2fb4897b..f0e748b62 100644 --- a/app/src/test/java/org/openedx/AppViewModelTest.kt +++ b/app/src/test/java/org/openedx/AppViewModelTest.kt @@ -26,13 +26,13 @@ import org.openedx.app.AppViewModel import org.openedx.app.data.storage.PreferencesManager import org.openedx.app.deeplink.DeepLinkRouter import org.openedx.app.room.AppDatabase -import org.openedx.core.system.notifier.app.LogoutEvent import org.openedx.core.config.Config import org.openedx.core.config.FirebaseConfig import org.openedx.core.data.model.User import org.openedx.core.system.notifier.DownloadNotifier import org.openedx.core.system.notifier.app.AppNotifier -import org.openedx.core.utils.FileUtil +import org.openedx.core.system.notifier.app.LogoutEvent +import org.openedx.foundation.utils.FileUtil @ExperimentalCoroutinesApi class AppViewModelTest { diff --git a/auth/build.gradle b/auth/build.gradle index cd6f00621..470174991 100644 --- a/auth/build.gradle +++ b/auth/build.gradle @@ -2,6 +2,7 @@ plugins { id 'com.android.library' id 'org.jetbrains.kotlin.android' id 'kotlin-parcelize' + id "org.jetbrains.kotlin.plugin.compose" } android { @@ -48,32 +49,26 @@ android { viewBinding true compose true } - composeOptions { - kotlinCompilerExtensionVersion = "$compose_compiler_version" - } } dependencies { implementation project(path: ':core') - implementation "androidx.credentials:credentials:1.2.0" - implementation "androidx.credentials:credentials-play-services-auth:1.2.0" + implementation "androidx.credentials:credentials:1.3.0" + implementation "androidx.credentials:credentials-play-services-auth:1.3.0" implementation "com.facebook.android:facebook-login:16.2.0" - implementation "com.google.android.gms:play-services-auth:21.0.0" - implementation "com.google.android.libraries.identity.googleid:googleid:1.1.0" + implementation "com.google.android.gms:play-services-auth:21.2.0" + implementation "com.google.android.libraries.identity.googleid:googleid:1.1.1" implementation("com.microsoft.identity.client:msal:4.9.0") { //Workaround for the error Failed to resolve: 'io.opentelemetry:opentelemetry-bom' for AS Iguana exclude(group: "io.opentelemetry") } implementation("io.opentelemetry:opentelemetry-api:1.18.0") implementation("io.opentelemetry:opentelemetry-context:1.18.0") - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" - debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version" + androidTestImplementation 'androidx.test.ext:junit:1.2.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' testImplementation "junit:junit:$junit_version" testImplementation "io.mockk:mockk:$mockk_version" testImplementation "io.mockk:mockk-android:$mockk_version" - testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version" testImplementation "androidx.arch.core:core-testing:$android_arch_version" } diff --git a/auth/src/main/java/org/openedx/auth/presentation/AgreementProvider.kt b/auth/src/main/java/org/openedx/auth/presentation/AgreementProvider.kt index 0141df227..2b8fc9708 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/AgreementProvider.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/AgreementProvider.kt @@ -3,7 +3,7 @@ package org.openedx.auth.presentation import androidx.compose.ui.text.intl.Locale import org.openedx.auth.R import org.openedx.core.config.Config -import org.openedx.core.system.ResourceManager +import org.openedx.foundation.system.ResourceManager class AgreementProvider( private val config: Config, diff --git a/auth/src/main/java/org/openedx/auth/presentation/logistration/LogistrationViewModel.kt b/auth/src/main/java/org/openedx/auth/presentation/logistration/LogistrationViewModel.kt index 090c03251..2b9ca07e2 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/logistration/LogistrationViewModel.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/logistration/LogistrationViewModel.kt @@ -5,9 +5,9 @@ import org.openedx.auth.presentation.AuthAnalytics import org.openedx.auth.presentation.AuthAnalyticsEvent import org.openedx.auth.presentation.AuthAnalyticsKey import org.openedx.auth.presentation.AuthRouter -import org.openedx.core.BaseViewModel import org.openedx.core.config.Config -import org.openedx.core.extension.takeIfNotEmpty +import org.openedx.foundation.extension.takeIfNotEmpty +import org.openedx.foundation.presentation.BaseViewModel class LogistrationViewModel( private val courseId: String, diff --git a/auth/src/main/java/org/openedx/auth/presentation/restore/RestorePasswordFragment.kt b/auth/src/main/java/org/openedx/auth/presentation/restore/RestorePasswordFragment.kt index 84d2d584e..6f02f231c 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/restore/RestorePasswordFragment.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/restore/RestorePasswordFragment.kt @@ -58,21 +58,21 @@ import org.koin.androidx.viewmodel.ext.android.viewModel import org.openedx.auth.presentation.ui.LoginTextField import org.openedx.core.AppUpdateState import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.presentation.global.app_upgrade.AppUpgradeRequiredScreen import org.openedx.core.ui.BackBtn import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.OpenEdXButton -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.auth.R as authR class RestorePasswordFragment : Fragment() { diff --git a/auth/src/main/java/org/openedx/auth/presentation/restore/RestorePasswordViewModel.kt b/auth/src/main/java/org/openedx/auth/presentation/restore/RestorePasswordViewModel.kt index 6827d8e78..504f55a7e 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/restore/RestorePasswordViewModel.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/restore/RestorePasswordViewModel.kt @@ -8,16 +8,16 @@ import org.openedx.auth.domain.interactor.AuthInteractor import org.openedx.auth.presentation.AuthAnalytics import org.openedx.auth.presentation.AuthAnalyticsEvent import org.openedx.auth.presentation.AuthAnalyticsKey -import org.openedx.core.BaseViewModel import org.openedx.core.R -import org.openedx.core.SingleEventLiveData -import org.openedx.core.UIMessage -import org.openedx.core.extension.isEmailValid -import org.openedx.core.extension.isInternetError import org.openedx.core.system.EdxError -import org.openedx.core.system.ResourceManager import org.openedx.core.system.notifier.app.AppNotifier import org.openedx.core.system.notifier.app.AppUpgradeEvent +import org.openedx.foundation.extension.isEmailValid +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.SingleEventLiveData +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager class RestorePasswordViewModel( private val interactor: AuthInteractor, diff --git a/auth/src/main/java/org/openedx/auth/presentation/signin/SignInFragment.kt b/auth/src/main/java/org/openedx/auth/presentation/signin/SignInFragment.kt index fabd8a40b..d5f11ea0a 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/signin/SignInFragment.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/signin/SignInFragment.kt @@ -17,8 +17,8 @@ import org.openedx.auth.data.model.AuthType import org.openedx.auth.presentation.signin.compose.LoginScreen import org.openedx.core.AppUpdateState import org.openedx.core.presentation.global.app_upgrade.AppUpgradeRequiredScreen -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.theme.OpenEdXTheme +import org.openedx.foundation.presentation.rememberWindowSize class SignInFragment : Fragment() { diff --git a/auth/src/main/java/org/openedx/auth/presentation/signin/SignInViewModel.kt b/auth/src/main/java/org/openedx/auth/presentation/signin/SignInViewModel.kt index 00b91d71f..5cc08b47e 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/signin/SignInViewModel.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/signin/SignInViewModel.kt @@ -21,23 +21,23 @@ import org.openedx.auth.presentation.AuthAnalyticsEvent import org.openedx.auth.presentation.AuthAnalyticsKey import org.openedx.auth.presentation.AuthRouter import org.openedx.auth.presentation.sso.OAuthHelper -import org.openedx.core.BaseViewModel -import org.openedx.core.SingleEventLiveData -import org.openedx.core.UIMessage import org.openedx.core.Validator import org.openedx.core.config.Config import org.openedx.core.data.storage.CalendarPreferences import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.interactor.CalendarInteractor import org.openedx.core.domain.model.createHonorCodeField -import org.openedx.core.extension.isInternetError import org.openedx.core.presentation.global.WhatsNewGlobalManager import org.openedx.core.system.EdxError -import org.openedx.core.system.ResourceManager import org.openedx.core.system.notifier.app.AppNotifier import org.openedx.core.system.notifier.app.AppUpgradeEvent import org.openedx.core.system.notifier.app.SignInEvent import org.openedx.core.utils.Logger +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.SingleEventLiveData +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import org.openedx.core.R as CoreRes class SignInViewModel( diff --git a/auth/src/main/java/org/openedx/auth/presentation/signin/compose/SignInView.kt b/auth/src/main/java/org/openedx/auth/presentation/signin/compose/SignInView.kt index 52fa9b4c4..be4e9bf53 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/signin/compose/SignInView.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/signin/compose/SignInView.kt @@ -62,14 +62,11 @@ import org.openedx.auth.presentation.signin.SignInUIState import org.openedx.auth.presentation.ui.LoginTextField import org.openedx.auth.presentation.ui.PasswordVisibilityIcon import org.openedx.auth.presentation.ui.SocialAuthView -import org.openedx.core.UIMessage import org.openedx.core.extension.TextConverter import org.openedx.core.ui.BackBtn import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.HyperlinkText import org.openedx.core.ui.OpenEdXButton -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape import org.openedx.core.ui.noRippleClickable import org.openedx.core.ui.theme.OpenEdXTheme @@ -77,7 +74,10 @@ import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography import org.openedx.core.ui.theme.compose.SignInLogoView -import org.openedx.core.ui.windowSizeValue +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.core.R as coreR @OptIn(ExperimentalComposeUiApi::class) diff --git a/auth/src/main/java/org/openedx/auth/presentation/signup/SignUpFragment.kt b/auth/src/main/java/org/openedx/auth/presentation/signup/SignUpFragment.kt index fa27d7d60..dabcc0e31 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/signup/SignUpFragment.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/signup/SignUpFragment.kt @@ -18,8 +18,8 @@ import org.openedx.auth.presentation.AuthRouter import org.openedx.auth.presentation.signup.compose.SignUpView import org.openedx.core.AppUpdateState import org.openedx.core.presentation.global.app_upgrade.AppUpgradeRequiredScreen -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.theme.OpenEdXTheme +import org.openedx.foundation.presentation.rememberWindowSize class SignUpFragment : Fragment() { diff --git a/auth/src/main/java/org/openedx/auth/presentation/signup/SignUpViewModel.kt b/auth/src/main/java/org/openedx/auth/presentation/signup/SignUpViewModel.kt index 0826fca5c..35da6c030 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/signup/SignUpViewModel.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/signup/SignUpViewModel.kt @@ -22,19 +22,19 @@ import org.openedx.auth.presentation.AuthAnalyticsKey import org.openedx.auth.presentation.AuthRouter import org.openedx.auth.presentation.sso.OAuthHelper import org.openedx.core.ApiConstants -import org.openedx.core.BaseViewModel -import org.openedx.core.UIMessage import org.openedx.core.config.Config import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.model.RegistrationField import org.openedx.core.domain.model.RegistrationFieldType import org.openedx.core.domain.model.createHonorCodeField -import org.openedx.core.extension.isInternetError -import org.openedx.core.system.ResourceManager import org.openedx.core.system.notifier.app.AppNotifier import org.openedx.core.system.notifier.app.AppUpgradeEvent import org.openedx.core.system.notifier.app.SignInEvent import org.openedx.core.utils.Logger +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import org.openedx.core.R as coreR class SignUpViewModel( diff --git a/auth/src/main/java/org/openedx/auth/presentation/signup/compose/SignUpView.kt b/auth/src/main/java/org/openedx/auth/presentation/signup/compose/SignUpView.kt index e1e31c7b8..05c5c1d4e 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/signup/compose/SignUpView.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/signup/compose/SignUpView.kt @@ -21,7 +21,6 @@ import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material.CircularProgressIndicator -import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.MaterialTheme import androidx.compose.material.ModalBottomSheetLayout import androidx.compose.material.ModalBottomSheetValue @@ -68,15 +67,12 @@ import org.openedx.auth.presentation.ui.ExpandableText import org.openedx.auth.presentation.ui.OptionalFields import org.openedx.auth.presentation.ui.RequiredFields import org.openedx.auth.presentation.ui.SocialAuthView -import org.openedx.core.UIMessage import org.openedx.core.domain.model.RegistrationField import org.openedx.core.domain.model.RegistrationFieldType import org.openedx.core.ui.BackBtn import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.OpenEdXButton import org.openedx.core.ui.SheetContent -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape import org.openedx.core.ui.isImeVisibleState import org.openedx.core.ui.noRippleClickable @@ -86,10 +82,13 @@ import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.core.R as coreR -@OptIn(ExperimentalMaterialApi::class, ExperimentalComposeUiApi::class) +@OptIn(ExperimentalComposeUiApi::class) @Composable internal fun SignUpView( windowSize: WindowSize, diff --git a/auth/src/main/java/org/openedx/auth/presentation/sso/FacebookAuthHelper.kt b/auth/src/main/java/org/openedx/auth/presentation/sso/FacebookAuthHelper.kt index f6e734629..0d00e734e 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/sso/FacebookAuthHelper.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/sso/FacebookAuthHelper.kt @@ -12,8 +12,8 @@ import kotlinx.coroutines.suspendCancellableCoroutine import org.openedx.auth.data.model.AuthType import org.openedx.auth.domain.model.SocialAuthResponse import org.openedx.core.ApiConstants -import org.openedx.core.extension.safeResume import org.openedx.core.utils.Logger +import org.openedx.foundation.extension.safeResume import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException diff --git a/auth/src/main/java/org/openedx/auth/presentation/sso/MicrosoftAuthHelper.kt b/auth/src/main/java/org/openedx/auth/presentation/sso/MicrosoftAuthHelper.kt index 7cfcef591..5b75f3896 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/sso/MicrosoftAuthHelper.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/sso/MicrosoftAuthHelper.kt @@ -12,8 +12,8 @@ import org.openedx.auth.data.model.AuthType import org.openedx.auth.domain.model.SocialAuthResponse import org.openedx.core.ApiConstants import org.openedx.core.R -import org.openedx.core.extension.safeResume import org.openedx.core.utils.Logger +import org.openedx.foundation.extension.safeResume import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException diff --git a/auth/src/main/java/org/openedx/auth/presentation/ui/AuthUI.kt b/auth/src/main/java/org/openedx/auth/presentation/ui/AuthUI.kt index 9f75a2478..8e1a31d05 100644 --- a/auth/src/main/java/org/openedx/auth/presentation/ui/AuthUI.kt +++ b/auth/src/main/java/org/openedx/auth/presentation/ui/AuthUI.kt @@ -3,8 +3,8 @@ package org.openedx.auth.presentation.ui import android.content.res.Configuration import androidx.compose.animation.core.MutableTransitionState import androidx.compose.animation.core.animateFloat +import androidx.compose.animation.core.rememberTransition import androidx.compose.animation.core.tween -import androidx.compose.animation.core.updateTransition import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column @@ -55,7 +55,6 @@ import org.openedx.auth.R import org.openedx.core.domain.model.RegistrationField import org.openedx.core.domain.model.RegistrationFieldType import org.openedx.core.extension.TextConverter -import org.openedx.core.extension.tagId import org.openedx.core.ui.HyperlinkText import org.openedx.core.ui.SheetContent import org.openedx.core.ui.noRippleClickable @@ -63,6 +62,7 @@ import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography +import org.openedx.foundation.extension.tagId @Composable fun RequiredFields( @@ -512,7 +512,7 @@ fun ExpandableText( targetState = !isExpanded } } - val transition = updateTransition(transitionState, label = "") + val transition = rememberTransition(transitionState, label = "") val arrowRotationDegree by transition.animateFloat({ tween(durationMillis = 300) }, label = "") { @@ -534,7 +534,6 @@ fun ExpandableText( }, horizontalArrangement = Arrangement.SpaceBetween ) { - //TODO: textStyle Text( modifier = Modifier, text = text, diff --git a/auth/src/test/java/org/openedx/auth/presentation/restore/RestorePasswordViewModelTest.kt b/auth/src/test/java/org/openedx/auth/presentation/restore/RestorePasswordViewModelTest.kt index 0f040e908..580688a48 100644 --- a/auth/src/test/java/org/openedx/auth/presentation/restore/RestorePasswordViewModelTest.kt +++ b/auth/src/test/java/org/openedx/auth/presentation/restore/RestorePasswordViewModelTest.kt @@ -23,10 +23,10 @@ import org.junit.rules.TestRule import org.openedx.auth.domain.interactor.AuthInteractor import org.openedx.auth.presentation.AuthAnalytics import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.system.EdxError -import org.openedx.core.system.ResourceManager import org.openedx.core.system.notifier.app.AppNotifier +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import java.net.UnknownHostException @OptIn(ExperimentalCoroutinesApi::class) diff --git a/auth/src/test/java/org/openedx/auth/presentation/signin/SignInViewModelTest.kt b/auth/src/test/java/org/openedx/auth/presentation/signin/SignInViewModelTest.kt index bef45ad82..48480e310 100644 --- a/auth/src/test/java/org/openedx/auth/presentation/signin/SignInViewModelTest.kt +++ b/auth/src/test/java/org/openedx/auth/presentation/signin/SignInViewModelTest.kt @@ -27,7 +27,6 @@ import org.openedx.auth.presentation.AgreementProvider import org.openedx.auth.presentation.AuthAnalytics import org.openedx.auth.presentation.AuthRouter import org.openedx.auth.presentation.sso.OAuthHelper -import org.openedx.core.UIMessage import org.openedx.core.Validator import org.openedx.core.config.Config import org.openedx.core.config.FacebookConfig @@ -39,10 +38,10 @@ import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.interactor.CalendarInteractor import org.openedx.core.presentation.global.WhatsNewGlobalManager import org.openedx.core.system.EdxError -import org.openedx.core.system.ResourceManager -import org.openedx.core.system.notifier.app.AppEvent import org.openedx.core.system.notifier.app.AppNotifier import org.openedx.core.system.notifier.app.SignInEvent +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import java.net.UnknownHostException import org.openedx.core.R as CoreRes diff --git a/auth/src/test/java/org/openedx/auth/presentation/signup/SignUpViewModelTest.kt b/auth/src/test/java/org/openedx/auth/presentation/signup/SignUpViewModelTest.kt index f61e1053e..90ef8728f 100644 --- a/auth/src/test/java/org/openedx/auth/presentation/signup/SignUpViewModelTest.kt +++ b/auth/src/test/java/org/openedx/auth/presentation/signup/SignUpViewModelTest.kt @@ -33,7 +33,6 @@ import org.openedx.auth.presentation.AuthRouter import org.openedx.auth.presentation.sso.OAuthHelper import org.openedx.core.ApiConstants import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.config.Config import org.openedx.core.config.FacebookConfig import org.openedx.core.config.GoogleConfig @@ -43,8 +42,9 @@ import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.model.AgreementUrls import org.openedx.core.domain.model.RegistrationField import org.openedx.core.domain.model.RegistrationFieldType -import org.openedx.core.system.ResourceManager import org.openedx.core.system.notifier.app.AppNotifier +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import java.net.UnknownHostException @ExperimentalCoroutinesApi diff --git a/build.gradle b/build.gradle index 1dab497e9..e7f7d673b 100644 --- a/build.gradle +++ b/build.gradle @@ -5,19 +5,20 @@ import java.util.regex.Pattern buildscript { ext { - kotlin_version = '1.9.22' - coroutines_version = '1.7.1' - compose_version = '1.6.2' - compose_compiler_version = '1.5.10' + //Depends on versions in OEXFoundation + kotlin_version = '2.0.0' + room_version = '2.6.1' } } plugins { - id 'com.android.application' version '8.4.0' apply false - id 'com.android.library' version '8.4.0' apply false + id 'com.android.application' version '8.5.2' apply false + id 'com.android.library' version '8.5.2' apply false id 'org.jetbrains.kotlin.android' version "$kotlin_version" apply false - id 'com.google.gms.google-services' version '4.4.1' apply false - id "com.google.firebase.crashlytics" version "3.0.1" apply false + id 'com.google.gms.google-services' version '4.4.2' apply false + id "com.google.firebase.crashlytics" version "3.0.2" apply false + id "com.google.devtools.ksp" version "2.0.0-1.0.24" apply false + id "org.jetbrains.kotlin.plugin.compose" version "$kotlin_version" apply false } tasks.register('clean', Delete) { @@ -25,44 +26,22 @@ tasks.register('clean', Delete) { } ext { - core_version = "1.10.1" - appcompat_version = "1.6.1" - material_version = "1.11.0" - lifecycle_version = "2.7.0" - fragment_version = "1.6.2" - constraintlayout_version = "2.1.4" - viewpager2_version = "1.0.0" - media3_version = "1.1.1" + media3_version = "1.4.1" youtubeplayer_version = "11.1.0" firebase_version = "33.0.0" - retrofit_version = '2.11.0' - logginginterceptor_version = '4.9.1' - - koin_version = '3.5.6' - - coil_version = '2.3.0' - jsoup_version = '1.13.1' - room_version = '2.6.1' - - work_version = '2.9.0' - - window_version = '1.2.0' - in_app_review = '2.0.1' extented_spans_version = "1.3.0" - webkit_version = "1.11.0" - configHelper = new ConfigHelper(projectDir, getCurrentFlavor()) zip_version = '2.6.3' //testing - mockk_version = '1.13.3' + mockk_version = '1.13.12' android_arch_version = '2.2.0' junit_version = '4.13.2' } @@ -84,6 +63,6 @@ def getCurrentFlavor() { } } -task generateMockedRawFile() { +tasks.register('generateMockedRawFile') { doLast { configHelper.generateMicrosoftConfig() } } diff --git a/core/build.gradle b/core/build.gradle index f135f62fd..f1ae6be5e 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -4,7 +4,7 @@ buildscript { } dependencies { - classpath 'org.yaml:snakeyaml:1.33' + classpath 'org.yaml:snakeyaml:2.0' } } @@ -12,7 +12,8 @@ plugins { id 'com.android.library' id 'org.jetbrains.kotlin.android' id 'kotlin-parcelize' - id 'kotlin-kapt' + id 'com.google.devtools.ksp' + id "org.jetbrains.kotlin.plugin.compose" } def currentFlavour = getCurrentFlavor() @@ -88,91 +89,39 @@ android { compose true buildConfig true } - composeOptions { - kotlinCompilerExtensionVersion = "$compose_compiler_version" - } } dependencies { api fileTree(dir: 'libs', include: ['*.jar']) - api "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version" - api "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version" - - //AndroidX - api "androidx.core:core-ktx:$core_version" - api "androidx.appcompat:appcompat:$appcompat_version" - api "com.google.android.material:material:$material_version" - api "androidx.fragment:fragment-ktx:$fragment_version" - api "androidx.constraintlayout:constraintlayout:$constraintlayout_version" - api "androidx.viewpager2:viewpager2:$viewpager2_version" - api "androidx.window:window:$window_version" - api "androidx.work:work-runtime-ktx:$work_version" - - //Android Jetpack - api "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version" - api "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version" - api "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version" - api "androidx.lifecycle:lifecycle-runtime-compose:$lifecycle_version" - - // Fullstory - api 'com.fullstory:instrumentation-full:1.47.0@aar' - api 'com.fullstory:compose:1.47.0@aar' - // Room - api "androidx.room:room-runtime:$room_version" - api "androidx.room:room-ktx:$room_version" - kapt "androidx.room:room-compiler:$room_version" - - //Compose - api "androidx.compose.runtime:runtime:$compose_version" - api "androidx.compose.runtime:runtime-livedata:$compose_version" - api "androidx.compose.ui:ui:$compose_version" - api "androidx.compose.material:material:$compose_version" - api "androidx.compose.foundation:foundation:$compose_version" - debugApi "androidx.compose.ui:ui-tooling:$compose_version" - api "androidx.compose.ui:ui-tooling-preview:$compose_version" - api "androidx.compose.material:material-icons-extended:$compose_version" - debugApi "androidx.customview:customview:1.2.0-alpha02" - debugApi "androidx.customview:customview-poolingcontainer:1.0.0" - - //Networking - api "com.squareup.retrofit2:retrofit:$retrofit_version" - api "com.squareup.retrofit2:converter-gson:$retrofit_version" - api "com.squareup.okhttp3:logging-interceptor:$logginginterceptor_version" - - // Koin DI - api "io.insert-koin:koin-core:$koin_version" - api "io.insert-koin:koin-android:$koin_version" - api "io.insert-koin:koin-androidx-compose:$koin_version" - - api "io.coil-kt:coil-compose:$coil_version" - api "io.coil-kt:coil-gif:$coil_version" + ksp "androidx.room:room-compiler:$room_version" + // jsoup api "org.jsoup:jsoup:$jsoup_version" + // Firebase api platform("com.google.firebase:firebase-bom:$firebase_version") api 'com.google.firebase:firebase-common-ktx' api "com.google.firebase:firebase-crashlytics-ktx" - api "com.google.firebase:firebase-analytics-ktx" //Play In-App Review api "com.google.android.play:review-ktx:$in_app_review" - api "androidx.webkit:webkit:$webkit_version" - // Branch SDK Integration api "io.branch.sdk.android:library:5.9.0" - api "com.google.android.gms:play-services-ads-identifier:18.0.1" + api "com.google.android.gms:play-services-ads-identifier:18.1.0" api "com.android.installreferrer:installreferrer:2.2" // Zip api "net.lingala.zip4j:zip4j:$zip_version" + // OpenEdx libs + api("com.github.openedx:openedx-app-foundation-android:1.0.0") + testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + androidTestImplementation 'androidx.test.ext:junit:1.2.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' } def insertBuildConfigFields(currentFlavour, buildType) { diff --git a/core/src/main/java/org/openedx/core/BaseViewModel.kt b/core/src/main/java/org/openedx/core/BaseViewModel.kt deleted file mode 100644 index ac0578624..000000000 --- a/core/src/main/java/org/openedx/core/BaseViewModel.kt +++ /dev/null @@ -1,6 +0,0 @@ -package org.openedx.core - -import androidx.lifecycle.DefaultLifecycleObserver -import androidx.lifecycle.ViewModel - -open class BaseViewModel : ViewModel(), DefaultLifecycleObserver \ No newline at end of file diff --git a/core/src/main/java/org/openedx/core/SingleEventLiveData.kt b/core/src/main/java/org/openedx/core/SingleEventLiveData.kt deleted file mode 100644 index dfa53c6dd..000000000 --- a/core/src/main/java/org/openedx/core/SingleEventLiveData.kt +++ /dev/null @@ -1,39 +0,0 @@ -package org.openedx.core - -import androidx.annotation.MainThread -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.MutableLiveData -import androidx.lifecycle.Observer - -class SingleEventLiveData : MutableLiveData() { - - @MainThread - override fun observe(owner: LifecycleOwner, observer: Observer) { - - // Being strict about the observer numbers is up to you - // I thought it made sense to only allow one to handle the event - if (hasActiveObservers()) { - throw IllegalAccessException("Only one observer at a time may observe to a SingleEventLiveData") - } - - super.observe(owner, Observer { data -> - // We ignore any null values and early return - if (data == null) return@Observer - observer.onChanged(data) - // We set the value to null straight after emitting the change to the observer - value = null - // This means that the state of the data will always be null / non existent - // It will only be available to the observer in its callback and since we do not emit null values - // the observer never receives a null value and any observers resuming do not receive the last event. - // Therefore it only emits to the observer the single action - // so you are free to show messages over and over again - // Or launch an activity/dialog or anything that should only happen once per action / click :). - }) - } - - // Just a nicely named method that wraps setting the value - @MainThread - fun sendAction(data: T) { - value = data - } -} \ No newline at end of file diff --git a/core/src/main/java/org/openedx/core/UIMessage.kt b/core/src/main/java/org/openedx/core/UIMessage.kt deleted file mode 100644 index 8a9267f36..000000000 --- a/core/src/main/java/org/openedx/core/UIMessage.kt +++ /dev/null @@ -1,12 +0,0 @@ -package org.openedx.core - -import androidx.compose.material.SnackbarDuration - -open class UIMessage { - class SnackBarMessage( - val message: String, - val duration: SnackbarDuration = SnackbarDuration.Long, - ) : UIMessage() - - class ToastMessage(val message: String) : UIMessage() -} diff --git a/core/src/main/java/org/openedx/core/config/AnalyticsSource.kt b/core/src/main/java/org/openedx/core/config/AnalyticsSource.kt deleted file mode 100644 index b3ee82211..000000000 --- a/core/src/main/java/org/openedx/core/config/AnalyticsSource.kt +++ /dev/null @@ -1,11 +0,0 @@ -package org.openedx.core.config - -import com.google.gson.annotations.SerializedName - -enum class AnalyticsSource { - @SerializedName("segment") - SEGMENT, - - @SerializedName("none") - NONE, -} diff --git a/core/src/main/java/org/openedx/core/config/Config.kt b/core/src/main/java/org/openedx/core/config/Config.kt index c97bf7b47..e38a923b5 100644 --- a/core/src/main/java/org/openedx/core/config/Config.kt +++ b/core/src/main/java/org/openedx/core/config/Config.kt @@ -60,14 +60,6 @@ class Config(context: Context) { return getObjectOrNewInstance(FIREBASE, FirebaseConfig::class.java) } - fun getSegmentConfig(): SegmentConfig { - return getObjectOrNewInstance(SEGMENT_IO, SegmentConfig::class.java) - } - - fun getFullstoryConfig(): FullstoryConfig { - return getObjectOrNewInstance(FULLSTORY, FullstoryConfig::class.java) - } - fun getBrazeConfig(): BrazeConfig { return getObjectOrNewInstance(BRAZE, BrazeConfig::class.java) } @@ -164,8 +156,6 @@ class Config(context: Context) { private const val WHATS_NEW_ENABLED = "WHATS_NEW_ENABLED" private const val SOCIAL_AUTH_ENABLED = "SOCIAL_AUTH_ENABLED" private const val FIREBASE = "FIREBASE" - private const val SEGMENT_IO = "SEGMENT_IO" - private const val FULLSTORY = "FULLSTORY" private const val BRAZE = "BRAZE" private const val FACEBOOK = "FACEBOOK" private const val GOOGLE = "GOOGLE" diff --git a/core/src/main/java/org/openedx/core/config/FirebaseConfig.kt b/core/src/main/java/org/openedx/core/config/FirebaseConfig.kt index f5b2e9136..878b1e734 100644 --- a/core/src/main/java/org/openedx/core/config/FirebaseConfig.kt +++ b/core/src/main/java/org/openedx/core/config/FirebaseConfig.kt @@ -6,9 +6,6 @@ data class FirebaseConfig( @SerializedName("ENABLED") val enabled: Boolean = false, - @SerializedName("ANALYTICS_SOURCE") - val analyticsSource: AnalyticsSource = AnalyticsSource.NONE, - @SerializedName("CLOUD_MESSAGING_ENABLED") val isCloudMessagingEnabled: Boolean = false, @@ -23,8 +20,4 @@ data class FirebaseConfig( @SerializedName("API_KEY") val apiKey: String = "", -) { - fun isSegmentAnalyticsSource(): Boolean { - return enabled && analyticsSource == AnalyticsSource.SEGMENT - } -} +) diff --git a/core/src/main/java/org/openedx/core/config/FullstoryConfig.kt b/core/src/main/java/org/openedx/core/config/FullstoryConfig.kt deleted file mode 100644 index 00bc00e81..000000000 --- a/core/src/main/java/org/openedx/core/config/FullstoryConfig.kt +++ /dev/null @@ -1,11 +0,0 @@ -package org.openedx.core.config - -import com.google.gson.annotations.SerializedName - -data class FullstoryConfig( - @SerializedName("ENABLED") - val isEnabled: Boolean = false, - - @SerializedName("ORG_ID") - private val orgId: String = "" -) diff --git a/core/src/main/java/org/openedx/core/config/SegmentConfig.kt b/core/src/main/java/org/openedx/core/config/SegmentConfig.kt deleted file mode 100644 index ffa43e8bc..000000000 --- a/core/src/main/java/org/openedx/core/config/SegmentConfig.kt +++ /dev/null @@ -1,11 +0,0 @@ -package org.openedx.core.config - -import com.google.gson.annotations.SerializedName - -data class SegmentConfig( - @SerializedName("ENABLED") - val enabled: Boolean = false, - - @SerializedName("SEGMENT_IO_WRITE_KEY") - val segmentWriteKey: String = "", -) diff --git a/core/src/main/java/org/openedx/core/extension/AssetExt.kt b/core/src/main/java/org/openedx/core/extension/AssetExt.kt deleted file mode 100644 index 190f68721..000000000 --- a/core/src/main/java/org/openedx/core/extension/AssetExt.kt +++ /dev/null @@ -1,15 +0,0 @@ -package org.openedx.core.extension - -import android.content.res.AssetManager -import android.util.Log -import java.io.BufferedReader - -fun AssetManager.readAsText(fileName: String): String? { - return try { - open(fileName).bufferedReader().use(BufferedReader::readText) - } catch (e: Exception) { - Log.e("AssetExt", "Unable to load file $fileName from assets") - e.printStackTrace() - null - } -} diff --git a/core/src/main/java/org/openedx/core/extension/BundleExt.kt b/core/src/main/java/org/openedx/core/extension/BundleExt.kt deleted file mode 100644 index 59c0b9f93..000000000 --- a/core/src/main/java/org/openedx/core/extension/BundleExt.kt +++ /dev/null @@ -1,34 +0,0 @@ -@file:Suppress("NOTHING_TO_INLINE") - -package org.openedx.core.extension - -import android.os.Build.VERSION.SDK_INT -import android.os.Bundle -import android.os.Parcelable -import com.google.gson.Gson -import java.io.Serializable - -inline fun Bundle.parcelable(key: String): T? = when { - SDK_INT >= 33 -> getParcelable(key, T::class.java) - else -> @Suppress("DEPRECATION") getParcelable(key) as? T -} - -inline fun Bundle.serializable(key: String): T? = when { - SDK_INT >= 33 -> getSerializable(key, T::class.java) - else -> @Suppress("DEPRECATION") getSerializable(key) as? T -} - -inline fun Bundle.parcelableArrayList(key: String): ArrayList? = when { - SDK_INT >= 33 -> getParcelableArrayList(key, T::class.java) - else -> @Suppress("DEPRECATION") getParcelableArrayList(key) -} - -inline fun objectToString(value: T): String = Gson().toJson(value) - -inline fun stringToObject(value: String): T? { - return try { - Gson().fromJson(value, genericType()) - } catch (e: Exception) { - null - } -} diff --git a/core/src/main/java/org/openedx/core/extension/ContinuationExt.kt b/core/src/main/java/org/openedx/core/extension/ContinuationExt.kt deleted file mode 100644 index 8de4ec05b..000000000 --- a/core/src/main/java/org/openedx/core/extension/ContinuationExt.kt +++ /dev/null @@ -1,12 +0,0 @@ -package org.openedx.core.extension - -import kotlinx.coroutines.CancellableContinuation -import kotlin.coroutines.resume - -inline fun CancellableContinuation.safeResume(value: T, onExceptionCalled: () -> Unit) { - if (isActive) { - resume(value) - } else { - onExceptionCalled() - } -} diff --git a/core/src/main/java/org/openedx/core/extension/FlowExtension.kt b/core/src/main/java/org/openedx/core/extension/FlowExtension.kt deleted file mode 100644 index e88aff9ac..000000000 --- a/core/src/main/java/org/openedx/core/extension/FlowExtension.kt +++ /dev/null @@ -1,18 +0,0 @@ -package org.openedx.core.extension - -import androidx.lifecycle.Lifecycle -import androidx.lifecycle.LifecycleOwner -import androidx.lifecycle.lifecycleScope -import androidx.lifecycle.repeatOnLifecycle -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.launch - -fun Flow.doWorkWhenStarted(lifecycleOwner: LifecycleOwner, doWork: (it: T) -> Unit) { - lifecycleOwner.lifecycleScope.launch { - lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) { - this@doWorkWhenStarted.collect { - doWork(it) - } - } - } -} \ No newline at end of file diff --git a/core/src/main/java/org/openedx/core/extension/FragmentExt.kt b/core/src/main/java/org/openedx/core/extension/FragmentExt.kt deleted file mode 100644 index 5d340b55d..000000000 --- a/core/src/main/java/org/openedx/core/extension/FragmentExt.kt +++ /dev/null @@ -1,28 +0,0 @@ -package org.openedx.core.extension - -import androidx.fragment.app.Fragment -import androidx.window.layout.WindowMetricsCalculator -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType - -fun Fragment.computeWindowSizeClasses(): WindowSize { - val metrics = WindowMetricsCalculator.getOrCreate() - .computeCurrentWindowMetrics(requireActivity()) - - val widthDp = metrics.bounds.width() / - resources.displayMetrics.density - val widthWindowSize = when { - widthDp < 600f -> WindowType.Compact - widthDp < 840f -> WindowType.Medium - else -> WindowType.Expanded - } - - val heightDp = metrics.bounds.height() / - resources.displayMetrics.density - val heightWindowSize = when { - heightDp < 480f -> WindowType.Compact - heightDp < 900f -> WindowType.Medium - else -> WindowType.Expanded - } - return WindowSize(widthWindowSize, heightWindowSize) -} \ No newline at end of file diff --git a/core/src/main/java/org/openedx/core/extension/GsonExt.kt b/core/src/main/java/org/openedx/core/extension/GsonExt.kt deleted file mode 100644 index 579a5ee6d..000000000 --- a/core/src/main/java/org/openedx/core/extension/GsonExt.kt +++ /dev/null @@ -1,9 +0,0 @@ -package org.openedx.core.extension - -import com.google.gson.Gson -import com.google.gson.reflect.TypeToken - -inline fun genericType() = object: TypeToken() {}.type - -inline fun Gson.fromJson(json: String) = fromJson(json, object: TypeToken() {}.type) - diff --git a/core/src/main/java/org/openedx/core/extension/ImageUploaderExtension.kt b/core/src/main/java/org/openedx/core/extension/ImageUploaderExtension.kt deleted file mode 100644 index a716544ca..000000000 --- a/core/src/main/java/org/openedx/core/extension/ImageUploaderExtension.kt +++ /dev/null @@ -1,17 +0,0 @@ -package org.openedx.core.extension - -import android.content.ContentResolver -import android.net.Uri -import android.provider.OpenableColumns - -fun ContentResolver.getFileName(fileUri: Uri): String { - var name = "" - val returnCursor = this.query(fileUri, null, null, null, null) - if (returnCursor != null) { - val nameIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME) - returnCursor.moveToFirst() - name = returnCursor.getString(nameIndex) - returnCursor.close() - } - return name -} \ No newline at end of file diff --git a/core/src/main/java/org/openedx/core/extension/IntExt.kt b/core/src/main/java/org/openedx/core/extension/IntExt.kt deleted file mode 100644 index 5739007f5..000000000 --- a/core/src/main/java/org/openedx/core/extension/IntExt.kt +++ /dev/null @@ -1,5 +0,0 @@ -package org.openedx.core.extension - -fun Int.nonZero(): Int? { - return if (this != 0) this else null -} diff --git a/core/src/main/java/org/openedx/core/extension/ListExt.kt b/core/src/main/java/org/openedx/core/extension/ListExt.kt index 1c2a242f7..6d97816ae 100644 --- a/core/src/main/java/org/openedx/core/extension/ListExt.kt +++ b/core/src/main/java/org/openedx/core/extension/ListExt.kt @@ -3,30 +3,6 @@ package org.openedx.core.extension import org.openedx.core.BlockType import org.openedx.core.domain.model.Block -inline fun List.indexOfFirstFromIndex(startIndex: Int, predicate: (T) -> Boolean): Int { - var index = 0 - for ((i, item) in this.withIndex()) { - if (i > startIndex) { - if (predicate(item)) - return index - } - index++ - } - return -1 -} - -fun ArrayList.clearAndAddAll(collection: Collection): ArrayList { - this.clear() - this.addAll(collection) - return this -} - -fun MutableList.clearAndAddAll(collection: Collection): MutableList { - this.clear() - this.addAll(collection) - return this -} - fun List.getVerticalBlocks(): List { return this.filter { it.type == BlockType.VERTICAL } } @@ -34,9 +10,3 @@ fun List.getVerticalBlocks(): List { fun List.getSequentialBlocks(): List { return this.filter { it.type == BlockType.SEQUENTIAL } } - -fun List?.isNotEmptyThenLet(block: (List) -> Unit) { - if (!isNullOrEmpty()) { - block(this) - } -} diff --git a/core/src/main/java/org/openedx/core/extension/LongExt.kt b/core/src/main/java/org/openedx/core/extension/LongExt.kt deleted file mode 100644 index 2071b6946..000000000 --- a/core/src/main/java/org/openedx/core/extension/LongExt.kt +++ /dev/null @@ -1,18 +0,0 @@ -package org.openedx.core.extension - -import kotlin.math.log10 -import kotlin.math.pow - -fun Long.toFileSize(round: Int = 2, space: Boolean = true): String { - try { - if (this <= 0) return "0MB" - val units = arrayOf("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB") - val digitGroups = (log10(this.toDouble()) / log10(1024.0)).toInt() - val size = this / 1024.0.pow(digitGroups.toDouble()) - val formatString = if (size % 1 < 0.05 || size % 1 >= 0.95) "%.0f" else "%.${round}f" - return String.format(formatString, size) + if (space) " " else "" + units[digitGroups] - } catch (e: Exception) { - println(e.toString()) - } - return "" -} diff --git a/core/src/main/java/org/openedx/core/extension/MapExt.kt b/core/src/main/java/org/openedx/core/extension/MapExt.kt deleted file mode 100644 index f985d119d..000000000 --- a/core/src/main/java/org/openedx/core/extension/MapExt.kt +++ /dev/null @@ -1,13 +0,0 @@ -package org.openedx.core.extension - -import android.os.Bundle - -fun Map.toBundle(): Bundle { - val bundle = Bundle() - for ((key, value) in this.entries) { - value?.let { - bundle.putString(key, it.toString()) - } - } - return bundle -} diff --git a/core/src/main/java/org/openedx/core/extension/StringExt.kt b/core/src/main/java/org/openedx/core/extension/StringExt.kt index 0ecc86e1f..301e9deb9 100644 --- a/core/src/main/java/org/openedx/core/extension/StringExt.kt +++ b/core/src/main/java/org/openedx/core/extension/StringExt.kt @@ -1,43 +1,6 @@ package org.openedx.core.extension -import android.util.Patterns import java.net.URL -import java.util.Locale -import java.util.regex.Pattern - - -fun String.isEmailValid(): Boolean { - val regex = - "^[\\w!#$%&'*+/=?`{|}~^-]+(?:\\.[\\w!#$%&'*+/=?`{|}~^-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,6}$" - return Pattern.compile(regex).matcher(this).matches() -} - -fun String.isLinkValid() = Patterns.WEB_URL.matcher(this).matches() - -fun String.replaceLinkTags(isDarkTheme: Boolean): String { - val linkColor = if (isDarkTheme) "879FF5" else "0000EE" - var text = ("" - + "" - + "" + this) + "" - var str: String - while (text.indexOf("\u0082") > 0) { - if (text.indexOf("\u0082") > 0 && text.indexOf("\u0083") > 0) { - str = text.substring(text.indexOf("\u0082") + 1, text.indexOf("\u0083")) - text = text.replace(("\u0082" + str + "\u0083").toRegex(), "$str") - } - } - return text -} - -fun String.replaceSpace(target: String = ""): String = this.replace(" ", target) - -fun String.tagId(): String = this.replaceSpace("_").lowercase(Locale.getDefault()) - -fun String.takeIfNotEmpty(): String? { - return if (this.isEmpty().not()) this else null -} fun String?.equalsHost(host: String?): Boolean { return try { @@ -46,10 +9,3 @@ fun String?.equalsHost(host: String?): Boolean { false } } - -fun String.toImageLink(apiHostURL: String): String = - if (this.isLinkValid()) { - this - } else { - (apiHostURL + this).replace(Regex("(? { - val paramsMap = mutableMapOf() - - queryParameterNames.forEach { name -> - getQueryParameter(name)?.let { value -> - paramsMap[name] = value - } - } - - return paramsMap -} diff --git a/core/src/main/java/org/openedx/core/extension/ViewExt.kt b/core/src/main/java/org/openedx/core/extension/ViewExt.kt index 498619480..81a153ba1 100644 --- a/core/src/main/java/org/openedx/core/extension/ViewExt.kt +++ b/core/src/main/java/org/openedx/core/extension/ViewExt.kt @@ -1,59 +1,10 @@ package org.openedx.core.extension -import android.content.Context -import android.content.res.Resources -import android.graphics.Rect -import android.os.Build -import android.util.DisplayMetrics -import android.view.View -import android.view.ViewGroup import android.webkit.WebView -import android.widget.Toast -import androidx.fragment.app.DialogFragment -import androidx.webkit.WebSettingsCompat -import androidx.webkit.WebViewFeature import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch import org.openedx.core.system.AppCookieManager -fun Context.dpToPixel(dp: Int): Float { - return dp * (resources.displayMetrics.densityDpi.toFloat() / DisplayMetrics.DENSITY_DEFAULT) -} - -fun Context.dpToPixel(dp: Float): Float { - return dp * (resources.displayMetrics.densityDpi.toFloat() / DisplayMetrics.DENSITY_DEFAULT) -} - -fun View.requestApplyInsetsWhenAttached() { - if (isAttachedToWindow) { - // We're already attached, just request as normal - requestApplyInsets() - } else { - // We're not attached to the hierarchy, add a listener to - // request when we are - addOnAttachStateChangeListener(object : View.OnAttachStateChangeListener { - override fun onViewAttachedToWindow(v: View) { - v.removeOnAttachStateChangeListener(this) - v.requestApplyInsets() - } - - override fun onViewDetachedFromWindow(v: View) = Unit - }) - } -} - -fun DialogFragment.setWidthPercent(percentage: Int) { - val percent = percentage.toFloat() / 100 - val dm = Resources.getSystem().displayMetrics - val rect = dm.run { Rect(0, 0, widthPixels, heightPixels) } - val percentWidth = rect.width() * percent - dialog?.window?.setLayout(percentWidth.toInt(), ViewGroup.LayoutParams.WRAP_CONTENT) -} - -fun Context.toastMessage(message: String) { - Toast.makeText(this, message, Toast.LENGTH_SHORT).show() -} - fun WebView.loadUrl(url: String, scope: CoroutineScope, cookieManager: AppCookieManager) { if (cookieManager.isSessionCookieMissingOrExpired()) { scope.launch { @@ -64,13 +15,3 @@ fun WebView.loadUrl(url: String, scope: CoroutineScope, cookieManager: AppCookie loadUrl(url) } } - -fun WebView.applyDarkModeIfEnabled(isDarkTheme: Boolean) { - if (isDarkTheme && WebViewFeature.isFeatureSupported(WebViewFeature.ALGORITHMIC_DARKENING)) { - try { - WebSettingsCompat.setAlgorithmicDarkeningAllowed(settings, true) - } catch (e: Exception) { - e.printStackTrace() - } - } -} diff --git a/core/src/main/java/org/openedx/core/module/DownloadWorker.kt b/core/src/main/java/org/openedx/core/module/DownloadWorker.kt index 2186dbfc6..b3c211916 100644 --- a/core/src/main/java/org/openedx/core/module/DownloadWorker.kt +++ b/core/src/main/java/org/openedx/core/module/DownloadWorker.kt @@ -26,7 +26,7 @@ import org.openedx.core.module.download.FileDownloader import org.openedx.core.system.notifier.DownloadFailed import org.openedx.core.system.notifier.DownloadNotifier import org.openedx.core.system.notifier.DownloadProgressChanged -import org.openedx.core.utils.FileUtil +import org.openedx.foundation.utils.FileUtil class DownloadWorker( val context: Context, @@ -43,7 +43,8 @@ class DownloadWorker( private var downloadEnqueue = listOf() private var downloadError = mutableListOf() - private val folder = FileUtil(context).getExternalAppDir() + private val fileUtil: FileUtil by inject(FileUtil::class.java) + private val folder = fileUtil.getExternalAppDir() private var currentDownload: DownloadModel? = null private var lastUpdateTime = 0L diff --git a/core/src/main/java/org/openedx/core/module/TranscriptManager.kt b/core/src/main/java/org/openedx/core/module/TranscriptManager.kt index 114fc3147..6db81533c 100644 --- a/core/src/main/java/org/openedx/core/module/TranscriptManager.kt +++ b/core/src/main/java/org/openedx/core/module/TranscriptManager.kt @@ -4,9 +4,9 @@ import android.content.Context import okhttp3.OkHttpClient import org.openedx.core.module.download.AbstractDownloader import org.openedx.core.utils.Directories -import org.openedx.core.utils.FileUtil import org.openedx.core.utils.IOUtils import org.openedx.core.utils.Sha1Util +import org.openedx.foundation.utils.FileUtil import subtitleFile.FormatSRT import subtitleFile.TimedTextObject import java.io.File @@ -18,6 +18,7 @@ import java.util.concurrent.TimeUnit class TranscriptManager( val context: Context, + val fileUtil: FileUtil ) { private val transcriptDownloader = object : AbstractDownloader() { @@ -118,7 +119,7 @@ class TranscriptManager( } private fun getTranscriptDir(): File? { - val externalAppDir: File = FileUtil(context).getExternalAppDir() + val externalAppDir: File = fileUtil.getExternalAppDir() if (externalAppDir.exists()) { val videosDir = File(externalAppDir, Directories.VIDEOS.name) val transcriptDir = File(videosDir, Directories.SUBTITLES.name) diff --git a/core/src/main/java/org/openedx/core/module/download/BaseDownloadViewModel.kt b/core/src/main/java/org/openedx/core/module/download/BaseDownloadViewModel.kt index 40d3f1f41..b6635047f 100644 --- a/core/src/main/java/org/openedx/core/module/download/BaseDownloadViewModel.kt +++ b/core/src/main/java/org/openedx/core/module/download/BaseDownloadViewModel.kt @@ -6,7 +6,6 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.map import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.BlockType import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.model.Block @@ -17,6 +16,7 @@ import org.openedx.core.module.db.DownloadedState import org.openedx.core.presentation.CoreAnalytics import org.openedx.core.presentation.CoreAnalyticsEvent import org.openedx.core.presentation.CoreAnalyticsKey +import org.openedx.foundation.presentation.BaseViewModel abstract class BaseDownloadViewModel( private val courseId: String, diff --git a/core/src/main/java/org/openedx/core/module/download/DownloadHelper.kt b/core/src/main/java/org/openedx/core/module/download/DownloadHelper.kt index 7c687f58e..79e44ab3c 100644 --- a/core/src/main/java/org/openedx/core/module/download/DownloadHelper.kt +++ b/core/src/main/java/org/openedx/core/module/download/DownloadHelper.kt @@ -5,8 +5,9 @@ import org.openedx.core.domain.model.Block import org.openedx.core.module.db.DownloadModel import org.openedx.core.module.db.DownloadedState import org.openedx.core.module.db.FileType -import org.openedx.core.utils.FileUtil import org.openedx.core.utils.Sha1Util +import org.openedx.core.utils.unzipFile +import org.openedx.foundation.utils.FileUtil import java.io.File class DownloadHelper( diff --git a/core/src/main/java/org/openedx/core/presentation/dialog/alert/ActionDialogFragment.kt b/core/src/main/java/org/openedx/core/presentation/dialog/alert/ActionDialogFragment.kt index b7b3167e6..451d94915 100644 --- a/core/src/main/java/org/openedx/core/presentation/dialog/alert/ActionDialogFragment.kt +++ b/core/src/main/java/org/openedx/core/presentation/dialog/alert/ActionDialogFragment.kt @@ -40,7 +40,7 @@ import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography -import org.openedx.core.utils.UrlUtils +import org.openedx.foundation.utils.UrlUtils class ActionDialogFragment : DialogFragment() { diff --git a/core/src/main/java/org/openedx/core/presentation/dialog/appreview/BaseAppReviewDialogFragment.kt b/core/src/main/java/org/openedx/core/presentation/dialog/appreview/BaseAppReviewDialogFragment.kt index 57dcdc233..245b8fe11 100644 --- a/core/src/main/java/org/openedx/core/presentation/dialog/appreview/BaseAppReviewDialogFragment.kt +++ b/core/src/main/java/org/openedx/core/presentation/dialog/appreview/BaseAppReviewDialogFragment.kt @@ -3,8 +3,8 @@ package org.openedx.core.presentation.dialog.appreview import androidx.fragment.app.DialogFragment import org.koin.android.ext.android.inject import org.openedx.core.data.storage.InAppReviewPreferences -import org.openedx.core.extension.nonZero import org.openedx.core.presentation.global.AppData +import org.openedx.foundation.extension.nonZero open class BaseAppReviewDialogFragment : DialogFragment() { diff --git a/core/src/main/java/org/openedx/core/presentation/dialog/selectorbottomsheet/SelectBottomDialogFragment.kt b/core/src/main/java/org/openedx/core/presentation/dialog/selectorbottomsheet/SelectBottomDialogFragment.kt index e2b6bdd58..8eca02a99 100644 --- a/core/src/main/java/org/openedx/core/presentation/dialog/selectorbottomsheet/SelectBottomDialogFragment.kt +++ b/core/src/main/java/org/openedx/core/presentation/dialog/selectorbottomsheet/SelectBottomDialogFragment.kt @@ -32,13 +32,13 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment import org.koin.androidx.viewmodel.ext.android.viewModel import org.openedx.core.R import org.openedx.core.domain.model.RegistrationField -import org.openedx.core.extension.parcelableArrayList import org.openedx.core.ui.SheetContent import org.openedx.core.ui.isImeVisibleState import org.openedx.core.ui.noRippleClickable import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes +import org.openedx.foundation.extension.parcelableArrayList class SelectBottomDialogFragment : BottomSheetDialogFragment() { @@ -95,7 +95,7 @@ class SelectBottomDialogFragment : BottomSheetDialogFragment() { ) .clip(MaterialTheme.appShapes.screenBackgroundShape) .padding(bottom = if (isImeVisible) 120.dp else 0.dp) - .noRippleClickable { } + .noRippleClickable { } ) { SheetContent( searchValue = searchValue, diff --git a/core/src/main/java/org/openedx/core/presentation/dialog/selectorbottomsheet/SelectDialogViewModel.kt b/core/src/main/java/org/openedx/core/presentation/dialog/selectorbottomsheet/SelectDialogViewModel.kt index 6a09f5724..84d6d1407 100644 --- a/core/src/main/java/org/openedx/core/presentation/dialog/selectorbottomsheet/SelectDialogViewModel.kt +++ b/core/src/main/java/org/openedx/core/presentation/dialog/selectorbottomsheet/SelectDialogViewModel.kt @@ -1,11 +1,11 @@ package org.openedx.core.presentation.dialog.selectorbottomsheet import androidx.lifecycle.viewModelScope -import org.openedx.core.BaseViewModel +import kotlinx.coroutines.launch import org.openedx.core.domain.model.RegistrationField import org.openedx.core.system.notifier.CourseNotifier import org.openedx.core.system.notifier.CourseSubtitleLanguageChanged -import kotlinx.coroutines.launch +import org.openedx.foundation.presentation.BaseViewModel class SelectDialogViewModel( private val notifier: CourseNotifier diff --git a/core/src/main/java/org/openedx/core/presentation/global/WindowSizeHolder.kt b/core/src/main/java/org/openedx/core/presentation/global/WindowSizeHolder.kt index 463f27ef2..510163b70 100644 --- a/core/src/main/java/org/openedx/core/presentation/global/WindowSizeHolder.kt +++ b/core/src/main/java/org/openedx/core/presentation/global/WindowSizeHolder.kt @@ -1,7 +1,7 @@ package org.openedx.core.presentation.global -import org.openedx.core.ui.WindowSize +import org.openedx.foundation.presentation.WindowSize interface WindowSizeHolder { val windowSize: WindowSize -} \ No newline at end of file +} diff --git a/core/src/main/java/org/openedx/core/presentation/global/webview/WebContentFragment.kt b/core/src/main/java/org/openedx/core/presentation/global/webview/WebContentFragment.kt index b1a496743..567a8ccce 100644 --- a/core/src/main/java/org/openedx/core/presentation/global/webview/WebContentFragment.kt +++ b/core/src/main/java/org/openedx/core/presentation/global/webview/WebContentFragment.kt @@ -11,8 +11,8 @@ 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 +import org.openedx.foundation.presentation.rememberWindowSize class WebContentFragment : Fragment() { diff --git a/core/src/main/java/org/openedx/core/presentation/settings/calendarsync/CalendarSyncDialog.kt b/core/src/main/java/org/openedx/core/presentation/settings/calendarsync/CalendarSyncDialog.kt index ac358228e..f53e27e90 100644 --- a/core/src/main/java/org/openedx/core/presentation/settings/calendarsync/CalendarSyncDialog.kt +++ b/core/src/main/java/org/openedx/core/presentation/settings/calendarsync/CalendarSyncDialog.kt @@ -24,12 +24,12 @@ import androidx.compose.ui.tooling.preview.PreviewParameterProvider import androidx.compose.ui.unit.dp import androidx.compose.ui.window.Dialog import org.openedx.core.R -import org.openedx.core.extension.takeIfNotEmpty import org.openedx.core.presentation.global.app_upgrade.TransparentTextButton import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography +import org.openedx.foundation.extension.takeIfNotEmpty import androidx.compose.ui.window.DialogProperties as AlertDialogProperties import org.openedx.core.R as CoreR @@ -230,5 +230,5 @@ private fun CalendarSyncDialogsPreview( } private class CalendarSyncDialogTypeProvider : PreviewParameterProvider { - override val values = CalendarSyncDialogType.values().dropLast(1).asSequence() + override val values = CalendarSyncDialogType.entries.dropLast(1).asSequence() } diff --git a/core/src/main/java/org/openedx/core/presentation/settings/video/VideoQualityFragment.kt b/core/src/main/java/org/openedx/core/presentation/settings/video/VideoQualityFragment.kt index edd00ce53..660a52a94 100644 --- a/core/src/main/java/org/openedx/core/presentation/settings/video/VideoQualityFragment.kt +++ b/core/src/main/java/org/openedx/core/presentation/settings/video/VideoQualityFragment.kt @@ -49,18 +49,18 @@ import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf import org.openedx.core.R import org.openedx.core.domain.model.VideoQuality -import org.openedx.core.extension.nonZero -import org.openedx.core.extension.tagId import org.openedx.core.ui.Toolbar -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue +import org.openedx.foundation.extension.nonZero +import org.openedx.foundation.extension.tagId +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue class VideoQualityFragment : Fragment() { @@ -183,7 +183,7 @@ private fun VideoQualityScreen( .verticalScroll(rememberScrollState()), horizontalAlignment = Alignment.CenterHorizontally ) { - VideoQuality.values().forEach { videoQuality -> + VideoQuality.entries.forEach { videoQuality -> QualityOption( title = stringResource(id = videoQuality.titleResId), description = videoQuality.desResId.nonZero() diff --git a/core/src/main/java/org/openedx/core/presentation/settings/video/VideoQualityViewModel.kt b/core/src/main/java/org/openedx/core/presentation/settings/video/VideoQualityViewModel.kt index bf30bbe30..2f8935e7a 100644 --- a/core/src/main/java/org/openedx/core/presentation/settings/video/VideoQualityViewModel.kt +++ b/core/src/main/java/org/openedx/core/presentation/settings/video/VideoQualityViewModel.kt @@ -4,7 +4,6 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.viewModelScope import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.model.VideoQuality import org.openedx.core.presentation.CoreAnalytics @@ -12,6 +11,7 @@ import org.openedx.core.presentation.CoreAnalyticsEvent import org.openedx.core.presentation.CoreAnalyticsKey import org.openedx.core.system.notifier.VideoNotifier import org.openedx.core.system.notifier.VideoQualityChanged +import org.openedx.foundation.presentation.BaseViewModel class VideoQualityViewModel( private val qualityType: String, diff --git a/core/src/main/java/org/openedx/core/system/PreviewFragmentManager.kt b/core/src/main/java/org/openedx/core/system/PreviewFragmentManager.kt deleted file mode 100644 index 36d4b39eb..000000000 --- a/core/src/main/java/org/openedx/core/system/PreviewFragmentManager.kt +++ /dev/null @@ -1,5 +0,0 @@ -package org.openedx.core.system - -import androidx.fragment.app.FragmentManager - -object PreviewFragmentManager : FragmentManager() diff --git a/core/src/main/java/org/openedx/core/system/ResourceManager.kt b/core/src/main/java/org/openedx/core/system/ResourceManager.kt deleted file mode 100644 index 541eae56f..000000000 --- a/core/src/main/java/org/openedx/core/system/ResourceManager.kt +++ /dev/null @@ -1,43 +0,0 @@ -package org.openedx.core.system - -import android.content.Context -import android.graphics.Typeface -import android.graphics.drawable.Drawable -import androidx.annotation.* -import androidx.core.content.ContextCompat -import androidx.core.content.res.ResourcesCompat -import java.io.InputStream - -class ResourceManager(private val context: Context) { - - fun getString(@StringRes id: Int): String = context.getString(id) - - fun getString(@StringRes id: Int, vararg formatArgs: Any): String = - context.getString(id, *formatArgs) - - fun getStringArray(@ArrayRes id: Int): Array = context.resources.getStringArray(id) - - fun getIntArray(@ArrayRes id: Int): IntArray = context.resources.getIntArray(id) - - @ColorInt - fun getColor(@ColorRes id: Int): Int = context.getColor(id) - - fun getFont(@FontRes id: Int): Typeface? = ResourcesCompat.getFont(context, id) - - fun getRaw(@RawRes id: Int): InputStream { - return context.resources.openRawResource(id) - } - - fun getQuantityString(@PluralsRes id: Int, quantity: Int): String { - return context.resources.getQuantityString(id, quantity) - } - - fun getQuantityString(@PluralsRes id: Int, quantity: Int, vararg formatArgs: Any): String { - return context.resources.getQuantityString(id, quantity, *formatArgs) - } - - fun getDrawable(@DrawableRes id: Int): Drawable { - return ContextCompat.getDrawable(context, id)!! - } - -} \ No newline at end of file diff --git a/core/src/main/java/org/openedx/core/ui/ComposeCommon.kt b/core/src/main/java/org/openedx/core/ui/ComposeCommon.kt index 3c4578d58..23f0d3315 100644 --- a/core/src/main/java/org/openedx/core/ui/ComposeCommon.kt +++ b/core/src/main/java/org/openedx/core/ui/ComposeCommon.kt @@ -6,6 +6,7 @@ import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.clickable +import androidx.compose.foundation.gestures.detectTapGestures import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box @@ -33,7 +34,7 @@ import androidx.compose.foundation.pager.PagerState import androidx.compose.foundation.pager.rememberPagerState import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.CircleShape -import androidx.compose.foundation.text.ClickableText +import androidx.compose.foundation.text.BasicText import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll @@ -77,6 +78,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.graphics.vector.rememberVectorPainter +import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalFocusManager @@ -109,16 +111,16 @@ import coil.decode.ImageDecoderDecoder import kotlinx.coroutines.launch import org.openedx.core.NoContentScreenType import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.domain.model.RegistrationField import org.openedx.core.extension.LinkedImageText -import org.openedx.core.extension.tagId -import org.openedx.core.extension.toastMessage import org.openedx.core.presentation.global.ErrorType import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography +import org.openedx.foundation.extension.tagId +import org.openedx.foundation.extension.toastMessage +import org.openedx.foundation.presentation.UIMessage @Composable fun StaticSearchBar( @@ -479,18 +481,19 @@ fun HyperlinkText( val uriHandler = LocalUriHandler.current - ClickableText( - modifier = modifier, + BasicText( text = annotatedString, - style = textStyle, - onClick = { - annotatedString - .getStringAnnotations("URL", it, it) - .firstOrNull()?.let { stringAnnotation -> - action?.invoke(stringAnnotation.item) - ?: uriHandler.openUri(stringAnnotation.item) - } - } + modifier = modifier.pointerInput(Unit) { + detectTapGestures { offset -> + val position = offset.x.toInt() + annotatedString.getStringAnnotations("URL", position, position) + .firstOrNull()?.let { stringAnnotation -> + action?.invoke(stringAnnotation.item) + ?: uriHandler.openUri(stringAnnotation.item) + } + } + }, + style = textStyle ) } @@ -590,17 +593,18 @@ fun HyperlinkImageText( .build() Column(Modifier.fillMaxWidth()) { - ClickableText( - modifier = modifier, + BasicText( text = annotatedString, - style = textStyle, - onClick = { - annotatedString - .getStringAnnotations("URL", it, it) - .firstOrNull()?.let { stringAnnotation -> - uriHandler.openUri(stringAnnotation.item) - } - } + modifier = modifier.pointerInput(Unit) { + detectTapGestures { offset -> + val position = offset.x.toInt() + annotatedString.getStringAnnotations("URL", position, position) + .firstOrNull()?.let { stringAnnotation -> + uriHandler.openUri(stringAnnotation.item) + } + } + }, + style = textStyle ) imageText.imageLinks.values.forEach { Spacer(Modifier.height(8.dp)) @@ -941,11 +945,11 @@ fun IconText( @Composable fun TextIcon( + modifier: Modifier = Modifier, text: String, icon: ImageVector, color: Color, textStyle: TextStyle = MaterialTheme.appTypography.bodySmall, - modifier: Modifier = Modifier, iconModifier: Modifier? = null, onClick: (() -> Unit)? = null, ) { @@ -971,11 +975,11 @@ fun TextIcon( @Composable fun TextIcon( + iconModifier: Modifier = Modifier, text: String, painter: Painter, color: Color, textStyle: TextStyle = MaterialTheme.appTypography.bodySmall, - iconModifier: Modifier = Modifier, onClick: (() -> Unit)? = null, ) { val modifier = if (onClick == null) { diff --git a/core/src/main/java/org/openedx/core/ui/WebContentScreen.kt b/core/src/main/java/org/openedx/core/ui/WebContentScreen.kt index 2fe762b26..807acd918 100644 --- a/core/src/main/java/org/openedx/core/ui/WebContentScreen.kt +++ b/core/src/main/java/org/openedx/core/ui/WebContentScreen.kt @@ -35,11 +35,13 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.compose.ui.viewinterop.AndroidView import androidx.compose.ui.zIndex -import org.openedx.core.extension.applyDarkModeIfEnabled -import org.openedx.core.extension.isEmailValid -import org.openedx.core.extension.replaceLinkTags import org.openedx.core.ui.theme.appColors import org.openedx.core.utils.EmailUtil +import org.openedx.foundation.extension.applyDarkModeIfEnabled +import org.openedx.foundation.extension.isEmailValid +import org.openedx.foundation.extension.replaceLinkTags +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.windowSizeValue import java.nio.charset.StandardCharsets @OptIn(ExperimentalComposeUiApi::class) diff --git a/core/src/main/java/org/openedx/core/ui/WindowSize.kt b/core/src/main/java/org/openedx/core/ui/WindowSize.kt deleted file mode 100644 index 735dfc209..000000000 --- a/core/src/main/java/org/openedx/core/ui/WindowSize.kt +++ /dev/null @@ -1,55 +0,0 @@ -package org.openedx.core.ui - -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.ui.platform.LocalConfiguration - -data class WindowSize( - val width: WindowType, - val height: WindowType -) { - val isTablet: Boolean - get() = height != WindowType.Compact && width != WindowType.Compact -} - -fun WindowSize.windowSizeValue(expanded: T, compact: T): T { - return if (height != WindowType.Compact && width != WindowType.Compact) { - expanded - } else { - compact - } -} - -enum class WindowType { - Compact, Medium, Expanded -} - -@Composable -fun rememberWindowSize(): WindowSize { - val configuration = LocalConfiguration.current - val screenWidth by remember(key1 = configuration) { - mutableStateOf(configuration.screenWidthDp) - } - val screenHeight by remember(key1 = configuration) { - mutableStateOf(configuration.screenHeightDp) - } - - return WindowSize( - width = getScreenWidth(screenWidth), - height = getScreenHeight(screenHeight) - ) -} - -fun getScreenWidth(width: Int): WindowType = when { - width < 600 -> WindowType.Compact - width < 840 -> WindowType.Medium - else -> WindowType.Expanded -} - -fun getScreenHeight(height: Int): WindowType = when { - height < 480 -> WindowType.Compact - height < 900 -> WindowType.Medium - else -> WindowType.Expanded -} \ No newline at end of file diff --git a/core/src/main/java/org/openedx/core/utils/FileUtil.kt b/core/src/main/java/org/openedx/core/utils/FileUtil.kt index 7c7423e60..5f890e690 100644 --- a/core/src/main/java/org/openedx/core/utils/FileUtil.kt +++ b/core/src/main/java/org/openedx/core/utils/FileUtil.kt @@ -1,122 +1,28 @@ package org.openedx.core.utils -import android.content.Context -import android.util.Log -import com.google.gson.Gson -import com.google.gson.GsonBuilder import net.lingala.zip4j.ZipFile import net.lingala.zip4j.exception.ZipException +import org.openedx.foundation.utils.FileUtil import java.io.File -import java.util.Collections -class FileUtil(val context: Context) { - - fun getExternalAppDir(): File { - val dir = context.externalCacheDir.toString() + File.separator + - context.getString(org.openedx.core.R.string.app_name).replace(Regex("\\s"), "_") - val file = File(dir) - file.mkdirs() - return file - } - - inline fun saveObjectToFile( - obj: T, - fileName: String = "${T::class.java.simpleName}.json", - ) { - val gson: Gson = GsonBuilder().setPrettyPrinting().create() - val jsonString = gson.toJson(obj) - File(getExternalAppDir().path + fileName).writeText(jsonString) - } - - inline fun getObjectFromFile(fileName: String = "${T::class.java.simpleName}.json"): T? { - val file = File(getExternalAppDir().path + fileName) - return if (file.exists()) { - val gson: Gson = GsonBuilder().setPrettyPrinting().create() - val jsonString = file.readText() - gson.fromJson(jsonString, T::class.java) - } else { - null - } - } - - /** - * Deletes all the files and directories in the app's external storage directory. - */ - fun deleteOldAppDirectory() { - val externalFilesDir = context.getExternalFilesDir(null) - val externalAppDir = File(externalFilesDir?.parentFile, Directories.VIDEOS.name) - if (externalAppDir.isDirectory) { - deleteRecursive(externalAppDir, Collections.emptyList()) - } - } - - /** - * Deletes a file or directory and all its content recursively. - * - * @param fileOrDirectory The file or directory that needs to be deleted. - * @param exceptions Names of the files or directories that need to be skipped while deletion. - */ - private fun deleteRecursive( - fileOrDirectory: File, - exceptions: List, - ) { - if (exceptions.contains(fileOrDirectory.name)) return - - if (fileOrDirectory.isDirectory) { - val filesList = fileOrDirectory.listFiles() - if (filesList != null) { - for (child in filesList) { - deleteRecursive(child, exceptions) - } - } - } - - // Don't break the recursion upon encountering an error - // noinspection ResultOfMethodCallIgnored - fileOrDirectory.delete() - } - - fun unzipFile(filepath: String): String? { - val archive = File(filepath) - val destinationFolder = File( - archive.parentFile.absolutePath + "/" + archive.name + "-unzipped" - ) - try { - if (!destinationFolder.exists()) { - destinationFolder.mkdirs() - } - val zip = ZipFile(archive) - zip.extractAll(destinationFolder.absolutePath) - deleteFile(archive.absolutePath) - return destinationFolder.absolutePath - } catch (e: ZipException) { - e.printStackTrace() - deleteFile(destinationFolder.absolutePath) - } - return null - } - - private fun deleteFile(filepath: String?): Boolean { - try { - if (filepath != null) { - val file = File(filepath) - if (file.exists()) { - if (file.delete()) { - Log.d(this.javaClass.name, "Deleted: " + file.path) - return true - } else { - Log.d(this.javaClass.name, "Delete failed: " + file.path) - } - } else { - Log.d(this.javaClass.name, "Delete failed, file does NOT exist: " + file.path) - return true - } - } - } catch (e: Exception) { - e.printStackTrace() +fun FileUtil.unzipFile(filepath: String): String? { + val archive = File(filepath) + val destinationFolder = File( + archive.parentFile.absolutePath + "/" + archive.name + "-unzipped" + ) + try { + if (!destinationFolder.exists()) { + destinationFolder.mkdirs() } - return false + val zip = ZipFile(archive) + zip.extractAll(destinationFolder.absolutePath) + deleteFile(archive.absolutePath) + return destinationFolder.absolutePath + } catch (e: ZipException) { + e.printStackTrace() + deleteFile(destinationFolder.absolutePath) } + return null } enum class Directories { diff --git a/core/src/main/java/org/openedx/core/utils/TimeUtils.kt b/core/src/main/java/org/openedx/core/utils/TimeUtils.kt index 02e0bde2f..f39b9369a 100644 --- a/core/src/main/java/org/openedx/core/utils/TimeUtils.kt +++ b/core/src/main/java/org/openedx/core/utils/TimeUtils.kt @@ -5,7 +5,7 @@ import android.text.format.DateUtils import com.google.gson.internal.bind.util.ISO8601Utils import org.openedx.core.R import org.openedx.core.domain.model.StartType -import org.openedx.core.system.ResourceManager +import org.openedx.foundation.system.ResourceManager import java.text.DateFormat import java.text.ParseException import java.text.ParsePosition diff --git a/core/src/main/java/org/openedx/core/utils/UrlUtils.kt b/core/src/main/java/org/openedx/core/utils/UrlUtils.kt deleted file mode 100644 index 191edd4da..000000000 --- a/core/src/main/java/org/openedx/core/utils/UrlUtils.kt +++ /dev/null @@ -1,67 +0,0 @@ -package org.openedx.core.utils - -import android.content.Context -import android.content.Intent -import android.net.Uri - -object UrlUtils { - - const val QUERY_PARAM_SEARCH = "q" - - fun openInBrowser(activity: Context, apiHostUrl: String, url: String) { - if (url.isEmpty()) { - return - } - if (url.startsWith("/")) { - // Use API host as the base URL for relative paths - val absoluteUrl = "$apiHostUrl$url" - openInBrowser(activity, absoluteUrl) - return - } - openInBrowser(activity, url) - } - - private fun openInBrowser(context: Context, url: String) { - val intent = Intent(Intent.ACTION_VIEW) - intent.setData(Uri.parse(url)) - context.startActivity(intent) - } - - /** - * Utility function to remove the given query parameter from the URL - * Ref: https://stackoverflow.com/a/56108097 - * - * @param url that needs to update - * @param queryParam that needs to remove from the URL - * @return The URL after removing the given params - */ - private fun removeQueryParameterFromURL(url: String, queryParam: String): String { - val uri = Uri.parse(url) - val params = uri.queryParameterNames - val newUri = uri.buildUpon().clearQuery() - for (param in params) { - if (queryParam != param) { - newUri.appendQueryParameter(param, uri.getQueryParameter(param)) - } - } - return newUri.build().toString() - } - - /** - * Builds a valid URL with the given query params. - * - * @param url The base URL. - * @param queryParams The query params to add in the URL. - * @return URL String with query params added to it. - */ - fun buildUrlWithQueryParams(url: String, queryParams: Map): String { - val uriBuilder = Uri.parse(url).buildUpon() - for ((key, value) in queryParams) { - if (url.contains(key)) { - removeQueryParameterFromURL(url, key) - } - uriBuilder.appendQueryParameter(key, value) - } - return uriBuilder.build().toString() - } -} diff --git a/course/build.gradle b/course/build.gradle index 49946ca92..3b8096dc4 100644 --- a/course/build.gradle +++ b/course/build.gradle @@ -2,6 +2,7 @@ plugins { id 'com.android.library' id 'org.jetbrains.kotlin.android' id 'kotlin-parcelize' + id "org.jetbrains.kotlin.plugin.compose" } android { @@ -36,9 +37,6 @@ android { viewBinding true compose true } - composeOptions { - kotlinCompilerExtensionVersion = "$compose_compiler_version" - } flavorDimensions += "env" productFlavors { @@ -68,13 +66,10 @@ dependencies { implementation "androidx.media3:media3-cast:$media3_version" implementation "me.saket.extendedspans:extendedspans:$extented_spans_version" - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" - debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version" + androidTestImplementation 'androidx.test.ext:junit:1.2.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' testImplementation "junit:junit:$junit_version" testImplementation "io.mockk:mockk:$mockk_version" testImplementation "io.mockk:mockk-android:$mockk_version" - testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version" testImplementation "androidx.arch.core:core-testing:$android_arch_version" } \ No newline at end of file diff --git a/course/src/main/java/org/openedx/course/DatesShiftedSnackBar.kt b/course/src/main/java/org/openedx/course/DatesShiftedSnackBar.kt index fd2a3ce6b..1c7d5fcaf 100644 --- a/course/src/main/java/org/openedx/course/DatesShiftedSnackBar.kt +++ b/course/src/main/java/org/openedx/course/DatesShiftedSnackBar.kt @@ -1,5 +1,5 @@ package org.openedx.course -import org.openedx.core.UIMessage +import org.openedx.foundation.presentation.UIMessage class DatesShiftedSnackBar : UIMessage() diff --git a/course/src/main/java/org/openedx/course/data/storage/CourseConverter.kt b/course/src/main/java/org/openedx/course/data/storage/CourseConverter.kt index 1865a3c34..f71c8593f 100644 --- a/course/src/main/java/org/openedx/course/data/storage/CourseConverter.kt +++ b/course/src/main/java/org/openedx/course/data/storage/CourseConverter.kt @@ -5,7 +5,7 @@ import com.google.gson.Gson import org.openedx.core.data.model.room.BlockDb import org.openedx.core.data.model.room.VideoInfoDb import org.openedx.core.data.model.room.discovery.CourseDateBlockDb -import org.openedx.core.extension.genericType +import org.openedx.foundation.extension.genericType class CourseConverter { diff --git a/course/src/main/java/org/openedx/course/presentation/ChapterEndFragmentDialog.kt b/course/src/main/java/org/openedx/course/presentation/ChapterEndFragmentDialog.kt index c416aa497..13380ddde 100644 --- a/course/src/main/java/org/openedx/course/presentation/ChapterEndFragmentDialog.kt +++ b/course/src/main/java/org/openedx/course/presentation/ChapterEndFragmentDialog.kt @@ -40,7 +40,6 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.core.os.bundleOf import androidx.fragment.app.DialogFragment -import org.openedx.core.extension.setWidthPercent import org.openedx.core.ui.AutoSizeText import org.openedx.core.ui.OpenEdXButton import org.openedx.core.ui.OpenEdXOutlinedButton @@ -50,6 +49,7 @@ import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography import org.openedx.course.R +import org.openedx.foundation.extension.setWidthPercent class ChapterEndFragmentDialog : DialogFragment() { diff --git a/course/src/main/java/org/openedx/course/presentation/container/CollapsingLayout.kt b/course/src/main/java/org/openedx/course/presentation/container/CollapsingLayout.kt index 08f6cf96a..b40387266 100644 --- a/course/src/main/java/org/openedx/course/presentation/container/CollapsingLayout.kt +++ b/course/src/main/java/org/openedx/course/presentation/container/CollapsingLayout.kt @@ -68,10 +68,10 @@ import kotlinx.coroutines.launch import org.openedx.core.R import org.openedx.core.ui.RoundTabsBar import org.openedx.core.ui.displayCutoutForLandscape -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors +import org.openedx.foundation.presentation.rememberWindowSize import kotlin.math.roundToInt @Composable diff --git a/course/src/main/java/org/openedx/course/presentation/container/CourseContainerFragment.kt b/course/src/main/java/org/openedx/course/presentation/container/CourseContainerFragment.kt index 9e3db405c..856b40c4f 100644 --- a/course/src/main/java/org/openedx/course/presentation/container/CourseContainerFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/container/CourseContainerFragment.kt @@ -55,13 +55,10 @@ import kotlinx.coroutines.launch import org.koin.androidx.compose.koinViewModel import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf -import org.openedx.core.extension.takeIfNotEmpty import org.openedx.core.presentation.global.viewBinding import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.OfflineModeDialog import org.openedx.core.ui.RoundTabsBar -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.course.DatesShiftedSnackBar @@ -75,6 +72,9 @@ import org.openedx.course.presentation.outline.CourseOutlineScreen import org.openedx.course.presentation.ui.CourseVideosScreen import org.openedx.course.presentation.ui.DatesShiftedSnackBar import org.openedx.discussion.presentation.topics.DiscussionTopicsScreen +import org.openedx.foundation.extension.takeIfNotEmpty +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.rememberWindowSize class CourseContainerFragment : Fragment(R.layout.fragment_course_container) { @@ -368,7 +368,6 @@ fun CourseDashboard( } } -@OptIn(ExperimentalFoundationApi::class) @Composable fun DashboardPager( windowSize: WindowSize, @@ -382,7 +381,7 @@ fun DashboardPager( HorizontalPager( state = pagerState, userScrollEnabled = isNavigationEnabled, - beyondBoundsPageCount = CourseContainerTab.entries.size + beyondViewportPageCount = CourseContainerTab.entries.size ) { page -> when (CourseContainerTab.entries[page]) { CourseContainerTab.HOME -> { diff --git a/course/src/main/java/org/openedx/course/presentation/container/CourseContainerViewModel.kt b/course/src/main/java/org/openedx/course/presentation/container/CourseContainerViewModel.kt index d30d68c00..f27227b8f 100644 --- a/course/src/main/java/org/openedx/course/presentation/container/CourseContainerViewModel.kt +++ b/course/src/main/java/org/openedx/course/presentation/container/CourseContainerViewModel.kt @@ -15,18 +15,11 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel -import org.openedx.core.ImageProcessor -import org.openedx.core.SingleEventLiveData -import org.openedx.core.UIMessage import org.openedx.core.config.Config import org.openedx.core.data.storage.CorePreferences import org.openedx.core.exception.NoCachedDataException -import org.openedx.core.extension.isInternetError -import org.openedx.core.extension.toImageLink import org.openedx.core.presentation.settings.calendarsync.CalendarSyncDialogType import org.openedx.core.presentation.settings.calendarsync.CalendarSyncUIState -import org.openedx.core.system.ResourceManager import org.openedx.core.system.connection.NetworkConnection import org.openedx.core.system.notifier.CalendarSyncEvent.CreateCalendarSyncEvent import org.openedx.core.system.notifier.CourseCompletionSet @@ -45,6 +38,13 @@ import org.openedx.course.presentation.CourseAnalytics import org.openedx.course.presentation.CourseAnalyticsEvent import org.openedx.course.presentation.CourseAnalyticsKey import org.openedx.course.presentation.CourseRouter +import org.openedx.course.utils.ImageProcessor +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.extension.toImageLink +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.SingleEventLiveData +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import java.util.Date import java.util.concurrent.atomic.AtomicReference import org.openedx.core.R as CoreR diff --git a/course/src/main/java/org/openedx/course/presentation/container/HeaderContent.kt b/course/src/main/java/org/openedx/course/presentation/container/HeaderContent.kt index a2070eb66..5b1625d49 100644 --- a/course/src/main/java/org/openedx/course/presentation/container/HeaderContent.kt +++ b/course/src/main/java/org/openedx/course/presentation/container/HeaderContent.kt @@ -11,10 +11,10 @@ import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Devices import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appTypography +import org.openedx.foundation.presentation.rememberWindowSize @Composable internal fun ExpandedHeaderContent( diff --git a/course/src/main/java/org/openedx/course/presentation/container/NoAccessCourseContainerFragment.kt b/course/src/main/java/org/openedx/course/presentation/container/NoAccessCourseContainerFragment.kt index f6f5d8e7d..e9b3b2e89 100644 --- a/course/src/main/java/org/openedx/course/presentation/container/NoAccessCourseContainerFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/container/NoAccessCourseContainerFragment.kt @@ -4,10 +4,24 @@ import android.content.res.Configuration import android.os.Bundle import android.view.LayoutInflater import android.view.ViewGroup -import androidx.compose.foundation.layout.* -import androidx.compose.material.* +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.widthIn +import androidx.compose.material.Icon +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Scaffold +import androidx.compose.material.Surface +import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Error +import androidx.compose.material.rememberScaffoldState import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -25,12 +39,15 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.zIndex import androidx.core.os.bundleOf import androidx.fragment.app.Fragment -import org.openedx.core.extension.parcelable -import org.openedx.core.ui.* +import org.openedx.core.ui.BackBtn +import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appTypography -import java.util.* +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.course.R as courseR class NoAccessCourseContainerFragment : Fragment() { diff --git a/course/src/main/java/org/openedx/course/presentation/dates/CourseDatesScreen.kt b/course/src/main/java/org/openedx/course/presentation/dates/CourseDatesScreen.kt index e15d3f7d4..adb633b98 100644 --- a/course/src/main/java/org/openedx/course/presentation/dates/CourseDatesScreen.kt +++ b/course/src/main/java/org/openedx/course/presentation/dates/CourseDatesScreen.kt @@ -33,8 +33,6 @@ import androidx.compose.material.Icon import androidx.compose.material.MaterialTheme import androidx.compose.material.Scaffold import androidx.compose.material.Surface -import androidx.compose.material.Switch -import androidx.compose.material.SwitchDefaults import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.KeyboardArrowRight @@ -63,35 +61,32 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.fragment.app.FragmentManager import org.openedx.core.NoContentScreenType -import org.openedx.core.UIMessage import org.openedx.core.data.model.DateType import org.openedx.core.domain.model.CourseDateBlock import org.openedx.core.domain.model.CourseDatesBannerInfo import org.openedx.core.domain.model.CourseDatesResult import org.openedx.core.domain.model.DatesSection -import org.openedx.core.extension.isNotEmptyThenLet import org.openedx.core.presentation.CoreAnalyticsScreen import org.openedx.core.presentation.course.CourseViewMode import org.openedx.core.presentation.dialog.alert.ActionDialogFragment import org.openedx.core.presentation.settings.calendarsync.CalendarSyncState -import org.openedx.core.presentation.settings.calendarsync.CalendarSyncUIState import org.openedx.core.ui.CircularProgress import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.NoContentScreen -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors -import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue import org.openedx.core.utils.TimeUtils import org.openedx.core.utils.TimeUtils.formatToString import org.openedx.core.utils.clearTime -import org.openedx.course.R import org.openedx.course.presentation.ui.CourseDatesBanner import org.openedx.course.presentation.ui.CourseDatesBannerTablet +import org.openedx.foundation.extension.isNotEmptyThenLet +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.windowSizeValue import java.util.Date import org.openedx.core.R as CoreR @@ -353,68 +348,6 @@ private fun CourseDatesUI( } } -@Composable -fun CalendarSyncCard( - modifier: Modifier = Modifier, - checked: Boolean, - onCalendarSync: (Boolean) -> Unit, -) { - val cardModifier = modifier - .background( - MaterialTheme.appColors.cardViewBackground, - MaterialTheme.appShapes.material.medium - ) - .border( - 1.dp, - MaterialTheme.appColors.cardViewBorder, - MaterialTheme.appShapes.material.medium - ) - .padding(16.dp) - - Column(modifier = cardModifier) { - Row( - modifier = Modifier - .fillMaxWidth() - .height(40.dp), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.Start - ) { - Icon( - painter = painterResource(id = R.drawable.course_ic_calenday_sync), - contentDescription = null, - modifier = Modifier.size(24.dp) - ) - Text( - modifier = Modifier - .padding(start = 8.dp, end = 8.dp) - .weight(1f), - text = stringResource(id = CoreR.string.core_header_sync_to_calendar), - style = MaterialTheme.appTypography.titleMedium, - color = MaterialTheme.appColors.textDark - ) - Switch( - checked = checked, - onCheckedChange = onCalendarSync, - modifier = Modifier.size(48.dp), - colors = SwitchDefaults.colors( - checkedThumbColor = MaterialTheme.appColors.primary, - checkedTrackColor = MaterialTheme.appColors.primary - ) - ) - } - - Text( - modifier = Modifier - .fillMaxWidth() - .padding(top = 8.dp) - .height(40.dp), - text = stringResource(id = CoreR.string.core_body_sync_to_calendar), - style = MaterialTheme.appTypography.bodyMedium, - color = MaterialTheme.appColors.textDark, - ) - } -} - @Composable fun ExpandableView( sectionKey: DatesSection = DatesSection.NONE, diff --git a/course/src/main/java/org/openedx/course/presentation/dates/CourseDatesViewModel.kt b/course/src/main/java/org/openedx/course/presentation/dates/CourseDatesViewModel.kt index 54406019d..3f716607f 100644 --- a/course/src/main/java/org/openedx/course/presentation/dates/CourseDatesViewModel.kt +++ b/course/src/main/java/org/openedx/course/presentation/dates/CourseDatesViewModel.kt @@ -9,10 +9,8 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.CalendarRouter import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.config.Config import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.interactor.CalendarInteractor @@ -22,10 +20,8 @@ import org.openedx.core.domain.model.CourseDateBlock import org.openedx.core.domain.model.CourseStructure import org.openedx.core.extension.getSequentialBlocks import org.openedx.core.extension.getVerticalBlocks -import org.openedx.core.extension.isInternetError import org.openedx.core.presentation.settings.calendarsync.CalendarSyncDialogType import org.openedx.core.presentation.settings.calendarsync.CalendarSyncState -import org.openedx.core.system.ResourceManager import org.openedx.core.system.notifier.CalendarSyncEvent.CreateCalendarSyncEvent import org.openedx.core.system.notifier.CourseDatesShifted import org.openedx.core.system.notifier.CourseLoading @@ -37,6 +33,10 @@ import org.openedx.course.presentation.CourseAnalytics import org.openedx.course.presentation.CourseAnalyticsEvent import org.openedx.course.presentation.CourseAnalyticsKey import org.openedx.course.presentation.CourseRouter +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import org.openedx.core.R as CoreR class CourseDatesViewModel( diff --git a/course/src/main/java/org/openedx/course/presentation/download/DownloadConfirmDialogFragment.kt b/course/src/main/java/org/openedx/course/presentation/download/DownloadConfirmDialogFragment.kt index 1c220903f..c591966f4 100644 --- a/course/src/main/java/org/openedx/course/presentation/download/DownloadConfirmDialogFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/download/DownloadConfirmDialogFragment.kt @@ -33,10 +33,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.core.os.bundleOf import androidx.fragment.app.DialogFragment -import org.openedx.core.extension.parcelable -import org.openedx.core.extension.toFileSize import org.openedx.core.presentation.dialog.DefaultDialogBox -import org.openedx.core.system.PreviewFragmentManager import org.openedx.core.ui.AutoSizeText import org.openedx.core.ui.IconText import org.openedx.core.ui.OpenEdXButton @@ -46,6 +43,9 @@ import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appTypography import org.openedx.course.R import org.openedx.course.domain.model.DownloadDialogResource +import org.openedx.foundation.extension.parcelable +import org.openedx.foundation.extension.toFileSize +import org.openedx.foundation.system.PreviewFragmentManager import androidx.compose.ui.graphics.Color as ComposeColor import org.openedx.core.R as coreR diff --git a/course/src/main/java/org/openedx/course/presentation/download/DownloadErrorDialogFragment.kt b/course/src/main/java/org/openedx/course/presentation/download/DownloadErrorDialogFragment.kt index 05d7e0243..96cdf3d40 100644 --- a/course/src/main/java/org/openedx/course/presentation/download/DownloadErrorDialogFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/download/DownloadErrorDialogFragment.kt @@ -29,9 +29,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.core.os.bundleOf import androidx.fragment.app.DialogFragment -import org.openedx.core.extension.parcelable import org.openedx.core.presentation.dialog.DefaultDialogBox -import org.openedx.core.system.PreviewFragmentManager import org.openedx.core.ui.AutoSizeText import org.openedx.core.ui.OpenEdXButton import org.openedx.core.ui.OpenEdXOutlinedButton @@ -40,6 +38,8 @@ import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appTypography import org.openedx.course.R import org.openedx.course.domain.model.DownloadDialogResource +import org.openedx.foundation.extension.parcelable +import org.openedx.foundation.system.PreviewFragmentManager import org.openedx.core.R as coreR class DownloadErrorDialogFragment : DialogFragment() { diff --git a/course/src/main/java/org/openedx/course/presentation/download/DownloadStorageErrorDialogFragment.kt b/course/src/main/java/org/openedx/course/presentation/download/DownloadStorageErrorDialogFragment.kt index 0059f2bec..4c192209f 100644 --- a/course/src/main/java/org/openedx/course/presentation/download/DownloadStorageErrorDialogFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/download/DownloadStorageErrorDialogFragment.kt @@ -41,10 +41,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.core.os.bundleOf import androidx.fragment.app.DialogFragment -import org.openedx.core.extension.parcelable -import org.openedx.core.extension.toFileSize import org.openedx.core.presentation.dialog.DefaultDialogBox -import org.openedx.core.system.PreviewFragmentManager import org.openedx.core.system.StorageManager import org.openedx.core.ui.AutoSizeText import org.openedx.core.ui.OpenEdXOutlinedButton @@ -54,6 +51,9 @@ import org.openedx.core.ui.theme.appTypography import org.openedx.course.R import org.openedx.course.domain.model.DownloadDialogResource import org.openedx.course.presentation.download.DownloadDialogManager.Companion.DOWNLOAD_SIZE_FACTOR +import org.openedx.foundation.extension.parcelable +import org.openedx.foundation.extension.toFileSize +import org.openedx.foundation.system.PreviewFragmentManager import org.openedx.core.R as coreR class DownloadStorageErrorDialogFragment : DialogFragment() { diff --git a/course/src/main/java/org/openedx/course/presentation/download/DownloadView.kt b/course/src/main/java/org/openedx/course/presentation/download/DownloadView.kt index 2a760c772..fd70dd723 100644 --- a/course/src/main/java/org/openedx/course/presentation/download/DownloadView.kt +++ b/course/src/main/java/org/openedx/course/presentation/download/DownloadView.kt @@ -15,9 +15,9 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp import org.openedx.core.R -import org.openedx.core.extension.toFileSize import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appTypography +import org.openedx.foundation.extension.toFileSize @Composable fun DownloadDialogItem( diff --git a/course/src/main/java/org/openedx/course/presentation/handouts/HandoutsScreen.kt b/course/src/main/java/org/openedx/course/presentation/handouts/HandoutsScreen.kt index 184031091..9720740a2 100644 --- a/course/src/main/java/org/openedx/course/presentation/handouts/HandoutsScreen.kt +++ b/course/src/main/java/org/openedx/course/presentation/handouts/HandoutsScreen.kt @@ -34,14 +34,14 @@ import androidx.compose.ui.tooling.preview.Devices import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue import org.openedx.course.presentation.ui.CardArrow +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.course.R as courseR @Composable diff --git a/course/src/main/java/org/openedx/course/presentation/handouts/HandoutsViewModel.kt b/course/src/main/java/org/openedx/course/presentation/handouts/HandoutsViewModel.kt index 424f71f81..c8d9a87f8 100644 --- a/course/src/main/java/org/openedx/course/presentation/handouts/HandoutsViewModel.kt +++ b/course/src/main/java/org/openedx/course/presentation/handouts/HandoutsViewModel.kt @@ -5,7 +5,6 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.config.Config import org.openedx.core.domain.model.AnnouncementModel import org.openedx.core.domain.model.HandoutsModel @@ -13,6 +12,7 @@ import org.openedx.course.domain.interactor.CourseInteractor import org.openedx.course.presentation.CourseAnalytics import org.openedx.course.presentation.CourseAnalyticsEvent import org.openedx.course.presentation.CourseAnalyticsKey +import org.openedx.foundation.presentation.BaseViewModel class HandoutsViewModel( private val courseId: String, diff --git a/course/src/main/java/org/openedx/course/presentation/handouts/HandoutsWebViewFragment.kt b/course/src/main/java/org/openedx/course/presentation/handouts/HandoutsWebViewFragment.kt index dbcbde30a..24240954a 100644 --- a/course/src/main/java/org/openedx/course/presentation/handouts/HandoutsWebViewFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/handouts/HandoutsWebViewFragment.kt @@ -40,15 +40,15 @@ import org.openedx.core.ui.CircularProgress import org.openedx.core.ui.NoContentScreen import org.openedx.core.ui.Toolbar import org.openedx.core.ui.WebContentScreen -import org.openedx.core.ui.WindowSize import org.openedx.core.ui.displayCutoutForLandscape -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors -import org.openedx.core.ui.windowSizeValue import org.openedx.course.R import org.openedx.course.presentation.CourseAnalyticsEvent +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue class HandoutsWebViewFragment : Fragment() { diff --git a/course/src/main/java/org/openedx/course/presentation/offline/CourseOfflineScreen.kt b/course/src/main/java/org/openedx/course/presentation/offline/CourseOfflineScreen.kt index cdad27742..9a4374aec 100644 --- a/course/src/main/java/org/openedx/course/presentation/offline/CourseOfflineScreen.kt +++ b/course/src/main/java/org/openedx/course/presentation/offline/CourseOfflineScreen.kt @@ -49,21 +49,21 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.fragment.app.FragmentManager -import org.openedx.core.extension.toFileSize import org.openedx.core.module.db.DownloadModel import org.openedx.core.module.db.DownloadedState import org.openedx.core.module.db.FileType import org.openedx.core.ui.IconText import org.openedx.core.ui.OpenEdXButton import org.openedx.core.ui.OpenEdXOutlinedButton -import org.openedx.core.ui.WindowSize import org.openedx.core.ui.displayCutoutForLandscape -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue import org.openedx.course.R +import org.openedx.foundation.extension.toFileSize +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.core.R as coreR @Composable diff --git a/course/src/main/java/org/openedx/course/presentation/offline/CourseOfflineViewModel.kt b/course/src/main/java/org/openedx/course/presentation/offline/CourseOfflineViewModel.kt index 6fc72607f..88c8a60c4 100644 --- a/course/src/main/java/org/openedx/course/presentation/offline/CourseOfflineViewModel.kt +++ b/course/src/main/java/org/openedx/course/presentation/offline/CourseOfflineViewModel.kt @@ -14,7 +14,6 @@ import kotlinx.coroutines.launch import org.openedx.core.BlockType import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.model.Block -import org.openedx.core.extension.toFileSize import org.openedx.core.module.DownloadWorkerController import org.openedx.core.module.db.DownloadDao import org.openedx.core.module.db.DownloadModel @@ -23,10 +22,11 @@ import org.openedx.core.module.download.BaseDownloadViewModel import org.openedx.core.module.download.DownloadHelper import org.openedx.core.presentation.CoreAnalytics import org.openedx.core.system.connection.NetworkConnection -import org.openedx.core.utils.FileUtil import org.openedx.course.domain.interactor.CourseInteractor import org.openedx.course.presentation.download.DownloadDialogItem import org.openedx.course.presentation.download.DownloadDialogManager +import org.openedx.foundation.extension.toFileSize +import org.openedx.foundation.utils.FileUtil class CourseOfflineViewModel( val courseId: String, diff --git a/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineScreen.kt b/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineScreen.kt index 90d74e7f5..6d6b10af7 100644 --- a/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineScreen.kt +++ b/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineScreen.kt @@ -46,7 +46,6 @@ import androidx.compose.ui.unit.dp import androidx.fragment.app.FragmentManager import org.openedx.core.BlockType import org.openedx.core.NoContentScreenType -import org.openedx.core.UIMessage import org.openedx.core.domain.model.AssignmentProgress import org.openedx.core.domain.model.Block import org.openedx.core.domain.model.BlockCounts @@ -55,25 +54,26 @@ import org.openedx.core.domain.model.CourseStructure import org.openedx.core.domain.model.CoursewareAccess import org.openedx.core.domain.model.OfflineDownload import org.openedx.core.domain.model.Progress -import org.openedx.core.extension.takeIfNotEmpty import org.openedx.core.presentation.course.CourseViewMode import org.openedx.core.ui.CircularProgress import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.NoContentScreen import org.openedx.core.ui.OpenEdXButton import org.openedx.core.ui.TextIcon -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue import org.openedx.course.R import org.openedx.course.presentation.ui.CourseDatesBanner import org.openedx.course.presentation.ui.CourseDatesBannerTablet import org.openedx.course.presentation.ui.CourseMessage import org.openedx.course.presentation.ui.CourseSection +import org.openedx.foundation.extension.takeIfNotEmpty +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.windowSizeValue import java.util.Date import org.openedx.core.R as CoreR diff --git a/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineViewModel.kt b/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineViewModel.kt index 006176b56..b613bea49 100644 --- a/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineViewModel.kt +++ b/course/src/main/java/org/openedx/course/presentation/outline/CourseOutlineViewModel.kt @@ -11,7 +11,6 @@ import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch import org.openedx.core.BlockType import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.config.Config import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.model.Block @@ -22,7 +21,6 @@ import org.openedx.core.domain.model.CourseDatesResult import org.openedx.core.domain.model.CourseStructure import org.openedx.core.extension.getSequentialBlocks import org.openedx.core.extension.getVerticalBlocks -import org.openedx.core.extension.isInternetError import org.openedx.core.module.DownloadWorkerController import org.openedx.core.module.db.DownloadDao import org.openedx.core.module.download.BaseDownloadViewModel @@ -30,7 +28,6 @@ import org.openedx.core.module.download.DownloadHelper import org.openedx.core.presentation.CoreAnalytics import org.openedx.core.presentation.course.CourseViewMode import org.openedx.core.presentation.settings.calendarsync.CalendarSyncDialogType -import org.openedx.core.system.ResourceManager import org.openedx.core.system.connection.NetworkConnection import org.openedx.core.system.notifier.CalendarSyncEvent.CreateCalendarSyncEvent import org.openedx.core.system.notifier.CourseDatesShifted @@ -38,13 +35,16 @@ import org.openedx.core.system.notifier.CourseLoading import org.openedx.core.system.notifier.CourseNotifier import org.openedx.core.system.notifier.CourseOpenBlock import org.openedx.core.system.notifier.CourseStructureUpdated -import org.openedx.core.utils.FileUtil import org.openedx.course.domain.interactor.CourseInteractor import org.openedx.course.presentation.CourseAnalytics import org.openedx.course.presentation.CourseAnalyticsEvent import org.openedx.course.presentation.CourseAnalyticsKey import org.openedx.course.presentation.CourseRouter import org.openedx.course.presentation.download.DownloadDialogManager +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager +import org.openedx.foundation.utils.FileUtil class CourseOutlineViewModel( val courseId: String, diff --git a/course/src/main/java/org/openedx/course/presentation/section/CourseSectionFragment.kt b/course/src/main/java/org/openedx/course/presentation/section/CourseSectionFragment.kt index 2aee3cbc5..7a08bd9b0 100644 --- a/course/src/main/java/org/openedx/course/presentation/section/CourseSectionFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/section/CourseSectionFragment.kt @@ -55,27 +55,27 @@ import org.koin.android.ext.android.inject import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf import org.openedx.core.BlockType -import org.openedx.core.UIMessage import org.openedx.core.domain.model.AssignmentProgress import org.openedx.core.domain.model.Block import org.openedx.core.domain.model.BlockCounts -import org.openedx.core.extension.serializable import org.openedx.core.presentation.course.CourseViewMode import org.openedx.core.ui.BackBtn import org.openedx.core.ui.HandleUIMessage -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue import org.openedx.course.R import org.openedx.course.presentation.CourseRouter import org.openedx.course.presentation.ui.CardArrow +import org.openedx.foundation.extension.serializable +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import java.util.Date import org.openedx.core.R as CoreR @@ -337,16 +337,6 @@ private fun CourseSubsectionItem( } } -private fun getUnitBlockIcon(block: Block): Int { - return when (block.descendantsType) { - BlockType.VIDEO -> R.drawable.ic_course_video - BlockType.PROBLEM -> R.drawable.ic_course_pen - BlockType.DISCUSSION -> R.drawable.ic_course_discussion - else -> R.drawable.ic_course_block - } -} - - @Preview(uiMode = Configuration.UI_MODE_NIGHT_NO) @Preview(uiMode = Configuration.UI_MODE_NIGHT_YES) @Composable diff --git a/course/src/main/java/org/openedx/course/presentation/section/CourseSectionViewModel.kt b/course/src/main/java/org/openedx/course/presentation/section/CourseSectionViewModel.kt index 7f12a314f..d760620af 100644 --- a/course/src/main/java/org/openedx/course/presentation/section/CourseSectionViewModel.kt +++ b/course/src/main/java/org/openedx/course/presentation/section/CourseSectionViewModel.kt @@ -5,21 +5,21 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.viewModelScope import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.BlockType import org.openedx.core.R -import org.openedx.core.SingleEventLiveData -import org.openedx.core.UIMessage import org.openedx.core.domain.model.Block -import org.openedx.core.extension.isInternetError import org.openedx.core.presentation.course.CourseViewMode -import org.openedx.core.system.ResourceManager import org.openedx.core.system.notifier.CourseNotifier import org.openedx.core.system.notifier.CourseSectionChanged import org.openedx.course.domain.interactor.CourseInteractor import org.openedx.course.presentation.CourseAnalytics import org.openedx.course.presentation.CourseAnalyticsEvent import org.openedx.course.presentation.CourseAnalyticsKey +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.SingleEventLiveData +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager class CourseSectionViewModel( val courseId: String, diff --git a/course/src/main/java/org/openedx/course/presentation/ui/CourseUI.kt b/course/src/main/java/org/openedx/course/presentation/ui/CourseUI.kt index 780a7361d..6927c0106 100644 --- a/course/src/main/java/org/openedx/course/presentation/ui/CourseUI.kt +++ b/course/src/main/java/org/openedx/course/presentation/ui/CourseUI.kt @@ -84,8 +84,6 @@ import org.openedx.core.domain.model.AssignmentProgress import org.openedx.core.domain.model.Block import org.openedx.core.domain.model.BlockCounts import org.openedx.core.domain.model.CourseDatesBannerInfo -import org.openedx.core.extension.nonZero -import org.openedx.core.extension.toFileSize import org.openedx.core.module.db.DownloadModel import org.openedx.core.module.db.DownloadedState import org.openedx.core.module.db.FileType @@ -103,6 +101,8 @@ import org.openedx.core.utils.TimeUtils import org.openedx.course.R import org.openedx.course.presentation.dates.mockedCourseBannerInfo import org.openedx.course.presentation.outline.getUnitBlockIcon +import org.openedx.foundation.extension.nonZero +import org.openedx.foundation.extension.toFileSize import subtitleFile.Caption import subtitleFile.TimedTextObject import java.util.Date @@ -238,7 +238,7 @@ fun OfflineQueueCard( maxLines = 1 ) Text( - text = downloadModel.size.toLong().toFileSize(), + text = downloadModel.size.toFileSize(), style = MaterialTheme.appTypography.titleSmall, color = MaterialTheme.appColors.textSecondary, overflow = TextOverflow.Ellipsis, @@ -758,7 +758,7 @@ fun CourseSubSectionItem( val due by rememberSaveable { mutableStateOf(block.due?.let { TimeUtils.formatToString(context, it, useRelativeDates) } ?: "") } - val isAssignmentEnable = !block.isCompleted() && block.assignmentProgress != null && !due.isNullOrEmpty() + val isAssignmentEnable = !block.isCompleted() && block.assignmentProgress != null && due.isNotEmpty() Column( modifier = modifier .fillMaxWidth() diff --git a/course/src/main/java/org/openedx/course/presentation/ui/CourseVideosUI.kt b/course/src/main/java/org/openedx/course/presentation/ui/CourseVideosUI.kt index 5fd4ea981..f8bcd7355 100644 --- a/course/src/main/java/org/openedx/course/presentation/ui/CourseVideosUI.kt +++ b/course/src/main/java/org/openedx/course/presentation/ui/CourseVideosUI.kt @@ -51,10 +51,10 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.fragment.app.FragmentManager +import org.koin.compose.koinInject import org.openedx.core.AppDataConstants import org.openedx.core.BlockType import org.openedx.core.NoContentScreenType -import org.openedx.core.UIMessage import org.openedx.core.domain.model.AssignmentProgress import org.openedx.core.domain.model.Block import org.openedx.core.domain.model.BlockCounts @@ -62,24 +62,25 @@ import org.openedx.core.domain.model.CourseStructure import org.openedx.core.domain.model.CoursewareAccess import org.openedx.core.domain.model.Progress import org.openedx.core.domain.model.VideoSettings -import org.openedx.core.extension.toFileSize import org.openedx.core.module.download.DownloadModelsSize import org.openedx.core.presentation.course.CourseViewMode import org.openedx.core.presentation.settings.video.VideoQualityType import org.openedx.core.ui.CircularProgress import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.NoContentScreen -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue -import org.openedx.core.utils.FileUtil import org.openedx.course.R import org.openedx.course.presentation.videos.CourseVideoViewModel import org.openedx.course.presentation.videos.CourseVideosUIState +import org.openedx.foundation.extension.toFileSize +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.windowSizeValue +import org.openedx.foundation.utils.FileUtil import java.util.Date @Composable @@ -92,6 +93,7 @@ fun CourseVideosScreen( val uiMessage by viewModel.uiMessage.collectAsState(null) val videoSettings by viewModel.videoSettings.collectAsState() val context = LocalContext.current + val fileUtil: FileUtil = koinInject() CourseVideosUI( windowSize = windowSize, @@ -137,7 +139,7 @@ fun CourseVideosScreen( viewModel.removeAllDownloadModels() } else { viewModel.saveAllDownloadModels( - FileUtil(context).getExternalAppDir().path + fileUtil.getExternalAppDir().path ) } }, diff --git a/course/src/main/java/org/openedx/course/presentation/unit/NotAvailableUnitFragment.kt b/course/src/main/java/org/openedx/course/presentation/unit/NotAvailableUnitFragment.kt index b29a7ac8f..b983822b2 100644 --- a/course/src/main/java/org/openedx/course/presentation/unit/NotAvailableUnitFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/unit/NotAvailableUnitFragment.kt @@ -37,14 +37,14 @@ import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp import androidx.core.os.bundleOf import androidx.fragment.app.Fragment -import org.openedx.core.extension.parcelable -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue +import org.openedx.foundation.extension.parcelable +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.course.R as courseR class NotAvailableUnitFragment : Fragment() { diff --git a/course/src/main/java/org/openedx/course/presentation/unit/container/CourseUnitContainerFragment.kt b/course/src/main/java/org/openedx/course/presentation/unit/container/CourseUnitContainerFragment.kt index 1bc26e1a4..d8870914a 100644 --- a/course/src/main/java/org/openedx/course/presentation/unit/container/CourseUnitContainerFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/unit/container/CourseUnitContainerFragment.kt @@ -31,7 +31,6 @@ import org.koin.android.ext.android.inject import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf import org.openedx.core.BlockType -import org.openedx.core.extension.serializable import org.openedx.core.presentation.course.CourseViewMode import org.openedx.core.presentation.global.InsetHolder import org.openedx.core.ui.theme.OpenEdXTheme @@ -47,6 +46,7 @@ import org.openedx.course.presentation.ui.NavigationUnitsButtons import org.openedx.course.presentation.ui.SubSectionUnitsList import org.openedx.course.presentation.ui.SubSectionUnitsTitle import org.openedx.course.presentation.ui.VerticalPageIndicator +import org.openedx.foundation.extension.serializable class CourseUnitContainerFragment : Fragment(R.layout.fragment_course_unit_container) { diff --git a/course/src/main/java/org/openedx/course/presentation/unit/container/CourseUnitContainerViewModel.kt b/course/src/main/java/org/openedx/course/presentation/unit/container/CourseUnitContainerViewModel.kt index 20c0c7c3c..5a4cb0393 100644 --- a/course/src/main/java/org/openedx/course/presentation/unit/container/CourseUnitContainerViewModel.kt +++ b/course/src/main/java/org/openedx/course/presentation/unit/container/CourseUnitContainerViewModel.kt @@ -9,12 +9,9 @@ import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.first import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking -import org.openedx.core.BaseViewModel import org.openedx.core.BlockType import org.openedx.core.config.Config import org.openedx.core.domain.model.Block -import org.openedx.core.extension.clearAndAddAll -import org.openedx.core.extension.indexOfFirstFromIndex import org.openedx.core.module.db.DownloadModel import org.openedx.core.module.db.DownloadedState import org.openedx.core.presentation.course.CourseViewMode @@ -26,6 +23,9 @@ import org.openedx.course.domain.interactor.CourseInteractor import org.openedx.course.presentation.CourseAnalytics import org.openedx.course.presentation.CourseAnalyticsEvent import org.openedx.course.presentation.CourseAnalyticsKey +import org.openedx.foundation.extension.clearAndAddAll +import org.openedx.foundation.extension.indexOfFirstFromIndex +import org.openedx.foundation.presentation.BaseViewModel class CourseUnitContainerViewModel( val courseId: String, 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 e342f1f06..7bf313ac8 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 @@ -52,19 +52,19 @@ import androidx.fragment.app.Fragment import kotlinx.coroutines.launch import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf -import org.openedx.core.extension.applyDarkModeIfEnabled import org.openedx.core.extension.equalsHost -import org.openedx.core.extension.isEmailValid import org.openedx.core.extension.loadUrl import org.openedx.core.system.AppCookieManager import org.openedx.core.ui.FullScreenErrorView -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.roundBorderWithoutBottom import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors -import org.openedx.core.ui.windowSizeValue import org.openedx.core.utils.EmailUtil +import org.openedx.foundation.extension.applyDarkModeIfEnabled +import org.openedx.foundation.extension.isEmailValid +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue class HtmlUnitFragment : Fragment() { 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 bccdcd0fd..ca79ce90b 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 @@ -4,13 +4,9 @@ import android.content.res.AssetManager import androidx.lifecycle.viewModelScope import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow -import kotlinx.coroutines.flow.update 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.ErrorType import org.openedx.core.system.AppCookieManager import org.openedx.core.system.connection.NetworkConnection @@ -18,6 +14,8 @@ import org.openedx.core.system.notifier.CourseCompletionSet import org.openedx.core.system.notifier.CourseNotifier import org.openedx.course.domain.interactor.CourseInteractor import org.openedx.course.worker.OfflineProgressSyncScheduler +import org.openedx.foundation.extension.readAsText +import org.openedx.foundation.presentation.BaseViewModel class HtmlUnitViewModel( private val blockId: String, @@ -92,6 +90,7 @@ class HtmlUnitViewModel( courseInteractor.submitOfflineXBlockProgress(blockId, courseId) } } catch (e: Exception) { + e.printStackTrace() } finally { _uiState.value = HtmlUnitUIState.Loading } diff --git a/course/src/main/java/org/openedx/course/presentation/unit/video/BaseVideoViewModel.kt b/course/src/main/java/org/openedx/course/presentation/unit/video/BaseVideoViewModel.kt index 96d285223..7c67329e6 100644 --- a/course/src/main/java/org/openedx/course/presentation/unit/video/BaseVideoViewModel.kt +++ b/course/src/main/java/org/openedx/course/presentation/unit/video/BaseVideoViewModel.kt @@ -1,9 +1,9 @@ package org.openedx.course.presentation.unit.video -import org.openedx.core.BaseViewModel import org.openedx.course.presentation.CourseAnalytics import org.openedx.course.presentation.CourseAnalyticsEvent import org.openedx.course.presentation.CourseAnalyticsKey +import org.openedx.foundation.presentation.BaseViewModel open class BaseVideoViewModel( private val courseId: String, diff --git a/course/src/main/java/org/openedx/course/presentation/unit/video/VideoFullScreenFragment.kt b/course/src/main/java/org/openedx/course/presentation/unit/video/VideoFullScreenFragment.kt index 3caa4d7c6..7bbf0bd25 100644 --- a/course/src/main/java/org/openedx/course/presentation/unit/video/VideoFullScreenFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/unit/video/VideoFullScreenFragment.kt @@ -27,12 +27,12 @@ import org.koin.android.ext.android.inject import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf import org.openedx.core.domain.model.VideoQuality -import org.openedx.core.extension.requestApplyInsetsWhenAttached import org.openedx.core.presentation.dialog.appreview.AppReviewManager import org.openedx.core.presentation.global.viewBinding import org.openedx.course.R import org.openedx.course.databinding.FragmentVideoFullScreenBinding import org.openedx.course.presentation.CourseAnalyticsKey +import org.openedx.foundation.extension.requestApplyInsetsWhenAttached class VideoFullScreenFragment : Fragment(R.layout.fragment_video_full_screen) { diff --git a/course/src/main/java/org/openedx/course/presentation/unit/video/VideoUnitFragment.kt b/course/src/main/java/org/openedx/course/presentation/unit/video/VideoUnitFragment.kt index 49431ba46..0cc44dac3 100644 --- a/course/src/main/java/org/openedx/course/presentation/unit/video/VideoUnitFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/unit/video/VideoUnitFragment.kt @@ -23,15 +23,10 @@ import androidx.window.layout.WindowMetricsCalculator import org.koin.android.ext.android.inject import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf -import org.openedx.core.extension.computeWindowSizeClasses -import org.openedx.core.extension.dpToPixel -import org.openedx.core.extension.objectToString -import org.openedx.core.extension.stringToObject import org.openedx.core.presentation.dialog.appreview.AppReviewManager import org.openedx.core.presentation.dialog.selectorbottomsheet.SelectBottomDialogFragment import org.openedx.core.presentation.global.viewBinding import org.openedx.core.ui.ConnectionErrorView -import org.openedx.core.ui.WindowSize import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.utils.LocaleUtils import org.openedx.course.R @@ -41,6 +36,11 @@ import org.openedx.course.presentation.CourseAnalyticsKey import org.openedx.course.presentation.CourseRouter import org.openedx.course.presentation.ui.VideoSubtitles import org.openedx.course.presentation.ui.VideoTitle +import org.openedx.foundation.extension.computeWindowSizeClasses +import org.openedx.foundation.extension.dpToPixel +import org.openedx.foundation.extension.objectToString +import org.openedx.foundation.extension.stringToObject +import org.openedx.foundation.presentation.WindowSize import kotlin.math.roundToInt class VideoUnitFragment : Fragment(R.layout.fragment_video_unit) { diff --git a/course/src/main/java/org/openedx/course/presentation/unit/video/YoutubeVideoFullScreenFragment.kt b/course/src/main/java/org/openedx/course/presentation/unit/video/YoutubeVideoFullScreenFragment.kt index f62659c26..397c36baf 100644 --- a/course/src/main/java/org/openedx/course/presentation/unit/video/YoutubeVideoFullScreenFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/unit/video/YoutubeVideoFullScreenFragment.kt @@ -16,12 +16,12 @@ import com.pierfrancescosoffritti.androidyoutubeplayer.core.ui.DefaultPlayerUiCo import org.koin.android.ext.android.inject import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf -import org.openedx.core.extension.requestApplyInsetsWhenAttached import org.openedx.core.presentation.dialog.appreview.AppReviewManager import org.openedx.core.presentation.global.viewBinding import org.openedx.course.R import org.openedx.course.databinding.FragmentYoutubeVideoFullScreenBinding import org.openedx.course.presentation.CourseAnalyticsKey +import org.openedx.foundation.extension.requestApplyInsetsWhenAttached class YoutubeVideoFullScreenFragment : Fragment(R.layout.fragment_youtube_video_full_screen) { diff --git a/course/src/main/java/org/openedx/course/presentation/unit/video/YoutubeVideoUnitFragment.kt b/course/src/main/java/org/openedx/course/presentation/unit/video/YoutubeVideoUnitFragment.kt index b163a7cde..58aaaf377 100644 --- a/course/src/main/java/org/openedx/course/presentation/unit/video/YoutubeVideoUnitFragment.kt +++ b/course/src/main/java/org/openedx/course/presentation/unit/video/YoutubeVideoUnitFragment.kt @@ -20,13 +20,9 @@ import com.pierfrancescosoffritti.androidyoutubeplayer.core.ui.DefaultPlayerUiCo import org.koin.android.ext.android.inject import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf -import org.openedx.core.extension.computeWindowSizeClasses -import org.openedx.core.extension.objectToString -import org.openedx.core.extension.stringToObject import org.openedx.core.presentation.dialog.appreview.AppReviewManager import org.openedx.core.presentation.dialog.selectorbottomsheet.SelectBottomDialogFragment import org.openedx.core.ui.ConnectionErrorView -import org.openedx.core.ui.WindowSize import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.utils.LocaleUtils import org.openedx.course.R @@ -35,6 +31,10 @@ import org.openedx.course.presentation.CourseAnalyticsKey import org.openedx.course.presentation.CourseRouter import org.openedx.course.presentation.ui.VideoSubtitles import org.openedx.course.presentation.ui.VideoTitle +import org.openedx.foundation.extension.computeWindowSizeClasses +import org.openedx.foundation.extension.objectToString +import org.openedx.foundation.extension.stringToObject +import org.openedx.foundation.presentation.WindowSize class YoutubeVideoUnitFragment : Fragment(R.layout.fragment_youtube_video_unit) { diff --git a/course/src/main/java/org/openedx/course/presentation/videos/CourseVideoViewModel.kt b/course/src/main/java/org/openedx/course/presentation/videos/CourseVideoViewModel.kt index a02eac54c..3d197859f 100644 --- a/course/src/main/java/org/openedx/course/presentation/videos/CourseVideoViewModel.kt +++ b/course/src/main/java/org/openedx/course/presentation/videos/CourseVideoViewModel.kt @@ -10,7 +10,6 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch import org.openedx.core.BlockType -import org.openedx.core.UIMessage import org.openedx.core.config.Config import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.model.Block @@ -20,19 +19,20 @@ import org.openedx.core.module.db.DownloadDao import org.openedx.core.module.download.BaseDownloadViewModel import org.openedx.core.module.download.DownloadHelper import org.openedx.core.presentation.CoreAnalytics -import org.openedx.core.system.ResourceManager import org.openedx.core.system.connection.NetworkConnection import org.openedx.core.system.notifier.CourseLoading import org.openedx.core.system.notifier.CourseNotifier import org.openedx.core.system.notifier.CourseStructureUpdated import org.openedx.core.system.notifier.VideoNotifier import org.openedx.core.system.notifier.VideoQualityChanged -import org.openedx.core.utils.FileUtil import org.openedx.course.R import org.openedx.course.domain.interactor.CourseInteractor import org.openedx.course.presentation.CourseAnalytics import org.openedx.course.presentation.CourseRouter import org.openedx.course.presentation.download.DownloadDialogManager +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager +import org.openedx.foundation.utils.FileUtil class CourseVideoViewModel( val courseId: String, diff --git a/course/src/main/java/org/openedx/course/settings/download/DownloadQueueFragment.kt b/course/src/main/java/org/openedx/course/settings/download/DownloadQueueFragment.kt index 3db1ee158..ceea27806 100644 --- a/course/src/main/java/org/openedx/course/settings/download/DownloadQueueFragment.kt +++ b/course/src/main/java/org/openedx/course/settings/download/DownloadQueueFragment.kt @@ -47,18 +47,18 @@ import org.openedx.core.module.db.DownloadModel import org.openedx.core.module.db.DownloadedState import org.openedx.core.module.db.FileType import org.openedx.core.ui.BackBtn -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue import org.openedx.course.R import org.openedx.course.presentation.ui.OfflineQueueCard +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue class DownloadQueueFragment : Fragment() { diff --git a/core/src/main/java/org/openedx/core/ImageProcessor.kt b/course/src/main/java/org/openedx/course/utils/ImageProcessor.kt similarity index 98% rename from core/src/main/java/org/openedx/core/ImageProcessor.kt rename to course/src/main/java/org/openedx/course/utils/ImageProcessor.kt index d3a6c4a4c..b83f4a5e5 100644 --- a/core/src/main/java/org/openedx/core/ImageProcessor.kt +++ b/course/src/main/java/org/openedx/course/utils/ImageProcessor.kt @@ -1,6 +1,6 @@ @file:Suppress("DEPRECATION") -package org.openedx.core +package org.openedx.course.utils import android.content.Context import android.graphics.Bitmap diff --git a/course/src/test/java/org/openedx/course/presentation/container/CourseContainerViewModelTest.kt b/course/src/test/java/org/openedx/course/presentation/container/CourseContainerViewModelTest.kt index 63ad22b05..5f9f19756 100644 --- a/course/src/test/java/org/openedx/course/presentation/container/CourseContainerViewModelTest.kt +++ b/course/src/test/java/org/openedx/course/presentation/container/CourseContainerViewModelTest.kt @@ -22,7 +22,6 @@ import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.rules.TestRule -import org.openedx.core.ImageProcessor import org.openedx.core.R import org.openedx.core.config.Config import org.openedx.core.data.api.CourseApi @@ -33,7 +32,6 @@ import org.openedx.core.domain.model.AppConfig import org.openedx.core.domain.model.CourseDatesCalendarSync import org.openedx.core.domain.model.CourseStructure import org.openedx.core.domain.model.CoursewareAccess -import org.openedx.core.system.ResourceManager import org.openedx.core.system.connection.NetworkConnection import org.openedx.core.system.notifier.CourseNotifier import org.openedx.core.system.notifier.CourseStructureUpdated @@ -42,6 +40,8 @@ import org.openedx.course.domain.interactor.CourseInteractor import org.openedx.course.presentation.CourseAnalytics import org.openedx.course.presentation.CourseAnalyticsEvent import org.openedx.course.presentation.CourseRouter +import org.openedx.course.utils.ImageProcessor +import org.openedx.foundation.system.ResourceManager import java.net.UnknownHostException import java.util.Date diff --git a/course/src/test/java/org/openedx/course/presentation/dates/CourseDatesViewModelTest.kt b/course/src/test/java/org/openedx/course/presentation/dates/CourseDatesViewModelTest.kt index 389196f31..f9392df33 100644 --- a/course/src/test/java/org/openedx/course/presentation/dates/CourseDatesViewModelTest.kt +++ b/course/src/test/java/org/openedx/course/presentation/dates/CourseDatesViewModelTest.kt @@ -25,7 +25,6 @@ import org.junit.Test import org.junit.rules.TestRule import org.openedx.core.CalendarRouter import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.config.Config import org.openedx.core.data.model.DateType import org.openedx.core.data.storage.CorePreferences @@ -37,7 +36,6 @@ import org.openedx.core.domain.model.CourseDatesResult import org.openedx.core.domain.model.CourseStructure import org.openedx.core.domain.model.CoursewareAccess import org.openedx.core.domain.model.DatesSection -import org.openedx.core.system.ResourceManager import org.openedx.core.system.notifier.CalendarSyncEvent.CreateCalendarSyncEvent import org.openedx.core.system.notifier.CourseLoading import org.openedx.core.system.notifier.CourseNotifier @@ -47,6 +45,8 @@ import org.openedx.core.system.notifier.calendar.CalendarSynced import org.openedx.course.domain.interactor.CourseInteractor import org.openedx.course.presentation.CourseAnalytics import org.openedx.course.presentation.CourseRouter +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import java.net.UnknownHostException import java.util.Date diff --git a/course/src/test/java/org/openedx/course/presentation/outline/CourseOutlineViewModelTest.kt b/course/src/test/java/org/openedx/course/presentation/outline/CourseOutlineViewModelTest.kt index 679dfedc9..a9ea6c5e9 100644 --- a/course/src/test/java/org/openedx/course/presentation/outline/CourseOutlineViewModelTest.kt +++ b/course/src/test/java/org/openedx/course/presentation/outline/CourseOutlineViewModelTest.kt @@ -29,7 +29,6 @@ import org.junit.Test import org.junit.rules.TestRule import org.openedx.core.BlockType import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.config.Config import org.openedx.core.data.model.DateType import org.openedx.core.data.storage.CorePreferences @@ -52,15 +51,16 @@ import org.openedx.core.module.db.FileType import org.openedx.core.module.download.DownloadHelper import org.openedx.core.presentation.CoreAnalytics import org.openedx.core.presentation.CoreAnalyticsEvent -import org.openedx.core.system.ResourceManager import org.openedx.core.system.connection.NetworkConnection import org.openedx.core.system.notifier.CourseNotifier import org.openedx.core.system.notifier.CourseStructureUpdated -import org.openedx.core.utils.FileUtil import org.openedx.course.domain.interactor.CourseInteractor import org.openedx.course.presentation.CourseAnalytics import org.openedx.course.presentation.CourseRouter import org.openedx.course.presentation.download.DownloadDialogManager +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager +import org.openedx.foundation.utils.FileUtil import java.net.UnknownHostException import java.util.Date diff --git a/course/src/test/java/org/openedx/course/presentation/section/CourseSectionViewModelTest.kt b/course/src/test/java/org/openedx/course/presentation/section/CourseSectionViewModelTest.kt index 45ff2a72f..e1c6a98ca 100644 --- a/course/src/test/java/org/openedx/course/presentation/section/CourseSectionViewModelTest.kt +++ b/course/src/test/java/org/openedx/course/presentation/section/CourseSectionViewModelTest.kt @@ -25,7 +25,6 @@ import org.junit.Test import org.junit.rules.TestRule import org.openedx.core.BlockType import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.model.AssignmentProgress import org.openedx.core.domain.model.Block @@ -41,11 +40,12 @@ import org.openedx.core.module.db.FileType import org.openedx.core.module.download.DownloadHelper import org.openedx.core.presentation.CoreAnalytics import org.openedx.core.presentation.course.CourseViewMode -import org.openedx.core.system.ResourceManager import org.openedx.core.system.connection.NetworkConnection import org.openedx.core.system.notifier.CourseNotifier import org.openedx.course.domain.interactor.CourseInteractor import org.openedx.course.presentation.CourseAnalytics +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import java.net.UnknownHostException import java.util.Date diff --git a/course/src/test/java/org/openedx/course/presentation/videos/CourseVideoViewModelTest.kt b/course/src/test/java/org/openedx/course/presentation/videos/CourseVideoViewModelTest.kt index 812962c83..e5df7e948 100644 --- a/course/src/test/java/org/openedx/course/presentation/videos/CourseVideoViewModelTest.kt +++ b/course/src/test/java/org/openedx/course/presentation/videos/CourseVideoViewModelTest.kt @@ -29,7 +29,6 @@ import org.junit.Rule import org.junit.Test import org.junit.rules.TestRule import org.openedx.core.BlockType -import org.openedx.core.UIMessage import org.openedx.core.config.Config import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.model.AssignmentProgress @@ -46,18 +45,19 @@ import org.openedx.core.module.db.DownloadedState import org.openedx.core.module.db.FileType import org.openedx.core.module.download.DownloadHelper import org.openedx.core.presentation.CoreAnalytics -import org.openedx.core.system.ResourceManager import org.openedx.core.system.connection.NetworkConnection import org.openedx.core.system.notifier.CourseLoading import org.openedx.core.system.notifier.CourseNotifier import org.openedx.core.system.notifier.CourseStructureUpdated import org.openedx.core.system.notifier.VideoNotifier -import org.openedx.core.utils.FileUtil import org.openedx.course.R import org.openedx.course.domain.interactor.CourseInteractor import org.openedx.course.presentation.CourseAnalytics import org.openedx.course.presentation.CourseRouter import org.openedx.course.presentation.download.DownloadDialogManager +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager +import org.openedx.foundation.utils.FileUtil import java.util.Date @OptIn(ExperimentalCoroutinesApi::class) diff --git a/dashboard/build.gradle b/dashboard/build.gradle index 2fea01174..13119287f 100644 --- a/dashboard/build.gradle +++ b/dashboard/build.gradle @@ -1,6 +1,7 @@ plugins { id 'com.android.library' id 'org.jetbrains.kotlin.android' + id "org.jetbrains.kotlin.plugin.compose" } android { @@ -36,9 +37,6 @@ android { viewBinding true compose true } - composeOptions { - kotlinCompilerExtensionVersion = "$compose_compiler_version" - } flavorDimensions += "env" productFlavors { @@ -57,13 +55,10 @@ android { dependencies { implementation project(path: ':core') - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" - debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version" + androidTestImplementation 'androidx.test.ext:junit:1.2.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' testImplementation "junit:junit:$junit_version" testImplementation "io.mockk:mockk:$mockk_version" testImplementation "io.mockk:mockk-android:$mockk_version" - testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version" testImplementation "androidx.arch.core:core-testing:$android_arch_version" } \ No newline at end of file diff --git a/dashboard/src/main/java/org/openedx/courses/presentation/AllEnrolledCoursesView.kt b/dashboard/src/main/java/org/openedx/courses/presentation/AllEnrolledCoursesView.kt index 7bd060bb5..e6ca810a1 100644 --- a/dashboard/src/main/java/org/openedx/courses/presentation/AllEnrolledCoursesView.kt +++ b/dashboard/src/main/java/org/openedx/courses/presentation/AllEnrolledCoursesView.kt @@ -73,7 +73,6 @@ import coil.request.ImageRequest import org.koin.androidx.compose.koinViewModel import org.openedx.Lock import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.domain.model.Certificate import org.openedx.core.domain.model.CourseAssignments import org.openedx.core.domain.model.CourseSharingUtmParameters @@ -82,22 +81,23 @@ import org.openedx.core.domain.model.CoursewareAccess import org.openedx.core.domain.model.EnrolledCourse import org.openedx.core.domain.model.EnrolledCourseData import org.openedx.core.domain.model.Progress -import org.openedx.core.extension.toImageLink import org.openedx.core.ui.BackBtn import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.OfflineModeDialog import org.openedx.core.ui.RoundTabsBar import org.openedx.core.ui.displayCutoutForLandscape -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.shouldLoadMore import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue import org.openedx.core.utils.TimeUtils import org.openedx.dashboard.domain.CourseStatusFilter +import org.openedx.foundation.extension.toImageLink +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import java.util.Date @Composable diff --git a/dashboard/src/main/java/org/openedx/courses/presentation/AllEnrolledCoursesViewModel.kt b/dashboard/src/main/java/org/openedx/courses/presentation/AllEnrolledCoursesViewModel.kt index d52475eca..9c6129623 100644 --- a/dashboard/src/main/java/org/openedx/courses/presentation/AllEnrolledCoursesViewModel.kt +++ b/dashboard/src/main/java/org/openedx/courses/presentation/AllEnrolledCoursesViewModel.kt @@ -11,13 +11,9 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.config.Config import org.openedx.core.domain.model.EnrolledCourse -import org.openedx.core.extension.isInternetError -import org.openedx.core.system.ResourceManager import org.openedx.core.system.connection.NetworkConnection import org.openedx.core.system.notifier.CourseDashboardUpdate import org.openedx.core.system.notifier.DiscoveryNotifier @@ -25,6 +21,10 @@ import org.openedx.dashboard.domain.CourseStatusFilter import org.openedx.dashboard.domain.interactor.DashboardInteractor import org.openedx.dashboard.presentation.DashboardAnalytics import org.openedx.dashboard.presentation.DashboardRouter +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager class AllEnrolledCoursesViewModel( private val config: Config, diff --git a/dashboard/src/main/java/org/openedx/courses/presentation/DashboardGalleryView.kt b/dashboard/src/main/java/org/openedx/courses/presentation/DashboardGalleryView.kt index 493f81a00..40e2b0318 100644 --- a/dashboard/src/main/java/org/openedx/courses/presentation/DashboardGalleryView.kt +++ b/dashboard/src/main/java/org/openedx/courses/presentation/DashboardGalleryView.kt @@ -71,7 +71,6 @@ import coil.request.ImageRequest import org.koin.androidx.compose.koinViewModel import org.koin.core.parameter.parametersOf import org.openedx.Lock -import org.openedx.core.UIMessage import org.openedx.core.domain.model.AppConfig import org.openedx.core.domain.model.Certificate import org.openedx.core.domain.model.CourseAssignments @@ -86,18 +85,19 @@ import org.openedx.core.domain.model.EnrolledCourse import org.openedx.core.domain.model.EnrolledCourseData import org.openedx.core.domain.model.Pagination import org.openedx.core.domain.model.Progress -import org.openedx.core.extension.toImageLink import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.OfflineModeDialog import org.openedx.core.ui.OpenEdXButton import org.openedx.core.ui.TextIcon -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography import org.openedx.core.utils.TimeUtils import org.openedx.dashboard.R +import org.openedx.foundation.extension.toImageLink +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.rememberWindowSize import java.util.Date import org.openedx.core.R as CoreR diff --git a/dashboard/src/main/java/org/openedx/courses/presentation/DashboardGalleryViewModel.kt b/dashboard/src/main/java/org/openedx/courses/presentation/DashboardGalleryViewModel.kt index 2c6ba0ccb..cf36699f1 100644 --- a/dashboard/src/main/java/org/openedx/courses/presentation/DashboardGalleryViewModel.kt +++ b/dashboard/src/main/java/org/openedx/courses/presentation/DashboardGalleryViewModel.kt @@ -9,23 +9,23 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.config.Config import org.openedx.core.data.model.CourseEnrollments import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.model.EnrolledCourse -import org.openedx.core.extension.isInternetError -import org.openedx.core.system.ResourceManager import org.openedx.core.system.connection.NetworkConnection import org.openedx.core.system.notifier.CourseDashboardUpdate import org.openedx.core.system.notifier.DiscoveryNotifier import org.openedx.core.system.notifier.NavigationToDiscovery -import org.openedx.core.ui.WindowSize -import org.openedx.core.utils.FileUtil import org.openedx.dashboard.domain.interactor.DashboardInteractor import org.openedx.dashboard.presentation.DashboardRouter +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.system.ResourceManager +import org.openedx.foundation.utils.FileUtil class DashboardGalleryViewModel( private val config: Config, diff --git a/dashboard/src/main/java/org/openedx/dashboard/data/repository/DashboardRepository.kt b/dashboard/src/main/java/org/openedx/dashboard/data/repository/DashboardRepository.kt index a65ca8d07..17c41e07d 100644 --- a/dashboard/src/main/java/org/openedx/dashboard/data/repository/DashboardRepository.kt +++ b/dashboard/src/main/java/org/openedx/dashboard/data/repository/DashboardRepository.kt @@ -5,9 +5,9 @@ import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.model.CourseEnrollments import org.openedx.core.domain.model.DashboardCourseList import org.openedx.core.domain.model.EnrolledCourse -import org.openedx.core.utils.FileUtil import org.openedx.dashboard.data.DashboardDao import org.openedx.dashboard.domain.CourseStatusFilter +import org.openedx.foundation.utils.FileUtil class DashboardRepository( private val api: CourseApi, diff --git a/dashboard/src/main/java/org/openedx/dashboard/presentation/DashboardListFragment.kt b/dashboard/src/main/java/org/openedx/dashboard/presentation/DashboardListFragment.kt index eea1b9db1..3ab2d7555 100644 --- a/dashboard/src/main/java/org/openedx/dashboard/presentation/DashboardListFragment.kt +++ b/dashboard/src/main/java/org/openedx/dashboard/presentation/DashboardListFragment.kt @@ -75,7 +75,6 @@ import coil.request.ImageRequest import org.koin.android.ext.android.inject import org.koin.androidx.viewmodel.ext.android.viewModel import org.openedx.core.AppUpdateState -import org.openedx.core.UIMessage import org.openedx.core.domain.model.Certificate import org.openedx.core.domain.model.CourseAssignments import org.openedx.core.domain.model.CourseSharingUtmParameters @@ -84,23 +83,24 @@ import org.openedx.core.domain.model.CoursewareAccess import org.openedx.core.domain.model.EnrolledCourse import org.openedx.core.domain.model.EnrolledCourseData import org.openedx.core.domain.model.Progress -import org.openedx.core.extension.toImageLink import org.openedx.core.presentation.global.app_upgrade.AppUpgradeRecommendedBox import org.openedx.core.system.notifier.app.AppUpgradeEvent import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.OfflineModeDialog -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.shouldLoadMore import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue import org.openedx.core.utils.TimeUtils import org.openedx.dashboard.R +import org.openedx.foundation.extension.toImageLink +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import java.util.Date import org.openedx.core.R as CoreR diff --git a/dashboard/src/main/java/org/openedx/dashboard/presentation/DashboardListViewModel.kt b/dashboard/src/main/java/org/openedx/dashboard/presentation/DashboardListViewModel.kt index bfafc81c4..e04ddb258 100644 --- a/dashboard/src/main/java/org/openedx/dashboard/presentation/DashboardListViewModel.kt +++ b/dashboard/src/main/java/org/openedx/dashboard/presentation/DashboardListViewModel.kt @@ -5,20 +5,20 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.viewModelScope import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.R -import org.openedx.core.SingleEventLiveData -import org.openedx.core.UIMessage import org.openedx.core.config.Config import org.openedx.core.domain.model.EnrolledCourse -import org.openedx.core.extension.isInternetError -import org.openedx.core.system.ResourceManager import org.openedx.core.system.connection.NetworkConnection -import org.openedx.core.system.notifier.app.AppUpgradeEvent import org.openedx.core.system.notifier.CourseDashboardUpdate import org.openedx.core.system.notifier.DiscoveryNotifier import org.openedx.core.system.notifier.app.AppNotifier +import org.openedx.core.system.notifier.app.AppUpgradeEvent import org.openedx.dashboard.domain.interactor.DashboardInteractor +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.SingleEventLiveData +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager class DashboardListViewModel( private val config: Config, diff --git a/dashboard/src/main/java/org/openedx/learn/presentation/LearnFragment.kt b/dashboard/src/main/java/org/openedx/learn/presentation/LearnFragment.kt index b1f4bbbb7..a0e304170 100644 --- a/dashboard/src/main/java/org/openedx/learn/presentation/LearnFragment.kt +++ b/dashboard/src/main/java/org/openedx/learn/presentation/LearnFragment.kt @@ -46,14 +46,14 @@ import org.openedx.core.adapter.NavigationFragmentAdapter import org.openedx.core.presentation.global.viewBinding import org.openedx.core.ui.crop import org.openedx.core.ui.displayCutoutForLandscape -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue import org.openedx.dashboard.R import org.openedx.dashboard.databinding.FragmentLearnBinding +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.learn.LearnType import org.openedx.core.R as CoreR diff --git a/dashboard/src/main/java/org/openedx/learn/presentation/LearnViewModel.kt b/dashboard/src/main/java/org/openedx/learn/presentation/LearnViewModel.kt index 9a2d17f1e..ee38caf75 100644 --- a/dashboard/src/main/java/org/openedx/learn/presentation/LearnViewModel.kt +++ b/dashboard/src/main/java/org/openedx/learn/presentation/LearnViewModel.kt @@ -2,12 +2,12 @@ package org.openedx.learn.presentation import androidx.fragment.app.FragmentManager import org.openedx.DashboardNavigator -import org.openedx.core.BaseViewModel import org.openedx.core.config.Config import org.openedx.dashboard.presentation.DashboardAnalytics import org.openedx.dashboard.presentation.DashboardAnalyticsEvent import org.openedx.dashboard.presentation.DashboardAnalyticsKey import org.openedx.dashboard.presentation.DashboardRouter +import org.openedx.foundation.presentation.BaseViewModel class LearnViewModel( private val config: Config, diff --git a/dashboard/src/test/java/org/openedx/dashboard/presentation/DashboardListViewModelTest.kt b/dashboard/src/test/java/org/openedx/dashboard/presentation/DashboardListViewModelTest.kt index 216d8ecbf..1eb943cca 100644 --- a/dashboard/src/test/java/org/openedx/dashboard/presentation/DashboardListViewModelTest.kt +++ b/dashboard/src/test/java/org/openedx/dashboard/presentation/DashboardListViewModelTest.kt @@ -25,16 +25,16 @@ import org.junit.Rule import org.junit.Test import org.junit.rules.TestRule import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.config.Config import org.openedx.core.domain.model.DashboardCourseList import org.openedx.core.domain.model.Pagination -import org.openedx.core.system.ResourceManager import org.openedx.core.system.connection.NetworkConnection import org.openedx.core.system.notifier.CourseDashboardUpdate import org.openedx.core.system.notifier.DiscoveryNotifier import org.openedx.core.system.notifier.app.AppNotifier import org.openedx.dashboard.domain.interactor.DashboardInteractor +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import java.net.UnknownHostException @OptIn(ExperimentalCoroutinesApi::class) diff --git a/default_config/dev/config.yaml b/default_config/dev/config.yaml index 19c1e600a..df9d1f401 100644 --- a/default_config/dev/config.yaml +++ b/default_config/dev/config.yaml @@ -33,17 +33,12 @@ DASHBOARD: FIREBASE: ENABLED: false - ANALYTICS_SOURCE: '' # segment | none CLOUD_MESSAGING_ENABLED: false PROJECT_NUMBER: '' PROJECT_ID: '' APPLICATION_ID: '' #App ID field from the Firebase console or mobilesdk_app_id from the google-services.json file. API_KEY: '' -SEGMENT_IO: - ENABLED: false - SEGMENT_IO_WRITE_KEY: '' - BRAZE: ENABLED: false PUSH_NOTIFICATIONS_ENABLED: false @@ -69,10 +64,6 @@ BRANCH: HOST: '' ALTERNATE_HOST: '' -FULLSTORY: - ENABLED: false - ORG_ID: '' - #Platform names PLATFORM_NAME: "OpenEdX" PLATFORM_FULL_NAME: "OpenEdX" @@ -90,4 +81,4 @@ REGISTRATION_ENABLED: true UI_COMPONENTS: COURSE_DROPDOWN_NAVIGATION_ENABLED: false COURSE_UNIT_PROGRESS_ENABLED: false - COURSE_DOWNLOAD_QUEUE_SCREEN: false + COURSE_DOWNLOAD_QUEUE_SCREEN: false \ No newline at end of file diff --git a/default_config/prod/config.yaml b/default_config/prod/config.yaml index 19c1e600a..19e53ef73 100644 --- a/default_config/prod/config.yaml +++ b/default_config/prod/config.yaml @@ -33,17 +33,12 @@ DASHBOARD: FIREBASE: ENABLED: false - ANALYTICS_SOURCE: '' # segment | none CLOUD_MESSAGING_ENABLED: false PROJECT_NUMBER: '' PROJECT_ID: '' APPLICATION_ID: '' #App ID field from the Firebase console or mobilesdk_app_id from the google-services.json file. API_KEY: '' -SEGMENT_IO: - ENABLED: false - SEGMENT_IO_WRITE_KEY: '' - BRAZE: ENABLED: false PUSH_NOTIFICATIONS_ENABLED: false @@ -69,10 +64,6 @@ BRANCH: HOST: '' ALTERNATE_HOST: '' -FULLSTORY: - ENABLED: false - ORG_ID: '' - #Platform names PLATFORM_NAME: "OpenEdX" PLATFORM_FULL_NAME: "OpenEdX" diff --git a/default_config/stage/config.yaml b/default_config/stage/config.yaml index 19c1e600a..19e53ef73 100644 --- a/default_config/stage/config.yaml +++ b/default_config/stage/config.yaml @@ -33,17 +33,12 @@ DASHBOARD: FIREBASE: ENABLED: false - ANALYTICS_SOURCE: '' # segment | none CLOUD_MESSAGING_ENABLED: false PROJECT_NUMBER: '' PROJECT_ID: '' APPLICATION_ID: '' #App ID field from the Firebase console or mobilesdk_app_id from the google-services.json file. API_KEY: '' -SEGMENT_IO: - ENABLED: false - SEGMENT_IO_WRITE_KEY: '' - BRAZE: ENABLED: false PUSH_NOTIFICATIONS_ENABLED: false @@ -69,10 +64,6 @@ BRANCH: HOST: '' ALTERNATE_HOST: '' -FULLSTORY: - ENABLED: false - ORG_ID: '' - #Platform names PLATFORM_NAME: "OpenEdX" PLATFORM_FULL_NAME: "OpenEdX" diff --git a/discovery/build.gradle b/discovery/build.gradle index 5e6e1887b..d9c4419fc 100644 --- a/discovery/build.gradle +++ b/discovery/build.gradle @@ -2,7 +2,8 @@ plugins { id 'com.android.library' id 'org.jetbrains.kotlin.android' id 'kotlin-parcelize' - id 'kotlin-kapt' + id 'com.google.devtools.ksp' + id "org.jetbrains.kotlin.plugin.compose" } android { @@ -38,9 +39,6 @@ android { viewBinding true compose true } - composeOptions { - kotlinCompilerExtensionVersion = "$compose_compiler_version" - } flavorDimensions += "env" productFlavors { @@ -59,17 +57,14 @@ android { dependencies { implementation project(path: ':core') - kapt "androidx.room:room-compiler:$room_version" + ksp "androidx.room:room-compiler:$room_version" implementation 'androidx.activity:activity-compose:1.8.1' - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" - debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version" + androidTestImplementation 'androidx.test.ext:junit:1.2.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' testImplementation "junit:junit:$junit_version" testImplementation "io.mockk:mockk:$mockk_version" testImplementation "io.mockk:mockk-android:$mockk_version" - testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version" testImplementation "androidx.arch.core:core-testing:$android_arch_version" } diff --git a/discovery/src/main/java/org/openedx/discovery/presentation/NativeDiscoveryFragment.kt b/discovery/src/main/java/org/openedx/discovery/presentation/NativeDiscoveryFragment.kt index 1e9c6663f..5efb7a5b0 100644 --- a/discovery/src/main/java/org/openedx/discovery/presentation/NativeDiscoveryFragment.kt +++ b/discovery/src/main/java/org/openedx/discovery/presentation/NativeDiscoveryFragment.kt @@ -59,7 +59,6 @@ import org.koin.android.ext.android.inject import org.koin.androidx.viewmodel.ext.android.viewModel import org.openedx.core.AppUpdateState import org.openedx.core.AppUpdateState.wasUpdateDialogClosed -import org.openedx.core.UIMessage import org.openedx.core.domain.model.Media import org.openedx.core.presentation.dialog.appupgrade.AppUpgradeDialogFragment import org.openedx.core.presentation.global.app_upgrade.AppUpgradeRecommendedBox @@ -70,19 +69,20 @@ import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.OfflineModeDialog import org.openedx.core.ui.StaticSearchBar import org.openedx.core.ui.Toolbar -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.shouldLoadMore import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue import org.openedx.discovery.R import org.openedx.discovery.domain.model.Course import org.openedx.discovery.presentation.ui.DiscoveryCourseItem +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue class NativeDiscoveryFragment : Fragment() { diff --git a/discovery/src/main/java/org/openedx/discovery/presentation/NativeDiscoveryViewModel.kt b/discovery/src/main/java/org/openedx/discovery/presentation/NativeDiscoveryViewModel.kt index 19bfb21f9..923846e8a 100644 --- a/discovery/src/main/java/org/openedx/discovery/presentation/NativeDiscoveryViewModel.kt +++ b/discovery/src/main/java/org/openedx/discovery/presentation/NativeDiscoveryViewModel.kt @@ -6,19 +6,19 @@ import androidx.lifecycle.viewModelScope import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.R -import org.openedx.core.SingleEventLiveData -import org.openedx.core.UIMessage import org.openedx.core.config.Config import org.openedx.core.data.storage.CorePreferences -import org.openedx.core.extension.isInternetError -import org.openedx.core.system.ResourceManager import org.openedx.core.system.connection.NetworkConnection import org.openedx.core.system.notifier.app.AppNotifier import org.openedx.core.system.notifier.app.AppUpgradeEvent import org.openedx.discovery.domain.interactor.DiscoveryInteractor import org.openedx.discovery.domain.model.Course +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.SingleEventLiveData +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager class NativeDiscoveryViewModel( private val config: Config, diff --git a/discovery/src/main/java/org/openedx/discovery/presentation/WebViewDiscoveryFragment.kt b/discovery/src/main/java/org/openedx/discovery/presentation/WebViewDiscoveryFragment.kt index cf67d1a2c..72ce6126c 100644 --- a/discovery/src/main/java/org/openedx/discovery/presentation/WebViewDiscoveryFragment.kt +++ b/discovery/src/main/java/org/openedx/discovery/presentation/WebViewDiscoveryFragment.kt @@ -59,17 +59,17 @@ import org.openedx.core.presentation.global.webview.WebViewUIState import org.openedx.core.ui.AuthButtonsPanel import org.openedx.core.ui.FullScreenErrorView import org.openedx.core.ui.Toolbar -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors -import org.openedx.core.ui.windowSizeValue import org.openedx.discovery.R import org.openedx.discovery.presentation.catalog.CatalogWebViewScreen import org.openedx.discovery.presentation.catalog.WebViewLink +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.core.R as CoreR class WebViewDiscoveryFragment : Fragment() { diff --git a/discovery/src/main/java/org/openedx/discovery/presentation/WebViewDiscoveryViewModel.kt b/discovery/src/main/java/org/openedx/discovery/presentation/WebViewDiscoveryViewModel.kt index a8f8cfc45..2cb7afd69 100644 --- a/discovery/src/main/java/org/openedx/discovery/presentation/WebViewDiscoveryViewModel.kt +++ b/discovery/src/main/java/org/openedx/discovery/presentation/WebViewDiscoveryViewModel.kt @@ -4,13 +4,13 @@ import androidx.fragment.app.FragmentManager import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow -import org.openedx.core.BaseViewModel import org.openedx.core.config.Config import org.openedx.core.data.storage.CorePreferences import org.openedx.core.presentation.global.ErrorType import org.openedx.core.presentation.global.webview.WebViewUIState import org.openedx.core.system.connection.NetworkConnection -import org.openedx.core.utils.UrlUtils +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.utils.UrlUtils class WebViewDiscoveryViewModel( private val querySearch: String, diff --git a/discovery/src/main/java/org/openedx/discovery/presentation/catalog/CatalogWebView.kt b/discovery/src/main/java/org/openedx/discovery/presentation/catalog/CatalogWebView.kt index 785e77767..aaac503a3 100644 --- a/discovery/src/main/java/org/openedx/discovery/presentation/catalog/CatalogWebView.kt +++ b/discovery/src/main/java/org/openedx/discovery/presentation/catalog/CatalogWebView.kt @@ -8,7 +8,7 @@ import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.platform.LocalContext -import org.openedx.core.extension.applyDarkModeIfEnabled +import org.openedx.foundation.extension.applyDarkModeIfEnabled import org.openedx.core.extension.equalsHost import org.openedx.discovery.presentation.catalog.WebViewLink.Authority as linkAuthority diff --git a/discovery/src/main/java/org/openedx/discovery/presentation/catalog/DefaultWebViewClient.kt b/discovery/src/main/java/org/openedx/discovery/presentation/catalog/DefaultWebViewClient.kt index 9cf94ecda..a039cab2f 100644 --- a/discovery/src/main/java/org/openedx/discovery/presentation/catalog/DefaultWebViewClient.kt +++ b/discovery/src/main/java/org/openedx/discovery/presentation/catalog/DefaultWebViewClient.kt @@ -7,8 +7,8 @@ import android.webkit.WebResourceRequest import android.webkit.WebResourceResponse import android.webkit.WebView import android.webkit.WebViewClient -import org.openedx.core.extension.isEmailValid import org.openedx.core.utils.EmailUtil +import org.openedx.foundation.extension.isEmailValid open class DefaultWebViewClient( val context: Context, diff --git a/discovery/src/main/java/org/openedx/discovery/presentation/catalog/WebViewLink.kt b/discovery/src/main/java/org/openedx/discovery/presentation/catalog/WebViewLink.kt index a467707ce..a482fc581 100644 --- a/discovery/src/main/java/org/openedx/discovery/presentation/catalog/WebViewLink.kt +++ b/discovery/src/main/java/org/openedx/discovery/presentation/catalog/WebViewLink.kt @@ -1,7 +1,7 @@ package org.openedx.discovery.presentation.catalog import android.net.Uri -import org.openedx.core.extension.getQueryParams +import org.openedx.foundation.extension.getQueryParams /** * To parse and store links that we need within a WebView. diff --git a/discovery/src/main/java/org/openedx/discovery/presentation/detail/CourseDetailsFragment.kt b/discovery/src/main/java/org/openedx/discovery/presentation/detail/CourseDetailsFragment.kt index 32c795c56..4bf51b23b 100644 --- a/discovery/src/main/java/org/openedx/discovery/presentation/detail/CourseDetailsFragment.kt +++ b/discovery/src/main/java/org/openedx/discovery/presentation/detail/CourseDetailsFragment.kt @@ -79,31 +79,31 @@ import androidx.fragment.app.Fragment import org.koin.android.ext.android.inject import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf -import org.openedx.core.UIMessage import org.openedx.core.domain.model.Media -import org.openedx.core.extension.applyDarkModeIfEnabled -import org.openedx.core.extension.isEmailValid import org.openedx.core.ui.AuthButtonsPanel import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.OfflineModeDialog import org.openedx.core.ui.OpenEdXButton import org.openedx.core.ui.Toolbar -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape import org.openedx.core.ui.isPreview -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue import org.openedx.core.utils.EmailUtil import org.openedx.discovery.R import org.openedx.discovery.domain.model.Course import org.openedx.discovery.presentation.DiscoveryRouter import org.openedx.discovery.presentation.ui.ImageHeader import org.openedx.discovery.presentation.ui.WarningLabel +import org.openedx.foundation.extension.applyDarkModeIfEnabled +import org.openedx.foundation.extension.isEmailValid +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import java.nio.charset.StandardCharsets import java.util.Date import org.openedx.core.R as CoreR diff --git a/discovery/src/main/java/org/openedx/discovery/presentation/detail/CourseDetailsViewModel.kt b/discovery/src/main/java/org/openedx/discovery/presentation/detail/CourseDetailsViewModel.kt index 81b36e651..b512ea99e 100644 --- a/discovery/src/main/java/org/openedx/discovery/presentation/detail/CourseDetailsViewModel.kt +++ b/discovery/src/main/java/org/openedx/discovery/presentation/detail/CourseDetailsViewModel.kt @@ -4,14 +4,9 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.viewModelScope import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.R -import org.openedx.core.SingleEventLiveData -import org.openedx.core.UIMessage import org.openedx.core.config.Config import org.openedx.core.data.storage.CorePreferences -import org.openedx.core.extension.isInternetError -import org.openedx.core.system.ResourceManager import org.openedx.core.system.connection.NetworkConnection import org.openedx.core.system.notifier.CourseDashboardUpdate import org.openedx.core.system.notifier.DiscoveryNotifier @@ -21,6 +16,11 @@ import org.openedx.discovery.domain.model.Course import org.openedx.discovery.presentation.DiscoveryAnalytics import org.openedx.discovery.presentation.DiscoveryAnalyticsEvent import org.openedx.discovery.presentation.DiscoveryAnalyticsKey +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.SingleEventLiveData +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager class CourseDetailsViewModel( val courseId: String, diff --git a/discovery/src/main/java/org/openedx/discovery/presentation/info/CourseInfoFragment.kt b/discovery/src/main/java/org/openedx/discovery/presentation/info/CourseInfoFragment.kt index 4906e91f8..3c6cb6c31 100644 --- a/discovery/src/main/java/org/openedx/discovery/presentation/info/CourseInfoFragment.kt +++ b/discovery/src/main/java/org/openedx/discovery/presentation/info/CourseInfoFragment.kt @@ -42,7 +42,6 @@ import androidx.core.os.bundleOf import androidx.fragment.app.Fragment import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf -import org.openedx.core.UIMessage import org.openedx.core.presentation.dialog.alert.ActionDialogFragment import org.openedx.core.presentation.dialog.alert.InfoDialogFragment import org.openedx.core.presentation.global.webview.WebViewUIAction @@ -51,18 +50,19 @@ import org.openedx.core.ui.AuthButtonsPanel import org.openedx.core.ui.FullScreenErrorView import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.Toolbar -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors -import org.openedx.core.ui.windowSizeValue import org.openedx.discovery.R import org.openedx.discovery.presentation.DiscoveryAnalyticsScreen import org.openedx.discovery.presentation.catalog.CatalogWebViewScreen import org.openedx.discovery.presentation.catalog.WebViewLink +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import java.util.concurrent.atomic.AtomicReference import org.openedx.core.R as CoreR import org.openedx.discovery.presentation.catalog.WebViewLink.Authority as linkAuthority diff --git a/discovery/src/main/java/org/openedx/discovery/presentation/info/CourseInfoViewModel.kt b/discovery/src/main/java/org/openedx/discovery/presentation/info/CourseInfoViewModel.kt index 65907f5cf..d5a935df3 100644 --- a/discovery/src/main/java/org/openedx/discovery/presentation/info/CourseInfoViewModel.kt +++ b/discovery/src/main/java/org/openedx/discovery/presentation/info/CourseInfoViewModel.kt @@ -12,15 +12,11 @@ import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch import kotlinx.coroutines.withContext -import org.openedx.core.BaseViewModel -import org.openedx.core.UIMessage import org.openedx.core.config.Config import org.openedx.core.data.storage.CorePreferences -import org.openedx.core.extension.isInternetError import org.openedx.core.presentation.CoreAnalyticsKey import org.openedx.core.presentation.global.ErrorType import org.openedx.core.presentation.global.webview.WebViewUIState -import org.openedx.core.system.ResourceManager import org.openedx.core.system.connection.NetworkConnection import org.openedx.core.system.notifier.CourseDashboardUpdate import org.openedx.core.system.notifier.DiscoveryNotifier @@ -31,6 +27,10 @@ import org.openedx.discovery.presentation.DiscoveryAnalyticsEvent import org.openedx.discovery.presentation.DiscoveryAnalyticsKey import org.openedx.discovery.presentation.DiscoveryRouter import org.openedx.discovery.presentation.catalog.WebViewLink +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import java.util.concurrent.atomic.AtomicReference import org.openedx.core.R as CoreR diff --git a/discovery/src/main/java/org/openedx/discovery/presentation/program/ProgramFragment.kt b/discovery/src/main/java/org/openedx/discovery/presentation/program/ProgramFragment.kt index 85809a9fb..07e59dc11 100644 --- a/discovery/src/main/java/org/openedx/discovery/presentation/program/ProgramFragment.kt +++ b/discovery/src/main/java/org/openedx/discovery/presentation/program/ProgramFragment.kt @@ -46,8 +46,6 @@ import kotlinx.coroutines.launch import org.koin.androidx.compose.koinViewModel import org.koin.androidx.viewmodel.ext.android.viewModel import org.openedx.core.extension.loadUrl -import org.openedx.core.extension.takeIfNotEmpty -import org.openedx.core.extension.toastMessage import org.openedx.core.presentation.dialog.alert.ActionDialogFragment import org.openedx.core.presentation.dialog.alert.InfoDialogFragment import org.openedx.core.presentation.global.webview.WebViewUIAction @@ -55,18 +53,20 @@ import org.openedx.core.system.AppCookieManager import org.openedx.core.ui.FullScreenErrorView import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.Toolbar -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors -import org.openedx.core.ui.windowSizeValue import org.openedx.discovery.R import org.openedx.discovery.presentation.DiscoveryAnalyticsScreen import org.openedx.discovery.presentation.catalog.CatalogWebViewScreen import org.openedx.discovery.presentation.catalog.WebViewLink +import org.openedx.foundation.extension.takeIfNotEmpty +import org.openedx.foundation.extension.toastMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.core.R as coreR import org.openedx.discovery.presentation.catalog.WebViewLink.Authority as linkAuthority diff --git a/discovery/src/main/java/org/openedx/discovery/presentation/program/ProgramUIState.kt b/discovery/src/main/java/org/openedx/discovery/presentation/program/ProgramUIState.kt index bed418100..b4ad7341d 100644 --- a/discovery/src/main/java/org/openedx/discovery/presentation/program/ProgramUIState.kt +++ b/discovery/src/main/java/org/openedx/discovery/presentation/program/ProgramUIState.kt @@ -1,6 +1,6 @@ package org.openedx.discovery.presentation.program -import org.openedx.core.UIMessage +import org.openedx.foundation.presentation.UIMessage import org.openedx.core.presentation.global.ErrorType sealed class ProgramUIState { diff --git a/discovery/src/main/java/org/openedx/discovery/presentation/program/ProgramViewModel.kt b/discovery/src/main/java/org/openedx/discovery/presentation/program/ProgramViewModel.kt index 59a26cba5..2263861bf 100644 --- a/discovery/src/main/java/org/openedx/discovery/presentation/program/ProgramViewModel.kt +++ b/discovery/src/main/java/org/openedx/discovery/presentation/program/ProgramViewModel.kt @@ -6,20 +6,20 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.config.Config -import org.openedx.core.extension.isInternetError import org.openedx.core.presentation.global.ErrorType import org.openedx.core.system.AppCookieManager -import org.openedx.core.system.ResourceManager import org.openedx.core.system.connection.NetworkConnection import org.openedx.core.system.notifier.CourseDashboardUpdate import org.openedx.core.system.notifier.DiscoveryNotifier import org.openedx.core.system.notifier.NavigationToDiscovery import org.openedx.discovery.domain.interactor.DiscoveryInteractor import org.openedx.discovery.presentation.DiscoveryRouter +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager class ProgramViewModel( private val config: Config, diff --git a/discovery/src/main/java/org/openedx/discovery/presentation/search/CourseSearchFragment.kt b/discovery/src/main/java/org/openedx/discovery/presentation/search/CourseSearchFragment.kt index 72a5aa909..fc2af30a6 100644 --- a/discovery/src/main/java/org/openedx/discovery/presentation/search/CourseSearchFragment.kt +++ b/discovery/src/main/java/org/openedx/discovery/presentation/search/CourseSearchFragment.kt @@ -63,24 +63,24 @@ import androidx.core.os.bundleOf import androidx.fragment.app.Fragment import org.koin.android.ext.android.inject import org.koin.androidx.viewmodel.ext.android.viewModel -import org.openedx.core.UIMessage import org.openedx.core.domain.model.Media import org.openedx.core.ui.AuthButtonsPanel import org.openedx.core.ui.BackBtn import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.SearchBar -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.shouldLoadMore import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue import org.openedx.discovery.domain.model.Course import org.openedx.discovery.presentation.DiscoveryRouter import org.openedx.discovery.presentation.ui.DiscoveryCourseItem +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.discovery.R as discoveryR class CourseSearchFragment : Fragment() { diff --git a/discovery/src/main/java/org/openedx/discovery/presentation/search/CourseSearchViewModel.kt b/discovery/src/main/java/org/openedx/discovery/presentation/search/CourseSearchViewModel.kt index 8acbe0e1c..d1ae276d8 100644 --- a/discovery/src/main/java/org/openedx/discovery/presentation/search/CourseSearchViewModel.kt +++ b/discovery/src/main/java/org/openedx/discovery/presentation/search/CourseSearchViewModel.kt @@ -8,17 +8,17 @@ import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.R -import org.openedx.core.SingleEventLiveData -import org.openedx.core.UIMessage import org.openedx.core.config.Config import org.openedx.core.data.storage.CorePreferences -import org.openedx.core.extension.isInternetError -import org.openedx.core.system.ResourceManager import org.openedx.discovery.domain.interactor.DiscoveryInteractor import org.openedx.discovery.domain.model.Course import org.openedx.discovery.presentation.DiscoveryAnalytics +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.SingleEventLiveData +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager class CourseSearchViewModel( private val config: Config, diff --git a/discovery/src/main/java/org/openedx/discovery/presentation/ui/DiscoveryUI.kt b/discovery/src/main/java/org/openedx/discovery/presentation/ui/DiscoveryUI.kt index 4ce446e31..5413543c9 100644 --- a/discovery/src/main/java/org/openedx/discovery/presentation/ui/DiscoveryUI.kt +++ b/discovery/src/main/java/org/openedx/discovery/presentation/ui/DiscoveryUI.kt @@ -39,20 +39,18 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import coil.compose.AsyncImage import coil.request.ImageRequest -import org.openedx.core.extension.isLinkValid -import org.openedx.core.extension.toImageLink -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue import org.openedx.discovery.R import org.openedx.discovery.domain.model.Course +import org.openedx.foundation.extension.toImageLink +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.core.R as CoreR - @Composable fun ImageHeader( modifier: Modifier, diff --git a/discovery/src/test/java/org/openedx/discovery/presentation/NativeDiscoveryViewModelTest.kt b/discovery/src/test/java/org/openedx/discovery/presentation/NativeDiscoveryViewModelTest.kt index 7360ef131..83550dc42 100644 --- a/discovery/src/test/java/org/openedx/discovery/presentation/NativeDiscoveryViewModelTest.kt +++ b/discovery/src/test/java/org/openedx/discovery/presentation/NativeDiscoveryViewModelTest.kt @@ -21,15 +21,15 @@ import org.junit.Rule import org.junit.Test import org.junit.rules.TestRule import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.config.Config import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.model.Pagination -import org.openedx.core.system.ResourceManager import org.openedx.core.system.connection.NetworkConnection import org.openedx.core.system.notifier.app.AppNotifier import org.openedx.discovery.domain.interactor.DiscoveryInteractor import org.openedx.discovery.domain.model.CourseList +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import java.net.UnknownHostException @OptIn(ExperimentalCoroutinesApi::class) diff --git a/discovery/src/test/java/org/openedx/discovery/presentation/detail/CourseDetailsViewModelTest.kt b/discovery/src/test/java/org/openedx/discovery/presentation/detail/CourseDetailsViewModelTest.kt index e62cd0b38..3e0f4906f 100644 --- a/discovery/src/test/java/org/openedx/discovery/presentation/detail/CourseDetailsViewModelTest.kt +++ b/discovery/src/test/java/org/openedx/discovery/presentation/detail/CourseDetailsViewModelTest.kt @@ -22,11 +22,9 @@ import org.junit.Rule import org.junit.Test import org.junit.rules.TestRule import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.config.Config import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.model.Media -import org.openedx.core.system.ResourceManager import org.openedx.core.system.connection.NetworkConnection import org.openedx.core.system.notifier.CourseDashboardUpdate import org.openedx.core.system.notifier.DiscoveryNotifier @@ -35,6 +33,8 @@ import org.openedx.discovery.domain.interactor.DiscoveryInteractor import org.openedx.discovery.domain.model.Course import org.openedx.discovery.presentation.DiscoveryAnalytics import org.openedx.discovery.presentation.DiscoveryAnalyticsEvent +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import java.net.UnknownHostException @OptIn(ExperimentalCoroutinesApi::class) diff --git a/discovery/src/test/java/org/openedx/discovery/presentation/search/CourseSearchViewModelTest.kt b/discovery/src/test/java/org/openedx/discovery/presentation/search/CourseSearchViewModelTest.kt index 40e44e73c..8b5a1bab4 100644 --- a/discovery/src/test/java/org/openedx/discovery/presentation/search/CourseSearchViewModelTest.kt +++ b/discovery/src/test/java/org/openedx/discovery/presentation/search/CourseSearchViewModelTest.kt @@ -20,16 +20,16 @@ import org.junit.Rule import org.junit.Test import org.junit.rules.TestRule import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.config.Config import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.model.Media import org.openedx.core.domain.model.Pagination -import org.openedx.core.system.ResourceManager import org.openedx.discovery.domain.interactor.DiscoveryInteractor import org.openedx.discovery.domain.model.Course import org.openedx.discovery.domain.model.CourseList import org.openedx.discovery.presentation.DiscoveryAnalytics +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import java.net.UnknownHostException @OptIn(ExperimentalCoroutinesApi::class) diff --git a/discussion/build.gradle b/discussion/build.gradle index 70ed3c39f..5442a57b2 100644 --- a/discussion/build.gradle +++ b/discussion/build.gradle @@ -2,6 +2,7 @@ plugins { id 'com.android.library' id 'org.jetbrains.kotlin.android' id 'kotlin-parcelize' + id "org.jetbrains.kotlin.plugin.compose" } android { @@ -35,9 +36,6 @@ android { viewBinding true compose true } - composeOptions { - kotlinCompilerExtensionVersion = "$compose_compiler_version" - } flavorDimensions += "env" productFlavors { @@ -56,11 +54,10 @@ android { dependencies { implementation project(path: ':core') - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + androidTestImplementation 'androidx.test.ext:junit:1.2.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' testImplementation "junit:junit:$junit_version" testImplementation "io.mockk:mockk:$mockk_version" testImplementation "io.mockk:mockk-android:$mockk_version" - testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version" testImplementation "androidx.arch.core:core-testing:$android_arch_version" } \ No newline at end of file diff --git a/discussion/src/main/java/org/openedx/discussion/data/repository/DiscussionRepository.kt b/discussion/src/main/java/org/openedx/discussion/data/repository/DiscussionRepository.kt index 95c603cf5..ac07087cd 100644 --- a/discussion/src/main/java/org/openedx/discussion/data/repository/DiscussionRepository.kt +++ b/discussion/src/main/java/org/openedx/discussion/data/repository/DiscussionRepository.kt @@ -2,7 +2,6 @@ package org.openedx.discussion.data.repository import org.openedx.core.data.model.BlocksCompletionBody import org.openedx.core.data.storage.CorePreferences -import org.openedx.core.system.ResourceManager import org.openedx.discussion.R import org.openedx.discussion.data.api.DiscussionApi import org.openedx.discussion.data.model.request.CommentBody @@ -15,6 +14,7 @@ import org.openedx.discussion.domain.model.CommentsData import org.openedx.discussion.domain.model.DiscussionComment import org.openedx.discussion.domain.model.ThreadsData import org.openedx.discussion.domain.model.Topic +import org.openedx.foundation.system.ResourceManager class DiscussionRepository( private val api: DiscussionApi, diff --git a/discussion/src/main/java/org/openedx/discussion/presentation/comments/DiscussionCommentsFragment.kt b/discussion/src/main/java/org/openedx/discussion/presentation/comments/DiscussionCommentsFragment.kt index 02f950bb6..2c7f03bd0 100644 --- a/discussion/src/main/java/org/openedx/discussion/presentation/comments/DiscussionCommentsFragment.kt +++ b/discussion/src/main/java/org/openedx/discussion/presentation/comments/DiscussionCommentsFragment.kt @@ -9,18 +9,45 @@ import android.view.ViewGroup import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.isSystemInDarkTheme -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.heightIn +import androidx.compose.foundation.layout.navigationBarsPadding +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.* +import androidx.compose.material.CircularProgressIndicator +import androidx.compose.material.Divider +import androidx.compose.material.ExperimentalMaterialApi +import androidx.compose.material.Icon +import androidx.compose.material.MaterialTheme +import androidx.compose.material.OutlinedTextField +import androidx.compose.material.Scaffold +import androidx.compose.material.Surface +import androidx.compose.material.Text +import androidx.compose.material.TextFieldDefaults import androidx.compose.material.pullrefresh.PullRefreshIndicator import androidx.compose.material.pullrefresh.pullRefresh import androidx.compose.material.pullrefresh.rememberPullRefreshState -import androidx.compose.runtime.* +import androidx.compose.material.rememberScaffoldState +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue import androidx.compose.runtime.livedata.observeAsState +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier @@ -41,24 +68,32 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.core.os.bundleOf import androidx.fragment.app.Fragment -import org.openedx.core.UIMessage +import org.koin.android.ext.android.inject +import org.koin.androidx.viewmodel.ext.android.viewModel +import org.koin.core.parameter.parametersOf import org.openedx.core.domain.model.ProfileImage import org.openedx.core.extension.TextConverter -import org.openedx.core.extension.parcelable -import org.openedx.core.ui.* +import org.openedx.core.ui.BackBtn +import org.openedx.core.ui.HandleUIMessage +import org.openedx.core.ui.displayCutoutForLandscape +import org.openedx.core.ui.shouldLoadMore +import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography +import org.openedx.discussion.R import org.openedx.discussion.domain.model.DiscussionComment import org.openedx.discussion.domain.model.DiscussionType import org.openedx.discussion.presentation.DiscussionRouter import org.openedx.discussion.presentation.ui.CommentItem import org.openedx.discussion.presentation.ui.ThreadMainItem -import org.koin.android.ext.android.inject -import org.koin.androidx.viewmodel.ext.android.viewModel -import org.koin.core.parameter.parametersOf -import org.openedx.discussion.R +import org.openedx.foundation.extension.parcelable +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue class DiscussionCommentsFragment : Fragment() { diff --git a/discussion/src/main/java/org/openedx/discussion/presentation/comments/DiscussionCommentsViewModel.kt b/discussion/src/main/java/org/openedx/discussion/presentation/comments/DiscussionCommentsViewModel.kt index bcf54a92e..33e858b6b 100644 --- a/discussion/src/main/java/org/openedx/discussion/presentation/comments/DiscussionCommentsViewModel.kt +++ b/discussion/src/main/java/org/openedx/discussion/presentation/comments/DiscussionCommentsViewModel.kt @@ -4,12 +4,8 @@ import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.viewModelScope -import org.openedx.core.BaseViewModel +import kotlinx.coroutines.launch import org.openedx.core.R -import org.openedx.core.SingleEventLiveData -import org.openedx.core.UIMessage -import org.openedx.core.extension.isInternetError -import org.openedx.core.system.ResourceManager import org.openedx.discussion.domain.interactor.DiscussionInteractor import org.openedx.discussion.domain.model.DiscussionComment import org.openedx.discussion.domain.model.DiscussionType @@ -17,7 +13,11 @@ import org.openedx.discussion.system.notifier.DiscussionCommentAdded import org.openedx.discussion.system.notifier.DiscussionCommentDataChanged import org.openedx.discussion.system.notifier.DiscussionNotifier import org.openedx.discussion.system.notifier.DiscussionThreadDataChanged -import kotlinx.coroutines.launch +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.SingleEventLiveData +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager class DiscussionCommentsViewModel( private val interactor: DiscussionInteractor, diff --git a/discussion/src/main/java/org/openedx/discussion/presentation/responses/DiscussionResponsesFragment.kt b/discussion/src/main/java/org/openedx/discussion/presentation/responses/DiscussionResponsesFragment.kt index b3d5a0d82..ebf0fb1b9 100644 --- a/discussion/src/main/java/org/openedx/discussion/presentation/responses/DiscussionResponsesFragment.kt +++ b/discussion/src/main/java/org/openedx/discussion/presentation/responses/DiscussionResponsesFragment.kt @@ -9,18 +9,48 @@ import android.view.ViewGroup import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.isSystemInDarkTheme -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.IntrinsicSize +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxHeight +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.heightIn +import androidx.compose.foundation.layout.navigationBarsPadding +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.* +import androidx.compose.material.CircularProgressIndicator +import androidx.compose.material.Divider +import androidx.compose.material.ExperimentalMaterialApi +import androidx.compose.material.Icon +import androidx.compose.material.MaterialTheme +import androidx.compose.material.OutlinedTextField +import androidx.compose.material.Scaffold +import androidx.compose.material.Surface +import androidx.compose.material.Text +import androidx.compose.material.TextFieldDefaults import androidx.compose.material.pullrefresh.PullRefreshIndicator import androidx.compose.material.pullrefresh.pullRefresh import androidx.compose.material.pullrefresh.rememberPullRefreshState -import androidx.compose.runtime.* +import androidx.compose.material.rememberScaffoldState +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue import androidx.compose.runtime.livedata.observeAsState +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier @@ -41,22 +71,30 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.core.os.bundleOf import androidx.fragment.app.Fragment +import org.koin.android.ext.android.inject import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf -import org.koin.android.ext.android.inject -import org.openedx.core.UIMessage import org.openedx.core.domain.model.ProfileImage import org.openedx.core.extension.TextConverter -import org.openedx.core.extension.parcelable -import org.openedx.core.ui.* +import org.openedx.core.ui.BackBtn +import org.openedx.core.ui.HandleUIMessage +import org.openedx.core.ui.displayCutoutForLandscape +import org.openedx.core.ui.shouldLoadMore +import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography import org.openedx.discussion.domain.model.DiscussionComment +import org.openedx.discussion.presentation.DiscussionRouter import org.openedx.discussion.presentation.comments.DiscussionCommentsFragment import org.openedx.discussion.presentation.ui.CommentMainItem -import org.openedx.discussion.presentation.DiscussionRouter +import org.openedx.foundation.extension.parcelable +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.discussion.R as discussionR class DiscussionResponsesFragment : Fragment() { diff --git a/discussion/src/main/java/org/openedx/discussion/presentation/responses/DiscussionResponsesViewModel.kt b/discussion/src/main/java/org/openedx/discussion/presentation/responses/DiscussionResponsesViewModel.kt index 3f9b75e60..ed8390c44 100644 --- a/discussion/src/main/java/org/openedx/discussion/presentation/responses/DiscussionResponsesViewModel.kt +++ b/discussion/src/main/java/org/openedx/discussion/presentation/responses/DiscussionResponsesViewModel.kt @@ -3,17 +3,17 @@ package org.openedx.discussion.presentation.responses import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.viewModelScope -import org.openedx.core.BaseViewModel +import kotlinx.coroutines.launch import org.openedx.core.R -import org.openedx.core.SingleEventLiveData -import org.openedx.core.UIMessage -import org.openedx.core.extension.isInternetError -import org.openedx.core.system.ResourceManager import org.openedx.discussion.domain.interactor.DiscussionInteractor import org.openedx.discussion.domain.model.DiscussionComment import org.openedx.discussion.system.notifier.DiscussionCommentDataChanged import org.openedx.discussion.system.notifier.DiscussionNotifier -import kotlinx.coroutines.launch +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.SingleEventLiveData +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager class DiscussionResponsesViewModel( private val interactor: DiscussionInteractor, diff --git a/discussion/src/main/java/org/openedx/discussion/presentation/search/DiscussionSearchThreadFragment.kt b/discussion/src/main/java/org/openedx/discussion/presentation/search/DiscussionSearchThreadFragment.kt index 05fceeffc..76c645e37 100644 --- a/discussion/src/main/java/org/openedx/discussion/presentation/search/DiscussionSearchThreadFragment.kt +++ b/discussion/src/main/java/org/openedx/discussion/presentation/search/DiscussionSearchThreadFragment.kt @@ -4,19 +4,41 @@ import android.content.res.Configuration import android.os.Bundle import android.view.LayoutInflater import android.view.ViewGroup -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.navigationBarsPadding +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.material.* +import androidx.compose.material.CircularProgressIndicator +import androidx.compose.material.Divider +import androidx.compose.material.ExperimentalMaterialApi +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Scaffold +import androidx.compose.material.Surface +import androidx.compose.material.Text import androidx.compose.material.pullrefresh.PullRefreshIndicator import androidx.compose.material.pullrefresh.pullRefresh import androidx.compose.material.pullrefresh.rememberPullRefreshState -import androidx.compose.runtime.* +import androidx.compose.material.rememberScaffoldState +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue import androidx.compose.runtime.livedata.observeAsState +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment -import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.LocalFocusManager @@ -34,20 +56,27 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.zIndex import androidx.core.os.bundleOf import androidx.fragment.app.Fragment +import org.koin.android.ext.android.inject +import org.koin.androidx.viewmodel.ext.android.viewModel +import org.koin.core.parameter.parametersOf import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.extension.TextConverter -import org.openedx.core.ui.* +import org.openedx.core.ui.BackBtn +import org.openedx.core.ui.HandleUIMessage +import org.openedx.core.ui.SearchBar +import org.openedx.core.ui.shouldLoadMore +import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appTypography import org.openedx.discussion.domain.model.DiscussionType import org.openedx.discussion.presentation.DiscussionRouter import org.openedx.discussion.presentation.ui.ThreadItem -import org.koin.android.ext.android.inject -import org.koin.androidx.viewmodel.ext.android.viewModel -import org.koin.core.parameter.parametersOf - +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.discussion.R as discussionR class DiscussionSearchThreadFragment : Fragment() { @@ -121,7 +150,7 @@ class DiscussionSearchThreadFragment : Fragment() { } -@OptIn(ExperimentalMaterialApi::class, ExperimentalComposeUiApi::class) +@OptIn(ExperimentalMaterialApi::class) @Composable private fun DiscussionSearchThreadScreen( windowSize: WindowSize, diff --git a/discussion/src/main/java/org/openedx/discussion/presentation/search/DiscussionSearchThreadViewModel.kt b/discussion/src/main/java/org/openedx/discussion/presentation/search/DiscussionSearchThreadViewModel.kt index a0c5c5c62..c101ae7b9 100644 --- a/discussion/src/main/java/org/openedx/discussion/presentation/search/DiscussionSearchThreadViewModel.kt +++ b/discussion/src/main/java/org/openedx/discussion/presentation/search/DiscussionSearchThreadViewModel.kt @@ -15,15 +15,15 @@ import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.R -import org.openedx.core.SingleEventLiveData -import org.openedx.core.UIMessage -import org.openedx.core.extension.isInternetError -import org.openedx.core.system.ResourceManager import org.openedx.discussion.domain.interactor.DiscussionInteractor import org.openedx.discussion.system.notifier.DiscussionNotifier import org.openedx.discussion.system.notifier.DiscussionThreadDataChanged +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.SingleEventLiveData +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager class DiscussionSearchThreadViewModel( private val interactor: DiscussionInteractor, diff --git a/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionAddThreadFragment.kt b/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionAddThreadFragment.kt index a211e10b3..82ad75a17 100644 --- a/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionAddThreadFragment.kt +++ b/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionAddThreadFragment.kt @@ -73,25 +73,25 @@ import androidx.fragment.app.Fragment import kotlinx.coroutines.launch import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf -import org.openedx.core.UIMessage import org.openedx.core.ui.BackBtn import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.OpenEdXButton import org.openedx.core.ui.OpenEdXOutlinedTextField import org.openedx.core.ui.SheetContent -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape import org.openedx.core.ui.isImeVisibleState import org.openedx.core.ui.noRippleClickable -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue import org.openedx.discussion.domain.model.DiscussionType +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.discussion.R as discussionR class DiscussionAddThreadFragment : Fragment() { diff --git a/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionAddThreadViewModel.kt b/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionAddThreadViewModel.kt index 278f6b4f0..3ff75bd9b 100644 --- a/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionAddThreadViewModel.kt +++ b/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionAddThreadViewModel.kt @@ -3,16 +3,16 @@ package org.openedx.discussion.presentation.threads import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.viewModelScope -import org.openedx.core.BaseViewModel +import kotlinx.coroutines.launch import org.openedx.core.R -import org.openedx.core.SingleEventLiveData -import org.openedx.core.UIMessage -import org.openedx.core.extension.isInternetError -import org.openedx.core.system.ResourceManager import org.openedx.discussion.domain.interactor.DiscussionInteractor import org.openedx.discussion.system.notifier.DiscussionNotifier import org.openedx.discussion.system.notifier.DiscussionThreadAdded -import kotlinx.coroutines.launch +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.SingleEventLiveData +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager class DiscussionAddThreadViewModel( private val interactor: DiscussionInteractor, diff --git a/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionThreadsFragment.kt b/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionThreadsFragment.kt index 34a08ebb2..35884fec0 100644 --- a/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionThreadsFragment.kt +++ b/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionThreadsFragment.kt @@ -6,20 +6,50 @@ import android.view.LayoutInflater import android.view.ViewGroup import androidx.compose.foundation.background import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.* +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.navigationBarsPadding +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width +import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.verticalScroll -import androidx.compose.material.* +import androidx.compose.material.CircularProgressIndicator +import androidx.compose.material.Divider +import androidx.compose.material.ExperimentalMaterialApi +import androidx.compose.material.Icon +import androidx.compose.material.MaterialTheme +import androidx.compose.material.ModalBottomSheetLayout +import androidx.compose.material.ModalBottomSheetValue +import androidx.compose.material.Scaffold +import androidx.compose.material.Surface +import androidx.compose.material.Text import androidx.compose.material.pullrefresh.PullRefreshIndicator import androidx.compose.material.pullrefresh.pullRefresh import androidx.compose.material.pullrefresh.rememberPullRefreshState -import androidx.compose.runtime.* +import androidx.compose.material.rememberModalBottomSheetState +import androidx.compose.material.rememberScaffoldState +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue import androidx.compose.runtime.livedata.observeAsState +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip @@ -44,13 +74,29 @@ import org.koin.android.ext.android.inject import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf import org.openedx.core.FragmentViewType -import org.openedx.core.UIMessage import org.openedx.core.extension.TextConverter -import org.openedx.core.ui.* -import org.openedx.core.ui.theme.* +import org.openedx.core.ui.BackBtn +import org.openedx.core.ui.HandleUIMessage +import org.openedx.core.ui.IconText +import org.openedx.core.ui.OpenEdXOutlinedButton +import org.openedx.core.ui.SheetContent +import org.openedx.core.ui.displayCutoutForLandscape +import org.openedx.core.ui.isImeVisibleState +import org.openedx.core.ui.noRippleClickable +import org.openedx.core.ui.shouldLoadMore +import org.openedx.core.ui.statusBarsInset +import org.openedx.core.ui.theme.OpenEdXTheme +import org.openedx.core.ui.theme.appColors +import org.openedx.core.ui.theme.appShapes +import org.openedx.core.ui.theme.appTypography import org.openedx.discussion.domain.model.DiscussionType import org.openedx.discussion.presentation.DiscussionRouter import org.openedx.discussion.presentation.ui.ThreadItem +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.discussion.R as discussionR class DiscussionThreadsFragment : Fragment() { diff --git a/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionThreadsViewModel.kt b/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionThreadsViewModel.kt index 2dbbd9af6..944152606 100644 --- a/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionThreadsViewModel.kt +++ b/discussion/src/main/java/org/openedx/discussion/presentation/threads/DiscussionThreadsViewModel.kt @@ -5,17 +5,17 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.viewModelScope import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.R -import org.openedx.core.SingleEventLiveData -import org.openedx.core.UIMessage -import org.openedx.core.extension.isInternetError -import org.openedx.core.system.ResourceManager import org.openedx.discussion.domain.interactor.DiscussionInteractor import org.openedx.discussion.presentation.topics.DiscussionTopicsViewModel import org.openedx.discussion.system.notifier.DiscussionNotifier import org.openedx.discussion.system.notifier.DiscussionThreadAdded import org.openedx.discussion.system.notifier.DiscussionThreadDataChanged +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.SingleEventLiveData +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager class DiscussionThreadsViewModel( private val interactor: DiscussionInteractor, diff --git a/discussion/src/main/java/org/openedx/discussion/presentation/topics/DiscussionTopicsScreen.kt b/discussion/src/main/java/org/openedx/discussion/presentation/topics/DiscussionTopicsScreen.kt index 990e14260..75bbe2eaa 100644 --- a/discussion/src/main/java/org/openedx/discussion/presentation/topics/DiscussionTopicsScreen.kt +++ b/discussion/src/main/java/org/openedx/discussion/presentation/topics/DiscussionTopicsScreen.kt @@ -39,23 +39,23 @@ import androidx.compose.ui.unit.dp import androidx.fragment.app.FragmentManager import org.openedx.core.FragmentViewType import org.openedx.core.NoContentScreenType -import org.openedx.core.UIMessage import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.NoContentScreen import org.openedx.core.ui.StaticSearchBar -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue import org.openedx.discussion.R import org.openedx.discussion.domain.model.Topic import org.openedx.discussion.presentation.ui.ThreadItemCategory import org.openedx.discussion.presentation.ui.TopicItem +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.windowSizeValue @Composable fun DiscussionTopicsScreen( diff --git a/discussion/src/main/java/org/openedx/discussion/presentation/topics/DiscussionTopicsViewModel.kt b/discussion/src/main/java/org/openedx/discussion/presentation/topics/DiscussionTopicsViewModel.kt index 516ee50f8..16572da7c 100644 --- a/discussion/src/main/java/org/openedx/discussion/presentation/topics/DiscussionTopicsViewModel.kt +++ b/discussion/src/main/java/org/openedx/discussion/presentation/topics/DiscussionTopicsViewModel.kt @@ -7,17 +7,17 @@ import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.R -import org.openedx.core.UIMessage -import org.openedx.core.extension.isInternetError -import org.openedx.core.system.ResourceManager import org.openedx.core.system.notifier.CourseLoading import org.openedx.core.system.notifier.CourseNotifier import org.openedx.core.system.notifier.RefreshDiscussions import org.openedx.discussion.domain.interactor.DiscussionInteractor import org.openedx.discussion.presentation.DiscussionAnalytics import org.openedx.discussion.presentation.DiscussionRouter +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager class DiscussionTopicsViewModel( val courseId: String, diff --git a/discussion/src/test/java/org/openedx/discussion/presentation/comments/DiscussionCommentsViewModelTest.kt b/discussion/src/test/java/org/openedx/discussion/presentation/comments/DiscussionCommentsViewModelTest.kt index 8e55f7cd2..933a3bd5b 100644 --- a/discussion/src/test/java/org/openedx/discussion/presentation/comments/DiscussionCommentsViewModelTest.kt +++ b/discussion/src/test/java/org/openedx/discussion/presentation/comments/DiscussionCommentsViewModelTest.kt @@ -4,25 +4,40 @@ import androidx.arch.core.executor.testing.InstantTaskExecutorRule import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleRegistry +import io.mockk.clearAllMocks +import io.mockk.coEvery +import io.mockk.coVerify +import io.mockk.every +import io.mockk.mockk +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.test.UnconfinedTestDispatcher +import kotlinx.coroutines.test.advanceUntilIdle +import kotlinx.coroutines.test.resetMain +import kotlinx.coroutines.test.runTest +import kotlinx.coroutines.test.setMain +import org.junit.After +import org.junit.Assert +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TestRule import org.openedx.core.R -import org.openedx.core.UIMessage +import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.model.Pagination import org.openedx.core.extension.TextConverter -import org.openedx.core.system.ResourceManager import org.openedx.discussion.domain.interactor.DiscussionInteractor import org.openedx.discussion.domain.model.CommentsData import org.openedx.discussion.domain.model.DiscussionComment import org.openedx.discussion.domain.model.DiscussionType -import org.openedx.discussion.system.notifier.* -import io.mockk.* -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.delay -import kotlinx.coroutines.flow.flow -import kotlinx.coroutines.test.* -import org.junit.* -import org.junit.rules.TestRule -import org.openedx.core.data.storage.CorePreferences +import org.openedx.discussion.system.notifier.DiscussionCommentAdded +import org.openedx.discussion.system.notifier.DiscussionCommentDataChanged +import org.openedx.discussion.system.notifier.DiscussionNotifier +import org.openedx.discussion.system.notifier.DiscussionThreadDataChanged +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import java.net.UnknownHostException @OptIn(ExperimentalCoroutinesApi::class) diff --git a/discussion/src/test/java/org/openedx/discussion/presentation/responses/DiscussionResponsesViewModelTest.kt b/discussion/src/test/java/org/openedx/discussion/presentation/responses/DiscussionResponsesViewModelTest.kt index 61fa44df7..e3e0aa8ca 100644 --- a/discussion/src/test/java/org/openedx/discussion/presentation/responses/DiscussionResponsesViewModelTest.kt +++ b/discussion/src/test/java/org/openedx/discussion/presentation/responses/DiscussionResponsesViewModelTest.kt @@ -1,24 +1,35 @@ package org.openedx.discussion.presentation.responses import androidx.arch.core.executor.testing.InstantTaskExecutorRule +import io.mockk.clearAllMocks +import io.mockk.coEvery +import io.mockk.coVerify +import io.mockk.every +import io.mockk.mockk +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.UnconfinedTestDispatcher +import kotlinx.coroutines.test.advanceUntilIdle +import kotlinx.coroutines.test.resetMain +import kotlinx.coroutines.test.runTest +import kotlinx.coroutines.test.setMain +import org.junit.After +import org.junit.Assert +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TestRule import org.openedx.core.R -import org.openedx.core.UIMessage +import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.model.Pagination import org.openedx.core.extension.LinkedImageText -import org.openedx.core.system.ResourceManager import org.openedx.discussion.domain.interactor.DiscussionInteractor import org.openedx.discussion.domain.model.CommentsData import org.openedx.discussion.domain.model.DiscussionComment import org.openedx.discussion.domain.model.DiscussionType import org.openedx.discussion.system.notifier.DiscussionNotifier -import io.mockk.* -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.* -import org.junit.* -import org.junit.Assert.* -import org.junit.rules.TestRule -import org.openedx.core.data.storage.CorePreferences +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import java.net.UnknownHostException @OptIn(ExperimentalCoroutinesApi::class) diff --git a/discussion/src/test/java/org/openedx/discussion/presentation/search/DiscussionSearchThreadViewModelTest.kt b/discussion/src/test/java/org/openedx/discussion/presentation/search/DiscussionSearchThreadViewModelTest.kt index 57d35df20..8cf079a35 100644 --- a/discussion/src/test/java/org/openedx/discussion/presentation/search/DiscussionSearchThreadViewModelTest.kt +++ b/discussion/src/test/java/org/openedx/discussion/presentation/search/DiscussionSearchThreadViewModelTest.kt @@ -4,16 +4,6 @@ import androidx.arch.core.executor.testing.InstantTaskExecutorRule import androidx.lifecycle.Lifecycle import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.LifecycleRegistry -import org.openedx.core.R -import org.openedx.core.UIMessage -import org.openedx.core.domain.model.Pagination -import org.openedx.core.extension.TextConverter -import org.openedx.core.system.ResourceManager -import org.openedx.discussion.domain.interactor.DiscussionInteractor -import org.openedx.discussion.domain.model.DiscussionType -import org.openedx.discussion.domain.model.ThreadsData -import org.openedx.discussion.system.notifier.DiscussionNotifier -import org.openedx.discussion.system.notifier.DiscussionThreadDataChanged import io.mockk.coEvery import io.mockk.coVerify import io.mockk.every @@ -22,13 +12,26 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.delay import kotlinx.coroutines.flow.flow -import kotlinx.coroutines.test.* +import kotlinx.coroutines.test.UnconfinedTestDispatcher +import kotlinx.coroutines.test.advanceUntilIdle +import kotlinx.coroutines.test.resetMain +import kotlinx.coroutines.test.runTest +import kotlinx.coroutines.test.setMain import org.junit.After -import org.junit.Assert.* import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.rules.TestRule +import org.openedx.core.R +import org.openedx.core.domain.model.Pagination +import org.openedx.core.extension.TextConverter +import org.openedx.discussion.domain.interactor.DiscussionInteractor +import org.openedx.discussion.domain.model.DiscussionType +import org.openedx.discussion.domain.model.ThreadsData +import org.openedx.discussion.system.notifier.DiscussionNotifier +import org.openedx.discussion.system.notifier.DiscussionThreadDataChanged +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import java.net.UnknownHostException @OptIn(ExperimentalCoroutinesApi::class) diff --git a/discussion/src/test/java/org/openedx/discussion/presentation/threads/DiscussionAddThreadViewModelTest.kt b/discussion/src/test/java/org/openedx/discussion/presentation/threads/DiscussionAddThreadViewModelTest.kt index 6944e33c4..27c74ae00 100644 --- a/discussion/src/test/java/org/openedx/discussion/presentation/threads/DiscussionAddThreadViewModelTest.kt +++ b/discussion/src/test/java/org/openedx/discussion/presentation/threads/DiscussionAddThreadViewModelTest.kt @@ -1,11 +1,27 @@ package org.openedx.discussion.presentation.threads import androidx.arch.core.executor.testing.InstantTaskExecutorRule +import io.mockk.clearAllMocks +import io.mockk.coEvery +import io.mockk.coVerify +import io.mockk.every +import io.mockk.mockk +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.UnconfinedTestDispatcher +import kotlinx.coroutines.test.advanceUntilIdle +import kotlinx.coroutines.test.resetMain +import kotlinx.coroutines.test.runTest +import kotlinx.coroutines.test.setMain +import org.junit.After +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TestRule import org.openedx.core.R -import org.openedx.core.UIMessage +import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.model.ProfileImage import org.openedx.core.extension.TextConverter -import org.openedx.core.system.ResourceManager import org.openedx.discussion.domain.interactor.DiscussionInteractor import org.openedx.discussion.domain.model.DiscussionComment import org.openedx.discussion.domain.model.DiscussionProfile @@ -13,16 +29,8 @@ import org.openedx.discussion.domain.model.DiscussionType import org.openedx.discussion.domain.model.Topic import org.openedx.discussion.system.notifier.DiscussionNotifier import org.openedx.discussion.system.notifier.DiscussionThreadAdded -import io.mockk.* -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.* -import org.junit.After -import org.junit.Before -import org.junit.Rule -import org.junit.Test -import org.junit.rules.TestRule -import org.openedx.core.data.storage.CorePreferences +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import java.net.UnknownHostException @OptIn(ExperimentalCoroutinesApi::class) diff --git a/discussion/src/test/java/org/openedx/discussion/presentation/threads/DiscussionThreadsViewModelTest.kt b/discussion/src/test/java/org/openedx/discussion/presentation/threads/DiscussionThreadsViewModelTest.kt index 92e5cd2fa..435981520 100644 --- a/discussion/src/test/java/org/openedx/discussion/presentation/threads/DiscussionThreadsViewModelTest.kt +++ b/discussion/src/test/java/org/openedx/discussion/presentation/threads/DiscussionThreadsViewModelTest.kt @@ -25,10 +25,8 @@ import org.junit.Rule import org.junit.Test import org.junit.rules.TestRule import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.domain.model.Pagination import org.openedx.core.extension.TextConverter -import org.openedx.core.system.ResourceManager import org.openedx.discussion.domain.interactor.DiscussionInteractor import org.openedx.discussion.domain.model.DiscussionType import org.openedx.discussion.domain.model.ThreadsData @@ -36,6 +34,8 @@ import org.openedx.discussion.presentation.topics.DiscussionTopicsViewModel import org.openedx.discussion.system.notifier.DiscussionNotifier import org.openedx.discussion.system.notifier.DiscussionThreadAdded import org.openedx.discussion.system.notifier.DiscussionThreadDataChanged +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import java.net.UnknownHostException @OptIn(ExperimentalCoroutinesApi::class) diff --git a/discussion/src/test/java/org/openedx/discussion/presentation/topics/DiscussionTopicsViewModelTest.kt b/discussion/src/test/java/org/openedx/discussion/presentation/topics/DiscussionTopicsViewModelTest.kt index 96e3c49f4..676595929 100644 --- a/discussion/src/test/java/org/openedx/discussion/presentation/topics/DiscussionTopicsViewModelTest.kt +++ b/discussion/src/test/java/org/openedx/discussion/presentation/topics/DiscussionTopicsViewModelTest.kt @@ -24,14 +24,14 @@ import org.junit.Rule import org.junit.Test import org.junit.rules.TestRule import org.openedx.core.R -import org.openedx.core.UIMessage -import org.openedx.core.system.ResourceManager import org.openedx.core.system.notifier.CourseLoading import org.openedx.core.system.notifier.CourseNotifier import org.openedx.discussion.domain.interactor.DiscussionInteractor import org.openedx.discussion.domain.model.Topic import org.openedx.discussion.presentation.DiscussionAnalytics import org.openedx.discussion.presentation.DiscussionRouter +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import java.net.UnknownHostException @OptIn(ExperimentalCoroutinesApi::class) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 35c31a92e..ec34fd6a7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Fri May 03 13:24:00 EEST 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/profile/build.gradle b/profile/build.gradle index 2ccd98e63..a1b894421 100644 --- a/profile/build.gradle +++ b/profile/build.gradle @@ -2,6 +2,7 @@ plugins { id 'com.android.library' id 'org.jetbrains.kotlin.android' id 'kotlin-parcelize' + id "org.jetbrains.kotlin.plugin.compose" } android { @@ -36,9 +37,6 @@ android { viewBinding true compose true } - composeOptions { - kotlinCompilerExtensionVersion = "$compose_compiler_version" - } flavorDimensions += "env" productFlavors { @@ -57,11 +55,10 @@ android { dependencies { implementation project(path: ":core") - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + androidTestImplementation 'androidx.test.ext:junit:1.2.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' testImplementation "junit:junit:$junit_version" testImplementation "io.mockk:mockk:$mockk_version" testImplementation "io.mockk:mockk-android:$mockk_version" - testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version" testImplementation "androidx.arch.core:core-testing:$android_arch_version" } \ No newline at end of file diff --git a/profile/src/main/java/org/openedx/profile/presentation/anothersaccount/AnothersProfileFragment.kt b/profile/src/main/java/org/openedx/profile/presentation/anothersaccount/AnothersProfileFragment.kt index db330faa3..8404bbae1 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/anothersaccount/AnothersProfileFragment.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/anothersaccount/AnothersProfileFragment.kt @@ -41,18 +41,18 @@ import androidx.fragment.app.Fragment import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.domain.model.ProfileImage import org.openedx.core.ui.BackBtn import org.openedx.core.ui.HandleUIMessage -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.profile.domain.model.Account import org.openedx.profile.presentation.ui.ProfileInfoSection import org.openedx.profile.presentation.ui.ProfileTopic diff --git a/profile/src/main/java/org/openedx/profile/presentation/anothersaccount/AnothersProfileViewModel.kt b/profile/src/main/java/org/openedx/profile/presentation/anothersaccount/AnothersProfileViewModel.kt index baabdb360..82b906207 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/anothersaccount/AnothersProfileViewModel.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/anothersaccount/AnothersProfileViewModel.kt @@ -4,11 +4,11 @@ import androidx.compose.runtime.State import androidx.compose.runtime.mutableStateOf import androidx.lifecycle.viewModelScope import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.R -import org.openedx.core.UIMessage -import org.openedx.core.extension.isInternetError -import org.openedx.core.system.ResourceManager +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import org.openedx.profile.domain.interactor.ProfileInteractor class AnothersProfileViewModel( diff --git a/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarFragment.kt b/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarFragment.kt index fcc6db153..eaf43cf56 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarFragment.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarFragment.kt @@ -11,9 +11,9 @@ import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.ViewCompositionStrategy import androidx.fragment.app.Fragment import org.koin.androidx.compose.koinViewModel -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.theme.OpenEdXTheme +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.rememberWindowSize class CalendarFragment : Fragment() { diff --git a/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarSetUpView.kt b/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarSetUpView.kt index 7309a42f9..363dc70eb 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarSetUpView.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarSetUpView.kt @@ -39,8 +39,6 @@ import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import org.openedx.core.ui.OpenEdXButton import org.openedx.core.ui.Toolbar -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape import org.openedx.core.ui.settingsHeaderBackground import org.openedx.core.ui.statusBarsInset @@ -48,7 +46,9 @@ import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.profile.R @OptIn(ExperimentalComposeUiApi::class) diff --git a/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarSettingsView.kt b/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarSettingsView.kt index d8c2e9a55..8a78c6f12 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarSettingsView.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarSettingsView.kt @@ -48,8 +48,6 @@ import org.openedx.core.domain.model.CalendarData import org.openedx.core.presentation.settings.calendarsync.CalendarSyncState import org.openedx.core.ui.OpenEdXOutlinedButton import org.openedx.core.ui.Toolbar -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape import org.openedx.core.ui.settingsHeaderBackground import org.openedx.core.ui.statusBarsInset @@ -57,7 +55,9 @@ import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.profile.R import org.openedx.profile.presentation.ui.SettingsItem diff --git a/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarViewModel.kt b/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarViewModel.kt index c50bf587c..85f217446 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarViewModel.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarViewModel.kt @@ -8,7 +8,6 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.data.storage.CalendarPreferences import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.interactor.CalendarInteractor @@ -23,6 +22,7 @@ import org.openedx.core.system.notifier.calendar.CalendarSyncOffline import org.openedx.core.system.notifier.calendar.CalendarSynced import org.openedx.core.system.notifier.calendar.CalendarSyncing import org.openedx.core.worker.CalendarSyncScheduler +import org.openedx.foundation.presentation.BaseViewModel import org.openedx.profile.presentation.ProfileRouter class CalendarViewModel( diff --git a/profile/src/main/java/org/openedx/profile/presentation/calendar/CoursesToSyncFragment.kt b/profile/src/main/java/org/openedx/profile/presentation/calendar/CoursesToSyncFragment.kt index 39e767e1b..fed719696 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/calendar/CoursesToSyncFragment.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/calendar/CoursesToSyncFragment.kt @@ -58,12 +58,9 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.fragment.app.Fragment import org.koin.androidx.compose.koinViewModel -import org.openedx.core.UIMessage import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.Toolbar -import org.openedx.core.ui.WindowSize import org.openedx.core.ui.displayCutoutForLandscape -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.settingsHeaderBackground import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme @@ -71,7 +68,10 @@ import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography import org.openedx.core.ui.theme.fontFamily -import org.openedx.core.ui.windowSizeValue +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.profile.R import org.openedx.core.R as coreR diff --git a/profile/src/main/java/org/openedx/profile/presentation/calendar/CoursesToSyncViewModel.kt b/profile/src/main/java/org/openedx/profile/presentation/calendar/CoursesToSyncViewModel.kt index 5e54363e6..cf7f8b24d 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/calendar/CoursesToSyncViewModel.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/calendar/CoursesToSyncViewModel.kt @@ -9,14 +9,14 @@ import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.update import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.data.storage.CalendarPreferences import org.openedx.core.domain.interactor.CalendarInteractor -import org.openedx.core.extension.isInternetError -import org.openedx.core.system.ResourceManager import org.openedx.core.worker.CalendarSyncScheduler +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager class CoursesToSyncViewModel( private val calendarInteractor: CalendarInteractor, diff --git a/profile/src/main/java/org/openedx/profile/presentation/calendar/DisableCalendarSyncDialogFragment.kt b/profile/src/main/java/org/openedx/profile/presentation/calendar/DisableCalendarSyncDialogFragment.kt index e6a196a8c..8a71410b1 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/calendar/DisableCalendarSyncDialogFragment.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/calendar/DisableCalendarSyncDialogFragment.kt @@ -35,7 +35,6 @@ import androidx.core.os.bundleOf import androidx.fragment.app.DialogFragment import org.koin.androidx.compose.koinViewModel import org.openedx.core.domain.model.CalendarData -import org.openedx.core.extension.parcelable import org.openedx.core.presentation.dialog.DefaultDialogBox import org.openedx.core.ui.OpenEdXButton import org.openedx.core.ui.OpenEdXOutlinedButton @@ -43,6 +42,7 @@ import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography +import org.openedx.foundation.extension.parcelable import org.openedx.profile.R import androidx.compose.ui.graphics.Color as ComposeColor import org.openedx.core.R as coreR diff --git a/profile/src/main/java/org/openedx/profile/presentation/calendar/DisableCalendarSyncDialogViewModel.kt b/profile/src/main/java/org/openedx/profile/presentation/calendar/DisableCalendarSyncDialogViewModel.kt index 303dd2a40..b29c3394c 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/calendar/DisableCalendarSyncDialogViewModel.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/calendar/DisableCalendarSyncDialogViewModel.kt @@ -2,12 +2,12 @@ package org.openedx.profile.presentation.calendar import androidx.lifecycle.viewModelScope import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.data.storage.CalendarPreferences import org.openedx.core.domain.interactor.CalendarInteractor import org.openedx.core.system.CalendarManager import org.openedx.core.system.notifier.calendar.CalendarNotifier import org.openedx.core.system.notifier.calendar.CalendarSyncDisabled +import org.openedx.foundation.presentation.BaseViewModel class DisableCalendarSyncDialogViewModel( private val calendarNotifier: CalendarNotifier, diff --git a/profile/src/main/java/org/openedx/profile/presentation/calendar/NewCalendarDialogFragment.kt b/profile/src/main/java/org/openedx/profile/presentation/calendar/NewCalendarDialogFragment.kt index af09b3ea3..361bd965e 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/calendar/NewCalendarDialogFragment.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/calendar/NewCalendarDialogFragment.kt @@ -64,8 +64,6 @@ import androidx.compose.ui.unit.dp import androidx.core.os.bundleOf import androidx.fragment.app.DialogFragment import org.koin.androidx.compose.koinViewModel -import org.openedx.core.extension.parcelable -import org.openedx.core.extension.toastMessage import org.openedx.core.presentation.dialog.DefaultDialogBox import org.openedx.core.ui.OpenEdXButton import org.openedx.core.ui.OpenEdXOutlinedButton @@ -74,6 +72,8 @@ import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography +import org.openedx.foundation.extension.parcelable +import org.openedx.foundation.extension.toastMessage import org.openedx.profile.R import androidx.compose.ui.graphics.Color as ComposeColor import org.openedx.core.R as CoreR diff --git a/profile/src/main/java/org/openedx/profile/presentation/calendar/NewCalendarDialogViewModel.kt b/profile/src/main/java/org/openedx/profile/presentation/calendar/NewCalendarDialogViewModel.kt index e43f1b989..20fbdbf23 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/calendar/NewCalendarDialogViewModel.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/calendar/NewCalendarDialogViewModel.kt @@ -5,15 +5,15 @@ import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.R import org.openedx.core.data.storage.CalendarPreferences import org.openedx.core.domain.interactor.CalendarInteractor import org.openedx.core.system.CalendarManager -import org.openedx.core.system.ResourceManager import org.openedx.core.system.connection.NetworkConnection import org.openedx.core.system.notifier.calendar.CalendarCreated import org.openedx.core.system.notifier.calendar.CalendarNotifier +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.system.ResourceManager class NewCalendarDialogViewModel( private val calendarManager: CalendarManager, diff --git a/profile/src/main/java/org/openedx/profile/presentation/delete/DeleteProfileFragment.kt b/profile/src/main/java/org/openedx/profile/presentation/delete/DeleteProfileFragment.kt index f92ca3c3e..f9d481466 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/delete/DeleteProfileFragment.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/delete/DeleteProfileFragment.kt @@ -56,22 +56,22 @@ import androidx.fragment.app.Fragment import org.koin.android.ext.android.inject import org.koin.androidx.viewmodel.ext.android.viewModel import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.OpenEdXButton import org.openedx.core.ui.OpenEdXOutlinedTextField import org.openedx.core.ui.Toolbar -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.settingsHeaderBackground import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.profile.presentation.ProfileRouter import org.openedx.profile.presentation.settings.SettingsViewModel import org.openedx.profile.R as profileR diff --git a/profile/src/main/java/org/openedx/profile/presentation/delete/DeleteProfileViewModel.kt b/profile/src/main/java/org/openedx/profile/presentation/delete/DeleteProfileViewModel.kt index 79fff00d1..d29e70ab3 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/delete/DeleteProfileViewModel.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/delete/DeleteProfileViewModel.kt @@ -4,13 +4,13 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.viewModelScope import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.Validator -import org.openedx.core.extension.isInternetError import org.openedx.core.system.EdxError -import org.openedx.core.system.ResourceManager +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import org.openedx.profile.domain.interactor.ProfileInteractor import org.openedx.profile.presentation.ProfileAnalytics import org.openedx.profile.presentation.ProfileAnalyticsEvent diff --git a/profile/src/main/java/org/openedx/profile/presentation/edit/EditProfileFragment.kt b/profile/src/main/java/org/openedx/profile/presentation/edit/EditProfileFragment.kt index 21317c3fe..4005d1191 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/edit/EditProfileFragment.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/edit/EditProfileFragment.kt @@ -42,7 +42,6 @@ import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll import androidx.compose.material.Card import androidx.compose.material.Divider -import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.Icon import androidx.compose.material.MaterialTheme import androidx.compose.material.ModalBottomSheetLayout @@ -108,13 +107,9 @@ import kotlinx.coroutines.launch import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf import org.openedx.core.AppDataConstants.DEFAULT_MIME_TYPE -import org.openedx.core.UIMessage import org.openedx.core.domain.model.LanguageProficiency import org.openedx.core.domain.model.ProfileImage import org.openedx.core.domain.model.RegistrationField -import org.openedx.core.extension.getFileName -import org.openedx.core.extension.parcelable -import org.openedx.core.extension.tagId import org.openedx.core.ui.AutoSizeText import org.openedx.core.ui.BackBtn import org.openedx.core.ui.HandleUIMessage @@ -122,20 +117,24 @@ import org.openedx.core.ui.IconText import org.openedx.core.ui.OpenEdXButton import org.openedx.core.ui.OpenEdXOutlinedButton import org.openedx.core.ui.SheetContent -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape import org.openedx.core.ui.isImeVisibleState import org.openedx.core.ui.noRippleClickable import org.openedx.core.ui.rememberSaveableMap -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue import org.openedx.core.utils.LocaleUtils +import org.openedx.foundation.extension.getFileName +import org.openedx.foundation.extension.parcelable +import org.openedx.foundation.extension.tagId +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.profile.R import org.openedx.profile.domain.model.Account import java.io.ByteArrayOutputStream @@ -304,10 +303,7 @@ class EditProfileFragment : Fragment() { } -@OptIn( - ExperimentalMaterialApi::class, - ExperimentalComposeUiApi::class -) +@OptIn(ExperimentalComposeUiApi::class) @Composable private fun EditProfileScreen( windowSize: WindowSize, diff --git a/profile/src/main/java/org/openedx/profile/presentation/edit/EditProfileViewModel.kt b/profile/src/main/java/org/openedx/profile/presentation/edit/EditProfileViewModel.kt index bc4c77dd1..33e804d28 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/edit/EditProfileViewModel.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/edit/EditProfileViewModel.kt @@ -5,11 +5,11 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.viewModelScope import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.R -import org.openedx.core.UIMessage -import org.openedx.core.extension.isInternetError -import org.openedx.core.system.ResourceManager +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import org.openedx.profile.domain.interactor.ProfileInteractor import org.openedx.profile.domain.model.Account import org.openedx.profile.presentation.ProfileAnalytics diff --git a/profile/src/main/java/org/openedx/profile/presentation/manageaccount/ManageAccountFragment.kt b/profile/src/main/java/org/openedx/profile/presentation/manageaccount/ManageAccountFragment.kt index 084d544aa..0616c9e84 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/manageaccount/ManageAccountFragment.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/manageaccount/ManageAccountFragment.kt @@ -9,8 +9,8 @@ import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.ViewCompositionStrategy import androidx.fragment.app.Fragment import org.koin.androidx.viewmodel.ext.android.viewModel -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.theme.OpenEdXTheme +import org.openedx.foundation.presentation.rememberWindowSize import org.openedx.profile.presentation.manageaccount.compose.ManageAccountView import org.openedx.profile.presentation.manageaccount.compose.ManageAccountViewAction diff --git a/profile/src/main/java/org/openedx/profile/presentation/manageaccount/ManageAccountViewModel.kt b/profile/src/main/java/org/openedx/profile/presentation/manageaccount/ManageAccountViewModel.kt index 972426d2e..3e25214a1 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/manageaccount/ManageAccountViewModel.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/manageaccount/ManageAccountViewModel.kt @@ -10,11 +10,11 @@ import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.R -import org.openedx.core.UIMessage -import org.openedx.core.extension.isInternetError -import org.openedx.core.system.ResourceManager +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import org.openedx.profile.domain.interactor.ProfileInteractor import org.openedx.profile.presentation.ProfileAnalytics import org.openedx.profile.presentation.ProfileAnalyticsEvent diff --git a/profile/src/main/java/org/openedx/profile/presentation/manageaccount/compose/ManageAccountView.kt b/profile/src/main/java/org/openedx/profile/presentation/manageaccount/compose/ManageAccountView.kt index 970ff2f91..016f1e90c 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/manageaccount/compose/ManageAccountView.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/manageaccount/compose/ManageAccountView.kt @@ -38,13 +38,10 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.IconText import org.openedx.core.ui.OpenEdXOutlinedButton import org.openedx.core.ui.Toolbar -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape import org.openedx.core.ui.settingsHeaderBackground import org.openedx.core.ui.statusBarsInset @@ -52,7 +49,10 @@ import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.profile.presentation.manageaccount.ManageAccountUIState import org.openedx.profile.presentation.ui.ProfileTopic import org.openedx.profile.presentation.ui.mockAccount diff --git a/profile/src/main/java/org/openedx/profile/presentation/profile/ProfileFragment.kt b/profile/src/main/java/org/openedx/profile/presentation/profile/ProfileFragment.kt index cdf190e6a..581bdc63f 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/profile/ProfileFragment.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/profile/ProfileFragment.kt @@ -10,8 +10,8 @@ import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.ViewCompositionStrategy import androidx.fragment.app.Fragment import org.koin.androidx.viewmodel.ext.android.viewModel -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.theme.OpenEdXTheme +import org.openedx.foundation.presentation.rememberWindowSize import org.openedx.profile.presentation.profile.compose.ProfileView import org.openedx.profile.presentation.profile.compose.ProfileViewAction diff --git a/profile/src/main/java/org/openedx/profile/presentation/profile/ProfileViewModel.kt b/profile/src/main/java/org/openedx/profile/presentation/profile/ProfileViewModel.kt index f02e09c22..b2d4ccb4e 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/profile/ProfileViewModel.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/profile/ProfileViewModel.kt @@ -9,11 +9,11 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.R -import org.openedx.core.UIMessage -import org.openedx.core.extension.isInternetError -import org.openedx.core.system.ResourceManager +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import org.openedx.profile.domain.interactor.ProfileInteractor import org.openedx.profile.presentation.ProfileAnalytics import org.openedx.profile.presentation.ProfileAnalyticsEvent diff --git a/profile/src/main/java/org/openedx/profile/presentation/profile/compose/ProfileView.kt b/profile/src/main/java/org/openedx/profile/presentation/profile/compose/ProfileView.kt index 411ac156d..7a0d90b16 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/profile/compose/ProfileView.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/profile/compose/ProfileView.kt @@ -37,17 +37,17 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.ui.HandleUIMessage import org.openedx.core.ui.OpenEdXOutlinedButton import org.openedx.core.ui.Toolbar -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors -import org.openedx.core.ui.windowSizeValue +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.profile.presentation.profile.ProfileUIState import org.openedx.profile.presentation.ui.ProfileInfoSection import org.openedx.profile.presentation.ui.ProfileTopic diff --git a/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsFragment.kt b/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsFragment.kt index 7ac402330..1746fa167 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsFragment.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsFragment.kt @@ -10,8 +10,8 @@ import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.ViewCompositionStrategy import androidx.fragment.app.Fragment import org.koin.androidx.viewmodel.ext.android.viewModel -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.theme.OpenEdXTheme +import org.openedx.foundation.presentation.rememberWindowSize class SettingsFragment : Fragment() { 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 5e044ca46..21d0fe1fb 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 @@ -56,8 +56,6 @@ import org.openedx.core.presentation.global.AppData import org.openedx.core.system.notifier.app.AppUpgradeEvent import org.openedx.core.ui.OpenEdXButton import org.openedx.core.ui.Toolbar -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape import org.openedx.core.ui.settingsHeaderBackground import org.openedx.core.ui.statusBarsInset @@ -65,7 +63,9 @@ import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.profile.domain.model.Configuration import org.openedx.profile.presentation.ui.SettingsDivider import org.openedx.profile.presentation.ui.SettingsItem diff --git a/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsViewModel.kt b/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsViewModel.kt index 64145b063..a483d0b91 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsViewModel.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsViewModel.kt @@ -14,20 +14,20 @@ import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import org.openedx.core.AppUpdateState -import org.openedx.core.BaseViewModel import org.openedx.core.CalendarRouter import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.config.Config -import org.openedx.core.extension.isInternetError import org.openedx.core.module.DownloadWorkerController import org.openedx.core.presentation.global.AppData import org.openedx.core.system.AppCookieManager -import org.openedx.core.system.ResourceManager import org.openedx.core.system.notifier.app.AppNotifier import org.openedx.core.system.notifier.app.AppUpgradeEvent import org.openedx.core.system.notifier.app.LogoutEvent import org.openedx.core.utils.EmailUtil +import org.openedx.foundation.extension.isInternetError +import org.openedx.foundation.presentation.BaseViewModel +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import org.openedx.profile.domain.interactor.ProfileInteractor import org.openedx.profile.domain.model.Configuration import org.openedx.profile.presentation.ProfileAnalytics diff --git a/profile/src/main/java/org/openedx/profile/presentation/ui/SettingsUI.kt b/profile/src/main/java/org/openedx/profile/presentation/ui/SettingsUI.kt index df6c719ca..f4811135a 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/ui/SettingsUI.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/ui/SettingsUI.kt @@ -19,9 +19,9 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp -import org.openedx.core.extension.tagId import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appTypography +import org.openedx.foundation.extension.tagId @Composable fun SettingsItem( diff --git a/profile/src/main/java/org/openedx/profile/presentation/video/VideoSettingsFragment.kt b/profile/src/main/java/org/openedx/profile/presentation/video/VideoSettingsFragment.kt index 5de93fdad..2213b083d 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/video/VideoSettingsFragment.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/video/VideoSettingsFragment.kt @@ -51,18 +51,18 @@ import androidx.fragment.app.Fragment import org.koin.androidx.viewmodel.ext.android.viewModel import org.openedx.core.domain.model.VideoSettings import org.openedx.core.ui.Toolbar -import org.openedx.core.ui.WindowSize -import org.openedx.core.ui.WindowType import org.openedx.core.ui.displayCutoutForLandscape import org.openedx.core.ui.noRippleClickable -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.settingsHeaderBackground import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appShapes import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.WindowType +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.profile.R import org.openedx.core.R as CoreR diff --git a/profile/src/main/java/org/openedx/profile/presentation/video/VideoSettingsViewModel.kt b/profile/src/main/java/org/openedx/profile/presentation/video/VideoSettingsViewModel.kt index f0ed7622a..f2fd90c61 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/video/VideoSettingsViewModel.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/video/VideoSettingsViewModel.kt @@ -7,12 +7,12 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.viewModelScope import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.launch -import org.openedx.core.BaseViewModel import org.openedx.core.data.storage.CorePreferences import org.openedx.core.domain.model.VideoSettings import org.openedx.core.presentation.settings.video.VideoQualityType import org.openedx.core.system.notifier.VideoNotifier import org.openedx.core.system.notifier.VideoQualityChanged +import org.openedx.foundation.presentation.BaseViewModel import org.openedx.profile.presentation.ProfileAnalytics import org.openedx.profile.presentation.ProfileAnalyticsEvent import org.openedx.profile.presentation.ProfileAnalyticsKey diff --git a/profile/src/test/java/org/openedx/profile/presentation/edit/EditProfileViewModelTest.kt b/profile/src/test/java/org/openedx/profile/presentation/edit/EditProfileViewModelTest.kt index e8f1c13ef..9cc8c79ff 100644 --- a/profile/src/test/java/org/openedx/profile/presentation/edit/EditProfileViewModelTest.kt +++ b/profile/src/test/java/org/openedx/profile/presentation/edit/EditProfileViewModelTest.kt @@ -20,9 +20,9 @@ import org.junit.Rule import org.junit.Test import org.junit.rules.TestRule import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.domain.model.ProfileImage -import org.openedx.core.system.ResourceManager +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import org.openedx.profile.domain.interactor.ProfileInteractor import org.openedx.profile.domain.model.Account import org.openedx.profile.presentation.ProfileAnalytics diff --git a/profile/src/test/java/org/openedx/profile/presentation/profile/AnothersProfileViewModelTest.kt b/profile/src/test/java/org/openedx/profile/presentation/profile/AnothersProfileViewModelTest.kt index 0e299e82a..6bdd07b82 100644 --- a/profile/src/test/java/org/openedx/profile/presentation/profile/AnothersProfileViewModelTest.kt +++ b/profile/src/test/java/org/openedx/profile/presentation/profile/AnothersProfileViewModelTest.kt @@ -19,9 +19,9 @@ import org.junit.Rule import org.junit.Test import org.junit.rules.TestRule import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.domain.model.ProfileImage -import org.openedx.core.system.ResourceManager +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import org.openedx.profile.domain.interactor.ProfileInteractor import org.openedx.profile.presentation.anothersaccount.AnothersProfileUIState import org.openedx.profile.presentation.anothersaccount.AnothersProfileViewModel diff --git a/profile/src/test/java/org/openedx/profile/presentation/profile/ProfileViewModelTest.kt b/profile/src/test/java/org/openedx/profile/presentation/profile/ProfileViewModelTest.kt index d33f24fb9..0d11e9c8a 100644 --- a/profile/src/test/java/org/openedx/profile/presentation/profile/ProfileViewModelTest.kt +++ b/profile/src/test/java/org/openedx/profile/presentation/profile/ProfileViewModelTest.kt @@ -24,11 +24,11 @@ import org.junit.Rule import org.junit.Test import org.junit.rules.TestRule import org.openedx.core.R -import org.openedx.core.UIMessage import org.openedx.core.config.Config import org.openedx.core.domain.model.AgreementUrls import org.openedx.core.domain.model.ProfileImage -import org.openedx.core.system.ResourceManager +import org.openedx.foundation.presentation.UIMessage +import org.openedx.foundation.system.ResourceManager import org.openedx.profile.domain.interactor.ProfileInteractor import org.openedx.profile.presentation.ProfileAnalytics import org.openedx.profile.presentation.ProfileRouter diff --git a/settings.gradle b/settings.gradle index 2e2262fff..40beee473 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,7 +3,6 @@ pluginManagement { gradlePluginPortal() google() mavenCentral() - maven { url "https://maven.fullstory.com" } } buildscript { repositories { @@ -11,11 +10,9 @@ pluginManagement { maven { url = uri("https://storage.googleapis.com/r8-releases/raw") } - maven { url "https://maven.fullstory.com" } } dependencies { - classpath("com.android.tools:r8:8.3.37") - classpath 'com.fullstory:gradle-plugin-local:1.47.0' + classpath("com.android.tools:r8:8.5.35") } } } @@ -24,16 +21,14 @@ dependencyResolutionManagement { repositories { google() mavenCentral() - maven { url "https://maven.fullstory.com" } maven { url "http://appboy.github.io/appboy-android-sdk/sdk" allowInsecureProtocol = true } + maven { url "https://pkgs.dev.azure.com/MicrosoftDeviceSDK/DuoSDK-Public/_packaging/Duo-SDK-Feed/maven/v1" } maven { - url "https://appboy.github.io/appboy-segment-android/sdk" - allowInsecureProtocol = true + url = uri("https://jitpack.io") } - maven { url "https://pkgs.dev.azure.com/MicrosoftDeviceSDK/DuoSDK-Public/_packaging/Duo-SDK-Feed/maven/v1" } } } //Workaround for AS Iguana https://github.com/gradle/gradle/issues/28407 diff --git a/whatsnew/build.gradle b/whatsnew/build.gradle index cd6778d05..59a5e14cc 100644 --- a/whatsnew/build.gradle +++ b/whatsnew/build.gradle @@ -2,6 +2,7 @@ plugins { id 'com.android.library' id 'org.jetbrains.kotlin.android' id 'kotlin-parcelize' + id "org.jetbrains.kotlin.plugin.compose" } android { @@ -38,10 +39,6 @@ android { compose true } - composeOptions { - kotlinCompilerExtensionVersion = "$compose_compiler_version" - } - flavorDimensions += "env" productFlavors { prod { @@ -59,11 +56,10 @@ android { dependencies { implementation project(path: ":core") - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + androidTestImplementation 'androidx.test.ext:junit:1.2.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' testImplementation "junit:junit:$junit_version" testImplementation "io.mockk:mockk:$mockk_version" testImplementation "io.mockk:mockk-android:$mockk_version" - testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version" testImplementation "androidx.arch.core:core-testing:$android_arch_version" } \ No newline at end of file diff --git a/whatsnew/src/main/java/org/openedx/whatsnew/presentation/whatsnew/WhatsNewFragment.kt b/whatsnew/src/main/java/org/openedx/whatsnew/presentation/whatsnew/WhatsNewFragment.kt index 541877ee2..8b9523eaa 100644 --- a/whatsnew/src/main/java/org/openedx/whatsnew/presentation/whatsnew/WhatsNewFragment.kt +++ b/whatsnew/src/main/java/org/openedx/whatsnew/presentation/whatsnew/WhatsNewFragment.kt @@ -57,14 +57,14 @@ import androidx.fragment.app.Fragment import kotlinx.coroutines.launch import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf -import org.openedx.core.ui.WindowSize import org.openedx.core.ui.calculateCurrentOffsetForPage -import org.openedx.core.ui.rememberWindowSize import org.openedx.core.ui.statusBarsInset import org.openedx.core.ui.theme.OpenEdXTheme import org.openedx.core.ui.theme.appColors import org.openedx.core.ui.theme.appTypography -import org.openedx.core.ui.windowSizeValue +import org.openedx.foundation.presentation.WindowSize +import org.openedx.foundation.presentation.rememberWindowSize +import org.openedx.foundation.presentation.windowSizeValue import org.openedx.whatsnew.domain.model.WhatsNewItem import org.openedx.whatsnew.domain.model.WhatsNewMessage import org.openedx.whatsnew.presentation.ui.NavigationUnitsButtons @@ -121,7 +121,7 @@ class WhatsNewFragment : Fragment() { } } -@OptIn(ExperimentalFoundationApi::class, ExperimentalComposeUiApi::class) +@OptIn(ExperimentalComposeUiApi::class) @Composable fun WhatsNewScreen( windowSize: WindowSize, @@ -176,7 +176,6 @@ fun WhatsNewScreen( } } -@OptIn(ExperimentalFoundationApi::class) @Composable private fun WhatsNewTopBar( windowSize: WindowSize, diff --git a/whatsnew/src/main/java/org/openedx/whatsnew/presentation/whatsnew/WhatsNewViewModel.kt b/whatsnew/src/main/java/org/openedx/whatsnew/presentation/whatsnew/WhatsNewViewModel.kt index 534a54f13..dbbbdda2f 100644 --- a/whatsnew/src/main/java/org/openedx/whatsnew/presentation/whatsnew/WhatsNewViewModel.kt +++ b/whatsnew/src/main/java/org/openedx/whatsnew/presentation/whatsnew/WhatsNewViewModel.kt @@ -3,8 +3,8 @@ package org.openedx.whatsnew.presentation.whatsnew import androidx.compose.runtime.State import androidx.compose.runtime.mutableStateOf import androidx.fragment.app.FragmentManager -import org.openedx.core.BaseViewModel import org.openedx.core.presentation.global.AppData +import org.openedx.foundation.presentation.BaseViewModel import org.openedx.whatsnew.WhatsNewManager import org.openedx.whatsnew.WhatsNewRouter import org.openedx.whatsnew.data.storage.WhatsNewPreferences