From 4a318cc22d5a7be18260c957297aa0685274e63b Mon Sep 17 00:00:00 2001 From: Leonardo Colman Lopes Date: Thu, 24 Oct 2024 21:32:22 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=9A=20Rename=20BlockRepository=20to=20?= =?UTF-8?q?CensorshipRepository?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Leonardo Colman Lopes --- .../com/colman/petals/ScreenshotTakerTest.kt | 10 +++++----- .../kotlin/br/com/colman/petals/KoinModule.kt | 4 ++-- .../br/com/colman/petals/use/UseBlock.kt | 18 +++++++++--------- ...ckRepository.kt => CensorshipRepository.kt} | 2 +- ...toryTest.kt => CensorshipRepositoryTest.kt} | 4 ++-- 5 files changed, 19 insertions(+), 19 deletions(-) rename app/src/main/kotlin/br/com/colman/petals/use/repository/{BlockRepository.kt => CensorshipRepository.kt} (98%) rename app/src/test/kotlin/br/com/colman/petals/use/repository/{BlockRepositoryTest.kt => CensorshipRepositoryTest.kt} (93%) diff --git a/app/src/androidTest/kotlin/br/com/colman/petals/ScreenshotTakerTest.kt b/app/src/androidTest/kotlin/br/com/colman/petals/ScreenshotTakerTest.kt index e8eb5bbe..1478d390 100644 --- a/app/src/androidTest/kotlin/br/com/colman/petals/ScreenshotTakerTest.kt +++ b/app/src/androidTest/kotlin/br/com/colman/petals/ScreenshotTakerTest.kt @@ -19,7 +19,7 @@ import androidx.compose.ui.test.swipeUp import br.com.colman.kotest.FunSpec import br.com.colman.petals.navigation.Page import br.com.colman.petals.use.io.input.UseImporter -import br.com.colman.petals.use.repository.BlockRepository +import br.com.colman.petals.use.repository.CensorshipRepository import br.com.colman.petals.use.repository.BlockType import com.github.kittinunf.fuel.Fuel import com.github.kittinunf.fuel.core.FileDataPart @@ -60,8 +60,8 @@ class ScreenshotTakerTest : FunSpec({ locales.forEach { (lang, country) -> activity?.setLocale(Locale(lang, country)) - val blockRepository by koin.inject() - blockRepository.setBlockCensure(BlockType.Today, true) + val censorshipRepository by koin.inject() + censorshipRepository.setBlockCensure(BlockType.Today, true) waitForIdle() takeScreenshot("1.png", lang, country) @@ -76,8 +76,8 @@ class ScreenshotTakerTest : FunSpec({ locales.forEach { (lang, country) -> activity?.setLocale(Locale(lang, country)) - val blockRepository by koin.inject() - blockRepository.setBlockCensure(BlockType.Today, true) + val censorshipRepository by koin.inject() + censorshipRepository.setBlockCensure(BlockType.Today, true) waitForIdle() diff --git a/app/src/main/kotlin/br/com/colman/petals/KoinModule.kt b/app/src/main/kotlin/br/com/colman/petals/KoinModule.kt index a3222a64..ec0f9eeb 100644 --- a/app/src/main/kotlin/br/com/colman/petals/KoinModule.kt +++ b/app/src/main/kotlin/br/com/colman/petals/KoinModule.kt @@ -24,7 +24,7 @@ import br.com.colman.petals.hittimer.HitTimerRepository import br.com.colman.petals.settings.SettingsMigrations import br.com.colman.petals.settings.SettingsRepository import br.com.colman.petals.use.pause.repository.PauseRepository -import br.com.colman.petals.use.repository.BlockRepository +import br.com.colman.petals.use.repository.CensorshipRepository import br.com.colman.petals.use.repository.UseRepository import org.koin.dsl.module @@ -37,5 +37,5 @@ val KoinModule = module { single { HitTimerRepository(get()) } single { SettingsRepository(get().settingsDatastore) } single { SettingsMigrations(get().settingsDatastore) } - single { BlockRepository(get().blockDataStore) } + single { CensorshipRepository(get().blockDataStore) } } diff --git a/app/src/main/kotlin/br/com/colman/petals/use/UseBlock.kt b/app/src/main/kotlin/br/com/colman/petals/use/UseBlock.kt index ea24ea16..3a4997b0 100644 --- a/app/src/main/kotlin/br/com/colman/petals/use/UseBlock.kt +++ b/app/src/main/kotlin/br/com/colman/petals/use/UseBlock.kt @@ -51,7 +51,7 @@ import androidx.compose.ui.unit.dp import br.com.colman.petals.R import br.com.colman.petals.R.string.amount_grams_short import br.com.colman.petals.settings.SettingsRepository -import br.com.colman.petals.use.repository.BlockRepository +import br.com.colman.petals.use.repository.CensorshipRepository import br.com.colman.petals.use.repository.BlockType import br.com.colman.petals.use.repository.BlockType.AllTime import br.com.colman.petals.use.repository.BlockType.ThisMonth @@ -73,14 +73,14 @@ import java.time.LocalTime @Composable fun StatsBlocks(uses: List) { - val blockRepository = koinInject() + val censorshipRepository = koinInject() val settingsRepository = koinInject() - val isTodayCensored by blockRepository.isTodayCensored.collectAsState(true) - val isThisWeekCensored by blockRepository.isThisWeekCensored.collectAsState(true) - val isThisMonthCensored by blockRepository.isThisMonthCensored.collectAsState(true) - val isThisYearCensored by blockRepository.isThisYearCensored.collectAsState(true) - val isAllTimeCensored by blockRepository.isAllTimeCensored.collectAsState(true) + val isTodayCensored by censorshipRepository.isTodayCensored.collectAsState(true) + val isThisWeekCensored by censorshipRepository.isThisWeekCensored.collectAsState(true) + val isThisMonthCensored by censorshipRepository.isThisMonthCensored.collectAsState(true) + val isThisYearCensored by censorshipRepository.isThisYearCensored.collectAsState(true) + val isAllTimeCensored by censorshipRepository.isAllTimeCensored.collectAsState(true) val isDayExtended by settingsRepository.isDayExtended.collectAsState(false) Row(Modifier.horizontalScroll(rememberScrollState()).width(Max).testTag("StatsBlockMainRow")) { @@ -133,7 +133,7 @@ private fun UseBlock( isCensored: Boolean = true ) { val settingsRepository = koinInject() - val blockRepository = koinInject() + val censorshipRepository = koinInject() val currencyIcon by settingsRepository.currencyIcon.collectAsState("$") @@ -141,7 +141,7 @@ private fun UseBlock( Column(Modifier.padding(8.dp), spacedBy(4.dp)) { Row(Modifier.padding(8.dp).fillMaxWidth(), Center, CenterVertically) { Text(stringResource(blockType.resourceId), fontWeight = Bold) - IconButton({ blockRepository.setBlockCensure(blockType, !isCensored) }) { + IconButton({ censorshipRepository.setBlockCensure(blockType, !isCensored) }) { CensureIcon(isCensored) } } diff --git a/app/src/main/kotlin/br/com/colman/petals/use/repository/BlockRepository.kt b/app/src/main/kotlin/br/com/colman/petals/use/repository/CensorshipRepository.kt similarity index 98% rename from app/src/main/kotlin/br/com/colman/petals/use/repository/BlockRepository.kt rename to app/src/main/kotlin/br/com/colman/petals/use/repository/CensorshipRepository.kt index 7b36ae71..6c838aac 100644 --- a/app/src/main/kotlin/br/com/colman/petals/use/repository/BlockRepository.kt +++ b/app/src/main/kotlin/br/com/colman/petals/use/repository/CensorshipRepository.kt @@ -14,7 +14,7 @@ import br.com.colman.petals.use.repository.BlockType.Today import kotlinx.coroutines.flow.map import kotlinx.coroutines.runBlocking -class BlockRepository( +class CensorshipRepository( private val datastore: DataStore ) { val isTodayCensored = datastore.data.map { it[Today.preferencesKey] ?: false } diff --git a/app/src/test/kotlin/br/com/colman/petals/use/repository/BlockRepositoryTest.kt b/app/src/test/kotlin/br/com/colman/petals/use/repository/CensorshipRepositoryTest.kt similarity index 93% rename from app/src/test/kotlin/br/com/colman/petals/use/repository/BlockRepositoryTest.kt rename to app/src/test/kotlin/br/com/colman/petals/use/repository/CensorshipRepositoryTest.kt index 38cb7d03..7df3430d 100644 --- a/app/src/test/kotlin/br/com/colman/petals/use/repository/BlockRepositoryTest.kt +++ b/app/src/test/kotlin/br/com/colman/petals/use/repository/CensorshipRepositoryTest.kt @@ -8,9 +8,9 @@ import io.kotest.engine.spec.tempfile import io.kotest.matchers.shouldBe import kotlinx.coroutines.flow.first -class BlockRepositoryTest : FunSpec({ +class CensorshipRepositoryTest : FunSpec({ val datastore: DataStore = PreferenceDataStoreFactory.create { tempfile(suffix = ".preferences_pb") } - val target = BlockRepository(datastore) + val target = CensorshipRepository(datastore) test("Defaults block censor to false") { BlockType.entries.forEach { blockType ->