From 86e322886a7f952e19a5d97339d91638bd7be260 Mon Sep 17 00:00:00 2001 From: Don Turner Date: Tue, 12 Mar 2024 14:16:30 +0000 Subject: [PATCH] Move models back into separate module Change-Id: Ibe3e115e7618505a51fe34c8ebbf80691d344ad5 --- .../apps/nowinandroid/ui/NavigationTest.kt | 2 +- .../samples/apps/nowinandroid/MainActivity.kt | 4 +- .../nowinandroid/MainActivityViewModel.kt | 2 +- .../test/repository/FakeNewsRepository.kt | 4 +- .../repository/FakeRecentSearchRepository.kt | 4 +- .../FakeSearchContentsRepository.kt | 4 +- .../test/repository/FakeTopicsRepository.kt | 8 +- .../test/repository/FakeUserDataRepository.kt | 12 +-- .../core/data/model/RecentSearchQuery.kt | 11 ++- .../CompositeUserNewsResourceRepository.kt | 10 +- .../DefaultRecentSearchRepository.kt | 4 +- .../DefaultSearchContentsRepository.kt | 6 +- .../repository/OfflineFirstNewsRepository.kt | 8 +- .../OfflineFirstTopicsRepository.kt | 10 +- .../OfflineFirstUserDataRepository.kt | 12 +-- .../core/data/util/SyncManager.kt | 6 +- ...CompositeUserNewsResourceRepositoryTest.kt | 16 ++-- .../core/data/UserNewsResourceTest.kt | 29 +++--- .../OfflineFirstNewsRepositoryTest.kt | 24 ++--- .../OfflineFirstTopicsRepositoryTest.kt | 8 +- .../OfflineFirstUserDataRepositoryTest.kt | 24 ++--- .../core/data/repository/TestSynchronizer.kt | 6 +- .../model/PopulatedNewsResourceKtTest.kt | 8 +- core/database/build.gradle.kts | 2 +- .../core/database/model/NewsResourceEntity.kt | 4 +- .../database/model/PopulatedNewsResource.kt | 4 +- .../core/database/model/TopicEntity.kt | 4 +- core/datastore/build.gradle.kts | 2 +- .../datastore/NiaPreferencesDataSource.kt | 42 ++++----- core/domain/build.gradle.kts | 1 + .../core/domain/repository/NewsRepository.kt | 4 +- .../repository/RecentSearchRepository.kt | 4 +- .../repository/SearchContentsRepository.kt | 4 +- .../domain/repository/TopicsRepository.kt | 6 +- .../domain/repository/UserDataRepository.kt | 12 +-- .../repository/UserNewsResourceRepository.kt | 8 +- .../usecase/GetFollowableTopicsUseCase.kt | 6 +- .../usecase/GetRecentSearchQueriesUseCase.kt | 4 +- .../usecase/GetSearchContentsUseCase.kt | 20 ++-- .../core/domain/utils/SyncUtilities.kt | 6 +- .../domain/GetFollowableTopicsUseCaseTest.kt | 27 ++++-- .../core}/model/ChangeListVersions.kt | 4 +- .../core}/model/DarkThemeConfig.kt | 4 +- .../core}/model/FollowableTopic.kt | 2 +- .../nowinandroid/core}/model/NewsResource.kt | 2 +- .../core}/model/RecentSearchQuery.kt | 2 +- .../nowinandroid/core}/model/SearchResult.kt | 2 +- .../nowinandroid/core}/model/ThemeBrand.kt | 4 +- .../apps/nowinandroid/core}/model/Topic.kt | 4 +- .../apps/nowinandroid/core}/model/UserData.kt | 2 +- .../core}/model/UserNewsResource.kt | 2 +- .../core}/model/UserSearchResult.kt | 2 +- core/network/build.gradle.kts | 2 +- .../core/network/model/NetworkTopic.kt | 2 +- core/notifications/build.gradle.kts | 3 +- .../core/notifications/NoOpNotifier.kt | 4 +- .../core/notifications/Notifier.kt | 4 +- .../core/notifications/SystemTrayNotifier.kt | 10 +- .../testing/data/FollowableTopicTestData.kt | 18 ++-- .../testing/data/NewsResourcesTestData.kt | 12 +-- .../core/testing/data/TopicsTestData.kt | 10 +- .../testing/data/UserNewsResourcesTestData.kt | 28 +++--- .../testing/notifications/TestNotifier.kt | 8 +- .../testing/repository/TestNewsRepository.kt | 12 +-- .../repository/TestRecentSearchRepository.kt | 8 +- .../TestSearchContentsRepository.kt | 18 ++-- .../repository/TestTopicsRepository.kt | 10 +- .../repository/TestUserDataRepository.kt | 22 ++--- core/ui/build.gradle.kts | 2 +- ...FollowableTopicPreviewParameterProvider.kt | 20 ++-- .../apps/nowinandroid/core/ui/NewsFeed.kt | 6 +- .../nowinandroid/core/ui/NewsResourceCard.kt | 12 +-- .../core/ui/NewsResourceCardList.kt | 6 +- ...serNewsResourcePreviewParameterProvider.kt | 42 ++++----- .../feature/bookmarks/BookmarksScreen.kt | 4 +- .../feature/bookmarks/BookmarksViewModel.kt | 4 +- .../feature/foryou/ForYouScreen.kt | 14 +-- .../feature/foryou/OnboardingUiState.kt | 4 +- .../feature/foryou/ForYouViewModelTest.kt | 93 +++++++++++-------- .../feature/interests/InterestsScreen.kt | 4 +- .../feature/interests/InterestsViewModel.kt | 4 +- .../feature/interests/TabContent.kt | 4 +- .../interests/InterestsViewModelTest.kt | 28 +++--- .../feature/search/SearchScreenTest.kt | 31 ++++--- .../search/RecentSearchQueriesUiState.kt | 4 +- .../feature/search/SearchResultUiState.kt | 8 +- .../feature/search/SearchScreen.kt | 8 +- .../SearchUiStatePreviewParameterProvider.kt | 7 +- .../feature/search/SearchViewModel.kt | 4 +- .../feature/settings/SettingsDialogTest.kt | 6 +- .../feature/settings/SettingsDialog.kt | 22 ++--- .../feature/settings/SettingsViewModel.kt | 12 +-- .../feature/settings/SettingsViewModelTest.kt | 4 +- .../nowinandroid/feature/topic/TopicScreen.kt | 8 +- .../feature/topic/TopicViewModel.kt | 16 ++-- .../feature/topic/TopicViewModelTest.kt | 36 +++---- .../nowinandroid/sync/workers/SyncWorker.kt | 6 +- 97 files changed, 517 insertions(+), 485 deletions(-) rename core/{domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain => model/src/main/kotlin/com/google/samples/apps/nowinandroid/core}/model/ChangeListVersions.kt (86%) rename core/{domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain => model/src/main/kotlin/com/google/samples/apps/nowinandroid/core}/model/DarkThemeConfig.kt (84%) rename core/{domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain => model/src/main/kotlin/com/google/samples/apps/nowinandroid/core}/model/FollowableTopic.kt (93%) rename core/{domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain => model/src/main/kotlin/com/google/samples/apps/nowinandroid/core}/model/NewsResource.kt (93%) rename core/{domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain => model/src/main/kotlin/com/google/samples/apps/nowinandroid/core}/model/RecentSearchQuery.kt (92%) rename core/{domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain => model/src/main/kotlin/com/google/samples/apps/nowinandroid/core}/model/SearchResult.kt (92%) rename core/{domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain => model/src/main/kotlin/com/google/samples/apps/nowinandroid/core}/model/ThemeBrand.kt (84%) rename core/{domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain => model/src/main/kotlin/com/google/samples/apps/nowinandroid/core}/model/Topic.kt (87%) rename core/{domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain => model/src/main/kotlin/com/google/samples/apps/nowinandroid/core}/model/UserData.kt (93%) rename core/{domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain => model/src/main/kotlin/com/google/samples/apps/nowinandroid/core}/model/UserNewsResource.kt (96%) rename core/{domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain => model/src/main/kotlin/com/google/samples/apps/nowinandroid/core}/model/UserSearchResult.kt (93%) diff --git a/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/NavigationTest.kt b/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/NavigationTest.kt index 52001de1d..9c0b5525a 100644 --- a/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/NavigationTest.kt +++ b/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/NavigationTest.kt @@ -35,7 +35,7 @@ import androidx.test.espresso.Espresso import androidx.test.espresso.NoActivityResumedException import com.google.samples.apps.nowinandroid.MainActivity import com.google.samples.apps.nowinandroid.R -import com.google.samples.apps.nowinandroid.core.domain.model.Topic +import com.google.samples.apps.nowinandroid.core.model.Topic import com.google.samples.apps.nowinandroid.core.domain.repository.TopicsRepository import com.google.samples.apps.nowinandroid.core.rules.GrantPostNotificationsPermissionRule import dagger.hilt.android.testing.BindValue diff --git a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/MainActivity.kt b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/MainActivity.kt index 45ef919cb..68fa8bbbd 100644 --- a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/MainActivity.kt +++ b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/MainActivity.kt @@ -44,8 +44,8 @@ import com.google.samples.apps.nowinandroid.core.analytics.LocalAnalyticsHelper import com.google.samples.apps.nowinandroid.core.data.util.NetworkMonitor import com.google.samples.apps.nowinandroid.core.data.util.TimeZoneMonitor import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme -import com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig -import com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand +import com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig +import com.google.samples.apps.nowinandroid.core.model.ThemeBrand import com.google.samples.apps.nowinandroid.core.domain.repository.UserNewsResourceRepository import com.google.samples.apps.nowinandroid.core.ui.LocalTimeZone import com.google.samples.apps.nowinandroid.ui.NiaApp diff --git a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/MainActivityViewModel.kt b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/MainActivityViewModel.kt index 14d282bd4..9f08a18ea 100644 --- a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/MainActivityViewModel.kt +++ b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/MainActivityViewModel.kt @@ -20,7 +20,7 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.google.samples.apps.nowinandroid.MainActivityUiState.Loading import com.google.samples.apps.nowinandroid.MainActivityUiState.Success -import com.google.samples.apps.nowinandroid.core.domain.model.UserData +import com.google.samples.apps.nowinandroid.core.model.UserData import com.google.samples.apps.nowinandroid.core.domain.repository.UserDataRepository import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.SharingStarted diff --git a/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeNewsRepository.kt b/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeNewsRepository.kt index a74fc02e3..a0e24dbb4 100644 --- a/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeNewsRepository.kt +++ b/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeNewsRepository.kt @@ -19,7 +19,7 @@ package com.google.samples.apps.nowinandroid.core.data.test.repository import com.google.samples.apps.nowinandroid.core.data.model.asEntity import com.google.samples.apps.nowinandroid.core.database.model.NewsResourceEntity import com.google.samples.apps.nowinandroid.core.database.model.asExternalModel -import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource +import com.google.samples.apps.nowinandroid.core.model.NewsResource import com.google.samples.apps.nowinandroid.core.domain.repository.NewsRepository import com.google.samples.apps.nowinandroid.core.domain.repository.NewsResourceQuery import com.google.samples.apps.nowinandroid.core.domain.utils.Synchronizer @@ -46,7 +46,7 @@ internal class FakeNewsRepository @Inject constructor( override fun getNewsResources( query: NewsResourceQuery, - ): Flow> = + ): Flow> = flow { emit( datasource diff --git a/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeRecentSearchRepository.kt b/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeRecentSearchRepository.kt index ca657b152..b9f7d36f0 100644 --- a/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeRecentSearchRepository.kt +++ b/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeRecentSearchRepository.kt @@ -16,7 +16,7 @@ package com.google.samples.apps.nowinandroid.core.data.test.repository -import com.google.samples.apps.nowinandroid.core.domain.model.RecentSearchQuery +import com.google.samples.apps.nowinandroid.core.model.RecentSearchQuery import com.google.samples.apps.nowinandroid.core.domain.repository.RecentSearchRepository import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf @@ -28,7 +28,7 @@ import javax.inject.Inject internal class FakeRecentSearchRepository @Inject constructor() : RecentSearchRepository { override suspend fun insertOrReplaceRecentSearch(searchQuery: String) = Unit - override fun getRecentSearchQueries(limit: Int): Flow> = + override fun getRecentSearchQueries(limit: Int): Flow> = flowOf(emptyList()) override suspend fun clearRecentSearches() = Unit diff --git a/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeSearchContentsRepository.kt b/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeSearchContentsRepository.kt index d176d97a2..a872a3ca2 100644 --- a/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeSearchContentsRepository.kt +++ b/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeSearchContentsRepository.kt @@ -16,7 +16,7 @@ package com.google.samples.apps.nowinandroid.core.data.test.repository -import com.google.samples.apps.nowinandroid.core.domain.model.SearchResult +import com.google.samples.apps.nowinandroid.core.model.SearchResult import com.google.samples.apps.nowinandroid.core.domain.repository.SearchContentsRepository import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf @@ -28,6 +28,6 @@ import javax.inject.Inject internal class FakeSearchContentsRepository @Inject constructor() : SearchContentsRepository { override suspend fun populateFtsData() = Unit - override fun searchContents(searchQuery: String): Flow = flowOf() + override fun searchContents(searchQuery: String): Flow = flowOf() override fun getSearchContentsCount(): Flow = flowOf(1) } diff --git a/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeTopicsRepository.kt b/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeTopicsRepository.kt index 0e409d7ea..3166641bb 100644 --- a/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeTopicsRepository.kt +++ b/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeTopicsRepository.kt @@ -16,7 +16,7 @@ package com.google.samples.apps.nowinandroid.core.data.test.repository -import com.google.samples.apps.nowinandroid.core.domain.model.Topic +import com.google.samples.apps.nowinandroid.core.model.Topic import com.google.samples.apps.nowinandroid.core.domain.repository.TopicsRepository import com.google.samples.apps.nowinandroid.core.domain.utils.Synchronizer import com.google.samples.apps.nowinandroid.core.network.Dispatcher @@ -40,10 +40,10 @@ internal class FakeTopicsRepository @Inject constructor( @Dispatcher(IO) private val ioDispatcher: CoroutineDispatcher, private val datasource: FakeNiaNetworkDataSource, ) : TopicsRepository { - override fun getTopics(): Flow> = flow { + override fun getTopics(): Flow> = flow { emit( datasource.getTopics().map { - Topic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = it.id, name = it.name, shortDescription = it.shortDescription, @@ -55,7 +55,7 @@ internal class FakeTopicsRepository @Inject constructor( ) }.flowOn(ioDispatcher) - override fun getTopic(id: String): Flow = getTopics() + override fun getTopic(id: String): Flow = getTopics() .map { it.first { topic -> topic.id == id } } override suspend fun syncWith(synchronizer: Synchronizer) = true diff --git a/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeUserDataRepository.kt b/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeUserDataRepository.kt index 3a408354e..5d973728e 100644 --- a/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeUserDataRepository.kt +++ b/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/repository/FakeUserDataRepository.kt @@ -17,9 +17,9 @@ package com.google.samples.apps.nowinandroid.core.data.test.repository import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesDataSource -import com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig -import com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand -import com.google.samples.apps.nowinandroid.core.domain.model.UserData +import com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig +import com.google.samples.apps.nowinandroid.core.model.ThemeBrand +import com.google.samples.apps.nowinandroid.core.model.UserData import com.google.samples.apps.nowinandroid.core.domain.repository.UserDataRepository import kotlinx.coroutines.flow.Flow import javax.inject.Inject @@ -34,7 +34,7 @@ internal class FakeUserDataRepository @Inject constructor( private val niaPreferencesDataSource: NiaPreferencesDataSource, ) : UserDataRepository { - override val userData: Flow = + override val userData: Flow = niaPreferencesDataSource.userData override suspend fun setFollowedTopicIds(followedTopicIds: Set) = @@ -50,11 +50,11 @@ internal class FakeUserDataRepository @Inject constructor( override suspend fun setNewsResourceViewed(newsResourceId: String, viewed: Boolean) = niaPreferencesDataSource.setNewsResourceViewed(newsResourceId, viewed) - override suspend fun setThemeBrand(themeBrand: ThemeBrand) { + override suspend fun setThemeBrand(themeBrand: com.google.samples.apps.nowinandroid.core.model.ThemeBrand) { niaPreferencesDataSource.setThemeBrand(themeBrand) } - override suspend fun setDarkThemeConfig(darkThemeConfig: DarkThemeConfig) { + override suspend fun setDarkThemeConfig(darkThemeConfig: com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig) { niaPreferencesDataSource.setDarkThemeConfig(darkThemeConfig) } diff --git a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/model/RecentSearchQuery.kt b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/model/RecentSearchQuery.kt index 5478572fa..127d972fa 100644 --- a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/model/RecentSearchQuery.kt +++ b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/model/RecentSearchQuery.kt @@ -17,9 +17,10 @@ package com.google.samples.apps.nowinandroid.core.data.model import com.google.samples.apps.nowinandroid.core.database.model.RecentSearchQueryEntity -import com.google.samples.apps.nowinandroid.core.domain.model.RecentSearchQuery +import com.google.samples.apps.nowinandroid.core.model.RecentSearchQuery -fun RecentSearchQueryEntity.asExternalModel() = RecentSearchQuery( - query = query, - queriedDate = queriedDate, -) +fun RecentSearchQueryEntity.asExternalModel() = + com.google.samples.apps.nowinandroid.core.model.RecentSearchQuery( + query = query, + queriedDate = queriedDate, + ) diff --git a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/CompositeUserNewsResourceRepository.kt b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/CompositeUserNewsResourceRepository.kt index d7132156a..5a160596c 100644 --- a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/CompositeUserNewsResourceRepository.kt +++ b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/CompositeUserNewsResourceRepository.kt @@ -16,8 +16,8 @@ package com.google.samples.apps.nowinandroid.core.data.repository -import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource -import com.google.samples.apps.nowinandroid.core.domain.model.mapToUserNewsResources +import com.google.samples.apps.nowinandroid.core.model.UserNewsResource +import com.google.samples.apps.nowinandroid.core.model.mapToUserNewsResources import com.google.samples.apps.nowinandroid.core.domain.repository.NewsRepository import com.google.samples.apps.nowinandroid.core.domain.repository.NewsResourceQuery import com.google.samples.apps.nowinandroid.core.domain.repository.UserDataRepository @@ -44,7 +44,7 @@ class CompositeUserNewsResourceRepository @Inject constructor( */ override fun observeAll( query: NewsResourceQuery, - ): Flow> = + ): Flow> = newsRepository.getNewsResources(query) .combine(userDataRepository.userData) { newsResources, userData -> newsResources.mapToUserNewsResources(userData) @@ -53,7 +53,7 @@ class CompositeUserNewsResourceRepository @Inject constructor( /** * Returns available news resources (joined with user data) for the followed topics. */ - override fun observeAllForFollowedTopics(): Flow> = + override fun observeAllForFollowedTopics(): Flow> = userDataRepository.userData.map { it.followedTopics }.distinctUntilChanged() .flatMapLatest { followedTopics -> when { @@ -62,7 +62,7 @@ class CompositeUserNewsResourceRepository @Inject constructor( } } - override fun observeAllBookmarked(): Flow> = + override fun observeAllBookmarked(): Flow> = userDataRepository.userData.map { it.bookmarkedNewsResources }.distinctUntilChanged() .flatMapLatest { bookmarkedNewsResources -> when { diff --git a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/DefaultRecentSearchRepository.kt b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/DefaultRecentSearchRepository.kt index 37ad8aba8..859b6d8b5 100644 --- a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/DefaultRecentSearchRepository.kt +++ b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/DefaultRecentSearchRepository.kt @@ -19,7 +19,7 @@ package com.google.samples.apps.nowinandroid.core.data.repository import com.google.samples.apps.nowinandroid.core.data.model.asExternalModel import com.google.samples.apps.nowinandroid.core.database.dao.RecentSearchQueryDao import com.google.samples.apps.nowinandroid.core.database.model.RecentSearchQueryEntity -import com.google.samples.apps.nowinandroid.core.domain.model.RecentSearchQuery +import com.google.samples.apps.nowinandroid.core.model.RecentSearchQuery import com.google.samples.apps.nowinandroid.core.domain.repository.RecentSearchRepository import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map @@ -38,7 +38,7 @@ internal class DefaultRecentSearchRepository @Inject constructor( ) } - override fun getRecentSearchQueries(limit: Int): Flow> = + override fun getRecentSearchQueries(limit: Int): Flow> = recentSearchQueryDao.getRecentSearchQueryEntities(limit).map { searchQueries -> searchQueries.map { it.asExternalModel() } } diff --git a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/DefaultSearchContentsRepository.kt b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/DefaultSearchContentsRepository.kt index d7549cb41..5f27fe21f 100644 --- a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/DefaultSearchContentsRepository.kt +++ b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/DefaultSearchContentsRepository.kt @@ -23,7 +23,7 @@ import com.google.samples.apps.nowinandroid.core.database.dao.TopicFtsDao import com.google.samples.apps.nowinandroid.core.database.model.PopulatedNewsResource import com.google.samples.apps.nowinandroid.core.database.model.asExternalModel import com.google.samples.apps.nowinandroid.core.database.model.asFtsEntity -import com.google.samples.apps.nowinandroid.core.domain.model.SearchResult +import com.google.samples.apps.nowinandroid.core.model.SearchResult import com.google.samples.apps.nowinandroid.core.domain.repository.SearchContentsRepository import com.google.samples.apps.nowinandroid.core.network.Dispatcher import com.google.samples.apps.nowinandroid.core.network.NiaDispatchers.IO @@ -59,7 +59,7 @@ internal class DefaultSearchContentsRepository @Inject constructor( } } - override fun searchContents(searchQuery: String): Flow { + override fun searchContents(searchQuery: String): Flow { // Surround the query by asterisks to match the query when it's in the middle of // a word val newsResourceIds = newsResourceFtsDao.searchAllNewsResources("*$searchQuery*") @@ -76,7 +76,7 @@ internal class DefaultSearchContentsRepository @Inject constructor( .distinctUntilChanged() .flatMapLatest(topicDao::getTopicEntities) return combine(newsResourcesFlow, topicsFlow) { newsResources, topics -> - SearchResult( + com.google.samples.apps.nowinandroid.core.model.SearchResult( topics = topics.map { it.asExternalModel() }, newsResources = newsResources.map { it.asExternalModel() }, ) diff --git a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstNewsRepository.kt b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstNewsRepository.kt index 36259aa66..087605aa6 100644 --- a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstNewsRepository.kt +++ b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstNewsRepository.kt @@ -26,8 +26,8 @@ import com.google.samples.apps.nowinandroid.core.database.model.PopulatedNewsRes import com.google.samples.apps.nowinandroid.core.database.model.TopicEntity import com.google.samples.apps.nowinandroid.core.database.model.asExternalModel import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesDataSource -import com.google.samples.apps.nowinandroid.core.domain.model.ChangeListVersions -import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource +import com.google.samples.apps.nowinandroid.core.model.ChangeListVersions +import com.google.samples.apps.nowinandroid.core.model.NewsResource import com.google.samples.apps.nowinandroid.core.domain.repository.NewsRepository import com.google.samples.apps.nowinandroid.core.domain.repository.NewsResourceQuery import com.google.samples.apps.nowinandroid.core.domain.utils.Synchronizer @@ -57,7 +57,7 @@ internal class OfflineFirstNewsRepository @Inject constructor( override fun getNewsResources( query: NewsResourceQuery, - ): Flow> = newsResourceDao.getNewsResources( + ): Flow> = newsResourceDao.getNewsResources( useFilterTopicIds = query.filterTopicIds != null, filterTopicIds = query.filterTopicIds ?: emptySet(), useFilterNewsIds = query.filterNewsIds != null, @@ -68,7 +68,7 @@ internal class OfflineFirstNewsRepository @Inject constructor( override suspend fun syncWith(synchronizer: Synchronizer): Boolean { var isFirstSync = false return synchronizer.changeListSync( - versionReader = ChangeListVersions::newsResourceVersion, + versionReader = com.google.samples.apps.nowinandroid.core.model.ChangeListVersions::newsResourceVersion, changeListFetcher = { currentVersion -> isFirstSync = currentVersion <= 0 network.getNewsResourceChangeList(after = currentVersion) diff --git a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstTopicsRepository.kt b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstTopicsRepository.kt index 0ce1659d3..ca32e0dac 100644 --- a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstTopicsRepository.kt +++ b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstTopicsRepository.kt @@ -21,8 +21,8 @@ import com.google.samples.apps.nowinandroid.core.data.util.changeListSync import com.google.samples.apps.nowinandroid.core.database.dao.TopicDao import com.google.samples.apps.nowinandroid.core.database.model.TopicEntity import com.google.samples.apps.nowinandroid.core.database.model.asExternalModel -import com.google.samples.apps.nowinandroid.core.domain.model.ChangeListVersions -import com.google.samples.apps.nowinandroid.core.domain.model.Topic +import com.google.samples.apps.nowinandroid.core.model.ChangeListVersions +import com.google.samples.apps.nowinandroid.core.model.Topic import com.google.samples.apps.nowinandroid.core.domain.repository.TopicsRepository import com.google.samples.apps.nowinandroid.core.domain.utils.Synchronizer import com.google.samples.apps.nowinandroid.core.network.NiaNetworkDataSource @@ -40,16 +40,16 @@ internal class OfflineFirstTopicsRepository @Inject constructor( private val network: NiaNetworkDataSource, ) : TopicsRepository { - override fun getTopics(): Flow> = + override fun getTopics(): Flow> = topicDao.getTopicEntities() .map { it.map(TopicEntity::asExternalModel) } - override fun getTopic(id: String): Flow = + override fun getTopic(id: String): Flow = topicDao.getTopicEntity(id).map { it.asExternalModel() } override suspend fun syncWith(synchronizer: Synchronizer): Boolean = synchronizer.changeListSync( - versionReader = ChangeListVersions::topicVersion, + versionReader = com.google.samples.apps.nowinandroid.core.model.ChangeListVersions::topicVersion, changeListFetcher = { currentVersion -> network.getTopicChangeList(after = currentVersion) }, diff --git a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstUserDataRepository.kt b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstUserDataRepository.kt index e1f04bb1c..34b230536 100644 --- a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstUserDataRepository.kt +++ b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstUserDataRepository.kt @@ -19,9 +19,9 @@ package com.google.samples.apps.nowinandroid.core.data.repository import androidx.annotation.VisibleForTesting import com.google.samples.apps.nowinandroid.core.analytics.AnalyticsHelper import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesDataSource -import com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig -import com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand -import com.google.samples.apps.nowinandroid.core.domain.model.UserData +import com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig +import com.google.samples.apps.nowinandroid.core.model.ThemeBrand +import com.google.samples.apps.nowinandroid.core.model.UserData import com.google.samples.apps.nowinandroid.core.domain.repository.UserDataRepository import kotlinx.coroutines.flow.Flow import javax.inject.Inject @@ -31,7 +31,7 @@ internal class OfflineFirstUserDataRepository @Inject constructor( private val analyticsHelper: AnalyticsHelper, ) : UserDataRepository { - override val userData: Flow = + override val userData: Flow = niaPreferencesDataSource.userData @VisibleForTesting @@ -54,12 +54,12 @@ internal class OfflineFirstUserDataRepository @Inject constructor( override suspend fun setNewsResourceViewed(newsResourceId: String, viewed: Boolean) = niaPreferencesDataSource.setNewsResourceViewed(newsResourceId, viewed) - override suspend fun setThemeBrand(themeBrand: ThemeBrand) { + override suspend fun setThemeBrand(themeBrand: com.google.samples.apps.nowinandroid.core.model.ThemeBrand) { niaPreferencesDataSource.setThemeBrand(themeBrand) analyticsHelper.logThemeChanged(themeBrand.name) } - override suspend fun setDarkThemeConfig(darkThemeConfig: DarkThemeConfig) { + override suspend fun setDarkThemeConfig(darkThemeConfig: com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig) { niaPreferencesDataSource.setDarkThemeConfig(darkThemeConfig) analyticsHelper.logDarkThemeConfigChanged(darkThemeConfig.name) } diff --git a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/util/SyncManager.kt b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/util/SyncManager.kt index e24fda9dc..81abe4dd6 100644 --- a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/util/SyncManager.kt +++ b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/util/SyncManager.kt @@ -17,7 +17,7 @@ package com.google.samples.apps.nowinandroid.core.data.util import android.util.Log -import com.google.samples.apps.nowinandroid.core.domain.model.ChangeListVersions +import com.google.samples.apps.nowinandroid.core.model.ChangeListVersions import com.google.samples.apps.nowinandroid.core.domain.utils.Synchronizer import com.google.samples.apps.nowinandroid.core.network.model.NetworkChangeList import kotlinx.coroutines.flow.Flow @@ -60,9 +60,9 @@ private suspend fun suspendRunCatching(block: suspend () -> T): Result = * implementation must guarantee this. */ suspend fun Synchronizer.changeListSync( - versionReader: (ChangeListVersions) -> Int, + versionReader: (com.google.samples.apps.nowinandroid.core.model.ChangeListVersions) -> Int, changeListFetcher: suspend (Int) -> List, - versionUpdater: ChangeListVersions.(Int) -> ChangeListVersions, + versionUpdater: com.google.samples.apps.nowinandroid.core.model.ChangeListVersions.(Int) -> com.google.samples.apps.nowinandroid.core.model.ChangeListVersions, modelDeleter: suspend (List) -> Unit, modelUpdater: suspend (List) -> Unit, ) = suspendRunCatching { diff --git a/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/CompositeUserNewsResourceRepositoryTest.kt b/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/CompositeUserNewsResourceRepositoryTest.kt index 959ad4a77..7ba571e11 100644 --- a/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/CompositeUserNewsResourceRepositoryTest.kt +++ b/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/CompositeUserNewsResourceRepositoryTest.kt @@ -17,9 +17,9 @@ package com.google.samples.apps.nowinandroid.core.data import com.google.samples.apps.nowinandroid.core.data.repository.CompositeUserNewsResourceRepository -import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource -import com.google.samples.apps.nowinandroid.core.domain.model.Topic -import com.google.samples.apps.nowinandroid.core.domain.model.mapToUserNewsResources +import com.google.samples.apps.nowinandroid.core.model.NewsResource +import com.google.samples.apps.nowinandroid.core.model.Topic +import com.google.samples.apps.nowinandroid.core.model.mapToUserNewsResources import com.google.samples.apps.nowinandroid.core.domain.repository.NewsResourceQuery import com.google.samples.apps.nowinandroid.core.testing.repository.TestNewsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository @@ -134,7 +134,7 @@ class CompositeUserNewsResourceRepositoryTest { } } -private val sampleTopic1 = Topic( +private val sampleTopic1 = com.google.samples.apps.nowinandroid.core.model.Topic( id = "Topic1", name = "Headlines", shortDescription = "", @@ -143,7 +143,7 @@ private val sampleTopic1 = Topic( imageUrl = "image URL", ) -private val sampleTopic2 = Topic( +private val sampleTopic2 = com.google.samples.apps.nowinandroid.core.model.Topic( id = "Topic2", name = "UI", shortDescription = "", @@ -153,7 +153,7 @@ private val sampleTopic2 = Topic( ) private val sampleNewsResources = listOf( - NewsResource( + com.google.samples.apps.nowinandroid.core.model.NewsResource( id = "1", title = "Thanks for helping us reach 1M YouTube Subscribers", content = "Thank you everyone for following the Now in Android series and everything the " + @@ -166,7 +166,7 @@ private val sampleNewsResources = listOf( type = "Video 📺", topics = listOf(sampleTopic1), ), - NewsResource( + com.google.samples.apps.nowinandroid.core.model.NewsResource( id = "2", title = "Transformations and customisations in the Paging Library", content = "A demonstration of different operations that can be performed with Paging. " + @@ -178,7 +178,7 @@ private val sampleNewsResources = listOf( type = "Video 📺", topics = listOf(sampleTopic1, sampleTopic2), ), - NewsResource( + com.google.samples.apps.nowinandroid.core.model.NewsResource( id = "3", title = "Community tip on Paging", content = "Tips for using the Paging library from the developer community", diff --git a/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/UserNewsResourceTest.kt b/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/UserNewsResourceTest.kt index 943078b29..b53e9e62e 100644 --- a/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/UserNewsResourceTest.kt +++ b/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/UserNewsResourceTest.kt @@ -16,13 +16,13 @@ package com.google.samples.apps.nowinandroid.core.data -import com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig.FOLLOW_SYSTEM -import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic -import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource -import com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand.DEFAULT -import com.google.samples.apps.nowinandroid.core.domain.model.Topic -import com.google.samples.apps.nowinandroid.core.domain.model.UserData -import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource +import com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig.FOLLOW_SYSTEM +import com.google.samples.apps.nowinandroid.core.model.FollowableTopic +import com.google.samples.apps.nowinandroid.core.model.NewsResource +import com.google.samples.apps.nowinandroid.core.model.ThemeBrand.DEFAULT +import com.google.samples.apps.nowinandroid.core.model.Topic +import com.google.samples.apps.nowinandroid.core.model.UserData +import com.google.samples.apps.nowinandroid.core.model.UserNewsResource import kotlinx.datetime.Clock.System import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue @@ -37,7 +37,7 @@ class UserNewsResourceTest { */ @Test fun userNewsResourcesAreConstructedFromNewsResourcesAndUserData() { - val newsResource1 = NewsResource( + val newsResource1 = com.google.samples.apps.nowinandroid.core.model.NewsResource( id = "N1", title = "Test news title", content = "Test news content", @@ -46,7 +46,7 @@ class UserNewsResourceTest { publishDate = System.now(), type = "Article 📚", topics = listOf( - Topic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "T1", name = "Topic 1", shortDescription = "Topic 1 short description", @@ -54,7 +54,7 @@ class UserNewsResourceTest { url = "Topic 1 URL", imageUrl = "Topic 1 image URL", ), - Topic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "T2", name = "Topic 2", shortDescription = "Topic 2 short description", @@ -65,7 +65,7 @@ class UserNewsResourceTest { ), ) - val userData = UserData( + val userData = com.google.samples.apps.nowinandroid.core.model.UserData( bookmarkedNewsResources = setOf("N1"), viewedNewsResources = setOf("N1"), followedTopics = setOf("T1"), @@ -75,7 +75,10 @@ class UserNewsResourceTest { shouldHideOnboarding = true, ) - val userNewsResource = UserNewsResource(newsResource1, userData) + val userNewsResource = com.google.samples.apps.nowinandroid.core.model.UserNewsResource( + newsResource1, + userData + ) // Check that the simple field mappings have been done correctly. assertEquals(newsResource1.id, userNewsResource.id) @@ -89,7 +92,7 @@ class UserNewsResourceTest { assertEquals(newsResource1.topics.size, userNewsResource.followableTopics.size) for (topic in newsResource1.topics) { // Construct the expected FollowableTopic. - val followableTopic = FollowableTopic( + val followableTopic = com.google.samples.apps.nowinandroid.core.model.FollowableTopic( topic = topic, isFollowed = topic.id in userData.followedTopics, ) diff --git a/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstNewsRepositoryTest.kt b/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstNewsRepositoryTest.kt index a02835ffa..76259dc0b 100644 --- a/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstNewsRepositoryTest.kt +++ b/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstNewsRepositoryTest.kt @@ -32,8 +32,8 @@ import com.google.samples.apps.nowinandroid.core.database.model.TopicEntity import com.google.samples.apps.nowinandroid.core.database.model.asExternalModel import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesDataSource import com.google.samples.apps.nowinandroid.core.datastore.test.testUserPreferencesDataStore -import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource -import com.google.samples.apps.nowinandroid.core.domain.model.Topic +import com.google.samples.apps.nowinandroid.core.model.NewsResource +import com.google.samples.apps.nowinandroid.core.model.Topic import com.google.samples.apps.nowinandroid.core.domain.repository.NewsResourceQuery import com.google.samples.apps.nowinandroid.core.domain.utils.Synchronizer import com.google.samples.apps.nowinandroid.core.network.model.NetworkChangeList @@ -150,8 +150,8 @@ class OfflineFirstNewsRepositoryTest { .map(PopulatedNewsResource::asExternalModel) assertEquals( - newsResourcesFromNetwork.map(NewsResource::id).sorted(), - newsResourcesFromDb.map(NewsResource::id).sorted(), + newsResourcesFromNetwork.map(com.google.samples.apps.nowinandroid.core.model.NewsResource::id).sorted(), + newsResourcesFromDb.map(com.google.samples.apps.nowinandroid.core.model.NewsResource::id).sorted(), ) // After sync version should be updated @@ -176,7 +176,7 @@ class OfflineFirstNewsRepositoryTest { // Delete half of the items on the network val deletedItems = newsResourcesFromNetwork - .map(NewsResource::id) + .map(com.google.samples.apps.nowinandroid.core.model.NewsResource::id) .partition { it.chars().sum() % 2 == 0 } .first .toSet() @@ -197,8 +197,8 @@ class OfflineFirstNewsRepositoryTest { // Assert that items marked deleted on the network have been deleted locally assertEquals( - expected = (newsResourcesFromNetwork.map(NewsResource::id) - deletedItems).sorted(), - actual = newsResourcesFromDb.map(NewsResource::id).sorted(), + expected = (newsResourcesFromNetwork.map(com.google.samples.apps.nowinandroid.core.model.NewsResource::id) - deletedItems).sorted(), + actual = newsResourcesFromDb.map(com.google.samples.apps.nowinandroid.core.model.NewsResource::id).sorted(), ) // After sync version should be updated @@ -242,8 +242,8 @@ class OfflineFirstNewsRepositoryTest { .map(PopulatedNewsResource::asExternalModel) assertEquals( - expected = newsResourcesFromNetwork.map(NewsResource::id).sorted(), - actual = newsResourcesFromDb.map(NewsResource::id).sorted(), + expected = newsResourcesFromNetwork.map(com.google.samples.apps.nowinandroid.core.model.NewsResource::id).sorted(), + actual = newsResourcesFromDb.map(com.google.samples.apps.nowinandroid.core.model.NewsResource::id).sorted(), ) // After sync version should be updated @@ -349,7 +349,7 @@ class OfflineFirstNewsRepositoryTest { // that the user follows assertEquals( expected = followedNewsResourceIdsFromNetwork, - actual = notifier.addedNewsResources.first().map(NewsResource::id).sorted(), + actual = notifier.addedNewsResources.first().map(com.google.samples.apps.nowinandroid.core.model.NewsResource::id).sorted(), ) } @@ -369,8 +369,8 @@ class OfflineFirstNewsRepositoryTest { newsResourceDao.upsertNewsResources(networkNewsResources) val followedTopicIds = newsResources - .flatMap(NewsResource::topics) - .map(Topic::id) + .flatMap(com.google.samples.apps.nowinandroid.core.model.NewsResource::topics) + .map(com.google.samples.apps.nowinandroid.core.model.Topic::id) .toSet() // Follow all topics diff --git a/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstTopicsRepositoryTest.kt b/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstTopicsRepositoryTest.kt index ea4a90a0d..e287a5b94 100644 --- a/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstTopicsRepositoryTest.kt +++ b/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstTopicsRepositoryTest.kt @@ -25,7 +25,7 @@ import com.google.samples.apps.nowinandroid.core.database.model.TopicEntity import com.google.samples.apps.nowinandroid.core.database.model.asExternalModel import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesDataSource import com.google.samples.apps.nowinandroid.core.datastore.test.testUserPreferencesDataStore -import com.google.samples.apps.nowinandroid.core.domain.model.Topic +import com.google.samples.apps.nowinandroid.core.model.Topic import com.google.samples.apps.nowinandroid.core.domain.utils.Synchronizer import com.google.samples.apps.nowinandroid.core.network.model.NetworkTopic import kotlinx.coroutines.flow.first @@ -144,7 +144,7 @@ class OfflineFirstTopicsRepositoryTest { // Delete half of the items on the network val deletedItems = networkTopics - .map(Topic::id) + .map(com.google.samples.apps.nowinandroid.core.model.Topic::id) .partition { it.chars().sum() % 2 == 0 } .first .toSet() @@ -165,8 +165,8 @@ class OfflineFirstTopicsRepositoryTest { // Assert that items marked deleted on the network have been deleted locally assertEquals( - networkTopics.map(Topic::id) - deletedItems, - dbTopics.map(Topic::id), + networkTopics.map(com.google.samples.apps.nowinandroid.core.model.Topic::id) - deletedItems, + dbTopics.map(com.google.samples.apps.nowinandroid.core.model.Topic::id), ) // After sync version should be updated diff --git a/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstUserDataRepositoryTest.kt b/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstUserDataRepositoryTest.kt index a7a2e2a9e..ba9de79dc 100644 --- a/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstUserDataRepositoryTest.kt +++ b/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/OfflineFirstUserDataRepositoryTest.kt @@ -19,11 +19,11 @@ package com.google.samples.apps.nowinandroid.core.data.repository import com.google.samples.apps.nowinandroid.core.analytics.NoOpAnalyticsHelper import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesDataSource import com.google.samples.apps.nowinandroid.core.datastore.test.testUserPreferencesDataStore -import com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig -import com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig.FOLLOW_SYSTEM -import com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand -import com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand.DEFAULT -import com.google.samples.apps.nowinandroid.core.domain.model.UserData +import com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig +import com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig.FOLLOW_SYSTEM +import com.google.samples.apps.nowinandroid.core.model.ThemeBrand +import com.google.samples.apps.nowinandroid.core.model.ThemeBrand.DEFAULT +import com.google.samples.apps.nowinandroid.core.model.UserData import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.map import kotlinx.coroutines.test.TestScope @@ -66,7 +66,7 @@ class OfflineFirstUserDataRepositoryTest { fun offlineFirstUserDataRepository_default_user_data_is_correct() = testScope.runTest { assertEquals( - UserData( + com.google.samples.apps.nowinandroid.core.model.UserData( bookmarkedNewsResources = emptySet(), viewedNewsResources = emptySet(), followedTopics = emptySet(), @@ -197,16 +197,16 @@ class OfflineFirstUserDataRepositoryTest { @Test fun offlineFirstUserDataRepository_set_theme_brand_delegates_to_nia_preferences() = testScope.runTest { - subject.setThemeBrand(ThemeBrand.ANDROID) + subject.setThemeBrand(com.google.samples.apps.nowinandroid.core.model.ThemeBrand.ANDROID) assertEquals( - ThemeBrand.ANDROID, + com.google.samples.apps.nowinandroid.core.model.ThemeBrand.ANDROID, subject.userData .map { it.themeBrand } .first(), ) assertEquals( - ThemeBrand.ANDROID, + com.google.samples.apps.nowinandroid.core.model.ThemeBrand.ANDROID, niaPreferencesDataSource .userData .map { it.themeBrand } @@ -237,16 +237,16 @@ class OfflineFirstUserDataRepositoryTest { @Test fun offlineFirstUserDataRepository_set_dark_theme_config_delegates_to_nia_preferences() = testScope.runTest { - subject.setDarkThemeConfig(DarkThemeConfig.DARK) + subject.setDarkThemeConfig(com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig.DARK) assertEquals( - DarkThemeConfig.DARK, + com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig.DARK, subject.userData .map { it.darkThemeConfig } .first(), ) assertEquals( - DarkThemeConfig.DARK, + com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig.DARK, niaPreferencesDataSource .userData .map { it.darkThemeConfig } diff --git a/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/TestSynchronizer.kt b/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/TestSynchronizer.kt index 29ac1f755..6742aab67 100644 --- a/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/TestSynchronizer.kt +++ b/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/TestSynchronizer.kt @@ -17,7 +17,7 @@ package com.google.samples.apps.nowinandroid.core.data.repository import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesDataSource -import com.google.samples.apps.nowinandroid.core.domain.model.ChangeListVersions +import com.google.samples.apps.nowinandroid.core.model.ChangeListVersions import com.google.samples.apps.nowinandroid.core.domain.utils.Synchronizer /** @@ -26,10 +26,10 @@ import com.google.samples.apps.nowinandroid.core.domain.utils.Synchronizer class TestSynchronizer( private val niaPreferences: NiaPreferencesDataSource, ) : Synchronizer { - override suspend fun getChangeListVersions(): ChangeListVersions = + override suspend fun getChangeListVersions(): com.google.samples.apps.nowinandroid.core.model.ChangeListVersions = niaPreferences.getChangeListVersions() override suspend fun updateChangeListVersions( - update: ChangeListVersions.() -> ChangeListVersions, + update: com.google.samples.apps.nowinandroid.core.model.ChangeListVersions.() -> com.google.samples.apps.nowinandroid.core.model.ChangeListVersions, ) = niaPreferences.updateChangeListVersion(update) } diff --git a/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/database/model/PopulatedNewsResourceKtTest.kt b/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/database/model/PopulatedNewsResourceKtTest.kt index 0f9e01659..c73b9b15f 100644 --- a/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/database/model/PopulatedNewsResourceKtTest.kt +++ b/core/data/src/test/kotlin/com/google/samples/apps/nowinandroid/core/database/model/PopulatedNewsResourceKtTest.kt @@ -16,8 +16,8 @@ package com.google.samples.apps.nowinandroid.core.database.model -import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource -import com.google.samples.apps.nowinandroid.core.domain.model.Topic +import com.google.samples.apps.nowinandroid.core.model.NewsResource +import com.google.samples.apps.nowinandroid.core.model.Topic import kotlinx.datetime.Instant import org.junit.Test import kotlin.test.assertEquals @@ -49,7 +49,7 @@ class PopulatedNewsResourceKtTest { val newsResource = populatedNewsResource.asExternalModel() assertEquals( - NewsResource( + com.google.samples.apps.nowinandroid.core.model.NewsResource( id = "1", title = "news", content = "Hilt", @@ -58,7 +58,7 @@ class PopulatedNewsResourceKtTest { type = "Video 📺", publishDate = Instant.fromEpochMilliseconds(1), topics = listOf( - Topic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "3", name = "name", shortDescription = "short description", diff --git a/core/database/build.gradle.kts b/core/database/build.gradle.kts index 5bd5bfc6e..4a6bcb66a 100644 --- a/core/database/build.gradle.kts +++ b/core/database/build.gradle.kts @@ -30,7 +30,7 @@ android { } dependencies { - api(projects.core.domain) + api(projects.core.model) implementation(libs.kotlinx.datetime) diff --git a/core/database/src/main/kotlin/com/google/samples/apps/nowinandroid/core/database/model/NewsResourceEntity.kt b/core/database/src/main/kotlin/com/google/samples/apps/nowinandroid/core/database/model/NewsResourceEntity.kt index 15d317d6f..f1f2cbbbc 100644 --- a/core/database/src/main/kotlin/com/google/samples/apps/nowinandroid/core/database/model/NewsResourceEntity.kt +++ b/core/database/src/main/kotlin/com/google/samples/apps/nowinandroid/core/database/model/NewsResourceEntity.kt @@ -19,7 +19,7 @@ package com.google.samples.apps.nowinandroid.core.database.model import androidx.room.ColumnInfo import androidx.room.Entity import androidx.room.PrimaryKey -import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource +import com.google.samples.apps.nowinandroid.core.model.NewsResource import kotlinx.datetime.Instant /** @@ -42,7 +42,7 @@ data class NewsResourceEntity( ) fun NewsResourceEntity.asExternalModel() = - com.google.samples.apps.nowinandroid.core.domain.model.NewsResource( + com.google.samples.apps.nowinandroid.core.model.NewsResource( id = id, title = title, content = content, diff --git a/core/database/src/main/kotlin/com/google/samples/apps/nowinandroid/core/database/model/PopulatedNewsResource.kt b/core/database/src/main/kotlin/com/google/samples/apps/nowinandroid/core/database/model/PopulatedNewsResource.kt index 7bc347b22..1ff963827 100644 --- a/core/database/src/main/kotlin/com/google/samples/apps/nowinandroid/core/database/model/PopulatedNewsResource.kt +++ b/core/database/src/main/kotlin/com/google/samples/apps/nowinandroid/core/database/model/PopulatedNewsResource.kt @@ -19,7 +19,7 @@ package com.google.samples.apps.nowinandroid.core.database.model import androidx.room.Embedded import androidx.room.Junction import androidx.room.Relation -import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource +import com.google.samples.apps.nowinandroid.core.model.NewsResource /** * External data layer representation of a fully populated NiA news resource @@ -40,7 +40,7 @@ data class PopulatedNewsResource( ) fun PopulatedNewsResource.asExternalModel() = - com.google.samples.apps.nowinandroid.core.domain.model.NewsResource( + com.google.samples.apps.nowinandroid.core.model.NewsResource( id = entity.id, title = entity.title, content = entity.content, diff --git a/core/database/src/main/kotlin/com/google/samples/apps/nowinandroid/core/database/model/TopicEntity.kt b/core/database/src/main/kotlin/com/google/samples/apps/nowinandroid/core/database/model/TopicEntity.kt index 210b38e6c..4a76c0183 100644 --- a/core/database/src/main/kotlin/com/google/samples/apps/nowinandroid/core/database/model/TopicEntity.kt +++ b/core/database/src/main/kotlin/com/google/samples/apps/nowinandroid/core/database/model/TopicEntity.kt @@ -19,7 +19,7 @@ package com.google.samples.apps.nowinandroid.core.database.model import androidx.room.ColumnInfo import androidx.room.Entity import androidx.room.PrimaryKey -import com.google.samples.apps.nowinandroid.core.domain.model.Topic +import com.google.samples.apps.nowinandroid.core.model.Topic /** * Defines a topic a user may follow. @@ -41,7 +41,7 @@ data class TopicEntity( val imageUrl: String, ) -fun TopicEntity.asExternalModel() = com.google.samples.apps.nowinandroid.core.domain.model.Topic( +fun TopicEntity.asExternalModel() = com.google.samples.apps.nowinandroid.core.model.Topic( id = id, name = name, shortDescription = shortDescription, diff --git a/core/datastore/build.gradle.kts b/core/datastore/build.gradle.kts index b2d8af51d..34ea5ee78 100644 --- a/core/datastore/build.gradle.kts +++ b/core/datastore/build.gradle.kts @@ -35,7 +35,7 @@ android { dependencies { api(libs.androidx.dataStore.core) api(projects.core.datastoreProto) - api(projects.core.domain) + api(projects.core.model) implementation(projects.core.common) diff --git a/core/datastore/src/main/kotlin/com/google/samples/apps/nowinandroid/core/datastore/NiaPreferencesDataSource.kt b/core/datastore/src/main/kotlin/com/google/samples/apps/nowinandroid/core/datastore/NiaPreferencesDataSource.kt index 3c3de5eb2..ed0aff688 100644 --- a/core/datastore/src/main/kotlin/com/google/samples/apps/nowinandroid/core/datastore/NiaPreferencesDataSource.kt +++ b/core/datastore/src/main/kotlin/com/google/samples/apps/nowinandroid/core/datastore/NiaPreferencesDataSource.kt @@ -26,10 +26,10 @@ import com.google.samples.apps.nowinandroid.core.datastore.ThemeBrandProto.THEME import com.google.samples.apps.nowinandroid.core.datastore.ThemeBrandProto.THEME_BRAND_DEFAULT import com.google.samples.apps.nowinandroid.core.datastore.ThemeBrandProto.THEME_BRAND_UNSPECIFIED import com.google.samples.apps.nowinandroid.core.datastore.ThemeBrandProto.UNRECOGNIZED -import com.google.samples.apps.nowinandroid.core.domain.model.ChangeListVersions -import com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig -import com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand -import com.google.samples.apps.nowinandroid.core.domain.model.UserData +import com.google.samples.apps.nowinandroid.core.model.ChangeListVersions +import com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig +import com.google.samples.apps.nowinandroid.core.model.ThemeBrand +import com.google.samples.apps.nowinandroid.core.model.UserData import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.flow.map import java.io.IOException @@ -40,7 +40,7 @@ class NiaPreferencesDataSource @Inject constructor( ) { val userData = userPreferences.data .map { - com.google.samples.apps.nowinandroid.core.domain.model.UserData( + com.google.samples.apps.nowinandroid.core.model.UserData( bookmarkedNewsResources = it.bookmarkedNewsResourceIdsMap.keys, viewedNewsResources = it.viewedNewsResourceIdsMap.keys, followedTopics = it.followedTopicIdsMap.keys, @@ -49,9 +49,9 @@ class NiaPreferencesDataSource @Inject constructor( THEME_BRAND_UNSPECIFIED, UNRECOGNIZED, THEME_BRAND_DEFAULT, - -> com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand.DEFAULT + -> com.google.samples.apps.nowinandroid.core.model.ThemeBrand.DEFAULT - THEME_BRAND_ANDROID -> com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand.ANDROID + THEME_BRAND_ANDROID -> com.google.samples.apps.nowinandroid.core.model.ThemeBrand.ANDROID }, darkThemeConfig = when (it.darkThemeConfig) { null, @@ -59,12 +59,12 @@ class NiaPreferencesDataSource @Inject constructor( DarkThemeConfigProto.UNRECOGNIZED, DARK_THEME_CONFIG_FOLLOW_SYSTEM, -> - com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig.FOLLOW_SYSTEM + com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig.FOLLOW_SYSTEM DARK_THEME_CONFIG_LIGHT -> - com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig.LIGHT + com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig.LIGHT - DARK_THEME_CONFIG_DARK -> com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig.DARK + DARK_THEME_CONFIG_DARK -> com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig.DARK }, useDynamicColor = it.useDynamicColor, shouldHideOnboarding = it.shouldHideOnboarding, @@ -102,12 +102,12 @@ class NiaPreferencesDataSource @Inject constructor( } } - suspend fun setThemeBrand(themeBrand: com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand) { + suspend fun setThemeBrand(themeBrand: com.google.samples.apps.nowinandroid.core.model.ThemeBrand) { userPreferences.updateData { it.copy { this.themeBrand = when (themeBrand) { - com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand.DEFAULT -> ThemeBrandProto.THEME_BRAND_DEFAULT - com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand.ANDROID -> ThemeBrandProto.THEME_BRAND_ANDROID + com.google.samples.apps.nowinandroid.core.model.ThemeBrand.DEFAULT -> ThemeBrandProto.THEME_BRAND_DEFAULT + com.google.samples.apps.nowinandroid.core.model.ThemeBrand.ANDROID -> ThemeBrandProto.THEME_BRAND_ANDROID } } } @@ -119,14 +119,14 @@ class NiaPreferencesDataSource @Inject constructor( } } - suspend fun setDarkThemeConfig(darkThemeConfig: com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig) { + suspend fun setDarkThemeConfig(darkThemeConfig: com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig) { userPreferences.updateData { it.copy { this.darkThemeConfig = when (darkThemeConfig) { - com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig.FOLLOW_SYSTEM -> + com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig.FOLLOW_SYSTEM -> DarkThemeConfigProto.DARK_THEME_CONFIG_FOLLOW_SYSTEM - com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig.LIGHT -> DarkThemeConfigProto.DARK_THEME_CONFIG_LIGHT - com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig.DARK -> DarkThemeConfigProto.DARK_THEME_CONFIG_DARK + com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig.LIGHT -> DarkThemeConfigProto.DARK_THEME_CONFIG_LIGHT + com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig.DARK -> DarkThemeConfigProto.DARK_THEME_CONFIG_DARK } } } @@ -168,21 +168,21 @@ class NiaPreferencesDataSource @Inject constructor( suspend fun getChangeListVersions() = userPreferences.data .map { - ChangeListVersions( + com.google.samples.apps.nowinandroid.core.model.ChangeListVersions( topicVersion = it.topicChangeListVersion, newsResourceVersion = it.newsResourceChangeListVersion, ) } - .firstOrNull() ?: ChangeListVersions() + .firstOrNull() ?: com.google.samples.apps.nowinandroid.core.model.ChangeListVersions() /** * Update the [ChangeListVersions] using [update]. */ - suspend fun updateChangeListVersion(update: ChangeListVersions.() -> ChangeListVersions) { + suspend fun updateChangeListVersion(update: com.google.samples.apps.nowinandroid.core.model.ChangeListVersions.() -> com.google.samples.apps.nowinandroid.core.model.ChangeListVersions) { try { userPreferences.updateData { currentPreferences -> val updatedChangeListVersions = update( - ChangeListVersions( + com.google.samples.apps.nowinandroid.core.model.ChangeListVersions( topicVersion = currentPreferences.topicChangeListVersion, newsResourceVersion = currentPreferences.newsResourceChangeListVersion, ), diff --git a/core/domain/build.gradle.kts b/core/domain/build.gradle.kts index 64dcc21ab..2cd419736 100644 --- a/core/domain/build.gradle.kts +++ b/core/domain/build.gradle.kts @@ -25,6 +25,7 @@ android { dependencies { api(libs.kotlinx.datetime) + implementation(projects.core.model) implementation(libs.javax.inject) diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/NewsRepository.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/NewsRepository.kt index d1a02c18a..9288e3b6a 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/NewsRepository.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/NewsRepository.kt @@ -16,7 +16,7 @@ package com.google.samples.apps.nowinandroid.core.domain.repository -import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource +import com.google.samples.apps.nowinandroid.core.model.NewsResource import com.google.samples.apps.nowinandroid.core.domain.utils.Syncable import kotlinx.coroutines.flow.Flow @@ -46,5 +46,5 @@ interface NewsRepository : Syncable { filterTopicIds = null, filterNewsIds = null, ), - ): Flow> + ): Flow> } diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/RecentSearchRepository.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/RecentSearchRepository.kt index e0dfcd61d..a4f76cae7 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/RecentSearchRepository.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/RecentSearchRepository.kt @@ -16,7 +16,7 @@ package com.google.samples.apps.nowinandroid.core.domain.repository -import com.google.samples.apps.nowinandroid.core.domain.model.RecentSearchQuery +import com.google.samples.apps.nowinandroid.core.model.RecentSearchQuery import kotlinx.coroutines.flow.Flow /** @@ -27,7 +27,7 @@ interface RecentSearchRepository { /** * Get the recent search queries up to the number of queries specified as [limit]. */ - fun getRecentSearchQueries(limit: Int): Flow> + fun getRecentSearchQueries(limit: Int): Flow> /** * Insert or replace the [searchQuery] as part of the recent searches. diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/SearchContentsRepository.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/SearchContentsRepository.kt index 0bdec046c..7df002d1d 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/SearchContentsRepository.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/SearchContentsRepository.kt @@ -16,7 +16,7 @@ package com.google.samples.apps.nowinandroid.core.domain.repository -import com.google.samples.apps.nowinandroid.core.domain.model.SearchResult +import com.google.samples.apps.nowinandroid.core.model.SearchResult import kotlinx.coroutines.flow.Flow /** @@ -32,7 +32,7 @@ interface SearchContentsRepository { /** * Query the contents matched with the [searchQuery] and returns it as a [Flow] of [SearchResult] */ - fun searchContents(searchQuery: String): Flow + fun searchContents(searchQuery: String): Flow fun getSearchContentsCount(): Flow } diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/TopicsRepository.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/TopicsRepository.kt index d807607d5..bf80b2a79 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/TopicsRepository.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/TopicsRepository.kt @@ -16,7 +16,7 @@ package com.google.samples.apps.nowinandroid.core.domain.repository -import com.google.samples.apps.nowinandroid.core.domain.model.Topic +import com.google.samples.apps.nowinandroid.core.model.Topic import com.google.samples.apps.nowinandroid.core.domain.utils.Syncable import kotlinx.coroutines.flow.Flow @@ -24,10 +24,10 @@ interface TopicsRepository : Syncable { /** * Gets the available topics as a stream */ - fun getTopics(): Flow> + fun getTopics(): Flow> /** * Gets data for a specific topic */ - fun getTopic(id: String): Flow + fun getTopic(id: String): Flow } diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/UserDataRepository.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/UserDataRepository.kt index 68e1c586d..74206144d 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/UserDataRepository.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/UserDataRepository.kt @@ -16,9 +16,9 @@ package com.google.samples.apps.nowinandroid.core.domain.repository -import com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig -import com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand -import com.google.samples.apps.nowinandroid.core.domain.model.UserData +import com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig +import com.google.samples.apps.nowinandroid.core.model.ThemeBrand +import com.google.samples.apps.nowinandroid.core.model.UserData import kotlinx.coroutines.flow.Flow interface UserDataRepository { @@ -26,7 +26,7 @@ interface UserDataRepository { /** * Stream of [UserData] */ - val userData: Flow + val userData: Flow /** * Sets the user's currently followed topics @@ -51,12 +51,12 @@ interface UserDataRepository { /** * Sets the desired theme brand. */ - suspend fun setThemeBrand(themeBrand: ThemeBrand) + suspend fun setThemeBrand(themeBrand: com.google.samples.apps.nowinandroid.core.model.ThemeBrand) /** * Sets the desired dark theme config. */ - suspend fun setDarkThemeConfig(darkThemeConfig: DarkThemeConfig) + suspend fun setDarkThemeConfig(darkThemeConfig: com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig) /** * Sets the preferred dynamic color config. diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/UserNewsResourceRepository.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/UserNewsResourceRepository.kt index 170e66876..e67d607d9 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/UserNewsResourceRepository.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/UserNewsResourceRepository.kt @@ -16,7 +16,7 @@ package com.google.samples.apps.nowinandroid.core.domain.repository -import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource +import com.google.samples.apps.nowinandroid.core.model.UserNewsResource import kotlinx.coroutines.flow.Flow /** @@ -31,15 +31,15 @@ interface UserNewsResourceRepository { filterTopicIds = null, filterNewsIds = null, ), - ): Flow> + ): Flow> /** * Returns available news resources for the user's followed topics as a stream. */ - fun observeAllForFollowedTopics(): Flow> + fun observeAllForFollowedTopics(): Flow> /** * Returns the user's bookmarked news resources as a stream. */ - fun observeAllBookmarked(): Flow> + fun observeAllBookmarked(): Flow> } diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetFollowableTopicsUseCase.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetFollowableTopicsUseCase.kt index 462bb45b1..c96dbbfbd 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetFollowableTopicsUseCase.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetFollowableTopicsUseCase.kt @@ -16,7 +16,7 @@ package com.google.samples.apps.nowinandroid.core.domain.usecase -import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic +import com.google.samples.apps.nowinandroid.core.model.FollowableTopic import com.google.samples.apps.nowinandroid.core.domain.repository.TopicsRepository import com.google.samples.apps.nowinandroid.core.domain.repository.UserDataRepository import com.google.samples.apps.nowinandroid.core.domain.usecase.TopicSortField.NAME @@ -37,13 +37,13 @@ class GetFollowableTopicsUseCase @Inject constructor( * * @param sortBy - the field used to sort the topics. Default NONE = no sorting. */ - operator fun invoke(sortBy: TopicSortField = NONE): Flow> = combine( + operator fun invoke(sortBy: TopicSortField = NONE): Flow> = combine( userDataRepository.userData, topicsRepository.getTopics(), ) { userData, topics -> val followedTopics = topics .map { topic -> - FollowableTopic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( topic = topic, isFollowed = topic.id in userData.followedTopics, ) diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetRecentSearchQueriesUseCase.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetRecentSearchQueriesUseCase.kt index d57ef6c1c..471f0d8e5 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetRecentSearchQueriesUseCase.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetRecentSearchQueriesUseCase.kt @@ -16,7 +16,7 @@ package com.google.samples.apps.nowinandroid.core.domain.usecase -import com.google.samples.apps.nowinandroid.core.domain.model.RecentSearchQuery +import com.google.samples.apps.nowinandroid.core.model.RecentSearchQuery import com.google.samples.apps.nowinandroid.core.domain.repository.RecentSearchRepository import kotlinx.coroutines.flow.Flow import javax.inject.Inject @@ -27,6 +27,6 @@ import javax.inject.Inject class GetRecentSearchQueriesUseCase @Inject constructor( private val recentSearchRepository: RecentSearchRepository, ) { - operator fun invoke(limit: Int = 10): Flow> = + operator fun invoke(limit: Int = 10): Flow> = recentSearchRepository.getRecentSearchQueries(limit) } diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetSearchContentsUseCase.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetSearchContentsUseCase.kt index c5c707b60..d531d9257 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetSearchContentsUseCase.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetSearchContentsUseCase.kt @@ -16,11 +16,11 @@ package com.google.samples.apps.nowinandroid.core.domain.usecase -import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic -import com.google.samples.apps.nowinandroid.core.domain.model.SearchResult -import com.google.samples.apps.nowinandroid.core.domain.model.UserData -import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource -import com.google.samples.apps.nowinandroid.core.domain.model.UserSearchResult +import com.google.samples.apps.nowinandroid.core.model.FollowableTopic +import com.google.samples.apps.nowinandroid.core.model.SearchResult +import com.google.samples.apps.nowinandroid.core.model.UserData +import com.google.samples.apps.nowinandroid.core.model.UserNewsResource +import com.google.samples.apps.nowinandroid.core.model.UserSearchResult import com.google.samples.apps.nowinandroid.core.domain.repository.SearchContentsRepository import com.google.samples.apps.nowinandroid.core.domain.repository.UserDataRepository import kotlinx.coroutines.flow.Flow @@ -37,22 +37,22 @@ class GetSearchContentsUseCase @Inject constructor( operator fun invoke( searchQuery: String, - ): Flow = + ): Flow = searchContentsRepository.searchContents(searchQuery) .mapToUserSearchResult(userDataRepository.userData) } -private fun Flow.mapToUserSearchResult(userDataStream: Flow): Flow = +private fun Flow.mapToUserSearchResult(userDataStream: Flow): Flow = combine(userDataStream) { searchResult, userData -> - UserSearchResult( + com.google.samples.apps.nowinandroid.core.model.UserSearchResult( topics = searchResult.topics.map { topic -> - FollowableTopic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( topic = topic, isFollowed = topic.id in userData.followedTopics, ) }, newsResources = searchResult.newsResources.map { news -> - UserNewsResource( + com.google.samples.apps.nowinandroid.core.model.UserNewsResource( newsResource = news, userData = userData, ) diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/utils/SyncUtilities.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/utils/SyncUtilities.kt index 3a686fab6..30a465e2e 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/utils/SyncUtilities.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/utils/SyncUtilities.kt @@ -16,7 +16,7 @@ package com.google.samples.apps.nowinandroid.core.domain.utils -import com.google.samples.apps.nowinandroid.core.domain.model.ChangeListVersions +import com.google.samples.apps.nowinandroid.core.model.ChangeListVersions import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine @@ -25,9 +25,9 @@ import kotlinx.coroutines.flow.combine * source for a [Syncable]. */ interface Synchronizer { - suspend fun getChangeListVersions(): ChangeListVersions + suspend fun getChangeListVersions(): com.google.samples.apps.nowinandroid.core.model.ChangeListVersions - suspend fun updateChangeListVersions(update: ChangeListVersions.() -> ChangeListVersions) + suspend fun updateChangeListVersions(update: com.google.samples.apps.nowinandroid.core.model.ChangeListVersions.() -> com.google.samples.apps.nowinandroid.core.model.ChangeListVersions) /** * Syntactic sugar to call [Syncable.syncWith] while omitting the synchronizer argument diff --git a/core/domain/src/test/kotlin/com/google/samples/apps/nowinandroid/core/domain/GetFollowableTopicsUseCaseTest.kt b/core/domain/src/test/kotlin/com/google/samples/apps/nowinandroid/core/domain/GetFollowableTopicsUseCaseTest.kt index b218b170e..57191012b 100644 --- a/core/domain/src/test/kotlin/com/google/samples/apps/nowinandroid/core/domain/GetFollowableTopicsUseCaseTest.kt +++ b/core/domain/src/test/kotlin/com/google/samples/apps/nowinandroid/core/domain/GetFollowableTopicsUseCaseTest.kt @@ -16,8 +16,8 @@ package com.google.samples.apps.nowinandroid.core.domain -import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic -import com.google.samples.apps.nowinandroid.core.domain.model.Topic +import com.google.samples.apps.nowinandroid.core.model.FollowableTopic +import com.google.samples.apps.nowinandroid.core.model.Topic import com.google.samples.apps.nowinandroid.core.domain.usecase.GetFollowableTopicsUseCase import com.google.samples.apps.nowinandroid.core.domain.usecase.TopicSortField.NAME import com.google.samples.apps.nowinandroid.core.testing.repository.TestTopicsRepository @@ -54,9 +54,18 @@ class GetFollowableTopicsUseCaseTest { // Check that the order hasn't changed and that the correct topics are marked as followed. assertEquals( listOf( - FollowableTopic(testTopics[0], true), - FollowableTopic(testTopics[1], false), - FollowableTopic(testTopics[2], true), + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + testTopics[0], + true + ), + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + testTopics[1], + false + ), + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + testTopics[2], + true + ), ), followableTopics.first(), ) @@ -79,14 +88,14 @@ class GetFollowableTopicsUseCaseTest { testTopics .sortedBy { it.name } .map { - FollowableTopic(it, false) + com.google.samples.apps.nowinandroid.core.model.FollowableTopic(it, false) }, ) } } private val testTopics = listOf( - Topic("1", "Headlines", "", "", "", ""), - Topic("2", "Android Studio", "", "", "", ""), - Topic("3", "Compose", "", "", "", ""), + com.google.samples.apps.nowinandroid.core.model.Topic("1", "Headlines", "", "", "", ""), + com.google.samples.apps.nowinandroid.core.model.Topic("2", "Android Studio", "", "", "", ""), + com.google.samples.apps.nowinandroid.core.model.Topic("3", "Compose", "", "", "", ""), ) diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/ChangeListVersions.kt b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/ChangeListVersions.kt similarity index 86% rename from core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/ChangeListVersions.kt rename to core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/ChangeListVersions.kt index 59527b458..b49081364 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/ChangeListVersions.kt +++ b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/ChangeListVersions.kt @@ -1,5 +1,5 @@ /* - * Copyright 2022 The Android Open Source Project + * Copyright 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.domain.model +package com.google.samples.apps.nowinandroid.core.model /** * Class summarizing the local version of each model for sync diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/DarkThemeConfig.kt b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/DarkThemeConfig.kt similarity index 84% rename from core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/DarkThemeConfig.kt rename to core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/DarkThemeConfig.kt index 4c7aef039..b7c1537e9 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/DarkThemeConfig.kt +++ b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/DarkThemeConfig.kt @@ -1,5 +1,5 @@ /* - * Copyright 2022 The Android Open Source Project + * Copyright 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.domain.model +package com.google.samples.apps.nowinandroid.core.model enum class DarkThemeConfig { FOLLOW_SYSTEM, diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/FollowableTopic.kt b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/FollowableTopic.kt similarity index 93% rename from core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/FollowableTopic.kt rename to core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/FollowableTopic.kt index 56f2906db..2b8e93d44 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/FollowableTopic.kt +++ b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/FollowableTopic.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.domain.model +package com.google.samples.apps.nowinandroid.core.model /** * A [topic] with the additional information for whether or not it is followed. diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/NewsResource.kt b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/NewsResource.kt similarity index 93% rename from core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/NewsResource.kt rename to core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/NewsResource.kt index 249169dcb..26d4a7f16 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/NewsResource.kt +++ b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/NewsResource.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.domain.model +package com.google.samples.apps.nowinandroid.core.model import kotlinx.datetime.Instant diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/RecentSearchQuery.kt b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/RecentSearchQuery.kt similarity index 92% rename from core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/RecentSearchQuery.kt rename to core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/RecentSearchQuery.kt index 0d087ff2a..9d9b8f7b6 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/RecentSearchQuery.kt +++ b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/RecentSearchQuery.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.domain.model +package com.google.samples.apps.nowinandroid.core.model import kotlinx.datetime.Clock import kotlinx.datetime.Instant diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/SearchResult.kt b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/SearchResult.kt similarity index 92% rename from core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/SearchResult.kt rename to core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/SearchResult.kt index 59dd446c2..092a18727 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/SearchResult.kt +++ b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/SearchResult.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.domain.model +package com.google.samples.apps.nowinandroid.core.model /** An entity that holds the search result */ data class SearchResult( diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/ThemeBrand.kt b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/ThemeBrand.kt similarity index 84% rename from core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/ThemeBrand.kt rename to core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/ThemeBrand.kt index dfc1ee566..8ba2ebb59 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/ThemeBrand.kt +++ b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/ThemeBrand.kt @@ -1,5 +1,5 @@ /* - * Copyright 2022 The Android Open Source Project + * Copyright 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.domain.model +package com.google.samples.apps.nowinandroid.core.model enum class ThemeBrand { DEFAULT, diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/Topic.kt b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/Topic.kt similarity index 87% rename from core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/Topic.kt rename to core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/Topic.kt index 12f69ad5d..4bc054a32 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/Topic.kt +++ b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/Topic.kt @@ -1,5 +1,5 @@ /* - * Copyright 2022 The Android Open Source Project + * Copyright 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.domain.model +package com.google.samples.apps.nowinandroid.core.model /** * External data layer representation of a NiA Topic diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/UserData.kt b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/UserData.kt similarity index 93% rename from core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/UserData.kt rename to core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/UserData.kt index 512b81b8c..6e7c4f395 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/UserData.kt +++ b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/UserData.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.domain.model +package com.google.samples.apps.nowinandroid.core.model /** * Class summarizing user interest data diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/UserNewsResource.kt b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/UserNewsResource.kt similarity index 96% rename from core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/UserNewsResource.kt rename to core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/UserNewsResource.kt index b38b815a7..4b9b95e69 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/UserNewsResource.kt +++ b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/UserNewsResource.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.domain.model +package com.google.samples.apps.nowinandroid.core.model import kotlinx.datetime.Instant diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/UserSearchResult.kt b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/UserSearchResult.kt similarity index 93% rename from core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/UserSearchResult.kt rename to core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/UserSearchResult.kt index 170fe57e1..26ef21d0c 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/UserSearchResult.kt +++ b/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/UserSearchResult.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.domain.model +package com.google.samples.apps.nowinandroid.core.model /** * An entity of [SearchResult] with additional user information such as whether the user is diff --git a/core/network/build.gradle.kts b/core/network/build.gradle.kts index a97fe4174..689a99e73 100644 --- a/core/network/build.gradle.kts +++ b/core/network/build.gradle.kts @@ -41,7 +41,7 @@ secrets { dependencies { api(libs.kotlinx.datetime) api(projects.core.common) - api(projects.core.domain) + api(projects.core.model) implementation(libs.coil.kt) implementation(libs.coil.kt.svg) diff --git a/core/network/src/main/kotlin/com/google/samples/apps/nowinandroid/core/network/model/NetworkTopic.kt b/core/network/src/main/kotlin/com/google/samples/apps/nowinandroid/core/network/model/NetworkTopic.kt index 06d8825e5..ff2a200b3 100644 --- a/core/network/src/main/kotlin/com/google/samples/apps/nowinandroid/core/network/model/NetworkTopic.kt +++ b/core/network/src/main/kotlin/com/google/samples/apps/nowinandroid/core/network/model/NetworkTopic.kt @@ -16,7 +16,7 @@ package com.google.samples.apps.nowinandroid.core.network.model -import com.google.samples.apps.nowinandroid.core.domain.model.Topic +import com.google.samples.apps.nowinandroid.core.model.Topic import kotlinx.serialization.Serializable /** diff --git a/core/notifications/build.gradle.kts b/core/notifications/build.gradle.kts index 93e128883..7fbc98c82 100644 --- a/core/notifications/build.gradle.kts +++ b/core/notifications/build.gradle.kts @@ -23,8 +23,7 @@ android { } dependencies { - api(projects.core.domain) - + implementation(projects.core.model) implementation(projects.core.common) compileOnly(platform(libs.androidx.compose.bom)) diff --git a/core/notifications/src/main/kotlin/com/google/samples/apps/nowinandroid/core/notifications/NoOpNotifier.kt b/core/notifications/src/main/kotlin/com/google/samples/apps/nowinandroid/core/notifications/NoOpNotifier.kt index 63e607b6b..e30be5ede 100644 --- a/core/notifications/src/main/kotlin/com/google/samples/apps/nowinandroid/core/notifications/NoOpNotifier.kt +++ b/core/notifications/src/main/kotlin/com/google/samples/apps/nowinandroid/core/notifications/NoOpNotifier.kt @@ -16,12 +16,12 @@ package com.google.samples.apps.nowinandroid.core.notifications -import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource +import com.google.samples.apps.nowinandroid.core.model.NewsResource import javax.inject.Inject /** * Implementation of [Notifier] which does nothing. Useful for tests and previews. */ internal class NoOpNotifier @Inject constructor() : Notifier { - override fun postNewsNotifications(newsResources: List) = Unit + override fun postNewsNotifications(newsResources: List) = Unit } diff --git a/core/notifications/src/main/kotlin/com/google/samples/apps/nowinandroid/core/notifications/Notifier.kt b/core/notifications/src/main/kotlin/com/google/samples/apps/nowinandroid/core/notifications/Notifier.kt index 30f195266..f343088f6 100644 --- a/core/notifications/src/main/kotlin/com/google/samples/apps/nowinandroid/core/notifications/Notifier.kt +++ b/core/notifications/src/main/kotlin/com/google/samples/apps/nowinandroid/core/notifications/Notifier.kt @@ -16,11 +16,11 @@ package com.google.samples.apps.nowinandroid.core.notifications -import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource +import com.google.samples.apps.nowinandroid.core.model.NewsResource /** * Interface for creating notifications in the app */ interface Notifier { - fun postNewsNotifications(newsResources: List) + fun postNewsNotifications(newsResources: List) } diff --git a/core/notifications/src/main/kotlin/com/google/samples/apps/nowinandroid/core/notifications/SystemTrayNotifier.kt b/core/notifications/src/main/kotlin/com/google/samples/apps/nowinandroid/core/notifications/SystemTrayNotifier.kt index 62a62e214..34ef946e9 100644 --- a/core/notifications/src/main/kotlin/com/google/samples/apps/nowinandroid/core/notifications/SystemTrayNotifier.kt +++ b/core/notifications/src/main/kotlin/com/google/samples/apps/nowinandroid/core/notifications/SystemTrayNotifier.kt @@ -32,7 +32,7 @@ import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat.InboxStyle import androidx.core.app.NotificationManagerCompat import androidx.core.net.toUri -import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource +import com.google.samples.apps.nowinandroid.core.model.NewsResource import dagger.hilt.android.qualifiers.ApplicationContext import javax.inject.Inject import javax.inject.Singleton @@ -55,7 +55,7 @@ internal class SystemTrayNotifier @Inject constructor( ) : Notifier { override fun postNewsNotifications( - newsResources: List, + newsResources: List, ) = with(context) { if (checkSelfPermission(this, permission.POST_NOTIFICATIONS) != PERMISSION_GRANTED) { return @@ -108,7 +108,7 @@ internal class SystemTrayNotifier @Inject constructor( * Creates an inbox style summary notification for news updates */ private fun newsNotificationStyle( - newsResources: List, + newsResources: List, title: String, ): InboxStyle = newsResources .fold(InboxStyle()) { inboxStyle, newsResource -> inboxStyle.addLine(newsResource.title) } @@ -150,7 +150,7 @@ private fun Context.ensureNotificationChannelExists() { } private fun Context.newsPendingIntent( - newsResource: com.google.samples.apps.nowinandroid.core.domain.model.NewsResource, + newsResource: com.google.samples.apps.nowinandroid.core.model.NewsResource, ): PendingIntent? = PendingIntent.getActivity( this, NEWS_NOTIFICATION_REQUEST_CODE, @@ -165,4 +165,4 @@ private fun Context.newsPendingIntent( PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE, ) -private fun com.google.samples.apps.nowinandroid.core.domain.model.NewsResource.newsDeepLinkUri() = "$DEEP_LINK_SCHEME_AND_HOST/$FOR_YOU_PATH/$id".toUri() +private fun com.google.samples.apps.nowinandroid.core.model.NewsResource.newsDeepLinkUri() = "$DEEP_LINK_SCHEME_AND_HOST/$FOR_YOU_PATH/$id".toUri() diff --git a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/FollowableTopicTestData.kt b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/FollowableTopicTestData.kt index 32aa9881b..c2f8c16fb 100644 --- a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/FollowableTopicTestData.kt +++ b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/FollowableTopicTestData.kt @@ -18,12 +18,12 @@ package com.google.samples.apps.nowinandroid.core.testing.data -import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic -import com.google.samples.apps.nowinandroid.core.domain.model.Topic +import com.google.samples.apps.nowinandroid.core.model.FollowableTopic +import com.google.samples.apps.nowinandroid.core.model.Topic -val followableTopicTestData: List = listOf( - FollowableTopic( - topic = Topic( +val followableTopicTestData: List = listOf( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + topic = com.google.samples.apps.nowinandroid.core.model.Topic( id = "2", name = "Headlines", shortDescription = "News we want everyone to see", @@ -33,8 +33,8 @@ val followableTopicTestData: List = listOf( ), isFollowed = false, ), - FollowableTopic( - topic = Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + topic = com.google.samples.apps.nowinandroid.core.model.Topic( id = "3", name = "UI", shortDescription = "Material Design, Navigation, Text, Paging, Accessibility (a11y), Internationalization (i18n), Localization (l10n), Animations, Large Screens, Widgets", @@ -44,8 +44,8 @@ val followableTopicTestData: List = listOf( ), isFollowed = true, ), - FollowableTopic( - topic = Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + topic = com.google.samples.apps.nowinandroid.core.model.Topic( id = "4", name = "Testing", shortDescription = "CI, Espresso, TestLab, etc", diff --git a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/NewsResourcesTestData.kt b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/NewsResourcesTestData.kt index c5648e365..47d48e8e7 100644 --- a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/NewsResourcesTestData.kt +++ b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/NewsResourcesTestData.kt @@ -18,11 +18,11 @@ package com.google.samples.apps.nowinandroid.core.testing.data -import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource +import com.google.samples.apps.nowinandroid.core.model.NewsResource import kotlinx.datetime.Instant -val newsResourcesTestData: List = listOf( - NewsResource( +val newsResourcesTestData: List = listOf( + com.google.samples.apps.nowinandroid.core.model.NewsResource( id = "1", title = "Android Basics with Compose", content = "We released the first two units of Android Basics with Compose, our first free course that teaches Android Development with Jetpack Compose to anyone; you do not need any prior programming experience other than basic computer literacy to get started. You’ll learn the fundamentals of programming in Kotlin while building Android apps using Jetpack Compose, Android’s modern toolkit that simplifies and accelerates native UI development. These two units are just the beginning; more will be coming soon. Check out Android Basics with Compose to get started on your Android development journey", @@ -32,7 +32,7 @@ val newsResourcesTestData: List = listOf( type = "Codelab", topics = listOf(topicsTestData[1]), ), - NewsResource( + com.google.samples.apps.nowinandroid.core.model.NewsResource( id = "2", title = "Thanks for helping us reach 1M YouTube Subscribers", content = "Thank you everyone for following the Now in Android series and everything the " + @@ -45,7 +45,7 @@ val newsResourcesTestData: List = listOf( type = "Video 📺", topics = listOf(topicsTestData[0], topicsTestData[1]), ), - NewsResource( + com.google.samples.apps.nowinandroid.core.model.NewsResource( id = "3", title = "Transformations and customisations in the Paging Library", content = "A demonstration of different operations that can be performed " + @@ -58,7 +58,7 @@ val newsResourcesTestData: List = listOf( type = "Video 📺", topics = listOf(topicsTestData[2]), ), - NewsResource( + com.google.samples.apps.nowinandroid.core.model.NewsResource( id = "4", title = "New Jetpack Release", content = "New Jetpack release includes updates to libraries such as CameraX, Benchmark, and" + diff --git a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/TopicsTestData.kt b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/TopicsTestData.kt index 8491f76a6..48dbbe738 100644 --- a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/TopicsTestData.kt +++ b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/TopicsTestData.kt @@ -18,10 +18,10 @@ package com.google.samples.apps.nowinandroid.core.testing.data -import com.google.samples.apps.nowinandroid.core.domain.model.Topic +import com.google.samples.apps.nowinandroid.core.model.Topic -val topicsTestData: List = listOf( - Topic( +val topicsTestData: List = listOf( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "2", name = "Headlines", shortDescription = "News we want everyone to see", @@ -29,7 +29,7 @@ val topicsTestData: List = listOf( imageUrl = "https://firebasestorage.googleapis.com/v0/b/now-in-android.appspot.com/o/img%2Fic_topic_Headlines.svg?alt=media&token=506faab0-617a-4668-9e63-4a2fb996603f", url = "", ), - Topic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "3", name = "UI", shortDescription = "Material Design, Navigation, Text, Paging, Accessibility (a11y), Internationalization (i18n), Localization (l10n), Animations, Large Screens, Widgets", @@ -37,7 +37,7 @@ val topicsTestData: List = listOf( imageUrl = "https://firebasestorage.googleapis.com/v0/b/now-in-android.appspot.com/o/img%2Fic_topic_UI.svg?alt=media&token=0ee1842b-12e8-435f-87ba-a5bb02c47594", url = "", ), - Topic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "4", name = "Testing", shortDescription = "CI, Espresso, TestLab, etc", diff --git a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/UserNewsResourcesTestData.kt b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/UserNewsResourcesTestData.kt index ea33e5cb0..ab5e4d19d 100644 --- a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/UserNewsResourcesTestData.kt +++ b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/data/UserNewsResourcesTestData.kt @@ -18,17 +18,17 @@ package com.google.samples.apps.nowinandroid.core.testing.data -import com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig.DARK -import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource -import com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand.ANDROID -import com.google.samples.apps.nowinandroid.core.domain.model.UserData -import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource +import com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig.DARK +import com.google.samples.apps.nowinandroid.core.model.NewsResource +import com.google.samples.apps.nowinandroid.core.model.ThemeBrand.ANDROID +import com.google.samples.apps.nowinandroid.core.model.UserData +import com.google.samples.apps.nowinandroid.core.model.UserNewsResource import kotlinx.datetime.Instant import kotlinx.datetime.LocalDateTime import kotlinx.datetime.TimeZone import kotlinx.datetime.toInstant -val userNewsResourcesTestData: List = UserData( +val userNewsResourcesTestData: List = com.google.samples.apps.nowinandroid.core.model.UserData( bookmarkedNewsResources = setOf("1", "4"), viewedNewsResources = setOf("1", "2", "4"), followedTopics = emptySet(), @@ -38,8 +38,8 @@ val userNewsResourcesTestData: List = UserData( useDynamicColor = false, ).let { userData -> listOf( - UserNewsResource( - newsResource = NewsResource( + com.google.samples.apps.nowinandroid.core.model.UserNewsResource( + newsResource = com.google.samples.apps.nowinandroid.core.model.NewsResource( id = "1", title = "Android Basics with Compose", content = "We released the first two units of Android Basics with Compose, our first free course that teaches Android Development with Jetpack Compose to anyone; you do not need any prior programming experience other than basic computer literacy to get started. You’ll learn the fundamentals of programming in Kotlin while building Android apps using Jetpack Compose, Android’s modern toolkit that simplifies and accelerates native UI development. These two units are just the beginning; more will be coming soon. Check out Android Basics with Compose to get started on your Android development journey", @@ -59,8 +59,8 @@ val userNewsResourcesTestData: List = UserData( ), userData = userData, ), - UserNewsResource( - newsResource = NewsResource( + com.google.samples.apps.nowinandroid.core.model.UserNewsResource( + newsResource = com.google.samples.apps.nowinandroid.core.model.NewsResource( id = "2", title = "Thanks for helping us reach 1M YouTube Subscribers", content = "Thank you everyone for following the Now in Android series and everything the " + @@ -75,8 +75,8 @@ val userNewsResourcesTestData: List = UserData( ), userData = userData, ), - UserNewsResource( - newsResource = NewsResource( + com.google.samples.apps.nowinandroid.core.model.UserNewsResource( + newsResource = com.google.samples.apps.nowinandroid.core.model.NewsResource( id = "3", title = "Transformations and customisations in the Paging Library", content = "A demonstration of different operations that can be performed " + @@ -91,8 +91,8 @@ val userNewsResourcesTestData: List = UserData( ), userData = userData, ), - UserNewsResource( - newsResource = NewsResource( + com.google.samples.apps.nowinandroid.core.model.UserNewsResource( + newsResource = com.google.samples.apps.nowinandroid.core.model.NewsResource( id = "4", title = "New Jetpack Release", content = "New Jetpack release includes updates to libraries such as CameraX, Benchmark, and" + diff --git a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/notifications/TestNotifier.kt b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/notifications/TestNotifier.kt index b8f939b0e..5580aefc3 100644 --- a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/notifications/TestNotifier.kt +++ b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/notifications/TestNotifier.kt @@ -16,7 +16,7 @@ package com.google.samples.apps.nowinandroid.core.testing.notifications -import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource +import com.google.samples.apps.nowinandroid.core.model.NewsResource import com.google.samples.apps.nowinandroid.core.notifications.Notifier /** @@ -24,11 +24,11 @@ import com.google.samples.apps.nowinandroid.core.notifications.Notifier */ class TestNotifier : Notifier { - private val mutableAddedNewResources = mutableListOf>() + private val mutableAddedNewResources = mutableListOf>() - val addedNewsResources: List> = mutableAddedNewResources + val addedNewsResources: List> = mutableAddedNewResources - override fun postNewsNotifications(newsResources: List) { + override fun postNewsNotifications(newsResources: List) { mutableAddedNewResources.add(newsResources) } } diff --git a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestNewsRepository.kt b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestNewsRepository.kt index 9cfe92769..7195a00e4 100644 --- a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestNewsRepository.kt +++ b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestNewsRepository.kt @@ -16,8 +16,8 @@ package com.google.samples.apps.nowinandroid.core.testing.repository -import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource -import com.google.samples.apps.nowinandroid.core.domain.model.Topic +import com.google.samples.apps.nowinandroid.core.model.NewsResource +import com.google.samples.apps.nowinandroid.core.model.Topic import com.google.samples.apps.nowinandroid.core.domain.repository.NewsRepository import com.google.samples.apps.nowinandroid.core.domain.repository.NewsResourceQuery import com.google.samples.apps.nowinandroid.core.domain.utils.Synchronizer @@ -31,15 +31,15 @@ class TestNewsRepository : NewsRepository { /** * The backing hot flow for the list of topics ids for testing. */ - private val newsResourcesFlow: MutableSharedFlow> = + private val newsResourcesFlow: MutableSharedFlow> = MutableSharedFlow(replay = 1, onBufferOverflow = BufferOverflow.DROP_OLDEST) - override fun getNewsResources(query: NewsResourceQuery): Flow> = + override fun getNewsResources(query: NewsResourceQuery): Flow> = newsResourcesFlow.map { newsResources -> var result = newsResources query.filterTopicIds?.let { filterTopicIds -> result = newsResources.filter { - it.topics.map(Topic::id).intersect(filterTopicIds).isNotEmpty() + it.topics.map(com.google.samples.apps.nowinandroid.core.model.Topic::id).intersect(filterTopicIds).isNotEmpty() } } query.filterNewsIds?.let { filterNewsIds -> @@ -51,7 +51,7 @@ class TestNewsRepository : NewsRepository { /** * A test-only API to allow controlling the list of news resources from tests. */ - fun sendNewsResources(newsResources: List) { + fun sendNewsResources(newsResources: List) { newsResourcesFlow.tryEmit(newsResources) } diff --git a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestRecentSearchRepository.kt b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestRecentSearchRepository.kt index ae592b882..9bf52873e 100644 --- a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestRecentSearchRepository.kt +++ b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestRecentSearchRepository.kt @@ -16,21 +16,21 @@ package com.google.samples.apps.nowinandroid.core.testing.repository -import com.google.samples.apps.nowinandroid.core.domain.model.RecentSearchQuery +import com.google.samples.apps.nowinandroid.core.model.RecentSearchQuery import com.google.samples.apps.nowinandroid.core.domain.repository.RecentSearchRepository import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf class TestRecentSearchRepository : RecentSearchRepository { - private val cachedRecentSearches: MutableList = mutableListOf() + private val cachedRecentSearches: MutableList = mutableListOf() - override fun getRecentSearchQueries(limit: Int): Flow> = + override fun getRecentSearchQueries(limit: Int): Flow> = flowOf(cachedRecentSearches.sortedByDescending { it.queriedDate }.take(limit)) override suspend fun insertOrReplaceRecentSearch(searchQuery: String) { cachedRecentSearches.add( - RecentSearchQuery( + com.google.samples.apps.nowinandroid.core.model.RecentSearchQuery( searchQuery, ), ) diff --git a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestSearchContentsRepository.kt b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestSearchContentsRepository.kt index 8b7ef5ea9..c3e6e7193 100644 --- a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestSearchContentsRepository.kt +++ b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestSearchContentsRepository.kt @@ -16,9 +16,9 @@ package com.google.samples.apps.nowinandroid.core.testing.repository -import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource -import com.google.samples.apps.nowinandroid.core.domain.model.SearchResult -import com.google.samples.apps.nowinandroid.core.domain.model.Topic +import com.google.samples.apps.nowinandroid.core.model.NewsResource +import com.google.samples.apps.nowinandroid.core.model.SearchResult +import com.google.samples.apps.nowinandroid.core.model.Topic import com.google.samples.apps.nowinandroid.core.domain.repository.SearchContentsRepository import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow @@ -28,14 +28,14 @@ import org.jetbrains.annotations.TestOnly class TestSearchContentsRepository : SearchContentsRepository { - private val cachedTopics = MutableStateFlow(emptyList()) - private val cachedNewsResources = MutableStateFlow(emptyList()) + private val cachedTopics = MutableStateFlow(emptyList()) + private val cachedNewsResources = MutableStateFlow(emptyList()) override suspend fun populateFtsData() = Unit - override fun searchContents(searchQuery: String): Flow = + override fun searchContents(searchQuery: String): Flow = combine(cachedTopics, cachedNewsResources) { topics, news -> - SearchResult( + com.google.samples.apps.nowinandroid.core.model.SearchResult( topics = topics.filter { searchQuery in it.name || searchQuery in it.shortDescription || searchQuery in it.longDescription }, @@ -48,9 +48,9 @@ class TestSearchContentsRepository : SearchContentsRepository { override fun getSearchContentsCount(): Flow = combine(cachedTopics, cachedNewsResources) { topics, news -> topics.size + news.size } @TestOnly - fun addTopics(topics: List) = cachedTopics.update { it + topics } + fun addTopics(topics: List) = cachedTopics.update { it + topics } @TestOnly - fun addNewsResources(newsResources: List) = + fun addNewsResources(newsResources: List) = cachedNewsResources.update { it + newsResources } } diff --git a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestTopicsRepository.kt b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestTopicsRepository.kt index 52bade77c..3cb56f135 100644 --- a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestTopicsRepository.kt +++ b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestTopicsRepository.kt @@ -16,7 +16,7 @@ package com.google.samples.apps.nowinandroid.core.testing.repository -import com.google.samples.apps.nowinandroid.core.domain.model.Topic +import com.google.samples.apps.nowinandroid.core.model.Topic import com.google.samples.apps.nowinandroid.core.domain.repository.TopicsRepository import com.google.samples.apps.nowinandroid.core.domain.utils.Synchronizer import kotlinx.coroutines.channels.BufferOverflow @@ -28,18 +28,18 @@ class TestTopicsRepository : TopicsRepository { /** * The backing hot flow for the list of topics ids for testing. */ - private val topicsFlow: MutableSharedFlow> = + private val topicsFlow: MutableSharedFlow> = MutableSharedFlow(replay = 1, onBufferOverflow = BufferOverflow.DROP_OLDEST) - override fun getTopics(): Flow> = topicsFlow + override fun getTopics(): Flow> = topicsFlow - override fun getTopic(id: String): Flow = + override fun getTopic(id: String): Flow = topicsFlow.map { topics -> topics.find { it.id == id }!! } /** * A test-only API to allow controlling the list of topics from tests. */ - fun sendTopics(topics: List) { + fun sendTopics(topics: List) { topicsFlow.tryEmit(topics) } diff --git a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestUserDataRepository.kt b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestUserDataRepository.kt index d23fdaa36..a354dfd0e 100644 --- a/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestUserDataRepository.kt +++ b/core/testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/repository/TestUserDataRepository.kt @@ -16,18 +16,18 @@ package com.google.samples.apps.nowinandroid.core.testing.repository -import com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig -import com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig.FOLLOW_SYSTEM -import com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand -import com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand.DEFAULT -import com.google.samples.apps.nowinandroid.core.domain.model.UserData +import com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig +import com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig.FOLLOW_SYSTEM +import com.google.samples.apps.nowinandroid.core.model.ThemeBrand +import com.google.samples.apps.nowinandroid.core.model.ThemeBrand.DEFAULT +import com.google.samples.apps.nowinandroid.core.model.UserData import com.google.samples.apps.nowinandroid.core.domain.repository.UserDataRepository import kotlinx.coroutines.channels.BufferOverflow.DROP_OLDEST import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.filterNotNull -val emptyUserData = UserData( +val emptyUserData = com.google.samples.apps.nowinandroid.core.model.UserData( bookmarkedNewsResources = emptySet(), viewedNewsResources = emptySet(), followedTopics = emptySet(), @@ -41,11 +41,11 @@ class TestUserDataRepository : UserDataRepository { /** * The backing hot flow for the list of followed topic ids for testing. */ - private val _userData = MutableSharedFlow(replay = 1, onBufferOverflow = DROP_OLDEST) + private val _userData = MutableSharedFlow(replay = 1, onBufferOverflow = DROP_OLDEST) private val currentUserData get() = _userData.replayCache.firstOrNull() ?: emptyUserData - override val userData: Flow = _userData.filterNotNull() + override val userData: Flow = _userData.filterNotNull() override suspend fun setFollowedTopicIds(followedTopicIds: Set) { _userData.tryEmit(currentUserData.copy(followedTopics = followedTopicIds)) @@ -90,13 +90,13 @@ class TestUserDataRepository : UserDataRepository { } } - override suspend fun setThemeBrand(themeBrand: ThemeBrand) { + override suspend fun setThemeBrand(themeBrand: com.google.samples.apps.nowinandroid.core.model.ThemeBrand) { currentUserData.let { current -> _userData.tryEmit(current.copy(themeBrand = themeBrand)) } } - override suspend fun setDarkThemeConfig(darkThemeConfig: DarkThemeConfig) { + override suspend fun setDarkThemeConfig(darkThemeConfig: com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig) { currentUserData.let { current -> _userData.tryEmit(current.copy(darkThemeConfig = darkThemeConfig)) } @@ -117,7 +117,7 @@ class TestUserDataRepository : UserDataRepository { /** * A test-only API to allow setting of user data directly. */ - fun setUserData(userData: UserData) { + fun setUserData(userData: com.google.samples.apps.nowinandroid.core.model.UserData) { _userData.tryEmit(userData) } } diff --git a/core/ui/build.gradle.kts b/core/ui/build.gradle.kts index 890d94e52..5d8a65d44 100644 --- a/core/ui/build.gradle.kts +++ b/core/ui/build.gradle.kts @@ -30,7 +30,7 @@ dependencies { api(libs.androidx.metrics) api(projects.core.analytics) api(projects.core.designsystem) - api(projects.core.domain) + api(projects.core.model) implementation(libs.androidx.browser) implementation(libs.coil.kt) diff --git a/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/FollowableTopicPreviewParameterProvider.kt b/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/FollowableTopicPreviewParameterProvider.kt index e212372eb..42b29b4c1 100644 --- a/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/FollowableTopicPreviewParameterProvider.kt +++ b/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/FollowableTopicPreviewParameterProvider.kt @@ -19,19 +19,19 @@ package com.google.samples.apps.nowinandroid.core.ui import androidx.compose.ui.tooling.preview.PreviewParameterProvider -import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic -import com.google.samples.apps.nowinandroid.core.domain.model.Topic +import com.google.samples.apps.nowinandroid.core.model.FollowableTopic +import com.google.samples.apps.nowinandroid.core.model.Topic /** * This [PreviewParameterProvider](https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/preview/PreviewParameterProvider) * provides list of [FollowableTopic] for Composable previews. */ -class FollowableTopicPreviewParameterProvider : PreviewParameterProvider> { - override val values: Sequence> +class FollowableTopicPreviewParameterProvider : PreviewParameterProvider> { + override val values: Sequence> get() = sequenceOf( listOf( - com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic( - topic = com.google.samples.apps.nowinandroid.core.domain.model.Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + topic = com.google.samples.apps.nowinandroid.core.model.Topic( id = "2", name = "Headlines", shortDescription = "News we want everyone to see", @@ -41,8 +41,8 @@ class FollowableTopicPreviewParameterProvider : PreviewParameterProvider, + val feed: List, ) : NewsFeedUiState } @@ -144,7 +144,7 @@ private fun NewsFeedLoadingPreview() { @Composable private fun NewsFeedContentPreview( @PreviewParameter(UserNewsResourcePreviewParameterProvider::class) - userNewsResources: List, + userNewsResources: List, ) { NiaTheme { LazyVerticalStaggeredGrid(columns = StaggeredGridCells.Adaptive(300.dp)) { diff --git a/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt b/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt index c8e225d66..4e85b3712 100644 --- a/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt +++ b/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt @@ -64,9 +64,9 @@ import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaIconT import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaTopicTag import com.google.samples.apps.nowinandroid.core.designsystem.icon.NiaIcons import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme -import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic -import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource -import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource +import com.google.samples.apps.nowinandroid.core.model.FollowableTopic +import com.google.samples.apps.nowinandroid.core.model.NewsResource +import com.google.samples.apps.nowinandroid.core.model.UserNewsResource import kotlinx.datetime.Instant import kotlinx.datetime.toJavaInstant import kotlinx.datetime.toJavaZoneId @@ -81,7 +81,7 @@ import java.util.Locale @OptIn(ExperimentalMaterial3Api::class) @Composable fun NewsResourceCardExpanded( - userNewsResource: com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource, + userNewsResource: com.google.samples.apps.nowinandroid.core.model.UserNewsResource, isBookmarked: Boolean, hasBeenViewed: Boolean, onToggleBookmark: () -> Unit, @@ -273,7 +273,7 @@ fun NewsResourceShortDescription( @Composable fun NewsResourceTopics( - topics: List, + topics: List, onTopicClick: (String) -> Unit, modifier: Modifier = Modifier, ) { @@ -334,7 +334,7 @@ private fun BookmarkButtonBookmarkedPreview() { @Composable private fun ExpandedNewsResourcePreview( @PreviewParameter(UserNewsResourcePreviewParameterProvider::class) - userNewsResources: List, + userNewsResources: List, ) { CompositionLocalProvider( LocalInspectionMode provides true, diff --git a/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCardList.kt b/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCardList.kt index da9b27103..2a1a7e035 100644 --- a/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCardList.kt +++ b/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCardList.kt @@ -24,7 +24,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.toArgb import androidx.compose.ui.platform.LocalContext import com.google.samples.apps.nowinandroid.core.analytics.LocalAnalyticsHelper -import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource +import com.google.samples.apps.nowinandroid.core.model.UserNewsResource /** * Extension function for displaying a [List] of [NewsResourceCardExpanded] backed by a list of @@ -34,8 +34,8 @@ import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource * When a news resource card is tapped it will open the news resource URL in a Chrome Custom Tab. */ fun LazyListScope.userNewsResourceCardItems( - items: List, - onToggleBookmark: (item: com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource) -> Unit, + items: List, + onToggleBookmark: (item: com.google.samples.apps.nowinandroid.core.model.UserNewsResource) -> Unit, onNewsResourceViewed: (String) -> Unit, onTopicClick: (String) -> Unit, itemModifier: Modifier = Modifier, diff --git a/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/UserNewsResourcePreviewParameterProvider.kt b/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/UserNewsResourcePreviewParameterProvider.kt index c2e0f94a7..a966f070b 100644 --- a/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/UserNewsResourcePreviewParameterProvider.kt +++ b/core/ui/src/main/kotlin/com/google/samples/apps/nowinandroid/core/ui/UserNewsResourcePreviewParameterProvider.kt @@ -19,12 +19,12 @@ package com.google.samples.apps.nowinandroid.core.ui import androidx.compose.ui.tooling.preview.PreviewParameterProvider -import com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig -import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource -import com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand -import com.google.samples.apps.nowinandroid.core.domain.model.Topic -import com.google.samples.apps.nowinandroid.core.domain.model.UserData -import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource +import com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig +import com.google.samples.apps.nowinandroid.core.model.NewsResource +import com.google.samples.apps.nowinandroid.core.model.ThemeBrand +import com.google.samples.apps.nowinandroid.core.model.Topic +import com.google.samples.apps.nowinandroid.core.model.UserData +import com.google.samples.apps.nowinandroid.core.model.UserNewsResource import com.google.samples.apps.nowinandroid.core.ui.PreviewParameterData.newsResources import kotlinx.datetime.Instant import kotlinx.datetime.LocalDateTime @@ -35,26 +35,26 @@ import kotlinx.datetime.toInstant * This [PreviewParameterProvider](https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/preview/PreviewParameterProvider) * provides list of [UserNewsResource] for Composable previews. */ -class UserNewsResourcePreviewParameterProvider : PreviewParameterProvider> { +class UserNewsResourcePreviewParameterProvider : PreviewParameterProvider> { - override val values: Sequence> = sequenceOf(newsResources) + override val values: Sequence> = sequenceOf(newsResources) } object PreviewParameterData { - private val userData: com.google.samples.apps.nowinandroid.core.domain.model.UserData = - com.google.samples.apps.nowinandroid.core.domain.model.UserData( + private val userData: com.google.samples.apps.nowinandroid.core.model.UserData = + com.google.samples.apps.nowinandroid.core.model.UserData( bookmarkedNewsResources = setOf("1", "3"), viewedNewsResources = setOf("1", "2", "4"), followedTopics = emptySet(), - themeBrand = com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand.ANDROID, - darkThemeConfig = com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig.DARK, + themeBrand = com.google.samples.apps.nowinandroid.core.model.ThemeBrand.ANDROID, + darkThemeConfig = com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig.DARK, shouldHideOnboarding = true, useDynamicColor = false, ) val topics = listOf( - com.google.samples.apps.nowinandroid.core.domain.model.Topic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "2", name = "Headlines", shortDescription = "News we want everyone to see", @@ -62,7 +62,7 @@ object PreviewParameterData { imageUrl = "https://firebasestorage.googleapis.com/v0/b/now-in-android.appspot.com/o/img%2Fic_topic_Headlines.svg?alt=media&token=506faab0-617a-4668-9e63-4a2fb996603f", url = "", ), - com.google.samples.apps.nowinandroid.core.domain.model.Topic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "3", name = "UI", shortDescription = "Material Design, Navigation, Text, Paging, Accessibility (a11y), Internationalization (i18n), Localization (l10n), Animations, Large Screens, Widgets", @@ -70,7 +70,7 @@ object PreviewParameterData { imageUrl = "https://firebasestorage.googleapis.com/v0/b/now-in-android.appspot.com/o/img%2Fic_topic_UI.svg?alt=media&token=0ee1842b-12e8-435f-87ba-a5bb02c47594", url = "", ), - com.google.samples.apps.nowinandroid.core.domain.model.Topic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "4", name = "Testing", shortDescription = "CI, Espresso, TestLab, etc", @@ -81,8 +81,8 @@ object PreviewParameterData { ) val newsResources = listOf( - com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource( - newsResource = com.google.samples.apps.nowinandroid.core.domain.model.NewsResource( + com.google.samples.apps.nowinandroid.core.model.UserNewsResource( + newsResource = com.google.samples.apps.nowinandroid.core.model.NewsResource( id = "1", title = "Android Basics with Compose", content = "We released the first two units of Android Basics with Compose, our first free course that teaches Android Development with Jetpack Compose to anyone; you do not need any prior programming experience other than basic computer literacy to get started. You’ll learn the fundamentals of programming in Kotlin while building Android apps using Jetpack Compose, Android’s modern toolkit that simplifies and accelerates native UI development. These two units are just the beginning; more will be coming soon. Check out Android Basics with Compose to get started on your Android development journey", @@ -102,8 +102,8 @@ object PreviewParameterData { ), userData = userData, ), - com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource( - newsResource = com.google.samples.apps.nowinandroid.core.domain.model.NewsResource( + com.google.samples.apps.nowinandroid.core.model.UserNewsResource( + newsResource = com.google.samples.apps.nowinandroid.core.model.NewsResource( id = "2", title = "Thanks for helping us reach 1M YouTube Subscribers", content = "Thank you everyone for following the Now in Android series and everything the " + @@ -118,8 +118,8 @@ object PreviewParameterData { ), userData = userData, ), - com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource( - newsResource = com.google.samples.apps.nowinandroid.core.domain.model.NewsResource( + com.google.samples.apps.nowinandroid.core.model.UserNewsResource( + newsResource = com.google.samples.apps.nowinandroid.core.model.NewsResource( id = "3", title = "Transformations and customisations in the Paging Library", content = "A demonstration of different operations that can be performed " + diff --git a/feature/bookmarks/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksScreen.kt b/feature/bookmarks/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksScreen.kt index c2e4d4f65..4876eb850 100644 --- a/feature/bookmarks/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksScreen.kt +++ b/feature/bookmarks/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksScreen.kt @@ -66,7 +66,7 @@ import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollba import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollbar.scrollbarState import com.google.samples.apps.nowinandroid.core.designsystem.theme.LocalTintTheme import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme -import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource +import com.google.samples.apps.nowinandroid.core.model.UserNewsResource import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState.Loading import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState.Success @@ -266,7 +266,7 @@ private fun LoadingStatePreview() { @Composable private fun BookmarksGridPreview( @PreviewParameter(UserNewsResourcePreviewParameterProvider::class) - userNewsResources: List, + userNewsResources: List, ) { NiaTheme { BookmarksGrid( diff --git a/feature/bookmarks/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksViewModel.kt b/feature/bookmarks/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksViewModel.kt index 150c0ee40..f3caf844f 100644 --- a/feature/bookmarks/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksViewModel.kt +++ b/feature/bookmarks/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksViewModel.kt @@ -21,7 +21,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource +import com.google.samples.apps.nowinandroid.core.model.UserNewsResource import com.google.samples.apps.nowinandroid.core.domain.repository.UserDataRepository import com.google.samples.apps.nowinandroid.core.domain.repository.UserNewsResourceRepository import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState @@ -46,7 +46,7 @@ class BookmarksViewModel @Inject constructor( val feedUiState: StateFlow = userNewsResourceRepository.observeAllBookmarked() - .map, NewsFeedUiState>(NewsFeedUiState::Success) + .map, NewsFeedUiState>(NewsFeedUiState::Success) .onStart { emit(Loading) } .stateIn( scope = viewModelScope, diff --git a/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt b/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt index 72678f143..36906baee 100644 --- a/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt +++ b/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt @@ -96,7 +96,7 @@ import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollba import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollbar.scrollbarState import com.google.samples.apps.nowinandroid.core.designsystem.icon.NiaIcons import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme -import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource +import com.google.samples.apps.nowinandroid.core.model.UserNewsResource import com.google.samples.apps.nowinandroid.core.ui.DevicePreviews import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState import com.google.samples.apps.nowinandroid.core.ui.TrackScreenViewEvent @@ -136,7 +136,7 @@ internal fun ForYouScreen( isSyncing: Boolean, onboardingUiState: OnboardingUiState, feedState: NewsFeedUiState, - deepLinkedUserNewsResource: UserNewsResource?, + deepLinkedUserNewsResource: com.google.samples.apps.nowinandroid.core.model.UserNewsResource?, onTopicCheckedChanged: (String, Boolean) -> Unit, onTopicClick: (String) -> Unit, onDeepLinkOpened: (String) -> Unit, @@ -464,7 +464,7 @@ private fun NotificationPermissionEffect() { @Composable private fun DeepLinkEffect( - userNewsResource: UserNewsResource?, + userNewsResource: com.google.samples.apps.nowinandroid.core.model.UserNewsResource?, onDeepLinkOpened: (String) -> Unit, ) { val context = LocalContext.current @@ -505,7 +505,7 @@ private fun feedItemsSize( @Composable fun ForYouScreenPopulatedFeed( @PreviewParameter(UserNewsResourcePreviewParameterProvider::class) - userNewsResources: List, + userNewsResources: List, ) { NiaTheme { ForYouScreen( @@ -529,7 +529,7 @@ fun ForYouScreenPopulatedFeed( @Composable fun ForYouScreenOfflinePopulatedFeed( @PreviewParameter(UserNewsResourcePreviewParameterProvider::class) - userNewsResources: List, + userNewsResources: List, ) { NiaTheme { ForYouScreen( @@ -553,7 +553,7 @@ fun ForYouScreenOfflinePopulatedFeed( @Composable fun ForYouScreenTopicSelection( @PreviewParameter(UserNewsResourcePreviewParameterProvider::class) - userNewsResources: List, + userNewsResources: List, ) { NiaTheme { ForYouScreen( @@ -599,7 +599,7 @@ fun ForYouScreenLoading() { @Composable fun ForYouScreenPopulatedAndLoading( @PreviewParameter(UserNewsResourcePreviewParameterProvider::class) - userNewsResources: List, + userNewsResources: List, ) { NiaTheme { ForYouScreen( diff --git a/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/OnboardingUiState.kt b/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/OnboardingUiState.kt index da661aeac..7436f3c72 100644 --- a/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/OnboardingUiState.kt +++ b/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/OnboardingUiState.kt @@ -16,7 +16,7 @@ package com.google.samples.apps.nowinandroid.feature.foryou -import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic +import com.google.samples.apps.nowinandroid.core.model.FollowableTopic /** * A sealed hierarchy describing the onboarding state for the for you screen. @@ -41,7 +41,7 @@ sealed interface OnboardingUiState { * There is a onboarding state, with the given lists of topics. */ data class Shown( - val topics: List, + val topics: List, ) : OnboardingUiState { /** * True if the onboarding can be dismissed. diff --git a/feature/foryou/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModelTest.kt b/feature/foryou/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModelTest.kt index 56d02d305..80bdf9d4a 100644 --- a/feature/foryou/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModelTest.kt +++ b/feature/foryou/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModelTest.kt @@ -20,11 +20,11 @@ import androidx.lifecycle.SavedStateHandle import com.google.samples.apps.nowinandroid.core.analytics.AnalyticsEvent import com.google.samples.apps.nowinandroid.core.analytics.AnalyticsEvent.Param import com.google.samples.apps.nowinandroid.core.data.repository.CompositeUserNewsResourceRepository -import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic -import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource -import com.google.samples.apps.nowinandroid.core.domain.model.Topic -import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource -import com.google.samples.apps.nowinandroid.core.domain.model.mapToUserNewsResources +import com.google.samples.apps.nowinandroid.core.model.FollowableTopic +import com.google.samples.apps.nowinandroid.core.model.NewsResource +import com.google.samples.apps.nowinandroid.core.model.Topic +import com.google.samples.apps.nowinandroid.core.model.UserNewsResource +import com.google.samples.apps.nowinandroid.core.model.mapToUserNewsResources import com.google.samples.apps.nowinandroid.core.domain.usecase.GetFollowableTopicsUseCase import com.google.samples.apps.nowinandroid.core.testing.repository.TestNewsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestTopicsRepository @@ -157,8 +157,8 @@ class ForYouViewModelTest { assertEquals( OnboardingUiState.Shown( topics = listOf( - FollowableTopic( - topic = Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + topic = com.google.samples.apps.nowinandroid.core.model.Topic( id = "0", name = "Headlines", shortDescription = "", @@ -168,8 +168,8 @@ class ForYouViewModelTest { ), isFollowed = false, ), - FollowableTopic( - topic = Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + topic = com.google.samples.apps.nowinandroid.core.model.Topic( id = "1", name = "UI", shortDescription = "", @@ -179,8 +179,8 @@ class ForYouViewModelTest { ), isFollowed = false, ), - FollowableTopic( - topic = Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + topic = com.google.samples.apps.nowinandroid.core.model.Topic( id = "2", name = "Tools", shortDescription = "", @@ -218,8 +218,8 @@ class ForYouViewModelTest { assertEquals( OnboardingUiState.Shown( topics = listOf( - FollowableTopic( - topic = Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + topic = com.google.samples.apps.nowinandroid.core.model.Topic( id = "0", name = "Headlines", shortDescription = "", @@ -229,8 +229,8 @@ class ForYouViewModelTest { ), isFollowed = false, ), - FollowableTopic( - topic = Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + topic = com.google.samples.apps.nowinandroid.core.model.Topic( id = "1", name = "UI", shortDescription = "", @@ -240,8 +240,8 @@ class ForYouViewModelTest { ), isFollowed = false, ), - FollowableTopic( - topic = Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + topic = com.google.samples.apps.nowinandroid.core.model.Topic( id = "2", name = "Tools", shortDescription = "", @@ -315,7 +315,7 @@ class ForYouViewModelTest { assertEquals( OnboardingUiState.Shown( topics = sampleTopics.map { - FollowableTopic(it, false) + com.google.samples.apps.nowinandroid.core.model.FollowableTopic(it, false) }, ), viewModel.onboardingUiState.value, @@ -333,7 +333,10 @@ class ForYouViewModelTest { assertEquals( OnboardingUiState.Shown( topics = sampleTopics.map { - FollowableTopic(it, it.id == followedTopicId) + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + it, + it.id == followedTopicId + ) }, ), viewModel.onboardingUiState.value, @@ -344,8 +347,14 @@ class ForYouViewModelTest { assertEquals( NewsFeedUiState.Success( feed = listOf( - UserNewsResource(sampleNewsResources[1], userData), - UserNewsResource(sampleNewsResources[2], userData), + com.google.samples.apps.nowinandroid.core.model.UserNewsResource( + sampleNewsResources[1], + userData + ), + com.google.samples.apps.nowinandroid.core.model.UserNewsResource( + sampleNewsResources[2], + userData + ), ), ), viewModel.feedState.value, @@ -371,8 +380,8 @@ class ForYouViewModelTest { assertEquals( OnboardingUiState.Shown( topics = listOf( - FollowableTopic( - topic = Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + topic = com.google.samples.apps.nowinandroid.core.model.Topic( id = "0", name = "Headlines", shortDescription = "", @@ -382,8 +391,8 @@ class ForYouViewModelTest { ), isFollowed = false, ), - FollowableTopic( - topic = Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + topic = com.google.samples.apps.nowinandroid.core.model.Topic( id = "1", name = "UI", shortDescription = "", @@ -393,8 +402,8 @@ class ForYouViewModelTest { ), isFollowed = false, ), - FollowableTopic( - topic = Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + topic = com.google.samples.apps.nowinandroid.core.model.Topic( id = "2", name = "Tools", shortDescription = "", @@ -452,8 +461,14 @@ class ForYouViewModelTest { assertEquals( NewsFeedUiState.Success( feed = listOf( - UserNewsResource(newsResource = sampleNewsResources[1], userDataExpected), - UserNewsResource(newsResource = sampleNewsResources[2], userDataExpected), + com.google.samples.apps.nowinandroid.core.model.UserNewsResource( + newsResource = sampleNewsResources[1], + userDataExpected + ), + com.google.samples.apps.nowinandroid.core.model.UserNewsResource( + newsResource = sampleNewsResources[2], + userDataExpected + ), ), ), viewModel.feedState.value, @@ -473,7 +488,7 @@ class ForYouViewModelTest { savedStateHandle[LINKED_NEWS_RESOURCE_ID] = sampleNewsResources.first().id assertEquals( - expected = UserNewsResource( + expected = com.google.samples.apps.nowinandroid.core.model.UserNewsResource( newsResource = sampleNewsResources.first(), userData = emptyUserData, ), @@ -507,7 +522,7 @@ class ForYouViewModelTest { } private val sampleTopics = listOf( - Topic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "0", name = "Headlines", shortDescription = "", @@ -515,7 +530,7 @@ private val sampleTopics = listOf( url = "URL", imageUrl = "image URL", ), - Topic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "1", name = "UI", shortDescription = "", @@ -523,7 +538,7 @@ private val sampleTopics = listOf( url = "URL", imageUrl = "image URL", ), - Topic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "2", name = "Tools", shortDescription = "", @@ -534,7 +549,7 @@ private val sampleTopics = listOf( ) private val sampleNewsResources = listOf( - NewsResource( + com.google.samples.apps.nowinandroid.core.model.NewsResource( id = "1", title = "Thanks for helping us reach 1M YouTube Subscribers", content = "Thank you everyone for following the Now in Android series and everything the " + @@ -546,7 +561,7 @@ private val sampleNewsResources = listOf( publishDate = Instant.parse("2021-11-09T00:00:00.000Z"), type = "Video 📺", topics = listOf( - Topic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "0", name = "Headlines", shortDescription = "", @@ -556,7 +571,7 @@ private val sampleNewsResources = listOf( ), ), ), - NewsResource( + com.google.samples.apps.nowinandroid.core.model.NewsResource( id = "2", title = "Transformations and customisations in the Paging Library", content = "A demonstration of different operations that can be performed with Paging. " + @@ -567,7 +582,7 @@ private val sampleNewsResources = listOf( publishDate = Instant.parse("2021-11-01T00:00:00.000Z"), type = "Video 📺", topics = listOf( - Topic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "1", name = "UI", shortDescription = "", @@ -577,7 +592,7 @@ private val sampleNewsResources = listOf( ), ), ), - NewsResource( + com.google.samples.apps.nowinandroid.core.model.NewsResource( id = "3", title = "Community tip on Paging", content = "Tips for using the Paging library from the developer community", @@ -586,7 +601,7 @@ private val sampleNewsResources = listOf( publishDate = Instant.parse("2021-11-08T00:00:00.000Z"), type = "Video 📺", topics = listOf( - Topic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "1", name = "UI", shortDescription = "", diff --git a/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/InterestsScreen.kt b/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/InterestsScreen.kt index dbd87e953..c8539f841 100644 --- a/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/InterestsScreen.kt +++ b/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/InterestsScreen.kt @@ -29,7 +29,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaBackground import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaLoadingWheel import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme -import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic +import com.google.samples.apps.nowinandroid.core.model.FollowableTopic import com.google.samples.apps.nowinandroid.core.ui.DevicePreviews import com.google.samples.apps.nowinandroid.core.ui.FollowableTopicPreviewParameterProvider import com.google.samples.apps.nowinandroid.core.ui.TrackScreenViewEvent @@ -99,7 +99,7 @@ private fun InterestsEmptyScreen() { @Composable fun InterestsScreenPopulated( @PreviewParameter(FollowableTopicPreviewParameterProvider::class) - followableTopics: List, + followableTopics: List, ) { NiaTheme { NiaBackground { diff --git a/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/InterestsViewModel.kt b/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/InterestsViewModel.kt index 6db274eb3..5a406f514 100644 --- a/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/InterestsViewModel.kt +++ b/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/InterestsViewModel.kt @@ -19,7 +19,7 @@ package com.google.samples.apps.nowinandroid.feature.interests import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic +import com.google.samples.apps.nowinandroid.core.model.FollowableTopic import com.google.samples.apps.nowinandroid.core.domain.repository.UserDataRepository import com.google.samples.apps.nowinandroid.core.domain.usecase.GetFollowableTopicsUseCase import com.google.samples.apps.nowinandroid.core.domain.usecase.TopicSortField @@ -67,7 +67,7 @@ sealed interface InterestsUiState { data class Interests( val selectedTopicId: String?, - val topics: List, + val topics: List, ) : InterestsUiState data object Empty : InterestsUiState diff --git a/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/TabContent.kt b/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/TabContent.kt index ca74bb6e3..90ca3a3a3 100644 --- a/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/TabContent.kt +++ b/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/TabContent.kt @@ -38,11 +38,11 @@ import androidx.compose.ui.unit.dp import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollbar.DraggableScrollbar import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollbar.rememberDraggableScroller import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollbar.scrollbarState -import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic +import com.google.samples.apps.nowinandroid.core.model.FollowableTopic @Composable fun TopicsTabContent( - topics: List, + topics: List, onTopicClick: (String) -> Unit, onFollowButtonClick: (String, Boolean) -> Unit, modifier: Modifier = Modifier, diff --git a/feature/interests/src/test/kotlin/com/google/samples/apps/nowinandroid/interests/InterestsViewModelTest.kt b/feature/interests/src/test/kotlin/com/google/samples/apps/nowinandroid/interests/InterestsViewModelTest.kt index 5e2675229..fe8ca91a8 100644 --- a/feature/interests/src/test/kotlin/com/google/samples/apps/nowinandroid/interests/InterestsViewModelTest.kt +++ b/feature/interests/src/test/kotlin/com/google/samples/apps/nowinandroid/interests/InterestsViewModelTest.kt @@ -17,8 +17,8 @@ package com.google.samples.apps.nowinandroid.interests import androidx.lifecycle.SavedStateHandle -import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic -import com.google.samples.apps.nowinandroid.core.domain.model.Topic +import com.google.samples.apps.nowinandroid.core.model.FollowableTopic +import com.google.samples.apps.nowinandroid.core.model.Topic import com.google.samples.apps.nowinandroid.core.domain.usecase.GetFollowableTopicsUseCase import com.google.samples.apps.nowinandroid.core.testing.repository.TestTopicsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository @@ -149,8 +149,8 @@ private const val TOPIC_URL = "URL" private const val TOPIC_IMAGE_URL = "Image URL" private val testInputTopics = listOf( - FollowableTopic( - Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "0", name = TOPIC_1_NAME, shortDescription = TOPIC_SHORT_DESC, @@ -160,8 +160,8 @@ private val testInputTopics = listOf( ), isFollowed = true, ), - FollowableTopic( - Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "1", name = TOPIC_2_NAME, shortDescription = TOPIC_SHORT_DESC, @@ -171,8 +171,8 @@ private val testInputTopics = listOf( ), isFollowed = false, ), - FollowableTopic( - Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "2", name = TOPIC_3_NAME, shortDescription = TOPIC_SHORT_DESC, @@ -185,8 +185,8 @@ private val testInputTopics = listOf( ) private val testOutputTopics = listOf( - FollowableTopic( - Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "0", name = TOPIC_1_NAME, shortDescription = TOPIC_SHORT_DESC, @@ -196,8 +196,8 @@ private val testOutputTopics = listOf( ), isFollowed = true, ), - FollowableTopic( - Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "1", name = TOPIC_2_NAME, shortDescription = TOPIC_SHORT_DESC, @@ -207,8 +207,8 @@ private val testOutputTopics = listOf( ), isFollowed = true, ), - FollowableTopic( - Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "2", name = TOPIC_3_NAME, shortDescription = TOPIC_SHORT_DESC, diff --git a/feature/search/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchScreenTest.kt b/feature/search/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchScreenTest.kt index 80bb113c5..18f47a4e5 100644 --- a/feature/search/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchScreenTest.kt +++ b/feature/search/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchScreenTest.kt @@ -28,11 +28,11 @@ import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performScrollToIndex -import com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig.DARK -import com.google.samples.apps.nowinandroid.core.domain.model.RecentSearchQuery -import com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand.ANDROID -import com.google.samples.apps.nowinandroid.core.domain.model.UserData -import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource +import com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig.DARK +import com.google.samples.apps.nowinandroid.core.model.RecentSearchQuery +import com.google.samples.apps.nowinandroid.core.model.ThemeBrand.ANDROID +import com.google.samples.apps.nowinandroid.core.model.UserData +import com.google.samples.apps.nowinandroid.core.model.UserNewsResource import com.google.samples.apps.nowinandroid.core.testing.data.followableTopicTestData import com.google.samples.apps.nowinandroid.core.testing.data.newsResourcesTestData import org.junit.Before @@ -57,15 +57,16 @@ class SearchScreenTest { private lateinit var tryAnotherSearchString: String private lateinit var searchNotReadyString: String - private val userData: UserData = UserData( - bookmarkedNewsResources = setOf("1", "3"), - viewedNewsResources = setOf("1", "2", "4"), - followedTopics = emptySet(), - themeBrand = ANDROID, - darkThemeConfig = DARK, - shouldHideOnboarding = true, - useDynamicColor = false, - ) + private val userData: com.google.samples.apps.nowinandroid.core.model.UserData = + com.google.samples.apps.nowinandroid.core.model.UserData( + bookmarkedNewsResources = setOf("1", "3"), + viewedNewsResources = setOf("1", "2", "4"), + followedTopics = emptySet(), + themeBrand = ANDROID, + darkThemeConfig = DARK, + shouldHideOnboarding = true, + useDynamicColor = false, + ) @Before fun setup() { @@ -169,7 +170,7 @@ class SearchScreenTest { SearchScreen( searchResultUiState = SearchResultUiState.Success( newsResources = newsResourcesTestData.map { - UserNewsResource( + com.google.samples.apps.nowinandroid.core.model.UserNewsResource( newsResource = it, userData = userData, ) diff --git a/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/RecentSearchQueriesUiState.kt b/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/RecentSearchQueriesUiState.kt index 1f421d94c..129fbc73f 100644 --- a/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/RecentSearchQueriesUiState.kt +++ b/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/RecentSearchQueriesUiState.kt @@ -16,12 +16,12 @@ package com.google.samples.apps.nowinandroid.feature.search -import com.google.samples.apps.nowinandroid.core.domain.model.RecentSearchQuery +import com.google.samples.apps.nowinandroid.core.model.RecentSearchQuery sealed interface RecentSearchQueriesUiState { data object Loading : RecentSearchQueriesUiState data class Success( - val recentQueries: List = emptyList(), + val recentQueries: List = emptyList(), ) : RecentSearchQueriesUiState } diff --git a/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchResultUiState.kt b/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchResultUiState.kt index 71a09d762..fd0818557 100644 --- a/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchResultUiState.kt +++ b/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchResultUiState.kt @@ -16,8 +16,8 @@ package com.google.samples.apps.nowinandroid.feature.search -import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic -import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource +import com.google.samples.apps.nowinandroid.core.model.FollowableTopic +import com.google.samples.apps.nowinandroid.core.model.UserNewsResource sealed interface SearchResultUiState { data object Loading : SearchResultUiState @@ -32,8 +32,8 @@ sealed interface SearchResultUiState { data object LoadFailed : SearchResultUiState data class Success( - val topics: List = emptyList(), - val newsResources: List = emptyList(), + val topics: List = emptyList(), + val newsResources: List = emptyList(), ) : SearchResultUiState { fun isEmpty(): Boolean = topics.isEmpty() && newsResources.isEmpty() } diff --git a/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchScreen.kt b/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchScreen.kt index f09c50f9d..78bfd6ecf 100644 --- a/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchScreen.kt +++ b/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchScreen.kt @@ -85,8 +85,8 @@ import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollba import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollbar.scrollbarState import com.google.samples.apps.nowinandroid.core.designsystem.icon.NiaIcons import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme -import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic -import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource +import com.google.samples.apps.nowinandroid.core.model.FollowableTopic +import com.google.samples.apps.nowinandroid.core.model.UserNewsResource import com.google.samples.apps.nowinandroid.core.ui.DevicePreviews import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState.Success import com.google.samples.apps.nowinandroid.core.ui.R.string @@ -287,8 +287,8 @@ private fun SearchNotReadyBody() { @Composable private fun SearchResultBody( searchQuery: String, - topics: List, - newsResources: List, + topics: List, + newsResources: List, onSearchTriggered: (String) -> Unit, onTopicClick: (String) -> Unit, onNewsResourcesCheckedChanged: (String, Boolean) -> Unit, diff --git a/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchUiStatePreviewParameterProvider.kt b/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchUiStatePreviewParameterProvider.kt index b037afe5b..f4bd2ccc7 100644 --- a/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchUiStatePreviewParameterProvider.kt +++ b/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchUiStatePreviewParameterProvider.kt @@ -19,7 +19,7 @@ package com.google.samples.apps.nowinandroid.feature.search import androidx.compose.ui.tooling.preview.PreviewParameterProvider -import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic +import com.google.samples.apps.nowinandroid.core.model.FollowableTopic import com.google.samples.apps.nowinandroid.core.ui.PreviewParameterData.newsResources import com.google.samples.apps.nowinandroid.core.ui.PreviewParameterData.topics @@ -31,7 +31,10 @@ class SearchUiStatePreviewParameterProvider : PreviewParameterProvider = sequenceOf( SearchResultUiState.Success( topics = topics.mapIndexed { i, topic -> - FollowableTopic(topic = topic, isFollowed = i % 2 == 0) + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + topic = topic, + isFollowed = i % 2 == 0 + ) }, newsResources = newsResources, ), diff --git a/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchViewModel.kt b/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchViewModel.kt index 1b626acdb..4a5ed6d9a 100644 --- a/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchViewModel.kt +++ b/feature/search/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchViewModel.kt @@ -22,7 +22,7 @@ import androidx.lifecycle.viewModelScope import com.google.samples.apps.nowinandroid.core.analytics.AnalyticsEvent import com.google.samples.apps.nowinandroid.core.analytics.AnalyticsEvent.Param import com.google.samples.apps.nowinandroid.core.analytics.AnalyticsHelper -import com.google.samples.apps.nowinandroid.core.domain.model.UserSearchResult +import com.google.samples.apps.nowinandroid.core.model.UserSearchResult import com.google.samples.apps.nowinandroid.core.domain.repository.RecentSearchRepository import com.google.samples.apps.nowinandroid.core.domain.usecase.GetRecentSearchQueriesUseCase import com.google.samples.apps.nowinandroid.core.domain.usecase.GetSearchContentsCountUseCase @@ -63,7 +63,7 @@ class SearchViewModel @Inject constructor( getSearchContentsUseCase(query) // Not using .asResult() here, because it emits Loading state every // time the user types a letter in the search box, which flickers the screen. - .map { data -> + .map { data -> SearchResultUiState.Success( topics = data.topics, newsResources = data.newsResources, diff --git a/feature/settings/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialogTest.kt b/feature/settings/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialogTest.kt index 25fae3a3e..fbd4bd7f6 100644 --- a/feature/settings/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialogTest.kt +++ b/feature/settings/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialogTest.kt @@ -20,9 +20,9 @@ import androidx.activity.ComponentActivity import androidx.compose.ui.test.assertIsSelected import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.onNodeWithText -import com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig.DARK -import com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand.ANDROID -import com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand.DEFAULT +import com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig.DARK +import com.google.samples.apps.nowinandroid.core.model.ThemeBrand.ANDROID +import com.google.samples.apps.nowinandroid.core.model.ThemeBrand.DEFAULT import com.google.samples.apps.nowinandroid.feature.settings.SettingsUiState.Loading import com.google.samples.apps.nowinandroid.feature.settings.SettingsUiState.Success import org.junit.Rule diff --git a/feature/settings/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialog.kt b/feature/settings/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialog.kt index 5539045b8..f18148f76 100644 --- a/feature/settings/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialog.kt +++ b/feature/settings/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/settings/SettingsDialog.kt @@ -59,13 +59,13 @@ import com.google.android.gms.oss.licenses.OssLicensesMenuActivity import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaTextButton import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme import com.google.samples.apps.nowinandroid.core.designsystem.theme.supportsDynamicTheming -import com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig -import com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig.DARK -import com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig.FOLLOW_SYSTEM -import com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig.LIGHT -import com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand -import com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand.ANDROID -import com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand.DEFAULT +import com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig +import com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig.DARK +import com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig.FOLLOW_SYSTEM +import com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig.LIGHT +import com.google.samples.apps.nowinandroid.core.model.ThemeBrand +import com.google.samples.apps.nowinandroid.core.model.ThemeBrand.ANDROID +import com.google.samples.apps.nowinandroid.core.model.ThemeBrand.DEFAULT import com.google.samples.apps.nowinandroid.core.ui.TrackScreenViewEvent import com.google.samples.apps.nowinandroid.feature.settings.R.string import com.google.samples.apps.nowinandroid.feature.settings.SettingsUiState.Loading @@ -91,9 +91,9 @@ fun SettingsDialog( settingsUiState: SettingsUiState, supportDynamicColor: Boolean = supportsDynamicTheming(), onDismiss: () -> Unit, - onChangeThemeBrand: (themeBrand: ThemeBrand) -> Unit, + onChangeThemeBrand: (themeBrand: com.google.samples.apps.nowinandroid.core.model.ThemeBrand) -> Unit, onChangeDynamicColorPreference: (useDynamicColor: Boolean) -> Unit, - onChangeDarkThemeConfig: (darkThemeConfig: DarkThemeConfig) -> Unit, + onChangeDarkThemeConfig: (darkThemeConfig: com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig) -> Unit, ) { val configuration = LocalConfiguration.current @@ -158,9 +158,9 @@ fun SettingsDialog( private fun ColumnScope.SettingsPanel( settings: UserEditableSettings, supportDynamicColor: Boolean, - onChangeThemeBrand: (themeBrand: ThemeBrand) -> Unit, + onChangeThemeBrand: (themeBrand: com.google.samples.apps.nowinandroid.core.model.ThemeBrand) -> Unit, onChangeDynamicColorPreference: (useDynamicColor: Boolean) -> Unit, - onChangeDarkThemeConfig: (darkThemeConfig: DarkThemeConfig) -> Unit, + onChangeDarkThemeConfig: (darkThemeConfig: com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig) -> Unit, ) { SettingsDialogSectionTitle(text = stringResource(string.feature_settings_theme)) Column(Modifier.selectableGroup()) { diff --git a/feature/settings/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/settings/SettingsViewModel.kt b/feature/settings/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/settings/SettingsViewModel.kt index 39340cffe..40d621810 100644 --- a/feature/settings/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/settings/SettingsViewModel.kt +++ b/feature/settings/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/settings/SettingsViewModel.kt @@ -18,8 +18,8 @@ package com.google.samples.apps.nowinandroid.feature.settings import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig -import com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand +import com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig +import com.google.samples.apps.nowinandroid.core.model.ThemeBrand import com.google.samples.apps.nowinandroid.core.domain.repository.UserDataRepository import com.google.samples.apps.nowinandroid.feature.settings.SettingsUiState.Loading import com.google.samples.apps.nowinandroid.feature.settings.SettingsUiState.Success @@ -53,13 +53,13 @@ class SettingsViewModel @Inject constructor( initialValue = Loading, ) - fun updateThemeBrand(themeBrand: ThemeBrand) { + fun updateThemeBrand(themeBrand: com.google.samples.apps.nowinandroid.core.model.ThemeBrand) { viewModelScope.launch { userDataRepository.setThemeBrand(themeBrand) } } - fun updateDarkThemeConfig(darkThemeConfig: DarkThemeConfig) { + fun updateDarkThemeConfig(darkThemeConfig: com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig) { viewModelScope.launch { userDataRepository.setDarkThemeConfig(darkThemeConfig) } @@ -76,9 +76,9 @@ class SettingsViewModel @Inject constructor( * Represents the settings which the user can edit within the app. */ data class UserEditableSettings( - val brand: ThemeBrand, + val brand: com.google.samples.apps.nowinandroid.core.model.ThemeBrand, val useDynamicColor: Boolean, - val darkThemeConfig: DarkThemeConfig, + val darkThemeConfig: com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig, ) sealed interface SettingsUiState { diff --git a/feature/settings/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/settings/SettingsViewModelTest.kt b/feature/settings/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/settings/SettingsViewModelTest.kt index edddc8d7b..f7bbd738a 100644 --- a/feature/settings/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/settings/SettingsViewModelTest.kt +++ b/feature/settings/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/settings/SettingsViewModelTest.kt @@ -16,8 +16,8 @@ package com.google.samples.apps.nowinandroid.feature.settings -import com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig.DARK -import com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand.ANDROID +import com.google.samples.apps.nowinandroid.core.model.DarkThemeConfig.DARK +import com.google.samples.apps.nowinandroid.core.model.ThemeBrand.ANDROID import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository import com.google.samples.apps.nowinandroid.core.testing.util.MainDispatcherRule import com.google.samples.apps.nowinandroid.feature.settings.SettingsUiState.Loading diff --git a/feature/topic/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/topic/TopicScreen.kt b/feature/topic/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/topic/TopicScreen.kt index 24c739be6..af8e0ce76 100644 --- a/feature/topic/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/topic/TopicScreen.kt +++ b/feature/topic/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/topic/TopicScreen.kt @@ -61,8 +61,8 @@ import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollba import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollbar.scrollbarState import com.google.samples.apps.nowinandroid.core.designsystem.icon.NiaIcons import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme -import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic -import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource +import com.google.samples.apps.nowinandroid.core.model.FollowableTopic +import com.google.samples.apps.nowinandroid.core.model.UserNewsResource import com.google.samples.apps.nowinandroid.core.ui.DevicePreviews import com.google.samples.apps.nowinandroid.core.ui.TrackScreenViewEvent import com.google.samples.apps.nowinandroid.core.ui.TrackScrollJank @@ -274,7 +274,7 @@ private fun TopicBodyPreview() { @Composable private fun TopicToolbar( - uiState: FollowableTopic, + uiState: com.google.samples.apps.nowinandroid.core.model.FollowableTopic, modifier: Modifier = Modifier, showBackButton: Boolean = true, onBackClick: () -> Unit = {}, @@ -319,7 +319,7 @@ private fun TopicToolbar( @Composable fun TopicScreenPopulated( @PreviewParameter(UserNewsResourcePreviewParameterProvider::class) - userNewsResources: List, + userNewsResources: List, ) { NiaTheme { NiaBackground { diff --git a/feature/topic/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModel.kt b/feature/topic/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModel.kt index 33fc16c03..32d82b36c 100644 --- a/feature/topic/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModel.kt +++ b/feature/topic/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModel.kt @@ -19,9 +19,9 @@ package com.google.samples.apps.nowinandroid.feature.topic import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic -import com.google.samples.apps.nowinandroid.core.domain.model.Topic -import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource +import com.google.samples.apps.nowinandroid.core.model.FollowableTopic +import com.google.samples.apps.nowinandroid.core.model.Topic +import com.google.samples.apps.nowinandroid.core.model.UserNewsResource import com.google.samples.apps.nowinandroid.core.domain.repository.NewsResourceQuery import com.google.samples.apps.nowinandroid.core.domain.repository.TopicsRepository import com.google.samples.apps.nowinandroid.core.domain.repository.UserDataRepository @@ -103,7 +103,7 @@ private fun topicUiState( .map { it.followedTopics } // Observe topic information - val topicStream: Flow = topicsRepository.getTopic( + val topicStream: Flow = topicsRepository.getTopic( id = topicId, ) @@ -118,7 +118,7 @@ private fun topicUiState( is Result.Success -> { val (followedTopics, topic) = followedTopicToTopicResult.data TopicUiState.Success( - followableTopic = FollowableTopic( + followableTopic = com.google.samples.apps.nowinandroid.core.model.FollowableTopic( topic = topic, isFollowed = topicId in followedTopics, ), @@ -137,7 +137,7 @@ private fun newsUiState( userDataRepository: UserDataRepository, ): Flow { // Observe news - val newsStream: Flow> = userNewsResourceRepository.observeAll( + val newsStream: Flow> = userNewsResourceRepository.observeAll( NewsResourceQuery(filterTopicIds = setOf(element = topicId)), ) @@ -157,13 +157,13 @@ private fun newsUiState( } sealed interface TopicUiState { - data class Success(val followableTopic: FollowableTopic) : TopicUiState + data class Success(val followableTopic: com.google.samples.apps.nowinandroid.core.model.FollowableTopic) : TopicUiState data object Error : TopicUiState data object Loading : TopicUiState } sealed interface NewsUiState { - data class Success(val news: List) : NewsUiState + data class Success(val news: List) : NewsUiState data object Error : NewsUiState data object Loading : NewsUiState } diff --git a/feature/topic/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModelTest.kt b/feature/topic/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModelTest.kt index ff50da74c..fcbb27883 100644 --- a/feature/topic/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModelTest.kt +++ b/feature/topic/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModelTest.kt @@ -18,9 +18,9 @@ package com.google.samples.apps.nowinandroid.feature.topic import androidx.lifecycle.SavedStateHandle import com.google.samples.apps.nowinandroid.core.data.repository.CompositeUserNewsResourceRepository -import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic -import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource -import com.google.samples.apps.nowinandroid.core.domain.model.Topic +import com.google.samples.apps.nowinandroid.core.model.FollowableTopic +import com.google.samples.apps.nowinandroid.core.model.NewsResource +import com.google.samples.apps.nowinandroid.core.model.Topic import com.google.samples.apps.nowinandroid.core.testing.repository.TestNewsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestTopicsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository @@ -75,7 +75,7 @@ class TopicViewModelTest { fun uiStateTopic_whenSuccess_matchesTopicFromRepository() = runTest { val collectJob = launch(UnconfinedTestDispatcher()) { viewModel.topicUiState.collect() } - topicsRepository.sendTopics(testInputTopics.map(FollowableTopic::topic)) + topicsRepository.sendTopics(testInputTopics.map(com.google.samples.apps.nowinandroid.core.model.FollowableTopic::topic)) userDataRepository.setFollowedTopicIds(setOf(testInputTopics[1].topic.id)) val item = viewModel.topicUiState.value assertIs(item) @@ -175,8 +175,8 @@ private const val TOPIC_URL = "URL" private const val TOPIC_IMAGE_URL = "Image URL" private val testInputTopics = listOf( - FollowableTopic( - Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "0", name = TOPIC_1_NAME, shortDescription = TOPIC_SHORT_DESC, @@ -186,8 +186,8 @@ private val testInputTopics = listOf( ), isFollowed = true, ), - FollowableTopic( - Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "1", name = TOPIC_2_NAME, shortDescription = TOPIC_SHORT_DESC, @@ -197,8 +197,8 @@ private val testInputTopics = listOf( ), isFollowed = false, ), - FollowableTopic( - Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "2", name = TOPIC_3_NAME, shortDescription = TOPIC_SHORT_DESC, @@ -211,8 +211,8 @@ private val testInputTopics = listOf( ) private val testOutputTopics = listOf( - FollowableTopic( - Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "0", name = TOPIC_1_NAME, shortDescription = TOPIC_SHORT_DESC, @@ -222,8 +222,8 @@ private val testOutputTopics = listOf( ), isFollowed = true, ), - FollowableTopic( - Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "1", name = TOPIC_2_NAME, shortDescription = TOPIC_SHORT_DESC, @@ -233,8 +233,8 @@ private val testOutputTopics = listOf( ), isFollowed = true, ), - FollowableTopic( - Topic( + com.google.samples.apps.nowinandroid.core.model.FollowableTopic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "2", name = TOPIC_3_NAME, shortDescription = TOPIC_SHORT_DESC, @@ -247,7 +247,7 @@ private val testOutputTopics = listOf( ) private val sampleNewsResources = listOf( - NewsResource( + com.google.samples.apps.nowinandroid.core.model.NewsResource( id = "1", title = "Thanks for helping us reach 1M YouTube Subscribers", content = "Thank you everyone for following the Now in Android series and everything the " + @@ -259,7 +259,7 @@ private val sampleNewsResources = listOf( publishDate = Instant.parse("2021-11-09T00:00:00.000Z"), type = "Video 📺", topics = listOf( - Topic( + com.google.samples.apps.nowinandroid.core.model.Topic( id = "0", name = "Headlines", shortDescription = "", diff --git a/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/workers/SyncWorker.kt b/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/workers/SyncWorker.kt index 1d0d3b392..e3fa8a746 100644 --- a/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/workers/SyncWorker.kt +++ b/sync/work/src/main/kotlin/com/google/samples/apps/nowinandroid/sync/workers/SyncWorker.kt @@ -26,7 +26,7 @@ import androidx.work.OutOfQuotaPolicy import androidx.work.WorkerParameters import com.google.samples.apps.nowinandroid.core.analytics.AnalyticsHelper import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesDataSource -import com.google.samples.apps.nowinandroid.core.domain.model.ChangeListVersions +import com.google.samples.apps.nowinandroid.core.model.ChangeListVersions import com.google.samples.apps.nowinandroid.core.domain.repository.NewsRepository import com.google.samples.apps.nowinandroid.core.domain.repository.SearchContentsRepository import com.google.samples.apps.nowinandroid.core.domain.repository.TopicsRepository @@ -86,11 +86,11 @@ internal class SyncWorker @AssistedInject constructor( } } - override suspend fun getChangeListVersions(): ChangeListVersions = + override suspend fun getChangeListVersions(): com.google.samples.apps.nowinandroid.core.model.ChangeListVersions = niaPreferences.getChangeListVersions() override suspend fun updateChangeListVersions( - update: ChangeListVersions.() -> ChangeListVersions, + update: com.google.samples.apps.nowinandroid.core.model.ChangeListVersions.() -> com.google.samples.apps.nowinandroid.core.model.ChangeListVersions, ) = niaPreferences.updateChangeListVersion(update) companion object {