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 c9cc64120..52001de1d 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,8 +35,8 @@ 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.data.repository.TopicsRepository -import com.google.samples.apps.nowinandroid.core.model.data.Topic +import com.google.samples.apps.nowinandroid.core.domain.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 import dagger.hilt.android.testing.HiltAndroidRule 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 ad95c297f..45ef919cb 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 @@ -41,12 +41,12 @@ import com.google.samples.apps.nowinandroid.MainActivityUiState.Loading import com.google.samples.apps.nowinandroid.MainActivityUiState.Success import com.google.samples.apps.nowinandroid.core.analytics.AnalyticsHelper import com.google.samples.apps.nowinandroid.core.analytics.LocalAnalyticsHelper -import com.google.samples.apps.nowinandroid.core.data.repository.UserNewsResourceRepository 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.model.data.DarkThemeConfig -import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand +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.repository.UserNewsResourceRepository import com.google.samples.apps.nowinandroid.core.ui.LocalTimeZone import com.google.samples.apps.nowinandroid.ui.NiaApp import com.google.samples.apps.nowinandroid.ui.rememberNiaAppState 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 09f4597a7..14d282bd4 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,8 +20,8 @@ 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.data.repository.UserDataRepository -import com.google.samples.apps.nowinandroid.core.model.data.UserData +import com.google.samples.apps.nowinandroid.core.domain.model.UserData +import com.google.samples.apps.nowinandroid.core.domain.repository.UserDataRepository import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow diff --git a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppState.kt b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppState.kt index b653d8910..a9cdb626c 100644 --- a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppState.kt +++ b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppState.kt @@ -30,9 +30,9 @@ import androidx.navigation.compose.currentBackStackEntryAsState import androidx.navigation.compose.rememberNavController import androidx.navigation.navOptions import androidx.tracing.trace -import com.google.samples.apps.nowinandroid.core.data.repository.UserNewsResourceRepository 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.domain.repository.UserNewsResourceRepository import com.google.samples.apps.nowinandroid.core.ui.TrackDisposableJank import com.google.samples.apps.nowinandroid.feature.bookmarks.navigation.BOOKMARKS_ROUTE import com.google.samples.apps.nowinandroid.feature.bookmarks.navigation.navigateToBookmarks diff --git a/app/src/testDemo/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppScreenSizesScreenshotTests.kt b/app/src/testDemo/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppScreenSizesScreenshotTests.kt index 83ca1bb3d..d68cbc26a 100644 --- a/app/src/testDemo/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppScreenSizesScreenshotTests.kt +++ b/app/src/testDemo/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppScreenSizesScreenshotTests.kt @@ -33,12 +33,12 @@ import androidx.work.testing.SynchronousExecutor import androidx.work.testing.WorkManagerTestInitHelper import com.github.takahirom.roborazzi.captureRoboImage import com.google.accompanist.testharness.TestHarness -import com.google.samples.apps.nowinandroid.core.data.repository.TopicsRepository -import com.google.samples.apps.nowinandroid.core.data.repository.UserDataRepository -import com.google.samples.apps.nowinandroid.core.data.repository.UserNewsResourceRepository 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.repository.TopicsRepository +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.testing.util.DefaultRoborazziOptions import com.google.samples.apps.nowinandroid.uitesthiltmanifest.HiltComponentActivity import dagger.hilt.android.testing.BindValue diff --git a/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/TestDataModule.kt b/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/TestDataModule.kt index 46158479c..4ebd77646 100644 --- a/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/TestDataModule.kt +++ b/core/data-test/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/test/TestDataModule.kt @@ -17,11 +17,6 @@ package com.google.samples.apps.nowinandroid.core.data.test import com.google.samples.apps.nowinandroid.core.data.di.DataModule -import com.google.samples.apps.nowinandroid.core.data.repository.NewsRepository -import com.google.samples.apps.nowinandroid.core.data.repository.RecentSearchRepository -import com.google.samples.apps.nowinandroid.core.data.repository.SearchContentsRepository -import com.google.samples.apps.nowinandroid.core.data.repository.TopicsRepository -import com.google.samples.apps.nowinandroid.core.data.repository.UserDataRepository import com.google.samples.apps.nowinandroid.core.data.test.repository.FakeNewsRepository import com.google.samples.apps.nowinandroid.core.data.test.repository.FakeRecentSearchRepository import com.google.samples.apps.nowinandroid.core.data.test.repository.FakeSearchContentsRepository @@ -29,6 +24,11 @@ import com.google.samples.apps.nowinandroid.core.data.test.repository.FakeTopics import com.google.samples.apps.nowinandroid.core.data.test.repository.FakeUserDataRepository 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.domain.repository.NewsRepository +import com.google.samples.apps.nowinandroid.core.domain.repository.RecentSearchRepository +import com.google.samples.apps.nowinandroid.core.domain.repository.SearchContentsRepository +import com.google.samples.apps.nowinandroid.core.domain.repository.TopicsRepository +import com.google.samples.apps.nowinandroid.core.domain.repository.UserDataRepository import dagger.Binds import dagger.Module import dagger.hilt.components.SingletonComponent 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 5ceff4dd0..a74fc02e3 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 @@ -16,13 +16,13 @@ package com.google.samples.apps.nowinandroid.core.data.test.repository -import com.google.samples.apps.nowinandroid.core.data.Synchronizer import com.google.samples.apps.nowinandroid.core.data.model.asEntity -import com.google.samples.apps.nowinandroid.core.data.repository.NewsRepository -import com.google.samples.apps.nowinandroid.core.data.repository.NewsResourceQuery 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.model.data.NewsResource +import com.google.samples.apps.nowinandroid.core.domain.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 import com.google.samples.apps.nowinandroid.core.network.Dispatcher import com.google.samples.apps.nowinandroid.core.network.NiaDispatchers.IO import com.google.samples.apps.nowinandroid.core.network.fake.FakeNiaNetworkDataSource 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 b8d949efe..ca657b152 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,8 +16,8 @@ package com.google.samples.apps.nowinandroid.core.data.test.repository -import com.google.samples.apps.nowinandroid.core.data.model.RecentSearchQuery -import com.google.samples.apps.nowinandroid.core.data.repository.RecentSearchRepository +import com.google.samples.apps.nowinandroid.core.domain.model.RecentSearchQuery +import com.google.samples.apps.nowinandroid.core.domain.repository.RecentSearchRepository import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf import javax.inject.Inject 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 1feeb6dcc..d176d97a2 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,8 +16,8 @@ package com.google.samples.apps.nowinandroid.core.data.test.repository -import com.google.samples.apps.nowinandroid.core.data.repository.SearchContentsRepository -import com.google.samples.apps.nowinandroid.core.model.data.SearchResult +import com.google.samples.apps.nowinandroid.core.domain.model.SearchResult +import com.google.samples.apps.nowinandroid.core.domain.repository.SearchContentsRepository import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf import javax.inject.Inject 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 f8ebca29e..0e409d7ea 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,9 +16,9 @@ package com.google.samples.apps.nowinandroid.core.data.test.repository -import com.google.samples.apps.nowinandroid.core.data.Synchronizer -import com.google.samples.apps.nowinandroid.core.data.repository.TopicsRepository -import com.google.samples.apps.nowinandroid.core.model.data.Topic +import com.google.samples.apps.nowinandroid.core.domain.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 import com.google.samples.apps.nowinandroid.core.network.NiaDispatchers.IO import com.google.samples.apps.nowinandroid.core.network.fake.FakeNiaNetworkDataSource 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 cdd23429f..3a408354e 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 @@ -16,11 +16,11 @@ package com.google.samples.apps.nowinandroid.core.data.test.repository -import com.google.samples.apps.nowinandroid.core.data.repository.UserDataRepository import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesDataSource -import com.google.samples.apps.nowinandroid.core.model.data.DarkThemeConfig -import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand -import com.google.samples.apps.nowinandroid.core.model.data.UserData +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.domain.repository.UserDataRepository import kotlinx.coroutines.flow.Flow import javax.inject.Inject diff --git a/core/data/build.gradle.kts b/core/data/build.gradle.kts index 142637ff9..e047c0e87 100644 --- a/core/data/build.gradle.kts +++ b/core/data/build.gradle.kts @@ -35,6 +35,7 @@ dependencies { api(projects.core.database) api(projects.core.datastore) api(projects.core.network) + api(projects.core.domain) implementation(projects.core.analytics) implementation(projects.core.notifications) diff --git a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/SyncUtilities.kt b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/SyncUtilities.kt deleted file mode 100644 index 5d069dbaf..000000000 --- a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/SyncUtilities.kt +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.samples.apps.nowinandroid.core.data - -import android.util.Log -import com.google.samples.apps.nowinandroid.core.datastore.ChangeListVersions -import com.google.samples.apps.nowinandroid.core.network.model.NetworkChangeList -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.combine -import kotlin.coroutines.cancellation.CancellationException - -/** - * Interface marker for a class that manages synchronization between local data and a remote - * source for a [Syncable]. - */ -interface Synchronizer { - suspend fun getChangeListVersions(): ChangeListVersions - - suspend fun updateChangeListVersions(update: ChangeListVersions.() -> ChangeListVersions) - - /** - * Syntactic sugar to call [Syncable.syncWith] while omitting the synchronizer argument - */ - suspend fun Syncable.sync() = this@sync.syncWith(this@Synchronizer) -} - -/** - * Interface marker for a class that is synchronized with a remote source. Syncing must not be - * performed concurrently and it is the [Synchronizer]'s responsibility to ensure this. - */ -interface Syncable { - /** - * Synchronizes the local database backing the repository with the network. - * Returns if the sync was successful or not. - */ - suspend fun syncWith(synchronizer: Synchronizer): Boolean -} - -/** - * Attempts [block], returning a successful [Result] if it succeeds, otherwise a [Result.Failure] - * taking care not to break structured concurrency - */ -private suspend fun suspendRunCatching(block: suspend () -> T): Result = try { - Result.success(block()) -} catch (cancellationException: CancellationException) { - throw cancellationException -} catch (exception: Exception) { - Log.i( - "suspendRunCatching", - "Failed to evaluate a suspendRunCatchingBlock. Returning failure Result", - exception, - ) - Result.failure(exception) -} - -/** - * Utility function for syncing a repository with the network. - * [versionReader] Reads the current version of the model that needs to be synced - * [changeListFetcher] Fetches the change list for the model - * [versionUpdater] Updates the [ChangeListVersions] after a successful sync - * [modelDeleter] Deletes models by consuming the ids of the models that have been deleted. - * [modelUpdater] Updates models by consuming the ids of the models that have changed. - * - * Note that the blocks defined above are never run concurrently, and the [Synchronizer] - * implementation must guarantee this. - */ -suspend fun Synchronizer.changeListSync( - versionReader: (ChangeListVersions) -> Int, - changeListFetcher: suspend (Int) -> List, - versionUpdater: ChangeListVersions.(Int) -> ChangeListVersions, - modelDeleter: suspend (List) -> Unit, - modelUpdater: suspend (List) -> Unit, -) = suspendRunCatching { - // Fetch the change list since last sync (akin to a git fetch) - val currentVersion = versionReader(getChangeListVersions()) - val changeList = changeListFetcher(currentVersion) - if (changeList.isEmpty()) return@suspendRunCatching true - - val (deleted, updated) = changeList.partition(NetworkChangeList::isDelete) - - // Delete models that have been deleted server-side - modelDeleter(deleted.map(NetworkChangeList::id)) - - // Using the change list, pull down and save the changes (akin to a git pull) - modelUpdater(updated.map(NetworkChangeList::id)) - - // Update the last synced version (akin to updating local git HEAD) - val latestVersion = changeList.last().changeListVersion - updateChangeListVersions { - versionUpdater(latestVersion) - } -}.isSuccess - -/** - * Returns a [Flow] whose values are generated by [transform] function that process the most - * recently emitted values by each flow. - */ -fun combine( - flow: Flow, - flow2: Flow, - flow3: Flow, - flow4: Flow, - flow5: Flow, - flow6: Flow, - transform: suspend (T1, T2, T3, T4, T5, T6) -> R, -): Flow = combine( - combine(flow, flow2, flow3, ::Triple), - combine(flow4, flow5, flow6, ::Triple), -) { t1, t2 -> - transform( - t1.first, - t1.second, - t1.third, - t2.first, - t2.second, - t2.third, - ) -} diff --git a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/di/DataModule.kt b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/di/DataModule.kt index fa4bde8b8..422fa5f3a 100644 --- a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/di/DataModule.kt +++ b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/di/DataModule.kt @@ -18,18 +18,18 @@ package com.google.samples.apps.nowinandroid.core.data.di import com.google.samples.apps.nowinandroid.core.data.repository.DefaultRecentSearchRepository import com.google.samples.apps.nowinandroid.core.data.repository.DefaultSearchContentsRepository -import com.google.samples.apps.nowinandroid.core.data.repository.NewsRepository import com.google.samples.apps.nowinandroid.core.data.repository.OfflineFirstNewsRepository import com.google.samples.apps.nowinandroid.core.data.repository.OfflineFirstTopicsRepository import com.google.samples.apps.nowinandroid.core.data.repository.OfflineFirstUserDataRepository -import com.google.samples.apps.nowinandroid.core.data.repository.RecentSearchRepository -import com.google.samples.apps.nowinandroid.core.data.repository.SearchContentsRepository -import com.google.samples.apps.nowinandroid.core.data.repository.TopicsRepository -import com.google.samples.apps.nowinandroid.core.data.repository.UserDataRepository import com.google.samples.apps.nowinandroid.core.data.util.ConnectivityManagerNetworkMonitor import com.google.samples.apps.nowinandroid.core.data.util.NetworkMonitor import com.google.samples.apps.nowinandroid.core.data.util.TimeZoneBroadcastMonitor import com.google.samples.apps.nowinandroid.core.data.util.TimeZoneMonitor +import com.google.samples.apps.nowinandroid.core.domain.repository.NewsRepository +import com.google.samples.apps.nowinandroid.core.domain.repository.RecentSearchRepository +import com.google.samples.apps.nowinandroid.core.domain.repository.SearchContentsRepository +import com.google.samples.apps.nowinandroid.core.domain.repository.TopicsRepository +import com.google.samples.apps.nowinandroid.core.domain.repository.UserDataRepository import dagger.Binds import dagger.Module import dagger.hilt.InstallIn diff --git a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/di/UserNewsResourceRepositoryModule.kt b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/di/UserNewsResourceRepositoryModule.kt index 7f4e27b41..32dded0d7 100644 --- a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/di/UserNewsResourceRepositoryModule.kt +++ b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/di/UserNewsResourceRepositoryModule.kt @@ -17,7 +17,7 @@ package com.google.samples.apps.nowinandroid.core.data.di import com.google.samples.apps.nowinandroid.core.data.repository.CompositeUserNewsResourceRepository -import com.google.samples.apps.nowinandroid.core.data.repository.UserNewsResourceRepository +import com.google.samples.apps.nowinandroid.core.domain.repository.UserNewsResourceRepository import dagger.Binds import dagger.Module import dagger.hilt.InstallIn diff --git a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/model/NewsResource.kt b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/model/NewsResource.kt index c3ad91dfe..a74ad7241 100644 --- a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/model/NewsResource.kt +++ b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/model/NewsResource.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. 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 76dd08811..5478572fa 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 @@ -1,5 +1,5 @@ /* - * Copyright 2023 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. @@ -17,13 +17,7 @@ package com.google.samples.apps.nowinandroid.core.data.model import com.google.samples.apps.nowinandroid.core.database.model.RecentSearchQueryEntity -import kotlinx.datetime.Clock -import kotlinx.datetime.Instant - -data class RecentSearchQuery( - val query: String, - val queriedDate: Instant = Clock.System.now(), -) +import com.google.samples.apps.nowinandroid.core.domain.model.RecentSearchQuery fun RecentSearchQueryEntity.asExternalModel() = RecentSearchQuery( query = query, diff --git a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/model/Topic.kt b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/model/Topic.kt index 188b1e06d..ccebbf81e 100644 --- a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/model/Topic.kt +++ b/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/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. 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 64e02e7d9..d7132156a 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,12 @@ package com.google.samples.apps.nowinandroid.core.data.repository -import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource -import com.google.samples.apps.nowinandroid.core.model.data.mapToUserNewsResources +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.domain.repository.NewsRepository +import com.google.samples.apps.nowinandroid.core.domain.repository.NewsResourceQuery +import com.google.samples.apps.nowinandroid.core.domain.repository.UserDataRepository +import com.google.samples.apps.nowinandroid.core.domain.repository.UserNewsResourceRepository import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged 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 32239362d..37ad8aba8 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 @@ -16,10 +16,11 @@ package com.google.samples.apps.nowinandroid.core.data.repository -import com.google.samples.apps.nowinandroid.core.data.model.RecentSearchQuery 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.domain.repository.RecentSearchRepository import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map import kotlinx.datetime.Clock 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 3bacb8a14..d7549cb41 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,8 @@ 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.model.data.SearchResult +import com.google.samples.apps.nowinandroid.core.domain.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 import kotlinx.coroutines.CoroutineDispatcher 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 d33c904e5..36259aa66 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 @@ -16,19 +16,21 @@ package com.google.samples.apps.nowinandroid.core.data.repository -import com.google.samples.apps.nowinandroid.core.data.Synchronizer -import com.google.samples.apps.nowinandroid.core.data.changeListSync import com.google.samples.apps.nowinandroid.core.data.model.asEntity import com.google.samples.apps.nowinandroid.core.data.model.topicCrossReferences import com.google.samples.apps.nowinandroid.core.data.model.topicEntityShells +import com.google.samples.apps.nowinandroid.core.data.util.changeListSync import com.google.samples.apps.nowinandroid.core.database.dao.NewsResourceDao import com.google.samples.apps.nowinandroid.core.database.dao.TopicDao import com.google.samples.apps.nowinandroid.core.database.model.PopulatedNewsResource 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.ChangeListVersions import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferencesDataSource -import com.google.samples.apps.nowinandroid.core.model.data.NewsResource +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.domain.repository.NewsRepository +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.NiaNetworkDataSource import com.google.samples.apps.nowinandroid.core.network.model.NetworkNewsResource import com.google.samples.apps.nowinandroid.core.notifications.Notifier 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 5c8cecce8..0ce1659d3 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 @@ -16,14 +16,15 @@ package com.google.samples.apps.nowinandroid.core.data.repository -import com.google.samples.apps.nowinandroid.core.data.Synchronizer -import com.google.samples.apps.nowinandroid.core.data.changeListSync import com.google.samples.apps.nowinandroid.core.data.model.asEntity +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.datastore.ChangeListVersions -import com.google.samples.apps.nowinandroid.core.model.data.Topic +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.domain.repository.TopicsRepository +import com.google.samples.apps.nowinandroid.core.domain.utils.Synchronizer import com.google.samples.apps.nowinandroid.core.network.NiaNetworkDataSource import com.google.samples.apps.nowinandroid.core.network.model.NetworkTopic import kotlinx.coroutines.flow.Flow 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 c0b1bcc33..e1f04bb1c 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,10 @@ 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.model.data.DarkThemeConfig -import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand -import com.google.samples.apps.nowinandroid.core.model.data.UserData +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.domain.repository.UserDataRepository import kotlinx.coroutines.flow.Flow import javax.inject.Inject 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 d72fa27a6..e24fda9dc 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 @@ -16,7 +16,12 @@ 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.domain.utils.Synchronizer +import com.google.samples.apps.nowinandroid.core.network.model.NetworkChangeList import kotlinx.coroutines.flow.Flow +import kotlin.coroutines.cancellation.CancellationException /** * Reports on if synchronization is in progress @@ -25,3 +30,58 @@ interface SyncManager { val isSyncing: Flow fun requestSync() } + +/** + * Attempts [block], returning a successful [Result] if it succeeds, otherwise a [Result.Failure] + * taking care not to break structured concurrency + */ +private suspend fun suspendRunCatching(block: suspend () -> T): Result = try { + Result.success(block()) +} catch (cancellationException: CancellationException) { + throw cancellationException +} catch (exception: Exception) { + Log.i( + "suspendRunCatching", + "Failed to evaluate a suspendRunCatchingBlock. Returning failure Result", + exception, + ) + Result.failure(exception) +} + +/** + * Utility function for syncing a repository with the network. + * [versionReader] Reads the current version of the model that needs to be synced + * [changeListFetcher] Fetches the change list for the model + * [versionUpdater] Updates the [ChangeListVersions] after a successful sync + * [modelDeleter] Deletes models by consuming the ids of the models that have been deleted. + * [modelUpdater] Updates models by consuming the ids of the models that have changed. + * + * Note that the blocks defined above are never run concurrently, and the [Synchronizer] + * implementation must guarantee this. + */ +suspend fun Synchronizer.changeListSync( + versionReader: (ChangeListVersions) -> Int, + changeListFetcher: suspend (Int) -> List, + versionUpdater: ChangeListVersions.(Int) -> ChangeListVersions, + modelDeleter: suspend (List) -> Unit, + modelUpdater: suspend (List) -> Unit, +) = suspendRunCatching { + // Fetch the change list since last sync (akin to a git fetch) + val currentVersion = versionReader(getChangeListVersions()) + val changeList = changeListFetcher(currentVersion) + if (changeList.isEmpty()) return@suspendRunCatching true + + val (deleted, updated) = changeList.partition(NetworkChangeList::isDelete) + + // Delete models that have been deleted server-side + modelDeleter(deleted.map(NetworkChangeList::id)) + + // Using the change list, pull down and save the changes (akin to a git pull) + modelUpdater(updated.map(NetworkChangeList::id)) + + // Update the last synced version (akin to updating local git HEAD) + val latestVersion = changeList.last().changeListVersion + updateChangeListVersions { + versionUpdater(latestVersion) + } +}.isSuccess 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 05811f4be..959ad4a77 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,10 +17,10 @@ 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.data.repository.NewsResourceQuery -import com.google.samples.apps.nowinandroid.core.model.data.NewsResource -import com.google.samples.apps.nowinandroid.core.model.data.Topic -import com.google.samples.apps.nowinandroid.core.model.data.mapToUserNewsResources +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.domain.repository.NewsResourceQuery import com.google.samples.apps.nowinandroid.core.testing.repository.TestNewsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository import com.google.samples.apps.nowinandroid.core.testing.repository.emptyUserData 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 c7dfd99d0..943078b29 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,14 +16,14 @@ package com.google.samples.apps.nowinandroid.core.data -import com.google.samples.apps.nowinandroid.core.model.data.DarkThemeConfig.FOLLOW_SYSTEM -import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic -import com.google.samples.apps.nowinandroid.core.model.data.NewsResource -import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand.DEFAULT -import com.google.samples.apps.nowinandroid.core.model.data.Topic -import com.google.samples.apps.nowinandroid.core.model.data.UserData -import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource -import kotlinx.datetime.Clock +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 kotlinx.datetime.Clock.System import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue import org.junit.Test @@ -43,7 +43,7 @@ class UserNewsResourceTest { content = "Test news content", url = "Test URL", headerImageUrl = "Test image URL", - publishDate = Clock.System.now(), + publishDate = System.now(), type = "Article 📚", topics = listOf( Topic( 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 47c3996c4..a02835ffa 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 @@ -16,7 +16,6 @@ package com.google.samples.apps.nowinandroid.core.data.repository -import com.google.samples.apps.nowinandroid.core.data.Synchronizer import com.google.samples.apps.nowinandroid.core.data.model.asEntity import com.google.samples.apps.nowinandroid.core.data.model.topicCrossReferences import com.google.samples.apps.nowinandroid.core.data.model.topicEntityShells @@ -33,8 +32,10 @@ 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.model.data.NewsResource -import com.google.samples.apps.nowinandroid.core.model.data.Topic +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.repository.NewsResourceQuery +import com.google.samples.apps.nowinandroid.core.domain.utils.Synchronizer import com.google.samples.apps.nowinandroid.core.network.model.NetworkChangeList import com.google.samples.apps.nowinandroid.core.network.model.NetworkNewsResource import com.google.samples.apps.nowinandroid.core.testing.notifications.TestNotifier 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 3bd314eae..ea4a90a0d 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 @@ -16,7 +16,6 @@ package com.google.samples.apps.nowinandroid.core.data.repository -import com.google.samples.apps.nowinandroid.core.data.Synchronizer import com.google.samples.apps.nowinandroid.core.data.model.asEntity import com.google.samples.apps.nowinandroid.core.data.testdoubles.CollectionType import com.google.samples.apps.nowinandroid.core.data.testdoubles.TestNiaNetworkDataSource @@ -26,7 +25,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.model.data.Topic +import com.google.samples.apps.nowinandroid.core.domain.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 import kotlinx.coroutines.test.TestScope 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 27e86f2f4..a7a2e2a9e 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,9 +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.model.data.DarkThemeConfig -import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand -import com.google.samples.apps.nowinandroid.core.model.data.UserData +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 kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.map import kotlinx.coroutines.test.TestScope @@ -68,8 +70,8 @@ class OfflineFirstUserDataRepositoryTest { bookmarkedNewsResources = emptySet(), viewedNewsResources = emptySet(), followedTopics = emptySet(), - themeBrand = ThemeBrand.DEFAULT, - darkThemeConfig = DarkThemeConfig.FOLLOW_SYSTEM, + themeBrand = DEFAULT, + darkThemeConfig = FOLLOW_SYSTEM, useDynamicColor = false, shouldHideOnboarding = false, ), 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 270dd010e..29ac1f755 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 @@ -16,9 +16,9 @@ package com.google.samples.apps.nowinandroid.core.data.repository -import com.google.samples.apps.nowinandroid.core.data.Synchronizer -import com.google.samples.apps.nowinandroid.core.datastore.ChangeListVersions 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.utils.Synchronizer /** * Test synchronizer that delegates to [NiaPreferencesDataSource] 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 a1b72c52f..0f9e01659 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.model.data.NewsResource -import com.google.samples.apps.nowinandroid.core.model.data.Topic +import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource +import com.google.samples.apps.nowinandroid.core.domain.model.Topic import kotlinx.datetime.Instant import org.junit.Test import kotlin.test.assertEquals diff --git a/core/database/build.gradle.kts b/core/database/build.gradle.kts index 4a6bcb66a..5bd5bfc6e 100644 --- a/core/database/build.gradle.kts +++ b/core/database/build.gradle.kts @@ -30,7 +30,7 @@ android { } dependencies { - api(projects.core.model) + api(projects.core.domain) implementation(libs.kotlinx.datetime) diff --git a/core/database/src/main/kotlin/com/google/samples/apps/nowinandroid/core/database/dao/NewsResourceDao.kt b/core/database/src/main/kotlin/com/google/samples/apps/nowinandroid/core/database/dao/NewsResourceDao.kt index 929b88ce6..cdc8976e8 100644 --- a/core/database/src/main/kotlin/com/google/samples/apps/nowinandroid/core/database/dao/NewsResourceDao.kt +++ b/core/database/src/main/kotlin/com/google/samples/apps/nowinandroid/core/database/dao/NewsResourceDao.kt @@ -25,7 +25,6 @@ import androidx.room.Upsert import com.google.samples.apps.nowinandroid.core.database.model.NewsResourceEntity import com.google.samples.apps.nowinandroid.core.database.model.NewsResourceTopicCrossRef import com.google.samples.apps.nowinandroid.core.database.model.PopulatedNewsResource -import com.google.samples.apps.nowinandroid.core.model.data.NewsResource import kotlinx.coroutines.flow.Flow /** 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 9450a24ad..15d317d6f 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.model.data.NewsResource +import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource import kotlinx.datetime.Instant /** @@ -41,13 +41,14 @@ data class NewsResourceEntity( val type: String, ) -fun NewsResourceEntity.asExternalModel() = NewsResource( - id = id, - title = title, - content = content, - url = url, - headerImageUrl = headerImageUrl, - publishDate = publishDate, - type = type, - topics = listOf(), -) +fun NewsResourceEntity.asExternalModel() = + com.google.samples.apps.nowinandroid.core.domain.model.NewsResource( + id = id, + title = title, + content = content, + url = url, + headerImageUrl = headerImageUrl, + publishDate = publishDate, + type = type, + topics = listOf(), + ) 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 a70342401..7bc347b22 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.model.data.NewsResource +import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource /** * External data layer representation of a fully populated NiA news resource @@ -39,16 +39,17 @@ data class PopulatedNewsResource( val topics: List, ) -fun PopulatedNewsResource.asExternalModel() = NewsResource( - id = entity.id, - title = entity.title, - content = entity.content, - url = entity.url, - headerImageUrl = entity.headerImageUrl, - publishDate = entity.publishDate, - type = entity.type, - topics = topics.map(TopicEntity::asExternalModel), -) +fun PopulatedNewsResource.asExternalModel() = + com.google.samples.apps.nowinandroid.core.domain.model.NewsResource( + id = entity.id, + title = entity.title, + content = entity.content, + url = entity.url, + headerImageUrl = entity.headerImageUrl, + publishDate = entity.publishDate, + type = entity.type, + topics = topics.map(TopicEntity::asExternalModel), + ) fun PopulatedNewsResource.asFtsEntity() = NewsResourceFtsEntity( newsResourceId = entity.id, 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 043d110cd..210b38e6c 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.model.data.Topic +import com.google.samples.apps.nowinandroid.core.domain.model.Topic /** * Defines a topic a user may follow. @@ -41,7 +41,7 @@ data class TopicEntity( val imageUrl: String, ) -fun TopicEntity.asExternalModel() = Topic( +fun TopicEntity.asExternalModel() = com.google.samples.apps.nowinandroid.core.domain.model.Topic( id = id, name = name, shortDescription = shortDescription, diff --git a/core/datastore/build.gradle.kts b/core/datastore/build.gradle.kts index 34ea5ee78..b2d8af51d 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.model) + api(projects.core.domain) 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 9a76a75a1..3c3de5eb2 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 @@ -18,9 +18,18 @@ package com.google.samples.apps.nowinandroid.core.datastore import android.util.Log import androidx.datastore.core.DataStore -import com.google.samples.apps.nowinandroid.core.model.data.DarkThemeConfig -import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand -import com.google.samples.apps.nowinandroid.core.model.data.UserData +import com.google.samples.apps.nowinandroid.core.datastore.DarkThemeConfigProto.DARK_THEME_CONFIG_DARK +import com.google.samples.apps.nowinandroid.core.datastore.DarkThemeConfigProto.DARK_THEME_CONFIG_FOLLOW_SYSTEM +import com.google.samples.apps.nowinandroid.core.datastore.DarkThemeConfigProto.DARK_THEME_CONFIG_LIGHT +import com.google.samples.apps.nowinandroid.core.datastore.DarkThemeConfigProto.DARK_THEME_CONFIG_UNSPECIFIED +import com.google.samples.apps.nowinandroid.core.datastore.ThemeBrandProto.THEME_BRAND_ANDROID +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 kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.flow.map import java.io.IOException @@ -31,28 +40,31 @@ class NiaPreferencesDataSource @Inject constructor( ) { val userData = userPreferences.data .map { - UserData( + com.google.samples.apps.nowinandroid.core.domain.model.UserData( bookmarkedNewsResources = it.bookmarkedNewsResourceIdsMap.keys, viewedNewsResources = it.viewedNewsResourceIdsMap.keys, followedTopics = it.followedTopicIdsMap.keys, themeBrand = when (it.themeBrand) { null, - ThemeBrandProto.THEME_BRAND_UNSPECIFIED, - ThemeBrandProto.UNRECOGNIZED, - ThemeBrandProto.THEME_BRAND_DEFAULT, - -> ThemeBrand.DEFAULT - ThemeBrandProto.THEME_BRAND_ANDROID -> ThemeBrand.ANDROID + THEME_BRAND_UNSPECIFIED, + UNRECOGNIZED, + THEME_BRAND_DEFAULT, + -> com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand.DEFAULT + + THEME_BRAND_ANDROID -> com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand.ANDROID }, darkThemeConfig = when (it.darkThemeConfig) { null, - DarkThemeConfigProto.DARK_THEME_CONFIG_UNSPECIFIED, + DARK_THEME_CONFIG_UNSPECIFIED, DarkThemeConfigProto.UNRECOGNIZED, - DarkThemeConfigProto.DARK_THEME_CONFIG_FOLLOW_SYSTEM, + DARK_THEME_CONFIG_FOLLOW_SYSTEM, -> - DarkThemeConfig.FOLLOW_SYSTEM - DarkThemeConfigProto.DARK_THEME_CONFIG_LIGHT -> - DarkThemeConfig.LIGHT - DarkThemeConfigProto.DARK_THEME_CONFIG_DARK -> DarkThemeConfig.DARK + com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig.FOLLOW_SYSTEM + + DARK_THEME_CONFIG_LIGHT -> + com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig.LIGHT + + DARK_THEME_CONFIG_DARK -> com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig.DARK }, useDynamicColor = it.useDynamicColor, shouldHideOnboarding = it.shouldHideOnboarding, @@ -90,12 +102,12 @@ class NiaPreferencesDataSource @Inject constructor( } } - suspend fun setThemeBrand(themeBrand: ThemeBrand) { + suspend fun setThemeBrand(themeBrand: com.google.samples.apps.nowinandroid.core.domain.model.ThemeBrand) { userPreferences.updateData { it.copy { this.themeBrand = when (themeBrand) { - ThemeBrand.DEFAULT -> ThemeBrandProto.THEME_BRAND_DEFAULT - ThemeBrand.ANDROID -> ThemeBrandProto.THEME_BRAND_ANDROID + 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 } } } @@ -107,14 +119,14 @@ class NiaPreferencesDataSource @Inject constructor( } } - suspend fun setDarkThemeConfig(darkThemeConfig: DarkThemeConfig) { + suspend fun setDarkThemeConfig(darkThemeConfig: com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig) { userPreferences.updateData { it.copy { this.darkThemeConfig = when (darkThemeConfig) { - DarkThemeConfig.FOLLOW_SYSTEM -> + com.google.samples.apps.nowinandroid.core.domain.model.DarkThemeConfig.FOLLOW_SYSTEM -> DarkThemeConfigProto.DARK_THEME_CONFIG_FOLLOW_SYSTEM - DarkThemeConfig.LIGHT -> DarkThemeConfigProto.DARK_THEME_CONFIG_LIGHT - DarkThemeConfig.DARK -> DarkThemeConfigProto.DARK_THEME_CONFIG_DARK + 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 } } } diff --git a/core/domain/build.gradle.kts b/core/domain/build.gradle.kts index 191877459..64dcc21ab 100644 --- a/core/domain/build.gradle.kts +++ b/core/domain/build.gradle.kts @@ -16,7 +16,7 @@ plugins { alias(libs.plugins.nowinandroid.android.library) alias(libs.plugins.nowinandroid.android.library.jacoco) - id("com.google.devtools.ksp") + alias(libs.plugins.nowinandroid.android.hilt) } android { @@ -24,8 +24,7 @@ android { } dependencies { - api(projects.core.data) - api(projects.core.model) + api(libs.kotlinx.datetime) implementation(libs.javax.inject) diff --git a/core/datastore/src/main/kotlin/com/google/samples/apps/nowinandroid/core/datastore/ChangeListVersions.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/ChangeListVersions.kt similarity index 92% rename from core/datastore/src/main/kotlin/com/google/samples/apps/nowinandroid/core/datastore/ChangeListVersions.kt rename to core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/ChangeListVersions.kt index 8b91b43a1..59527b458 100644 --- a/core/datastore/src/main/kotlin/com/google/samples/apps/nowinandroid/core/datastore/ChangeListVersions.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/ChangeListVersions.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.datastore +package com.google.samples.apps.nowinandroid.core.domain.model /** * Class summarizing the local version of each model for sync diff --git a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/DarkThemeConfig.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/DarkThemeConfig.kt similarity index 91% rename from core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/DarkThemeConfig.kt rename to core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/DarkThemeConfig.kt index dcbcaa531..4c7aef039 100644 --- a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/DarkThemeConfig.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/DarkThemeConfig.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.model.data +package com.google.samples.apps.nowinandroid.core.domain.model enum class DarkThemeConfig { FOLLOW_SYSTEM, diff --git a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/FollowableTopic.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/FollowableTopic.kt similarity index 87% rename from core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/FollowableTopic.kt rename to core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/FollowableTopic.kt index ae1d525c5..56f2906db 100644 --- a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/FollowableTopic.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/FollowableTopic.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023 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.model.data +package com.google.samples.apps.nowinandroid.core.domain.model /** * A [topic] with the additional information for whether or not it is followed. diff --git a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/NewsResource.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/NewsResource.kt similarity index 89% rename from core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/NewsResource.kt rename to core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/NewsResource.kt index 996851ff3..249169dcb 100644 --- a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/NewsResource.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/NewsResource.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.model.data +package com.google.samples.apps.nowinandroid.core.domain.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/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/RecentSearchQuery.kt new file mode 100644 index 000000000..0d087ff2a --- /dev/null +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/RecentSearchQuery.kt @@ -0,0 +1,25 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.samples.apps.nowinandroid.core.domain.model + +import kotlinx.datetime.Clock +import kotlinx.datetime.Instant + +data class RecentSearchQuery( + val query: String, + val queriedDate: Instant = Clock.System.now(), +) diff --git a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/SearchResult.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/SearchResult.kt similarity index 86% rename from core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/SearchResult.kt rename to core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/SearchResult.kt index 060347035..59dd446c2 100644 --- a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/SearchResult.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/SearchResult.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023 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.model.data +package com.google.samples.apps.nowinandroid.core.domain.model /** An entity that holds the search result */ data class SearchResult( diff --git a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/ThemeBrand.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/ThemeBrand.kt similarity index 91% rename from core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/ThemeBrand.kt rename to core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/ThemeBrand.kt index 431d4b573..dfc1ee566 100644 --- a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/ThemeBrand.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/ThemeBrand.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.model.data +package com.google.samples.apps.nowinandroid.core.domain.model enum class ThemeBrand { DEFAULT, diff --git a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/Topic.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/Topic.kt similarity index 93% rename from core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/Topic.kt rename to core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/Topic.kt index cc45937b6..12f69ad5d 100644 --- a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/Topic.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/Topic.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.model.data +package com.google.samples.apps.nowinandroid.core.domain.model /** * External data layer representation of a NiA Topic diff --git a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/UserData.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/UserData.kt similarity index 88% rename from core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/UserData.kt rename to core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/UserData.kt index 6a22e4ff5..512b81b8c 100644 --- a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/UserData.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/UserData.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.model.data +package com.google.samples.apps.nowinandroid.core.domain.model /** * Class summarizing user interest data diff --git a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/UserNewsResource.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/UserNewsResource.kt similarity index 94% rename from core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/UserNewsResource.kt rename to core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/UserNewsResource.kt index a56bbcb8d..b38b815a7 100644 --- a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/UserNewsResource.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/UserNewsResource.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023 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.model.data +package com.google.samples.apps.nowinandroid.core.domain.model import kotlinx.datetime.Instant diff --git a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/UserSearchResult.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/UserSearchResult.kt similarity index 88% rename from core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/UserSearchResult.kt rename to core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/UserSearchResult.kt index acc2cdc69..170fe57e1 100644 --- a/core/model/src/main/kotlin/com/google/samples/apps/nowinandroid/core/model/data/UserSearchResult.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/model/UserSearchResult.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023 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.model.data +package com.google.samples.apps.nowinandroid.core.domain.model /** * An entity of [SearchResult] with additional user information such as whether the user is diff --git a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/NewsRepository.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/NewsRepository.kt similarity index 83% rename from core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/NewsRepository.kt rename to core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/NewsRepository.kt index 0e53f1239..d1a02c18a 100644 --- a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/NewsRepository.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/NewsRepository.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,10 +14,10 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.data.repository +package com.google.samples.apps.nowinandroid.core.domain.repository -import com.google.samples.apps.nowinandroid.core.data.Syncable -import com.google.samples.apps.nowinandroid.core.model.data.NewsResource +import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource +import com.google.samples.apps.nowinandroid.core.domain.utils.Syncable import kotlinx.coroutines.flow.Flow /** diff --git a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/RecentSearchRepository.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/RecentSearchRepository.kt similarity index 85% rename from core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/RecentSearchRepository.kt rename to core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/RecentSearchRepository.kt index 87a2ce9dc..e0dfcd61d 100644 --- a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/RecentSearchRepository.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/RecentSearchRepository.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023 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,9 +14,9 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.data.repository +package com.google.samples.apps.nowinandroid.core.domain.repository -import com.google.samples.apps.nowinandroid.core.data.model.RecentSearchQuery +import com.google.samples.apps.nowinandroid.core.domain.model.RecentSearchQuery import kotlinx.coroutines.flow.Flow /** diff --git a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/SearchContentsRepository.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/SearchContentsRepository.kt similarity index 84% rename from core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/SearchContentsRepository.kt rename to core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/SearchContentsRepository.kt index 2fe6bd820..0bdec046c 100644 --- a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/SearchContentsRepository.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/SearchContentsRepository.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023 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,9 +14,9 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.data.repository +package com.google.samples.apps.nowinandroid.core.domain.repository -import com.google.samples.apps.nowinandroid.core.model.data.SearchResult +import com.google.samples.apps.nowinandroid.core.domain.model.SearchResult import kotlinx.coroutines.flow.Flow /** diff --git a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/TopicsRepository.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/TopicsRepository.kt similarity index 76% rename from core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/TopicsRepository.kt rename to core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/TopicsRepository.kt index fcf875cdd..d807607d5 100644 --- a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/TopicsRepository.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/TopicsRepository.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,10 +14,10 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.data.repository +package com.google.samples.apps.nowinandroid.core.domain.repository -import com.google.samples.apps.nowinandroid.core.data.Syncable -import com.google.samples.apps.nowinandroid.core.model.data.Topic +import com.google.samples.apps.nowinandroid.core.domain.model.Topic +import com.google.samples.apps.nowinandroid.core.domain.utils.Syncable import kotlinx.coroutines.flow.Flow interface TopicsRepository : Syncable { diff --git a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/UserDataRepository.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/UserDataRepository.kt similarity index 84% rename from core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/UserDataRepository.kt rename to core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/UserDataRepository.kt index ff616c179..68e1c586d 100644 --- a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/UserDataRepository.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/UserDataRepository.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,11 +14,11 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.data.repository +package com.google.samples.apps.nowinandroid.core.domain.repository -import com.google.samples.apps.nowinandroid.core.model.data.DarkThemeConfig -import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand -import com.google.samples.apps.nowinandroid.core.model.data.UserData +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 kotlinx.coroutines.flow.Flow interface UserDataRepository { diff --git a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/UserNewsResourceRepository.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/UserNewsResourceRepository.kt similarity index 86% rename from core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/UserNewsResourceRepository.kt rename to core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/UserNewsResourceRepository.kt index c0f4c013a..170e66876 100644 --- a/core/data/src/main/kotlin/com/google/samples/apps/nowinandroid/core/data/repository/UserNewsResourceRepository.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/repository/UserNewsResourceRepository.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023 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,9 +14,9 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.data.repository +package com.google.samples.apps.nowinandroid.core.domain.repository -import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource +import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource import kotlinx.coroutines.flow.Flow /** diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/GetFollowableTopicsUseCase.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetFollowableTopicsUseCase.kt similarity index 76% rename from core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/GetFollowableTopicsUseCase.kt rename to core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetFollowableTopicsUseCase.kt index 0167a3192..462bb45b1 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/GetFollowableTopicsUseCase.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetFollowableTopicsUseCase.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,13 +14,13 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.domain +package com.google.samples.apps.nowinandroid.core.domain.usecase -import com.google.samples.apps.nowinandroid.core.data.repository.TopicsRepository -import com.google.samples.apps.nowinandroid.core.data.repository.UserDataRepository -import com.google.samples.apps.nowinandroid.core.domain.TopicSortField.NAME -import com.google.samples.apps.nowinandroid.core.domain.TopicSortField.NONE -import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic +import com.google.samples.apps.nowinandroid.core.domain.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 +import com.google.samples.apps.nowinandroid.core.domain.usecase.TopicSortField.NONE import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import javax.inject.Inject diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/GetRecentSearchQueriesUseCase.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetRecentSearchQueriesUseCase.kt similarity index 77% rename from core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/GetRecentSearchQueriesUseCase.kt rename to core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetRecentSearchQueriesUseCase.kt index 51f87d6fd..d57ef6c1c 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/GetRecentSearchQueriesUseCase.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetRecentSearchQueriesUseCase.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023 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,10 +14,10 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.domain +package com.google.samples.apps.nowinandroid.core.domain.usecase -import com.google.samples.apps.nowinandroid.core.data.model.RecentSearchQuery -import com.google.samples.apps.nowinandroid.core.data.repository.RecentSearchRepository +import com.google.samples.apps.nowinandroid.core.domain.model.RecentSearchQuery +import com.google.samples.apps.nowinandroid.core.domain.repository.RecentSearchRepository import kotlinx.coroutines.flow.Flow import javax.inject.Inject diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/GetSearchContentsCountUseCase.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetSearchContentsCountUseCase.kt similarity index 81% rename from core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/GetSearchContentsCountUseCase.kt rename to core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetSearchContentsCountUseCase.kt index 3e3e1952e..b6628955e 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/GetSearchContentsCountUseCase.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetSearchContentsCountUseCase.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023 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,9 +14,9 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.domain +package com.google.samples.apps.nowinandroid.core.domain.usecase -import com.google.samples.apps.nowinandroid.core.data.repository.SearchContentsRepository +import com.google.samples.apps.nowinandroid.core.domain.repository.SearchContentsRepository import kotlinx.coroutines.flow.Flow import javax.inject.Inject diff --git a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/GetSearchContentsUseCase.kt b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetSearchContentsUseCase.kt similarity index 72% rename from core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/GetSearchContentsUseCase.kt rename to core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetSearchContentsUseCase.kt index d1065e87c..c5c707b60 100644 --- a/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/GetSearchContentsUseCase.kt +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/usecase/GetSearchContentsUseCase.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023 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,15 +14,15 @@ * limitations under the License. */ -package com.google.samples.apps.nowinandroid.core.domain +package com.google.samples.apps.nowinandroid.core.domain.usecase -import com.google.samples.apps.nowinandroid.core.data.repository.SearchContentsRepository -import com.google.samples.apps.nowinandroid.core.data.repository.UserDataRepository -import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic -import com.google.samples.apps.nowinandroid.core.model.data.SearchResult -import com.google.samples.apps.nowinandroid.core.model.data.UserData -import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource -import com.google.samples.apps.nowinandroid.core.model.data.UserSearchResult +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.domain.repository.SearchContentsRepository +import com.google.samples.apps.nowinandroid.core.domain.repository.UserDataRepository import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import javax.inject.Inject 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 new file mode 100644 index 000000000..3a686fab6 --- /dev/null +++ b/core/domain/src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/utils/SyncUtilities.kt @@ -0,0 +1,74 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.samples.apps.nowinandroid.core.domain.utils + +import com.google.samples.apps.nowinandroid.core.domain.model.ChangeListVersions +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.combine + +/** + * Interface marker for a class that manages synchronization between local data and a remote + * source for a [Syncable]. + */ +interface Synchronizer { + suspend fun getChangeListVersions(): ChangeListVersions + + suspend fun updateChangeListVersions(update: ChangeListVersions.() -> ChangeListVersions) + + /** + * Syntactic sugar to call [Syncable.syncWith] while omitting the synchronizer argument + */ + suspend fun Syncable.sync() = this@sync.syncWith(this@Synchronizer) +} + +/** + * Interface marker for a class that is synchronized with a remote source. Syncing must not be + * performed concurrently and it is the [Synchronizer]'s responsibility to ensure this. + */ +interface Syncable { + /** + * Synchronizes the local database backing the repository with the network. + * Returns if the sync was successful or not. + */ + suspend fun syncWith(synchronizer: Synchronizer): Boolean +} + +/** + * Returns a [Flow] whose values are generated by [transform] function that process the most + * recently emitted values by each flow. + */ +fun combine( + flow: Flow, + flow2: Flow, + flow3: Flow, + flow4: Flow, + flow5: Flow, + flow6: Flow, + transform: suspend (T1, T2, T3, T4, T5, T6) -> R, +): Flow = combine( + combine(flow, flow2, flow3, ::Triple), + combine(flow4, flow5, flow6, ::Triple), +) { t1, t2 -> + transform( + t1.first, + t1.second, + t1.third, + t2.first, + t2.second, + t2.third, + ) +} 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 42a31f858..b218b170e 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,9 +16,10 @@ package com.google.samples.apps.nowinandroid.core.domain -import com.google.samples.apps.nowinandroid.core.domain.TopicSortField.NAME -import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic -import com.google.samples.apps.nowinandroid.core.model.data.Topic +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.usecase.GetFollowableTopicsUseCase +import com.google.samples.apps.nowinandroid.core.domain.usecase.TopicSortField.NAME import com.google.samples.apps.nowinandroid.core.testing.repository.TestTopicsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository import com.google.samples.apps.nowinandroid.core.testing.util.MainDispatcherRule diff --git a/core/network/build.gradle.kts b/core/network/build.gradle.kts index 689a99e73..a97fe4174 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.model) + api(projects.core.domain) 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/NetworkNewsResource.kt b/core/network/src/main/kotlin/com/google/samples/apps/nowinandroid/core/network/model/NetworkNewsResource.kt index 89af19c99..f5dac9928 100644 --- a/core/network/src/main/kotlin/com/google/samples/apps/nowinandroid/core/network/model/NetworkNewsResource.kt +++ b/core/network/src/main/kotlin/com/google/samples/apps/nowinandroid/core/network/model/NetworkNewsResource.kt @@ -16,7 +16,6 @@ package com.google.samples.apps.nowinandroid.core.network.model -import com.google.samples.apps.nowinandroid.core.model.data.NewsResource import kotlinx.datetime.Instant import kotlinx.serialization.Serializable 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 e1043938f..06d8825e5 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.model.data.Topic +import com.google.samples.apps.nowinandroid.core.domain.model.Topic import kotlinx.serialization.Serializable /** diff --git a/core/notifications/build.gradle.kts b/core/notifications/build.gradle.kts index 92871b72b..93e128883 100644 --- a/core/notifications/build.gradle.kts +++ b/core/notifications/build.gradle.kts @@ -23,7 +23,7 @@ android { } dependencies { - api(projects.core.model) + api(projects.core.domain) implementation(projects.core.common) 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 863c1a662..63e607b6b 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.model.data.NewsResource +import com.google.samples.apps.nowinandroid.core.domain.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 fff8cb9c8..30f195266 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.model.data.NewsResource +import com.google.samples.apps.nowinandroid.core.domain.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 1c9e7ab63..62a62e214 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.model.data.NewsResource +import com.google.samples.apps.nowinandroid.core.domain.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: NewsResource, + newsResource: com.google.samples.apps.nowinandroid.core.domain.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 NewsResource.newsDeepLinkUri() = "$DEEP_LINK_SCHEME_AND_HOST/$FOR_YOU_PATH/$id".toUri() +private fun com.google.samples.apps.nowinandroid.core.domain.model.NewsResource.newsDeepLinkUri() = "$DEEP_LINK_SCHEME_AND_HOST/$FOR_YOU_PATH/$id".toUri() diff --git a/core/testing/build.gradle.kts b/core/testing/build.gradle.kts index 02729ceff..878f89ae4 100644 --- a/core/testing/build.gradle.kts +++ b/core/testing/build.gradle.kts @@ -28,7 +28,7 @@ dependencies { api(libs.androidx.compose.ui.test) api(projects.core.analytics) api(projects.core.data) - api(projects.core.model) + api(projects.core.domain) api(projects.core.notifications) debugApi(libs.androidx.compose.ui.testManifest) 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 9b85516e7..32aa9881b 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,8 +18,8 @@ package com.google.samples.apps.nowinandroid.core.testing.data -import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic -import com.google.samples.apps.nowinandroid.core.model.data.Topic +import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic +import com.google.samples.apps.nowinandroid.core.domain.model.Topic val followableTopicTestData: List = listOf( FollowableTopic( 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 b3fff7ca0..c5648e365 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,7 +18,7 @@ package com.google.samples.apps.nowinandroid.core.testing.data -import com.google.samples.apps.nowinandroid.core.model.data.NewsResource +import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource import kotlinx.datetime.Instant val newsResourcesTestData: List = listOf( 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 fc6ef62a6..8491f76a6 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,7 +18,7 @@ package com.google.samples.apps.nowinandroid.core.testing.data -import com.google.samples.apps.nowinandroid.core.model.data.Topic +import com.google.samples.apps.nowinandroid.core.domain.model.Topic val topicsTestData: List = listOf( Topic( 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 4174391df..ea33e5cb0 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,11 +18,11 @@ package com.google.samples.apps.nowinandroid.core.testing.data -import com.google.samples.apps.nowinandroid.core.model.data.DarkThemeConfig -import com.google.samples.apps.nowinandroid.core.model.data.NewsResource -import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand -import com.google.samples.apps.nowinandroid.core.model.data.UserData -import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource +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 kotlinx.datetime.Instant import kotlinx.datetime.LocalDateTime import kotlinx.datetime.TimeZone @@ -32,8 +32,8 @@ val userNewsResourcesTestData: List = UserData( bookmarkedNewsResources = setOf("1", "4"), viewedNewsResources = setOf("1", "2", "4"), followedTopics = emptySet(), - themeBrand = ThemeBrand.ANDROID, - darkThemeConfig = DarkThemeConfig.DARK, + themeBrand = ANDROID, + darkThemeConfig = DARK, shouldHideOnboarding = true, useDynamicColor = false, ).let { userData -> 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 d57c4ed75..b8f939b0e 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.model.data.NewsResource +import com.google.samples.apps.nowinandroid.core.domain.model.NewsResource import com.google.samples.apps.nowinandroid.core.notifications.Notifier /** 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 ef065a9f8..9cfe92769 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,11 +16,11 @@ package com.google.samples.apps.nowinandroid.core.testing.repository -import com.google.samples.apps.nowinandroid.core.data.Synchronizer -import com.google.samples.apps.nowinandroid.core.data.repository.NewsRepository -import com.google.samples.apps.nowinandroid.core.data.repository.NewsResourceQuery -import com.google.samples.apps.nowinandroid.core.model.data.NewsResource -import com.google.samples.apps.nowinandroid.core.model.data.Topic +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.repository.NewsRepository +import com.google.samples.apps.nowinandroid.core.domain.repository.NewsResourceQuery +import com.google.samples.apps.nowinandroid.core.domain.utils.Synchronizer import kotlinx.coroutines.channels.BufferOverflow import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow 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 f700bdc31..ae592b882 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,8 +16,8 @@ package com.google.samples.apps.nowinandroid.core.testing.repository -import com.google.samples.apps.nowinandroid.core.data.model.RecentSearchQuery -import com.google.samples.apps.nowinandroid.core.data.repository.RecentSearchRepository +import com.google.samples.apps.nowinandroid.core.domain.model.RecentSearchQuery +import com.google.samples.apps.nowinandroid.core.domain.repository.RecentSearchRepository import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf @@ -29,7 +29,11 @@ class TestRecentSearchRepository : RecentSearchRepository { flowOf(cachedRecentSearches.sortedByDescending { it.queriedDate }.take(limit)) override suspend fun insertOrReplaceRecentSearch(searchQuery: String) { - cachedRecentSearches.add(RecentSearchQuery(searchQuery)) + cachedRecentSearches.add( + RecentSearchQuery( + searchQuery, + ), + ) } override suspend fun clearRecentSearches() = cachedRecentSearches.clear() 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 5436cd10f..8b7ef5ea9 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,10 +16,10 @@ package com.google.samples.apps.nowinandroid.core.testing.repository -import com.google.samples.apps.nowinandroid.core.data.repository.SearchContentsRepository -import com.google.samples.apps.nowinandroid.core.model.data.NewsResource -import com.google.samples.apps.nowinandroid.core.model.data.SearchResult -import com.google.samples.apps.nowinandroid.core.model.data.Topic +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.domain.repository.SearchContentsRepository import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.combine 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 ddccbbe35..52bade77c 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,9 +16,9 @@ package com.google.samples.apps.nowinandroid.core.testing.repository -import com.google.samples.apps.nowinandroid.core.data.Synchronizer -import com.google.samples.apps.nowinandroid.core.data.repository.TopicsRepository -import com.google.samples.apps.nowinandroid.core.model.data.Topic +import com.google.samples.apps.nowinandroid.core.domain.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 import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow 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 504e79217..d23fdaa36 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,10 +16,12 @@ package com.google.samples.apps.nowinandroid.core.testing.repository -import com.google.samples.apps.nowinandroid.core.data.repository.UserDataRepository -import com.google.samples.apps.nowinandroid.core.model.data.DarkThemeConfig -import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand -import com.google.samples.apps.nowinandroid.core.model.data.UserData +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.domain.repository.UserDataRepository import kotlinx.coroutines.channels.BufferOverflow.DROP_OLDEST import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow @@ -29,8 +31,8 @@ val emptyUserData = UserData( bookmarkedNewsResources = emptySet(), viewedNewsResources = emptySet(), followedTopics = emptySet(), - themeBrand = ThemeBrand.DEFAULT, - darkThemeConfig = DarkThemeConfig.FOLLOW_SYSTEM, + themeBrand = DEFAULT, + darkThemeConfig = FOLLOW_SYSTEM, useDynamicColor = false, shouldHideOnboarding = false, ) diff --git a/core/ui/build.gradle.kts b/core/ui/build.gradle.kts index 5d8a65d44..890d94e52 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.model) + api(projects.core.domain) 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 16ae1eced..e212372eb 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.model.data.FollowableTopic -import com.google.samples.apps.nowinandroid.core.model.data.Topic +import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic +import com.google.samples.apps.nowinandroid.core.domain.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( - FollowableTopic( - topic = Topic( + com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic( + topic = com.google.samples.apps.nowinandroid.core.domain.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 e3fd29e9a..c8e225d66 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.model.data.FollowableTopic -import com.google.samples.apps.nowinandroid.core.model.data.NewsResource -import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource +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 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: UserNewsResource, + userNewsResource: com.google.samples.apps.nowinandroid.core.domain.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 ea1c09d01..da9b27103 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.model.data.UserNewsResource +import com.google.samples.apps.nowinandroid.core.domain.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.model.data.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: UserNewsResource) -> Unit, + items: List, + onToggleBookmark: (item: com.google.samples.apps.nowinandroid.core.domain.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 3189e8403..c2e0f94a7 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.model.data.DarkThemeConfig -import com.google.samples.apps.nowinandroid.core.model.data.NewsResource -import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand -import com.google.samples.apps.nowinandroid.core.model.data.Topic -import com.google.samples.apps.nowinandroid.core.model.data.UserData -import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource +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.ui.PreviewParameterData.newsResources import kotlinx.datetime.Instant import kotlinx.datetime.LocalDateTime @@ -35,25 +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: UserData = UserData( - bookmarkedNewsResources = setOf("1", "3"), - viewedNewsResources = setOf("1", "2", "4"), - followedTopics = emptySet(), - themeBrand = ThemeBrand.ANDROID, - darkThemeConfig = DarkThemeConfig.DARK, - shouldHideOnboarding = true, - useDynamicColor = false, - ) + private val userData: com.google.samples.apps.nowinandroid.core.domain.model.UserData = + com.google.samples.apps.nowinandroid.core.domain.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, + shouldHideOnboarding = true, + useDynamicColor = false, + ) val topics = listOf( - Topic( + com.google.samples.apps.nowinandroid.core.domain.model.Topic( id = "2", name = "Headlines", shortDescription = "News we want everyone to see", @@ -61,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 = "", ), - Topic( + com.google.samples.apps.nowinandroid.core.domain.model.Topic( id = "3", name = "UI", shortDescription = "Material Design, Navigation, Text, Paging, Accessibility (a11y), Internationalization (i18n), Localization (l10n), Animations, Large Screens, Widgets", @@ -69,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 = "", ), - Topic( + com.google.samples.apps.nowinandroid.core.domain.model.Topic( id = "4", name = "Testing", shortDescription = "CI, Espresso, TestLab, etc", @@ -80,8 +81,8 @@ object PreviewParameterData { ) val newsResources = listOf( - UserNewsResource( - newsResource = NewsResource( + com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource( + newsResource = com.google.samples.apps.nowinandroid.core.domain.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", @@ -101,8 +102,8 @@ object PreviewParameterData { ), userData = userData, ), - UserNewsResource( - newsResource = NewsResource( + com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource( + newsResource = com.google.samples.apps.nowinandroid.core.domain.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 " + @@ -117,8 +118,8 @@ object PreviewParameterData { ), userData = userData, ), - UserNewsResource( - newsResource = NewsResource( + com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource( + newsResource = com.google.samples.apps.nowinandroid.core.domain.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 7c229c5ea..c2e4d4f65 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.model.data.UserNewsResource +import com.google.samples.apps.nowinandroid.core.domain.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 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 7b6cac76a..150c0ee40 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,9 +21,9 @@ 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.data.repository.UserDataRepository -import com.google.samples.apps.nowinandroid.core.data.repository.UserNewsResourceRepository -import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource +import com.google.samples.apps.nowinandroid.core.domain.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 import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState.Loading import dagger.hilt.android.lifecycle.HiltViewModel 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 885020636..72678f143 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.model.data.UserNewsResource +import com.google.samples.apps.nowinandroid.core.domain.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 diff --git a/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModel.kt b/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModel.kt index 2a4b6f4ec..b9dbbcda1 100644 --- a/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModel.kt +++ b/feature/foryou/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModel.kt @@ -22,11 +22,11 @@ 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.data.repository.NewsResourceQuery -import com.google.samples.apps.nowinandroid.core.data.repository.UserDataRepository -import com.google.samples.apps.nowinandroid.core.data.repository.UserNewsResourceRepository import com.google.samples.apps.nowinandroid.core.data.util.SyncManager -import com.google.samples.apps.nowinandroid.core.domain.GetFollowableTopicsUseCase +import com.google.samples.apps.nowinandroid.core.domain.repository.NewsResourceQuery +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.domain.usecase.GetFollowableTopicsUseCase import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState import com.google.samples.apps.nowinandroid.feature.foryou.navigation.LINKED_NEWS_RESOURCE_ID import dagger.hilt.android.lifecycle.HiltViewModel 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 70634b4c5..da661aeac 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.model.data.FollowableTopic +import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic /** * A sealed hierarchy describing the onboarding state for the for you screen. 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 b75573975..56d02d305 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,12 +20,12 @@ 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.GetFollowableTopicsUseCase -import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic -import com.google.samples.apps.nowinandroid.core.model.data.NewsResource -import com.google.samples.apps.nowinandroid.core.model.data.Topic -import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource -import com.google.samples.apps.nowinandroid.core.model.data.mapToUserNewsResources +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.domain.usecase.GetFollowableTopicsUseCase 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 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 468550878..dbd87e953 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.model.data.FollowableTopic +import com.google.samples.apps.nowinandroid.core.domain.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 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 b369ac5ab..6db274eb3 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,10 +19,10 @@ 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.data.repository.UserDataRepository -import com.google.samples.apps.nowinandroid.core.domain.GetFollowableTopicsUseCase -import com.google.samples.apps.nowinandroid.core.domain.TopicSortField -import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic +import com.google.samples.apps.nowinandroid.core.domain.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 import com.google.samples.apps.nowinandroid.feature.interests.navigation.TOPIC_ID_ARG import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.SharingStarted 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 4a48645c5..ca74bb6e3 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,7 +38,7 @@ 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.model.data.FollowableTopic +import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic @Composable fun TopicsTabContent( 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 63d3c49b7..5e2675229 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,9 +17,9 @@ package com.google.samples.apps.nowinandroid.interests import androidx.lifecycle.SavedStateHandle -import com.google.samples.apps.nowinandroid.core.domain.GetFollowableTopicsUseCase -import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic -import com.google.samples.apps.nowinandroid.core.model.data.Topic +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.usecase.GetFollowableTopicsUseCase import com.google.samples.apps.nowinandroid.core.testing.repository.TestTopicsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository import com.google.samples.apps.nowinandroid.core.testing.util.MainDispatcherRule 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 8a0532e1b..80bb113c5 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.data.model.RecentSearchQuery -import com.google.samples.apps.nowinandroid.core.model.data.DarkThemeConfig.DARK -import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand.ANDROID -import com.google.samples.apps.nowinandroid.core.model.data.UserData -import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource +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.testing.data.followableTopicTestData import com.google.samples.apps.nowinandroid.core.testing.data.newsResourcesTestData import org.junit.Before 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 8aa5bb3b8..1f421d94c 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,7 +16,7 @@ package com.google.samples.apps.nowinandroid.feature.search -import com.google.samples.apps.nowinandroid.core.data.model.RecentSearchQuery +import com.google.samples.apps.nowinandroid.core.domain.model.RecentSearchQuery sealed interface RecentSearchQueriesUiState { data object Loading : 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 aaf7dba7d..71a09d762 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.model.data.FollowableTopic -import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource +import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic +import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource sealed interface SearchResultUiState { data object Loading : SearchResultUiState 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 ca159c80b..f09c50f9d 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.model.data.FollowableTopic -import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource +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.ui.DevicePreviews import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState.Success import com.google.samples.apps.nowinandroid.core.ui.R.string 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 257d8b68e..b037afe5b 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.model.data.FollowableTopic +import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic import com.google.samples.apps.nowinandroid.core.ui.PreviewParameterData.newsResources import com.google.samples.apps.nowinandroid.core.ui.PreviewParameterData.topics 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 7c05f81c5..1b626acdb 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,11 +22,11 @@ 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.data.repository.RecentSearchRepository -import com.google.samples.apps.nowinandroid.core.domain.GetRecentSearchQueriesUseCase -import com.google.samples.apps.nowinandroid.core.domain.GetSearchContentsCountUseCase -import com.google.samples.apps.nowinandroid.core.domain.GetSearchContentsUseCase -import com.google.samples.apps.nowinandroid.core.model.data.UserSearchResult +import com.google.samples.apps.nowinandroid.core.domain.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 +import com.google.samples.apps.nowinandroid.core.domain.usecase.GetSearchContentsUseCase import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow diff --git a/feature/search/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchViewModelTest.kt b/feature/search/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchViewModelTest.kt index da0d5654e..da4cce004 100644 --- a/feature/search/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchViewModelTest.kt +++ b/feature/search/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchViewModelTest.kt @@ -18,9 +18,9 @@ package com.google.samples.apps.nowinandroid.feature.search import androidx.lifecycle.SavedStateHandle import com.google.samples.apps.nowinandroid.core.analytics.NoOpAnalyticsHelper -import com.google.samples.apps.nowinandroid.core.domain.GetRecentSearchQueriesUseCase -import com.google.samples.apps.nowinandroid.core.domain.GetSearchContentsCountUseCase -import com.google.samples.apps.nowinandroid.core.domain.GetSearchContentsUseCase +import com.google.samples.apps.nowinandroid.core.domain.usecase.GetRecentSearchQueriesUseCase +import com.google.samples.apps.nowinandroid.core.domain.usecase.GetSearchContentsCountUseCase +import com.google.samples.apps.nowinandroid.core.domain.usecase.GetSearchContentsUseCase import com.google.samples.apps.nowinandroid.core.testing.data.newsResourcesTestData import com.google.samples.apps.nowinandroid.core.testing.data.topicsTestData import com.google.samples.apps.nowinandroid.core.testing.repository.TestRecentSearchRepository 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 790b5964d..25fae3a3e 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.model.data.DarkThemeConfig.DARK -import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand.ANDROID -import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand.DEFAULT +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.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 db60a6447..5539045b8 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.model.data.DarkThemeConfig -import com.google.samples.apps.nowinandroid.core.model.data.DarkThemeConfig.DARK -import com.google.samples.apps.nowinandroid.core.model.data.DarkThemeConfig.FOLLOW_SYSTEM -import com.google.samples.apps.nowinandroid.core.model.data.DarkThemeConfig.LIGHT -import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand -import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand.ANDROID -import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand.DEFAULT +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.ui.TrackScreenViewEvent import com.google.samples.apps.nowinandroid.feature.settings.R.string import com.google.samples.apps.nowinandroid.feature.settings.SettingsUiState.Loading 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 123c84d1c..39340cffe 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,9 +18,9 @@ package com.google.samples.apps.nowinandroid.feature.settings import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.google.samples.apps.nowinandroid.core.data.repository.UserDataRepository -import com.google.samples.apps.nowinandroid.core.model.data.DarkThemeConfig -import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand +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.repository.UserDataRepository import com.google.samples.apps.nowinandroid.feature.settings.SettingsUiState.Loading import com.google.samples.apps.nowinandroid.feature.settings.SettingsUiState.Success import dagger.hilt.android.lifecycle.HiltViewModel 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 9062abee6..edddc8d7b 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.model.data.DarkThemeConfig.DARK -import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand.ANDROID +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.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 5ac766675..24c739be6 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.model.data.FollowableTopic -import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource +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.ui.DevicePreviews import com.google.samples.apps.nowinandroid.core.ui.TrackScreenViewEvent import com.google.samples.apps.nowinandroid.core.ui.TrackScrollJank 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 9fe6a2dd2..33fc16c03 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,13 +19,13 @@ 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.data.repository.NewsResourceQuery -import com.google.samples.apps.nowinandroid.core.data.repository.TopicsRepository -import com.google.samples.apps.nowinandroid.core.data.repository.UserDataRepository -import com.google.samples.apps.nowinandroid.core.data.repository.UserNewsResourceRepository -import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic -import com.google.samples.apps.nowinandroid.core.model.data.Topic -import com.google.samples.apps.nowinandroid.core.model.data.UserNewsResource +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.domain.repository.NewsResourceQuery +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.repository.UserNewsResourceRepository import com.google.samples.apps.nowinandroid.core.result.Result import com.google.samples.apps.nowinandroid.core.result.asResult import com.google.samples.apps.nowinandroid.feature.topic.navigation.TopicArgs 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 565732f59..ff50da74c 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.model.data.FollowableTopic -import com.google.samples.apps.nowinandroid.core.model.data.NewsResource -import com.google.samples.apps.nowinandroid.core.model.data.Topic +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.testing.repository.TestNewsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestTopicsRepository import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserDataRepository 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 ea5f36042..1d0d3b392 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 @@ -25,12 +25,12 @@ import androidx.work.OneTimeWorkRequestBuilder import androidx.work.OutOfQuotaPolicy import androidx.work.WorkerParameters import com.google.samples.apps.nowinandroid.core.analytics.AnalyticsHelper -import com.google.samples.apps.nowinandroid.core.data.Synchronizer -import com.google.samples.apps.nowinandroid.core.data.repository.NewsRepository -import com.google.samples.apps.nowinandroid.core.data.repository.SearchContentsRepository -import com.google.samples.apps.nowinandroid.core.data.repository.TopicsRepository -import com.google.samples.apps.nowinandroid.core.datastore.ChangeListVersions 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.repository.NewsRepository +import com.google.samples.apps.nowinandroid.core.domain.repository.SearchContentsRepository +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 import com.google.samples.apps.nowinandroid.core.network.NiaDispatchers.IO import com.google.samples.apps.nowinandroid.sync.initializers.SyncConstraints