From cc16c193e60628e8b9c1253f9931d089a8e13edf Mon Sep 17 00:00:00 2001 From: T8RIN Date: Wed, 15 Jan 2025 12:18:20 +0300 Subject: [PATCH] Save last selected hashing algorithm in checksum tools --- .../screenLogic/ChecksumToolsComponent.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/feature/checksum-tools/src/main/java/ru/tech/imageresizershrinker/feature/checksum_tools/presentation/screenLogic/ChecksumToolsComponent.kt b/feature/checksum-tools/src/main/java/ru/tech/imageresizershrinker/feature/checksum_tools/presentation/screenLogic/ChecksumToolsComponent.kt index e19e70c81..f87dcf940 100644 --- a/feature/checksum-tools/src/main/java/ru/tech/imageresizershrinker/feature/checksum_tools/presentation/screenLogic/ChecksumToolsComponent.kt +++ b/feature/checksum-tools/src/main/java/ru/tech/imageresizershrinker/feature/checksum_tools/presentation/screenLogic/ChecksumToolsComponent.kt @@ -27,6 +27,7 @@ import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject import ru.tech.imageresizershrinker.core.domain.dispatchers.DispatchersHolder import ru.tech.imageresizershrinker.core.domain.model.HashingType +import ru.tech.imageresizershrinker.core.domain.saving.FileController import ru.tech.imageresizershrinker.core.ui.utils.BaseComponent import ru.tech.imageresizershrinker.core.ui.utils.state.update import ru.tech.imageresizershrinker.feature.checksum_tools.domain.ChecksumManager @@ -38,6 +39,7 @@ class ChecksumToolsComponent @AssistedInject constructor( @Assisted initialUri: Uri?, @Assisted val onGoBack: () -> Unit, private val checksumManager: ChecksumManager, + private val fileController: FileController, dispatchersHolder: DispatchersHolder ) : BaseComponent(dispatchersHolder, componentContext) { @@ -61,6 +63,10 @@ class ChecksumToolsComponent @AssistedInject constructor( init { debounce { initialUri?.let(::setUri) + fileController.restoreObject( + key = "checksum_type", + kClass = HashingType::class + )?.let(::updateChecksumType) } } @@ -141,6 +147,12 @@ class ChecksumToolsComponent @AssistedInject constructor( calculateFromUriPage.uri?.let(::setUri) calculateFromTextPage.text.let(::setText) compareWithUriPage.uri?.let(::setDataForComparison) + componentScope.launch { + fileController.saveObject( + key = "checksum_type", + value = type + ) + } } @AssistedFactory