Skip to content

Commit

Permalink
ktlintformat
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Meyer committed Dec 23, 2024
1 parent bcf6e58 commit 3b9e801
Show file tree
Hide file tree
Showing 39 changed files with 396 additions and 407 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ kover {
"*Hilt_*",
"*_HiltModules*",
"*BuildConfig",
"*_Factory",
"*_Factory"
)
packages(
"hilt_aggregated_deps",
"dagger.hilt.internal.aggregatedroot.codegen",
"*.di",
"*.di"
)
}
}
Expand Down
34 changes: 34 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,38 @@
# Keep all test classes
-keep class * {
@org.junit.Test *;
}

# JNA-related rules
-dontwarn com.sun.jna.**
-keep class com.sun.jna.** { *; }

# Windows-specific JNA rules
-dontwarn com.sun.jna.platform.win32.**
-keep class com.sun.jna.platform.win32.** { *; }

# ByteBuddy rules
-dontwarn net.bytebuddy.**
-keep class net.bytebuddy.** { *; }

# Java Instrumentation rules
-dontwarn java.lang.instrument.**
-keep class java.lang.instrument.** { *; }

# FindBugs annotations
-dontwarn edu.umd.cs.findbugs.annotations.**
-keep class edu.umd.cs.findbugs.annotations.** { *; }

# SLF4J logging
-dontwarn org.slf4j.**
-keep class org.slf4j.** { *; }

# MockK rules
-dontwarn io.mockk.**
-keep class io.mockk.** { *; }

# Keep any classes using specific annotations
-keep @edu.umd.cs.findbugs.annotations.SuppressFBWarnings class * { *; }
-keep class * {
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings *;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ class MainActivity : ComponentActivity() {
super.onCreate(savedInstanceState)
setContent {
SessionTimerTheme {
Box(Modifier
.safeDrawingPadding()
.padding(top = 16.dp, bottom = 42.dp)
Box(
Modifier
.safeDrawingPadding()
.padding(top = 16.dp, bottom = 42.dp)
) {
AppNavGraph()
}
Expand Down
2 changes: 1 addition & 1 deletion build-logic/src/main/kotlin/AndroidTestPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AndroidTestPlugin : Plugin<Project> {
"testImplementation"(libs.libRobolectric)
"testImplementation"(libs.libComposeTestJUnit)

"debugImplementation"(libs.libComposeTestManifest)
"testImplementation"(libs.libComposeTestManifest)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/database/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ kover {
excludes {
classes(
"net.onefivefour.sessiontimer.core.database.*Queries*",
"net.onefivefour.sessiontimer.core.database.database.*",
"net.onefivefour.sessiontimer.core.database.database.*"
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ val surfaceContainerLowestDark = Color(0xFF0C0F09)
val surfaceContainerLowDark = Color(0xFF1A1C16)
val surfaceContainerDark = Color(0xFF1E201A)
val surfaceContainerHighDark = Color(0xFF282B24)
val surfaceContainerHighestDark = Color(0xFF33362E)
val surfaceContainerHighestDark = Color(0xFF33362E)
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
package net.onefivefour.sessiontimer.core.theme

import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext

private val lightScheme = lightColorScheme(
primary = primaryLight,
Expand Down Expand Up @@ -48,7 +41,7 @@ private val lightScheme = lightColorScheme(
surfaceContainerLow = surfaceContainerLowLight,
surfaceContainer = surfaceContainerLight,
surfaceContainerHigh = surfaceContainerHighLight,
surfaceContainerHighest = surfaceContainerHighestLight,
surfaceContainerHighest = surfaceContainerHighestLight
)

private val darkScheme = darkColorScheme(
Expand Down Expand Up @@ -86,14 +79,11 @@ private val darkScheme = darkColorScheme(
surfaceContainerLow = surfaceContainerLowDark,
surfaceContainer = surfaceContainerDark,
surfaceContainerHigh = surfaceContainerHighDark,
surfaceContainerHighest = surfaceContainerHighestDark,
surfaceContainerHighest = surfaceContainerHighestDark
)

@Composable
fun SessionTimerTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable () -> Unit
) {
fun SessionTimerTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
val colorScheme = when {
darkTheme -> darkScheme
else -> lightScheme
Expand All @@ -104,4 +94,4 @@ fun SessionTimerTheme(
typography = typography,
content = content
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import kotlinx.coroutines.flow.Flow
import net.onefivefour.sessiontimer.core.timer.api.model.TimerState

interface SessionTimer {
val state: Flow<TimerState>
fun init(totalDuration: Duration)
fun start()
fun pause()
fun reset()
fun getStatus(): Flow<TimerState>
fun seekTo(seekTo: Duration)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ val FAKE_TIMER_STATUS_IDLE = TimerState(
elapsedDuration = Duration.ZERO
)

fun FAKE_TIMER_STATUS_FINISHED(totalDuration: Duration) = TimerState(
fun fakeTimerStatusFinished(totalDuration: Duration) = TimerState(
TimerMode.FINISHED,
elapsedDuration = totalDuration
)
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package net.onefivefour.sessiontimer.core.timer

class NotInitializedException : Throwable("Initialize SessionTimer first.")
class NotInitializedException : Throwable("Initialize SessionTimer first.")
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
package net.onefivefour.sessiontimer.core.timer

import javax.inject.Inject
import javax.inject.Singleton
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import net.onefivefour.sessiontimer.core.di.DefaultDispatcher
import net.onefivefour.sessiontimer.core.timer.api.SessionTimer
import net.onefivefour.sessiontimer.core.timer.api.model.TimerMode
import net.onefivefour.sessiontimer.core.timer.api.model.TimerState
import javax.inject.Inject
import javax.inject.Singleton
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds

@Singleton
internal class SessionTimerImpl @Inject constructor(
Expand All @@ -29,6 +27,8 @@ internal class SessionTimerImpl @Inject constructor(
private val timerScope = CoroutineScope(dispatcher)

private var _state = MutableStateFlow(TimerState())
override val state = _state.asStateFlow()

private var timerJob: Job? = null

override fun init(totalDuration: Duration) {
Expand All @@ -48,7 +48,6 @@ internal class SessionTimerImpl @Inject constructor(
}
}
}

}

override fun pause() {
Expand Down Expand Up @@ -87,7 +86,7 @@ internal class SessionTimerImpl @Inject constructor(
}

state.mode == TimerMode.FINISHED &&
newElapsed < currentTotalDuration -> TimerMode.PAUSED
newElapsed < currentTotalDuration -> TimerMode.PAUSED

else -> state.mode
}
Expand All @@ -97,8 +96,6 @@ internal class SessionTimerImpl @Inject constructor(

private fun updateTimerStatus() = updateProgress(Duration.ZERO)

override fun getStatus() = _state

private fun cancelTimer() {
timerJob?.cancel()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.test.advanceUntilIdle
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import net.onefivefour.sessiontimer.core.test.StandardTestDispatcherRule
import net.onefivefour.sessiontimer.core.timer.api.model.TimerMode
Expand Down Expand Up @@ -37,7 +36,7 @@ internal class SessionTimerImplTest {
delay(6000)

// THEN
val status = sut.getStatus().first()
val status = sut.state.first()
assertThat(status.mode).isEqualTo(TimerMode.FINISHED)
assertThat(status.elapsedDuration >= totalDuration).isTrue()
}
Expand All @@ -57,7 +56,7 @@ internal class SessionTimerImplTest {
advanceUntilIdle()

// THEN
val status = sut.getStatus().first()
val status = sut.state.first()
assertThat(status.mode).isEqualTo(TimerMode.PAUSED)
assertThat(status.elapsedDuration.inWholeSeconds).isEqualTo(2)
}
Expand All @@ -75,7 +74,7 @@ internal class SessionTimerImplTest {
sut.reset()

// THEN
val status = sut.getStatus().first()
val status = sut.state.first()
assertThat(status.mode).isEqualTo(TimerMode.IDLE)
assertThat(status.elapsedDuration).isEqualTo(0.seconds)
}
Expand All @@ -93,15 +92,15 @@ internal class SessionTimerImplTest {
delay(3000)

// THEN
val status1 = sut.getStatus().first()
val status1 = sut.state.first()
assertThat(status1.mode).isEqualTo(TimerMode.RUNNING)
assertThat(status1.elapsedDuration > Duration.ZERO).isTrue()

// WHEN
delay(3000)

// THEN
val status2 = sut.getStatus().first()
val status2 = sut.state.first()
assertThat(TimerMode.FINISHED).isEqualTo(status2.mode)
assertThat(status2.elapsedDuration >= totalDuration)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ internal class GetTimerStatusUseCaseImpl @Inject constructor(
) : GetTimerStatusUseCase {

override fun execute(): Flow<TimerState> {
return sessionTimer.getStatus()
return sessionTimer.state
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package net.onefivefour.sessiontimer.core.usecases.timer

import dagger.hilt.android.scopes.ViewModelScoped
import javax.inject.Inject
import kotlin.time.Duration
import net.onefivefour.sessiontimer.core.timer.api.SessionTimer
import net.onefivefour.sessiontimer.core.usecases.api.timer.InitSessionTimerUseCase
import kotlin.time.Duration

@ViewModelScoped
internal class InitSessionTimerUseCaseImpl @Inject constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import javax.inject.Inject
import kotlin.time.Duration
import net.onefivefour.sessiontimer.core.timer.api.SessionTimer
import net.onefivefour.sessiontimer.core.usecases.api.timer.SeekTimerUseCase
import net.onefivefour.sessiontimer.core.usecases.api.timer.StartTimerUseCase

@ViewModelScoped
class SeekTimerUseCaseImpl @Inject constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package net.onefivefour.sessiontimer.core.usecases.timer

import dagger.hilt.android.scopes.ViewModelScoped
import javax.inject.Inject
import kotlin.time.Duration
import net.onefivefour.sessiontimer.core.timer.api.SessionTimer
import net.onefivefour.sessiontimer.core.usecases.api.timer.StartTimerUseCase

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal class GetTimerStateUseCaseTest {
fun `GIVEN a new timerStates WHEN executing the UseCase THEN it is calling getStatus on the sessionTimer`() =
runTest {
// GIVEN
coEvery { sessionTimer.getStatus() } returns flowOf(
coEvery { sessionTimer.state } returns flowOf(
TimerState()
)

Expand All @@ -36,6 +36,6 @@ internal class GetTimerStateUseCaseTest {
}

// THEN
verify { sessionTimer.getStatus() }
verify { sessionTimer.state }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package net.onefivefour.sessiontimer.core.usecases.timer

import io.mockk.mockk
import io.mockk.verify
import kotlin.time.Duration
import net.onefivefour.sessiontimer.core.timer.api.SessionTimer
import org.junit.Test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ internal data class UiTask(
val title: String,
val duration: Duration
)

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.ComposeContentTestRule
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.onRoot
import androidx.compose.ui.test.printToString
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
Expand All @@ -22,9 +24,15 @@ class SessionEditorErrorTest {
with(composeTestRule) {
initNode()

onNodeWithText(errorMessage)
.assertIsDisplayed()

try {
onNodeWithText(errorMessage)
.assertExists()
.assertIsDisplayed()
} catch (e: AssertionError) {
// Print the semantic tree to help debug
println("Semantic tree: ${composeTestRule.onRoot().printToString()}")
throw e
}
}
}

Expand All @@ -33,5 +41,4 @@ class SessionEditorErrorTest {
SessionEditorError(errorMessage)
}
}

}
}
Loading

0 comments on commit 3b9e801

Please sign in to comment.