From f368fcdac74d9b310daf2c318932987287476cd2 Mon Sep 17 00:00:00 2001 From: PavloNetrebchuk Date: Thu, 6 Jun 2024 14:28:03 +0300 Subject: [PATCH] fix: Fixes according to code review feedback --- .../app/data/storage/PreferencesManager.kt | 2 +- .../main/java/org/openedx/app/di/AppModule.kt | 6 ++-- .../java/org/openedx/app/di/ScreenModule.kt | 2 +- .../dates/CourseDatesViewModel.kt | 33 ------------------- .../data/storage/CalendarPreferences.kt | 2 +- .../calendar/CalendarAccessDialogFragment.kt | 4 +++ .../calendar/CalendarSetUpView.kt | 11 +++++-- .../calendar/CalendarSettingsView.kt | 19 +++++++---- .../presentation/calendar/CalendarUIState.kt | 2 +- .../calendar/CalendarViewModel.kt | 17 +++++----- .../calendar/CoursesToSyncFragment.kt | 3 +- .../calendar/CoursesToSyncViewModel.kt | 2 +- .../DisableCalendarSyncDialogFragment.kt | 10 ++++-- .../DisableCalendarSyncDialogViewModel.kt | 6 ++-- .../calendar/NewCalendarDialogFragment.kt | 13 ++++++-- .../calendar/NewCalendarDialogViewModel.kt | 17 ++++------ .../delete/DeleteProfileViewModel.kt | 4 +-- .../presentation/edit/EditProfileViewModel.kt | 4 +-- .../manageaccount/ManageAccountViewModel.kt | 4 +-- .../presentation/profile/ProfileViewModel.kt | 4 +-- .../settings/SettingsViewModel.kt | 4 +-- .../system/notifier/AccountDeactivated.kt | 3 -- .../profile/system/notifier/AccountUpdated.kt | 3 -- .../system/notifier/CalendarCreated.kt | 3 -- .../profile/system/notifier/CalendarEvent.kt | 3 -- .../system/notifier/CalendarSyncDisabled.kt | 3 -- .../system/notifier/CalendarSyncFailed.kt | 3 -- .../profile/system/notifier/CalendarSynced.kt | 3 -- .../system/notifier/CalendarSyncing.kt | 3 -- .../profile/system/notifier/ProfileEvent.kt | 3 -- .../notifier/account/AccountDeactivated.kt | 5 +++ .../system/notifier/account/AccountUpdated.kt | 5 +++ .../notifier/calendar/CalendarCreated.kt | 3 ++ .../system/notifier/calendar/CalendarEvent.kt | 3 ++ .../{ => calendar}/CalendarNotifier.kt | 2 +- .../notifier/calendar/CalendarSyncDisabled.kt | 3 ++ .../notifier/calendar/CalendarSyncFailed.kt | 3 ++ .../notifier/calendar/CalendarSynced.kt | 3 ++ .../notifier/calendar/CalendarSyncing.kt | 3 ++ .../system/notifier/profile/ProfileEvent.kt | 3 ++ .../notifier/{ => profile}/ProfileNotifier.kt | 5 +-- .../profile/worker/CalendarSyncWorker.kt | 10 +++--- profile/src/main/res/values/strings.xml | 4 +-- .../edit/EditProfileViewModelTest.kt | 30 ++++++++++------- .../profile/ProfileViewModelTest.kt | 4 +-- 45 files changed, 144 insertions(+), 138 deletions(-) rename {core/src/main/java/org/openedx/core => profile/src/main/java/org/openedx/profile}/data/storage/CalendarPreferences.kt (77%) delete mode 100644 profile/src/main/java/org/openedx/profile/system/notifier/AccountDeactivated.kt delete mode 100644 profile/src/main/java/org/openedx/profile/system/notifier/AccountUpdated.kt delete mode 100644 profile/src/main/java/org/openedx/profile/system/notifier/CalendarCreated.kt delete mode 100644 profile/src/main/java/org/openedx/profile/system/notifier/CalendarEvent.kt delete mode 100644 profile/src/main/java/org/openedx/profile/system/notifier/CalendarSyncDisabled.kt delete mode 100644 profile/src/main/java/org/openedx/profile/system/notifier/CalendarSyncFailed.kt delete mode 100644 profile/src/main/java/org/openedx/profile/system/notifier/CalendarSynced.kt delete mode 100644 profile/src/main/java/org/openedx/profile/system/notifier/CalendarSyncing.kt delete mode 100644 profile/src/main/java/org/openedx/profile/system/notifier/ProfileEvent.kt create mode 100644 profile/src/main/java/org/openedx/profile/system/notifier/account/AccountDeactivated.kt create mode 100644 profile/src/main/java/org/openedx/profile/system/notifier/account/AccountUpdated.kt create mode 100644 profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarCreated.kt create mode 100644 profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarEvent.kt rename profile/src/main/java/org/openedx/profile/system/notifier/{ => calendar}/CalendarNotifier.kt (87%) create mode 100644 profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarSyncDisabled.kt create mode 100644 profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarSyncFailed.kt create mode 100644 profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarSynced.kt create mode 100644 profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarSyncing.kt create mode 100644 profile/src/main/java/org/openedx/profile/system/notifier/profile/ProfileEvent.kt rename profile/src/main/java/org/openedx/profile/system/notifier/{ => profile}/ProfileNotifier.kt (70%) 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 7578d799c..5f7b248ae 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 @@ -4,7 +4,6 @@ import android.content.Context import com.google.gson.Gson import org.openedx.app.BuildConfig import org.openedx.core.data.model.User -import org.openedx.core.data.storage.CalendarPreferences import org.openedx.core.data.storage.CorePreferences import org.openedx.core.data.storage.InAppReviewPreferences import org.openedx.core.domain.model.AppConfig @@ -13,6 +12,7 @@ import org.openedx.core.domain.model.VideoSettings import org.openedx.core.extension.replaceSpace import org.openedx.course.data.storage.CoursePreferences import org.openedx.profile.data.model.Account +import org.openedx.profile.data.storage.CalendarPreferences import org.openedx.profile.data.storage.ProfilePreferences import org.openedx.profile.system.CalendarManager 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 67deb6641..32d1dbe7f 100644 --- a/app/src/main/java/org/openedx/app/di/AppModule.kt +++ b/app/src/main/java/org/openedx/app/di/AppModule.kt @@ -28,7 +28,6 @@ import org.openedx.auth.presentation.sso.OAuthHelper import org.openedx.core.ImageProcessor import org.openedx.core.config.Config import org.openedx.core.data.model.CourseEnrollments -import org.openedx.core.data.storage.CalendarPreferences import org.openedx.core.data.storage.CorePreferences import org.openedx.core.data.storage.InAppReviewPreferences import org.openedx.core.module.DownloadWorkerController @@ -59,12 +58,13 @@ 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.profile.data.storage.CalendarPreferences import org.openedx.profile.data.storage.ProfilePreferences import org.openedx.profile.presentation.ProfileAnalytics import org.openedx.profile.presentation.ProfileRouter import org.openedx.profile.system.CalendarManager -import org.openedx.profile.system.notifier.CalendarNotifier -import org.openedx.profile.system.notifier.ProfileNotifier +import org.openedx.profile.system.notifier.calendar.CalendarNotifier +import org.openedx.profile.system.notifier.profile.ProfileNotifier import org.openedx.profile.worker.CalendarSyncScheduler import org.openedx.whatsnew.WhatsNewManager import org.openedx.whatsnew.WhatsNewRouter 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 932869ae4..5b2591a19 100644 --- a/app/src/main/java/org/openedx/app/di/ScreenModule.kt +++ b/app/src/main/java/org/openedx/app/di/ScreenModule.kt @@ -179,7 +179,7 @@ val screenModule = module { viewModel { CoursesToSyncViewModel(get(), get(), get()) } viewModel { NewCalendarDialogViewModel(get(), get(), get()) } viewModel { DisableCalendarSyncDialogViewModel(get(), get()) } - single { CalendarRepository(get(), get(), get()) } + factory { CalendarRepository(get(), get(), get()) } factory { CalendarInteractor(get()) } single { CourseRepository(get(), get(), get(), get(), get()) } 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 8485fcb5a..cde8b7c49 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 @@ -136,21 +136,6 @@ class CourseDatesViewModel( } } - private fun setCalendarSyncDialogType(dialog: CalendarSyncDialogType) { - val value = _uiState.value - if (value is DatesUIState.Dates) { - viewModelScope.launch { - courseNotifier.send( - CreateCalendarSyncEvent( - courseDates = value.courseDatesResult.datesSection.values.flatten(), - dialogType = dialog.name, - checkOutOfSync = false, - ) - ) - } - } - } - private fun checkIfCalendarOutOfDate() { val value = _uiState.value if (value is DatesUIState.Dates) { @@ -166,12 +151,6 @@ class CourseDatesViewModel( } } - private fun isCalendarSyncEnabled(): Boolean { - val calendarSync = corePreferences.appConfig.courseDatesCalendarSync - return calendarSync.isEnabled && ((calendarSync.isSelfPacedEnabled && isSelfPaced) || - (calendarSync.isInstructorPacedEnabled && !isSelfPaced)) - } - fun logPlsBannerViewed() { logPLSBannerEvent(CourseAnalyticsEvent.PLS_BANNER_VIEWED) } @@ -195,18 +174,6 @@ class CourseDatesViewModel( logDatesEvent(CourseAnalyticsEvent.DATES_COURSE_COMPONENT_CLICKED, params) } - private fun logCalendarSyncToggle(isChecked: Boolean) { - logDatesEvent( - CourseAnalyticsEvent.DATES_CALENDAR_SYNC_TOGGLE, - buildMap { - put( - CourseAnalyticsKey.ACTION.key, - if (isChecked) CourseAnalyticsKey.ON.key else CourseAnalyticsKey.OFF.key - ) - } - ) - } - private fun logDatesEvent( event: CourseAnalyticsEvent, param: Map = emptyMap(), diff --git a/core/src/main/java/org/openedx/core/data/storage/CalendarPreferences.kt b/profile/src/main/java/org/openedx/profile/data/storage/CalendarPreferences.kt similarity index 77% rename from core/src/main/java/org/openedx/core/data/storage/CalendarPreferences.kt rename to profile/src/main/java/org/openedx/profile/data/storage/CalendarPreferences.kt index 4efd79881..e05f7f6ee 100644 --- a/core/src/main/java/org/openedx/core/data/storage/CalendarPreferences.kt +++ b/profile/src/main/java/org/openedx/profile/data/storage/CalendarPreferences.kt @@ -1,4 +1,4 @@ -package org.openedx.core.data.storage +package org.openedx.profile.data.storage interface CalendarPreferences { var calendarId: Long diff --git a/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarAccessDialogFragment.kt b/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarAccessDialogFragment.kt index 8d49fb8ec..c1dc22df2 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarAccessDialogFragment.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarAccessDialogFragment.kt @@ -16,6 +16,8 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.material.icons.Icons @@ -86,6 +88,7 @@ private fun CalendarAccessDialog( onCancelClick: () -> Unit, onGrantCalendarAccessClick: () -> Unit ) { + val scrollState = rememberScrollState() DefaultDialogBox( modifier = modifier, onDismissClick = onCancelClick @@ -93,6 +96,7 @@ private fun CalendarAccessDialog( Column( modifier = Modifier .fillMaxWidth() + .verticalScroll(scrollState) .padding(20.dp), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(16.dp) 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 9a1c39cf2..06a842630 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 @@ -10,6 +10,8 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.widthIn +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll import androidx.compose.material.Card import androidx.compose.material.Icon import androidx.compose.material.MaterialTheme @@ -57,6 +59,7 @@ fun CalendarSetUpView( onBackClick: () -> Unit ) { val scaffoldState = rememberScaffoldState() + val scrollState = rememberScrollState() Scaffold( modifier = Modifier @@ -119,11 +122,13 @@ fun CalendarSetUpView( contentAlignment = Alignment.TopCenter ) { Column( - modifier = contentWidth.padding(vertical = 28.dp), + modifier = contentWidth + .verticalScroll(scrollState) + .padding(vertical = 28.dp), ) { Text( - modifier = Modifier.testTag("txt_settings"), - text = stringResource(id = org.openedx.core.R.string.core_settings), + modifier = Modifier.testTag("txt_calendar_sync"), + text = stringResource(id = R.string.profile_calendar_sync), style = MaterialTheme.appTypography.labelLarge, color = MaterialTheme.appColors.textSecondary ) 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 33ba5df38..866ab2f86 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 @@ -13,7 +13,9 @@ 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.foundation.rememberScrollState import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.verticalScroll import androidx.compose.material.Card import androidx.compose.material.CircularProgressIndicator import androidx.compose.material.ExperimentalMaterialApi @@ -69,6 +71,7 @@ fun CalendarSettingsView( onBackClick: () -> Unit ) { val scaffoldState = rememberScaffoldState() + val scrollState = rememberScrollState() Scaffold( modifier = Modifier @@ -131,10 +134,10 @@ fun CalendarSettingsView( contentAlignment = Alignment.TopCenter ) { Column( - modifier = contentWidth.padding(vertical = 28.dp), + modifier = contentWidth + .verticalScroll(scrollState) + .padding(vertical = 28.dp), ) { - val coursesSynced = uiState.coursesSynced - if (uiState.calendarData != null) { CalendarSyncSection( isCourseCalendarSyncEnabled = uiState.isCalendarSyncEnabled, @@ -145,10 +148,12 @@ fun CalendarSettingsView( ) } Spacer(modifier = Modifier.height(20.dp)) - CoursesToSyncSection( - coursesSynced = coursesSynced, - onCourseToSyncClick = onCourseToSyncClick - ) + if (uiState.coursesSynced != null) { + CoursesToSyncSection( + coursesSynced = uiState.coursesSynced, + onCourseToSyncClick = onCourseToSyncClick + ) + } } } } diff --git a/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarUIState.kt b/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarUIState.kt index e111fd4be..294f8e00d 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarUIState.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/calendar/CalendarUIState.kt @@ -7,5 +7,5 @@ data class CalendarUIState( val calendarData: CalendarData? = null, val calendarSyncState: CalendarSyncState, val isCalendarSyncEnabled: Boolean, - val coursesSynced: Int + val coursesSynced: Int? ) 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 79c459071..10a851478 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 @@ -9,17 +9,17 @@ 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.domain.interactor.CalendarInteractor import org.openedx.core.system.connection.NetworkConnection +import org.openedx.profile.data.storage.CalendarPreferences import org.openedx.profile.presentation.ProfileRouter import org.openedx.profile.system.CalendarManager -import org.openedx.profile.system.notifier.CalendarCreated -import org.openedx.profile.system.notifier.CalendarNotifier -import org.openedx.profile.system.notifier.CalendarSyncDisabled -import org.openedx.profile.system.notifier.CalendarSyncFailed -import org.openedx.profile.system.notifier.CalendarSynced -import org.openedx.profile.system.notifier.CalendarSyncing +import org.openedx.profile.system.notifier.calendar.CalendarCreated +import org.openedx.profile.system.notifier.calendar.CalendarNotifier +import org.openedx.profile.system.notifier.calendar.CalendarSyncDisabled +import org.openedx.profile.system.notifier.calendar.CalendarSyncFailed +import org.openedx.profile.system.notifier.calendar.CalendarSynced +import org.openedx.profile.system.notifier.calendar.CalendarSyncing import org.openedx.profile.worker.CalendarSyncScheduler class CalendarViewModel( @@ -38,7 +38,7 @@ class CalendarViewModel( calendarData = null, calendarSyncState = if (networkConnection.isOnline()) CalendarSyncState.SYNCED else CalendarSyncState.OFFLINE, isCalendarSyncEnabled = calendarPreferences.isCalendarSyncEnabled, - coursesSynced = 0 + coursesSynced = null ) ) val uiState: StateFlow @@ -49,7 +49,6 @@ class CalendarViewModel( calendarNotifier.notifier.collect { calendarEvent -> when (calendarEvent) { CalendarCreated -> { - calendarSyncScheduler.scheduleDailySync() calendarSyncScheduler.requestImmediateSync() _uiState.update { it.copy(isCalendarExist = true) } getCalendarData() 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 93b6d12be..6dcffa1b9 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 @@ -168,7 +168,8 @@ private fun CoursesToSyncView( contentAlignment = Alignment.TopCenter ) { Column( - modifier = contentWidth.padding(vertical = 28.dp), + modifier = contentWidth + .padding(vertical = 28.dp), ) { Text( text = stringResource(R.string.profile_courses_to_sync_title), 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 0ed28f058..2748e04ab 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 @@ -7,8 +7,8 @@ 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.domain.interactor.CalendarInteractor +import org.openedx.profile.data.storage.CalendarPreferences import org.openedx.profile.worker.CalendarSyncScheduler class CoursesToSyncViewModel( 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 f25051181..a3074e78e 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 @@ -15,7 +15,9 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size +import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.verticalScroll import androidx.compose.material.MaterialTheme import androidx.compose.material.Text import androidx.compose.runtime.Composable @@ -94,6 +96,7 @@ private fun DisableCalendarSyncDialogView( onCancelClick: () -> Unit, onDisableSyncingClick: () -> Unit ) { + val scrollState = rememberScrollState() DefaultDialogBox( modifier = modifier, onDismissClick = onCancelClick @@ -101,6 +104,7 @@ private fun DisableCalendarSyncDialogView( Column( modifier = Modifier .fillMaxWidth() + .verticalScroll(scrollState) .padding(20.dp), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(16.dp) @@ -148,11 +152,13 @@ private fun DisableCalendarSyncDialogView( } Text( modifier = Modifier.fillMaxWidth(), - text = stringResource(id = org.openedx.profile.R.string.profile_disable_calendar_dialog_description), + text = stringResource( + id = org.openedx.profile.R.string.profile_disable_calendar_dialog_description, + calendarData?.title ?: "" + ), style = MaterialTheme.appTypography.bodyMedium, color = MaterialTheme.appColors.textDark ) - OpenEdXOutlinedButton( modifier = Modifier.fillMaxWidth(), text = stringResource(id = R.string.profile_disable_syncing), 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 10bcf08a5..1d67bf55d 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 @@ -3,9 +3,9 @@ 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.profile.system.notifier.CalendarNotifier -import org.openedx.profile.system.notifier.CalendarSyncDisabled +import org.openedx.profile.data.storage.CalendarPreferences +import org.openedx.profile.system.notifier.calendar.CalendarNotifier +import org.openedx.profile.system.notifier.calendar.CalendarSyncDisabled class DisableCalendarSyncDialogViewModel( private val calendarPreferences: CalendarPreferences, 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 7f0103789..77d365ccc 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 @@ -21,9 +21,11 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width +import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions +import androidx.compose.foundation.verticalScroll import androidx.compose.material.Divider import androidx.compose.material.DropdownMenu import androidx.compose.material.DropdownMenuItem @@ -62,6 +64,7 @@ import androidx.core.os.bundleOf import androidx.fragment.app.DialogFragment import org.koin.androidx.viewmodel.ext.android.viewModel 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 @@ -94,7 +97,10 @@ class NewCalendarDialogFragment : DialogFragment() { dismiss() }, onBeginSyncingClick = { calendarTitle, calendarColor -> - viewModel.createCalendar(requireContext(), calendarTitle, calendarColor) + val isCalendarCreated = viewModel.createCalendar(calendarTitle, calendarColor) + if (!isCalendarCreated) { + requireContext().toastMessage(context.getString(CoreR.string.core_error_unknown_error)) + } dismiss() } ) @@ -130,6 +136,7 @@ private fun NewCalendarDialog( onBeginSyncingClick: (calendarTitle: String, calendarColor: CalendarColor) -> Unit ) { val context = LocalContext.current + val scrollState = rememberScrollState() val title = when (newCalendarDialogType) { NewCalendarDialogType.CREATE_NEW -> stringResource(id = R.string.profile_new_calendar) NewCalendarDialogType.UPDATE -> stringResource(id = R.string.profile_change_sync_options) @@ -147,6 +154,7 @@ private fun NewCalendarDialog( Column( modifier = Modifier .fillMaxWidth() + .verticalScroll(scrollState) .padding(20.dp), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(16.dp) @@ -218,6 +226,7 @@ private fun CalendarTitleTextField( onValueChanged: (String) -> Unit ) { val focusManager = LocalFocusManager.current + val maxChar = 40 var textFieldValue by rememberSaveable(stateSaver = TextFieldValue.Saver) { mutableStateOf( TextFieldValue("") @@ -238,7 +247,7 @@ private fun CalendarTitleTextField( .height(48.dp), value = textFieldValue, onValueChange = { - textFieldValue = it + if (it.text.length <= maxChar) textFieldValue = it onValueChanged(it.text.trim()) }, colors = TextFieldDefaults.outlinedTextFieldColors( 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 272414b58..04ed647fa 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 @@ -1,15 +1,12 @@ package org.openedx.profile.presentation.calendar -import android.content.Context import androidx.lifecycle.viewModelScope import kotlinx.coroutines.launch import org.openedx.core.BaseViewModel -import org.openedx.core.data.storage.CalendarPreferences -import org.openedx.core.extension.toastMessage +import org.openedx.profile.data.storage.CalendarPreferences import org.openedx.profile.system.CalendarManager -import org.openedx.profile.system.notifier.CalendarCreated -import org.openedx.profile.system.notifier.CalendarNotifier -import org.openedx.core.R as coreR +import org.openedx.profile.system.notifier.calendar.CalendarCreated +import org.openedx.profile.system.notifier.calendar.CalendarNotifier class NewCalendarDialogViewModel( private val calendarManager: CalendarManager, @@ -18,21 +15,21 @@ class NewCalendarDialogViewModel( ) : BaseViewModel() { fun createCalendar( - context: Context, calendarTitle: String, calendarColor: CalendarColor, - ) { + ): Boolean { val calendarId = calendarManager.createOrUpdateCalendar( calendarTitle = calendarTitle, calendarColor = calendarColor.color ) - if (calendarId != CalendarManager.CALENDAR_DOES_NOT_EXIST) { + return if (calendarId != CalendarManager.CALENDAR_DOES_NOT_EXIST) { calendarPreferences.calendarId = calendarId viewModelScope.launch { calendarNotifier.send(CalendarCreated) } + true } else { - context.toastMessage(context.getString(coreR.string.core_error_unknown_error)) + false } } } 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 c4477ef28..79fff00d1 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 @@ -15,8 +15,8 @@ import org.openedx.profile.domain.interactor.ProfileInteractor import org.openedx.profile.presentation.ProfileAnalytics import org.openedx.profile.presentation.ProfileAnalyticsEvent import org.openedx.profile.presentation.ProfileAnalyticsKey -import org.openedx.profile.system.notifier.AccountDeactivated -import org.openedx.profile.system.notifier.ProfileNotifier +import org.openedx.profile.system.notifier.account.AccountDeactivated +import org.openedx.profile.system.notifier.profile.ProfileNotifier class DeleteProfileViewModel( private val resourceManager: ResourceManager, 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 64cf9789f..ee179c146 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 @@ -15,8 +15,8 @@ import org.openedx.profile.domain.model.Account import org.openedx.profile.presentation.ProfileAnalytics import org.openedx.profile.presentation.ProfileAnalyticsEvent import org.openedx.profile.presentation.ProfileAnalyticsKey -import org.openedx.profile.system.notifier.AccountUpdated -import org.openedx.profile.system.notifier.ProfileNotifier +import org.openedx.profile.system.notifier.account.AccountUpdated +import org.openedx.profile.system.notifier.profile.ProfileNotifier import java.io.File class EditProfileViewModel( 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 2370e0508..972426d2e 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 @@ -20,8 +20,8 @@ import org.openedx.profile.presentation.ProfileAnalytics import org.openedx.profile.presentation.ProfileAnalyticsEvent import org.openedx.profile.presentation.ProfileAnalyticsKey import org.openedx.profile.presentation.ProfileRouter -import org.openedx.profile.system.notifier.AccountUpdated -import org.openedx.profile.system.notifier.ProfileNotifier +import org.openedx.profile.system.notifier.account.AccountUpdated +import org.openedx.profile.system.notifier.profile.ProfileNotifier class ManageAccountViewModel( private val interactor: ProfileInteractor, 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 d8fc19715..f02e09c22 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 @@ -19,8 +19,8 @@ import org.openedx.profile.presentation.ProfileAnalytics import org.openedx.profile.presentation.ProfileAnalyticsEvent import org.openedx.profile.presentation.ProfileAnalyticsKey import org.openedx.profile.presentation.ProfileRouter -import org.openedx.profile.system.notifier.AccountUpdated -import org.openedx.profile.system.notifier.ProfileNotifier +import org.openedx.profile.system.notifier.account.AccountUpdated +import org.openedx.profile.system.notifier.profile.ProfileNotifier class ProfileViewModel( private val interactor: ProfileInteractor, 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 9715eb774..3e9492a21 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 @@ -32,8 +32,8 @@ import org.openedx.profile.presentation.ProfileAnalytics import org.openedx.profile.presentation.ProfileAnalyticsEvent import org.openedx.profile.presentation.ProfileAnalyticsKey import org.openedx.profile.presentation.ProfileRouter -import org.openedx.profile.system.notifier.AccountDeactivated -import org.openedx.profile.system.notifier.ProfileNotifier +import org.openedx.profile.system.notifier.account.AccountDeactivated +import org.openedx.profile.system.notifier.profile.ProfileNotifier class SettingsViewModel( private val appData: AppData, diff --git a/profile/src/main/java/org/openedx/profile/system/notifier/AccountDeactivated.kt b/profile/src/main/java/org/openedx/profile/system/notifier/AccountDeactivated.kt deleted file mode 100644 index ff09cbf72..000000000 --- a/profile/src/main/java/org/openedx/profile/system/notifier/AccountDeactivated.kt +++ /dev/null @@ -1,3 +0,0 @@ -package org.openedx.profile.system.notifier - -class AccountDeactivated : ProfileEvent diff --git a/profile/src/main/java/org/openedx/profile/system/notifier/AccountUpdated.kt b/profile/src/main/java/org/openedx/profile/system/notifier/AccountUpdated.kt deleted file mode 100644 index 2870235f2..000000000 --- a/profile/src/main/java/org/openedx/profile/system/notifier/AccountUpdated.kt +++ /dev/null @@ -1,3 +0,0 @@ -package org.openedx.profile.system.notifier - -class AccountUpdated : ProfileEvent diff --git a/profile/src/main/java/org/openedx/profile/system/notifier/CalendarCreated.kt b/profile/src/main/java/org/openedx/profile/system/notifier/CalendarCreated.kt deleted file mode 100644 index ba605a4a1..000000000 --- a/profile/src/main/java/org/openedx/profile/system/notifier/CalendarCreated.kt +++ /dev/null @@ -1,3 +0,0 @@ -package org.openedx.profile.system.notifier - -object CalendarCreated : CalendarEvent diff --git a/profile/src/main/java/org/openedx/profile/system/notifier/CalendarEvent.kt b/profile/src/main/java/org/openedx/profile/system/notifier/CalendarEvent.kt deleted file mode 100644 index b85e4db66..000000000 --- a/profile/src/main/java/org/openedx/profile/system/notifier/CalendarEvent.kt +++ /dev/null @@ -1,3 +0,0 @@ -package org.openedx.profile.system.notifier - -interface CalendarEvent \ No newline at end of file diff --git a/profile/src/main/java/org/openedx/profile/system/notifier/CalendarSyncDisabled.kt b/profile/src/main/java/org/openedx/profile/system/notifier/CalendarSyncDisabled.kt deleted file mode 100644 index c2290f3b9..000000000 --- a/profile/src/main/java/org/openedx/profile/system/notifier/CalendarSyncDisabled.kt +++ /dev/null @@ -1,3 +0,0 @@ -package org.openedx.profile.system.notifier - -object CalendarSyncDisabled : CalendarEvent diff --git a/profile/src/main/java/org/openedx/profile/system/notifier/CalendarSyncFailed.kt b/profile/src/main/java/org/openedx/profile/system/notifier/CalendarSyncFailed.kt deleted file mode 100644 index 63ffd0fd9..000000000 --- a/profile/src/main/java/org/openedx/profile/system/notifier/CalendarSyncFailed.kt +++ /dev/null @@ -1,3 +0,0 @@ -package org.openedx.profile.system.notifier - -object CalendarSyncFailed : CalendarEvent diff --git a/profile/src/main/java/org/openedx/profile/system/notifier/CalendarSynced.kt b/profile/src/main/java/org/openedx/profile/system/notifier/CalendarSynced.kt deleted file mode 100644 index 00d65b7a5..000000000 --- a/profile/src/main/java/org/openedx/profile/system/notifier/CalendarSynced.kt +++ /dev/null @@ -1,3 +0,0 @@ -package org.openedx.profile.system.notifier - -object CalendarSynced : CalendarEvent diff --git a/profile/src/main/java/org/openedx/profile/system/notifier/CalendarSyncing.kt b/profile/src/main/java/org/openedx/profile/system/notifier/CalendarSyncing.kt deleted file mode 100644 index bb92163af..000000000 --- a/profile/src/main/java/org/openedx/profile/system/notifier/CalendarSyncing.kt +++ /dev/null @@ -1,3 +0,0 @@ -package org.openedx.profile.system.notifier - -object CalendarSyncing : CalendarEvent diff --git a/profile/src/main/java/org/openedx/profile/system/notifier/ProfileEvent.kt b/profile/src/main/java/org/openedx/profile/system/notifier/ProfileEvent.kt deleted file mode 100644 index dbe877081..000000000 --- a/profile/src/main/java/org/openedx/profile/system/notifier/ProfileEvent.kt +++ /dev/null @@ -1,3 +0,0 @@ -package org.openedx.profile.system.notifier - -interface ProfileEvent diff --git a/profile/src/main/java/org/openedx/profile/system/notifier/account/AccountDeactivated.kt b/profile/src/main/java/org/openedx/profile/system/notifier/account/AccountDeactivated.kt new file mode 100644 index 000000000..68f68e58f --- /dev/null +++ b/profile/src/main/java/org/openedx/profile/system/notifier/account/AccountDeactivated.kt @@ -0,0 +1,5 @@ +package org.openedx.profile.system.notifier.account + +import org.openedx.profile.system.notifier.profile.ProfileEvent + +class AccountDeactivated : ProfileEvent diff --git a/profile/src/main/java/org/openedx/profile/system/notifier/account/AccountUpdated.kt b/profile/src/main/java/org/openedx/profile/system/notifier/account/AccountUpdated.kt new file mode 100644 index 000000000..f43d6c329 --- /dev/null +++ b/profile/src/main/java/org/openedx/profile/system/notifier/account/AccountUpdated.kt @@ -0,0 +1,5 @@ +package org.openedx.profile.system.notifier.account + +import org.openedx.profile.system.notifier.profile.ProfileEvent + +class AccountUpdated : ProfileEvent diff --git a/profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarCreated.kt b/profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarCreated.kt new file mode 100644 index 000000000..61f64da54 --- /dev/null +++ b/profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarCreated.kt @@ -0,0 +1,3 @@ +package org.openedx.profile.system.notifier.calendar + +object CalendarCreated : CalendarEvent diff --git a/profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarEvent.kt b/profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarEvent.kt new file mode 100644 index 000000000..1528bec33 --- /dev/null +++ b/profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarEvent.kt @@ -0,0 +1,3 @@ +package org.openedx.profile.system.notifier.calendar + +interface CalendarEvent diff --git a/profile/src/main/java/org/openedx/profile/system/notifier/CalendarNotifier.kt b/profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarNotifier.kt similarity index 87% rename from profile/src/main/java/org/openedx/profile/system/notifier/CalendarNotifier.kt rename to profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarNotifier.kt index 3d9f054d3..6b109b396 100644 --- a/profile/src/main/java/org/openedx/profile/system/notifier/CalendarNotifier.kt +++ b/profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarNotifier.kt @@ -1,4 +1,4 @@ -package org.openedx.profile.system.notifier +package org.openedx.profile.system.notifier.calendar import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow diff --git a/profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarSyncDisabled.kt b/profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarSyncDisabled.kt new file mode 100644 index 000000000..065f61e8a --- /dev/null +++ b/profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarSyncDisabled.kt @@ -0,0 +1,3 @@ +package org.openedx.profile.system.notifier.calendar + +object CalendarSyncDisabled : CalendarEvent diff --git a/profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarSyncFailed.kt b/profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarSyncFailed.kt new file mode 100644 index 000000000..87a79966b --- /dev/null +++ b/profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarSyncFailed.kt @@ -0,0 +1,3 @@ +package org.openedx.profile.system.notifier.calendar + +object CalendarSyncFailed : CalendarEvent diff --git a/profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarSynced.kt b/profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarSynced.kt new file mode 100644 index 000000000..33cee4ce3 --- /dev/null +++ b/profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarSynced.kt @@ -0,0 +1,3 @@ +package org.openedx.profile.system.notifier.calendar + +object CalendarSynced : CalendarEvent diff --git a/profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarSyncing.kt b/profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarSyncing.kt new file mode 100644 index 000000000..0d423913d --- /dev/null +++ b/profile/src/main/java/org/openedx/profile/system/notifier/calendar/CalendarSyncing.kt @@ -0,0 +1,3 @@ +package org.openedx.profile.system.notifier.calendar + +object CalendarSyncing : CalendarEvent diff --git a/profile/src/main/java/org/openedx/profile/system/notifier/profile/ProfileEvent.kt b/profile/src/main/java/org/openedx/profile/system/notifier/profile/ProfileEvent.kt new file mode 100644 index 000000000..c978a78d3 --- /dev/null +++ b/profile/src/main/java/org/openedx/profile/system/notifier/profile/ProfileEvent.kt @@ -0,0 +1,3 @@ +package org.openedx.profile.system.notifier.profile + +interface ProfileEvent diff --git a/profile/src/main/java/org/openedx/profile/system/notifier/ProfileNotifier.kt b/profile/src/main/java/org/openedx/profile/system/notifier/profile/ProfileNotifier.kt similarity index 70% rename from profile/src/main/java/org/openedx/profile/system/notifier/ProfileNotifier.kt rename to profile/src/main/java/org/openedx/profile/system/notifier/profile/ProfileNotifier.kt index c51d82340..71e2dbf1d 100644 --- a/profile/src/main/java/org/openedx/profile/system/notifier/ProfileNotifier.kt +++ b/profile/src/main/java/org/openedx/profile/system/notifier/profile/ProfileNotifier.kt @@ -1,9 +1,10 @@ -package org.openedx.profile.system.notifier +package org.openedx.profile.system.notifier.profile import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow -import org.openedx.core.system.notifier.VideoQualityChanged +import org.openedx.profile.system.notifier.account.AccountDeactivated +import org.openedx.profile.system.notifier.account.AccountUpdated class ProfileNotifier { diff --git a/profile/src/main/java/org/openedx/profile/worker/CalendarSyncWorker.kt b/profile/src/main/java/org/openedx/profile/worker/CalendarSyncWorker.kt index a2f8399eb..45b527a90 100644 --- a/profile/src/main/java/org/openedx/profile/worker/CalendarSyncWorker.kt +++ b/profile/src/main/java/org/openedx/profile/worker/CalendarSyncWorker.kt @@ -8,15 +8,15 @@ import org.koin.core.component.inject import org.openedx.core.data.model.CourseDates import org.openedx.core.data.model.room.CourseCalendarEventEntity import org.openedx.core.data.model.room.CourseCalendarStateEntity -import org.openedx.core.data.storage.CalendarPreferences import org.openedx.core.domain.interactor.CalendarInteractor import org.openedx.core.domain.model.CourseDateBlock import org.openedx.core.domain.model.EnrollmentStatus +import org.openedx.profile.data.storage.CalendarPreferences import org.openedx.profile.system.CalendarManager -import org.openedx.profile.system.notifier.CalendarNotifier -import org.openedx.profile.system.notifier.CalendarSyncFailed -import org.openedx.profile.system.notifier.CalendarSynced -import org.openedx.profile.system.notifier.CalendarSyncing +import org.openedx.profile.system.notifier.calendar.CalendarNotifier +import org.openedx.profile.system.notifier.calendar.CalendarSyncFailed +import org.openedx.profile.system.notifier.calendar.CalendarSynced +import org.openedx.profile.system.notifier.calendar.CalendarSyncing class CalendarSyncWorker( context: Context, diff --git a/profile/src/main/res/values/strings.xml b/profile/src/main/res/values/strings.xml index f5aa71051..422f7aa31 100644 --- a/profile/src/main/res/values/strings.xml +++ b/profile/src/main/res/values/strings.xml @@ -71,13 +71,13 @@ Offline Sync Failed Synced - Syncing to calendar + Syncing to calendar… Disabling sync for a course will remove all events connected to the course from your synced calendar. Automatically remove events from courses you haven’t viewed in the last month Not Synced Inactive Hide Inactive Courses Disable Calendar Sync - Disabling calendar sync will delete the calendar “My Assignments.” You can turn calendar sync back on at any time. + Disabling calendar sync will delete the calendar “%1$s.” You can turn calendar sync back on at any time. 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 bfe6bb0b3..2322f8485 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 @@ -1,25 +1,33 @@ package org.openedx.profile.presentation.edit import androidx.arch.core.executor.testing.InstantTaskExecutorRule -import org.openedx.core.R -import org.openedx.core.UIMessage -import org.openedx.profile.domain.model.Account -import org.openedx.core.domain.model.ProfileImage -import org.openedx.core.system.ResourceManager -import org.openedx.profile.domain.interactor.ProfileInteractor -import org.openedx.profile.presentation.ProfileAnalytics -import org.openedx.profile.system.notifier.AccountUpdated -import org.openedx.profile.system.notifier.ProfileNotifier -import io.mockk.* +import io.mockk.coEvery +import io.mockk.coVerify +import io.mockk.every +import io.mockk.mockk +import io.mockk.verify import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.test.* +import kotlinx.coroutines.test.StandardTestDispatcher +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.assertEquals 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.domain.model.ProfileImage +import org.openedx.core.system.ResourceManager +import org.openedx.profile.domain.interactor.ProfileInteractor +import org.openedx.profile.domain.model.Account +import org.openedx.profile.presentation.ProfileAnalytics +import org.openedx.profile.system.notifier.account.AccountUpdated +import org.openedx.profile.system.notifier.profile.ProfileNotifier import java.io.File import java.net.UnknownHostException 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 ca2ffd9bb..d33f24fb9 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 @@ -32,8 +32,8 @@ import org.openedx.core.system.ResourceManager import org.openedx.profile.domain.interactor.ProfileInteractor import org.openedx.profile.presentation.ProfileAnalytics import org.openedx.profile.presentation.ProfileRouter -import org.openedx.profile.system.notifier.AccountUpdated -import org.openedx.profile.system.notifier.ProfileNotifier +import org.openedx.profile.system.notifier.account.AccountUpdated +import org.openedx.profile.system.notifier.profile.ProfileNotifier import java.net.UnknownHostException @OptIn(ExperimentalCoroutinesApi::class)