diff --git a/app/src/main/java/com/willowtree/vocable/AppKoinModule.kt b/app/src/main/java/com/willowtree/vocable/AppKoinModule.kt index a1778f12..e31ce7e0 100644 --- a/app/src/main/java/com/willowtree/vocable/AppKoinModule.kt +++ b/app/src/main/java/com/willowtree/vocable/AppKoinModule.kt @@ -3,9 +3,9 @@ package com.willowtree.vocable import com.squareup.moshi.Moshi import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory import com.willowtree.vocable.facetracking.FaceTrackingViewModel -import com.willowtree.vocable.presets.IPresetsRepository +import com.willowtree.vocable.presets.ILegacyCategoriesAndPhrasesRepository import com.willowtree.vocable.presets.PresetCategoriesRepository -import com.willowtree.vocable.presets.PresetsRepository +import com.willowtree.vocable.presets.LegacyCategoriesAndPhrasesRepository import com.willowtree.vocable.presets.PresetsViewModel import com.willowtree.vocable.presets.RoomPresetCategoriesRepository import com.willowtree.vocable.room.RoomStoredCategoriesRepository @@ -34,7 +34,7 @@ object AppKoinModule { single { FaceTrackingPermissions(get()) } bind IFaceTrackingPermissions::class single { VocableSharedPreferences() } bind IVocableSharedPreferences::class - single { PresetsRepository(get()) } bind IPresetsRepository::class + single { LegacyCategoriesAndPhrasesRepository(get()) } bind ILegacyCategoriesAndPhrasesRepository::class single { Moshi.Builder().add(KotlinJsonAdapterFactory()).build() } single { LocalizedResourceUtility() } bind ILocalizedResourceUtility::class single { CategoriesUseCase(get(), get(), get(), get(), get()) } bind ICategoriesUseCase::class diff --git a/app/src/main/java/com/willowtree/vocable/CategoriesUseCase.kt b/app/src/main/java/com/willowtree/vocable/CategoriesUseCase.kt index 9631e369..ebae66b2 100644 --- a/app/src/main/java/com/willowtree/vocable/CategoriesUseCase.kt +++ b/app/src/main/java/com/willowtree/vocable/CategoriesUseCase.kt @@ -1,7 +1,7 @@ package com.willowtree.vocable import com.willowtree.vocable.presets.Category -import com.willowtree.vocable.presets.IPresetsRepository +import com.willowtree.vocable.presets.ILegacyCategoriesAndPhrasesRepository import com.willowtree.vocable.presets.PresetCategoriesRepository import com.willowtree.vocable.presets.asCategory import com.willowtree.vocable.room.CategorySortOrder @@ -13,7 +13,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map class CategoriesUseCase( - private val presetsRepository: IPresetsRepository, + private val presetsRepository: ILegacyCategoriesAndPhrasesRepository, private val uuidProvider: UUIDProvider, private val localeProvider: LocaleProvider, private val storedCategoriesRepository: StoredCategoriesRepository, diff --git a/app/src/main/java/com/willowtree/vocable/PhrasesUseCase.kt b/app/src/main/java/com/willowtree/vocable/PhrasesUseCase.kt index d79e5e48..4896de6f 100644 --- a/app/src/main/java/com/willowtree/vocable/PhrasesUseCase.kt +++ b/app/src/main/java/com/willowtree/vocable/PhrasesUseCase.kt @@ -1,6 +1,6 @@ package com.willowtree.vocable -import com.willowtree.vocable.presets.IPresetsRepository +import com.willowtree.vocable.presets.ILegacyCategoriesAndPhrasesRepository import com.willowtree.vocable.presets.Phrase import com.willowtree.vocable.presets.PresetCategories import com.willowtree.vocable.presets.asPhrase @@ -9,7 +9,7 @@ import com.willowtree.vocable.utils.DateProvider import com.willowtree.vocable.utils.locale.LocalesWithText class PhrasesUseCase( - private val presetsRepository: IPresetsRepository, + private val presetsRepository: ILegacyCategoriesAndPhrasesRepository, private val dateProvider: DateProvider ) { suspend fun getPhrasesForCategory(categoryId: String): List { diff --git a/app/src/main/java/com/willowtree/vocable/presets/IPresetsRepository.kt b/app/src/main/java/com/willowtree/vocable/presets/ILegacyCategoriesAndPhrasesRepository.kt similarity index 88% rename from app/src/main/java/com/willowtree/vocable/presets/IPresetsRepository.kt rename to app/src/main/java/com/willowtree/vocable/presets/ILegacyCategoriesAndPhrasesRepository.kt index dfe9ef90..8d39f2da 100644 --- a/app/src/main/java/com/willowtree/vocable/presets/IPresetsRepository.kt +++ b/app/src/main/java/com/willowtree/vocable/presets/ILegacyCategoriesAndPhrasesRepository.kt @@ -6,8 +6,9 @@ import com.willowtree.vocable.room.PhraseDto import com.willowtree.vocable.utils.locale.LocalesWithText import kotlinx.coroutines.flow.Flow -//TODO: PK - Rename this once we make the jump to rename [PresetsRepository] -> "RoomPresetsRepository" -interface IPresetsRepository { +@Deprecated("This is the old way of accessing categories and phrases. Prefer using" + + " ICategoriesUseCase instead.") +interface ILegacyCategoriesAndPhrasesRepository { suspend fun getPhrasesForCategory(categoryId: String): List /** diff --git a/app/src/main/java/com/willowtree/vocable/presets/PresetsRepository.kt b/app/src/main/java/com/willowtree/vocable/presets/LegacyCategoriesAndPhrasesRepository.kt similarity index 97% rename from app/src/main/java/com/willowtree/vocable/presets/PresetsRepository.kt rename to app/src/main/java/com/willowtree/vocable/presets/LegacyCategoriesAndPhrasesRepository.kt index 579d03d3..cf837f68 100644 --- a/app/src/main/java/com/willowtree/vocable/presets/PresetsRepository.kt +++ b/app/src/main/java/com/willowtree/vocable/presets/LegacyCategoriesAndPhrasesRepository.kt @@ -14,7 +14,7 @@ import org.koin.core.component.KoinComponent import org.koin.core.component.get import java.util.Locale -class PresetsRepository(val context: Context) : KoinComponent, IPresetsRepository { +class LegacyCategoriesAndPhrasesRepository(val context: Context) : KoinComponent, ILegacyCategoriesAndPhrasesRepository { private val database = VocableDatabase.getVocableDatabase(context) diff --git a/app/src/main/java/com/willowtree/vocable/settings/AddPhraseViewModel.kt b/app/src/main/java/com/willowtree/vocable/settings/AddPhraseViewModel.kt index f942d5e8..e7b76d40 100644 --- a/app/src/main/java/com/willowtree/vocable/settings/AddPhraseViewModel.kt +++ b/app/src/main/java/com/willowtree/vocable/settings/AddPhraseViewModel.kt @@ -5,7 +5,7 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.willowtree.vocable.PhrasesUseCase -import com.willowtree.vocable.presets.PresetsRepository +import com.willowtree.vocable.presets.LegacyCategoriesAndPhrasesRepository import com.willowtree.vocable.utils.locale.LocalesWithText import kotlinx.coroutines.launch import org.koin.core.component.KoinComponent @@ -14,7 +14,7 @@ import java.util.Locale class AddPhraseViewModel : ViewModel(), KoinComponent { - private val presetsRepository: PresetsRepository by inject() + private val presetsRepository: LegacyCategoriesAndPhrasesRepository by inject() private val phrasesUseCase: PhrasesUseCase by inject() private val liveShowPhraseAdded = MutableLiveData() diff --git a/app/src/main/java/com/willowtree/vocable/settings/EditCategoryMenuViewModel.kt b/app/src/main/java/com/willowtree/vocable/settings/EditCategoryMenuViewModel.kt index d6a5da18..b961895e 100644 --- a/app/src/main/java/com/willowtree/vocable/settings/EditCategoryMenuViewModel.kt +++ b/app/src/main/java/com/willowtree/vocable/settings/EditCategoryMenuViewModel.kt @@ -7,12 +7,12 @@ import androidx.lifecycle.viewModelScope import com.willowtree.vocable.CategoriesUseCase import com.willowtree.vocable.presets.Category import com.willowtree.vocable.presets.PresetCategories -import com.willowtree.vocable.presets.PresetsRepository +import com.willowtree.vocable.presets.LegacyCategoriesAndPhrasesRepository import com.willowtree.vocable.room.CategorySortOrder import kotlinx.coroutines.launch class EditCategoryMenuViewModel( - private val presetsRepository: PresetsRepository, + private val presetsRepository: LegacyCategoriesAndPhrasesRepository, private val categoriesUseCase: CategoriesUseCase ) : ViewModel() { diff --git a/app/src/main/java/com/willowtree/vocable/settings/SettingsViewModel.kt b/app/src/main/java/com/willowtree/vocable/settings/SettingsViewModel.kt index 7ef521b5..5c180bc0 100644 --- a/app/src/main/java/com/willowtree/vocable/settings/SettingsViewModel.kt +++ b/app/src/main/java/com/willowtree/vocable/settings/SettingsViewModel.kt @@ -1,14 +1,11 @@ package com.willowtree.vocable.settings -import androidx.lifecycle.LiveData -import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel -import com.willowtree.vocable.presets.PresetsRepository -import com.willowtree.vocable.utils.VocableSharedPreferences +import com.willowtree.vocable.presets.LegacyCategoriesAndPhrasesRepository import org.koin.core.component.KoinComponent import org.koin.core.component.inject class SettingsViewModel : ViewModel(), KoinComponent { - private val presetsRepository: PresetsRepository by inject() + private val presetsRepository: LegacyCategoriesAndPhrasesRepository by inject() } diff --git a/app/src/main/java/com/willowtree/vocable/splash/SplashViewModel.kt b/app/src/main/java/com/willowtree/vocable/splash/SplashViewModel.kt index edf8d9c1..005ba639 100644 --- a/app/src/main/java/com/willowtree/vocable/splash/SplashViewModel.kt +++ b/app/src/main/java/com/willowtree/vocable/splash/SplashViewModel.kt @@ -4,7 +4,7 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.willowtree.vocable.presets.PresetsRepository +import com.willowtree.vocable.presets.LegacyCategoriesAndPhrasesRepository import com.willowtree.vocable.utils.VocableSharedPreferences import kotlinx.coroutines.launch import org.koin.core.component.KoinComponent @@ -12,7 +12,7 @@ import org.koin.core.component.inject class SplashViewModel : ViewModel(), KoinComponent { - private val presetsRepository: PresetsRepository by inject() + private val presetsRepository: LegacyCategoriesAndPhrasesRepository by inject() private val sharedPrefs: VocableSharedPreferences by inject() diff --git a/app/src/test/java/com/willowtree/vocable/CategoriesUseCaseTest.kt b/app/src/test/java/com/willowtree/vocable/CategoriesUseCaseTest.kt index 33327e7c..542972c5 100644 --- a/app/src/test/java/com/willowtree/vocable/CategoriesUseCaseTest.kt +++ b/app/src/test/java/com/willowtree/vocable/CategoriesUseCaseTest.kt @@ -2,7 +2,7 @@ package com.willowtree.vocable import com.willowtree.vocable.presets.Category import com.willowtree.vocable.presets.FakePresetCategoriesRepository -import com.willowtree.vocable.presets.FakePresetsRepository +import com.willowtree.vocable.presets.FakeLegacyCategoriesAndPhrasesRepository import com.willowtree.vocable.room.CategoryDto import com.willowtree.vocable.room.CategorySortOrder import com.willowtree.vocable.room.FakeStoredCategoriesRepository @@ -17,7 +17,7 @@ import org.junit.Test class CategoriesUseCaseTest { - private val fakePresetsRepository = FakePresetsRepository() + private val fakePresetsRepository = FakeLegacyCategoriesAndPhrasesRepository() private val fakeStoredCategoriesRepository = FakeStoredCategoriesRepository() private val fakePresetCategoriesRepository = FakePresetCategoriesRepository() diff --git a/app/src/test/java/com/willowtree/vocable/PhrasesUseCaseTest.kt b/app/src/test/java/com/willowtree/vocable/PhrasesUseCaseTest.kt index 3672fe2c..1d3d0336 100644 --- a/app/src/test/java/com/willowtree/vocable/PhrasesUseCaseTest.kt +++ b/app/src/test/java/com/willowtree/vocable/PhrasesUseCaseTest.kt @@ -1,7 +1,7 @@ package com.willowtree.vocable import com.willowtree.vocable.presets.CustomPhrase -import com.willowtree.vocable.presets.FakePresetsRepository +import com.willowtree.vocable.presets.FakeLegacyCategoriesAndPhrasesRepository import com.willowtree.vocable.presets.PresetCategories import com.willowtree.vocable.room.PhraseDto import com.willowtree.vocable.utils.FakeDateProvider @@ -11,7 +11,7 @@ import org.junit.Test class PhrasesUseCaseTest { - private val presetsRepository = FakePresetsRepository() + private val presetsRepository = FakeLegacyCategoriesAndPhrasesRepository() private fun createUseCase(): PhrasesUseCase { return PhrasesUseCase(presetsRepository, FakeDateProvider()) diff --git a/app/src/test/java/com/willowtree/vocable/presets/FakePresetsRepository.kt b/app/src/test/java/com/willowtree/vocable/presets/FakeLegacyCategoriesAndPhrasesRepository.kt similarity index 97% rename from app/src/test/java/com/willowtree/vocable/presets/FakePresetsRepository.kt rename to app/src/test/java/com/willowtree/vocable/presets/FakeLegacyCategoriesAndPhrasesRepository.kt index 4e3e2856..0ec10b7c 100644 --- a/app/src/test/java/com/willowtree/vocable/presets/FakePresetsRepository.kt +++ b/app/src/test/java/com/willowtree/vocable/presets/FakeLegacyCategoriesAndPhrasesRepository.kt @@ -9,7 +9,7 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.update -class FakePresetsRepository : IPresetsRepository { +class FakeLegacyCategoriesAndPhrasesRepository : ILegacyCategoriesAndPhrasesRepository { val _allCategories = MutableStateFlow( listOf( diff --git a/app/src/test/java/com/willowtree/vocable/presets/PresetsViewModelTest.kt b/app/src/test/java/com/willowtree/vocable/presets/PresetsViewModelTest.kt index ff651046..4fd70c97 100644 --- a/app/src/test/java/com/willowtree/vocable/presets/PresetsViewModelTest.kt +++ b/app/src/test/java/com/willowtree/vocable/presets/PresetsViewModelTest.kt @@ -25,7 +25,7 @@ class PresetsViewModelTest { @get:Rule val instantTaskExecutorRule = InstantTaskExecutorRule() - private val fakePresetsRepository = FakePresetsRepository() + private val fakePresetsRepository = FakeLegacyCategoriesAndPhrasesRepository() private val fakeCategoriesUseCase = FakeCategoriesUseCase() private fun createViewModel(): PresetsViewModel { diff --git a/app/src/test/java/com/willowtree/vocable/settings/EditCategoriesViewModelTest.kt b/app/src/test/java/com/willowtree/vocable/settings/EditCategoriesViewModelTest.kt index 1285b84f..8dad33b4 100644 --- a/app/src/test/java/com/willowtree/vocable/settings/EditCategoriesViewModelTest.kt +++ b/app/src/test/java/com/willowtree/vocable/settings/EditCategoriesViewModelTest.kt @@ -4,7 +4,7 @@ import androidx.arch.core.executor.testing.InstantTaskExecutorRule import com.willowtree.vocable.FakeCategoriesUseCase import com.willowtree.vocable.MainDispatcherRule import com.willowtree.vocable.PhrasesUseCase -import com.willowtree.vocable.presets.FakePresetsRepository +import com.willowtree.vocable.presets.FakeLegacyCategoriesAndPhrasesRepository import com.willowtree.vocable.presets.createStoredCategory import com.willowtree.vocable.utils.FakeDateProvider import com.willowtree.vocable.utils.FakeLocalizedResourceUtility @@ -21,7 +21,7 @@ class EditCategoriesViewModelTest { @get:Rule val instantTaskExecutorRule = InstantTaskExecutorRule() - private val fakePresetsRepository = FakePresetsRepository() + private val fakePresetsRepository = FakeLegacyCategoriesAndPhrasesRepository() private val categoriesUseCase = FakeCategoriesUseCase() private fun createViewModel(): EditCategoriesViewModel {