diff --git a/app/build.gradle.kts b/app/build.gradle.kts index e3d0f4b3..60156a84 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,5 +1,5 @@ -import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties -import org.gradle.configurationcache.extensions.capitalized +import org.gradle.internal.extensions.stdlib.capitalized +import java.util.Properties plugins { id("com.android.application") @@ -14,13 +14,15 @@ android { namespace = "ru.rznnike.eyehealthmanager" compileSdk = rootProject.extra["TARGET_SDK"] as Int - buildToolsVersion = "34.0.0" + buildToolsVersion = "35.0.0" signingConfigs { create("config") { storeFile = file("../eyehealthmanager.jks") keyAlias = "eyehealthmanager" - val localProperties = gradleLocalProperties(rootDir) + val localProperties = Properties().apply { + rootProject.file("local.properties").reader().use(::load) + } val keyPass = localProperties.getProperty("PROJECT_KEY_PASSWORD") val storePass = localProperties.getProperty("PROJECT_KEYSTORE_PASSWORD") if (keyPass.isNullOrBlank() || storePass.isNullOrBlank()) { @@ -106,7 +108,6 @@ android { viewBinding = true buildConfig = true } - @Suppress("UnstableApiUsage") bundle { abi.enableSplit = false language.enableSplit = false @@ -120,25 +121,26 @@ android { } dependencies { - implementation(project(":data")) implementation(project(":domain")) - implementation(project(":device")) + implementation(project(":data")) implementation(project(":resources")) // Desugaring - coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4") + // https://mvnrepository.com/artifact/com.android.tools/desugar_jdk_libs + coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:" + rootProject.extra["desugaringVersion"]) // AndroidX - implementation("androidx.appcompat:appcompat:1.6.1") + implementation("androidx.appcompat:appcompat:1.7.0") implementation("androidx.constraintlayout:constraintlayout:2.1.4") implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0") - implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0") - implementation("androidx.lifecycle:lifecycle-extensions:2.2.0") + val lifecycleVersion = "2.8.6" + implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion") + implementation("androidx.lifecycle:lifecycle-process:$lifecycleVersion") implementation("androidx.preference:preference-ktx:1.2.1") - implementation("androidx.viewpager2:viewpager2:1.1.0-beta02") - implementation("androidx.annotation:annotation:1.7.1") - implementation("androidx.fragment:fragment-ktx:1.6.2") - implementation("androidx.window:window:1.2.0") + implementation("androidx.viewpager2:viewpager2:1.1.0") + implementation("androidx.annotation:annotation:1.9.0") + implementation("androidx.fragment:fragment-ktx:1.8.4") + implementation("androidx.window:window:1.3.0") // Coroutines implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:" + rootProject.extra["coroutinesVersion"]) @@ -146,11 +148,11 @@ dependencies { testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:" + rootProject.extra["coroutinesVersion"]) // Material - implementation("com.google.android.material:material:1.11.0") + implementation("com.google.android.material:material:1.12.0") // Firebase - implementation("com.google.firebase:firebase-crashlytics-ktx:18.6.1") - implementation("com.google.firebase:firebase-messaging:23.4.0") + implementation("com.google.firebase:firebase-crashlytics-ktx:19.2.0") + implementation("com.google.firebase:firebase-messaging:24.0.2") // Koin // https://github.com/InsertKoinIO/koin @@ -181,7 +183,7 @@ dependencies { // Image loader // https://github.com/coil-kt/coil - implementation("io.coil-kt:coil:2.5.0") + implementation("io.coil-kt:coil:2.7.0") // MPAndroidChart // https://github.com/PhilJay/MPAndroidChart @@ -204,9 +206,9 @@ dependencies { // Mocks for testing // https://github.com/mockito/mockito - val mockitoVersion = "5.9.0" + val mockitoVersion = "5.14.2" testImplementation("org.mockito:mockito-core:$mockitoVersion") testImplementation("org.mockito:mockito-junit-jupiter:$mockitoVersion") // https://github.com/mockito/mockito-kotlin - testImplementation("org.mockito.kotlin:mockito-kotlin:5.2.1") + testImplementation("org.mockito.kotlin:mockito-kotlin:5.4.0") } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8a71db89..e465c0d9 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -33,12 +33,12 @@ diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/App.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/App.kt index b7bdb987..4d80646e 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/App.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/App.kt @@ -14,11 +14,9 @@ import org.koin.core.logger.Level import ru.rznnike.eyehealthmanager.BuildConfig import ru.rznnike.eyehealthmanager.app.di.appComponent import ru.rznnike.eyehealthmanager.app.observer.AppLifeCycleObserver -import ru.rznnike.eyehealthmanager.data.preference.PreferencesWrapper class App : Application() { private val appLifecycleObserver: AppLifeCycleObserver by inject() - private val preferences: PreferencesWrapper by inject() private val boxStore: BoxStore by inject() override fun onCreate() { diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/Screens.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/Screens.kt index 4098290e..21f84d31 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/Screens.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/Screens.kt @@ -44,12 +44,12 @@ import ru.rznnike.eyehealthmanager.app.ui.fragment.nearfar.test.NearFarTestFragm import ru.rznnike.eyehealthmanager.app.ui.fragment.settings.testing.TestingSettingsFragment import ru.rznnike.eyehealthmanager.app.ui.fragment.splash.SplashFlowFragment import ru.rznnike.eyehealthmanager.app.ui.fragment.splash.SplashFragment -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestResult -import ru.rznnike.eyehealthmanager.domain.model.AnalysisResult -import ru.rznnike.eyehealthmanager.domain.model.enums.AstigmatismAnswerType -import ru.rznnike.eyehealthmanager.domain.model.enums.DaltonismAnomalyType -import ru.rznnike.eyehealthmanager.domain.model.enums.DayPart -import ru.rznnike.eyehealthmanager.domain.model.enums.NearFarAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestResult +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisResult +import ru.rznnike.eyehealthmanager.domain.model.test.astigmatism.AstigmatismAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismAnomalyType +import ru.rznnike.eyehealthmanager.domain.model.common.DayPart +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarAnswerType object Screens { object Flow { diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/di/AppModule.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/di/AppModule.kt index 69b1b2dd..fb8a3aa2 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/di/AppModule.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/di/AppModule.kt @@ -3,7 +3,7 @@ package ru.rznnike.eyehealthmanager.app.di import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.MainScope -import org.koin.android.ext.koin.androidContext +import org.koin.android.ext.koin.androidApplication import org.koin.dsl.module import ru.rznnike.eyehealthmanager.app.crash.CrashlyticsProvider import ru.rznnike.eyehealthmanager.app.crash.CrashlyticsProviderImpl @@ -12,29 +12,32 @@ import ru.rznnike.eyehealthmanager.app.dispatcher.external.ExternalIntentDispatc import ru.rznnike.eyehealthmanager.app.dispatcher.notifier.Notifier import ru.rznnike.eyehealthmanager.app.global.presentation.ErrorHandler import ru.rznnike.eyehealthmanager.app.observer.AppLifeCycleObserver -import ru.rznnike.eyehealthmanager.device.notification.Notificator -import ru.rznnike.eyehealthmanager.domain.global.CoroutineProvider +import ru.rznnike.eyehealthmanager.app.notification.Notificator +import ru.rznnike.eyehealthmanager.app.utils.JournalBackupManagerAndroid +import ru.rznnike.eyehealthmanager.app.utils.JournalBackupManagerAndroidImpl +import ru.rznnike.eyehealthmanager.domain.global.CoroutineScopeProvider import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider import java.time.Clock val appModule = module { - factory { androidContext().resources } + factory { androidApplication().resources } factory { AppLifeCycleObserver() } single { Notifier(get()) } single { ErrorHandler(get(), get()) } single { EventDispatcher(get()) } single { ExternalIntentDispatcher(get()) } - single { Notificator(androidContext()) } + single { Notificator() } single { CrashlyticsProviderImpl() } single { Clock.systemUTC() } + factory { JournalBackupManagerAndroidImpl() } - single { - object : CoroutineProvider { - override val scopeIo = CoroutineScope(Dispatchers.IO) - override val scopeMain = MainScope() - override val scopeMainImmediate = CoroutineScope(Dispatchers.Main.immediate) - override val scopeUnconfined = CoroutineScope(Dispatchers.Unconfined) + single { + object : CoroutineScopeProvider { + override val ui = MainScope() + override val default = CoroutineScope(Dispatchers.Default) + override val io = CoroutineScope(Dispatchers.IO) + override val unconfined = CoroutineScope(Dispatchers.Unconfined) } } diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/di/GatewayModule.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/di/GatewayModule.kt index 13b7162a..87c562c1 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/di/GatewayModule.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/di/GatewayModule.kt @@ -13,9 +13,9 @@ import ru.rznnike.eyehealthmanager.domain.gateway.TestGateway import ru.rznnike.eyehealthmanager.domain.gateway.UserGateway val gatewayModule = module { - single { UserGatewayImpl(get()) } - single { NotificationGatewayImpl() } + single { UserGatewayImpl(get(), get()) } + single { NotificationGatewayImpl(get()) } single { TestGatewayImpl(get(), get(), get()) } - single { AnalysisGatewayImpl(get(), get()) } - single { DevGatewayImpl(get(), get()) } + single { AnalysisGatewayImpl(get(), get(), get()) } + single { DevGatewayImpl(get(), get(), get()) } } diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/di/InteractorModule.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/di/InteractorModule.kt index 181456fc..964d6fa1 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/di/InteractorModule.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/di/InteractorModule.kt @@ -40,7 +40,6 @@ val interactorModule = module { single { DeleteAllTestResultsUseCase(get(), get()) } single { DeleteDuplicatesUseCase(get(), get()) } single { ExportJournalUseCase(get(), get()) } - single { GetAvailableImportTypesUseCase(get(), get()) } single { ImportJournalUseCase(get(), get()) } single { GetAnalysisResultUseCase(get(), get()) } diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/dispatcher/event/EventDispatcher.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/dispatcher/event/EventDispatcher.kt index bb7e0510..4badc0cd 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/dispatcher/event/EventDispatcher.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/dispatcher/event/EventDispatcher.kt @@ -1,12 +1,12 @@ package ru.rznnike.eyehealthmanager.app.dispatcher.event import kotlinx.coroutines.launch -import ru.rznnike.eyehealthmanager.domain.global.CoroutineProvider +import ru.rznnike.eyehealthmanager.domain.global.CoroutineScopeProvider import java.util.* import kotlin.reflect.KClass class EventDispatcher( - private val coroutineProvider: CoroutineProvider + private val coroutineScopeProvider: CoroutineScopeProvider ) { private val eventListeners = HashMap>() @@ -36,16 +36,16 @@ class EventDispatcher( } fun removeEventListener(listener: EventListener) = eventListeners - .filter { it.value.size > 0 } + .filter { it.value.isNotEmpty() } .forEach { it.value.remove(listener) } fun sendEvent(appEvent: AppEvent) { val key = appEvent::class.java.name eventListeners - .filter { it.key == key && it.value.size > 0 } + .filter { it.key == key && it.value.isNotEmpty() } .forEach { it.value.forEach { listener -> - coroutineProvider.scopeMain.launch { + coroutineScopeProvider.ui.launch { listener.onEvent(appEvent) } } diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/dispatcher/external/ExternalIntentDispatcher.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/dispatcher/external/ExternalIntentDispatcher.kt index fd79aef3..ad9c0c9c 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/dispatcher/external/ExternalIntentDispatcher.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/dispatcher/external/ExternalIntentDispatcher.kt @@ -3,11 +3,11 @@ package ru.rznnike.eyehealthmanager.app.dispatcher.external import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch -import ru.rznnike.eyehealthmanager.domain.global.CoroutineProvider -import ru.rznnike.eyehealthmanager.domain.model.ExternalIntentData +import ru.rznnike.eyehealthmanager.domain.global.CoroutineScopeProvider +import ru.rznnike.eyehealthmanager.domain.model.common.ExternalIntentData class ExternalIntentDispatcher( - private val coroutineProvider: CoroutineProvider + private val coroutineScopeProvider: CoroutineScopeProvider ) { private val eventsFlow = MutableStateFlow( ExternalIntentData.App().apply { processed = true } @@ -16,7 +16,7 @@ class ExternalIntentDispatcher( fun subscribe() = eventsFlow.asStateFlow() fun send(data: ExternalIntentData) { - coroutineProvider.scopeIo.launch { + coroutineScopeProvider.io.launch { eventsFlow.emit(data) } } diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/dispatcher/notifier/Notifier.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/dispatcher/notifier/Notifier.kt index 2891cd1b..55d2cb8b 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/dispatcher/notifier/Notifier.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/dispatcher/notifier/Notifier.kt @@ -4,10 +4,10 @@ import androidx.annotation.StringRes import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow import kotlinx.coroutines.launch -import ru.rznnike.eyehealthmanager.domain.global.CoroutineProvider +import ru.rznnike.eyehealthmanager.domain.global.CoroutineScopeProvider class Notifier( - private val coroutineProvider: CoroutineProvider + private val coroutineScopeProvider: CoroutineScopeProvider ) { private val notifierFlow = MutableSharedFlow() @@ -86,7 +86,7 @@ class Notifier( ) private fun emitMessage(message: SystemMessage) { - coroutineProvider.scopeIo.launch { + coroutineScopeProvider.io.launch { notifierFlow.emit(message) } } diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/global/ui/activity/BaseActivity.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/global/ui/activity/BaseActivity.kt index f5fd56a4..258231aa 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/global/ui/activity/BaseActivity.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/global/ui/activity/BaseActivity.kt @@ -11,7 +11,7 @@ import ru.rznnike.eyehealthmanager.app.global.presentation.ErrorHandler import ru.rznnike.eyehealthmanager.app.global.ui.fragment.BaseFragment import ru.rznnike.eyehealthmanager.app.utils.extensions.applyTheme import ru.rznnike.eyehealthmanager.data.preference.PreferencesWrapper -import ru.rznnike.eyehealthmanager.domain.model.enums.AppTheme +import ru.rznnike.eyehealthmanager.domain.model.common.AppTheme abstract class BaseActivity(@LayoutRes layoutRes: Int) : MvpAppCompatActivity(layoutRes) { private val preferences: PreferencesWrapper by inject() diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/global/ui/fragment/BaseFragment.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/global/ui/fragment/BaseFragment.kt index 447aa087..eac085da 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/global/ui/fragment/BaseFragment.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/global/ui/fragment/BaseFragment.kt @@ -16,10 +16,10 @@ import kotlin.concurrent.schedule abstract class BaseFragment(@LayoutRes layoutRes: Int) : MvpAppCompatFragment(layoutRes) { open var isLightStatusBar: Boolean = true - get() = !(context?.isNightModeEnabled ?: false) + get() = context?.isNightModeEnabled != true protected set open var isLightNavigationBar: Boolean = true - get() = !(context?.isNightModeEnabled ?: false) + get() = context?.isNightModeEnabled != true protected set open var progressDelayMs: Long = DEFAULT_PROGRESS_DELAY_MS protected set diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/common/AppThemeVM.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/common/AppThemeVM.kt new file mode 100644 index 00000000..c89bd4ce --- /dev/null +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/common/AppThemeVM.kt @@ -0,0 +1,27 @@ +package ru.rznnike.eyehealthmanager.app.model.common + +import androidx.annotation.StringRes +import ru.rznnike.eyehealthmanager.R +import ru.rznnike.eyehealthmanager.domain.model.common.AppTheme + +enum class AppThemeVM( + val data: AppTheme, + @StringRes val nameResId: Int +) { + LIGHT( + data = AppTheme.LIGHT, + nameResId = R.string.theme_light + ), + DARK( + data = AppTheme.DARK, + nameResId = R.string.theme_dark + ), + SYSTEM( + data = AppTheme.SYSTEM, + nameResId = R.string.theme_system + ); + + companion object { + operator fun get(data: AppTheme?) = entries.find { it.data == data } ?: SYSTEM + } +} \ No newline at end of file diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/notification/NotificationChannelTypeVM.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/notification/NotificationChannelTypeVM.kt new file mode 100644 index 00000000..8f11d32a --- /dev/null +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/notification/NotificationChannelTypeVM.kt @@ -0,0 +1,19 @@ +package ru.rznnike.eyehealthmanager.app.model.notification + +import androidx.annotation.StringRes +import ru.rznnike.eyehealthmanager.R +import ru.rznnike.eyehealthmanager.domain.model.notification.NotificationChannelType + +enum class NotificationChannelTypeVM( + val data: NotificationChannelType, + @StringRes val nameResId: Int +) { + SYSTEM( + data = NotificationChannelType.SYSTEM, + nameResId = R.string.notification_channel_system + ); + + companion object { + operator fun get(data: NotificationChannelType?) = entries.find { it.data == data } ?: SYSTEM + } +} \ No newline at end of file diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/TestEyesTypeVM.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/TestEyesTypeVM.kt new file mode 100644 index 00000000..2afbdc4a --- /dev/null +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/TestEyesTypeVM.kt @@ -0,0 +1,27 @@ +package ru.rznnike.eyehealthmanager.app.model.test + +import androidx.annotation.StringRes +import ru.rznnike.eyehealthmanager.R +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType + +enum class TestEyesTypeVM( + val data: TestEyesType, + @StringRes val nameResId: Int +) { + BOTH( + data = TestEyesType.BOTH, + nameResId = R.string.eyes_type_both + ), + LEFT( + data = TestEyesType.LEFT, + nameResId = R.string.eyes_type_left + ), + RIGHT( + data = TestEyesType.RIGHT, + nameResId = R.string.eyes_type_right + ); + + companion object { + operator fun get(data: TestEyesType?) = entries.find { it.data == data } ?: BOTH + } +} \ No newline at end of file diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/TestTypeVM.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/TestTypeVM.kt new file mode 100644 index 00000000..3db2af10 --- /dev/null +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/TestTypeVM.kt @@ -0,0 +1,47 @@ +package ru.rznnike.eyehealthmanager.app.model.test + +import androidx.annotation.DrawableRes +import androidx.annotation.StringRes +import ru.rznnike.eyehealthmanager.R +import ru.rznnike.eyehealthmanager.domain.model.test.TestType + +enum class TestTypeVM( + val data: TestType, + @StringRes val nameResId: Int, + @DrawableRes val iconResId: Int +) { + ACUITY( + data = TestType.ACUITY, + nameResId = R.string.test_acuity, + iconResId = R.drawable.ic_acuity + ), + ASTIGMATISM( + data = TestType.ASTIGMATISM, + nameResId = R.string.test_astigmatism, + iconResId = R.drawable.ic_astigmatism + ), + NEAR_FAR( + data = TestType.NEAR_FAR, + nameResId = R.string.test_nearsightedness_farsightedness, + iconResId = R.drawable.ic_near_far + ), + COLOR_PERCEPTION( + data = TestType.COLOR_PERCEPTION, + nameResId = R.string.test_color_perception, + iconResId = R.drawable.ic_color_perception + ), + DALTONISM( + data = TestType.DALTONISM, + nameResId = R.string.test_daltonism, + iconResId = R.drawable.ic_daltonism + ), + CONTRAST( + data = TestType.CONTRAST, + nameResId = R.string.test_contrast, + iconResId = R.drawable.ic_contrast + ); + + companion object { + operator fun get(data: TestType?) = entries.find { it.data == data } ?: ACUITY + } +} \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AcuitySymbolLetterEn.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/acuity/AcuitySymbolLetterEn.kt similarity index 77% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AcuitySymbolLetterEn.kt rename to app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/acuity/AcuitySymbolLetterEn.kt index 3ffb16c8..af782b0f 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AcuitySymbolLetterEn.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/acuity/AcuitySymbolLetterEn.kt @@ -1,8 +1,7 @@ -package ru.rznnike.eyehealthmanager.domain.model.enums +package ru.rznnike.eyehealthmanager.app.model.test.acuity import androidx.annotation.DrawableRes -import ru.rznnike.eyehealthmanager.domain.R -import ru.rznnike.eyehealthmanager.domain.model.IAcuitySymbol +import ru.rznnike.eyehealthmanager.R enum class AcuitySymbolLetterEn( @DrawableRes val iconResId: Int diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AcuitySymbolLetterRu.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/acuity/AcuitySymbolLetterRu.kt similarity index 74% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AcuitySymbolLetterRu.kt rename to app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/acuity/AcuitySymbolLetterRu.kt index ebbf9bf8..2751a01e 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AcuitySymbolLetterRu.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/acuity/AcuitySymbolLetterRu.kt @@ -1,8 +1,7 @@ -package ru.rznnike.eyehealthmanager.domain.model.enums +package ru.rznnike.eyehealthmanager.app.model.test.acuity import androidx.annotation.DrawableRes -import ru.rznnike.eyehealthmanager.domain.R -import ru.rznnike.eyehealthmanager.domain.model.IAcuitySymbol +import ru.rznnike.eyehealthmanager.R enum class AcuitySymbolLetterRu( @DrawableRes val iconResId: Int diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AcuitySymbolSquare.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/acuity/AcuitySymbolSquare.kt similarity index 80% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AcuitySymbolSquare.kt rename to app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/acuity/AcuitySymbolSquare.kt index bae7b4ea..b6ce29db 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AcuitySymbolSquare.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/acuity/AcuitySymbolSquare.kt @@ -1,8 +1,7 @@ -package ru.rznnike.eyehealthmanager.domain.model.enums +package ru.rznnike.eyehealthmanager.app.model.test.acuity import androidx.annotation.DrawableRes -import ru.rznnike.eyehealthmanager.domain.R -import ru.rznnike.eyehealthmanager.domain.model.IAcuitySymbol +import ru.rznnike.eyehealthmanager.R enum class AcuitySymbolSquare( @DrawableRes val iconResId: Int diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AcuitySymbolTriangle.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/acuity/AcuitySymbolTriangle.kt similarity index 81% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AcuitySymbolTriangle.kt rename to app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/acuity/AcuitySymbolTriangle.kt index a26ddd09..9abc2f41 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AcuitySymbolTriangle.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/acuity/AcuitySymbolTriangle.kt @@ -1,8 +1,7 @@ -package ru.rznnike.eyehealthmanager.domain.model.enums +package ru.rznnike.eyehealthmanager.app.model.test.acuity import androidx.annotation.DrawableRes -import ru.rznnike.eyehealthmanager.domain.R -import ru.rznnike.eyehealthmanager.domain.model.IAcuitySymbol +import ru.rznnike.eyehealthmanager.R enum class AcuitySymbolTriangle( @DrawableRes val iconResId: Int diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/acuity/AcuityTestSymbolsTypeVM.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/acuity/AcuityTestSymbolsTypeVM.kt new file mode 100644 index 00000000..46decfe6 --- /dev/null +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/acuity/AcuityTestSymbolsTypeVM.kt @@ -0,0 +1,37 @@ +package ru.rznnike.eyehealthmanager.app.model.test.acuity + +import androidx.annotation.DrawableRes +import androidx.annotation.StringRes +import ru.rznnike.eyehealthmanager.R +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestSymbolsType + +enum class AcuityTestSymbolsTypeVM( + val data: AcuityTestSymbolsType, + @DrawableRes val iconResId: Int, + @StringRes val nameResId: Int +) { + LETTERS_RU( + data = AcuityTestSymbolsType.LETTERS_RU, + iconResId = R.drawable.ic_letters_ru_sh, + nameResId = R.string.symbols_letters_ru + ), + LETTERS_EN( + data = AcuityTestSymbolsType.LETTERS_EN, + iconResId = R.drawable.ic_letters_en_f, + nameResId = R.string.symbols_letters_en + ), + SQUARE( + data = AcuityTestSymbolsType.SQUARE, + iconResId = R.drawable.ic_square_symbol_1, + nameResId = R.string.symbols_square + ), + TRIANGLE( + data = AcuityTestSymbolsType.TRIANGLE, + iconResId = R.drawable.ic_triangle_symbol_1, + nameResId = R.string.symbols_triangle + ); + + companion object { + operator fun get(data: AcuityTestSymbolsType?) = entries.find { it.data == data } ?: LETTERS_RU + } +} \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/EmptyAcuitySymbol.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/acuity/EmptyAcuitySymbol.kt similarity index 66% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/EmptyAcuitySymbol.kt rename to app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/acuity/EmptyAcuitySymbol.kt index 88b3222a..1361b902 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/EmptyAcuitySymbol.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/acuity/EmptyAcuitySymbol.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.app.model.test.acuity object EmptyAcuitySymbol : IAcuitySymbol { override fun getDrawableRes() = 0 diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/IAcuitySymbol.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/acuity/IAcuitySymbol.kt similarity index 69% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/IAcuitySymbol.kt rename to app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/acuity/IAcuitySymbol.kt index 247556aa..400f34cc 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/IAcuitySymbol.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/acuity/IAcuitySymbol.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.app.model.test.acuity import androidx.annotation.DrawableRes diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/astigmatism/AstigmatismAnswerTypeVM.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/astigmatism/AstigmatismAnswerTypeVM.kt new file mode 100644 index 00000000..0963acb7 --- /dev/null +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/astigmatism/AstigmatismAnswerTypeVM.kt @@ -0,0 +1,26 @@ +package ru.rznnike.eyehealthmanager.app.model.test.astigmatism + +import android.os.Parcelable +import androidx.annotation.StringRes +import kotlinx.parcelize.Parcelize +import ru.rznnike.eyehealthmanager.R +import ru.rznnike.eyehealthmanager.domain.model.test.astigmatism.AstigmatismAnswerType + +@Parcelize +enum class AstigmatismAnswerTypeVM( + val data: AstigmatismAnswerType, + @StringRes val nameResId: Int +) : Parcelable { + OK( + data = AstigmatismAnswerType.OK, + nameResId = R.string.normal_condition + ), + ANOMALY( + data = AstigmatismAnswerType.ANOMALY, + nameResId = R.string.possible_astigmatism + ); + + companion object { + operator fun get(data: AstigmatismAnswerType?) = entries.find { it.data == data } ?: OK + } +} \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/ColorPerceptionTestData.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/colorperception/ColorPerceptionTestData.kt similarity index 94% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/ColorPerceptionTestData.kt rename to app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/colorperception/ColorPerceptionTestData.kt index 136e7143..b5c35754 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/ColorPerceptionTestData.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/colorperception/ColorPerceptionTestData.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.app.model.test.colorperception import androidx.annotation.ColorInt diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/daltonism/DaltonismAnomalyTypeVM.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/daltonism/DaltonismAnomalyTypeVM.kt new file mode 100644 index 00000000..b38eefcf --- /dev/null +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/daltonism/DaltonismAnomalyTypeVM.kt @@ -0,0 +1,58 @@ +package ru.rznnike.eyehealthmanager.app.model.test.daltonism + +import android.os.Parcelable +import androidx.annotation.StringRes +import kotlinx.parcelize.Parcelize +import ru.rznnike.eyehealthmanager.R +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismAnomalyType + +@Parcelize +enum class DaltonismAnomalyTypeVM( + val data: DaltonismAnomalyType, + @StringRes val nameResId: Int +) : Parcelable { + NONE( + data = DaltonismAnomalyType.NONE, + nameResId = R.string.rabkin_result_normal + ), + PROTANOPIA( + data = DaltonismAnomalyType.PROTANOPIA, + nameResId = R.string.rabkin_result_protanopia + ), + DEITERANOPIA( + data = DaltonismAnomalyType.DEITERANOPIA, + nameResId = R.string.rabkin_result_deiteranopia + ), + PROTANOMALY_A( + data = DaltonismAnomalyType.PROTANOMALY_A, + nameResId = R.string.rabkin_result_protanomaly_a + ), + PROTANOMALY_B( + data = DaltonismAnomalyType.PROTANOMALY_B, + nameResId = R.string.rabkin_result_protanomaly_b + ), + PROTANOMALY_C( + data = DaltonismAnomalyType.PROTANOMALY_C, + nameResId = R.string.rabkin_result_protanomaly_c + ), + DEITERANOMALY_A( + data = DaltonismAnomalyType.DEITERANOMALY_A, + nameResId = R.string.rabkin_result_deiteranomaly_a + ), + DEITERANOMALY_B( + data = DaltonismAnomalyType.DEITERANOMALY_B, + nameResId = R.string.rabkin_result_deiteranomaly_b + ), + DEITERANOMALY_C( + data = DaltonismAnomalyType.DEITERANOMALY_C, + nameResId = R.string.rabkin_result_deiteranomaly_c + ), + PATHOLOGY( + data = DaltonismAnomalyType.PATHOLOGY, + nameResId = R.string.rabkin_result_parhology + ); + + companion object { + operator fun get(data: DaltonismAnomalyType?) = entries.find { it.data == data } ?: NONE + } +} \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/DaltonismTestData.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/daltonism/DaltonismTestData.kt similarity index 99% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/DaltonismTestData.kt rename to app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/daltonism/DaltonismTestData.kt index 34ffcc9d..7d36bc44 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/DaltonismTestData.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/daltonism/DaltonismTestData.kt @@ -1,7 +1,7 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.app.model.test.daltonism -import ru.rznnike.eyehealthmanager.domain.R -import ru.rznnike.eyehealthmanager.domain.model.enums.DaltonismAnomalyType +import ru.rznnike.eyehealthmanager.R +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismAnomalyType object DaltonismTestData { val questions: List = listOf( diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/DaltonismTestQuestion.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/daltonism/DaltonismTestQuestion.kt similarity index 69% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/DaltonismTestQuestion.kt rename to app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/daltonism/DaltonismTestQuestion.kt index 34e612fe..1c95ef95 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/DaltonismTestQuestion.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/daltonism/DaltonismTestQuestion.kt @@ -1,8 +1,8 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.app.model.test.daltonism import androidx.annotation.DrawableRes import androidx.annotation.StringRes -import ru.rznnike.eyehealthmanager.domain.model.enums.DaltonismAnomalyType +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismAnomalyType data class DaltonismTestQuestion( @DrawableRes val testImageResId: Int, diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/nearfar/NearFarAnswerTypeVM.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/nearfar/NearFarAnswerTypeVM.kt new file mode 100644 index 00000000..01459143 --- /dev/null +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/model/test/nearfar/NearFarAnswerTypeVM.kt @@ -0,0 +1,30 @@ +package ru.rznnike.eyehealthmanager.app.model.test.nearfar + +import android.os.Parcelable +import androidx.annotation.StringRes +import kotlinx.parcelize.Parcelize +import ru.rznnike.eyehealthmanager.R +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarAnswerType + +@Parcelize +enum class NearFarAnswerTypeVM( + val data: NearFarAnswerType, + @StringRes val nameResId: Int +) : Parcelable { + EQUAL( + data = NearFarAnswerType.EQUAL, + nameResId = R.string.normal_condition + ), + RED_BETTER( + data = NearFarAnswerType.RED_BETTER, + nameResId = R.string.possible_myopia + ), + GREEN_BETTER( + data = NearFarAnswerType.GREEN_BETTER, + nameResId = R.string.possible_farsightedness + ); + + companion object { + operator fun get(data: NearFarAnswerType?) = entries.find { it.data == data } ?: EQUAL + } +} \ No newline at end of file diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/navigation/SupportAppNavigation.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/navigation/SupportAppNavigation.kt index f632d55f..c97af3cd 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/navigation/SupportAppNavigation.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/navigation/SupportAppNavigation.kt @@ -9,7 +9,7 @@ import androidx.transition.Fade import com.github.terrakok.cicerone.androidx.FragmentScreen import ru.rznnike.eyehealthmanager.R import ru.rznnike.eyehealthmanager.app.dispatcher.notifier.Notifier -import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants +import ru.rznnike.eyehealthmanager.app.utils.AppConstants open class SupportAppNavigation( appActivity: AppCompatActivity, @@ -39,7 +39,7 @@ open class SupportAppNavigation( notifier.sendMessage(R.string.double_back_to_exit) Handler(Looper.getMainLooper()).postDelayed( { doubleBackToExitPressedOnce = false }, - GlobalConstants.APP_EXIT_DURATION_MS + AppConstants.APP_EXIT_DURATION_MS ) } } \ No newline at end of file diff --git a/device/src/main/java/ru/rznnike/eyehealthmanager/device/notification/Notificator.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/notification/Notificator.kt similarity index 90% rename from device/src/main/java/ru/rznnike/eyehealthmanager/device/notification/Notificator.kt rename to app/src/main/java/ru/rznnike/eyehealthmanager/app/notification/Notificator.kt index 196a14f9..ad8d8b8b 100644 --- a/device/src/main/java/ru/rznnike/eyehealthmanager/device/notification/Notificator.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/notification/Notificator.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.device.notification +package ru.rznnike.eyehealthmanager.app.notification import android.app.NotificationChannel import android.app.NotificationManager @@ -14,15 +14,17 @@ import androidx.core.app.NotificationCompat import androidx.core.content.ContextCompat import org.koin.core.component.KoinComponent import org.koin.core.component.inject +import ru.rznnike.eyehealthmanager.R +import ru.rznnike.eyehealthmanager.app.model.notification.NotificationChannelTypeVM import ru.rznnike.eyehealthmanager.data.preference.PreferencesWrapper -import ru.rznnike.eyehealthmanager.device.R -import ru.rznnike.eyehealthmanager.domain.model.CancelNotification -import ru.rznnike.eyehealthmanager.domain.model.Notification -import ru.rznnike.eyehealthmanager.domain.model.enums.NotificationChannelType +import ru.rznnike.eyehealthmanager.domain.model.notification.CancelNotification +import ru.rznnike.eyehealthmanager.domain.model.notification.Notification +import ru.rznnike.eyehealthmanager.domain.model.notification.NotificationChannelType private const val NOTIFICATION_CHANNEL_ID_SOUNDLESS_SUFFIX = "_soundless" -class Notificator(val context: Context) : KoinComponent { +class Notificator : KoinComponent { + private val context: Context by inject() private val preferencesWrapper: PreferencesWrapper by inject() private val notificationManager: NotificationManager = @@ -31,12 +33,13 @@ class Notificator(val context: Context) : KoinComponent { init { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationChannelType.entries.forEach { + val typeVM = NotificationChannelTypeVM[it] createIfNotExistNotificationChannel( channelId = getChannelId( notificationChannelType = it, soundEnabled = true ), - channelName = context.getString(it.nameResId), + channelName = context.getString(typeVM.nameResId), soundEnabled = true ) createIfNotExistNotificationChannel( @@ -45,7 +48,7 @@ class Notificator(val context: Context) : KoinComponent { soundEnabled = false ), channelName = "%s (%s)".format( - context.getString(it.nameResId), + context.getString(typeVM.nameResId), context.getString(R.string.notification_channel_soundless_suffix) ), soundEnabled = false diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/observer/AppLifeCycleObserver.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/observer/AppLifeCycleObserver.kt index 98696e6a..5f6aad34 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/observer/AppLifeCycleObserver.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/observer/AppLifeCycleObserver.kt @@ -6,7 +6,7 @@ import androidx.lifecycle.LifecycleOwner import org.koin.core.component.KoinComponent import org.koin.core.component.inject import ru.rznnike.eyehealthmanager.app.global.presentation.ErrorHandler -import ru.rznnike.eyehealthmanager.device.service.NotificationService +import ru.rznnike.eyehealthmanager.app.service.NotificationService class AppLifeCycleObserver : DefaultLifecycleObserver, KoinComponent { private val context: Context by inject() diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/doctor/AcuityDoctorResultPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/doctor/AcuityDoctorResultPresenter.kt index 83f14a81..dbf99ebf 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/doctor/AcuityDoctorResultPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/doctor/AcuityDoctorResultPresenter.kt @@ -11,10 +11,10 @@ import ru.rznnike.eyehealthmanager.app.dispatcher.notifier.Notifier import ru.rznnike.eyehealthmanager.app.global.presentation.BasePresenter import ru.rznnike.eyehealthmanager.app.global.presentation.ErrorHandler import ru.rznnike.eyehealthmanager.domain.interactor.test.AddTestResultUseCase -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestResult -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuityTestSymbolsType -import ru.rznnike.eyehealthmanager.domain.model.enums.DayPart -import ru.rznnike.eyehealthmanager.domain.model.enums.TestEyesType +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestSymbolsType +import ru.rznnike.eyehealthmanager.domain.model.common.DayPart +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType import ru.rznnike.eyehealthmanager.domain.utils.toFloatOrNullSmart import java.time.Clock diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/info/AcuityInfoPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/info/AcuityInfoPresenter.kt index a793c73d..91ba19eb 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/info/AcuityInfoPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/info/AcuityInfoPresenter.kt @@ -11,11 +11,11 @@ import ru.rznnike.eyehealthmanager.app.global.presentation.BasePresenter import ru.rznnike.eyehealthmanager.domain.interactor.user.GetAcuityTestingSettingsUseCase import ru.rznnike.eyehealthmanager.domain.interactor.user.GetTestingSettingsUseCase import ru.rznnike.eyehealthmanager.domain.interactor.user.SetAcuityTestingSettingsUseCase -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestingSettings -import ru.rznnike.eyehealthmanager.domain.model.TestingSettings -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuityTestSymbolsType -import ru.rznnike.eyehealthmanager.domain.model.enums.DayPart -import ru.rznnike.eyehealthmanager.domain.model.enums.TestEyesType +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestingSettings +import ru.rznnike.eyehealthmanager.domain.model.test.TestingSettings +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestSymbolsType +import ru.rznnike.eyehealthmanager.domain.model.common.DayPart +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType import ru.rznnike.eyehealthmanager.domain.utils.getDayTime import java.time.Clock diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/info/AcuityInfoView.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/info/AcuityInfoView.kt index 169e0982..fc17a388 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/info/AcuityInfoView.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/info/AcuityInfoView.kt @@ -3,7 +3,7 @@ package ru.rznnike.eyehealthmanager.app.presentation.acuity.info import moxy.viewstate.strategy.alias.AddToEndSingle import moxy.viewstate.strategy.alias.OneExecution import ru.rznnike.eyehealthmanager.app.global.presentation.NavigationMvpView -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestingSettings +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestingSettings interface AcuityInfoView : NavigationMvpView { @AddToEndSingle diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/instruction/AcuityInstructionPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/instruction/AcuityInstructionPresenter.kt index 35dfa6ef..a07ea316 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/instruction/AcuityInstructionPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/instruction/AcuityInstructionPresenter.kt @@ -3,7 +3,7 @@ package ru.rznnike.eyehealthmanager.app.presentation.acuity.instruction import moxy.InjectViewState import ru.rznnike.eyehealthmanager.app.Screens import ru.rznnike.eyehealthmanager.app.global.presentation.BasePresenter -import ru.rznnike.eyehealthmanager.domain.model.enums.DayPart +import ru.rznnike.eyehealthmanager.domain.model.common.DayPart @InjectViewState class AcuityInstructionPresenter( diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/result/AcuityResultPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/result/AcuityResultPresenter.kt index 537c5eed..054b82a4 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/result/AcuityResultPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/result/AcuityResultPresenter.kt @@ -13,10 +13,10 @@ import ru.rznnike.eyehealthmanager.app.global.presentation.ErrorHandler import ru.rznnike.eyehealthmanager.domain.interactor.analysis.GetAnalysisResultUseCase import ru.rznnike.eyehealthmanager.domain.interactor.test.DeleteTestResultUseCase import ru.rznnike.eyehealthmanager.domain.interactor.user.GetApplyDynamicCorrectionsUseCase -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestResult -import ru.rznnike.eyehealthmanager.domain.model.AnalysisParameters -import ru.rznnike.eyehealthmanager.domain.model.AnalysisResult -import ru.rznnike.eyehealthmanager.domain.model.enums.AnalysisType +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestResult +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisParameters +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisResult +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisType import ru.rznnike.eyehealthmanager.domain.model.exception.NotEnoughDataException import ru.rznnike.eyehealthmanager.domain.utils.atEndOfDay import ru.rznnike.eyehealthmanager.domain.utils.millis @@ -41,7 +41,7 @@ class AcuityResultPresenter( override fun onFirstViewAttach() { presenterScope.launch { viewState.setProgress(true) - applyDynamicCorrections = getApplyDynamicCorrectionsUseCase().data ?: false + applyDynamicCorrections = getApplyDynamicCorrectionsUseCase().data == true val dateNow = clock.millis().toLocalDate() val parameters = AnalysisParameters( dateFrom = dateNow.minusMonths(1).atStartOfDay().millis(), diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/result/AcuityResultView.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/result/AcuityResultView.kt index 8573dab0..006f9f52 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/result/AcuityResultView.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/result/AcuityResultView.kt @@ -2,8 +2,8 @@ package ru.rznnike.eyehealthmanager.app.presentation.acuity.result import moxy.viewstate.strategy.alias.AddToEndSingle import ru.rznnike.eyehealthmanager.app.global.presentation.NavigationMvpView -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestResult -import ru.rznnike.eyehealthmanager.domain.model.AnalysisResult +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestResult +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisResult interface AcuityResultView : NavigationMvpView { @AddToEndSingle diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/test/AcuityTestPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/test/AcuityTestPresenter.kt index c99ffbc5..3e18eff4 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/test/AcuityTestPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/test/AcuityTestPresenter.kt @@ -10,11 +10,21 @@ import ru.rznnike.eyehealthmanager.app.dispatcher.event.EventDispatcher import ru.rznnike.eyehealthmanager.app.dispatcher.notifier.Notifier import ru.rznnike.eyehealthmanager.app.global.presentation.BasePresenter import ru.rznnike.eyehealthmanager.app.global.presentation.ErrorHandler +import ru.rznnike.eyehealthmanager.app.model.test.acuity.AcuitySymbolLetterEn +import ru.rznnike.eyehealthmanager.app.model.test.acuity.AcuitySymbolLetterRu +import ru.rznnike.eyehealthmanager.app.model.test.acuity.AcuitySymbolSquare +import ru.rznnike.eyehealthmanager.app.model.test.acuity.AcuitySymbolTriangle import ru.rznnike.eyehealthmanager.domain.interactor.test.AddTestResultUseCase import ru.rznnike.eyehealthmanager.domain.interactor.user.GetAcuityTestingSettingsUseCase import ru.rznnike.eyehealthmanager.domain.interactor.user.GetTestingSettingsUseCase -import ru.rznnike.eyehealthmanager.domain.model.* -import ru.rznnike.eyehealthmanager.domain.model.enums.* +import ru.rznnike.eyehealthmanager.domain.model.common.DayPart +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType +import ru.rznnike.eyehealthmanager.domain.model.test.TestingSettings +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestSymbolsType +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestingSettings +import ru.rznnike.eyehealthmanager.app.model.test.acuity.EmptyAcuitySymbol +import ru.rznnike.eyehealthmanager.app.model.test.acuity.IAcuitySymbol import java.time.Clock import kotlin.math.pow import kotlin.math.sqrt diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/test/AcuityTestView.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/test/AcuityTestView.kt index 936d2093..348572fc 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/test/AcuityTestView.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/test/AcuityTestView.kt @@ -5,9 +5,9 @@ import moxy.viewstate.strategy.AddToEndSingleTagStrategy import moxy.viewstate.strategy.StateStrategyType import moxy.viewstate.strategy.alias.AddToEndSingle import ru.rznnike.eyehealthmanager.app.global.presentation.NavigationMvpView -import ru.rznnike.eyehealthmanager.domain.model.IAcuitySymbol -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuityTestSymbolsType -import ru.rznnike.eyehealthmanager.domain.model.enums.TestEyesType +import ru.rznnike.eyehealthmanager.app.model.test.acuity.IAcuitySymbol +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestSymbolsType +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType private const val DATA_TAG = "DATA_TAG" diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/parameters/AnalysisParametersPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/parameters/AnalysisParametersPresenter.kt index 7235e480..77e1ecf7 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/parameters/AnalysisParametersPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/parameters/AnalysisParametersPresenter.kt @@ -8,13 +8,13 @@ import ru.rznnike.eyehealthmanager.app.Screens import ru.rznnike.eyehealthmanager.app.dispatcher.notifier.Notifier import ru.rznnike.eyehealthmanager.app.global.presentation.BasePresenter import ru.rznnike.eyehealthmanager.app.global.presentation.ErrorHandler +import ru.rznnike.eyehealthmanager.data.utils.DataConstants import ru.rznnike.eyehealthmanager.domain.interactor.analysis.GetAnalysisResultUseCase import ru.rznnike.eyehealthmanager.domain.interactor.user.GetApplyDynamicCorrectionsUseCase import ru.rznnike.eyehealthmanager.domain.interactor.user.SetApplyDynamicCorrectionsUseCase -import ru.rznnike.eyehealthmanager.domain.model.AnalysisParameters -import ru.rznnike.eyehealthmanager.domain.model.enums.AnalysisType +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisParameters +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisType import ru.rznnike.eyehealthmanager.domain.model.exception.NotEnoughDataException -import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants import ru.rznnike.eyehealthmanager.domain.utils.atEndOfDay import ru.rznnike.eyehealthmanager.domain.utils.millis import ru.rznnike.eyehealthmanager.domain.utils.toLocalDate @@ -40,9 +40,9 @@ class AnalysisParametersPresenter : BasePresenter() { presenterScope.launch { val dateNow = clock.millis().toLocalDate() parameters.apply { - dateFrom = dateNow.minusDays(GlobalConstants.ANALYSIS_MAX_RANGE_DAYS - 1).atStartOfDay().millis() + dateFrom = dateNow.minusDays(DataConstants.ANALYSIS_MAX_RANGE_DAYS - 1).atStartOfDay().millis() dateTo = dateNow.atEndOfDay().millis() - applyDynamicCorrections = getApplyDynamicCorrectionsUseCase().data ?: false + applyDynamicCorrections = getApplyDynamicCorrectionsUseCase().data == true } viewState.populateData(parameters) } @@ -52,15 +52,15 @@ class AnalysisParametersPresenter : BasePresenter() { parameters.dateFrom = newValue.toLocalDate().atStartOfDay().millis() val deltaDays = ChronoUnit.DAYS.between(parameters.dateFrom.toLocalDate(), parameters.dateTo.toLocalDate()) when { - deltaDays < (GlobalConstants.ANALYSIS_MIN_RANGE_DAYS - 1) -> { + deltaDays < (DataConstants.ANALYSIS_MIN_RANGE_DAYS - 1) -> { parameters.dateTo = newValue.toLocalDate() - .plusDays(GlobalConstants.ANALYSIS_MIN_RANGE_DAYS - 1) + .plusDays(DataConstants.ANALYSIS_MIN_RANGE_DAYS - 1) .atEndOfDay() .millis() } - deltaDays > (GlobalConstants.ANALYSIS_MAX_RANGE_DAYS - 1) -> { + deltaDays > (DataConstants.ANALYSIS_MAX_RANGE_DAYS - 1) -> { parameters.dateTo = newValue.toLocalDate() - .plusDays(GlobalConstants.ANALYSIS_MAX_RANGE_DAYS - 1) + .plusDays(DataConstants.ANALYSIS_MAX_RANGE_DAYS - 1) .atEndOfDay() .millis() } @@ -72,15 +72,15 @@ class AnalysisParametersPresenter : BasePresenter() { parameters.dateTo = newValue.toLocalDate().atEndOfDay().millis() val deltaDays = ChronoUnit.DAYS.between(parameters.dateFrom.toLocalDate(), parameters.dateTo.toLocalDate()) when { - deltaDays < (GlobalConstants.ANALYSIS_MIN_RANGE_DAYS - 1) -> { + deltaDays < (DataConstants.ANALYSIS_MIN_RANGE_DAYS - 1) -> { parameters.dateFrom = newValue.toLocalDate() - .minusDays(GlobalConstants.ANALYSIS_MIN_RANGE_DAYS - 1) + .minusDays(DataConstants.ANALYSIS_MIN_RANGE_DAYS - 1) .atStartOfDay() .millis() } - deltaDays > (GlobalConstants.ANALYSIS_MAX_RANGE_DAYS - 1) -> { + deltaDays > (DataConstants.ANALYSIS_MAX_RANGE_DAYS - 1) -> { parameters.dateFrom = newValue.toLocalDate() - .minusDays(GlobalConstants.ANALYSIS_MAX_RANGE_DAYS - 1) + .minusDays(DataConstants.ANALYSIS_MAX_RANGE_DAYS - 1) .atStartOfDay() .millis() } diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/parameters/AnalysisParametersView.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/parameters/AnalysisParametersView.kt index 65c52226..5df7add6 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/parameters/AnalysisParametersView.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/parameters/AnalysisParametersView.kt @@ -3,7 +3,7 @@ package ru.rznnike.eyehealthmanager.app.presentation.analysis.parameters import moxy.viewstate.strategy.alias.AddToEndSingle import moxy.viewstate.strategy.alias.OneExecution import ru.rznnike.eyehealthmanager.app.global.presentation.NavigationMvpView -import ru.rznnike.eyehealthmanager.domain.model.AnalysisParameters +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisParameters interface AnalysisParametersView : NavigationMvpView { @AddToEndSingle diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/result/AnalysisResultPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/result/AnalysisResultPresenter.kt index 540c581f..49373dd2 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/result/AnalysisResultPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/result/AnalysisResultPresenter.kt @@ -2,7 +2,7 @@ package ru.rznnike.eyehealthmanager.app.presentation.analysis.result import moxy.InjectViewState import ru.rznnike.eyehealthmanager.app.global.presentation.BasePresenter -import ru.rznnike.eyehealthmanager.domain.model.AnalysisResult +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisResult @InjectViewState class AnalysisResultPresenter( diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/result/AnalysisResultView.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/result/AnalysisResultView.kt index 3bc949c6..bded742f 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/result/AnalysisResultView.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/result/AnalysisResultView.kt @@ -2,7 +2,7 @@ package ru.rznnike.eyehealthmanager.app.presentation.analysis.result import moxy.viewstate.strategy.alias.AddToEndSingle import ru.rznnike.eyehealthmanager.app.global.presentation.NavigationMvpView -import ru.rznnike.eyehealthmanager.domain.model.AnalysisResult +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisResult interface AnalysisResultView : NavigationMvpView { @AddToEndSingle diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/app/AppPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/app/AppPresenter.kt index 489358f5..3bf8b84a 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/app/AppPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/app/AppPresenter.kt @@ -4,7 +4,7 @@ import moxy.InjectViewState import org.koin.core.component.inject import ru.rznnike.eyehealthmanager.app.dispatcher.external.ExternalIntentDispatcher import ru.rznnike.eyehealthmanager.app.global.presentation.BasePresenter -import ru.rznnike.eyehealthmanager.domain.model.Notification +import ru.rznnike.eyehealthmanager.domain.model.notification.Notification @InjectViewState class AppPresenter : BasePresenter() { diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/answer/AstigmatismAnswerPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/answer/AstigmatismAnswerPresenter.kt index 4d184e55..3220f42b 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/answer/AstigmatismAnswerPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/answer/AstigmatismAnswerPresenter.kt @@ -11,8 +11,8 @@ import ru.rznnike.eyehealthmanager.app.dispatcher.notifier.Notifier import ru.rznnike.eyehealthmanager.app.global.presentation.BasePresenter import ru.rznnike.eyehealthmanager.app.global.presentation.ErrorHandler import ru.rznnike.eyehealthmanager.domain.interactor.test.AddTestResultUseCase -import ru.rznnike.eyehealthmanager.domain.model.AstigmatismTestResult -import ru.rznnike.eyehealthmanager.domain.model.enums.AstigmatismAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.astigmatism.AstigmatismTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.astigmatism.AstigmatismAnswerType import java.time.Clock @InjectViewState diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/result/AstigmatismResultPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/result/AstigmatismResultPresenter.kt index e0728c0c..2f7f6772 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/result/AstigmatismResultPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/result/AstigmatismResultPresenter.kt @@ -2,7 +2,7 @@ package ru.rznnike.eyehealthmanager.app.presentation.astigmatism.result import moxy.InjectViewState import ru.rznnike.eyehealthmanager.app.global.presentation.BasePresenter -import ru.rznnike.eyehealthmanager.domain.model.enums.AstigmatismAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.astigmatism.AstigmatismAnswerType @InjectViewState class AstigmatismResultPresenter( diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/result/AstigmatismResultView.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/result/AstigmatismResultView.kt index a889fb95..78c427a8 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/result/AstigmatismResultView.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/result/AstigmatismResultView.kt @@ -2,7 +2,7 @@ package ru.rznnike.eyehealthmanager.app.presentation.astigmatism.result import moxy.viewstate.strategy.alias.AddToEndSingle import ru.rznnike.eyehealthmanager.app.global.presentation.NavigationMvpView -import ru.rznnike.eyehealthmanager.domain.model.enums.AstigmatismAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.astigmatism.AstigmatismAnswerType interface AstigmatismResultView : NavigationMvpView { @AddToEndSingle diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/test/AstigmatismTestPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/test/AstigmatismTestPresenter.kt index 63be91fe..03ea9e52 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/test/AstigmatismTestPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/test/AstigmatismTestPresenter.kt @@ -7,7 +7,7 @@ import org.koin.core.component.inject import ru.rznnike.eyehealthmanager.app.Screens import ru.rznnike.eyehealthmanager.app.global.presentation.BasePresenter import ru.rznnike.eyehealthmanager.domain.interactor.user.GetTestingSettingsUseCase -import ru.rznnike.eyehealthmanager.domain.model.TestingSettings +import ru.rznnike.eyehealthmanager.domain.model.test.TestingSettings @InjectViewState class AstigmatismTestPresenter : BasePresenter() { diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/test/AstigmatismTestView.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/test/AstigmatismTestView.kt index 169d91cf..59569523 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/test/AstigmatismTestView.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/test/AstigmatismTestView.kt @@ -2,7 +2,7 @@ package ru.rznnike.eyehealthmanager.app.presentation.astigmatism.test import moxy.viewstate.strategy.alias.AddToEndSingle import ru.rznnike.eyehealthmanager.app.global.presentation.NavigationMvpView -import ru.rznnike.eyehealthmanager.domain.model.TestingSettings +import ru.rznnike.eyehealthmanager.domain.model.test.TestingSettings interface AstigmatismTestView : NavigationMvpView { @AddToEndSingle diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/colorperception/test/ColorPerceptionTestPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/colorperception/test/ColorPerceptionTestPresenter.kt index 5fade5c3..05c760fa 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/colorperception/test/ColorPerceptionTestPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/colorperception/test/ColorPerceptionTestPresenter.kt @@ -11,8 +11,8 @@ import ru.rznnike.eyehealthmanager.app.dispatcher.notifier.Notifier import ru.rznnike.eyehealthmanager.app.global.presentation.BasePresenter import ru.rznnike.eyehealthmanager.app.global.presentation.ErrorHandler import ru.rznnike.eyehealthmanager.domain.interactor.test.AddTestResultUseCase -import ru.rznnike.eyehealthmanager.domain.model.ColorPerceptionTestData -import ru.rznnike.eyehealthmanager.domain.model.ColorPerceptionTestResult +import ru.rznnike.eyehealthmanager.app.model.test.colorperception.ColorPerceptionTestData +import ru.rznnike.eyehealthmanager.domain.model.test.colorperception.ColorPerceptionTestResult import java.time.Clock @InjectViewState diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/contrast/test/ContrastTestPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/contrast/test/ContrastTestPresenter.kt index 6e913f12..b35e29f8 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/contrast/test/ContrastTestPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/contrast/test/ContrastTestPresenter.kt @@ -11,8 +11,8 @@ import ru.rznnike.eyehealthmanager.app.dispatcher.notifier.Notifier import ru.rznnike.eyehealthmanager.app.global.presentation.BasePresenter import ru.rznnike.eyehealthmanager.app.global.presentation.ErrorHandler import ru.rznnike.eyehealthmanager.domain.interactor.test.AddTestResultUseCase -import ru.rznnike.eyehealthmanager.domain.model.ContrastTestResult -import ru.rznnike.eyehealthmanager.domain.model.enums.Direction +import ru.rznnike.eyehealthmanager.domain.model.test.contrast.ContrastTestResult +import ru.rznnike.eyehealthmanager.domain.model.common.Direction import java.time.Clock import kotlin.random.Random diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/contrast/test/ContrastTestView.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/contrast/test/ContrastTestView.kt index db123a2c..cf4a92ad 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/contrast/test/ContrastTestView.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/contrast/test/ContrastTestView.kt @@ -2,7 +2,7 @@ package ru.rznnike.eyehealthmanager.app.presentation.contrast.test import moxy.viewstate.strategy.alias.AddToEndSingle import ru.rznnike.eyehealthmanager.app.global.presentation.NavigationMvpView -import ru.rznnike.eyehealthmanager.domain.model.enums.Direction +import ru.rznnike.eyehealthmanager.domain.model.common.Direction interface ContrastTestView : NavigationMvpView { @AddToEndSingle diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/daltonism/result/DaltonismResultPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/daltonism/result/DaltonismResultPresenter.kt index 97b58733..ab1a0587 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/daltonism/result/DaltonismResultPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/daltonism/result/DaltonismResultPresenter.kt @@ -2,7 +2,7 @@ package ru.rznnike.eyehealthmanager.app.presentation.daltonism.result import moxy.InjectViewState import ru.rznnike.eyehealthmanager.app.global.presentation.BasePresenter -import ru.rznnike.eyehealthmanager.domain.model.enums.DaltonismAnomalyType +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismAnomalyType @InjectViewState class DaltonismResultPresenter( diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/daltonism/result/DaltonismResultView.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/daltonism/result/DaltonismResultView.kt index 8fdc280b..d17d1dca 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/daltonism/result/DaltonismResultView.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/daltonism/result/DaltonismResultView.kt @@ -2,7 +2,7 @@ package ru.rznnike.eyehealthmanager.app.presentation.daltonism.result import moxy.viewstate.strategy.alias.AddToEndSingle import ru.rznnike.eyehealthmanager.app.global.presentation.NavigationMvpView -import ru.rznnike.eyehealthmanager.domain.model.enums.DaltonismAnomalyType +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismAnomalyType interface DaltonismResultView : NavigationMvpView { @AddToEndSingle diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/daltonism/test/DaltonismTestPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/daltonism/test/DaltonismTestPresenter.kt index 7c76ba7a..c792fe63 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/daltonism/test/DaltonismTestPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/daltonism/test/DaltonismTestPresenter.kt @@ -11,9 +11,9 @@ import ru.rznnike.eyehealthmanager.app.dispatcher.notifier.Notifier import ru.rznnike.eyehealthmanager.app.global.presentation.BasePresenter import ru.rznnike.eyehealthmanager.app.global.presentation.ErrorHandler import ru.rznnike.eyehealthmanager.domain.interactor.test.AddTestResultUseCase -import ru.rznnike.eyehealthmanager.domain.model.DaltonismTestData -import ru.rznnike.eyehealthmanager.domain.model.DaltonismTestResult -import ru.rznnike.eyehealthmanager.domain.model.enums.DaltonismAnomalyType +import ru.rznnike.eyehealthmanager.app.model.test.daltonism.DaltonismTestData +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismAnomalyType import java.time.Clock private const val NORMAL_BORDER = 2 @@ -66,7 +66,8 @@ class DaltonismTestPresenter : BasePresenter() { viewState.setProgress(true) DaltonismTestData.questions.forEachIndexed { index, question -> if (userAnswers[index] > 0) { - answerDeltas[DaltonismAnomalyType.NONE] = answerDeltas.getOrDefault(DaltonismAnomalyType.NONE, 0) + 1 + answerDeltas[DaltonismAnomalyType.NONE] = answerDeltas.getOrDefault( + DaltonismAnomalyType.NONE, 0) + 1 } question.answerVariantsMap.forEach { (type, variants) -> if (!variants.contains(userAnswers[index])) { diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/journal/backup/ExportJournalPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/journal/backup/ExportJournalPresenter.kt index e9ae0911..e40a4e93 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/journal/backup/ExportJournalPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/journal/backup/ExportJournalPresenter.kt @@ -15,10 +15,11 @@ import ru.rznnike.eyehealthmanager.app.dispatcher.event.EventDispatcher import ru.rznnike.eyehealthmanager.app.dispatcher.notifier.Notifier import ru.rznnike.eyehealthmanager.app.global.presentation.BasePresenter import ru.rznnike.eyehealthmanager.app.global.presentation.ErrorHandler +import ru.rznnike.eyehealthmanager.app.utils.JournalBackupManagerAndroid +import ru.rznnike.eyehealthmanager.data.utils.DataConstants import ru.rznnike.eyehealthmanager.domain.interactor.test.ExportJournalUseCase -import ru.rznnike.eyehealthmanager.domain.model.TestResultFilter -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType -import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultFilter +import ru.rznnike.eyehealthmanager.domain.model.test.TestType import ru.rznnike.eyehealthmanager.domain.utils.atEndOfDay import ru.rznnike.eyehealthmanager.domain.utils.millis import ru.rznnike.eyehealthmanager.domain.utils.toLocalDate @@ -31,6 +32,7 @@ class ExportJournalPresenter : BasePresenter() { private val notifier: Notifier by inject() private val eventDispatcher: EventDispatcher by inject() private val context: Context by inject() + private val journalBackupManager: JournalBackupManagerAndroid by inject() private val exportJournalUseCase: ExportJournalUseCase by inject() private lateinit var filter: TestResultFilter @@ -90,7 +92,7 @@ class ExportJournalPresenter : BasePresenter() { private fun populateData() { val savedUri = getSavedExportFolder() val folderPath = savedUri?.let { - "${savedUri.lastPathSegment}/${GlobalConstants.APP_DIR}/${GlobalConstants.EXPORT_DIR}" + "${savedUri.lastPathSegment}/${DataConstants.APP_DIR}/${DataConstants.EXPORT_DIR}" } viewState.populateData(filter, folderPath) } @@ -116,17 +118,23 @@ class ExportJournalPresenter : BasePresenter() { fun startExport() { getSavedExportFolder()?.let { - exportDatabase() + exportDatabase(context) } ?: run { startExportAutomatically = true viewState.selectExportFolder() } } - private fun exportDatabase() { + private fun exportDatabase(context: Context) { presenterScope.launch { viewState.setProgress(true) - exportJournalUseCase(filter).process( + journalBackupManager.context = context + exportJournalUseCase( + ExportJournalUseCase.Parameters( + filter = filter, + manager = journalBackupManager + ) + ).process( { result -> result.exportFolderUri?.let { eventDispatcher.sendEvent( @@ -140,6 +148,7 @@ class ExportJournalPresenter : BasePresenter() { } } ) + journalBackupManager.context = null viewState.setProgress(false) } } @@ -149,8 +158,8 @@ class ExportJournalPresenter : BasePresenter() { getSavedExportFolder()?.let { uri -> DocumentFile.fromTreeUri(context, uri) - ?.findOrCreateDocumentFolder(GlobalConstants.APP_DIR) - ?.findOrCreateDocumentFolder(GlobalConstants.EXPORT_DIR) + ?.findOrCreateDocumentFolder(DataConstants.APP_DIR) + ?.findOrCreateDocumentFolder(DataConstants.EXPORT_DIR) ?.let { exportFolder -> viewState.routerStartFlow(Screens.Common.actionOpenFolder(exportFolder.uri)) } diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/journal/backup/ExportJournalView.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/journal/backup/ExportJournalView.kt index 172f13ad..36201f02 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/journal/backup/ExportJournalView.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/journal/backup/ExportJournalView.kt @@ -3,7 +3,7 @@ package ru.rznnike.eyehealthmanager.app.presentation.journal.backup import moxy.viewstate.strategy.alias.AddToEndSingle import moxy.viewstate.strategy.alias.OneExecution import ru.rznnike.eyehealthmanager.app.global.presentation.NavigationMvpView -import ru.rznnike.eyehealthmanager.domain.model.TestResultFilter +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultFilter interface ExportJournalView : NavigationMvpView { @AddToEndSingle diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/journal/restore/ImportJournalPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/journal/restore/ImportJournalPresenter.kt index 68f292bb..c9eb393a 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/journal/restore/ImportJournalPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/journal/restore/ImportJournalPresenter.kt @@ -1,7 +1,9 @@ package ru.rznnike.eyehealthmanager.app.presentation.journal.restore +import android.content.Context import android.net.Uri import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext import moxy.InjectViewState import moxy.presenterScope import org.koin.core.component.inject @@ -12,16 +14,18 @@ import ru.rznnike.eyehealthmanager.app.dispatcher.event.EventDispatcher import ru.rznnike.eyehealthmanager.app.dispatcher.notifier.Notifier import ru.rznnike.eyehealthmanager.app.global.presentation.BasePresenter import ru.rznnike.eyehealthmanager.app.global.presentation.ErrorHandler -import ru.rznnike.eyehealthmanager.domain.interactor.test.GetAvailableImportTypesUseCase +import ru.rznnike.eyehealthmanager.app.utils.JournalBackupManagerAndroid +import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider import ru.rznnike.eyehealthmanager.domain.interactor.test.ImportJournalUseCase -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType +import ru.rznnike.eyehealthmanager.domain.model.test.TestType @InjectViewState class ImportJournalPresenter : BasePresenter() { private val errorHandler: ErrorHandler by inject() private val notifier: Notifier by inject() private val eventDispatcher: EventDispatcher by inject() - private val getAvailableImportTypesUseCase: GetAvailableImportTypesUseCase by inject() + private val dispatcherProvider: DispatcherProvider by inject() + private val journalBackupManager: JournalBackupManagerAndroid by inject() private val importJournalUseCase: ImportJournalUseCase by inject() private var importFolderUri: Uri? = null @@ -37,26 +41,26 @@ class ImportJournalPresenter : BasePresenter() { folderPath = importFolderUri?.lastPathSegment ) - fun onFolderSelected(uri: Uri) { + fun onFolderSelected(uri: Uri, context: Context) { presenterScope.launch { importFolderUri = uri viewState.setProgress(true) - getAvailableImportTypesUseCase(uri).process( - { result -> - availableImportTypes = result - populateData() - if (startImportAutomatically) { - startImportAutomatically = false - importFiles() - } - }, ::onError - ) + withContext(dispatcherProvider.io) { + journalBackupManager.context = context + availableImportTypes = journalBackupManager.getAvailableImportTypes(uri) + journalBackupManager.context = null + } + populateData() + if (startImportAutomatically) { + startImportAutomatically = false + importFiles(context) + } viewState.setProgress(false) } } - fun importFiles() { + fun importFiles(context: Context) { presenterScope.launch { when { importFolderUri == null -> { @@ -69,12 +73,19 @@ class ImportJournalPresenter : BasePresenter() { else -> { viewState.setProgress(true) importFolderUri?.let { importFolderUri -> - importJournalUseCase(importFolderUri).process( + journalBackupManager.context = context + importJournalUseCase( + ImportJournalUseCase.Parameters( + importFolderUri = importFolderUri, + manager = journalBackupManager + ) + ).process( { eventDispatcher.sendEvent(AppEvent.JournalImported(importFolderUri)) viewState.routerExit() }, ::onError ) + journalBackupManager.context = null } viewState.setProgress(false) } diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/journal/restore/ImportJournalView.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/journal/restore/ImportJournalView.kt index b7fe074b..36578ab4 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/journal/restore/ImportJournalView.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/journal/restore/ImportJournalView.kt @@ -3,7 +3,7 @@ package ru.rznnike.eyehealthmanager.app.presentation.journal.restore import moxy.viewstate.strategy.alias.AddToEndSingle import moxy.viewstate.strategy.alias.OneExecution import ru.rznnike.eyehealthmanager.app.global.presentation.NavigationMvpView -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType +import ru.rznnike.eyehealthmanager.domain.model.test.TestType interface ImportJournalView : NavigationMvpView { @AddToEndSingle diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/MainPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/MainPresenter.kt index f56d923f..13d1e66b 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/MainPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/MainPresenter.kt @@ -11,7 +11,7 @@ import ru.rznnike.eyehealthmanager.app.dispatcher.event.EventDispatcher import ru.rznnike.eyehealthmanager.app.dispatcher.notifier.Notifier import ru.rznnike.eyehealthmanager.app.global.presentation.BasePresenter import ru.rznnike.eyehealthmanager.app.global.presentation.ErrorHandler -import ru.rznnike.eyehealthmanager.domain.global.CoroutineProvider +import ru.rznnike.eyehealthmanager.domain.global.CoroutineScopeProvider import ru.rznnike.eyehealthmanager.domain.interactor.test.DeleteAllTestResultsUseCase import ru.rznnike.eyehealthmanager.domain.interactor.test.DeleteDuplicatesUseCase import ru.rznnike.eyehealthmanager.domain.interactor.user.GetDisplayedChangelogVersionUseCase @@ -24,7 +24,7 @@ class MainPresenter : BasePresenter(), EventDispatcher.EventListener { private val eventDispatcher: EventDispatcher by inject() private val notifier: Notifier by inject() private val errorHandler: ErrorHandler by inject() - private val coroutineProvider: CoroutineProvider by inject() + private val coroutineScopeProvider: CoroutineScopeProvider by inject() private val getWelcomeDialogShowedUseCase: GetWelcomeDialogShowedUseCase by inject() private val setWelcomeDialogShowedUseCase: SetWelcomeDialogShowedUseCase by inject() private val getDisplayedChangelogVersionUseCase: GetDisplayedChangelogVersionUseCase by inject() @@ -67,7 +67,7 @@ class MainPresenter : BasePresenter(), EventDispatcher.EventListener { private fun checkWelcomeDialog() { presenterScope.launch { - val showed = getWelcomeDialogShowedUseCase().data ?: false + val showed = getWelcomeDialogShowedUseCase().data == true if (!showed) { viewState.showWelcomeDialog() setWelcomeDialogShowedUseCase(true) @@ -89,7 +89,7 @@ class MainPresenter : BasePresenter(), EventDispatcher.EventListener { } fun deleteDuplicatesInJournal() { - coroutineProvider.scopeIo.launch { + coroutineScopeProvider.io.launch { viewState.setProgress(true) deleteDuplicatesUseCase().process( { @@ -102,7 +102,7 @@ class MainPresenter : BasePresenter(), EventDispatcher.EventListener { } private fun deleteJournal() { - coroutineProvider.scopeIo.launch { + coroutineScopeProvider.io.launch { viewState.setProgress(true) deleteAllTestResultsUseCase().process( { diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/journal/JournalPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/journal/JournalPresenter.kt index f8279d96..5e877594 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/journal/JournalPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/journal/JournalPresenter.kt @@ -14,15 +14,15 @@ import ru.rznnike.eyehealthmanager.app.global.presentation.ErrorHandler import ru.rznnike.eyehealthmanager.app.pagination.Paginator import ru.rznnike.eyehealthmanager.domain.interactor.test.DeleteTestResultUseCase import ru.rznnike.eyehealthmanager.domain.interactor.test.GetTestResultsUseCase -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestResult -import ru.rznnike.eyehealthmanager.domain.model.AstigmatismTestResult -import ru.rznnike.eyehealthmanager.domain.model.ColorPerceptionTestResult -import ru.rznnike.eyehealthmanager.domain.model.ContrastTestResult -import ru.rznnike.eyehealthmanager.domain.model.DaltonismTestResult -import ru.rznnike.eyehealthmanager.domain.model.NearFarTestResult -import ru.rznnike.eyehealthmanager.domain.model.TestResult -import ru.rznnike.eyehealthmanager.domain.model.TestResultFilter -import ru.rznnike.eyehealthmanager.domain.model.TestResultPagingParameters +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.astigmatism.AstigmatismTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.colorperception.ColorPerceptionTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.contrast.ContrastTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultFilter +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultPagingParameters import ru.rznnike.eyehealthmanager.domain.utils.atEndOfDay import ru.rznnike.eyehealthmanager.domain.utils.millis import ru.rznnike.eyehealthmanager.domain.utils.toLocalDate diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/journal/JournalView.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/journal/JournalView.kt index 4fdecd98..adfc6ed6 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/journal/JournalView.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/journal/JournalView.kt @@ -2,8 +2,8 @@ package ru.rznnike.eyehealthmanager.app.presentation.main.journal import moxy.viewstate.strategy.alias.AddToEndSingle import ru.rznnike.eyehealthmanager.app.global.presentation.PagerView -import ru.rznnike.eyehealthmanager.domain.model.TestResult -import ru.rznnike.eyehealthmanager.domain.model.TestResultFilter +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultFilter interface JournalView : PagerView { @AddToEndSingle diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/settings/SettingsPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/settings/SettingsPresenter.kt index ff56f21a..24235f6f 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/settings/SettingsPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/settings/SettingsPresenter.kt @@ -16,9 +16,9 @@ import ru.rznnike.eyehealthmanager.app.utils.extensions.setSelectedLanguage import ru.rznnike.eyehealthmanager.domain.interactor.dev.GenerateDataUseCase import ru.rznnike.eyehealthmanager.domain.interactor.user.GetAppThemeUseCase import ru.rznnike.eyehealthmanager.domain.interactor.user.SetAppThemeUseCase -import ru.rznnike.eyehealthmanager.domain.model.enums.AppTheme -import ru.rznnike.eyehealthmanager.domain.model.enums.DataGenerationType -import ru.rznnike.eyehealthmanager.domain.model.enums.Language +import ru.rznnike.eyehealthmanager.domain.model.common.AppTheme +import ru.rznnike.eyehealthmanager.domain.model.common.DataGenerationType +import ru.rznnike.eyehealthmanager.domain.model.common.Language @InjectViewState class SettingsPresenter : BasePresenter() { diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/settings/SettingsView.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/settings/SettingsView.kt index 9060d670..2bbf5150 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/settings/SettingsView.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/settings/SettingsView.kt @@ -1,10 +1,9 @@ package ru.rznnike.eyehealthmanager.app.presentation.main.settings import moxy.viewstate.strategy.alias.AddToEndSingle -import moxy.viewstate.strategy.alias.OneExecution import ru.rznnike.eyehealthmanager.app.global.presentation.NavigationMvpView -import ru.rznnike.eyehealthmanager.domain.model.enums.AppTheme -import ru.rznnike.eyehealthmanager.domain.model.enums.Language +import ru.rznnike.eyehealthmanager.domain.model.common.AppTheme +import ru.rznnike.eyehealthmanager.domain.model.common.Language interface SettingsView : NavigationMvpView { @AddToEndSingle diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/tests/TestsPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/tests/TestsPresenter.kt index 42a638c2..3ff2c152 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/tests/TestsPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/main/tests/TestsPresenter.kt @@ -3,7 +3,7 @@ package ru.rznnike.eyehealthmanager.app.presentation.main.tests import moxy.InjectViewState import ru.rznnike.eyehealthmanager.app.Screens import ru.rznnike.eyehealthmanager.app.global.presentation.BasePresenter -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType +import ru.rznnike.eyehealthmanager.domain.model.test.TestType @InjectViewState class TestsPresenter : BasePresenter() { diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/nearfar/answer/NearFarAnswerPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/nearfar/answer/NearFarAnswerPresenter.kt index 18ec5e09..13bd7338 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/nearfar/answer/NearFarAnswerPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/nearfar/answer/NearFarAnswerPresenter.kt @@ -11,8 +11,8 @@ import ru.rznnike.eyehealthmanager.app.dispatcher.notifier.Notifier import ru.rznnike.eyehealthmanager.app.global.presentation.BasePresenter import ru.rznnike.eyehealthmanager.app.global.presentation.ErrorHandler import ru.rznnike.eyehealthmanager.domain.interactor.test.AddTestResultUseCase -import ru.rznnike.eyehealthmanager.domain.model.NearFarTestResult -import ru.rznnike.eyehealthmanager.domain.model.enums.NearFarAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarAnswerType import java.time.Clock @InjectViewState diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/nearfar/result/NearFarResultPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/nearfar/result/NearFarResultPresenter.kt index 83c598fa..eac3b945 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/nearfar/result/NearFarResultPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/nearfar/result/NearFarResultPresenter.kt @@ -2,7 +2,7 @@ package ru.rznnike.eyehealthmanager.app.presentation.nearfar.result import moxy.InjectViewState import ru.rznnike.eyehealthmanager.app.global.presentation.BasePresenter -import ru.rznnike.eyehealthmanager.domain.model.enums.NearFarAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarAnswerType @InjectViewState class NearFarResultPresenter( diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/nearfar/result/NearFarResultView.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/nearfar/result/NearFarResultView.kt index 20b634fb..46bbf0f1 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/nearfar/result/NearFarResultView.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/nearfar/result/NearFarResultView.kt @@ -2,7 +2,7 @@ package ru.rznnike.eyehealthmanager.app.presentation.nearfar.result import moxy.viewstate.strategy.alias.AddToEndSingle import ru.rznnike.eyehealthmanager.app.global.presentation.NavigationMvpView -import ru.rznnike.eyehealthmanager.domain.model.enums.NearFarAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarAnswerType interface NearFarResultView : NavigationMvpView { @AddToEndSingle diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/settings/testing/TestingSettingsPresenter.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/settings/testing/TestingSettingsPresenter.kt index 10894f25..a800df00 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/settings/testing/TestingSettingsPresenter.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/settings/testing/TestingSettingsPresenter.kt @@ -9,18 +9,18 @@ import ru.rznnike.eyehealthmanager.app.dispatcher.event.EventDispatcher import ru.rznnike.eyehealthmanager.app.dispatcher.notifier.Notifier import ru.rznnike.eyehealthmanager.app.global.presentation.BasePresenter import ru.rznnike.eyehealthmanager.app.global.presentation.ErrorHandler -import ru.rznnike.eyehealthmanager.domain.global.CoroutineProvider +import ru.rznnike.eyehealthmanager.data.utils.DataConstants +import ru.rznnike.eyehealthmanager.domain.global.CoroutineScopeProvider import ru.rznnike.eyehealthmanager.domain.interactor.user.GetTestingSettingsUseCase import ru.rznnike.eyehealthmanager.domain.interactor.user.SetTestingSettingsUseCase -import ru.rznnike.eyehealthmanager.domain.model.TestingSettings -import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants +import ru.rznnike.eyehealthmanager.domain.model.test.TestingSettings import ru.rznnike.eyehealthmanager.domain.utils.getDayTime @InjectViewState class TestingSettingsPresenter : BasePresenter() { private val errorHandler: ErrorHandler by inject() private val notifier: Notifier by inject() - private val coroutineProvider: CoroutineProvider by inject() + private val coroutineScopeProvider: CoroutineScopeProvider by inject() private val eventDispatcher: EventDispatcher by inject() private val getTestingSettingsUseCase: GetTestingSettingsUseCase by inject() private val setTestingSettingsUseCase: SetTestingSettingsUseCase by inject() @@ -32,7 +32,7 @@ class TestingSettingsPresenter : BasePresenter() { } fun onPause() { - coroutineProvider.scopeIo.launch { + coroutineScopeProvider.io.launch { setTestingSettingsUseCase(settings).process( { eventDispatcher.sendEvent(AppEvent.TestingSettingsChanged) @@ -102,12 +102,12 @@ class TestingSettingsPresenter : BasePresenter() { val middle = if (settings.timeToDayMiddle >= settings.timeToDayBeginning) { settings.timeToDayMiddle } else { - settings.timeToDayMiddle + GlobalConstants.DAY_MS + settings.timeToDayMiddle + DataConstants.DAY_MS } val end = if (settings.timeToDayEnd >= settings.timeToDayBeginning) { settings.timeToDayEnd } else { - settings.timeToDayEnd + GlobalConstants.DAY_MS + settings.timeToDayEnd + DataConstants.DAY_MS } return (middle > settings.timeToDayBeginning) && (end > middle) @@ -116,21 +116,21 @@ class TestingSettingsPresenter : BasePresenter() { if (!isTimeOrderCorrect(settings)) { when (period) { TimePeriod.BEGINNING -> { - settings.timeToDayBeginning = settings.timeToDayEnd + GlobalConstants.MINUTE_MS - if (settings.timeToDayBeginning >= GlobalConstants.DAY_MS) { - settings.timeToDayBeginning -= GlobalConstants.DAY_MS + settings.timeToDayBeginning = settings.timeToDayEnd + DataConstants.MINUTE_MS + if (settings.timeToDayBeginning >= DataConstants.DAY_MS) { + settings.timeToDayBeginning -= DataConstants.DAY_MS } } TimePeriod.MIDDLE -> { - settings.timeToDayMiddle = settings.timeToDayBeginning + GlobalConstants.MINUTE_MS - if (settings.timeToDayMiddle >= GlobalConstants.DAY_MS) { - settings.timeToDayMiddle -= GlobalConstants.DAY_MS + settings.timeToDayMiddle = settings.timeToDayBeginning + DataConstants.MINUTE_MS + if (settings.timeToDayMiddle >= DataConstants.DAY_MS) { + settings.timeToDayMiddle -= DataConstants.DAY_MS } } TimePeriod.END -> { - settings.timeToDayEnd = settings.timeToDayMiddle + GlobalConstants.MINUTE_MS - if (settings.timeToDayEnd >= GlobalConstants.DAY_MS) { - settings.timeToDayEnd -= GlobalConstants.DAY_MS + settings.timeToDayEnd = settings.timeToDayMiddle + DataConstants.MINUTE_MS + if (settings.timeToDayEnd >= DataConstants.DAY_MS) { + settings.timeToDayEnd -= DataConstants.DAY_MS } } } diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/settings/testing/TestingSettingsView.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/settings/testing/TestingSettingsView.kt index 3e592642..7e83e94e 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/settings/testing/TestingSettingsView.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/presentation/settings/testing/TestingSettingsView.kt @@ -2,7 +2,7 @@ package ru.rznnike.eyehealthmanager.app.presentation.settings.testing import moxy.viewstate.strategy.alias.AddToEndSingle import ru.rznnike.eyehealthmanager.app.global.presentation.NavigationMvpView -import ru.rznnike.eyehealthmanager.domain.model.TestingSettings +import ru.rznnike.eyehealthmanager.domain.model.test.TestingSettings interface TestingSettingsView : NavigationMvpView { @AddToEndSingle diff --git a/device/src/main/java/ru/rznnike/eyehealthmanager/device/service/AppFirebaseMessagingService.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/service/AppFirebaseMessagingService.kt similarity index 72% rename from device/src/main/java/ru/rznnike/eyehealthmanager/device/service/AppFirebaseMessagingService.kt rename to app/src/main/java/ru/rznnike/eyehealthmanager/app/service/AppFirebaseMessagingService.kt index 7130bb38..4b940b76 100644 --- a/device/src/main/java/ru/rznnike/eyehealthmanager/device/service/AppFirebaseMessagingService.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/service/AppFirebaseMessagingService.kt @@ -1,21 +1,21 @@ -package ru.rznnike.eyehealthmanager.device.service +package ru.rznnike.eyehealthmanager.app.service import com.google.firebase.messaging.FirebaseMessagingService import com.google.firebase.messaging.RemoteMessage import kotlinx.coroutines.launch -import ru.rznnike.eyehealthmanager.domain.global.CoroutineProvider +import ru.rznnike.eyehealthmanager.domain.global.CoroutineScopeProvider import org.koin.android.ext.android.inject import ru.rznnike.eyehealthmanager.domain.interactor.notification.EmitShowNotificationUseCase -import ru.rznnike.eyehealthmanager.domain.model.toNotification +import ru.rznnike.eyehealthmanager.domain.model.notification.toNotification class AppFirebaseMessagingService : FirebaseMessagingService() { - private val coroutineProvider: CoroutineProvider by inject() + private val coroutineScopeProvider: CoroutineScopeProvider by inject() private val emitShowNotificationUseCase: EmitShowNotificationUseCase by inject() override fun onNewToken(token: String) = Unit override fun onMessageReceived(remoteMessage: RemoteMessage) { - coroutineProvider.scopeIo.launch { + coroutineScopeProvider.io.launch { val notification = remoteMessage.data.toNotification( title = remoteMessage.notification?.title, message = remoteMessage.notification?.body diff --git a/device/src/main/java/ru/rznnike/eyehealthmanager/device/service/NotificationService.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/service/NotificationService.kt similarity index 81% rename from device/src/main/java/ru/rznnike/eyehealthmanager/device/service/NotificationService.kt rename to app/src/main/java/ru/rznnike/eyehealthmanager/app/service/NotificationService.kt index caf56c72..b9267289 100644 --- a/device/src/main/java/ru/rznnike/eyehealthmanager/device/service/NotificationService.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/service/NotificationService.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.device.service +package ru.rznnike.eyehealthmanager.app.service import android.app.job.JobInfo import android.app.job.JobParameters @@ -11,16 +11,15 @@ import kotlinx.coroutines.Job import kotlinx.coroutines.flow.cancellable import kotlinx.coroutines.launch import org.koin.android.ext.android.inject -import ru.rznnike.eyehealthmanager.device.notification.Notificator -import ru.rznnike.eyehealthmanager.domain.global.CoroutineProvider +import ru.rznnike.eyehealthmanager.domain.global.CoroutineScopeProvider import ru.rznnike.eyehealthmanager.domain.interactor.notification.ObserveCancelNotificationUseCase import ru.rznnike.eyehealthmanager.domain.interactor.notification.ObserveShowNotificationUseCase class NotificationService : JobService() { - private val coroutineProvider: CoroutineProvider by inject() + private val coroutineScopeProvider: CoroutineScopeProvider by inject() private val observeShowNotificationUseCase: ObserveShowNotificationUseCase by inject() private val observeCancelNotificationUseCase: ObserveCancelNotificationUseCase by inject() - private val notificator: Notificator by inject() + private val notificator: ru.rznnike.eyehealthmanager.app.notification.Notificator by inject() private var notificationShowJob: Job? = null private var notificationCancelJob: Job? = null @@ -49,7 +48,7 @@ class NotificationService : JobService() { private fun observeShowNotification() { if (notificationShowJob?.isActive == true) return - notificationShowJob = coroutineProvider.scopeMain.launch { + notificationShowJob = coroutineScopeProvider.ui.launch { observeShowNotificationUseCase().cancellable().collect { notification -> if (!notification.showed) { notificator.show(notification) @@ -62,7 +61,7 @@ class NotificationService : JobService() { private fun observeCancelNotification() { if (notificationCancelJob?.isActive == true) return - notificationCancelJob = coroutineProvider.scopeMain.launch { + notificationCancelJob = coroutineScopeProvider.ui.launch { observeCancelNotificationUseCase().collect { notification -> notificator.cancel(notification) } @@ -87,12 +86,12 @@ class NotificationService : JobService() { val jobInfo = JobInfo.Builder(JOB_ID, serviceName) .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) .build() - val scheduler = context.getSystemService(Context.JOB_SCHEDULER_SERVICE) as JobScheduler + val scheduler = context.getSystemService(JOB_SCHEDULER_SERVICE) as JobScheduler scheduler.schedule(jobInfo) } fun stopAsJob(ctx: Context) { - val scheduler = ctx.getSystemService(Context.JOB_SCHEDULER_SERVICE) as JobScheduler + val scheduler = ctx.getSystemService(JOB_SCHEDULER_SERVICE) as JobScheduler scheduler.cancel(JOB_ID) } } diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/activity/AppActivity.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/activity/AppActivity.kt index b5b285a4..d030dc75 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/activity/AppActivity.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/activity/AppActivity.kt @@ -13,6 +13,7 @@ import by.kirich1409.viewbindingdelegate.viewBinding import com.github.terrakok.cicerone.Navigator import com.github.terrakok.cicerone.NavigatorHolder import com.google.android.material.snackbar.Snackbar +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import moxy.presenter.InjectPresenter import org.koin.android.ext.android.inject @@ -38,10 +39,10 @@ import ru.rznnike.eyehealthmanager.app.utils.extensions.setVisible import ru.rznnike.eyehealthmanager.databinding.ActivityBinding import ru.rznnike.eyehealthmanager.databinding.ViewSnackbarBottomBinding import ru.rznnike.eyehealthmanager.databinding.ViewSnackbarTopBinding -import ru.rznnike.eyehealthmanager.device.notification.Notificator -import ru.rznnike.eyehealthmanager.domain.global.CoroutineProvider -import ru.rznnike.eyehealthmanager.domain.model.Notification -import ru.rznnike.eyehealthmanager.domain.model.toNotification +import ru.rznnike.eyehealthmanager.app.notification.Notificator +import ru.rznnike.eyehealthmanager.domain.global.CoroutineScopeProvider +import ru.rznnike.eyehealthmanager.domain.model.notification.Notification +import ru.rznnike.eyehealthmanager.domain.model.notification.toNotification private const val TOP_BAR_TIME_MS = 10_000 @@ -53,12 +54,12 @@ class AppActivity : BaseActivity(R.layout.activity), AppView { private val navigatorHolder: NavigatorHolder by inject() private val notifier: Notifier by inject() - private val coroutineProvider: CoroutineProvider by inject() + private val coroutineScopeProvider: CoroutineScopeProvider by inject() private val router: AppRouter by inject() private val navigator: Navigator = object : SupportAppNavigation(this, notifier, R.id.container) {} - private var subscribedToNotifications = false + private var notificationsJob: Job? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -80,11 +81,9 @@ class AppActivity : BaseActivity(R.layout.activity), AppView { ?.associate { it to (intent.getStringExtra(it) ?: "") } ?.toNotification() - override fun onNewIntent(intent: Intent?) { + override fun onNewIntent(intent: Intent) { super.onNewIntent(intent) - intent?.let { - presenter.processNotificationIntent(getNotificationFromIntent(intent)) - } + presenter.processNotificationIntent(getNotificationFromIntent(intent)) } override fun onPause() { @@ -94,7 +93,15 @@ class AppActivity : BaseActivity(R.layout.activity), AppView { override fun onStart() { super.onStart() - subscribeOnSystemMessages() + notificationsJob?.cancel() + notificationsJob = coroutineScopeProvider.ui.launch { + notifier.subscribe().collect(::onNextMessageNotify) + } + } + + override fun onStop() { + notificationsJob?.cancel() + super.onStop() } override fun onResumeFragments() { @@ -115,15 +122,6 @@ class AppActivity : BaseActivity(R.layout.activity), AppView { return true } - private fun subscribeOnSystemMessages() { - if (subscribedToNotifications) return - - subscribedToNotifications = true - coroutineProvider.scopeMainImmediate.launch { - notifier.subscribe().collect(::onNextMessageNotify) - } - } - private fun initWindowFlags() { WindowCompat.setDecorFitsSystemWindows(window, false) } diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/acuity/info/AcuityInfoFragment.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/acuity/info/AcuityInfoFragment.kt index 5ba4ce7e..1aee9e6c 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/acuity/info/AcuityInfoFragment.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/acuity/info/AcuityInfoFragment.kt @@ -21,10 +21,10 @@ import ru.rznnike.eyehealthmanager.app.utils.extensions.addSystemWindowInsetToPa import ru.rznnike.eyehealthmanager.app.utils.extensions.createFastAdapter import ru.rznnike.eyehealthmanager.databinding.DialogDayPartSelectionBinding import ru.rznnike.eyehealthmanager.databinding.FragmentAcuityInfoBinding -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestingSettings -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuityTestSymbolsType -import ru.rznnike.eyehealthmanager.domain.model.enums.DayPart -import ru.rznnike.eyehealthmanager.domain.model.enums.TestEyesType +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestingSettings +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestSymbolsType +import ru.rznnike.eyehealthmanager.domain.model.common.DayPart +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType class AcuityInfoFragment : BaseFragment(R.layout.fragment_acuity_info), AcuityInfoView { @InjectPresenter diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/acuity/result/AcuityResultFragment.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/acuity/result/AcuityResultFragment.kt index 8fd88bd7..8b1011f0 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/acuity/result/AcuityResultFragment.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/acuity/result/AcuityResultFragment.kt @@ -11,11 +11,11 @@ import ru.rznnike.eyehealthmanager.app.presentation.acuity.result.AcuityResultPr import ru.rznnike.eyehealthmanager.app.presentation.acuity.result.AcuityResultView import ru.rznnike.eyehealthmanager.app.utils.extensions.* import ru.rznnike.eyehealthmanager.databinding.FragmentAcuityResultBinding -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestResult -import ru.rznnike.eyehealthmanager.domain.model.AnalysisResult -import ru.rznnike.eyehealthmanager.domain.model.SingleEyeAnalysisResult -import ru.rznnike.eyehealthmanager.domain.model.enums.DayPart -import ru.rznnike.eyehealthmanager.domain.model.enums.TestEyesType +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestResult +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisResult +import ru.rznnike.eyehealthmanager.domain.model.analysis.SingleEyeAnalysisResult +import ru.rznnike.eyehealthmanager.domain.model.common.DayPart +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType class AcuityResultFragment : BaseFragment(R.layout.fragment_acuity_result), AcuityResultView { @InjectPresenter @@ -112,7 +112,7 @@ class AcuityResultFragment : BaseFragment(R.layout.fragment_acuity_result), Acui layoutNoiseProcessing.setVisible(analysisResult?.lastResultRecognizedAsNoise == true) checkBoxApplyDynamicCorrections.isChecked = applyDynamicCorrections - textViewMessage.setVisible(analysisResult?.showWarningAboutVision ?: false) + textViewMessage.setVisible(analysisResult?.showWarningAboutVision == true) } } diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/acuity/test/AcuityTestFragment.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/acuity/test/AcuityTestFragment.kt index e343b8ae..1cfe5c95 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/acuity/test/AcuityTestFragment.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/acuity/test/AcuityTestFragment.kt @@ -18,6 +18,10 @@ import ru.rznnike.eyehealthmanager.app.dialog.alert.AlertDialogAction import ru.rznnike.eyehealthmanager.app.dialog.alert.AlertDialogParameters import ru.rznnike.eyehealthmanager.app.dialog.showAlertDialog import ru.rznnike.eyehealthmanager.app.global.ui.fragment.BaseFragment +import ru.rznnike.eyehealthmanager.app.model.test.acuity.AcuitySymbolLetterEn +import ru.rznnike.eyehealthmanager.app.model.test.acuity.AcuitySymbolLetterRu +import ru.rznnike.eyehealthmanager.app.model.test.acuity.AcuitySymbolSquare +import ru.rznnike.eyehealthmanager.app.model.test.acuity.AcuitySymbolTriangle import ru.rznnike.eyehealthmanager.app.presentation.acuity.test.AcuityTestPresenter import ru.rznnike.eyehealthmanager.app.presentation.acuity.test.AcuityTestView import ru.rznnike.eyehealthmanager.app.ui.item.CantAnswerItem @@ -32,14 +36,10 @@ import ru.rznnike.eyehealthmanager.app.utils.extensions.setGone import ru.rznnike.eyehealthmanager.app.utils.extensions.setVisible import ru.rznnike.eyehealthmanager.app.utils.extensions.withDelay import ru.rznnike.eyehealthmanager.databinding.FragmentAcuityTestBinding -import ru.rznnike.eyehealthmanager.domain.model.EmptyAcuitySymbol -import ru.rznnike.eyehealthmanager.domain.model.IAcuitySymbol -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuitySymbolLetterEn -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuitySymbolLetterRu -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuitySymbolSquare -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuitySymbolTriangle -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuityTestSymbolsType -import ru.rznnike.eyehealthmanager.domain.model.enums.TestEyesType +import ru.rznnike.eyehealthmanager.app.model.test.acuity.EmptyAcuitySymbol +import ru.rznnike.eyehealthmanager.app.model.test.acuity.IAcuitySymbol +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestSymbolsType +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType private const val BASIC_HEIGHT_MM = 7f private const val BASIC_DISTANCE_MM = 5000f diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/analysis/parameters/AnalysisParametersFragment.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/analysis/parameters/AnalysisParametersFragment.kt index f8c3abe1..6ddeb49d 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/analysis/parameters/AnalysisParametersFragment.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/analysis/parameters/AnalysisParametersFragment.kt @@ -15,8 +15,8 @@ import ru.rznnike.eyehealthmanager.app.presentation.analysis.parameters.Analysis import ru.rznnike.eyehealthmanager.app.utils.extensions.addSystemWindowInsetToMargin import ru.rznnike.eyehealthmanager.app.utils.extensions.addSystemWindowInsetToPadding import ru.rznnike.eyehealthmanager.databinding.FragmentAnalysisParametersBinding -import ru.rznnike.eyehealthmanager.domain.model.AnalysisParameters -import ru.rznnike.eyehealthmanager.domain.model.enums.AnalysisType +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisParameters +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisType import ru.rznnike.eyehealthmanager.domain.utils.toDate class AnalysisParametersFragment : BaseFragment(R.layout.fragment_analysis_parameters), AnalysisParametersView { diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/analysis/result/AnalysisResultFragment.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/analysis/result/AnalysisResultFragment.kt index b5058722..df7d1401 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/analysis/result/AnalysisResultFragment.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/analysis/result/AnalysisResultFragment.kt @@ -30,10 +30,10 @@ import ru.rznnike.eyehealthmanager.app.utils.extensions.getString import ru.rznnike.eyehealthmanager.app.utils.extensions.resources import ru.rznnike.eyehealthmanager.app.utils.extensions.toHtmlSpanned import ru.rznnike.eyehealthmanager.databinding.FragmentAnalysisResultBinding -import ru.rznnike.eyehealthmanager.domain.model.AnalysisResult -import ru.rznnike.eyehealthmanager.domain.model.AnalysisStatistics -import ru.rznnike.eyehealthmanager.domain.model.SingleEyeAnalysisResult -import ru.rznnike.eyehealthmanager.domain.model.enums.TestEyesType +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisResult +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisStatistics +import ru.rznnike.eyehealthmanager.domain.model.analysis.SingleEyeAnalysisResult +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType import ru.rznnike.eyehealthmanager.domain.utils.toDate import kotlin.math.abs import kotlin.math.max diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/astigmatism/result/AstigmatismResultFragment.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/astigmatism/result/AstigmatismResultFragment.kt index 3d5b8478..40200bb4 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/astigmatism/result/AstigmatismResultFragment.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/astigmatism/result/AstigmatismResultFragment.kt @@ -12,7 +12,7 @@ import ru.rznnike.eyehealthmanager.app.presentation.astigmatism.result.Astigmati import ru.rznnike.eyehealthmanager.app.presentation.astigmatism.result.AstigmatismResultView import ru.rznnike.eyehealthmanager.app.utils.extensions.* import ru.rznnike.eyehealthmanager.databinding.FragmentAstigmatismResultBinding -import ru.rznnike.eyehealthmanager.domain.model.enums.AstigmatismAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.astigmatism.AstigmatismAnswerType class AstigmatismResultFragment : BaseFragment(R.layout.fragment_astigmatism_result), AstigmatismResultView { diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/astigmatism/test/AstigmatismTestFragment.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/astigmatism/test/AstigmatismTestFragment.kt index 5171462a..903db2ea 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/astigmatism/test/AstigmatismTestFragment.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/astigmatism/test/AstigmatismTestFragment.kt @@ -16,7 +16,7 @@ import ru.rznnike.eyehealthmanager.app.utils.extensions.addSystemWindowInsetToPa import ru.rznnike.eyehealthmanager.app.utils.extensions.context import ru.rznnike.eyehealthmanager.app.utils.extensions.convertMmToPx import ru.rznnike.eyehealthmanager.databinding.FragmentAstigmatismTestBinding -import ru.rznnike.eyehealthmanager.domain.model.TestingSettings +import ru.rznnike.eyehealthmanager.domain.model.test.TestingSettings private const val BASIC_HEIGHT_MM = 100f private const val BASIC_DISTANCE_MM = 5000f diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/contrast/test/ContrastTestFragment.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/contrast/test/ContrastTestFragment.kt index 95ccb3c5..204b9b7a 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/contrast/test/ContrastTestFragment.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/contrast/test/ContrastTestFragment.kt @@ -16,7 +16,7 @@ import ru.rznnike.eyehealthmanager.app.utils.extensions.addSystemWindowInsetToPa import ru.rznnike.eyehealthmanager.app.utils.extensions.setVisible import ru.rznnike.eyehealthmanager.app.utils.extensions.withEndActionSafe import ru.rznnike.eyehealthmanager.databinding.FragmentContrastTestBinding -import ru.rznnike.eyehealthmanager.domain.model.enums.Direction +import ru.rznnike.eyehealthmanager.domain.model.common.Direction private const val FADE_ANIMATION_MS = 250L diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/daltonism/result/DaltonismResultFragment.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/daltonism/result/DaltonismResultFragment.kt index 26a35d1e..841634fe 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/daltonism/result/DaltonismResultFragment.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/daltonism/result/DaltonismResultFragment.kt @@ -8,12 +8,12 @@ import moxy.presenter.InjectPresenter import moxy.presenter.ProvidePresenter import ru.rznnike.eyehealthmanager.R import ru.rznnike.eyehealthmanager.app.global.ui.fragment.BaseFragment +import ru.rznnike.eyehealthmanager.app.model.test.daltonism.DaltonismAnomalyTypeVM import ru.rznnike.eyehealthmanager.app.presentation.daltonism.result.DaltonismResultPresenter import ru.rznnike.eyehealthmanager.app.presentation.daltonism.result.DaltonismResultView import ru.rznnike.eyehealthmanager.app.utils.extensions.* import ru.rznnike.eyehealthmanager.databinding.FragmentDaltonismResultBinding -import ru.rznnike.eyehealthmanager.domain.model.enums.DaltonismAnomalyType -import java.util.* +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismAnomalyType class DaltonismResultFragment : BaseFragment(R.layout.fragment_daltonism_result), DaltonismResultView { @@ -59,7 +59,7 @@ class DaltonismResultFragment : BaseFragment(R.layout.fragment_daltonism_result) textViewResult.text = "%s %s\n%s".format( errorsCount, resources.getQuantityString(R.plurals.errors, errorsCount), - getString(resultType.nameResId) + getString(DaltonismAnomalyTypeVM[resultType].nameResId) ) if (resultType == DaltonismAnomalyType.NONE) { textViewResult.setTextColorRes(R.color.colorAccent) diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/journal/backup/ExportJournalFragment.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/journal/backup/ExportJournalFragment.kt index ca34789f..b6d03f18 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/journal/backup/ExportJournalFragment.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/journal/backup/ExportJournalFragment.kt @@ -24,8 +24,8 @@ import ru.rznnike.eyehealthmanager.app.utils.extensions.addSystemWindowInsetToMa import ru.rznnike.eyehealthmanager.app.utils.extensions.addSystemWindowInsetToPadding import ru.rznnike.eyehealthmanager.app.utils.extensions.createFastAdapter import ru.rznnike.eyehealthmanager.databinding.FragmentExportJournalBinding -import ru.rznnike.eyehealthmanager.domain.model.TestResultFilter -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultFilter +import ru.rznnike.eyehealthmanager.domain.model.test.TestType import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants import ru.rznnike.eyehealthmanager.domain.utils.toDate diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/journal/restore/ImportJournalFragment.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/journal/restore/ImportJournalFragment.kt index db87f488..216f8f4c 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/journal/restore/ImportJournalFragment.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/journal/restore/ImportJournalFragment.kt @@ -20,7 +20,7 @@ import ru.rznnike.eyehealthmanager.app.utils.extensions.addSystemWindowInsetToPa import ru.rznnike.eyehealthmanager.app.utils.extensions.createFastAdapter import ru.rznnike.eyehealthmanager.app.utils.extensions.setVisible import ru.rznnike.eyehealthmanager.databinding.FragmentImportJournalBinding -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType +import ru.rznnike.eyehealthmanager.domain.model.test.TestType class ImportJournalFragment : BaseFragment(R.layout.fragment_import_journal), ImportJournalView { @InjectPresenter @@ -33,7 +33,7 @@ class ImportJournalFragment : BaseFragment(R.layout.fragment_import_journal), Im private val folderPicker = registerForActivityResult(ActivityResultContracts.OpenDocumentTree()) { uri -> uri?.let { - presenter.onFolderSelected(uri) + presenter.onFolderSelected(uri = uri, context = requireContext()) } } @@ -97,7 +97,7 @@ class ImportJournalFragment : BaseFragment(R.layout.fragment_import_journal), Im presenter.openImportFolder() } buttonStartImport.setOnClickListener { - presenter.importFiles() + presenter.importFiles(context = requireContext()) } } diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/main/journal/JournalFragment.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/main/journal/JournalFragment.kt index ba6c90a1..601b9e50 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/main/journal/JournalFragment.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/main/journal/JournalFragment.kt @@ -27,15 +27,15 @@ import ru.rznnike.eyehealthmanager.app.presentation.main.journal.JournalView import ru.rznnike.eyehealthmanager.app.ui.item.TestResultItem import ru.rznnike.eyehealthmanager.app.ui.item.TestTypeSmallItem import ru.rznnike.eyehealthmanager.app.ui.view.EmptyDividerDecoration +import ru.rznnike.eyehealthmanager.app.utils.AppConstants import ru.rznnike.eyehealthmanager.app.utils.extensions.addSystemWindowInsetToPadding import ru.rznnike.eyehealthmanager.app.utils.extensions.createFastAdapter import ru.rznnike.eyehealthmanager.app.utils.extensions.setVisible import ru.rznnike.eyehealthmanager.databinding.BottomDialogJournalFiltersBinding import ru.rznnike.eyehealthmanager.databinding.FragmentJournalBinding -import ru.rznnike.eyehealthmanager.domain.model.TestResult -import ru.rznnike.eyehealthmanager.domain.model.TestResultFilter -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType -import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultFilter +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult +import ru.rznnike.eyehealthmanager.domain.model.test.TestType import ru.rznnike.eyehealthmanager.domain.utils.atEndOfDay import ru.rznnike.eyehealthmanager.domain.utils.millis import ru.rznnike.eyehealthmanager.domain.utils.toDate @@ -71,7 +71,7 @@ class JournalFragment : BaseFragment(R.layout.fragment_journal), JournalView { adapter = createFastAdapter(itemAdapter, footerAdapter) adapter.setHasStableIds(true) - val preloadItemPosition = GlobalConstants.PRELOAD_ITEM_POSITION + val preloadItemPosition = AppConstants.PRELOAD_ITEM_POSITION adapter.onBindViewHolderListener = object : OnBindViewHolderListenerImpl>() { override fun onBindViewHolder( viewHolder: RecyclerView.ViewHolder, diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/main/settings/SettingsFragment.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/main/settings/SettingsFragment.kt index 1d59e96e..2cef7503 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/main/settings/SettingsFragment.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/main/settings/SettingsFragment.kt @@ -14,8 +14,10 @@ import ru.rznnike.eyehealthmanager.app.dialog.bottom.BottomDialogAction import ru.rznnike.eyehealthmanager.app.dialog.showAlertDialog import ru.rznnike.eyehealthmanager.app.dialog.showBottomDialog import ru.rznnike.eyehealthmanager.app.global.ui.fragment.BaseFragment +import ru.rznnike.eyehealthmanager.app.model.common.AppThemeVM import ru.rznnike.eyehealthmanager.app.presentation.main.settings.SettingsPresenter import ru.rznnike.eyehealthmanager.app.presentation.main.settings.SettingsView +import ru.rznnike.eyehealthmanager.app.utils.AppConstants import ru.rznnike.eyehealthmanager.app.utils.extensions.addSystemWindowInsetToPadding import ru.rznnike.eyehealthmanager.app.utils.extensions.setScaleOnTouch import ru.rznnike.eyehealthmanager.app.utils.extensions.setVisible @@ -23,10 +25,9 @@ import ru.rznnike.eyehealthmanager.databinding.DialogAboutAppBinding import ru.rznnike.eyehealthmanager.databinding.DialogChangelogBinding import ru.rznnike.eyehealthmanager.databinding.DialogDevMenuBinding import ru.rznnike.eyehealthmanager.databinding.FragmentSettingsBinding -import ru.rznnike.eyehealthmanager.domain.model.enums.AppTheme -import ru.rznnike.eyehealthmanager.domain.model.enums.DataGenerationType -import ru.rznnike.eyehealthmanager.domain.model.enums.Language -import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants +import ru.rznnike.eyehealthmanager.domain.model.common.AppTheme +import ru.rznnike.eyehealthmanager.domain.model.common.DataGenerationType +import ru.rznnike.eyehealthmanager.domain.model.common.Language class SettingsFragment : BaseFragment(R.layout.fragment_settings), SettingsView { @InjectPresenter @@ -110,7 +111,7 @@ class SettingsFragment : BaseFragment(R.layout.fragment_settings), SettingsView buttonLanguage.setOnClickListener { showLanguageSelectionBottomDialog(language) } - textViewCurrentTheme.setText(theme.nameResId) + textViewCurrentTheme.setText(AppThemeVM[theme].nameResId) buttonTheme.setOnClickListener { showThemeSelectionBottomDialog(theme) } @@ -137,7 +138,7 @@ class SettingsFragment : BaseFragment(R.layout.fragment_settings), SettingsView header = getString(R.string.choose_theme), actions = AppTheme.entries.map { theme -> BottomDialogAction( - text = getString(theme.nameResId), + text = getString(AppThemeVM[theme].nameResId), selected = theme == currentTheme ) { it.dismiss() @@ -175,7 +176,7 @@ class SettingsFragment : BaseFragment(R.layout.fragment_settings), SettingsView dialog.dismiss() routerStartFlow( Screens.Common.actionMailTo( - email = GlobalConstants.FEEDBACK_EMAIL_ADDRESS, + email = AppConstants.FEEDBACK_EMAIL_ADDRESS, subject = getString(R.string.app_name) ) ) @@ -183,7 +184,7 @@ class SettingsFragment : BaseFragment(R.layout.fragment_settings), SettingsView buttonDialogSourceCode.setOnClickListener { dialog.dismiss() routerStartFlow( - Screens.Common.actionOpenLink(GlobalConstants.REPOSITORY_LINK) + Screens.Common.actionOpenLink(AppConstants.REPOSITORY_LINK) ) } diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/main/tests/TestsFragment.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/main/tests/TestsFragment.kt index b57ca8ba..a3d1848e 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/main/tests/TestsFragment.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/main/tests/TestsFragment.kt @@ -17,7 +17,7 @@ import ru.rznnike.eyehealthmanager.app.ui.view.EmptyDividerDecoration import ru.rznnike.eyehealthmanager.app.utils.extensions.addSystemWindowInsetToPadding import ru.rznnike.eyehealthmanager.app.utils.extensions.createFastAdapter import ru.rznnike.eyehealthmanager.databinding.FragmentTestsBinding -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType +import ru.rznnike.eyehealthmanager.domain.model.test.TestType class TestsFragment : BaseFragment(R.layout.fragment_tests), TestsView { @InjectPresenter diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/nearfar/result/NearFarResultFragment.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/nearfar/result/NearFarResultFragment.kt index 884651c3..c009f979 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/nearfar/result/NearFarResultFragment.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/nearfar/result/NearFarResultFragment.kt @@ -8,11 +8,12 @@ import moxy.presenter.InjectPresenter import moxy.presenter.ProvidePresenter import ru.rznnike.eyehealthmanager.R import ru.rznnike.eyehealthmanager.app.global.ui.fragment.BaseFragment +import ru.rznnike.eyehealthmanager.app.model.test.nearfar.NearFarAnswerTypeVM import ru.rznnike.eyehealthmanager.app.presentation.nearfar.result.NearFarResultPresenter import ru.rznnike.eyehealthmanager.app.presentation.nearfar.result.NearFarResultView import ru.rznnike.eyehealthmanager.app.utils.extensions.* import ru.rznnike.eyehealthmanager.databinding.FragmentNearFarResultBinding -import ru.rznnike.eyehealthmanager.domain.model.enums.NearFarAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarAnswerType class NearFarResultFragment : BaseFragment(R.layout.fragment_near_far_result), NearFarResultView { @InjectPresenter @@ -59,14 +60,14 @@ class NearFarResultFragment : BaseFragment(R.layout.fragment_near_far_result), N NearFarAnswerType.GREEN_BETTER -> "%s" NearFarAnswerType.EQUAL -> "%s" }.format( - getString(answerLeftEye.nameResId) + getString(NearFarAnswerTypeVM[answerLeftEye].nameResId) ) val rightEyeStatus = when (answerRightEye) { NearFarAnswerType.RED_BETTER -> "%s" NearFarAnswerType.GREEN_BETTER -> "%s" NearFarAnswerType.EQUAL -> "%s" }.format( - getString(answerRightEye.nameResId) + getString(NearFarAnswerTypeVM[answerRightEye].nameResId) ) textViewResult.text = "%s - %s
%s - %s".format( getString(R.string.left_eye), diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/settings/testing/TestingSettingsFragment.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/settings/testing/TestingSettingsFragment.kt index 78e8f3ab..76a99973 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/settings/testing/TestingSettingsFragment.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/fragment/settings/testing/TestingSettingsFragment.kt @@ -15,7 +15,7 @@ import ru.rznnike.eyehealthmanager.app.presentation.settings.testing.TestingSett import ru.rznnike.eyehealthmanager.app.presentation.settings.testing.TestingSettingsView import ru.rznnike.eyehealthmanager.app.utils.extensions.* import ru.rznnike.eyehealthmanager.databinding.FragmentSettingsTestingBinding -import ru.rznnike.eyehealthmanager.domain.model.TestingSettings +import ru.rznnike.eyehealthmanager.domain.model.test.TestingSettings import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants import ru.rznnike.eyehealthmanager.domain.utils.toDate import java.util.* diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/EyesTypeItem.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/EyesTypeItem.kt index b8551bce..f237a876 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/EyesTypeItem.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/EyesTypeItem.kt @@ -4,8 +4,9 @@ import android.view.LayoutInflater import android.view.ViewGroup import ru.rznnike.eyehealthmanager.R import ru.rznnike.eyehealthmanager.app.global.BaseBindingItem +import ru.rznnike.eyehealthmanager.app.model.test.TestEyesTypeVM import ru.rznnike.eyehealthmanager.databinding.ItemEyesTypeBinding -import ru.rznnike.eyehealthmanager.domain.model.enums.TestEyesType +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType class EyesTypeItem( val eyesType: TestEyesType @@ -18,7 +19,7 @@ class EyesTypeItem( ItemEyesTypeBinding.inflate(inflater, parent, false) override fun ItemEyesTypeBinding.bindView() { - textViewName.setText(eyesType.nameResId) + textViewName.setText(TestEyesTypeVM[eyesType].nameResId) textViewName.setBackgroundResource( if (isSelected) R.drawable.bg_rounded_8_outline_accent else R.color.colorTransparent ) diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/SymbolItem.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/SymbolItem.kt index 22810648..a96aab94 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/SymbolItem.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/SymbolItem.kt @@ -5,7 +5,7 @@ import android.view.ViewGroup import ru.rznnike.eyehealthmanager.R import ru.rznnike.eyehealthmanager.app.global.BaseBindingItem import ru.rznnike.eyehealthmanager.databinding.ItemSymbolBinding -import ru.rznnike.eyehealthmanager.domain.model.IAcuitySymbol +import ru.rznnike.eyehealthmanager.app.model.test.acuity.IAcuitySymbol class SymbolItem( val symbol: IAcuitySymbol diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/SymbolsTypeItem.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/SymbolsTypeItem.kt index 516376aa..247235d4 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/SymbolsTypeItem.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/SymbolsTypeItem.kt @@ -4,8 +4,9 @@ import android.view.LayoutInflater import android.view.ViewGroup import ru.rznnike.eyehealthmanager.R import ru.rznnike.eyehealthmanager.app.global.BaseBindingItem +import ru.rznnike.eyehealthmanager.app.model.test.acuity.AcuityTestSymbolsTypeVM import ru.rznnike.eyehealthmanager.databinding.ItemSymbolsTypeBinding -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuityTestSymbolsType +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestSymbolsType class SymbolsTypeItem( val symbolsType: AcuityTestSymbolsType @@ -18,7 +19,7 @@ class SymbolsTypeItem( ItemSymbolsTypeBinding.inflate(inflater, parent, false) override fun ItemSymbolsTypeBinding.bindView() { - imageViewIcon.setImageResource(symbolsType.iconResId) + imageViewIcon.setImageResource(AcuityTestSymbolsTypeVM[symbolsType].iconResId) imageViewIcon.setBackgroundResource( if (isSelected) R.drawable.bg_rounded_8_outline_accent else R.color.colorTransparent ) diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/TestResultItem.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/TestResultItem.kt index f714875b..4fa3f177 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/TestResultItem.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/TestResultItem.kt @@ -4,20 +4,25 @@ import android.view.LayoutInflater import android.view.ViewGroup import ru.rznnike.eyehealthmanager.R import ru.rznnike.eyehealthmanager.app.global.BaseBindingItem +import ru.rznnike.eyehealthmanager.app.model.test.TestTypeVM +import ru.rznnike.eyehealthmanager.app.model.test.acuity.AcuityTestSymbolsTypeVM +import ru.rznnike.eyehealthmanager.app.model.test.astigmatism.AstigmatismAnswerTypeVM +import ru.rznnike.eyehealthmanager.app.model.test.daltonism.DaltonismAnomalyTypeVM +import ru.rznnike.eyehealthmanager.app.model.test.nearfar.NearFarAnswerTypeVM import ru.rznnike.eyehealthmanager.app.utils.extensions.getString import ru.rznnike.eyehealthmanager.app.utils.extensions.resources import ru.rznnike.eyehealthmanager.app.utils.extensions.setScaleOnTouch import ru.rznnike.eyehealthmanager.app.utils.extensions.toHtmlSpanned import ru.rznnike.eyehealthmanager.databinding.ItemTestResultBinding -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestResult -import ru.rznnike.eyehealthmanager.domain.model.AstigmatismTestResult -import ru.rznnike.eyehealthmanager.domain.model.ColorPerceptionTestResult -import ru.rznnike.eyehealthmanager.domain.model.ContrastTestResult -import ru.rznnike.eyehealthmanager.domain.model.DaltonismTestResult -import ru.rznnike.eyehealthmanager.domain.model.NearFarTestResult -import ru.rznnike.eyehealthmanager.domain.model.TestResult -import ru.rznnike.eyehealthmanager.domain.model.enums.TestEyesType -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.astigmatism.AstigmatismTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.colorperception.ColorPerceptionTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.contrast.ContrastTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType +import ru.rznnike.eyehealthmanager.domain.model.test.TestType import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants import ru.rznnike.eyehealthmanager.domain.utils.toDate @@ -66,9 +71,10 @@ class TestResultItem( } } - textViewName.setText(testType.nameResId) + val testTypeVM = TestTypeVM[testType] + textViewName.setText(testTypeVM.nameResId) textViewDetails.text = details.replace("\n", "
").toHtmlSpanned() - imageViewIcon.setImageResource(testType.iconResId) + imageViewIcon.setImageResource(testTypeVM.iconResId) textViewDate.text = testResult.timestamp.toDate(GlobalConstants.DATE_PATTERN_SIMPLE_WITH_TIME) @@ -83,7 +89,7 @@ class TestResultItem( } else { "%s: %s".format( getString(R.string.symbols_set), - getString(testResult.symbolsType.nameResId) + getString(AcuityTestSymbolsTypeVM[testResult.symbolsType].nameResId) ) } val eyesPart = when (testResult.testEyesType) { @@ -109,8 +115,16 @@ class TestResultItem( } private fun ItemTestResultBinding.getAstigmatismTestDetails(testResult: AstigmatismTestResult): String { - val leftEyeStatus = testResult.resultLeftEye?.nameResId?.let { getString(it) } ?: "-" - val rightEyeStatus = testResult.resultRightEye?.nameResId?.let { getString(it) } ?: "-" + val leftEyeStatus = testResult.resultLeftEye + ?.let { AstigmatismAnswerTypeVM[it] } + ?.nameResId + ?.let { getString(it) } + ?: "-" + val rightEyeStatus = testResult.resultRightEye + ?.let { AstigmatismAnswerTypeVM[it] } + ?.nameResId + ?.let { getString(it) } + ?: "-" return "%s: %s\n%s: %s".format( getString(R.string.left_eye), leftEyeStatus, @@ -120,8 +134,8 @@ class TestResultItem( } private fun ItemTestResultBinding.getNearFarTestDetails(testResult: NearFarTestResult): String { - val leftEyeStatus = getString(testResult.resultLeftEye.nameResId) - val rightEyeStatus = getString(testResult.resultRightEye.nameResId) + val leftEyeStatus = getString(NearFarAnswerTypeVM[testResult.resultLeftEye].nameResId) + val rightEyeStatus = getString(NearFarAnswerTypeVM[testResult.resultRightEye].nameResId) return "%s: %s\n%s: %s".format( getString(R.string.left_eye), leftEyeStatus, @@ -141,7 +155,7 @@ class TestResultItem( "%s %s\n%s".format( testResult.errorsCount, resources.getQuantityString(R.plurals.errors, testResult.errorsCount), - getString(testResult.anomalyType.nameResId) + getString(DaltonismAnomalyTypeVM[testResult.anomalyType].nameResId) ) private fun ItemTestResultBinding.getContrastTestDetails(testResult: ContrastTestResult) = diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/TestTypeIndicatorItem.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/TestTypeIndicatorItem.kt index c055d0ae..3f8ab22c 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/TestTypeIndicatorItem.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/TestTypeIndicatorItem.kt @@ -4,9 +4,10 @@ import android.view.LayoutInflater import android.view.ViewGroup import ru.rznnike.eyehealthmanager.R import ru.rznnike.eyehealthmanager.app.global.BaseBindingItem +import ru.rznnike.eyehealthmanager.app.model.test.TestTypeVM import ru.rznnike.eyehealthmanager.app.utils.extensions.setImageTint import ru.rznnike.eyehealthmanager.databinding.ItemTestTypeIndicatorBinding -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType +import ru.rznnike.eyehealthmanager.domain.model.test.TestType class TestTypeIndicatorItem( private val testType: TestType, @@ -20,8 +21,9 @@ class TestTypeIndicatorItem( ItemTestTypeIndicatorBinding.inflate(inflater, parent, false) override fun ItemTestTypeIndicatorBinding.bindView() { - textViewName.setText(testType.nameResId) - imageViewIcon.setImageResource(testType.iconResId) + val testTypeVM = TestTypeVM[testType] + textViewName.setText(testTypeVM.nameResId) + imageViewIcon.setImageResource(testTypeVM.iconResId) if (available) { imageViewIndicator.setImageResource(R.drawable.ic_check) imageViewIndicator.setImageTint(R.color.colorAccent) diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/TestTypeItem.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/TestTypeItem.kt index 4fd2ab0a..f7e04e6e 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/TestTypeItem.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/TestTypeItem.kt @@ -4,9 +4,10 @@ import android.view.LayoutInflater import android.view.ViewGroup import ru.rznnike.eyehealthmanager.R import ru.rznnike.eyehealthmanager.app.global.BaseBindingItem +import ru.rznnike.eyehealthmanager.app.model.test.TestTypeVM import ru.rznnike.eyehealthmanager.app.utils.extensions.setScaleOnTouch import ru.rznnike.eyehealthmanager.databinding.ItemTestTypeBinding -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType +import ru.rznnike.eyehealthmanager.domain.model.test.TestType class TestTypeItem( val testType: TestType @@ -19,8 +20,9 @@ class TestTypeItem( ItemTestTypeBinding.inflate(inflater, parent, false) override fun ItemTestTypeBinding.bindView() { - textViewName.setText(testType.nameResId) - imageViewIcon.setImageResource(testType.iconResId) + val testTypeVM = TestTypeVM[testType] + textViewName.setText(testTypeVM.nameResId) + imageViewIcon.setImageResource(testTypeVM.iconResId) root.setScaleOnTouch() } diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/TestTypeSmallItem.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/TestTypeSmallItem.kt index cbe1c30c..c3345292 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/TestTypeSmallItem.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/item/TestTypeSmallItem.kt @@ -4,8 +4,9 @@ import android.view.LayoutInflater import android.view.ViewGroup import ru.rznnike.eyehealthmanager.R import ru.rznnike.eyehealthmanager.app.global.BaseBindingItem +import ru.rznnike.eyehealthmanager.app.model.test.TestTypeVM import ru.rznnike.eyehealthmanager.databinding.ItemTestTypeSmallBinding -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType +import ru.rznnike.eyehealthmanager.domain.model.test.TestType class TestTypeSmallItem( val testType: TestType @@ -18,7 +19,7 @@ class TestTypeSmallItem( ItemTestTypeSmallBinding.inflate(inflater, parent, false) override fun ItemTestTypeSmallBinding.bindView() { - imageViewIcon.setImageResource(testType.iconResId) + imageViewIcon.setImageResource(TestTypeVM[testType].iconResId) imageViewIcon.setBackgroundResource( if (isSelected) R.drawable.bg_rounded_8_outline_accent else R.color.colorTransparent ) diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/view/EmptyDividerDecoration.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/view/EmptyDividerDecoration.kt index 4ae33065..f23eef4c 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/view/EmptyDividerDecoration.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/ui/view/EmptyDividerDecoration.kt @@ -43,7 +43,7 @@ class EmptyDividerDecoration( if (displayMode == -1) { displayMode = resolveDisplayMode(layoutManager) } - val reverseLayout = (layoutManager as? LinearLayoutManager)?.reverseLayout ?: false + val reverseLayout = (layoutManager as? LinearLayoutManager)?.reverseLayout == true when (displayMode) { HORIZONTAL -> { diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/utils/AppConstants.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/utils/AppConstants.kt new file mode 100644 index 00000000..557c8b31 --- /dev/null +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/utils/AppConstants.kt @@ -0,0 +1,10 @@ +package ru.rznnike.eyehealthmanager.app.utils + +object AppConstants { + const val APP_EXIT_DURATION_MS = 2500L + + const val PRELOAD_ITEM_POSITION = 10 + + const val FEEDBACK_EMAIL_ADDRESS = "rznnike@yandex.ru" + const val REPOSITORY_LINK = "https://github.com/RznNike/EyeHealthManager" +} \ No newline at end of file diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/utils/JournalBackupManagerAndroid.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/utils/JournalBackupManagerAndroid.kt new file mode 100644 index 00000000..176817e2 --- /dev/null +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/utils/JournalBackupManagerAndroid.kt @@ -0,0 +1,12 @@ +package ru.rznnike.eyehealthmanager.app.utils + +import android.content.Context +import android.net.Uri +import ru.rznnike.eyehealthmanager.domain.model.test.TestType +import ru.rznnike.eyehealthmanager.domain.utils.JournalBackupManager + +abstract class JournalBackupManagerAndroid : JournalBackupManager { + var context: Context? = null + + abstract fun getAvailableImportTypes(importFolderUri: Uri): List +} \ No newline at end of file diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/utils/JournalBackupManagerAndroidImpl.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/utils/JournalBackupManagerAndroidImpl.kt new file mode 100644 index 00000000..db602fee --- /dev/null +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/utils/JournalBackupManagerAndroidImpl.kt @@ -0,0 +1,186 @@ +package ru.rznnike.eyehealthmanager.app.utils + +import android.annotation.SuppressLint +import android.net.Uri +import androidx.documentfile.provider.DocumentFile +import ru.rznnike.eyehealthmanager.data.utils.DataConstants +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultFilter +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult +import ru.rznnike.eyehealthmanager.domain.model.test.TestType +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.astigmatism.AstigmatismTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.colorperception.ColorPerceptionTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.contrast.ContrastTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarTestResult +import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants +import ru.rznnike.eyehealthmanager.domain.utils.toDate +import java.io.BufferedWriter +import java.io.IOException +import java.time.Clock +import java.util.EnumMap + +class JournalBackupManagerAndroidImpl : JournalBackupManagerAndroid() { + @SuppressLint("Recycle") + override suspend fun exportJournal( + filter: TestResultFilter, + clock: Clock, + readDataFromDBCallback: suspend (filter: TestResultFilter, pageOffset: Int) -> List + ): Uri? { + fun DocumentFile.findOrCreateDocumentFolder(name: String) = findFile(name) ?: createDirectory(name) + + var exportFolderUri: Uri? = null + val exportFiles: MutableMap = EnumMap(TestType::class.java) + val exportFileWriters: MutableMap = EnumMap(TestType::class.java) + val exportEntryCounters: MutableMap = EnumMap(TestType::class.java) + + context?.let { context -> + context.contentResolver + .persistedUriPermissions + .firstOrNull() + ?.uri + ?.let { DocumentFile.fromTreeUri(context, it) } + ?.findOrCreateDocumentFolder(DataConstants.APP_DIR) + ?.findOrCreateDocumentFolder(DataConstants.EXPORT_DIR) + ?.findOrCreateDocumentFolder( + clock.millis().toDate(GlobalConstants.DATE_PATTERN_FULL_FOR_PATH) + ) + ?.let { folder -> + try { + exportFolderUri = folder.uri + TestType.entries.forEach { type -> + val fileName = type.toString().lowercase() + folder.createFile( + "text/tab-separated-values", + "${fileName}.tsv" + )?.let { file -> + context.contentResolver + .openOutputStream(file.uri) + ?.bufferedWriter() + ?.let { + exportFileWriters[type] = it + it.appendLine(type.exportHeader) + } + + exportFiles[type] = file + exportEntryCounters[type] = 0 + } + } + + var dataCounter = 0 + do { + val page = writeJournalPageToFiles( + filter = filter, + pageOffset = dataCounter, + exportFileWriters = exportFileWriters, + exportEntryCounters = exportEntryCounters, + readDataFromDBCallback = readDataFromDBCallback + ) + dataCounter += page + } while (page == DataConstants.EXPORT_PAGE_SIZE) + } finally { + exportFileWriters.forEach { + try { + it.value.close() + if (exportEntryCounters[it.key] == 0) { + exportFiles[it.key]?.delete() + } + } catch (e: IOException) { + e.printStackTrace() + } + } + } + } + } + return exportFolderUri + } + + private suspend fun writeJournalPageToFiles( + filter: TestResultFilter, + pageOffset: Int, + exportFileWriters: MutableMap, + exportEntryCounters: MutableMap, + readDataFromDBCallback: suspend (filter: TestResultFilter, pageOffset: Int) -> List + ): Int { + val data = readDataFromDBCallback(filter, pageOffset) + data.forEach { testResult -> + when (testResult) { + is AcuityTestResult -> TestType.ACUITY + is AstigmatismTestResult -> TestType.ASTIGMATISM + is ColorPerceptionTestResult -> TestType.COLOR_PERCEPTION + is ContrastTestResult -> TestType.CONTRAST + is DaltonismTestResult -> TestType.DALTONISM + is NearFarTestResult -> TestType.NEAR_FAR + else -> null + }?.let { type -> + val exportString = testResult.exportToString() + exportFileWriters[type]?.appendLine(exportString) + exportEntryCounters[type] = exportEntryCounters.getOrDefault(type, 0) + 1 + } + } + exportFileWriters.values.forEach { + it.flush() + } + return data.size + } + + @SuppressLint("Recycle") + override suspend fun importJournal( + importFolderUri: Uri, + writeDataToDBCallback: suspend (List) -> Unit + ) { + context?.let { context -> + DocumentFile.fromTreeUri(context, importFolderUri) + ?.listFiles() + ?.filter { it.isFile } + ?.mapNotNull { file -> + val fileName = file.name?.removeSuffix(".tsv") + val type = TestType.entries.firstOrNull { fileName == it.name.lowercase() } + type?.let { type to file } + } + ?.distinctBy { it.first } + ?.forEach { mappedFile -> + val type = mappedFile.first + val file = mappedFile.second + val resultsBuffer = mutableListOf() + + context.contentResolver + .openInputStream(file.uri) + ?.bufferedReader() + ?.useLines { lines -> + lines + .mapNotNull { line -> + when (type) { + TestType.ACUITY -> AcuityTestResult.importFromString(line) + TestType.ASTIGMATISM -> AstigmatismTestResult.importFromString(line) + TestType.NEAR_FAR -> NearFarTestResult.importFromString(line) + TestType.COLOR_PERCEPTION -> ColorPerceptionTestResult.importFromString(line) + TestType.DALTONISM -> DaltonismTestResult.importFromString(line) + TestType.CONTRAST -> ContrastTestResult.importFromString(line) + } + } + .forEach { + resultsBuffer.add(it) + if (resultsBuffer.size >= DataConstants.IMPORT_PAGE_SIZE) { + writeDataToDBCallback(resultsBuffer) + resultsBuffer.clear() + } + } + writeDataToDBCallback(resultsBuffer) + } + } + } + } + + override fun getAvailableImportTypes(importFolderUri: Uri) = + context?.let { context -> + DocumentFile.fromTreeUri(context, importFolderUri) + ?.listFiles() + ?.filter { it.isFile } + ?.mapNotNull { file -> + val fileName = file.name?.removeSuffix(".tsv") + TestType.entries.firstOrNull { fileName == it.name.lowercase() } + } + ?.distinct() + } ?: emptyList() +} \ No newline at end of file diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/utils/extensions/ActivityUtils.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/utils/extensions/ActivityUtils.kt index 370dc965..d5da1a44 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/utils/extensions/ActivityUtils.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/utils/extensions/ActivityUtils.kt @@ -4,8 +4,8 @@ import android.app.Activity import android.content.Intent import androidx.appcompat.app.AppCompatDelegate import androidx.core.os.LocaleListCompat -import ru.rznnike.eyehealthmanager.domain.model.enums.AppTheme -import ru.rznnike.eyehealthmanager.domain.model.enums.Language +import ru.rznnike.eyehealthmanager.domain.model.common.AppTheme +import ru.rznnike.eyehealthmanager.domain.model.common.Language import java.util.Locale import kotlin.system.exitProcess diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/utils/extensions/ArgumentsUtils.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/utils/extensions/ArgumentsUtils.kt index def00c8b..6c19dcdf 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/utils/extensions/ArgumentsUtils.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/utils/extensions/ArgumentsUtils.kt @@ -19,7 +19,7 @@ inline fun Fragment.getParcelableListArg(key: String): L arguments?.getParcelableArrayList(key) } ?: emptyList() -fun Fragment.getBooleanArg(key: String): Boolean = arguments?.getBoolean(key) ?: false +fun Fragment.getBooleanArg(key: String): Boolean = arguments?.getBoolean(key) == true fun Fragment.getStringArg(key: String): String? = arguments?.getString(key) diff --git a/app/src/main/java/ru/rznnike/eyehealthmanager/app/utils/extensions/EditTextUtils.kt b/app/src/main/java/ru/rznnike/eyehealthmanager/app/utils/extensions/EditTextUtils.kt index 36c769ab..06d5c017 100644 --- a/app/src/main/java/ru/rznnike/eyehealthmanager/app/utils/extensions/EditTextUtils.kt +++ b/app/src/main/java/ru/rznnike/eyehealthmanager/app/utils/extensions/EditTextUtils.kt @@ -1,5 +1,6 @@ package ru.rznnike.eyehealthmanager.app.utils.extensions +import android.annotation.SuppressLint import android.text.style.UnderlineSpan import android.widget.EditText @@ -10,6 +11,7 @@ fun EditText.syncWithValue(value: String?) { } } +@SuppressLint("SetTextI18n") fun EditText.syncWithValue(value: Double?) = value?.let { val editTextValue = text.toString().toDoubleOrNull() ?: 0.0 if (editTextValue != it) { @@ -21,6 +23,7 @@ fun EditText.syncWithValue(value: Double?) = value?.let { } } +@SuppressLint("SetTextI18n") fun EditText.syncWithValue(value: Int?) = value?.let { val editTextValue = text.toString().toIntOrNull() ?: 0 if (editTextValue != it) { diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/dispatcher/external/ExternalIntentDispatcherTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/dispatcher/external/ExternalIntentDispatcherTest.kt index 7e2bde36..f0e4a8cf 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/dispatcher/external/ExternalIntentDispatcherTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/dispatcher/external/ExternalIntentDispatcherTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Assertions.assertFalse import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test import ru.rznnike.eyehealthmanager.app.utils.createTestCoroutineProvider -import ru.rznnike.eyehealthmanager.domain.model.ExternalIntentData +import ru.rznnike.eyehealthmanager.domain.model.common.ExternalIntentData @OptIn(ExperimentalCoroutinesApi::class) class ExternalIntentDispatcherTest { diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/doctor/AcuityDoctorResultPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/doctor/AcuityDoctorResultPresenterTest.kt index f05dcf47..fd9ce13a 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/doctor/AcuityDoctorResultPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/doctor/AcuityDoctorResultPresenterTest.kt @@ -34,10 +34,10 @@ import ru.rznnike.eyehealthmanager.app.dispatcher.notifier.Notifier import ru.rznnike.eyehealthmanager.app.global.presentation.ErrorHandler import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseResult import ru.rznnike.eyehealthmanager.domain.interactor.test.AddTestResultUseCase -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestResult -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuityTestSymbolsType -import ru.rznnike.eyehealthmanager.domain.model.enums.DayPart -import ru.rznnike.eyehealthmanager.domain.model.enums.TestEyesType +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestSymbolsType +import ru.rznnike.eyehealthmanager.domain.model.common.DayPart +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType @ExtendWith(MockitoExtension::class) class AcuityDoctorResultPresenterTest : KoinTest { diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/info/AcuityInfoPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/info/AcuityInfoPresenterTest.kt index 51bbe91c..e8839ae6 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/info/AcuityInfoPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/info/AcuityInfoPresenterTest.kt @@ -38,11 +38,11 @@ import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseResult import ru.rznnike.eyehealthmanager.domain.interactor.user.GetAcuityTestingSettingsUseCase import ru.rznnike.eyehealthmanager.domain.interactor.user.GetTestingSettingsUseCase import ru.rznnike.eyehealthmanager.domain.interactor.user.SetAcuityTestingSettingsUseCase -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestingSettings -import ru.rznnike.eyehealthmanager.domain.model.TestingSettings -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuityTestSymbolsType -import ru.rznnike.eyehealthmanager.domain.model.enums.DayPart -import ru.rznnike.eyehealthmanager.domain.model.enums.TestEyesType +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestingSettings +import ru.rznnike.eyehealthmanager.domain.model.test.TestingSettings +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestSymbolsType +import ru.rznnike.eyehealthmanager.domain.model.common.DayPart +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType import java.time.Clock import java.time.Instant import java.time.ZoneOffset diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/instruction/AcuityInstructionPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/instruction/AcuityInstructionPresenterTest.kt index d1d21d63..28ae3583 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/instruction/AcuityInstructionPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/instruction/AcuityInstructionPresenterTest.kt @@ -8,7 +8,7 @@ import org.mockito.kotlin.only import org.mockito.kotlin.verify import ru.rznnike.eyehealthmanager.app.ui.fragment.acuity.test.AcuityTestFragment import ru.rznnike.eyehealthmanager.app.utils.screenMatcher -import ru.rznnike.eyehealthmanager.domain.model.enums.DayPart +import ru.rznnike.eyehealthmanager.domain.model.common.DayPart @ExtendWith(MockitoExtension::class) class AcuityInstructionPresenterTest { diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/result/AcuityResultPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/result/AcuityResultPresenterTest.kt index b87e019a..11f293c7 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/result/AcuityResultPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/result/AcuityResultPresenterTest.kt @@ -38,11 +38,11 @@ import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseResult import ru.rznnike.eyehealthmanager.domain.interactor.analysis.GetAnalysisResultUseCase import ru.rznnike.eyehealthmanager.domain.interactor.test.DeleteTestResultUseCase import ru.rznnike.eyehealthmanager.domain.interactor.user.GetApplyDynamicCorrectionsUseCase -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestResult -import ru.rznnike.eyehealthmanager.domain.model.AnalysisResult -import ru.rznnike.eyehealthmanager.domain.model.SingleEyeAnalysisResult -import ru.rznnike.eyehealthmanager.domain.model.enums.AnalysisType -import ru.rznnike.eyehealthmanager.domain.model.enums.DayPart +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestResult +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisResult +import ru.rznnike.eyehealthmanager.domain.model.analysis.SingleEyeAnalysisResult +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisType +import ru.rznnike.eyehealthmanager.domain.model.common.DayPart import ru.rznnike.eyehealthmanager.domain.model.exception.NotEnoughDataException import java.time.Clock import java.time.Instant diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/test/AcuityTestPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/test/AcuityTestPresenterTest.kt index eed16e65..d24e9b3e 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/test/AcuityTestPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/acuity/test/AcuityTestPresenterTest.kt @@ -29,18 +29,18 @@ import org.mockito.kotlin.whenever import ru.rznnike.eyehealthmanager.app.dispatcher.event.EventDispatcher import ru.rznnike.eyehealthmanager.app.dispatcher.notifier.Notifier import ru.rznnike.eyehealthmanager.app.global.presentation.ErrorHandler +import ru.rznnike.eyehealthmanager.app.model.test.acuity.AcuitySymbolLetterEn import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseResult import ru.rznnike.eyehealthmanager.domain.interactor.test.AddTestResultUseCase import ru.rznnike.eyehealthmanager.domain.interactor.user.GetAcuityTestingSettingsUseCase import ru.rznnike.eyehealthmanager.domain.interactor.user.GetTestingSettingsUseCase -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestingSettings -import ru.rznnike.eyehealthmanager.domain.model.EmptyAcuitySymbol -import ru.rznnike.eyehealthmanager.domain.model.IAcuitySymbol -import ru.rznnike.eyehealthmanager.domain.model.TestingSettings -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuitySymbolLetterEn -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuityTestSymbolsType -import ru.rznnike.eyehealthmanager.domain.model.enums.DayPart -import ru.rznnike.eyehealthmanager.domain.model.enums.TestEyesType +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestingSettings +import ru.rznnike.eyehealthmanager.app.model.test.acuity.EmptyAcuitySymbol +import ru.rznnike.eyehealthmanager.app.model.test.acuity.IAcuitySymbol +import ru.rznnike.eyehealthmanager.domain.model.test.TestingSettings +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestSymbolsType +import ru.rznnike.eyehealthmanager.domain.model.common.DayPart +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType import java.time.Clock @ExtendWith(MockitoExtension::class) diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/parameters/AnalysisParametersPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/parameters/AnalysisParametersPresenterTest.kt index 4a154d99..1200a24c 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/parameters/AnalysisParametersPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/parameters/AnalysisParametersPresenterTest.kt @@ -36,9 +36,9 @@ import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseResult import ru.rznnike.eyehealthmanager.domain.interactor.analysis.GetAnalysisResultUseCase import ru.rznnike.eyehealthmanager.domain.interactor.user.GetApplyDynamicCorrectionsUseCase import ru.rznnike.eyehealthmanager.domain.interactor.user.SetApplyDynamicCorrectionsUseCase -import ru.rznnike.eyehealthmanager.domain.model.AnalysisResult -import ru.rznnike.eyehealthmanager.domain.model.SingleEyeAnalysisResult -import ru.rznnike.eyehealthmanager.domain.model.enums.AnalysisType +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisResult +import ru.rznnike.eyehealthmanager.domain.model.analysis.SingleEyeAnalysisResult +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisType import ru.rznnike.eyehealthmanager.domain.model.exception.NotEnoughDataException import java.time.Clock import java.time.Instant diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/result/AnalysisResultPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/result/AnalysisResultPresenterTest.kt index 89b93d56..bd8e3cfe 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/result/AnalysisResultPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/analysis/result/AnalysisResultPresenterTest.kt @@ -6,8 +6,8 @@ import org.mockito.Mock import org.mockito.junit.jupiter.MockitoExtension import org.mockito.kotlin.verify import org.mockito.kotlin.verifyNoMoreInteractions -import ru.rznnike.eyehealthmanager.domain.model.AnalysisResult -import ru.rznnike.eyehealthmanager.domain.model.SingleEyeAnalysisResult +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisResult +import ru.rznnike.eyehealthmanager.domain.model.analysis.SingleEyeAnalysisResult @ExtendWith(MockitoExtension::class) class AnalysisResultPresenterTest { diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/app/AppPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/app/AppPresenterTest.kt index c7df3ecb..bc04c5c5 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/app/AppPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/app/AppPresenterTest.kt @@ -11,8 +11,8 @@ import org.mockito.Mockito.verify import org.mockito.Mockito.verifyNoInteractions import org.mockito.kotlin.mock import ru.rznnike.eyehealthmanager.app.dispatcher.external.ExternalIntentDispatcher -import ru.rznnike.eyehealthmanager.domain.model.ExternalIntentData -import ru.rznnike.eyehealthmanager.domain.model.Notification +import ru.rznnike.eyehealthmanager.domain.model.common.ExternalIntentData +import ru.rznnike.eyehealthmanager.domain.model.notification.Notification class AppPresenterTest : KoinTest { private val mockExternalIntentDispatcher: ExternalIntentDispatcher by inject() diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/answer/AstigmatismAnswerPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/answer/AstigmatismAnswerPresenterTest.kt index ad5d508e..263bfa90 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/answer/AstigmatismAnswerPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/answer/AstigmatismAnswerPresenterTest.kt @@ -36,8 +36,8 @@ import ru.rznnike.eyehealthmanager.app.ui.fragment.astigmatism.result.Astigmatis import ru.rznnike.eyehealthmanager.app.utils.screenMatcher import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseResult import ru.rznnike.eyehealthmanager.domain.interactor.test.AddTestResultUseCase -import ru.rznnike.eyehealthmanager.domain.model.AstigmatismTestResult -import ru.rznnike.eyehealthmanager.domain.model.enums.AstigmatismAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.astigmatism.AstigmatismTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.astigmatism.AstigmatismAnswerType import java.time.Clock import java.time.Instant import java.time.ZoneOffset diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/result/AstigmatismResultPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/result/AstigmatismResultPresenterTest.kt index 64884cec..3c540aec 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/result/AstigmatismResultPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/result/AstigmatismResultPresenterTest.kt @@ -6,7 +6,7 @@ import org.mockito.Mock import org.mockito.junit.jupiter.MockitoExtension import org.mockito.kotlin.only import org.mockito.kotlin.verify -import ru.rznnike.eyehealthmanager.domain.model.enums.AstigmatismAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.astigmatism.AstigmatismAnswerType @ExtendWith(MockitoExtension::class) class AstigmatismResultPresenterTest { diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/test/AstigmatismTestPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/test/AstigmatismTestPresenterTest.kt index f31cad28..b7897b9c 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/test/AstigmatismTestPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/astigmatism/test/AstigmatismTestPresenterTest.kt @@ -30,7 +30,7 @@ import ru.rznnike.eyehealthmanager.app.ui.fragment.astigmatism.answer.Astigmatis import ru.rznnike.eyehealthmanager.app.utils.screenMatcher import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseResult import ru.rznnike.eyehealthmanager.domain.interactor.user.GetTestingSettingsUseCase -import ru.rznnike.eyehealthmanager.domain.model.TestingSettings +import ru.rznnike.eyehealthmanager.domain.model.test.TestingSettings @ExtendWith(MockitoExtension::class) class AstigmatismTestPresenterTest : KoinTest { diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/colorperception/test/ColorPerceptionTestPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/colorperception/test/ColorPerceptionTestPresenterTest.kt index 2aeb59fb..29a36ed4 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/colorperception/test/ColorPerceptionTestPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/colorperception/test/ColorPerceptionTestPresenterTest.kt @@ -36,8 +36,8 @@ import ru.rznnike.eyehealthmanager.app.ui.fragment.colorperception.result.ColorP import ru.rznnike.eyehealthmanager.app.utils.screenMatcher import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseResult import ru.rznnike.eyehealthmanager.domain.interactor.test.AddTestResultUseCase -import ru.rznnike.eyehealthmanager.domain.model.ColorPerceptionTestData -import ru.rznnike.eyehealthmanager.domain.model.ColorPerceptionTestResult +import ru.rznnike.eyehealthmanager.app.model.test.colorperception.ColorPerceptionTestData +import ru.rznnike.eyehealthmanager.domain.model.test.colorperception.ColorPerceptionTestResult import java.time.Clock import java.time.Instant import java.time.ZoneOffset diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/contrast/test/ContrastTestPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/contrast/test/ContrastTestPresenterTest.kt index 347a6cad..0c1009ce 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/contrast/test/ContrastTestPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/contrast/test/ContrastTestPresenterTest.kt @@ -39,8 +39,8 @@ import ru.rznnike.eyehealthmanager.app.utils.floatEquals import ru.rznnike.eyehealthmanager.app.utils.screenMatcher import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseResult import ru.rznnike.eyehealthmanager.domain.interactor.test.AddTestResultUseCase -import ru.rznnike.eyehealthmanager.domain.model.ContrastTestResult -import ru.rznnike.eyehealthmanager.domain.model.enums.Direction +import ru.rznnike.eyehealthmanager.domain.model.test.contrast.ContrastTestResult +import ru.rznnike.eyehealthmanager.domain.model.common.Direction import java.time.Clock import java.time.Instant import java.time.ZoneOffset diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/daltonism/result/DaltonismResultPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/daltonism/result/DaltonismResultPresenterTest.kt index 76497cb3..67d8b038 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/daltonism/result/DaltonismResultPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/daltonism/result/DaltonismResultPresenterTest.kt @@ -6,7 +6,7 @@ import org.mockito.Mock import org.mockito.junit.jupiter.MockitoExtension import org.mockito.kotlin.only import org.mockito.kotlin.verify -import ru.rznnike.eyehealthmanager.domain.model.enums.DaltonismAnomalyType +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismAnomalyType @ExtendWith(MockitoExtension::class) class DaltonismResultPresenterTest { diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/daltonism/test/DaltonismTestPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/daltonism/test/DaltonismTestPresenterTest.kt index 4db37b70..ce02cb0a 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/daltonism/test/DaltonismTestPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/daltonism/test/DaltonismTestPresenterTest.kt @@ -37,9 +37,9 @@ import ru.rznnike.eyehealthmanager.app.ui.fragment.daltonism.result.DaltonismRes import ru.rznnike.eyehealthmanager.app.utils.screenMatcher import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseResult import ru.rznnike.eyehealthmanager.domain.interactor.test.AddTestResultUseCase -import ru.rznnike.eyehealthmanager.domain.model.DaltonismTestData -import ru.rznnike.eyehealthmanager.domain.model.DaltonismTestResult -import ru.rznnike.eyehealthmanager.domain.model.enums.DaltonismAnomalyType +import ru.rznnike.eyehealthmanager.app.model.test.daltonism.DaltonismTestData +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismAnomalyType import java.time.Clock import java.time.Instant import java.time.ZoneOffset diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/journal/backup/ExportJournalPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/journal/backup/ExportJournalPresenterTest.kt index bd06c1ab..8081f854 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/journal/backup/ExportJournalPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/journal/backup/ExportJournalPresenterTest.kt @@ -37,10 +37,11 @@ import ru.rznnike.eyehealthmanager.app.dispatcher.event.AppEvent import ru.rznnike.eyehealthmanager.app.dispatcher.event.EventDispatcher import ru.rznnike.eyehealthmanager.app.dispatcher.notifier.Notifier import ru.rznnike.eyehealthmanager.app.global.presentation.ErrorHandler +import ru.rznnike.eyehealthmanager.app.utils.JournalBackupManagerAndroid +import ru.rznnike.eyehealthmanager.data.utils.DataConstants import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseResult import ru.rznnike.eyehealthmanager.domain.interactor.test.ExportJournalUseCase -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType -import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants +import ru.rznnike.eyehealthmanager.domain.model.test.TestType import java.time.Clock import java.time.Instant import java.time.ZoneOffset @@ -61,6 +62,7 @@ class ExportJournalPresenterTest : KoinTest { private val mockNotifier: Notifier by inject() private val mockEventDispatcher: EventDispatcher by inject() private val mockContext: Context by inject() + private val mockJournalBackupManagerAndroid: JournalBackupManagerAndroid by inject() private val mockExportJournalUseCase: ExportJournalUseCase by inject() private val testDispatcher = StandardTestDispatcher() @@ -75,6 +77,7 @@ class ExportJournalPresenterTest : KoinTest { single { mock() } single { mock() } single { mock() } + single { mock() } single { mock() } } ) @@ -126,7 +129,7 @@ class ExportJournalPresenterTest : KoinTest { && (filter.dateTo == 1705622399999L) && (filter.selectedTestTypes.isEmpty()) }, - folderPath = eq("${testUrl}/${GlobalConstants.APP_DIR}/${GlobalConstants.EXPORT_DIR}") + folderPath = eq("${testUrl}/${DataConstants.APP_DIR}/${DataConstants.EXPORT_DIR}") ) verifyNoMoreInteractionsForAll() } @@ -161,7 +164,7 @@ class ExportJournalPresenterTest : KoinTest { && (filter.dateTo == 1705622399999L) && (filter.selectedTestTypes.isEmpty()) }, - folderPath = eq("${testUrl}/${GlobalConstants.APP_DIR}/${GlobalConstants.EXPORT_DIR}") + folderPath = eq("${testUrl}/${DataConstants.APP_DIR}/${DataConstants.EXPORT_DIR}") ) verifyNoMoreInteractionsForAll() } @@ -196,7 +199,7 @@ class ExportJournalPresenterTest : KoinTest { && (filter.dateTo == 1705622399999L) && (filter.selectedTestTypes == listOf(selectedType)) }, - folderPath = eq("${testUrl}/${GlobalConstants.APP_DIR}/${GlobalConstants.EXPORT_DIR}") + folderPath = eq("${testUrl}/${DataConstants.APP_DIR}/${DataConstants.EXPORT_DIR}") ) verifyNoMoreInteractionsForAll() } @@ -232,7 +235,7 @@ class ExportJournalPresenterTest : KoinTest { && (filter.dateTo == 1705622399999L) && (filter.selectedTestTypes.isEmpty()) }, - folderPath = eq("${testUrl}/${GlobalConstants.APP_DIR}/${GlobalConstants.EXPORT_DIR}") + folderPath = eq("${testUrl}/${DataConstants.APP_DIR}/${DataConstants.EXPORT_DIR}") ) verifyNoMoreInteractionsForAll() } @@ -267,7 +270,7 @@ class ExportJournalPresenterTest : KoinTest { && (filter.dateTo == 1705622399999L) && (filter.selectedTestTypes.isEmpty()) }, - folderPath = eq("${testUrl}/${GlobalConstants.APP_DIR}/${GlobalConstants.EXPORT_DIR}") + folderPath = eq("${testUrl}/${DataConstants.APP_DIR}/${DataConstants.EXPORT_DIR}") ) verifyNoMoreInteractionsForAll() } @@ -302,7 +305,7 @@ class ExportJournalPresenterTest : KoinTest { && (filter.dateTo == 1705622399999L) && (filter.selectedTestTypes.isEmpty()) }, - folderPath = eq("${testUrl}/${GlobalConstants.APP_DIR}/${GlobalConstants.EXPORT_DIR}") + folderPath = eq("${testUrl}/${DataConstants.APP_DIR}/${DataConstants.EXPORT_DIR}") ) verifyNoMoreInteractionsForAll() } @@ -337,7 +340,7 @@ class ExportJournalPresenterTest : KoinTest { && (filter.dateTo == 1705622399999L) && (filter.selectedTestTypes.isEmpty()) }, - folderPath = eq("${testUrl}/${GlobalConstants.APP_DIR}/${GlobalConstants.EXPORT_DIR}") + folderPath = eq("${testUrl}/${DataConstants.APP_DIR}/${DataConstants.EXPORT_DIR}") ) verifyNoMoreInteractionsForAll() } @@ -372,7 +375,7 @@ class ExportJournalPresenterTest : KoinTest { && (filter.dateTo == 1705795199999L) && (filter.selectedTestTypes.isEmpty()) }, - folderPath = eq("${testUrl}/${GlobalConstants.APP_DIR}/${GlobalConstants.EXPORT_DIR}") + folderPath = eq("${testUrl}/${DataConstants.APP_DIR}/${DataConstants.EXPORT_DIR}") ) verifyNoMoreInteractionsForAll() } @@ -407,7 +410,7 @@ class ExportJournalPresenterTest : KoinTest { && (filter.dateTo == 1705363199999L) && (filter.selectedTestTypes.isEmpty()) }, - folderPath = eq("${testUrl}/${GlobalConstants.APP_DIR}/${GlobalConstants.EXPORT_DIR}") + folderPath = eq("${testUrl}/${DataConstants.APP_DIR}/${DataConstants.EXPORT_DIR}") ) verifyNoMoreInteractionsForAll() } @@ -442,7 +445,7 @@ class ExportJournalPresenterTest : KoinTest { && (filter.dateTo == 1701907199999L) && (filter.selectedTestTypes.isEmpty()) }, - folderPath = eq("${testUrl}/${GlobalConstants.APP_DIR}/${GlobalConstants.EXPORT_DIR}") + folderPath = eq("${testUrl}/${DataConstants.APP_DIR}/${DataConstants.EXPORT_DIR}") ) verifyNoMoreInteractionsForAll() } @@ -470,7 +473,9 @@ class ExportJournalPresenterTest : KoinTest { testScheduler.advanceUntilIdle() verify(mockView).setProgress(show = true, immediately = true) + verify(mockJournalBackupManagerAndroid).context = mockContext verify(mockExportJournalUseCase)(any()) + verify(mockJournalBackupManagerAndroid).context = null verify(mockEventDispatcher).sendEvent( argThat { (this is AppEvent.JournalExported) @@ -503,8 +508,10 @@ class ExportJournalPresenterTest : KoinTest { testScheduler.advanceUntilIdle() verify(mockView).setProgress(show = true, immediately = true) + verify(mockJournalBackupManagerAndroid).context = mockContext verify(mockExportJournalUseCase)(any()) verify(mockErrorHandler).proceed(any(), any()) + verify(mockJournalBackupManagerAndroid).context = null verify(mockView).setProgress(show = false, immediately = true) verifyNoMoreInteractionsForAll() } @@ -538,6 +545,7 @@ class ExportJournalPresenterTest : KoinTest { mockNotifier, mockEventDispatcher, mockContext, + mockJournalBackupManagerAndroid, mockExportJournalUseCase ) } diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/journal/restore/ImportJournalPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/journal/restore/ImportJournalPresenterTest.kt index 4a15f294..f1857a72 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/journal/restore/ImportJournalPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/journal/restore/ImportJournalPresenterTest.kt @@ -1,5 +1,6 @@ package ru.rznnike.eyehealthmanager.app.presentation.journal.restore +import android.content.Context import android.net.Uri import com.github.terrakok.cicerone.androidx.ActivityScreen import kotlinx.coroutines.Dispatchers @@ -35,10 +36,11 @@ import ru.rznnike.eyehealthmanager.app.dispatcher.event.AppEvent import ru.rznnike.eyehealthmanager.app.dispatcher.event.EventDispatcher import ru.rznnike.eyehealthmanager.app.dispatcher.notifier.Notifier import ru.rznnike.eyehealthmanager.app.global.presentation.ErrorHandler +import ru.rznnike.eyehealthmanager.app.utils.JournalBackupManagerAndroid +import ru.rznnike.eyehealthmanager.app.utils.createTestDispatcherProvider import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseResult -import ru.rznnike.eyehealthmanager.domain.interactor.test.GetAvailableImportTypesUseCase import ru.rznnike.eyehealthmanager.domain.interactor.test.ImportJournalUseCase -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType +import ru.rznnike.eyehealthmanager.domain.model.test.TestType @ExtendWith(MockitoExtension::class) class ImportJournalPresenterTest : KoinTest { @@ -48,10 +50,12 @@ class ImportJournalPresenterTest : KoinTest { private val mockErrorHandler: ErrorHandler by inject() private val mockNotifier: Notifier by inject() private val mockEventDispatcher: EventDispatcher by inject() - private val mockGetAvailableImportTypesUseCase: GetAvailableImportTypesUseCase by inject() + private val mockJournalBackupManagerAndroid: JournalBackupManagerAndroid by inject() private val mockImportJournalUseCase: ImportJournalUseCase by inject() + private val mockContext: Context by inject() private val testDispatcher = StandardTestDispatcher() + private val testDispatcherProvider = testDispatcher.createTestDispatcherProvider() @JvmField @RegisterExtension @@ -61,8 +65,10 @@ class ImportJournalPresenterTest : KoinTest { single { mock() } single { mock() } single { mock() } - single { mock() } + single { mock() } single { mock() } + single { mock() } + single { testDispatcherProvider } } ) } @@ -100,7 +106,7 @@ class ImportJournalPresenterTest : KoinTest { @Test fun onFolderSelected_success_checkAvailableData() = runTest { val availableTypes = listOf(TestType.ACUITY) - whenever(mockGetAvailableImportTypesUseCase(any())).doReturn(UseCaseResult(availableTypes)) + whenever(mockJournalBackupManagerAndroid.getAvailableImportTypes(any())).doReturn(availableTypes) val presenter = ImportJournalPresenter() presenter.attachView(mockView) val url = "test" @@ -109,11 +115,13 @@ class ImportJournalPresenterTest : KoinTest { } clearInvocationsForAll() - presenter.onFolderSelected(mockUri) + presenter.onFolderSelected(mockUri, mockContext) testScheduler.advanceUntilIdle() verify(mockView).setProgress(true) - verify(mockGetAvailableImportTypesUseCase)(mockUri) + verify(mockJournalBackupManagerAndroid).context = mockContext + verify(mockJournalBackupManagerAndroid).getAvailableImportTypes(mockUri) + verify(mockJournalBackupManagerAndroid).context = null verify(mockView).populateData( availableImportTypes = availableTypes, folderPath = url @@ -125,7 +133,7 @@ class ImportJournalPresenterTest : KoinTest { @Test fun onFolderSelected_startImportAutomatically_importFiles() = runTest { val availableTypes = listOf(TestType.ACUITY) - whenever(mockGetAvailableImportTypesUseCase(any())).doReturn(UseCaseResult(availableTypes)) + whenever(mockJournalBackupManagerAndroid.getAvailableImportTypes(any())).doReturn(availableTypes) whenever(mockImportJournalUseCase(any())).doReturn(UseCaseResult(Unit)) val presenter = ImportJournalPresenter() presenter.attachView(mockView) @@ -133,52 +141,41 @@ class ImportJournalPresenterTest : KoinTest { val mockUri = mock { on { lastPathSegment } doReturn url } - presenter.importFiles() + presenter.importFiles(mockContext) testScheduler.advanceUntilIdle() clearInvocationsForAll() - presenter.onFolderSelected(mockUri) + presenter.onFolderSelected(mockUri, mockContext) testScheduler.advanceUntilIdle() verify(mockView, times(2)).setProgress(true) - verify(mockGetAvailableImportTypesUseCase)(mockUri) + verify(mockJournalBackupManagerAndroid, times(2)).context = mockContext + verify(mockJournalBackupManagerAndroid).getAvailableImportTypes(mockUri) + verify(mockJournalBackupManagerAndroid, times(2)).context = null verify(mockView).populateData( availableImportTypes = availableTypes, folderPath = url ) verify(mockView, times(2)).setProgress(false) // import part - verify(mockImportJournalUseCase)(mockUri) + verify(mockImportJournalUseCase)( + argThat { + (importFolderUri == mockUri) + && (manager == mockJournalBackupManagerAndroid) + } + ) verify(mockEventDispatcher).sendEvent(AppEvent.JournalImported(mockUri)) verify(mockView).routerExit() verifyNoMoreInteractionsForAll() } - @Test - fun onFolderSelected_exception_errorHandler() = runTest { - whenever(mockGetAvailableImportTypesUseCase(any())).doReturn(UseCaseResult(error = Exception())) - val presenter = ImportJournalPresenter() - presenter.attachView(mockView) - val mockUri = mock() - clearInvocationsForAll() - - presenter.onFolderSelected(mockUri) - testScheduler.advanceUntilIdle() - - verify(mockView).setProgress(true) - verify(mockGetAvailableImportTypesUseCase)(mockUri) - verify(mockErrorHandler).proceed(any(), any()) - verify(mockView).setProgress(false) - verifyNoMoreInteractionsForAll() - } - @Test fun importFiles_folderNotSelected_requestSelection() = runTest { val presenter = ImportJournalPresenter() presenter.attachView(mockView) clearInvocationsForAll() - presenter.importFiles() + presenter.importFiles(mockContext) testScheduler.advanceUntilIdle() verify(mockView).selectImportFolder() @@ -187,18 +184,18 @@ class ImportJournalPresenterTest : KoinTest { @Test fun importFiles_noData_showMessage() = runTest { - whenever(mockGetAvailableImportTypesUseCase(any())).doReturn(UseCaseResult(emptyList())) + whenever(mockJournalBackupManagerAndroid.getAvailableImportTypes(any())).doReturn(emptyList()) val presenter = ImportJournalPresenter() presenter.attachView(mockView) val url = "test" val mockUri = mock { on { lastPathSegment } doReturn url } - presenter.onFolderSelected(mockUri) + presenter.onFolderSelected(mockUri, mockContext) testScheduler.advanceUntilIdle() clearInvocationsForAll() - presenter.importFiles() + presenter.importFiles(mockContext) testScheduler.advanceUntilIdle() verify(mockNotifier).sendMessage(R.string.error_no_backup_in_folder) @@ -208,7 +205,7 @@ class ImportJournalPresenterTest : KoinTest { @Test fun importFiles_withDataAndSuccess_closeScreen() = runTest { val availableTypes = listOf(TestType.ACUITY) - whenever(mockGetAvailableImportTypesUseCase(any())).doReturn(UseCaseResult(availableTypes)) + whenever(mockJournalBackupManagerAndroid.getAvailableImportTypes(any())).doReturn(availableTypes) whenever(mockImportJournalUseCase(any())).doReturn(UseCaseResult(Unit)) val presenter = ImportJournalPresenter() presenter.attachView(mockView) @@ -216,15 +213,22 @@ class ImportJournalPresenterTest : KoinTest { val mockUri = mock { on { lastPathSegment } doReturn url } - presenter.onFolderSelected(mockUri) + presenter.onFolderSelected(mockUri, mockContext) testScheduler.advanceUntilIdle() clearInvocationsForAll() - presenter.importFiles() + presenter.importFiles(mockContext) testScheduler.advanceUntilIdle() verify(mockView).setProgress(true) - verify(mockImportJournalUseCase)(mockUri) + verify(mockJournalBackupManagerAndroid).context = mockContext + verify(mockImportJournalUseCase)( + argThat { + (importFolderUri == mockUri) + && (manager == mockJournalBackupManagerAndroid) + } + ) + verify(mockJournalBackupManagerAndroid).context = null verify(mockEventDispatcher).sendEvent(AppEvent.JournalImported(mockUri)) verify(mockView).routerExit() verify(mockView).setProgress(false) @@ -234,7 +238,7 @@ class ImportJournalPresenterTest : KoinTest { @Test fun importFiles_withDataAndException_errorHandler() = runTest { val availableTypes = listOf(TestType.ACUITY) - whenever(mockGetAvailableImportTypesUseCase(any())).doReturn(UseCaseResult(availableTypes)) + whenever(mockJournalBackupManagerAndroid.getAvailableImportTypes(any())).doReturn(availableTypes) whenever(mockImportJournalUseCase(any())).doReturn(UseCaseResult(error = Exception())) val presenter = ImportJournalPresenter() presenter.attachView(mockView) @@ -242,15 +246,22 @@ class ImportJournalPresenterTest : KoinTest { val mockUri = mock { on { lastPathSegment } doReturn url } - presenter.onFolderSelected(mockUri) + presenter.onFolderSelected(mockUri, mockContext) testScheduler.advanceUntilIdle() clearInvocationsForAll() - presenter.importFiles() + presenter.importFiles(mockContext) testScheduler.advanceUntilIdle() verify(mockView).setProgress(true) - verify(mockImportJournalUseCase)(mockUri) + verify(mockJournalBackupManagerAndroid).context = mockContext + verify(mockImportJournalUseCase)( + argThat { + (importFolderUri == mockUri) + && (manager == mockJournalBackupManagerAndroid) + } + ) + verify(mockJournalBackupManagerAndroid).context = null verify(mockErrorHandler).proceed(any(), any()) verify(mockView).setProgress(false) verifyNoMoreInteractionsForAll() @@ -269,14 +280,14 @@ class ImportJournalPresenterTest : KoinTest { @Test fun openImportFolder_folderSelected_openFolderFlow() = runTest { - whenever(mockGetAvailableImportTypesUseCase(any())).doReturn(UseCaseResult(emptyList())) + whenever(mockJournalBackupManagerAndroid.getAvailableImportTypes(any())).doReturn(emptyList()) val presenter = ImportJournalPresenter() presenter.attachView(mockView) val url = "test" val mockUri = mock { on { lastPathSegment } doReturn url } - presenter.onFolderSelected(mockUri) + presenter.onFolderSelected(mockUri, mockContext) testScheduler.advanceUntilIdle() clearInvocationsForAll() @@ -297,8 +308,9 @@ class ImportJournalPresenterTest : KoinTest { mockErrorHandler, mockNotifier, mockEventDispatcher, - mockGetAvailableImportTypesUseCase, - mockImportJournalUseCase + mockJournalBackupManagerAndroid, + mockImportJournalUseCase, + mockContext ) } diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/main/journal/JournalPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/main/journal/JournalPresenterTest.kt index fbf1caf4..2252f7e9 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/main/journal/JournalPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/main/journal/JournalPresenterTest.kt @@ -47,16 +47,16 @@ import ru.rznnike.eyehealthmanager.app.utils.screenMatcher import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseResult import ru.rznnike.eyehealthmanager.domain.interactor.test.DeleteTestResultUseCase import ru.rznnike.eyehealthmanager.domain.interactor.test.GetTestResultsUseCase -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestResult -import ru.rznnike.eyehealthmanager.domain.model.AstigmatismTestResult -import ru.rznnike.eyehealthmanager.domain.model.ColorPerceptionTestResult -import ru.rznnike.eyehealthmanager.domain.model.ContrastTestResult -import ru.rznnike.eyehealthmanager.domain.model.DaltonismTestResult -import ru.rznnike.eyehealthmanager.domain.model.NearFarTestResult -import ru.rznnike.eyehealthmanager.domain.model.TestResult -import ru.rznnike.eyehealthmanager.domain.model.TestResultFilter -import ru.rznnike.eyehealthmanager.domain.model.enums.DaltonismAnomalyType -import ru.rznnike.eyehealthmanager.domain.model.enums.NearFarAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.astigmatism.AstigmatismTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.colorperception.ColorPerceptionTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.contrast.ContrastTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultFilter +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismAnomalyType +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarAnswerType import java.time.Clock import java.util.TimeZone diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/main/settings/SettingsPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/main/settings/SettingsPresenterTest.kt index 28e98ccd..3255964d 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/main/settings/SettingsPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/main/settings/SettingsPresenterTest.kt @@ -40,8 +40,8 @@ import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseResult import ru.rznnike.eyehealthmanager.domain.interactor.dev.GenerateDataUseCase import ru.rznnike.eyehealthmanager.domain.interactor.user.GetAppThemeUseCase import ru.rznnike.eyehealthmanager.domain.interactor.user.SetAppThemeUseCase -import ru.rznnike.eyehealthmanager.domain.model.enums.AppTheme -import ru.rznnike.eyehealthmanager.domain.model.enums.DataGenerationType +import ru.rznnike.eyehealthmanager.domain.model.common.AppTheme +import ru.rznnike.eyehealthmanager.domain.model.common.DataGenerationType @ExtendWith(MockitoExtension::class) class SettingsPresenterTest : KoinTest { diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/main/tests/TestsPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/main/tests/TestsPresenterTest.kt index fe9ea1d8..58796eba 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/main/tests/TestsPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/main/tests/TestsPresenterTest.kt @@ -14,7 +14,7 @@ import ru.rznnike.eyehealthmanager.app.ui.fragment.contrast.ContrastFlowFragment import ru.rznnike.eyehealthmanager.app.ui.fragment.daltonism.DaltonismFlowFragment import ru.rznnike.eyehealthmanager.app.ui.fragment.nearfar.NearFarFlowFragment import ru.rznnike.eyehealthmanager.app.utils.screenMatcher -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType +import ru.rznnike.eyehealthmanager.domain.model.test.TestType import kotlin.reflect.KClass @ExtendWith(MockitoExtension::class) diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/nearfar/answer/NearFarAnswerPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/nearfar/answer/NearFarAnswerPresenterTest.kt index 81f72d1f..6fa1f30f 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/nearfar/answer/NearFarAnswerPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/nearfar/answer/NearFarAnswerPresenterTest.kt @@ -36,8 +36,8 @@ import ru.rznnike.eyehealthmanager.app.ui.fragment.nearfar.result.NearFarResultF import ru.rznnike.eyehealthmanager.app.utils.screenMatcher import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseResult import ru.rznnike.eyehealthmanager.domain.interactor.test.AddTestResultUseCase -import ru.rznnike.eyehealthmanager.domain.model.NearFarTestResult -import ru.rznnike.eyehealthmanager.domain.model.enums.NearFarAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarAnswerType import java.time.Clock import java.time.Instant import java.time.ZoneOffset diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/nearfar/result/NearFarResultPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/nearfar/result/NearFarResultPresenterTest.kt index 4746b2e8..0b9d44a0 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/nearfar/result/NearFarResultPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/nearfar/result/NearFarResultPresenterTest.kt @@ -6,7 +6,7 @@ import org.mockito.Mock import org.mockito.junit.jupiter.MockitoExtension import org.mockito.kotlin.only import org.mockito.kotlin.verify -import ru.rznnike.eyehealthmanager.domain.model.enums.NearFarAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarAnswerType @ExtendWith(MockitoExtension::class) class NearFarResultPresenterTest { diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/settings/testing/TestingSettingsPresenterTest.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/settings/testing/TestingSettingsPresenterTest.kt index d471dc42..fcd59be0 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/settings/testing/TestingSettingsPresenterTest.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/presentation/settings/testing/TestingSettingsPresenterTest.kt @@ -33,11 +33,11 @@ import ru.rznnike.eyehealthmanager.app.dispatcher.event.EventDispatcher import ru.rznnike.eyehealthmanager.app.dispatcher.notifier.Notifier import ru.rznnike.eyehealthmanager.app.global.presentation.ErrorHandler import ru.rznnike.eyehealthmanager.app.utils.createTestCoroutineProvider +import ru.rznnike.eyehealthmanager.data.utils.DataConstants import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseResult import ru.rznnike.eyehealthmanager.domain.interactor.user.GetTestingSettingsUseCase import ru.rznnike.eyehealthmanager.domain.interactor.user.SetTestingSettingsUseCase -import ru.rznnike.eyehealthmanager.domain.model.TestingSettings -import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants +import ru.rznnike.eyehealthmanager.domain.model.test.TestingSettings import java.util.TimeZone import kotlin.math.abs @@ -223,8 +223,8 @@ class TestingSettingsPresenterTest : KoinTest { verify(mockView).populateData( argThat { (timeToDayBeginning == newValue) - && (timeToDayMiddle == newValue + GlobalConstants.MINUTE_MS) - && (timeToDayEnd == newValue + 2 * GlobalConstants.MINUTE_MS) + && (timeToDayMiddle == newValue + DataConstants.MINUTE_MS) + && (timeToDayEnd == newValue + 2 * DataConstants.MINUTE_MS) } ) verifyNoMoreInteractionsForAll() @@ -274,9 +274,9 @@ class TestingSettingsPresenterTest : KoinTest { verify(mockView).populateData( argThat { - (timeToDayBeginning == newValue + 2 * GlobalConstants.MINUTE_MS) + (timeToDayBeginning == newValue + 2 * DataConstants.MINUTE_MS) && (timeToDayMiddle == newValue) - && (timeToDayEnd == newValue + GlobalConstants.MINUTE_MS) + && (timeToDayEnd == newValue + DataConstants.MINUTE_MS) } ) verifyNoMoreInteractionsForAll() @@ -326,8 +326,8 @@ class TestingSettingsPresenterTest : KoinTest { verify(mockView).populateData( argThat { - (timeToDayBeginning == newValue + GlobalConstants.MINUTE_MS) - && (timeToDayMiddle == newValue + 2 * GlobalConstants.MINUTE_MS) + (timeToDayBeginning == newValue + DataConstants.MINUTE_MS) + && (timeToDayMiddle == newValue + 2 * DataConstants.MINUTE_MS) && (timeToDayEnd == newValue) } ) diff --git a/app/src/test/java/ru/rznnike/eyehealthmanager/app/utils/TestUtils.kt b/app/src/test/java/ru/rznnike/eyehealthmanager/app/utils/TestUtils.kt index 4fab0f97..c561b36f 100644 --- a/app/src/test/java/ru/rznnike/eyehealthmanager/app/utils/TestUtils.kt +++ b/app/src/test/java/ru/rznnike/eyehealthmanager/app/utils/TestUtils.kt @@ -1,26 +1,36 @@ package ru.rznnike.eyehealthmanager.app.utils import androidx.fragment.app.Fragment +import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import org.mockito.ArgumentMatchers.floatThat import org.mockito.kotlin.argThat import ru.rznnike.eyehealthmanager.app.navigation.FragmentScreenWithArguments -import ru.rznnike.eyehealthmanager.domain.global.CoroutineProvider +import ru.rznnike.eyehealthmanager.domain.global.CoroutineScopeProvider +import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider import kotlin.math.abs import kotlin.reflect.KClass -fun CoroutineScope.createTestCoroutineProvider() = object : CoroutineProvider { - override val scopeIo = this@createTestCoroutineProvider - override val scopeMain = this@createTestCoroutineProvider - override val scopeMainImmediate = this@createTestCoroutineProvider - override val scopeUnconfined = this@createTestCoroutineProvider +fun CoroutineScope.createTestCoroutineProvider() = object : CoroutineScopeProvider { + override val ui = this@createTestCoroutineProvider + override val default = this@createTestCoroutineProvider + override val io = this@createTestCoroutineProvider + override val unconfined = this@createTestCoroutineProvider +} + +fun CoroutineDispatcher.createTestDispatcherProvider(): DispatcherProvider = object : + DispatcherProvider { + override val ui = this@createTestDispatcherProvider + override val default = this@createTestDispatcherProvider + override val io = this@createTestDispatcherProvider + override val unconfined = this@createTestDispatcherProvider } fun screenMatcher( fragmentClass: KClass, argumentsValidation: ((Map) -> Boolean)? = null ) = argThat { - (screenKey == fragmentClass.java.name) && (argumentsValidation?.invoke(arguments) ?: true) + (screenKey == fragmentClass.java.name) && (argumentsValidation?.invoke(arguments) != false) } fun floatEquals(value: Float, precision: Float = 1e-4f) = floatThat { abs((it ?: 0f) - value) < precision } \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index e745b20d..49a09140 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,16 +1,17 @@ buildscript { extra.apply { - set("VERSION_CODE", 17) - set("VERSION_NAME", "2.2.1.${extra["VERSION_CODE"]}") + set("VERSION_CODE", 18) + set("VERSION_NAME", "2.3.0.${extra["VERSION_CODE"]}") set("APK_NAME", "Eye Health Manager") set("MIN_SDK", 24) - set("TARGET_SDK", 34) + set("TARGET_SDK", 35) - set("kotlinVersion", "1.9.22") - set("coroutinesVersion", "1.7.3") - set("objectboxVersion", "3.7.1") - set("koinVersion", "3.5.3") - set("junitVersion", "5.10.1") + set("kotlinVersion", "2.0.21") + set("coroutinesVersion", "1.9.0") + set("objectboxVersion", "4.0.2") + set("koinVersion", "4.0.0") + set("junitVersion", "5.11.2") + set("desugaringVersion", "2.1.2") } repositories { @@ -19,10 +20,10 @@ buildscript { maven(url = "https://jitpack.io") } dependencies { - classpath("com.android.tools.build:gradle:8.2.2") + classpath("com.android.tools.build:gradle:8.7.1") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProject.extra["kotlinVersion"]}") - classpath("com.google.firebase:firebase-crashlytics-gradle:2.9.9") - classpath("com.google.gms:google-services:4.4.0") + classpath("com.google.firebase:firebase-crashlytics-gradle:3.0.2") + classpath("com.google.gms:google-services:4.4.2") classpath("io.objectbox:objectbox-gradle-plugin:${rootProject.extra["objectboxVersion"]}") } } diff --git a/data/build.gradle.kts b/data/build.gradle.kts index 076a2b53..e9f2496d 100644 --- a/data/build.gradle.kts +++ b/data/build.gradle.kts @@ -48,15 +48,11 @@ android { dependencies { implementation(project(":domain")) - implementation(project(":resources")) val stagingApi by configurations // Desugaring - coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4") - - // AndroidX - implementation("androidx.documentfile:documentfile:1.0.1") + coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:" + rootProject.extra["desugaringVersion"]) // Shared preferences // https://github.com/tfcporciuncula/flow-preferences diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/gateway/AnalysisGatewayImpl.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/gateway/AnalysisGatewayImpl.kt index fe4a7d2c..c108fbfd 100644 --- a/data/src/main/java/ru/rznnike/eyehealthmanager/data/gateway/AnalysisGatewayImpl.kt +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/gateway/AnalysisGatewayImpl.kt @@ -1,11 +1,28 @@ package ru.rznnike.eyehealthmanager.data.gateway -import ru.rznnike.eyehealthmanager.domain.storage.repository.TestRepository +import kotlinx.coroutines.withContext +import ru.rznnike.eyehealthmanager.data.utils.DataConstants import ru.rznnike.eyehealthmanager.domain.gateway.AnalysisGateway -import ru.rznnike.eyehealthmanager.domain.model.* -import ru.rznnike.eyehealthmanager.domain.model.enums.* +import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisParameters +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisResult +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisStatistics +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisType +import ru.rznnike.eyehealthmanager.domain.model.analysis.DynamicCorrectionsData +import ru.rznnike.eyehealthmanager.domain.model.analysis.EyeChartPoint +import ru.rznnike.eyehealthmanager.domain.model.analysis.FunctionPoint +import ru.rznnike.eyehealthmanager.domain.model.analysis.LinearFunction +import ru.rznnike.eyehealthmanager.domain.model.analysis.SingleEyeAnalysisResult +import ru.rznnike.eyehealthmanager.domain.model.analysis.VisionDynamicType +import ru.rznnike.eyehealthmanager.domain.model.common.DayPart import ru.rznnike.eyehealthmanager.domain.model.exception.NotEnoughDataException -import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultFilter +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultPagingParameters +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType +import ru.rznnike.eyehealthmanager.domain.model.test.TestType +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestResultGroup +import ru.rznnike.eyehealthmanager.domain.storage.repository.TestRepository import java.time.Clock import kotlin.math.abs import kotlin.math.max @@ -15,18 +32,19 @@ import kotlin.math.roundToLong private const val WARNING_VISION_DIFFERENCE_THRESHOLD = 20 private const val VISION_DYNAMIC_TYPE_THRESHOLD = 5 private const val NOISE_MIN_POINTS_COUNT = 5 -private const val NOISE_MIN_DATE_DELTA_MS = 5 * GlobalConstants.DAY_MS -private const val NOISE_MAX_DATE_DELTA_MS = 10 * GlobalConstants.DAY_MS +private const val NOISE_MIN_DATE_DELTA_MS = 5 * DataConstants.DAY_MS +private const val NOISE_MAX_DATE_DELTA_MS = 10 * DataConstants.DAY_MS private const val NOISE_FILTER_THRESHOLD = 30 -private const val EXTRAPOLATION_MAX_DATE_DELTA_MS = 90 * GlobalConstants.DAY_MS +private const val EXTRAPOLATION_MAX_DATE_DELTA_MS = 90 * DataConstants.DAY_MS private const val EXTRAPOLATION_RESULT_DATE_DIVIDER = 3 -private const val CORRECTIONS_DATE_DELTA_MS = 7 * GlobalConstants.DAY_MS +private const val CORRECTIONS_DATE_DELTA_MS = 7 * DataConstants.DAY_MS class AnalysisGatewayImpl( + private val dispatcherProvider: DispatcherProvider, private val testRepository: TestRepository, private val clock: Clock ) : AnalysisGateway { - override suspend fun getAnalysisResult(parameters: AnalysisParameters): AnalysisResult { + override suspend fun getAnalysisResult(parameters: AnalysisParameters): AnalysisResult = withContext(dispatcherProvider.io) { val acuitySearchParameters = TestResultPagingParameters( offset = 0, limit = Int.MAX_VALUE, @@ -41,7 +59,7 @@ class AnalysisGatewayImpl( val acuityResults = testRepository.getList(acuitySearchParameters) - if (acuityResults.size < GlobalConstants.ANALYSIS_MIN_RESULTS_COUNT) { + if (acuityResults.size < DataConstants.ANALYSIS_MIN_RESULTS_COUNT) { throw NotEnoughDataException() } @@ -96,7 +114,7 @@ class AnalysisGatewayImpl( rightEyeData = rightEyeAnalysisResult.statistics ) - return AnalysisResult( + AnalysisResult( testResults = allLastResults, leftEyeAnalysisResult = leftEyeAnalysisResult, rightEyeAnalysisResult = rightEyeAnalysisResult, @@ -308,9 +326,9 @@ class AnalysisGatewayImpl( ) currentGroup?.run { values.add(item) - val groupIsFilled = ((values.size >= GlobalConstants.ANALYSIS_GROUPING_MIN_SIZE) - && ((item.timestamp - dateFrom) >= GlobalConstants.ANALYSIS_GROUPING_MIN_RANGE_MS)) - || ((item.timestamp - dateFrom) > GlobalConstants.ANALYSIS_GROUPING_MAX_RANGE_MS) + val groupIsFilled = ((values.size >= DataConstants.ANALYSIS_GROUPING_MIN_SIZE) + && ((item.timestamp - dateFrom) >= DataConstants.ANALYSIS_GROUPING_MIN_RANGE_MS)) + || ((item.timestamp - dateFrom) > DataConstants.ANALYSIS_GROUPING_MAX_RANGE_MS) if (groupIsFilled) { groups.add(this) currentGroup = null @@ -324,7 +342,7 @@ class AnalysisGatewayImpl( var index = 0 while (index < groups.size) { val group = groups[index] - if ((group.values.size < GlobalConstants.ANALYSIS_GROUPING_MIN_SIZE) && (groups.size > 1)) { + if ((group.values.size < DataConstants.ANALYSIS_GROUPING_MIN_SIZE) && (groups.size > 1)) { val previousGroup = groups.getOrNull(index - 1) val nextGroup = groups.getOrNull(index + 1) when { @@ -345,7 +363,7 @@ class AnalysisGatewayImpl( } } - if (groups.size < GlobalConstants.ANALYSIS_MIN_GROUPS_COUNT) { + if (groups.size < DataConstants.ANALYSIS_MIN_GROUPS_COUNT) { throw NotEnoughDataException() } return groups @@ -417,7 +435,7 @@ class AnalysisGatewayImpl( else -> { val lastTimestamp = groupedResults.last().dateTo val lastGroups = groupedResults.filter { - (lastTimestamp - it.dateFrom) < GlobalConstants.ANALYSIS_MAX_RANGE_MS + (lastTimestamp - it.dateFrom) < DataConstants.ANALYSIS_MAX_RANGE_MS } val averageValue = chartData diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/gateway/DevGatewayImpl.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/gateway/DevGatewayImpl.kt index 9cf49ece..b940bd29 100644 --- a/data/src/main/java/ru/rznnike/eyehealthmanager/data/gateway/DevGatewayImpl.kt +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/gateway/DevGatewayImpl.kt @@ -1,33 +1,36 @@ package ru.rznnike.eyehealthmanager.data.gateway +import kotlinx.coroutines.withContext +import ru.rznnike.eyehealthmanager.data.utils.DataConstants import ru.rznnike.eyehealthmanager.domain.gateway.DevGateway -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestResult -import ru.rznnike.eyehealthmanager.domain.model.AstigmatismTestResult -import ru.rznnike.eyehealthmanager.domain.model.ColorPerceptionTestResult -import ru.rznnike.eyehealthmanager.domain.model.ContrastTestResult -import ru.rznnike.eyehealthmanager.domain.model.DaltonismTestResult -import ru.rznnike.eyehealthmanager.domain.model.LinearFunction -import ru.rznnike.eyehealthmanager.domain.model.NearFarTestResult -import ru.rznnike.eyehealthmanager.domain.model.TestResult -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuityTestSymbolsType -import ru.rznnike.eyehealthmanager.domain.model.enums.AstigmatismAnswerType -import ru.rznnike.eyehealthmanager.domain.model.enums.DaltonismAnomalyType -import ru.rznnike.eyehealthmanager.domain.model.enums.DataGenerationType -import ru.rznnike.eyehealthmanager.domain.model.enums.DayPart -import ru.rznnike.eyehealthmanager.domain.model.enums.NearFarAnswerType -import ru.rznnike.eyehealthmanager.domain.model.enums.TestEyesType +import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider +import ru.rznnike.eyehealthmanager.domain.model.analysis.LinearFunction +import ru.rznnike.eyehealthmanager.domain.model.common.DataGenerationType +import ru.rznnike.eyehealthmanager.domain.model.common.DayPart +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestSymbolsType +import ru.rznnike.eyehealthmanager.domain.model.test.astigmatism.AstigmatismAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.astigmatism.AstigmatismTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.colorperception.ColorPerceptionTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.contrast.ContrastTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismAnomalyType +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarTestResult import ru.rznnike.eyehealthmanager.domain.storage.repository.TestRepository -import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants import ru.rznnike.eyehealthmanager.domain.utils.millis import ru.rznnike.eyehealthmanager.domain.utils.toLocalDate import java.time.Clock import kotlin.random.Random class DevGatewayImpl( + private val dispatcherProvider: DispatcherProvider, private val testRepository: TestRepository, private val clock: Clock ) : DevGateway { - override suspend fun generateData(type: DataGenerationType) { + override suspend fun generateData(type: DataGenerationType) = withContext(dispatcherProvider.io) { when (type) { DataGenerationType.GOOD_VISION -> generateAcuityTests( leftEyeTrend = LinearFunction(0.002, 0.7), @@ -49,9 +52,9 @@ class DevGatewayImpl( leftEyeTrend: LinearFunction, rightEyeTrend: LinearFunction ) { - var dateTime = clock.millis().toLocalDate().minusDays(GlobalConstants.ANALYSIS_MAX_RANGE_DAYS).atStartOfDay() + var dateTime = clock.millis().toLocalDate().minusDays(DataConstants.ANALYSIS_MAX_RANGE_DAYS).atStartOfDay() val tests = mutableListOf() - for (day in 0 until GlobalConstants.ANALYSIS_MAX_RANGE_DAYS) { + for (day in 0 until DataConstants.ANALYSIS_MAX_RANGE_DAYS) { tests.add( AcuityTestResult( timestamp = dateTime.millis() + Random.nextInt(30_000_000), // nearly first 8 hours of day diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/gateway/NotificationGatewayImpl.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/gateway/NotificationGatewayImpl.kt index 9ad3bd12..70c95f0d 100644 --- a/data/src/main/java/ru/rznnike/eyehealthmanager/data/gateway/NotificationGatewayImpl.kt +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/gateway/NotificationGatewayImpl.kt @@ -1,24 +1,33 @@ package ru.rznnike.eyehealthmanager.data.gateway import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.flow.asSharedFlow +import kotlinx.coroutines.withContext import ru.rznnike.eyehealthmanager.domain.gateway.NotificationGateway -import ru.rznnike.eyehealthmanager.domain.model.CancelNotification -import ru.rznnike.eyehealthmanager.domain.model.Notification +import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider +import ru.rznnike.eyehealthmanager.domain.model.notification.CancelNotification +import ru.rznnike.eyehealthmanager.domain.model.notification.Notification -class NotificationGatewayImpl : NotificationGateway { +class NotificationGatewayImpl( + private val dispatcherProvider: DispatcherProvider +) : NotificationGateway { private val notificationFlow = MutableSharedFlow() private val cancelNotificationFlow = MutableSharedFlow() - override suspend fun emitShowNotification(notification: Notification) = + override suspend fun emitShowNotification(notification: Notification) = withContext(dispatcherProvider.default) { notificationFlow.emit(notification) + } - override suspend fun emitCancelNotification(cancelNotification: CancelNotification) = + override suspend fun emitCancelNotification(cancelNotification: CancelNotification) = withContext(dispatcherProvider.default) { cancelNotificationFlow.emit(cancelNotification) + } - override suspend fun observeCancelNotification() = + override suspend fun observeCancelNotification(): SharedFlow = withContext(dispatcherProvider.io) { cancelNotificationFlow.asSharedFlow() + } - override suspend fun observeShowNotification() = + override suspend fun observeShowNotification(): SharedFlow = withContext(dispatcherProvider.io) { notificationFlow.asSharedFlow() + } } \ No newline at end of file diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/gateway/TestGatewayImpl.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/gateway/TestGatewayImpl.kt index 1461e3b6..601ebf20 100644 --- a/data/src/main/java/ru/rznnike/eyehealthmanager/data/gateway/TestGatewayImpl.kt +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/gateway/TestGatewayImpl.kt @@ -1,200 +1,63 @@ package ru.rznnike.eyehealthmanager.data.gateway import android.annotation.SuppressLint -import android.content.Context import android.net.Uri -import androidx.documentfile.provider.DocumentFile -import ru.rznnike.eyehealthmanager.domain.storage.repository.TestRepository +import kotlinx.coroutines.withContext +import ru.rznnike.eyehealthmanager.data.utils.DataConstants import ru.rznnike.eyehealthmanager.domain.gateway.TestGateway -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestResult -import ru.rznnike.eyehealthmanager.domain.model.AstigmatismTestResult -import ru.rznnike.eyehealthmanager.domain.model.ColorPerceptionTestResult -import ru.rznnike.eyehealthmanager.domain.model.ContrastTestResult -import ru.rznnike.eyehealthmanager.domain.model.DaltonismTestResult -import ru.rznnike.eyehealthmanager.domain.model.NearFarTestResult -import ru.rznnike.eyehealthmanager.domain.model.TestResult -import ru.rznnike.eyehealthmanager.domain.model.TestResultFilter -import ru.rznnike.eyehealthmanager.domain.model.TestResultPagingParameters -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType -import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants -import ru.rznnike.eyehealthmanager.domain.utils.toDate -import java.io.BufferedWriter -import java.io.IOException +import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultFilter +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultPagingParameters +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult +import ru.rznnike.eyehealthmanager.domain.storage.repository.TestRepository +import ru.rznnike.eyehealthmanager.domain.utils.JournalBackupManager import java.time.Clock -import java.util.EnumMap class TestGatewayImpl( + private val dispatcherProvider: DispatcherProvider, private val testRepository: TestRepository, - private val context: Context, private val clock: Clock ) : TestGateway { - override suspend fun getTestResults(parameters: TestResultPagingParameters) = + override suspend fun getTestResults(parameters: TestResultPagingParameters): List = withContext(dispatcherProvider.io) { testRepository.getList(parameters) + } - override suspend fun addTestResult(item: TestResult) = + override suspend fun addTestResult(item: TestResult): Long = withContext(dispatcherProvider.io) { testRepository.add(item) + } - override suspend fun deleteTestResultById(id: Long) = + override suspend fun deleteTestResultById(id: Long) = withContext(dispatcherProvider.io) { testRepository.delete(id) + } - override suspend fun deleteAllTestResults() = + override suspend fun deleteAllTestResults() = withContext(dispatcherProvider.io) { testRepository.deleteAll() + } - override suspend fun deleteDuplicates() = + override suspend fun deleteDuplicates() = withContext(dispatcherProvider.io) { testRepository.deleteDuplicates() - - @SuppressLint("Recycle") - override suspend fun exportJournal(filter: TestResultFilter): Uri? { - fun DocumentFile.findOrCreateDocumentFolder(name: String) = findFile(name) ?: createDirectory(name) - - var exportFolderUri: Uri? = null - val exportFiles: MutableMap = EnumMap(TestType::class.java) - val exportFileWriters: MutableMap = EnumMap(TestType::class.java) - val exportEntryCounters: MutableMap = EnumMap(TestType::class.java) - - context.contentResolver - .persistedUriPermissions - .firstOrNull() - ?.uri - ?.let { DocumentFile.fromTreeUri(context, it) } - ?.findOrCreateDocumentFolder(GlobalConstants.APP_DIR) - ?.findOrCreateDocumentFolder(GlobalConstants.EXPORT_DIR) - ?.findOrCreateDocumentFolder( - clock.millis().toDate(GlobalConstants.DATE_PATTERN_FULL_FOR_PATH) - ) - ?.let { folder -> - try { - exportFolderUri = folder.uri - TestType.entries.forEach { type -> - val fileName = type.toString().lowercase() - folder.createFile( - "text/tab-separated-values", - "${fileName}.tsv" - )?.let { file -> - context.contentResolver - .openOutputStream(file.uri) - ?.bufferedWriter() - ?.let { - exportFileWriters[type] = it - it.appendLine(type.exportHeader) - } - - exportFiles[type] = file - exportEntryCounters[type] = 0 - } - } - - var dataCounter = 0 - do { - val page = writeJournalPageToFiles( - filter = filter, - pageOffset = dataCounter, - exportFileWriters = exportFileWriters, - exportEntryCounters = exportEntryCounters - ) - dataCounter += page - } while (page == GlobalConstants.EXPORT_PAGE_SIZE) - } finally { - exportFileWriters.forEach { - try { - it.value.close() - if (exportEntryCounters[it.key] == 0) { - exportFiles[it.key]?.delete() - } - } catch (e: IOException) { - e.printStackTrace() - } - } - } - } - return exportFolderUri } - private suspend fun writeJournalPageToFiles( - filter: TestResultFilter, - pageOffset: Int, - exportFileWriters: MutableMap, - exportEntryCounters: MutableMap - ): Int { - val data = testRepository.getList( - TestResultPagingParameters( - limit = GlobalConstants.EXPORT_PAGE_SIZE, - offset = pageOffset, - filter = filter + @SuppressLint("Recycle") + override suspend fun exportJournal(filter: TestResultFilter, manager: JournalBackupManager): Uri? = withContext(dispatcherProvider.io) { + manager.exportJournal( + filter = filter, + clock = clock + ) { callbackFilter: TestResultFilter, pageOffset: Int -> + testRepository.getList( + TestResultPagingParameters( + limit = DataConstants.EXPORT_PAGE_SIZE, + offset = pageOffset, + filter = callbackFilter + ) ) - ) - data.forEach { testResult -> - when (testResult) { - is AcuityTestResult -> TestType.ACUITY - is AstigmatismTestResult -> TestType.ASTIGMATISM - is ColorPerceptionTestResult -> TestType.COLOR_PERCEPTION - is ContrastTestResult -> TestType.CONTRAST - is DaltonismTestResult -> TestType.DALTONISM - is NearFarTestResult -> TestType.NEAR_FAR - else -> null - }?.let { type -> - val exportString = testResult.exportToString() - exportFileWriters[type]?.appendLine(exportString) - exportEntryCounters[type] = exportEntryCounters.getOrDefault(type, 0) + 1 - } } - exportFileWriters.values.forEach { - it.flush() - } - return data.size } - override suspend fun getAvailableImportTypes(importFolderUri: Uri) = - DocumentFile.fromTreeUri(context, importFolderUri) - ?.listFiles() - ?.filter { it.isFile } - ?.mapNotNull { file -> - val fileName = file.name?.removeSuffix(".tsv") - TestType.entries.firstOrNull { fileName == it.name.lowercase() } - } - ?.distinct() - ?: emptyList() - @SuppressLint("Recycle") - override suspend fun importJournal(importFolderUri: Uri) { - DocumentFile.fromTreeUri(context, importFolderUri) - ?.listFiles() - ?.filter { it.isFile } - ?.mapNotNull { file -> - val fileName = file.name?.removeSuffix(".tsv") - val type = TestType.entries.firstOrNull { fileName == it.name.lowercase() } - type?.let { type to file } - } - ?.distinctBy { it.first } - ?.forEach { mappedFile -> - val type = mappedFile.first - val file = mappedFile.second - val resultsBuffer = mutableListOf() - - context.contentResolver - .openInputStream(file.uri) - ?.bufferedReader() - ?.useLines { lines -> - lines - .mapNotNull { line -> - when (type) { - TestType.ACUITY -> AcuityTestResult.importFromString(line) - TestType.ASTIGMATISM -> AstigmatismTestResult.importFromString(line) - TestType.NEAR_FAR -> NearFarTestResult.importFromString(line) - TestType.COLOR_PERCEPTION -> ColorPerceptionTestResult.importFromString(line) - TestType.DALTONISM -> DaltonismTestResult.importFromString(line) - TestType.CONTRAST -> ContrastTestResult.importFromString(line) - } - } - .forEach { - resultsBuffer.add(it) - if (resultsBuffer.size >= GlobalConstants.IMPORT_PAGE_SIZE) { - testRepository.add(resultsBuffer) - resultsBuffer.clear() - } - } - testRepository.add(resultsBuffer) - } - } + override suspend fun importJournal(importFolderUri: Uri, manager: JournalBackupManager) = withContext(dispatcherProvider.io) { + manager.importJournal(importFolderUri) { results -> + testRepository.add(results) + } } } diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/gateway/UserGatewayImpl.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/gateway/UserGatewayImpl.kt index f5c812e8..926ebd1a 100644 --- a/data/src/main/java/ru/rznnike/eyehealthmanager/data/gateway/UserGatewayImpl.kt +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/gateway/UserGatewayImpl.kt @@ -1,29 +1,36 @@ package ru.rznnike.eyehealthmanager.data.gateway +import kotlinx.coroutines.withContext import ru.rznnike.eyehealthmanager.data.preference.PreferencesWrapper import ru.rznnike.eyehealthmanager.domain.gateway.UserGateway -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestingSettings -import ru.rznnike.eyehealthmanager.domain.model.TestingSettings -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuityTestSymbolsType -import ru.rznnike.eyehealthmanager.domain.model.enums.AppTheme -import ru.rznnike.eyehealthmanager.domain.model.enums.TestEyesType +import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestingSettings +import ru.rznnike.eyehealthmanager.domain.model.test.TestingSettings +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestSymbolsType +import ru.rznnike.eyehealthmanager.domain.model.common.AppTheme +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType class UserGatewayImpl( + private val dispatcherProvider: DispatcherProvider, private val preferences: PreferencesWrapper ) : UserGateway { - override suspend fun getWelcomeDialogShowed() = + override suspend fun getWelcomeDialogShowed(): Boolean = withContext(dispatcherProvider.io) { preferences.welcomeDialogShowed.get() + } - override suspend fun setWelcomeDialogShowed(newValue: Boolean) = + override suspend fun setWelcomeDialogShowed(newValue: Boolean) = withContext(dispatcherProvider.io) { preferences.welcomeDialogShowed.set(newValue) + } - override suspend fun getDisplayedChangelogVersion() = + override suspend fun getDisplayedChangelogVersion(): Int = withContext(dispatcherProvider.io) { preferences.displayedChangelogVersion.get() + } - override suspend fun setDisplayedChangelogVersion(newValue: Int) = + override suspend fun setDisplayedChangelogVersion(newValue: Int) = withContext(dispatcherProvider.io) { preferences.displayedChangelogVersion.set(newValue) + } - override suspend fun getTestingSettings() = + override suspend fun getTestingSettings(): TestingSettings = withContext(dispatcherProvider.io) { preferences.run { TestingSettings( armsLength = armsLength.get(), @@ -35,8 +42,9 @@ class UserGatewayImpl( timeToDayEnd = timeToDayEnd.get() ) } + } - override suspend fun setTestingSettings(newValue: TestingSettings) { + override suspend fun setTestingSettings(newValue: TestingSettings): Unit = withContext(dispatcherProvider.io) { preferences.apply { armsLength.set(newValue.armsLength) dotsPerMillimeter.set(newValue.dpmm) @@ -48,30 +56,35 @@ class UserGatewayImpl( } } - override suspend fun getAcuityTestingSettings() = + override suspend fun getAcuityTestingSettings(): AcuityTestingSettings = withContext(dispatcherProvider.io) { preferences.run { AcuityTestingSettings( symbolsType = AcuityTestSymbolsType[acuitySymbolsType.get()], eyesType = TestEyesType[testEyesType.get()] ) } + } - override suspend fun setAcuityTestingSettings(newValue: AcuityTestingSettings) { + override suspend fun setAcuityTestingSettings(newValue: AcuityTestingSettings): Unit = withContext(dispatcherProvider.io) { preferences.apply { acuitySymbolsType.set(newValue.symbolsType.id) testEyesType.set(newValue.eyesType.id) } } - override suspend fun getApplyDynamicCorrections() = + override suspend fun getApplyDynamicCorrections(): Boolean = withContext(dispatcherProvider.io) { preferences.applyDynamicCorrections.get() + } - override suspend fun setApplyDynamicCorrections(newValue: Boolean) = + override suspend fun setApplyDynamicCorrections(newValue: Boolean) = withContext(dispatcherProvider.io) { preferences.applyDynamicCorrections.set(newValue) + } - override suspend fun getAppTheme() = + override suspend fun getAppTheme(): AppTheme = withContext(dispatcherProvider.io) { AppTheme[preferences.appTheme.get()] + } - override suspend fun setAppTheme(appTheme: AppTheme) = + override suspend fun setAppTheme(appTheme: AppTheme) = withContext(dispatcherProvider.io) { preferences.appTheme.set(appTheme.id) + } } diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/preference/PreferencesWrapper.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/preference/PreferencesWrapper.kt index 473b82c2..ad6efd8f 100644 --- a/data/src/main/java/ru/rznnike/eyehealthmanager/data/preference/PreferencesWrapper.kt +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/preference/PreferencesWrapper.kt @@ -2,10 +2,9 @@ package ru.rznnike.eyehealthmanager.data.preference import com.fredporciuncula.flow.preferences.FlowSharedPreferences import com.fredporciuncula.flow.preferences.Preference -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuityTestSymbolsType -import ru.rznnike.eyehealthmanager.domain.model.enums.AppTheme -import ru.rznnike.eyehealthmanager.domain.model.enums.Language -import ru.rznnike.eyehealthmanager.domain.model.enums.TestEyesType +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestSymbolsType +import ru.rznnike.eyehealthmanager.domain.model.common.AppTheme +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType private const val ACUITY_SYMBOLS_TYPE = "ACUITY_SYMBOLS_TYPE_1" private const val TEST_EYES_TYPE = "TEST_EYES_TYPE_1" diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/AcuityTestSymbolsTypeConverter.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/AcuityTestSymbolsTypeConverter.kt index 23bdb2eb..613591a8 100644 --- a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/AcuityTestSymbolsTypeConverter.kt +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/AcuityTestSymbolsTypeConverter.kt @@ -1,7 +1,7 @@ package ru.rznnike.eyehealthmanager.data.storage.converter import io.objectbox.converter.PropertyConverter -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuityTestSymbolsType +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestSymbolsType class AcuityTestSymbolsTypeConverter : PropertyConverter { override fun convertToDatabaseValue(entityProperty: AcuityTestSymbolsType?) = diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/AstigmatismAnswerTypeConverter.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/AstigmatismAnswerTypeConverter.kt index 40ea6aab..d9da0ddb 100644 --- a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/AstigmatismAnswerTypeConverter.kt +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/AstigmatismAnswerTypeConverter.kt @@ -1,7 +1,7 @@ package ru.rznnike.eyehealthmanager.data.storage.converter import io.objectbox.converter.PropertyConverter -import ru.rznnike.eyehealthmanager.domain.model.enums.AstigmatismAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.astigmatism.AstigmatismAnswerType class AstigmatismAnswerTypeConverter : PropertyConverter { override fun convertToDatabaseValue(entityProperty: AstigmatismAnswerType?) = diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/DaltonismAnomalyTypeConverter.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/DaltonismAnomalyTypeConverter.kt index f3ecdad3..9ca1f53d 100644 --- a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/DaltonismAnomalyTypeConverter.kt +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/DaltonismAnomalyTypeConverter.kt @@ -1,7 +1,7 @@ package ru.rznnike.eyehealthmanager.data.storage.converter import io.objectbox.converter.PropertyConverter -import ru.rznnike.eyehealthmanager.domain.model.enums.DaltonismAnomalyType +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismAnomalyType class DaltonismAnomalyTypeConverter : PropertyConverter { override fun convertToDatabaseValue(entityProperty: DaltonismAnomalyType?) = diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/DayPartConverter.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/DayPartConverter.kt index 22c19a2e..924210a7 100644 --- a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/DayPartConverter.kt +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/DayPartConverter.kt @@ -1,7 +1,7 @@ package ru.rznnike.eyehealthmanager.data.storage.converter import io.objectbox.converter.PropertyConverter -import ru.rznnike.eyehealthmanager.domain.model.enums.DayPart +import ru.rznnike.eyehealthmanager.domain.model.common.DayPart class DayPartConverter : PropertyConverter { override fun convertToDatabaseValue(entityProperty: DayPart?) = diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/NearFarAnswerTypeConverter.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/NearFarAnswerTypeConverter.kt index 4d81dd30..a4b58dcf 100644 --- a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/NearFarAnswerTypeConverter.kt +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/NearFarAnswerTypeConverter.kt @@ -1,7 +1,7 @@ package ru.rznnike.eyehealthmanager.data.storage.converter import io.objectbox.converter.PropertyConverter -import ru.rznnike.eyehealthmanager.domain.model.enums.NearFarAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarAnswerType class NearFarAnswerTypeConverter : PropertyConverter { override fun convertToDatabaseValue(entityProperty: NearFarAnswerType?) = diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/TestEyesTypeConverter.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/TestEyesTypeConverter.kt index 37a44cbf..0edaca83 100644 --- a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/TestEyesTypeConverter.kt +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/TestEyesTypeConverter.kt @@ -1,7 +1,7 @@ package ru.rznnike.eyehealthmanager.data.storage.converter import io.objectbox.converter.PropertyConverter -import ru.rznnike.eyehealthmanager.domain.model.enums.TestEyesType +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType class TestEyesTypeConverter : PropertyConverter { override fun convertToDatabaseValue(entityProperty: TestEyesType?) = diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/TestTypeConverter.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/TestTypeConverter.kt index 0e5fcffd..c22dc692 100644 --- a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/TestTypeConverter.kt +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/converter/TestTypeConverter.kt @@ -1,7 +1,7 @@ package ru.rznnike.eyehealthmanager.data.storage.converter import io.objectbox.converter.PropertyConverter -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType +import ru.rznnike.eyehealthmanager.domain.model.test.TestType class TestTypeConverter : PropertyConverter { override fun convertToDatabaseValue(entityProperty: TestType?) = diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/dao/TestDAO.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/dao/TestDAO.kt index 7ed9de90..ebb3b722 100644 --- a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/dao/TestDAO.kt +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/dao/TestDAO.kt @@ -6,8 +6,8 @@ import ru.rznnike.eyehealthmanager.data.storage.entity.TestEntity import ru.rznnike.eyehealthmanager.data.storage.entity.TestEntity_ import ru.rznnike.eyehealthmanager.data.storage.global.BaseDAO import ru.rznnike.eyehealthmanager.data.storage.global.ITestDAO -import ru.rznnike.eyehealthmanager.domain.model.TestResultPagingParameters -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultPagingParameters +import ru.rznnike.eyehealthmanager.domain.model.test.TestType class TestDAO( boxStore: BoxStore diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/AcuityTestEntity.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/AcuityTestEntity.kt index b0fa6f9a..11e775dd 100644 --- a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/AcuityTestEntity.kt +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/AcuityTestEntity.kt @@ -6,10 +6,10 @@ import io.objectbox.annotation.Id import ru.rznnike.eyehealthmanager.data.storage.converter.AcuityTestSymbolsTypeConverter import ru.rznnike.eyehealthmanager.data.storage.converter.DayPartConverter import ru.rznnike.eyehealthmanager.data.storage.converter.TestEyesTypeConverter -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestResult -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuityTestSymbolsType -import ru.rznnike.eyehealthmanager.domain.model.enums.DayPart -import ru.rznnike.eyehealthmanager.domain.model.enums.TestEyesType +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestSymbolsType +import ru.rznnike.eyehealthmanager.domain.model.common.DayPart +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType @Entity data class AcuityTestEntity( diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/AstigmatismTestEntity.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/AstigmatismTestEntity.kt index 255e8303..9c234212 100644 --- a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/AstigmatismTestEntity.kt +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/AstigmatismTestEntity.kt @@ -4,8 +4,8 @@ import io.objectbox.annotation.Convert import io.objectbox.annotation.Entity import io.objectbox.annotation.Id import ru.rznnike.eyehealthmanager.data.storage.converter.AstigmatismAnswerTypeConverter -import ru.rznnike.eyehealthmanager.domain.model.AstigmatismTestResult -import ru.rznnike.eyehealthmanager.domain.model.enums.AstigmatismAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.astigmatism.AstigmatismTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.astigmatism.AstigmatismAnswerType @Entity data class AstigmatismTestEntity( diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/ColorPerceptionTestEntity.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/ColorPerceptionTestEntity.kt index 95801889..c1ce04fe 100644 --- a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/ColorPerceptionTestEntity.kt +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/ColorPerceptionTestEntity.kt @@ -2,7 +2,7 @@ package ru.rznnike.eyehealthmanager.data.storage.entity import io.objectbox.annotation.Entity import io.objectbox.annotation.Id -import ru.rznnike.eyehealthmanager.domain.model.ColorPerceptionTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.colorperception.ColorPerceptionTestResult @Entity data class ColorPerceptionTestEntity( diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/ContrastTestEntity.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/ContrastTestEntity.kt index a14dc7af..66b5343a 100644 --- a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/ContrastTestEntity.kt +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/ContrastTestEntity.kt @@ -2,7 +2,7 @@ package ru.rznnike.eyehealthmanager.data.storage.entity import io.objectbox.annotation.Entity import io.objectbox.annotation.Id -import ru.rznnike.eyehealthmanager.domain.model.ContrastTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.contrast.ContrastTestResult @Entity data class ContrastTestEntity( diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/DaltonismTestEntity.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/DaltonismTestEntity.kt index 1c08d2ff..d9c9c60d 100644 --- a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/DaltonismTestEntity.kt +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/DaltonismTestEntity.kt @@ -4,8 +4,8 @@ import io.objectbox.annotation.Convert import io.objectbox.annotation.Entity import io.objectbox.annotation.Id import ru.rznnike.eyehealthmanager.data.storage.converter.DaltonismAnomalyTypeConverter -import ru.rznnike.eyehealthmanager.domain.model.DaltonismTestResult -import ru.rznnike.eyehealthmanager.domain.model.enums.DaltonismAnomalyType +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismAnomalyType @Entity data class DaltonismTestEntity( diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/NearFarTestEntity.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/NearFarTestEntity.kt index 63aa1d9f..a1803e15 100644 --- a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/NearFarTestEntity.kt +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/NearFarTestEntity.kt @@ -4,8 +4,8 @@ import io.objectbox.annotation.Convert import io.objectbox.annotation.Entity import io.objectbox.annotation.Id import ru.rznnike.eyehealthmanager.data.storage.converter.NearFarAnswerTypeConverter -import ru.rznnike.eyehealthmanager.domain.model.NearFarTestResult -import ru.rznnike.eyehealthmanager.domain.model.enums.NearFarAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarAnswerType @Entity data class NearFarTestEntity( diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/TestEntity.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/TestEntity.kt index f09eca87..d953a52c 100644 --- a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/TestEntity.kt +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/entity/TestEntity.kt @@ -4,7 +4,7 @@ import io.objectbox.annotation.Convert import io.objectbox.annotation.Entity import io.objectbox.annotation.Id import ru.rznnike.eyehealthmanager.data.storage.converter.TestTypeConverter -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType +import ru.rznnike.eyehealthmanager.domain.model.test.TestType @Entity data class TestEntity( diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/repository/TestRepositoryImpl.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/repository/TestRepositoryImpl.kt index c32790c0..345312fe 100644 --- a/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/repository/TestRepositoryImpl.kt +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/storage/repository/TestRepositoryImpl.kt @@ -15,15 +15,15 @@ import ru.rznnike.eyehealthmanager.data.storage.entity.toColorPerceptionTestEnti import ru.rznnike.eyehealthmanager.data.storage.entity.toContrastTestEntity import ru.rznnike.eyehealthmanager.data.storage.entity.toDaltonismTestEntity import ru.rznnike.eyehealthmanager.data.storage.entity.toNearFarTestEntity -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestResult -import ru.rznnike.eyehealthmanager.domain.model.AstigmatismTestResult -import ru.rznnike.eyehealthmanager.domain.model.ColorPerceptionTestResult -import ru.rznnike.eyehealthmanager.domain.model.ContrastTestResult -import ru.rznnike.eyehealthmanager.domain.model.DaltonismTestResult -import ru.rznnike.eyehealthmanager.domain.model.NearFarTestResult -import ru.rznnike.eyehealthmanager.domain.model.TestResult -import ru.rznnike.eyehealthmanager.domain.model.TestResultPagingParameters -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.astigmatism.AstigmatismTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.colorperception.ColorPerceptionTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.contrast.ContrastTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultPagingParameters +import ru.rznnike.eyehealthmanager.domain.model.test.TestType import ru.rznnike.eyehealthmanager.domain.storage.repository.TestRepository class TestRepositoryImpl( diff --git a/data/src/main/java/ru/rznnike/eyehealthmanager/data/utils/DataConstants.kt b/data/src/main/java/ru/rznnike/eyehealthmanager/data/utils/DataConstants.kt new file mode 100644 index 00000000..86bbb7cb --- /dev/null +++ b/data/src/main/java/ru/rznnike/eyehealthmanager/data/utils/DataConstants.kt @@ -0,0 +1,21 @@ +package ru.rznnike.eyehealthmanager.data.utils + +object DataConstants { + const val EXPORT_PAGE_SIZE = 100 + const val IMPORT_PAGE_SIZE = 100 + const val APP_DIR = "Eye Health Manager" + const val EXPORT_DIR = "export" + + const val MINUTE_MS = 60_1000L + const val DAY_MS = 86_400_000L + + const val ANALYSIS_GROUPING_MIN_RANGE_DAYS = 3L + const val ANALYSIS_GROUPING_MIN_RANGE_MS = ANALYSIS_GROUPING_MIN_RANGE_DAYS * DAY_MS + const val ANALYSIS_GROUPING_MAX_RANGE_MS = 14 * DAY_MS + const val ANALYSIS_GROUPING_MIN_SIZE = 5 + const val ANALYSIS_MIN_GROUPS_COUNT = 2 + const val ANALYSIS_MIN_RESULTS_COUNT = ANALYSIS_GROUPING_MIN_SIZE * ANALYSIS_MIN_GROUPS_COUNT + const val ANALYSIS_MIN_RANGE_DAYS = ANALYSIS_GROUPING_MIN_RANGE_DAYS * ANALYSIS_MIN_GROUPS_COUNT + const val ANALYSIS_MAX_RANGE_DAYS = 90L + const val ANALYSIS_MAX_RANGE_MS = (ANALYSIS_MAX_RANGE_DAYS + 1) * DAY_MS - 1 // 90 days from day 1 start to day 90 end +} \ No newline at end of file diff --git a/data/src/test/java/ru/rznnike/eyehealthmanager/data/gateway/AnalysisGatewayImplTest.kt b/data/src/test/java/ru/rznnike/eyehealthmanager/data/gateway/AnalysisGatewayImplTest.kt index 66199ede..5de312a0 100644 --- a/data/src/test/java/ru/rznnike/eyehealthmanager/data/gateway/AnalysisGatewayImplTest.kt +++ b/data/src/test/java/ru/rznnike/eyehealthmanager/data/gateway/AnalysisGatewayImplTest.kt @@ -1,6 +1,12 @@ package ru.rznnike.eyehealthmanager.data.gateway +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.StandardTestDispatcher +import kotlinx.coroutines.test.resetMain import kotlinx.coroutines.test.runTest +import kotlinx.coroutines.test.setMain +import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertFalse import org.junit.jupiter.api.Assertions.assertNotNull @@ -9,28 +15,41 @@ import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestResult -import ru.rznnike.eyehealthmanager.domain.model.AnalysisParameters -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuityTestSymbolsType -import ru.rznnike.eyehealthmanager.domain.model.enums.AnalysisType -import ru.rznnike.eyehealthmanager.domain.model.enums.DataGenerationType -import ru.rznnike.eyehealthmanager.domain.model.enums.TestEyesType +import ru.rznnike.eyehealthmanager.data.utils.DataConstants +import ru.rznnike.eyehealthmanager.data.utils.createTestDispatcherProvider +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisParameters +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisType +import ru.rznnike.eyehealthmanager.domain.model.common.DataGenerationType import ru.rznnike.eyehealthmanager.domain.model.exception.NotEnoughDataException -import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestSymbolsType import ru.rznnike.eyehealthmanager.domain.utils.currentTimeMillis import java.time.Clock import java.util.TimeZone class AnalysisGatewayImplTest { + private val testDispatcher = StandardTestDispatcher() + private val testDispatcherProvider = testDispatcher.createTestDispatcherProvider() + + @OptIn(ExperimentalCoroutinesApi::class) @BeforeEach fun beforeEach() { + Dispatchers.setMain(testDispatcher) TimeZone.setDefault(TimeZone.getTimeZone("UTC")) } + @OptIn(ExperimentalCoroutinesApi::class) + @AfterEach + fun afterEach() { + Dispatchers.resetMain() + } + @Test fun getAnalysisResult_noData_exception() = runTest { val fakeTestRepository = FakeTestRepository() val gateway = AnalysisGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) @@ -53,6 +72,7 @@ class AnalysisGatewayImplTest { AcuityTestResult() ) val gateway = AnalysisGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) @@ -72,11 +92,13 @@ class AnalysisGatewayImplTest { fun getAnalysisResult_positiveData_noWarning() = runTest { val fakeTestRepository = FakeTestRepository() val generator = DevGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) generator.generateData(DataGenerationType.GOOD_VISION) val gateway = AnalysisGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) @@ -96,11 +118,13 @@ class AnalysisGatewayImplTest { fun getAnalysisResult_neutralData_noWarning() = runTest { val fakeTestRepository = FakeTestRepository() val generator = DevGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) generator.generateData(DataGenerationType.AVERAGE_VISION) val gateway = AnalysisGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) @@ -120,11 +144,13 @@ class AnalysisGatewayImplTest { fun getAnalysisResult_negativeData_warning() = runTest { val fakeTestRepository = FakeTestRepository() val generator = DevGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) generator.generateData(DataGenerationType.BAD_VISION) val gateway = AnalysisGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) @@ -144,6 +170,7 @@ class AnalysisGatewayImplTest { fun getAnalysisResult_withNoise_detected() = runTest { val fakeTestRepository = FakeTestRepository() val generator = DevGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) @@ -157,6 +184,7 @@ class AnalysisGatewayImplTest { resultRightEye = 10 ) val gateway = AnalysisGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) @@ -179,12 +207,14 @@ class AnalysisGatewayImplTest { fun getAnalysisResult_consolidated_withAllTests() = runTest { val fakeTestRepository = FakeTestRepository() val generator = DevGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) generator.generateData(DataGenerationType.GOOD_VISION) generator.generateData(DataGenerationType.OTHER_TESTS) val gateway = AnalysisGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) @@ -205,12 +235,14 @@ class AnalysisGatewayImplTest { fun getAnalysisResult_acuityOnly_withoutAllTests() = runTest { val fakeTestRepository = FakeTestRepository() val generator = DevGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) generator.generateData(DataGenerationType.GOOD_VISION) generator.generateData(DataGenerationType.OTHER_TESTS) val gateway = AnalysisGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) @@ -230,17 +262,19 @@ class AnalysisGatewayImplTest { fun getAnalysisResult_smallData_twoGroups() = runTest { val fakeTestRepository = FakeTestRepository() val generator = DevGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) generator.generateData(DataGenerationType.GOOD_VISION) val gateway = AnalysisGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) val lastTime = fakeTestRepository.tests.maxOf { it.timestamp } val parameters = AnalysisParameters( - dateFrom = lastTime - 10 * GlobalConstants.DAY_MS, + dateFrom = lastTime - 10 * DataConstants.DAY_MS, dateTo = currentTimeMillis(), analysisType = AnalysisType.CONSOLIDATED_REPORT, applyDynamicCorrections = true @@ -256,11 +290,13 @@ class AnalysisGatewayImplTest { fun getAnalysisResult_bigData_manyGroups() = runTest { val fakeTestRepository = FakeTestRepository() val generator = DevGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) generator.generateData(DataGenerationType.GOOD_VISION) val gateway = AnalysisGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) @@ -281,11 +317,13 @@ class AnalysisGatewayImplTest { fun getAnalysisResult_actualData_withExtrapolation() = runTest { val fakeTestRepository = FakeTestRepository() val generator = DevGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) generator.generateData(DataGenerationType.GOOD_VISION) val gateway = AnalysisGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) @@ -306,11 +344,13 @@ class AnalysisGatewayImplTest { fun getAnalysisResult_oldData_withoutExtrapolation() = runTest { val fakeTestRepository = FakeTestRepository() val generator = DevGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) generator.generateData(DataGenerationType.GOOD_VISION) val gateway = AnalysisGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) @@ -321,7 +361,7 @@ class AnalysisGatewayImplTest { applyDynamicCorrections = true ) - val timeOffset = 100 * GlobalConstants.DAY_MS + val timeOffset = 100 * DataConstants.DAY_MS fakeTestRepository.tests.forEach { it.timestamp -= timeOffset } diff --git a/data/src/test/java/ru/rznnike/eyehealthmanager/data/gateway/DevGatewayImplTest.kt b/data/src/test/java/ru/rznnike/eyehealthmanager/data/gateway/DevGatewayImplTest.kt index 90b6e953..533c2dfd 100644 --- a/data/src/test/java/ru/rznnike/eyehealthmanager/data/gateway/DevGatewayImplTest.kt +++ b/data/src/test/java/ru/rznnike/eyehealthmanager/data/gateway/DevGatewayImplTest.kt @@ -1,24 +1,42 @@ package ru.rznnike.eyehealthmanager.data.gateway +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.StandardTestDispatcher +import kotlinx.coroutines.test.resetMain import kotlinx.coroutines.test.runTest +import kotlinx.coroutines.test.setMain +import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestResult -import ru.rznnike.eyehealthmanager.domain.model.TestResultPagingParameters -import ru.rznnike.eyehealthmanager.domain.model.enums.DataGenerationType -import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants +import ru.rznnike.eyehealthmanager.data.utils.DataConstants +import ru.rznnike.eyehealthmanager.data.utils.createTestDispatcherProvider +import ru.rznnike.eyehealthmanager.domain.model.common.DataGenerationType +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultPagingParameters +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestResult import java.time.Clock import java.util.TimeZone import kotlin.math.abs class DevGatewayImplTest { + private val testDispatcher = StandardTestDispatcher() + private val testDispatcherProvider = testDispatcher.createTestDispatcherProvider() + + @OptIn(ExperimentalCoroutinesApi::class) @BeforeEach fun beforeEach() { + Dispatchers.setMain(testDispatcher) TimeZone.setDefault(TimeZone.getTimeZone("UTC")) } + @OptIn(ExperimentalCoroutinesApi::class) + @AfterEach + fun afterEach() { + Dispatchers.resetMain() + } + @Test fun generateData_goodVision_success() = runTest { val fakeTestRepository = FakeTestRepository() @@ -28,6 +46,7 @@ class DevGatewayImplTest { filter = null ) val gateway = DevGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) @@ -37,8 +56,8 @@ class DevGatewayImplTest { val filteredTests = tests.filterIsInstance() val delta = (filteredTests.last().resultLeftEye ?: 0) - (filteredTests.first().resultLeftEye ?: 0) - assertEquals(GlobalConstants.ANALYSIS_MAX_RANGE_DAYS, tests.size.toLong()) - assertEquals(GlobalConstants.ANALYSIS_MAX_RANGE_DAYS, filteredTests.size.toLong()) + assertEquals(DataConstants.ANALYSIS_MAX_RANGE_DAYS, tests.size.toLong()) + assertEquals(DataConstants.ANALYSIS_MAX_RANGE_DAYS, filteredTests.size.toLong()) assertTrue(delta > 10) } @@ -51,6 +70,7 @@ class DevGatewayImplTest { filter = null ) val gateway = DevGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) @@ -60,8 +80,8 @@ class DevGatewayImplTest { val filteredTests = tests.filterIsInstance() val delta = (filteredTests.last().resultLeftEye ?: 0) - (filteredTests.first().resultLeftEye ?: 0) - assertEquals(GlobalConstants.ANALYSIS_MAX_RANGE_DAYS, tests.size.toLong()) - assertEquals(GlobalConstants.ANALYSIS_MAX_RANGE_DAYS, filteredTests.size.toLong()) + assertEquals(DataConstants.ANALYSIS_MAX_RANGE_DAYS, tests.size.toLong()) + assertEquals(DataConstants.ANALYSIS_MAX_RANGE_DAYS, filteredTests.size.toLong()) assertTrue(abs(delta) < 7) } @@ -74,6 +94,7 @@ class DevGatewayImplTest { filter = null ) val gateway = DevGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) @@ -83,8 +104,8 @@ class DevGatewayImplTest { val filteredTests = tests.filterIsInstance() val delta = (filteredTests.last().resultLeftEye ?: 0) - (filteredTests.first().resultLeftEye ?: 0) - assertEquals(GlobalConstants.ANALYSIS_MAX_RANGE_DAYS, tests.size.toLong()) - assertEquals(GlobalConstants.ANALYSIS_MAX_RANGE_DAYS, filteredTests.size.toLong()) + assertEquals(DataConstants.ANALYSIS_MAX_RANGE_DAYS, tests.size.toLong()) + assertEquals(DataConstants.ANALYSIS_MAX_RANGE_DAYS, filteredTests.size.toLong()) assertTrue(delta < -10) } @@ -97,6 +118,7 @@ class DevGatewayImplTest { filter = null ) val gateway = DevGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = fakeTestRepository, clock = Clock.systemUTC() ) diff --git a/data/src/test/java/ru/rznnike/eyehealthmanager/data/gateway/FakeTestRepository.kt b/data/src/test/java/ru/rznnike/eyehealthmanager/data/gateway/FakeTestRepository.kt index 4aaddaac..832b3016 100644 --- a/data/src/test/java/ru/rznnike/eyehealthmanager/data/gateway/FakeTestRepository.kt +++ b/data/src/test/java/ru/rznnike/eyehealthmanager/data/gateway/FakeTestRepository.kt @@ -1,8 +1,8 @@ package ru.rznnike.eyehealthmanager.data.gateway -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestResult -import ru.rznnike.eyehealthmanager.domain.model.TestResult -import ru.rznnike.eyehealthmanager.domain.model.TestResultPagingParameters +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultPagingParameters import ru.rznnike.eyehealthmanager.domain.storage.repository.TestRepository class FakeTestRepository : TestRepository { @@ -13,7 +13,7 @@ class FakeTestRepository : TestRepository { parameters.filter?.let { filter -> ((!filter.filterByDate) || LongRange(filter.dateFrom, filter.dateTo).contains(testResult.timestamp)) && ((!filter.filterByType) || (testResult is AcuityTestResult)) - } ?: true + } != false } override suspend fun getListDistinctByType() = tests diff --git a/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/AbstractObjectBoxTest.kt b/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/AbstractObjectBoxTest.kt index 4a439f83..bf5e7159 100644 --- a/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/AbstractObjectBoxTest.kt +++ b/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/AbstractObjectBoxTest.kt @@ -12,7 +12,7 @@ open class AbstractObjectBoxTest { private set @BeforeEach - fun beforeEach() { + open fun beforeEach() { BoxStore.deleteAllFiles(TEST_DIRECTORY) store = MyObjectBox.builder() .directory(TEST_DIRECTORY) @@ -21,7 +21,7 @@ open class AbstractObjectBoxTest { } @AfterEach - fun afterEach() { + open fun afterEach() { store?.close() BoxStore.deleteAllFiles(TEST_DIRECTORY) } diff --git a/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/dao/AcuityTestDAOTest.kt b/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/dao/AcuityTestDAOTest.kt index 006d001b..2cbcc14a 100644 --- a/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/dao/AcuityTestDAOTest.kt +++ b/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/dao/AcuityTestDAOTest.kt @@ -9,9 +9,9 @@ import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test import ru.rznnike.eyehealthmanager.data.storage.AbstractObjectBoxTest import ru.rznnike.eyehealthmanager.data.storage.entity.AcuityTestEntity -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuityTestSymbolsType -import ru.rznnike.eyehealthmanager.domain.model.enums.DayPart -import ru.rznnike.eyehealthmanager.domain.model.enums.TestEyesType +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestSymbolsType +import ru.rznnike.eyehealthmanager.domain.model.common.DayPart +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType class AcuityTestDAOTest : AbstractObjectBoxTest() { @Test diff --git a/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/dao/AstigmatismTestDAOTest.kt b/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/dao/AstigmatismTestDAOTest.kt index fa431077..d05a8cd4 100644 --- a/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/dao/AstigmatismTestDAOTest.kt +++ b/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/dao/AstigmatismTestDAOTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test import ru.rznnike.eyehealthmanager.data.storage.AbstractObjectBoxTest import ru.rznnike.eyehealthmanager.data.storage.entity.AstigmatismTestEntity -import ru.rznnike.eyehealthmanager.domain.model.enums.AstigmatismAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.astigmatism.AstigmatismAnswerType class AstigmatismTestDAOTest : AbstractObjectBoxTest() { @Test diff --git a/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/dao/DaltonismTestDAOTest.kt b/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/dao/DaltonismTestDAOTest.kt index 2120caa3..8ae74210 100644 --- a/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/dao/DaltonismTestDAOTest.kt +++ b/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/dao/DaltonismTestDAOTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test import ru.rznnike.eyehealthmanager.data.storage.AbstractObjectBoxTest import ru.rznnike.eyehealthmanager.data.storage.entity.DaltonismTestEntity -import ru.rznnike.eyehealthmanager.domain.model.enums.DaltonismAnomalyType +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismAnomalyType class DaltonismTestDAOTest : AbstractObjectBoxTest() { @Test diff --git a/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/dao/NearFarTestDAOTest.kt b/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/dao/NearFarTestDAOTest.kt index f6b35a35..b4a27dc4 100644 --- a/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/dao/NearFarTestDAOTest.kt +++ b/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/dao/NearFarTestDAOTest.kt @@ -9,7 +9,7 @@ import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test import ru.rznnike.eyehealthmanager.data.storage.AbstractObjectBoxTest import ru.rznnike.eyehealthmanager.data.storage.entity.NearFarTestEntity -import ru.rznnike.eyehealthmanager.domain.model.enums.NearFarAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarAnswerType class NearFarTestDAOTest : AbstractObjectBoxTest() { @Test diff --git a/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/dao/TestDAOTest.kt b/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/dao/TestDAOTest.kt index ea1d3946..f803efbf 100644 --- a/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/dao/TestDAOTest.kt +++ b/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/dao/TestDAOTest.kt @@ -9,9 +9,9 @@ import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test import ru.rznnike.eyehealthmanager.data.storage.AbstractObjectBoxTest import ru.rznnike.eyehealthmanager.data.storage.entity.TestEntity -import ru.rznnike.eyehealthmanager.domain.model.TestResultFilter -import ru.rznnike.eyehealthmanager.domain.model.TestResultPagingParameters -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultFilter +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultPagingParameters +import ru.rznnike.eyehealthmanager.domain.model.test.TestType import ru.rznnike.eyehealthmanager.domain.utils.currentTimeMillis class TestDAOTest : AbstractObjectBoxTest() { diff --git a/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/repository/TestRepositoryImplTest.kt b/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/repository/TestRepositoryImplTest.kt index 51991634..e8bb0f59 100644 --- a/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/repository/TestRepositoryImplTest.kt +++ b/data/src/test/java/ru/rznnike/eyehealthmanager/data/storage/repository/TestRepositoryImplTest.kt @@ -1,8 +1,15 @@ package ru.rznnike.eyehealthmanager.data.storage.repository +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.StandardTestDispatcher +import kotlinx.coroutines.test.resetMain import kotlinx.coroutines.test.runTest +import kotlinx.coroutines.test.setMain +import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import ru.rznnike.eyehealthmanager.data.gateway.DevGatewayImpl import ru.rznnike.eyehealthmanager.data.storage.AbstractObjectBoxTest @@ -13,18 +20,36 @@ import ru.rznnike.eyehealthmanager.data.storage.dao.ContrastTestDAO import ru.rznnike.eyehealthmanager.data.storage.dao.DaltonismTestDAO import ru.rznnike.eyehealthmanager.data.storage.dao.NearFarTestDAO import ru.rznnike.eyehealthmanager.data.storage.dao.TestDAO -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestResult -import ru.rznnike.eyehealthmanager.domain.model.ContrastTestResult -import ru.rznnike.eyehealthmanager.domain.model.TestResult -import ru.rznnike.eyehealthmanager.domain.model.TestResultFilter -import ru.rznnike.eyehealthmanager.domain.model.TestResultPagingParameters -import ru.rznnike.eyehealthmanager.domain.model.enums.DataGenerationType -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType -import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants +import ru.rznnike.eyehealthmanager.data.utils.DataConstants +import ru.rznnike.eyehealthmanager.data.utils.createTestDispatcherProvider +import ru.rznnike.eyehealthmanager.domain.model.common.DataGenerationType +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultFilter +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultPagingParameters +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult +import ru.rznnike.eyehealthmanager.domain.model.test.TestType +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.contrast.ContrastTestResult import ru.rznnike.eyehealthmanager.domain.utils.currentTimeMillis import java.time.Clock class TestRepositoryImplTest : AbstractObjectBoxTest() { + private val testDispatcher = StandardTestDispatcher() + private val testDispatcherProvider = testDispatcher.createTestDispatcherProvider() + + @OptIn(ExperimentalCoroutinesApi::class) + @BeforeEach + override fun beforeEach() { + super.beforeEach() + Dispatchers.setMain(testDispatcher) + } + + @OptIn(ExperimentalCoroutinesApi::class) + @AfterEach + override fun afterEach() { + super.afterEach() + Dispatchers.resetMain() + } + @Test fun getList_empty_success() = runTest { val repository = createRepository() @@ -49,6 +74,7 @@ class TestRepositoryImplTest : AbstractObjectBoxTest() { fun getList_withData_success() = runTest { val repository = createRepository() val generator = DevGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = repository, clock = Clock.systemUTC() ) @@ -67,7 +93,7 @@ class TestRepositoryImplTest : AbstractObjectBoxTest() { val tests = repository.getList(parameters) - assertEquals(GlobalConstants.ANALYSIS_MAX_RANGE_DAYS, tests.size.toLong()) + assertEquals(DataConstants.ANALYSIS_MAX_RANGE_DAYS, tests.size.toLong()) } @Test @@ -111,6 +137,7 @@ class TestRepositoryImplTest : AbstractObjectBoxTest() { fun getList_filterByDate_success() = runTest { val repository = createRepository() val generator = DevGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = repository, clock = Clock.systemUTC() ) @@ -121,7 +148,7 @@ class TestRepositoryImplTest : AbstractObjectBoxTest() { filter = TestResultFilter( filterByDate = true, filterByType = false, - dateFrom = currentTimeMillis() - 10 * GlobalConstants.DAY_MS, + dateFrom = currentTimeMillis() - 10 * DataConstants.DAY_MS, dateTo = currentTimeMillis(), selectedTestTypes = mutableListOf() ) @@ -137,6 +164,7 @@ class TestRepositoryImplTest : AbstractObjectBoxTest() { fun getList_filterByType_success() = runTest { val repository = createRepository() val generator = DevGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = repository, clock = Clock.systemUTC() ) @@ -164,6 +192,7 @@ class TestRepositoryImplTest : AbstractObjectBoxTest() { fun getList_allFilters_success() = runTest { val repository = createRepository() val generator = DevGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = repository, clock = Clock.systemUTC() ) @@ -175,7 +204,7 @@ class TestRepositoryImplTest : AbstractObjectBoxTest() { filter = TestResultFilter( filterByDate = true, filterByType = true, - dateFrom = currentTimeMillis() - 10 * GlobalConstants.DAY_MS, + dateFrom = currentTimeMillis() - 10 * DataConstants.DAY_MS, dateTo = currentTimeMillis(), selectedTestTypes = mutableListOf(TestType.ACUITY) ) @@ -201,6 +230,7 @@ class TestRepositoryImplTest : AbstractObjectBoxTest() { fun getListDistinctByType_acuityOnly_success() = runTest { val repository = createRepository() val generator = DevGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = repository, clock = Clock.systemUTC() ) @@ -216,6 +246,7 @@ class TestRepositoryImplTest : AbstractObjectBoxTest() { fun getListDistinctByType_allTests_success() = runTest { val repository = createRepository() val generator = DevGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = repository, clock = Clock.systemUTC() ) @@ -393,6 +424,7 @@ class TestRepositoryImplTest : AbstractObjectBoxTest() { fun deleteAll_withData_success() = runTest { val repository = createRepository() val generator = DevGatewayImpl( + dispatcherProvider = testDispatcherProvider, testRepository = repository, clock = Clock.systemUTC() ) diff --git a/data/src/test/java/ru/rznnike/eyehealthmanager/data/utils/TestUtils.kt b/data/src/test/java/ru/rznnike/eyehealthmanager/data/utils/TestUtils.kt new file mode 100644 index 00000000..e5a1bb88 --- /dev/null +++ b/data/src/test/java/ru/rznnike/eyehealthmanager/data/utils/TestUtils.kt @@ -0,0 +1,11 @@ +package ru.rznnike.eyehealthmanager.data.utils + +import kotlinx.coroutines.CoroutineDispatcher +import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider + +fun CoroutineDispatcher.createTestDispatcherProvider(): DispatcherProvider = object : DispatcherProvider { + override val ui = this@createTestDispatcherProvider + override val default = this@createTestDispatcherProvider + override val io = this@createTestDispatcherProvider + override val unconfined = this@createTestDispatcherProvider +} \ No newline at end of file diff --git a/device/.gitignore b/device/.gitignore deleted file mode 100644 index 796b96d1..00000000 --- a/device/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/device/build.gradle.kts b/device/build.gradle.kts deleted file mode 100644 index 5faa6a69..00000000 --- a/device/build.gradle.kts +++ /dev/null @@ -1,56 +0,0 @@ -plugins { - id("com.android.library") - id("kotlin-android") -} - -android { - namespace = "ru.rznnike.eyehealthmanager.device" - - compileSdk = rootProject.extra["TARGET_SDK"] as Int - - defaultConfig { - minSdk = rootProject.extra["MIN_SDK"] as Int - } - - buildTypes { - debug { - isMinifyEnabled = false - } - register("staging") { - isMinifyEnabled = true - consumerProguardFiles("proguard-rules.pro") - } - release { - isMinifyEnabled = true - consumerProguardFiles("proguard-rules.pro") - } - } - - compileOptions { - isCoreLibraryDesugaringEnabled = true - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlin { - jvmToolchain(17) - } -} - -dependencies { - implementation(project(":data")) - implementation(project(":domain")) - - // Desugaring - coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4") - - // Firebase - api("com.google.firebase:firebase-core:21.1.1") - api("com.google.firebase:firebase-messaging:23.4.0") - - // Koin - api("io.insert-koin:koin-android:" + rootProject.extra["koinVersion"]) - - // Coroutines - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:" + rootProject.extra["coroutinesVersion"]) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:" + rootProject.extra["coroutinesVersion"]) -} diff --git a/device/proguard-rules.pro b/device/proguard-rules.pro deleted file mode 100644 index e69de29b..00000000 diff --git a/device/src/main/AndroidManifest.xml b/device/src/main/AndroidManifest.xml deleted file mode 100644 index cc947c56..00000000 --- a/device/src/main/AndroidManifest.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/domain/build.gradle.kts b/domain/build.gradle.kts index e3a60282..1692ae33 100644 --- a/domain/build.gradle.kts +++ b/domain/build.gradle.kts @@ -45,17 +45,11 @@ android { } dependencies { - implementation(project(":resources")) - // Desugaring - coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.4") - - // Android - api("androidx.core:core-ktx:1.12.0") + coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:" + rootProject.extra["desugaringVersion"]) // Coroutines implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:" + rootProject.extra["coroutinesVersion"]) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:" + rootProject.extra["coroutinesVersion"]) // Testing testImplementation("org.junit.jupiter:junit-jupiter:" + rootProject.extra["junitVersion"]) diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/gateway/AnalysisGateway.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/gateway/AnalysisGateway.kt index 858084ea..baefb899 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/gateway/AnalysisGateway.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/gateway/AnalysisGateway.kt @@ -1,7 +1,7 @@ package ru.rznnike.eyehealthmanager.domain.gateway -import ru.rznnike.eyehealthmanager.domain.model.AnalysisParameters -import ru.rznnike.eyehealthmanager.domain.model.AnalysisResult +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisParameters +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisResult interface AnalysisGateway { suspend fun getAnalysisResult(parameters: AnalysisParameters): AnalysisResult diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/gateway/DevGateway.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/gateway/DevGateway.kt index 952541d4..cdfd2588 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/gateway/DevGateway.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/gateway/DevGateway.kt @@ -1,6 +1,6 @@ package ru.rznnike.eyehealthmanager.domain.gateway -import ru.rznnike.eyehealthmanager.domain.model.enums.DataGenerationType +import ru.rznnike.eyehealthmanager.domain.model.common.DataGenerationType interface DevGateway { suspend fun generateData(type: DataGenerationType) diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/gateway/NotificationGateway.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/gateway/NotificationGateway.kt index cf6d99bc..5ef8aed8 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/gateway/NotificationGateway.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/gateway/NotificationGateway.kt @@ -1,8 +1,8 @@ package ru.rznnike.eyehealthmanager.domain.gateway import kotlinx.coroutines.flow.Flow -import ru.rznnike.eyehealthmanager.domain.model.CancelNotification -import ru.rznnike.eyehealthmanager.domain.model.Notification +import ru.rznnike.eyehealthmanager.domain.model.notification.CancelNotification +import ru.rznnike.eyehealthmanager.domain.model.notification.Notification interface NotificationGateway { suspend fun emitShowNotification(notification: Notification) diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/gateway/TestGateway.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/gateway/TestGateway.kt index 7ad240ce..f97fdd8e 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/gateway/TestGateway.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/gateway/TestGateway.kt @@ -1,10 +1,10 @@ package ru.rznnike.eyehealthmanager.domain.gateway import android.net.Uri -import ru.rznnike.eyehealthmanager.domain.model.TestResult -import ru.rznnike.eyehealthmanager.domain.model.TestResultFilter -import ru.rznnike.eyehealthmanager.domain.model.TestResultPagingParameters -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultFilter +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultPagingParameters +import ru.rznnike.eyehealthmanager.domain.utils.JournalBackupManager interface TestGateway { suspend fun getTestResults(parameters: TestResultPagingParameters): List @@ -17,9 +17,7 @@ interface TestGateway { suspend fun deleteDuplicates() - suspend fun exportJournal(filter: TestResultFilter): Uri? + suspend fun exportJournal(filter: TestResultFilter, manager: JournalBackupManager): Uri? - suspend fun getAvailableImportTypes(importFolderUri: Uri): List - - suspend fun importJournal(importFolderUri: Uri) + suspend fun importJournal(importFolderUri: Uri, manager: JournalBackupManager) } diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/gateway/UserGateway.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/gateway/UserGateway.kt index cde3c07a..ddedc245 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/gateway/UserGateway.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/gateway/UserGateway.kt @@ -1,8 +1,8 @@ package ru.rznnike.eyehealthmanager.domain.gateway -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestingSettings -import ru.rznnike.eyehealthmanager.domain.model.TestingSettings -import ru.rznnike.eyehealthmanager.domain.model.enums.AppTheme +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestingSettings +import ru.rznnike.eyehealthmanager.domain.model.test.TestingSettings +import ru.rznnike.eyehealthmanager.domain.model.common.AppTheme interface UserGateway { suspend fun getWelcomeDialogShowed(): Boolean diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/CoroutineProvider.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/CoroutineProvider.kt deleted file mode 100644 index d78f0365..00000000 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/CoroutineProvider.kt +++ /dev/null @@ -1,10 +0,0 @@ -package ru.rznnike.eyehealthmanager.domain.global - -import kotlinx.coroutines.CoroutineScope - -interface CoroutineProvider { - val scopeIo: CoroutineScope - val scopeMain: CoroutineScope - val scopeMainImmediate: CoroutineScope - val scopeUnconfined: CoroutineScope -} diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/CoroutineScopeProvider.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/CoroutineScopeProvider.kt new file mode 100644 index 00000000..e1749e48 --- /dev/null +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/CoroutineScopeProvider.kt @@ -0,0 +1,10 @@ +package ru.rznnike.eyehealthmanager.domain.global + +import kotlinx.coroutines.CoroutineScope + +interface CoroutineScopeProvider { + val ui: CoroutineScope + val default: CoroutineScope + val io: CoroutineScope + val unconfined: CoroutineScope +} diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/DispatcherProvider.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/DispatcherProvider.kt index 139282f2..06d2832f 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/DispatcherProvider.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/DispatcherProvider.kt @@ -3,8 +3,8 @@ package ru.rznnike.eyehealthmanager.domain.global import kotlinx.coroutines.CoroutineDispatcher interface DispatcherProvider { - val io: CoroutineDispatcher - val default: CoroutineDispatcher val ui: CoroutineDispatcher + val default: CoroutineDispatcher + val io: CoroutineDispatcher val unconfined: CoroutineDispatcher } \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/interactor/FlowUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/interactor/FlowUseCase.kt index 35a0c3b4..775eba4d 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/interactor/FlowUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/interactor/FlowUseCase.kt @@ -1,12 +1,12 @@ package ru.rznnike.eyehealthmanager.domain.global.interactor -import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOn +import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider -abstract class FlowUseCase(private val coroutineDispatcher: CoroutineDispatcher) { +abstract class FlowUseCase(private val dispatcherProvider: DispatcherProvider) { suspend operator fun invoke(): Flow { - return execute().flowOn(coroutineDispatcher) + return execute().flowOn(dispatcherProvider.default) } @Throws(RuntimeException::class) diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/interactor/FlowUseCaseWithParams.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/interactor/FlowUseCaseWithParams.kt index d249d2a4..244be4fe 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/interactor/FlowUseCaseWithParams.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/interactor/FlowUseCaseWithParams.kt @@ -1,12 +1,12 @@ package ru.rznnike.eyehealthmanager.domain.global.interactor -import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOn +import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider -abstract class FlowUseCaseWithParams(private val coroutineDispatcher: CoroutineDispatcher) { +abstract class FlowUseCaseWithParams(private val dispatcherProvider: DispatcherProvider) { suspend operator fun invoke(parameters: P): Flow { - return execute(parameters).flowOn(coroutineDispatcher) + return execute(parameters).flowOn(dispatcherProvider.default) } @Throws(RuntimeException::class) diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/interactor/UseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/interactor/UseCase.kt index e2c2ec5e..83ada34f 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/interactor/UseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/interactor/UseCase.kt @@ -1,12 +1,12 @@ package ru.rznnike.eyehealthmanager.domain.global.interactor -import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.withContext +import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider -abstract class UseCase(private val coroutineDispatcher: CoroutineDispatcher) { +abstract class UseCase(private val dispatcherProvider: DispatcherProvider) { suspend operator fun invoke(): UseCaseResult { return try { - withContext(coroutineDispatcher) { + withContext(dispatcherProvider.default) { UseCaseResult(data = execute()) } } catch (e: Exception) { diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/interactor/UseCaseResult.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/interactor/UseCaseResult.kt index 745efb9d..eb0d593e 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/interactor/UseCaseResult.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/interactor/UseCaseResult.kt @@ -12,9 +12,6 @@ class UseCaseResult( } } - val isSuccessful : Boolean - get() = (error == null) && (data != null) - suspend fun process( onSuccessCallback: suspend (R) -> Unit, onErrorCallback: (suspend (Exception) -> Unit)? = null diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/interactor/UseCaseWithParams.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/interactor/UseCaseWithParams.kt index 7dc46f7f..39e175fe 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/interactor/UseCaseWithParams.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/global/interactor/UseCaseWithParams.kt @@ -1,12 +1,12 @@ package ru.rznnike.eyehealthmanager.domain.global.interactor -import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.withContext +import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider -abstract class UseCaseWithParams(private val coroutineDispatcher: CoroutineDispatcher) { +abstract class UseCaseWithParams(private val dispatcherProvider: DispatcherProvider) { suspend operator fun invoke(parameters: P): UseCaseResult { return try { - withContext(coroutineDispatcher) { + withContext(dispatcherProvider.default) { UseCaseResult(data = execute(parameters)) } } catch (e: Exception) { diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/analysis/GetAnalysisResultUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/analysis/GetAnalysisResultUseCase.kt index 3c4e9649..4bc7cbfa 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/analysis/GetAnalysisResultUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/analysis/GetAnalysisResultUseCase.kt @@ -3,13 +3,13 @@ package ru.rznnike.eyehealthmanager.domain.interactor.analysis import ru.rznnike.eyehealthmanager.domain.gateway.AnalysisGateway import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseWithParams -import ru.rznnike.eyehealthmanager.domain.model.AnalysisParameters -import ru.rznnike.eyehealthmanager.domain.model.AnalysisResult +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisParameters +import ru.rznnike.eyehealthmanager.domain.model.analysis.AnalysisResult class GetAnalysisResultUseCase( private val analysisGateway: AnalysisGateway, dispatcherProvider: DispatcherProvider -) : UseCaseWithParams(dispatcherProvider.io) { +) : UseCaseWithParams(dispatcherProvider) { override suspend fun execute(parameters: AnalysisParameters) = analysisGateway.getAnalysisResult(parameters) } diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/dev/GenerateDataUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/dev/GenerateDataUseCase.kt index d2e4f1e4..8ff6ce46 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/dev/GenerateDataUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/dev/GenerateDataUseCase.kt @@ -3,12 +3,12 @@ package ru.rznnike.eyehealthmanager.domain.interactor.dev import ru.rznnike.eyehealthmanager.domain.gateway.DevGateway import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseWithParams -import ru.rznnike.eyehealthmanager.domain.model.enums.DataGenerationType +import ru.rznnike.eyehealthmanager.domain.model.common.DataGenerationType class GenerateDataUseCase( private val devGateway: DevGateway, dispatcherProvider: DispatcherProvider -) : UseCaseWithParams(dispatcherProvider.io) { +) : UseCaseWithParams(dispatcherProvider) { override suspend fun execute(parameters: DataGenerationType) = devGateway.generateData(parameters) } diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/notification/EmitShowNotificationUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/notification/EmitShowNotificationUseCase.kt index dccde1fd..05fa5b85 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/notification/EmitShowNotificationUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/notification/EmitShowNotificationUseCase.kt @@ -3,12 +3,12 @@ package ru.rznnike.eyehealthmanager.domain.interactor.notification import ru.rznnike.eyehealthmanager.domain.gateway.NotificationGateway import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseWithParams -import ru.rznnike.eyehealthmanager.domain.model.Notification +import ru.rznnike.eyehealthmanager.domain.model.notification.Notification class EmitShowNotificationUseCase( private val notificationGateway: NotificationGateway, dispatcherProvider: DispatcherProvider -) : UseCaseWithParams(dispatcherProvider.io) { +) : UseCaseWithParams(dispatcherProvider) { override suspend fun execute(parameters: Notification) = notificationGateway.emitShowNotification(parameters) } \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/notification/ObserveCancelNotificationUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/notification/ObserveCancelNotificationUseCase.kt index 5cb05aff..a312ba56 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/notification/ObserveCancelNotificationUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/notification/ObserveCancelNotificationUseCase.kt @@ -3,12 +3,12 @@ package ru.rznnike.eyehealthmanager.domain.interactor.notification import ru.rznnike.eyehealthmanager.domain.gateway.NotificationGateway import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider import ru.rznnike.eyehealthmanager.domain.global.interactor.FlowUseCase -import ru.rznnike.eyehealthmanager.domain.model.CancelNotification +import ru.rznnike.eyehealthmanager.domain.model.notification.CancelNotification class ObserveCancelNotificationUseCase( private val notificationGateway: NotificationGateway, dispatcherProvider: DispatcherProvider -) : FlowUseCase(dispatcherProvider.io) { +) : FlowUseCase(dispatcherProvider) { override suspend fun execute() = notificationGateway.observeCancelNotification() } \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/notification/ObserveShowNotificationUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/notification/ObserveShowNotificationUseCase.kt index 560fc968..b228b8ff 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/notification/ObserveShowNotificationUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/notification/ObserveShowNotificationUseCase.kt @@ -3,12 +3,12 @@ package ru.rznnike.eyehealthmanager.domain.interactor.notification import ru.rznnike.eyehealthmanager.domain.gateway.NotificationGateway import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider import ru.rznnike.eyehealthmanager.domain.global.interactor.FlowUseCase -import ru.rznnike.eyehealthmanager.domain.model.Notification +import ru.rznnike.eyehealthmanager.domain.model.notification.Notification class ObserveShowNotificationUseCase( private val notificationGateway: NotificationGateway, dispatcherProvider: DispatcherProvider -) : FlowUseCase(dispatcherProvider.io) { +) : FlowUseCase(dispatcherProvider) { override suspend fun execute() = notificationGateway.observeShowNotification() } \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/AddTestResultUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/AddTestResultUseCase.kt index 0e9933a9..5179395d 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/AddTestResultUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/AddTestResultUseCase.kt @@ -3,12 +3,12 @@ package ru.rznnike.eyehealthmanager.domain.interactor.test import ru.rznnike.eyehealthmanager.domain.gateway.TestGateway import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseWithParams -import ru.rznnike.eyehealthmanager.domain.model.TestResult +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult class AddTestResultUseCase( private val testGateway: TestGateway, dispatcherProvider: DispatcherProvider -) : UseCaseWithParams(dispatcherProvider.io) { +) : UseCaseWithParams(dispatcherProvider) { override suspend fun execute(parameters: TestResult) = testGateway.addTestResult(parameters) } diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/DeleteAllTestResultsUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/DeleteAllTestResultsUseCase.kt index 40565cc0..2bfa3fb0 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/DeleteAllTestResultsUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/DeleteAllTestResultsUseCase.kt @@ -7,7 +7,7 @@ import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCase class DeleteAllTestResultsUseCase( private val testGateway: TestGateway, dispatcherProvider: DispatcherProvider -) : UseCase(dispatcherProvider.io) { +) : UseCase(dispatcherProvider) { override suspend fun execute() = testGateway.deleteAllTestResults() } diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/DeleteDuplicatesUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/DeleteDuplicatesUseCase.kt index 2ea159e3..b7f456d9 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/DeleteDuplicatesUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/DeleteDuplicatesUseCase.kt @@ -7,7 +7,7 @@ import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCase class DeleteDuplicatesUseCase( private val testGateway: TestGateway, dispatcherProvider: DispatcherProvider -) : UseCase(dispatcherProvider.io) { +) : UseCase(dispatcherProvider) { override suspend fun execute() = testGateway.deleteDuplicates() } diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/DeleteTestResultUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/DeleteTestResultUseCase.kt index 750bf1b1..61a1de5f 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/DeleteTestResultUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/DeleteTestResultUseCase.kt @@ -7,7 +7,7 @@ import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseWithParams class DeleteTestResultUseCase( private val testGateway: TestGateway, dispatcherProvider: DispatcherProvider -) : UseCaseWithParams(dispatcherProvider.io) { +) : UseCaseWithParams(dispatcherProvider) { override suspend fun execute(parameters: Long) = testGateway.deleteTestResultById(parameters) } diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/ExportJournalUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/ExportJournalUseCase.kt index 8ce03a7c..4c03d8e5 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/ExportJournalUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/ExportJournalUseCase.kt @@ -4,17 +4,26 @@ import android.net.Uri import ru.rznnike.eyehealthmanager.domain.gateway.TestGateway import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseWithParams -import ru.rznnike.eyehealthmanager.domain.model.TestResultFilter +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultFilter +import ru.rznnike.eyehealthmanager.domain.utils.JournalBackupManager class ExportJournalUseCase( private val testGateway: TestGateway, dispatcherProvider: DispatcherProvider -) : UseCaseWithParams(dispatcherProvider.io) { - override suspend fun execute(parameters: TestResultFilter) = +) : UseCaseWithParams(dispatcherProvider) { + override suspend fun execute(parameters: Parameters) = Result( - exportFolderUri = testGateway.exportJournal(parameters) + exportFolderUri = testGateway.exportJournal( + filter = parameters.filter, + manager = parameters.manager + ) ) + data class Parameters( + val filter: TestResultFilter, + val manager: JournalBackupManager + ) + data class Result( val exportFolderUri: Uri? ) diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/GetAvailableImportTypesUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/GetAvailableImportTypesUseCase.kt deleted file mode 100644 index cab83c68..00000000 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/GetAvailableImportTypesUseCase.kt +++ /dev/null @@ -1,15 +0,0 @@ -package ru.rznnike.eyehealthmanager.domain.interactor.test - -import android.net.Uri -import ru.rznnike.eyehealthmanager.domain.gateway.TestGateway -import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider -import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseWithParams -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType - -class GetAvailableImportTypesUseCase( - private val testGateway: TestGateway, - dispatcherProvider: DispatcherProvider -) : UseCaseWithParams>(dispatcherProvider.io) { - override suspend fun execute(parameters: Uri) = - testGateway.getAvailableImportTypes(parameters) -} diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/GetTestResultsUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/GetTestResultsUseCase.kt index 44b97cb5..ff2ead4f 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/GetTestResultsUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/GetTestResultsUseCase.kt @@ -3,13 +3,13 @@ package ru.rznnike.eyehealthmanager.domain.interactor.test import ru.rznnike.eyehealthmanager.domain.gateway.TestGateway import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseWithParams -import ru.rznnike.eyehealthmanager.domain.model.TestResult -import ru.rznnike.eyehealthmanager.domain.model.TestResultPagingParameters +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultPagingParameters class GetTestResultsUseCase( private val testGateway: TestGateway, dispatcherProvider: DispatcherProvider -) : UseCaseWithParams>(dispatcherProvider.io) { +) : UseCaseWithParams>(dispatcherProvider) { override suspend fun execute(parameters: TestResultPagingParameters) = testGateway.getTestResults(parameters) } diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/ImportJournalUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/ImportJournalUseCase.kt index 97114ddb..6ecc511a 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/ImportJournalUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/test/ImportJournalUseCase.kt @@ -4,11 +4,20 @@ import android.net.Uri import ru.rznnike.eyehealthmanager.domain.gateway.TestGateway import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseWithParams +import ru.rznnike.eyehealthmanager.domain.utils.JournalBackupManager class ImportJournalUseCase( private val testGateway: TestGateway, dispatcherProvider: DispatcherProvider -) : UseCaseWithParams(dispatcherProvider.io) { - override suspend fun execute(parameters: Uri) = - testGateway.importJournal(parameters) +) : UseCaseWithParams(dispatcherProvider) { + override suspend fun execute(parameters: Parameters) = + testGateway.importJournal( + importFolderUri = parameters.importFolderUri, + manager = parameters.manager + ) + + data class Parameters( + val importFolderUri: Uri, + val manager: JournalBackupManager + ) } diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetAcuityTestingSettingsUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetAcuityTestingSettingsUseCase.kt index 76c21321..28fc0035 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetAcuityTestingSettingsUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetAcuityTestingSettingsUseCase.kt @@ -3,12 +3,12 @@ package ru.rznnike.eyehealthmanager.domain.interactor.user import ru.rznnike.eyehealthmanager.domain.gateway.UserGateway import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCase -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestingSettings +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestingSettings class GetAcuityTestingSettingsUseCase( private val userGateway: UserGateway, dispatcherProvider: DispatcherProvider -) : UseCase(dispatcherProvider.io) { +) : UseCase(dispatcherProvider) { override suspend fun execute() = userGateway.getAcuityTestingSettings() } diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetAppThemeUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetAppThemeUseCase.kt index 56d99bdd..55c3070c 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetAppThemeUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetAppThemeUseCase.kt @@ -3,12 +3,12 @@ package ru.rznnike.eyehealthmanager.domain.interactor.user import ru.rznnike.eyehealthmanager.domain.gateway.UserGateway import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCase -import ru.rznnike.eyehealthmanager.domain.model.enums.AppTheme +import ru.rznnike.eyehealthmanager.domain.model.common.AppTheme class GetAppThemeUseCase( private val userGateway: UserGateway, dispatcherProvider: DispatcherProvider -) : UseCase(dispatcherProvider.io) { +) : UseCase(dispatcherProvider) { override suspend fun execute() = userGateway.getAppTheme() } \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetApplyDynamicCorrectionsUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetApplyDynamicCorrectionsUseCase.kt index 725dd77d..88897f6e 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetApplyDynamicCorrectionsUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetApplyDynamicCorrectionsUseCase.kt @@ -7,7 +7,7 @@ import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCase class GetApplyDynamicCorrectionsUseCase( private val userGateway: UserGateway, dispatcherProvider: DispatcherProvider -) : UseCase(dispatcherProvider.io) { +) : UseCase(dispatcherProvider) { override suspend fun execute() = userGateway.getApplyDynamicCorrections() } diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetDisplayedChangelogVersionUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetDisplayedChangelogVersionUseCase.kt index d4141705..d1e7243e 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetDisplayedChangelogVersionUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetDisplayedChangelogVersionUseCase.kt @@ -7,7 +7,7 @@ import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCase class GetDisplayedChangelogVersionUseCase( private val userGateway: UserGateway, dispatcherProvider: DispatcherProvider -) : UseCase(dispatcherProvider.io) { +) : UseCase(dispatcherProvider) { override suspend fun execute() = userGateway.getDisplayedChangelogVersion() } diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetTestingSettingsUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetTestingSettingsUseCase.kt index 183f4a2a..5f5332e0 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetTestingSettingsUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetTestingSettingsUseCase.kt @@ -3,12 +3,12 @@ package ru.rznnike.eyehealthmanager.domain.interactor.user import ru.rznnike.eyehealthmanager.domain.gateway.UserGateway import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCase -import ru.rznnike.eyehealthmanager.domain.model.TestingSettings +import ru.rznnike.eyehealthmanager.domain.model.test.TestingSettings class GetTestingSettingsUseCase( private val userGateway: UserGateway, dispatcherProvider: DispatcherProvider -) : UseCase(dispatcherProvider.io) { +) : UseCase(dispatcherProvider) { override suspend fun execute() = userGateway.getTestingSettings() } diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetWelcomeDialogShowedUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetWelcomeDialogShowedUseCase.kt index c4a4ec18..ceb4bb86 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetWelcomeDialogShowedUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/GetWelcomeDialogShowedUseCase.kt @@ -7,7 +7,7 @@ import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCase class GetWelcomeDialogShowedUseCase( private val userGateway: UserGateway, dispatcherProvider: DispatcherProvider -) : UseCase(dispatcherProvider.io) { +) : UseCase(dispatcherProvider) { override suspend fun execute() = userGateway.getWelcomeDialogShowed() } diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetAcuityTestingSettingsUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetAcuityTestingSettingsUseCase.kt index 7712649e..4e93497c 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetAcuityTestingSettingsUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetAcuityTestingSettingsUseCase.kt @@ -3,12 +3,12 @@ package ru.rznnike.eyehealthmanager.domain.interactor.user import ru.rznnike.eyehealthmanager.domain.gateway.UserGateway import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseWithParams -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestingSettings +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestingSettings class SetAcuityTestingSettingsUseCase( private val userGateway: UserGateway, dispatcherProvider: DispatcherProvider -) : UseCaseWithParams(dispatcherProvider.io) { +) : UseCaseWithParams(dispatcherProvider) { override suspend fun execute(parameters: AcuityTestingSettings) = userGateway.setAcuityTestingSettings(parameters) } diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetAppThemeUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetAppThemeUseCase.kt index 3b2041ca..15d40e83 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetAppThemeUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetAppThemeUseCase.kt @@ -3,12 +3,12 @@ package ru.rznnike.eyehealthmanager.domain.interactor.user import ru.rznnike.eyehealthmanager.domain.gateway.UserGateway import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseWithParams -import ru.rznnike.eyehealthmanager.domain.model.enums.AppTheme +import ru.rznnike.eyehealthmanager.domain.model.common.AppTheme class SetAppThemeUseCase( private val userGateway: UserGateway, dispatcherProvider: DispatcherProvider -) : UseCaseWithParams(dispatcherProvider.io) { +) : UseCaseWithParams(dispatcherProvider) { override suspend fun execute(parameters: AppTheme) = userGateway.setAppTheme(parameters) } \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetApplyDynamicCorrectionsUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetApplyDynamicCorrectionsUseCase.kt index 752a903d..edaf641d 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetApplyDynamicCorrectionsUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetApplyDynamicCorrectionsUseCase.kt @@ -7,7 +7,7 @@ import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseWithParams class SetApplyDynamicCorrectionsUseCase( private val userGateway: UserGateway, dispatcherProvider: DispatcherProvider -) : UseCaseWithParams(dispatcherProvider.io) { +) : UseCaseWithParams(dispatcherProvider) { override suspend fun execute(parameters: Boolean) = userGateway.setApplyDynamicCorrections(parameters) } diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetDisplayedChangelogVersionUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetDisplayedChangelogVersionUseCase.kt index bc5fd790..480e38d5 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetDisplayedChangelogVersionUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetDisplayedChangelogVersionUseCase.kt @@ -7,7 +7,7 @@ import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseWithParams class SetDisplayedChangelogVersionUseCase( private val userGateway: UserGateway, dispatcherProvider: DispatcherProvider -) : UseCaseWithParams(dispatcherProvider.io) { +) : UseCaseWithParams(dispatcherProvider) { override suspend fun execute(parameters: Int) = userGateway.setDisplayedChangelogVersion(parameters) } diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetTestingSettingsUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetTestingSettingsUseCase.kt index 7ff787ce..6ffcc658 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetTestingSettingsUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetTestingSettingsUseCase.kt @@ -3,12 +3,12 @@ package ru.rznnike.eyehealthmanager.domain.interactor.user import ru.rznnike.eyehealthmanager.domain.gateway.UserGateway import ru.rznnike.eyehealthmanager.domain.global.DispatcherProvider import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseWithParams -import ru.rznnike.eyehealthmanager.domain.model.TestingSettings +import ru.rznnike.eyehealthmanager.domain.model.test.TestingSettings class SetTestingSettingsUseCase( private val userGateway: UserGateway, dispatcherProvider: DispatcherProvider -) : UseCaseWithParams(dispatcherProvider.io) { +) : UseCaseWithParams(dispatcherProvider) { override suspend fun execute(parameters: TestingSettings) = userGateway.setTestingSettings(parameters) } diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetWelcomeDialogShowedUseCase.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetWelcomeDialogShowedUseCase.kt index 690b544f..f06560eb 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetWelcomeDialogShowedUseCase.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/interactor/user/SetWelcomeDialogShowedUseCase.kt @@ -7,7 +7,7 @@ import ru.rznnike.eyehealthmanager.domain.global.interactor.UseCaseWithParams class SetWelcomeDialogShowedUseCase( private val userGateway: UserGateway, dispatcherProvider: DispatcherProvider -) : UseCaseWithParams(dispatcherProvider.io) { +) : UseCaseWithParams(dispatcherProvider) { override suspend fun execute(parameters: Boolean) = userGateway.setWelcomeDialogShowed(parameters) } diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/AcuityTestingSettings.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/AcuityTestingSettings.kt deleted file mode 100644 index 7823ae5b..00000000 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/AcuityTestingSettings.kt +++ /dev/null @@ -1,9 +0,0 @@ -package ru.rznnike.eyehealthmanager.domain.model - -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuityTestSymbolsType -import ru.rznnike.eyehealthmanager.domain.model.enums.TestEyesType - -data class AcuityTestingSettings( - var symbolsType: AcuityTestSymbolsType = AcuityTestSymbolsType.LETTERS_EN, - var eyesType: TestEyesType = TestEyesType.BOTH -) \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/AnalysisParameters.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/AnalysisParameters.kt similarity index 71% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/AnalysisParameters.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/AnalysisParameters.kt index 1ad96b13..f7c532a9 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/AnalysisParameters.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/AnalysisParameters.kt @@ -1,8 +1,7 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.analysis import android.os.Parcelable import kotlinx.parcelize.Parcelize -import ru.rznnike.eyehealthmanager.domain.model.enums.AnalysisType @Parcelize data class AnalysisParameters( diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/AnalysisResult.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/AnalysisResult.kt similarity index 74% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/AnalysisResult.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/AnalysisResult.kt index 2455848e..f6c53595 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/AnalysisResult.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/AnalysisResult.kt @@ -1,7 +1,8 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.analysis import android.os.Parcelable import kotlinx.parcelize.Parcelize +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult @Parcelize data class AnalysisResult( diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/AnalysisStatistics.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/AnalysisStatistics.kt similarity index 68% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/AnalysisStatistics.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/AnalysisStatistics.kt index ae0c409d..b855a44b 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/AnalysisStatistics.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/AnalysisStatistics.kt @@ -1,8 +1,7 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.analysis import android.os.Parcelable import kotlinx.parcelize.Parcelize -import ru.rznnike.eyehealthmanager.domain.model.enums.VisionDynamicType @Parcelize data class AnalysisStatistics( diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AnalysisType.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/AnalysisType.kt similarity index 54% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AnalysisType.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/AnalysisType.kt index 817a2c39..09988a25 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AnalysisType.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/AnalysisType.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model.enums +package ru.rznnike.eyehealthmanager.domain.model.analysis enum class AnalysisType { ACUITY_ONLY, diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/DynamicCorrectionsData.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/DynamicCorrectionsData.kt similarity index 82% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/DynamicCorrectionsData.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/DynamicCorrectionsData.kt index 60e207ea..83d08010 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/DynamicCorrectionsData.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/DynamicCorrectionsData.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.analysis import android.os.Parcelable import kotlinx.parcelize.Parcelize diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/EyeChartPoint.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/EyeChartPoint.kt similarity index 74% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/EyeChartPoint.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/EyeChartPoint.kt index 0d3955e8..d1e67c65 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/EyeChartPoint.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/EyeChartPoint.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.analysis import android.os.Parcelable import kotlinx.parcelize.Parcelize diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/FunctionPoint.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/FunctionPoint.kt similarity index 57% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/FunctionPoint.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/FunctionPoint.kt index f73680ae..17fa9f96 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/FunctionPoint.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/FunctionPoint.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.analysis data class FunctionPoint( var x: Double = 0.0, diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/LinearFunction.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/LinearFunction.kt similarity index 70% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/LinearFunction.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/LinearFunction.kt index b62e8b33..8ab67910 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/LinearFunction.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/LinearFunction.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.analysis /** * y = a*x+b diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/SingleEyeAnalysisResult.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/SingleEyeAnalysisResult.kt similarity index 84% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/SingleEyeAnalysisResult.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/SingleEyeAnalysisResult.kt index 0109ff74..65cba0a8 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/SingleEyeAnalysisResult.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/SingleEyeAnalysisResult.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.analysis import android.os.Parcelable import kotlinx.parcelize.Parcelize diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/VisionDynamicType.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/VisionDynamicType.kt similarity index 54% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/VisionDynamicType.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/VisionDynamicType.kt index f7d1d14e..3119ef4b 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/VisionDynamicType.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/analysis/VisionDynamicType.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model.enums +package ru.rznnike.eyehealthmanager.domain.model.analysis enum class VisionDynamicType { SAME, diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/common/AppTheme.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/common/AppTheme.kt new file mode 100644 index 00000000..76e579f2 --- /dev/null +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/common/AppTheme.kt @@ -0,0 +1,13 @@ +package ru.rznnike.eyehealthmanager.domain.model.common + +enum class AppTheme( + val id: Int +) { + LIGHT(1), + DARK(2), + SYSTEM(3); + + companion object { + operator fun get(id: Int?) = entries.find { it.id == id } ?: SYSTEM + } +} \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/DataGenerationType.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/common/DataGenerationType.kt similarity index 64% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/DataGenerationType.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/common/DataGenerationType.kt index fb951ada..edd657f2 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/DataGenerationType.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/common/DataGenerationType.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model.enums +package ru.rznnike.eyehealthmanager.domain.model.common enum class DataGenerationType { GOOD_VISION, diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/DayPart.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/common/DayPart.kt similarity index 86% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/DayPart.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/common/DayPart.kt index 87ff9a9b..eb84d260 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/DayPart.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/common/DayPart.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model.enums +package ru.rznnike.eyehealthmanager.domain.model.common import android.os.Parcelable import kotlinx.parcelize.Parcelize diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/Direction.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/common/Direction.kt similarity index 52% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/Direction.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/common/Direction.kt index 4f282922..93558a9b 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/Direction.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/common/Direction.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model.enums +package ru.rznnike.eyehealthmanager.domain.model.common enum class Direction { UP, diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/ExternalIntentData.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/common/ExternalIntentData.kt similarity index 89% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/ExternalIntentData.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/common/ExternalIntentData.kt index 113b02f7..8729aee4 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/ExternalIntentData.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/common/ExternalIntentData.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.common import android.os.Parcelable import kotlinx.parcelize.Parcelize diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/Language.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/common/Language.kt similarity index 81% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/Language.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/common/Language.kt index 2bb0a245..1e824653 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/Language.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/common/Language.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model.enums +package ru.rznnike.eyehealthmanager.domain.model.common enum class Language( val tag: String, diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AcuityTestSymbolsType.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AcuityTestSymbolsType.kt deleted file mode 100644 index dff60ffa..00000000 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AcuityTestSymbolsType.kt +++ /dev/null @@ -1,22 +0,0 @@ -package ru.rznnike.eyehealthmanager.domain.model.enums - -import androidx.annotation.DrawableRes -import androidx.annotation.StringRes -import ru.rznnike.eyehealthmanager.domain.R - -enum class AcuityTestSymbolsType( - val id: Int, - @DrawableRes val iconResId: Int, - @StringRes val nameResId: Int -) { - LETTERS_RU(1, R.drawable.ic_letters_ru_sh, R.string.symbols_letters_ru), - LETTERS_EN(2, R.drawable.ic_letters_en_f, R.string.symbols_letters_en), - SQUARE(3, R.drawable.ic_square_symbol_1, R.string.symbols_square), - TRIANGLE(4, R.drawable.ic_triangle_symbol_1, R.string.symbols_triangle); - - companion object { - operator fun get(id: Int?) = entries.find { it.id == id } ?: LETTERS_RU - - operator fun get(name: String?) = entries.find { it.toString() == name } - } -} \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AppTheme.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AppTheme.kt deleted file mode 100644 index 09bfdb70..00000000 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AppTheme.kt +++ /dev/null @@ -1,26 +0,0 @@ -package ru.rznnike.eyehealthmanager.domain.model.enums - -import androidx.annotation.StringRes -import ru.rznnike.eyehealthmanager.domain.R - -enum class AppTheme( - val id: Int, - @StringRes val nameResId: Int -) { - LIGHT( - id = 1, - nameResId = R.string.theme_light - ), - DARK( - id = 2, - nameResId = R.string.theme_dark - ), - SYSTEM( - id = 3, - nameResId = R.string.theme_system - ); - - companion object { - operator fun get(id: Int?) = entries.find { it.id == id } ?: SYSTEM - } -} \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AstigmatismAnswerType.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AstigmatismAnswerType.kt deleted file mode 100644 index 8b07977f..00000000 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/AstigmatismAnswerType.kt +++ /dev/null @@ -1,27 +0,0 @@ -package ru.rznnike.eyehealthmanager.domain.model.enums - -import android.os.Parcelable -import androidx.annotation.StringRes -import kotlinx.parcelize.Parcelize -import ru.rznnike.eyehealthmanager.domain.R - -@Parcelize -enum class AstigmatismAnswerType( - val id: Int, - @StringRes val nameResId: Int -) : Parcelable { - OK( - id = 1, - nameResId = R.string.normal_condition - ), - ANOMALY( - id = 2, - nameResId = R.string.possible_astigmatism - ); - - companion object { - operator fun get(id: Int?) = entries.find { it.id == id } ?: OK - - operator fun get(name: String?) = entries.find { it.toString() == name } - } -} \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/DaltonismAnomalyType.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/DaltonismAnomalyType.kt deleted file mode 100644 index 87e382e0..00000000 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/DaltonismAnomalyType.kt +++ /dev/null @@ -1,29 +0,0 @@ -package ru.rznnike.eyehealthmanager.domain.model.enums - -import android.os.Parcelable -import androidx.annotation.StringRes -import kotlinx.parcelize.Parcelize -import ru.rznnike.eyehealthmanager.domain.R - -@Parcelize -enum class DaltonismAnomalyType( - val id: Int, - @StringRes val nameResId: Int -) : Parcelable { - NONE(0, R.string.rabkin_result_normal), - PROTANOPIA(1, R.string.rabkin_result_protanopia), - DEITERANOPIA(2, R.string.rabkin_result_deiteranopia), - PROTANOMALY_A(3, R.string.rabkin_result_protanomaly_a), - PROTANOMALY_B(4, R.string.rabkin_result_protanomaly_b), - PROTANOMALY_C(5, R.string.rabkin_result_protanomaly_c), - DEITERANOMALY_A(6, R.string.rabkin_result_deiteranomaly_a), - DEITERANOMALY_B(7, R.string.rabkin_result_deiteranomaly_b), - DEITERANOMALY_C(8, R.string.rabkin_result_deiteranomaly_c), - PATHOLOGY(9, R.string.rabkin_result_parhology); - - companion object { - operator fun get(id: Int?) = entries.find { it.id == id } ?: NONE - - operator fun get(name: String?) = entries.find { it.toString() == name } - } -} \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/NearFarAnswerType.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/NearFarAnswerType.kt deleted file mode 100644 index 0278c87c..00000000 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/NearFarAnswerType.kt +++ /dev/null @@ -1,31 +0,0 @@ -package ru.rznnike.eyehealthmanager.domain.model.enums - -import android.os.Parcelable -import androidx.annotation.StringRes -import kotlinx.parcelize.Parcelize -import ru.rznnike.eyehealthmanager.domain.R - -@Parcelize -enum class NearFarAnswerType( - val id: Int, - @StringRes val nameResId: Int -) : Parcelable { - RED_BETTER( - id = 1, - nameResId = R.string.possible_myopia - ), - GREEN_BETTER( - id = 2, - nameResId = R.string.possible_farsightedness - ), - EQUAL( - id = 0, - nameResId = R.string.normal_condition - ); - - companion object { - operator fun get(id: Int?) = entries.find { it.id == id } ?: EQUAL - - operator fun get(name: String?) = entries.find { it.toString() == name } - } -} \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/NotificationChannelType.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/NotificationChannelType.kt deleted file mode 100644 index 0c4b86d1..00000000 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/NotificationChannelType.kt +++ /dev/null @@ -1,19 +0,0 @@ -package ru.rznnike.eyehealthmanager.domain.model.enums - -import android.os.Parcelable -import androidx.annotation.StringRes -import kotlinx.parcelize.Parcelize -import ru.rznnike.eyehealthmanager.domain.R - -@Parcelize -enum class NotificationChannelType( - val id: Int, - val channelId: String, - @StringRes val nameResId: Int -) : Parcelable { - SYSTEM(0, "system_channel", R.string.notification_channel_system); - - companion object { - operator fun get(id: Int?) = entries.find { it.id == id } ?: SYSTEM - } -} \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/TestEyesType.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/TestEyesType.kt deleted file mode 100644 index b121465c..00000000 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/TestEyesType.kt +++ /dev/null @@ -1,19 +0,0 @@ -package ru.rznnike.eyehealthmanager.domain.model.enums - -import androidx.annotation.StringRes -import ru.rznnike.eyehealthmanager.domain.R - -enum class TestEyesType( - val id: Int, - @StringRes val nameResId: Int -) { - BOTH(1, R.string.eyes_type_both), - LEFT(2, R.string.eyes_type_left), - RIGHT(3, R.string.eyes_type_right); - - companion object { - operator fun get(id: Int?) = entries.find { it.id == id } ?: BOTH - - operator fun get(name: String?) = entries.find { it.toString() == name } - } -} \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/TestType.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/TestType.kt deleted file mode 100644 index c3bf83b6..00000000 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/enums/TestType.kt +++ /dev/null @@ -1,59 +0,0 @@ -package ru.rznnike.eyehealthmanager.domain.model.enums - -import androidx.annotation.DrawableRes -import androidx.annotation.StringRes -import ru.rznnike.eyehealthmanager.domain.R -import ru.rznnike.eyehealthmanager.domain.model.AcuityTestResult -import ru.rznnike.eyehealthmanager.domain.model.AstigmatismTestResult -import ru.rznnike.eyehealthmanager.domain.model.ColorPerceptionTestResult -import ru.rznnike.eyehealthmanager.domain.model.ContrastTestResult -import ru.rznnike.eyehealthmanager.domain.model.DaltonismTestResult -import ru.rznnike.eyehealthmanager.domain.model.NearFarTestResult - -enum class TestType( - val id: Int, - @StringRes val nameResId: Int, - @DrawableRes val iconResId: Int, - val exportHeader: String -) { - ACUITY( - id = 1, - nameResId = R.string.test_acuity, - iconResId = R.drawable.ic_acuity, - exportHeader = AcuityTestResult.EXPORT_HEADER - ), - ASTIGMATISM( - id = 3, - nameResId = R.string.test_astigmatism, - iconResId = R.drawable.ic_astigmatism, - exportHeader = AstigmatismTestResult.EXPORT_HEADER - ), - NEAR_FAR( - id = 4, - nameResId = R.string.test_nearsightedness_farsightedness, - iconResId = R.drawable.ic_near_far, - exportHeader = NearFarTestResult.EXPORT_HEADER - ), - COLOR_PERCEPTION( - id = 5, - nameResId = R.string.test_color_perception, - iconResId = R.drawable.ic_color_perception, - exportHeader = ColorPerceptionTestResult.EXPORT_HEADER - ), - DALTONISM( - id = 6, - nameResId = R.string.test_daltonism, - iconResId = R.drawable.ic_daltonism, - exportHeader = DaltonismTestResult.EXPORT_HEADER - ), - CONTRAST( - id = 7, - nameResId = R.string.test_contrast, - iconResId = R.drawable.ic_contrast, - exportHeader = ContrastTestResult.EXPORT_HEADER - ); - - companion object { - operator fun get(id: Int?) = entries.find { it.id == id } ?: ACUITY - } -} \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/TestResultFilter.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/journal/TestResultFilter.kt similarity index 73% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/TestResultFilter.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/journal/TestResultFilter.kt index ce840148..cea92be8 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/TestResultFilter.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/journal/TestResultFilter.kt @@ -1,6 +1,6 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.journal -import ru.rznnike.eyehealthmanager.domain.model.enums.TestType +import ru.rznnike.eyehealthmanager.domain.model.test.TestType data class TestResultFilter( var filterByDate: Boolean = false, diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/TestResultPagingParameters.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/journal/TestResultPagingParameters.kt similarity index 67% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/TestResultPagingParameters.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/journal/TestResultPagingParameters.kt index b4d9ffb1..babf26f5 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/TestResultPagingParameters.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/journal/TestResultPagingParameters.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.journal data class TestResultPagingParameters( val limit: Int, diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/CancelNotification.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/notification/CancelNotification.kt similarity index 69% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/CancelNotification.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/notification/CancelNotification.kt index a41826b4..ddc3ec90 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/CancelNotification.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/notification/CancelNotification.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.notification data class CancelNotification(val id: Int = CANCEL_ALL) { companion object { diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/Notification.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/notification/Notification.kt similarity index 83% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/Notification.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/notification/Notification.kt index c4ee560d..2eb9d4fb 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/Notification.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/notification/Notification.kt @@ -1,9 +1,10 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.notification import android.os.Parcelable import kotlinx.parcelize.IgnoredOnParcel import kotlinx.parcelize.Parcelize -import ru.rznnike.eyehealthmanager.domain.model.enums.NotificationChannelType +import ru.rznnike.eyehealthmanager.domain.model.common.ExternalIntentData +import ru.rznnike.eyehealthmanager.domain.model.common.toExternalIntentData import ru.rznnike.eyehealthmanager.domain.utils.currentTimeMillis import java.util.UUID diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/notification/NotificationChannelType.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/notification/NotificationChannelType.kt new file mode 100644 index 00000000..29b70c0e --- /dev/null +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/notification/NotificationChannelType.kt @@ -0,0 +1,19 @@ +package ru.rznnike.eyehealthmanager.domain.model.notification + +import android.os.Parcelable +import kotlinx.parcelize.Parcelize + +@Parcelize +enum class NotificationChannelType( + val id: Int, + val channelId: String +) : Parcelable { + SYSTEM( + id = 0, + channelId = "system_channel" + ); + + companion object { + operator fun get(id: Int?) = entries.find { it.id == id } ?: SYSTEM + } +} \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/TestEyesType.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/TestEyesType.kt new file mode 100644 index 00000000..676bd5ab --- /dev/null +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/TestEyesType.kt @@ -0,0 +1,15 @@ +package ru.rznnike.eyehealthmanager.domain.model.test + +enum class TestEyesType( + val id: Int +) { + BOTH(1), + LEFT(2), + RIGHT(3); + + companion object { + operator fun get(id: Int?) = entries.find { it.id == id } ?: BOTH + + operator fun get(name: String?) = entries.find { it.toString() == name } + } +} \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/TestResult.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/TestResult.kt similarity index 81% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/TestResult.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/TestResult.kt index 58f58074..bd3aec16 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/TestResult.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/TestResult.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.test import android.os.Parcelable diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/TestType.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/TestType.kt new file mode 100644 index 00000000..16d998aa --- /dev/null +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/TestType.kt @@ -0,0 +1,42 @@ +package ru.rznnike.eyehealthmanager.domain.model.test + +import ru.rznnike.eyehealthmanager.domain.model.test.acuity.AcuityTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.astigmatism.AstigmatismTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.colorperception.ColorPerceptionTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.contrast.ContrastTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.daltonism.DaltonismTestResult +import ru.rznnike.eyehealthmanager.domain.model.test.nearfar.NearFarTestResult + +enum class TestType( + val id: Int, + val exportHeader: String +) { + ACUITY( + id = 1, + exportHeader = AcuityTestResult.EXPORT_HEADER + ), + ASTIGMATISM( + id = 3, + exportHeader = AstigmatismTestResult.EXPORT_HEADER + ), + NEAR_FAR( + id = 4, + exportHeader = NearFarTestResult.EXPORT_HEADER + ), + COLOR_PERCEPTION( + id = 5, + exportHeader = ColorPerceptionTestResult.EXPORT_HEADER + ), + DALTONISM( + id = 6, + exportHeader = DaltonismTestResult.EXPORT_HEADER + ), + CONTRAST( + id = 7, + exportHeader = ContrastTestResult.EXPORT_HEADER + ); + + companion object { + operator fun get(id: Int?) = entries.find { it.id == id } ?: ACUITY + } +} \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/TestingSettings.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/TestingSettings.kt similarity index 84% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/TestingSettings.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/TestingSettings.kt index a7ad3654..f82ed7ee 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/TestingSettings.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/TestingSettings.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.test data class TestingSettings( var armsLength: Int = 0, diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/AcuityTestResult.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/acuity/AcuityTestResult.kt similarity index 93% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/AcuityTestResult.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/acuity/AcuityTestResult.kt index 4c498e1f..922a80ee 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/AcuityTestResult.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/acuity/AcuityTestResult.kt @@ -1,10 +1,10 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.test.acuity import android.os.Parcelable import kotlinx.parcelize.Parcelize -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuityTestSymbolsType -import ru.rznnike.eyehealthmanager.domain.model.enums.DayPart -import ru.rznnike.eyehealthmanager.domain.model.enums.TestEyesType +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult +import ru.rznnike.eyehealthmanager.domain.model.common.DayPart +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants import ru.rznnike.eyehealthmanager.domain.utils.decimal2Format import ru.rznnike.eyehealthmanager.domain.utils.toDate diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/AcuityTestResultGroup.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/acuity/AcuityTestResultGroup.kt similarity index 71% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/AcuityTestResultGroup.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/acuity/AcuityTestResultGroup.kt index 4ddf5c0b..4e002050 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/AcuityTestResultGroup.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/acuity/AcuityTestResultGroup.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.test.acuity data class AcuityTestResultGroup( var dateFrom: Long = 0, diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/acuity/AcuityTestSymbolsType.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/acuity/AcuityTestSymbolsType.kt new file mode 100644 index 00000000..8cccfc83 --- /dev/null +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/acuity/AcuityTestSymbolsType.kt @@ -0,0 +1,16 @@ +package ru.rznnike.eyehealthmanager.domain.model.test.acuity + +enum class AcuityTestSymbolsType( + val id: Int +) { + LETTERS_RU(1), + LETTERS_EN(2), + SQUARE(3), + TRIANGLE(4); + + companion object { + operator fun get(id: Int?) = entries.find { it.id == id } ?: LETTERS_RU + + operator fun get(name: String?) = entries.find { it.toString() == name } + } +} \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/acuity/AcuityTestingSettings.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/acuity/AcuityTestingSettings.kt new file mode 100644 index 00000000..b39d3f5b --- /dev/null +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/acuity/AcuityTestingSettings.kt @@ -0,0 +1,8 @@ +package ru.rznnike.eyehealthmanager.domain.model.test.acuity + +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType + +data class AcuityTestingSettings( + var symbolsType: AcuityTestSymbolsType = AcuityTestSymbolsType.LETTERS_EN, + var eyesType: TestEyesType = TestEyesType.BOTH +) \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/astigmatism/AstigmatismAnswerType.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/astigmatism/AstigmatismAnswerType.kt new file mode 100644 index 00000000..921b4d1b --- /dev/null +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/astigmatism/AstigmatismAnswerType.kt @@ -0,0 +1,18 @@ +package ru.rznnike.eyehealthmanager.domain.model.test.astigmatism + +import android.os.Parcelable +import kotlinx.parcelize.Parcelize + +@Parcelize +enum class AstigmatismAnswerType( + val id: Int +) : Parcelable { + OK(1), + ANOMALY(2); + + companion object { + operator fun get(id: Int?) = entries.find { it.id == id } ?: OK + + operator fun get(name: String?) = entries.find { it.toString() == name } + } +} \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/AstigmatismTestResult.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/astigmatism/AstigmatismTestResult.kt similarity index 93% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/AstigmatismTestResult.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/astigmatism/AstigmatismTestResult.kt index e6abf7bf..51962e1f 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/AstigmatismTestResult.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/astigmatism/AstigmatismTestResult.kt @@ -1,8 +1,8 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.test.astigmatism import android.os.Parcelable import kotlinx.parcelize.Parcelize -import ru.rznnike.eyehealthmanager.domain.model.enums.AstigmatismAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants import ru.rznnike.eyehealthmanager.domain.utils.toDate import ru.rznnike.eyehealthmanager.domain.utils.toTimeStamp diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/ColorPerceptionTestResult.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/colorperception/ColorPerceptionTestResult.kt similarity index 94% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/ColorPerceptionTestResult.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/colorperception/ColorPerceptionTestResult.kt index 49c70e1b..9e2880bf 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/ColorPerceptionTestResult.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/colorperception/ColorPerceptionTestResult.kt @@ -1,7 +1,8 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.test.colorperception import android.os.Parcelable import kotlinx.parcelize.Parcelize +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants import ru.rznnike.eyehealthmanager.domain.utils.toDate import ru.rznnike.eyehealthmanager.domain.utils.toTimeStamp diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/ContrastTestResult.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/contrast/ContrastTestResult.kt similarity index 93% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/ContrastTestResult.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/contrast/ContrastTestResult.kt index 92176f32..6813d7f6 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/ContrastTestResult.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/contrast/ContrastTestResult.kt @@ -1,7 +1,8 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.test.contrast import android.os.Parcelable import kotlinx.parcelize.Parcelize +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants import ru.rznnike.eyehealthmanager.domain.utils.toDate import ru.rznnike.eyehealthmanager.domain.utils.toTimeStamp diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/daltonism/DaltonismAnomalyType.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/daltonism/DaltonismAnomalyType.kt new file mode 100644 index 00000000..1242f660 --- /dev/null +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/daltonism/DaltonismAnomalyType.kt @@ -0,0 +1,26 @@ +package ru.rznnike.eyehealthmanager.domain.model.test.daltonism + +import android.os.Parcelable +import kotlinx.parcelize.Parcelize + +@Parcelize +enum class DaltonismAnomalyType( + val id: Int +) : Parcelable { + NONE(0), + PROTANOPIA(1), + DEITERANOPIA(2), + PROTANOMALY_A(3), + PROTANOMALY_B(4), + PROTANOMALY_C(5), + DEITERANOMALY_A(6), + DEITERANOMALY_B(7), + DEITERANOMALY_C(8), + PATHOLOGY(9); + + companion object { + operator fun get(id: Int?) = entries.find { it.id == id } ?: NONE + + operator fun get(name: String?) = entries.find { it.toString() == name } + } +} \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/DaltonismTestResult.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/daltonism/DaltonismTestResult.kt similarity index 94% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/DaltonismTestResult.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/daltonism/DaltonismTestResult.kt index c27c8813..e413c729 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/DaltonismTestResult.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/daltonism/DaltonismTestResult.kt @@ -1,8 +1,8 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.test.daltonism import android.os.Parcelable import kotlinx.parcelize.Parcelize -import ru.rznnike.eyehealthmanager.domain.model.enums.DaltonismAnomalyType +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants import ru.rznnike.eyehealthmanager.domain.utils.toDate import ru.rznnike.eyehealthmanager.domain.utils.toTimeStamp diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/nearfar/NearFarAnswerType.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/nearfar/NearFarAnswerType.kt new file mode 100644 index 00000000..049f9aec --- /dev/null +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/nearfar/NearFarAnswerType.kt @@ -0,0 +1,19 @@ +package ru.rznnike.eyehealthmanager.domain.model.test.nearfar + +import android.os.Parcelable +import kotlinx.parcelize.Parcelize + +@Parcelize +enum class NearFarAnswerType( + val id: Int +) : Parcelable { + EQUAL(0), + RED_BETTER(1), + GREEN_BETTER(2); + + companion object { + operator fun get(id: Int?) = entries.find { it.id == id } ?: EQUAL + + operator fun get(name: String?) = entries.find { it.toString() == name } + } +} \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/NearFarTestResult.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/nearfar/NearFarTestResult.kt similarity index 94% rename from domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/NearFarTestResult.kt rename to domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/nearfar/NearFarTestResult.kt index a4c1910b..28de12ee 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/NearFarTestResult.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/model/test/nearfar/NearFarTestResult.kt @@ -1,8 +1,8 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.test.nearfar import android.os.Parcelable import kotlinx.parcelize.Parcelize -import ru.rznnike.eyehealthmanager.domain.model.enums.NearFarAnswerType +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult import ru.rznnike.eyehealthmanager.domain.utils.GlobalConstants import ru.rznnike.eyehealthmanager.domain.utils.toDate import ru.rznnike.eyehealthmanager.domain.utils.toTimeStamp diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/storage/repository/TestRepository.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/storage/repository/TestRepository.kt index 9b33079d..51f53a4f 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/storage/repository/TestRepository.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/storage/repository/TestRepository.kt @@ -1,7 +1,7 @@ package ru.rznnike.eyehealthmanager.domain.storage.repository -import ru.rznnike.eyehealthmanager.domain.model.TestResult -import ru.rznnike.eyehealthmanager.domain.model.TestResultPagingParameters +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultPagingParameters interface TestRepository { suspend fun getList(parameters: TestResultPagingParameters): List diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/utils/DateUtils.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/utils/DateUtils.kt index 332f472e..b439c018 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/utils/DateUtils.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/utils/DateUtils.kt @@ -43,7 +43,7 @@ fun Long.toDateTime(): ZonedDateTime = Instant.ofEpochMilli(this) fun Long.toLocalDate(): LocalDate = toDateTime().toLocalDate() -fun Long.getDayTime() = toDateTime().toLocalTime().toNanoOfDay() / 1000_000L +fun Long.getDayTime() = toDateTime().toLocalTime().toNanoOfDay() / 1_000_000L fun ZonedDateTime.millis() = toInstant().toEpochMilli() diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/utils/GlobalConstants.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/utils/GlobalConstants.kt index c494607e..b597b84f 100644 --- a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/utils/GlobalConstants.kt +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/utils/GlobalConstants.kt @@ -6,27 +6,4 @@ object GlobalConstants { const val DATE_PATTERN_SIMPLE = "dd.MM.yyyy" const val DATE_PATTERN_SIMPLE_WITH_TIME = "dd.MM.yyyy HH:mm" const val DATE_PATTERN_CLOCK = "HH:mm" - - const val APP_EXIT_DURATION_MS = 2500L - const val PRELOAD_ITEM_POSITION = 10 - - const val EXPORT_PAGE_SIZE = 100 - const val IMPORT_PAGE_SIZE = 100 - const val APP_DIR = "Eye Health Manager" - const val EXPORT_DIR = "export" - - const val FEEDBACK_EMAIL_ADDRESS = "rznnike@yandex.ru" - const val REPOSITORY_LINK = "https://github.com/RznNike/EyeHealthManager" - - const val MINUTE_MS = 60_1000L - const val DAY_MS = 86_400_000L - const val ANALYSIS_GROUPING_MIN_RANGE_DAYS = 3L - const val ANALYSIS_GROUPING_MIN_RANGE_MS = ANALYSIS_GROUPING_MIN_RANGE_DAYS * DAY_MS - const val ANALYSIS_GROUPING_MAX_RANGE_MS = 14 * DAY_MS - const val ANALYSIS_GROUPING_MIN_SIZE = 5 - const val ANALYSIS_MIN_GROUPS_COUNT = 2 - const val ANALYSIS_MIN_RESULTS_COUNT = ANALYSIS_GROUPING_MIN_SIZE * ANALYSIS_MIN_GROUPS_COUNT - const val ANALYSIS_MIN_RANGE_DAYS = ANALYSIS_GROUPING_MIN_RANGE_DAYS * ANALYSIS_MIN_GROUPS_COUNT - const val ANALYSIS_MAX_RANGE_DAYS = 90L - const val ANALYSIS_MAX_RANGE_MS = (ANALYSIS_MAX_RANGE_DAYS + 1) * DAY_MS - 1 // 90 days from day 1 start to day 90 end } \ No newline at end of file diff --git a/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/utils/JournalBackupManager.kt b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/utils/JournalBackupManager.kt new file mode 100644 index 00000000..ea7cac56 --- /dev/null +++ b/domain/src/main/java/ru/rznnike/eyehealthmanager/domain/utils/JournalBackupManager.kt @@ -0,0 +1,19 @@ +package ru.rznnike.eyehealthmanager.domain.utils + +import android.net.Uri +import ru.rznnike.eyehealthmanager.domain.model.journal.TestResultFilter +import ru.rznnike.eyehealthmanager.domain.model.test.TestResult +import java.time.Clock + +interface JournalBackupManager { + suspend fun exportJournal( + filter: TestResultFilter, + clock: Clock, + readDataFromDBCallback: suspend (filter: TestResultFilter, pageOffset: Int) -> List + ): Uri? + + suspend fun importJournal( + importFolderUri: Uri, + writeDataToDBCallback: suspend (List) -> Unit + ) +} \ No newline at end of file diff --git a/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/AcuityTestResultTest.kt b/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/test/acuity/AcuityTestResultTest.kt similarity index 91% rename from domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/AcuityTestResultTest.kt rename to domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/test/acuity/AcuityTestResultTest.kt index dc49bf20..61a94b31 100644 --- a/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/AcuityTestResultTest.kt +++ b/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/test/acuity/AcuityTestResultTest.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.test.acuity import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertFalse @@ -6,9 +6,8 @@ import org.junit.jupiter.api.Assertions.assertNull import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test -import ru.rznnike.eyehealthmanager.domain.model.enums.AcuityTestSymbolsType -import ru.rznnike.eyehealthmanager.domain.model.enums.DayPart -import ru.rznnike.eyehealthmanager.domain.model.enums.TestEyesType +import ru.rznnike.eyehealthmanager.domain.model.common.DayPart +import ru.rznnike.eyehealthmanager.domain.model.test.TestEyesType import java.util.TimeZone class AcuityTestResultTest { diff --git a/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/AstigmatismTestResultTest.kt b/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/test/astigmatism/AstigmatismTestResultTest.kt similarity index 93% rename from domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/AstigmatismTestResultTest.kt rename to domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/test/astigmatism/AstigmatismTestResultTest.kt index 04bbaa57..9a40aad0 100644 --- a/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/AstigmatismTestResultTest.kt +++ b/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/test/astigmatism/AstigmatismTestResultTest.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.test.astigmatism import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertFalse @@ -6,7 +6,6 @@ import org.junit.jupiter.api.Assertions.assertNull import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test -import ru.rznnike.eyehealthmanager.domain.model.enums.AstigmatismAnswerType import java.util.TimeZone class AstigmatismTestResultTest { diff --git a/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/ColorPerceptionTestResultTest.kt b/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/test/colorperception/ColorPerceptionTestResultTest.kt similarity index 96% rename from domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/ColorPerceptionTestResultTest.kt rename to domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/test/colorperception/ColorPerceptionTestResultTest.kt index 9a903e34..0e9307f8 100644 --- a/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/ColorPerceptionTestResultTest.kt +++ b/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/test/colorperception/ColorPerceptionTestResultTest.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.test.colorperception import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertFalse diff --git a/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/ContrastTestResultTest.kt b/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/test/contrast/ContrastTestResultTest.kt similarity index 96% rename from domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/ContrastTestResultTest.kt rename to domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/test/contrast/ContrastTestResultTest.kt index 379685c1..aa4761c5 100644 --- a/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/ContrastTestResultTest.kt +++ b/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/test/contrast/ContrastTestResultTest.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.test.contrast import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertFalse diff --git a/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/DaltonismTestResultTest.kt b/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/test/daltonism/DaltonismTestResultTest.kt similarity index 93% rename from domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/DaltonismTestResultTest.kt rename to domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/test/daltonism/DaltonismTestResultTest.kt index 1370866f..fd21a70b 100644 --- a/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/DaltonismTestResultTest.kt +++ b/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/test/daltonism/DaltonismTestResultTest.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.test.daltonism import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertFalse @@ -6,7 +6,6 @@ import org.junit.jupiter.api.Assertions.assertNull import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test -import ru.rznnike.eyehealthmanager.domain.model.enums.DaltonismAnomalyType import java.util.TimeZone class DaltonismTestResultTest { diff --git a/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/NearFarTestResultTest.kt b/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/test/nearfar/NearFarTestResultTest.kt similarity index 93% rename from domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/NearFarTestResultTest.kt rename to domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/test/nearfar/NearFarTestResultTest.kt index a7538c5f..9af65d7d 100644 --- a/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/NearFarTestResultTest.kt +++ b/domain/src/test/java/ru/rznnike/eyehealthmanager/domain/model/test/nearfar/NearFarTestResultTest.kt @@ -1,4 +1,4 @@ -package ru.rznnike.eyehealthmanager.domain.model +package ru.rznnike.eyehealthmanager.domain.model.test.nearfar import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertFalse @@ -6,7 +6,6 @@ import org.junit.jupiter.api.Assertions.assertNull import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test -import ru.rznnike.eyehealthmanager.domain.model.enums.NearFarAnswerType import java.util.TimeZone class NearFarTestResultTest { diff --git a/gradle.properties b/gradle.properties index e7a01200..c60e5c15 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,4 +19,6 @@ android.useAndroidX=true kotlin.code.style=official android.nonTransitiveRClass=false -android.nonFinalResIds=false \ No newline at end of file +android.nonFinalResIds=false + +android.disableMinifyLocalDependenciesForLibraries=false \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 08fe5735..6e2914a2 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/resources/src/main/res/values-ru/strings.xml b/resources/src/main/res/values-ru/strings.xml index e0c38baf..db23a650 100644 --- a/resources/src/main/res/values-ru/strings.xml +++ b/resources/src/main/res/values-ru/strings.xml @@ -197,7 +197,7 @@ Здравствуйте Это приложение - проект с открытым исходным кодом, написанный одним человеком на безвозмездной основе. Обо всех проблемах и пожеланиях вы можете писать на почту, указанную в настройках в разделе \"О программе\". Там же вы найдете ссылку на репозиторий с исходным кодом. Список изменений - 2.2.1\n• Добавлена возможность смены языка приложения из системных настроек (Android 13+).\n\n2.2.0\n• Добавлена темная тема. Вы можете выбрать темную/светлую тему на вкладке настроек главного экрана.\n• Исправление ошибок.\n\n2.1.1\n• Исправление ошибок.\n\n2.1.0\n• Оптимизация для Android 14.\n• Редизайн и улучшение UI.\n• Улучшен тест цветовосприятия.\n• Исправление ошибок.\n• Улучшение текстов. + 2.3.0\n• Оптимизация для Android 15.\n• Исправление ошибок.\n\n2.2.1\n• Добавлена возможность смены языка приложения из системных настроек (Android 13+).\n\n2.2.0\n• Добавлена темная тема. Вы можете выбрать темную/светлую тему на вкладке настроек главного экрана.\n• Исправление ошибок.\n\n2.1.1\n• Исправление ошибок.\n\n2.1.0\n• Оптимизация для Android 14.\n• Редизайн и улучшение UI.\n• Улучшен тест цветовосприятия.\n• Исправление ошибок.\n• Улучшение текстов. Файл не найден Системные уведомления без звука diff --git a/resources/src/main/res/values/strings.xml b/resources/src/main/res/values/strings.xml index 18975cdf..ce9e2a16 100644 --- a/resources/src/main/res/values/strings.xml +++ b/resources/src/main/res/values/strings.xml @@ -220,7 +220,7 @@ Hello This application is an open source project written by one person for free. You can write about all problems and wishes to the email specified in the settings in the \"About app\" section. There you will also find a link to the source code repository. Changelog - 2.2.1\n• Added the ability to change the application language from system settings (Android 13+).\n\n2.2.0\n• Dark theme added. You can choose dark/light theme from the main screen settings tab.\n• Bug fixes.\n\n2.1.1\n• Bug fixes.\n\n2.1.0\n• Optimization for Android 14.\n• Redesign and UI improvements.\n• Color perception test improved.\n• Bug fixes.\n• Improvement of texts. + 2.3.0\n• Optimization for Android 15.\n• Bug fixes.\n\n2.2.1\n• Added the ability to change the application language from system settings (Android 13+).\n\n2.2.0\n• Dark theme added. You can choose dark/light theme from the main screen settings tab.\n• Bug fixes.\n\n2.1.1\n• Bug fixes.\n\n2.1.0\n• Optimization for Android 14.\n• Redesign and UI improvements.\n• Color perception test improved.\n• Bug fixes.\n• Improvement of texts. File not found System notifications soundless diff --git a/settings.gradle.kts b/settings.gradle.kts index 9d43f8c2..d65aceae 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,2 +1,2 @@ -include(":device", ":resources", ":domain", ":data", ":app") +include(":resources", ":domain", ":data", ":app") rootProject.name = "Eye Health Manager" \ No newline at end of file