diff --git a/.editorconfig b/.editorconfig index 681f909..5a4c813 100644 --- a/.editorconfig +++ b/.editorconfig @@ -18,11 +18,14 @@ max_line_length = 120 [*.md] trim_trailing_whitespace = false +[{version.txt,versioncode.txt}] +trim_trailing_whitespace = true +insert_final_newline = false + [*.{kt,kts}] ktlint_code_style = ktlint_official ktlint_standard_no-wildcard-imports = disabled ktlint_standard_annotation = disabled # false positive with @JvmOverloads and default constructor - -[{version.txt,versioncode.txt}] -trim_trailing_whitespace = true -insert_final_newline = false +ktlint_function_naming_ignore_when_annotated_with = Composable +ktlint_standard_multiline-expression-wrapping = disabled +ktlint_standard_string-template-indent = disabled diff --git a/.github/workflows/dash.yaml b/.github/workflows/dash.yaml index 09078bc..2389d0d 100755 --- a/.github/workflows/dash.yaml +++ b/.github/workflows/dash.yaml @@ -1,7 +1,10 @@ name: Dash license check on: - pull_request + pull_request: + push: + branches: + - main jobs: check-dash: diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 43320d7..72f2e08 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -99,6 +99,10 @@ android { noCompress += "ramses" noCompress += "rlogic" } + sourceSets.getByName("main") { + java.srcDir("src/main/java") + java.srcDir("src/main/kotlin") + } } dependencies { diff --git a/app/src/main/kotlin/org/eclipse/kuksa/companion/MainActivity.kt b/app/src/main/kotlin/org/eclipse/kuksa/companion/MainActivity.kt index f4142c3..d5c0ed9 100644 --- a/app/src/main/kotlin/org/eclipse/kuksa/companion/MainActivity.kt +++ b/app/src/main/kotlin/org/eclipse/kuksa/companion/MainActivity.kt @@ -45,7 +45,7 @@ import org.eclipse.kuksa.companion.feature.door.viewModel.DoorControlViewModel.C import org.eclipse.kuksa.companion.feature.door.viewModel.DoorControlViewModel.Companion.DOOR_ALL_OPEN import org.eclipse.kuksa.companion.feature.door.viewModel.DoorControlViewModel.Companion.TRUNK_CLOSED import org.eclipse.kuksa.companion.feature.door.viewModel.DoorControlViewModel.Companion.TRUNK_OPEN -import org.eclipse.kuksa.companion.feature.home.view.HomeScreen +import org.eclipse.kuksa.companion.feature.home.view.HOME_SCREEN import org.eclipse.kuksa.companion.feature.home.view.RamsesView import org.eclipse.kuksa.companion.feature.home.view.homeScreen import org.eclipse.kuksa.companion.feature.light.viewmodel.LightControlViewModel @@ -151,7 +151,7 @@ class MainActivity : ComponentActivity() { KuksaCompanionTheme { val navController = rememberNavController() RamsesView(callback = doorVehicleSurface) - NavHost(navController, startDestination = HomeScreen) { + NavHost(navController, startDestination = HOME_SCREEN) { homeScreen( connectionStatusViewModel = connectionStatusViewModel, doorControlViewModel = doorControlViewModel, diff --git a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/connection/factory/DataBrokerConnectorFactory.kt b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/connection/factory/DataBrokerConnectorFactory.kt index 795ece1..d85e4ca 100644 --- a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/connection/factory/DataBrokerConnectorFactory.kt +++ b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/connection/factory/DataBrokerConnectorFactory.kt @@ -30,7 +30,10 @@ import org.eclipse.kuksa.companion.feature.connection.model.ConnectionInfo import java.io.IOException class DataBrokerConnectorFactory { - fun create(context: Context, connectionInfo: ConnectionInfo): DataBrokerConnector { + fun create( + context: Context, + connectionInfo: ConnectionInfo, + ): DataBrokerConnector { val isTlsEnabled = connectionInfo.isTlsEnabled return if (isTlsEnabled) { createSecureConnector(context, connectionInfo) @@ -48,7 +51,10 @@ class DataBrokerConnectorFactory { return DataBrokerConnector(managedChannel) } - private fun createSecureConnector(context: Context, connectionInfo: ConnectionInfo): DataBrokerConnector { + private fun createSecureConnector( + context: Context, + connectionInfo: ConnectionInfo, + ): DataBrokerConnector { val host = connectionInfo.host val port = connectionInfo.port diff --git a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/connection/repository/ConnectionInfoRepository.kt b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/connection/repository/ConnectionInfoRepository.kt index e185222..fc8b462 100644 --- a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/connection/repository/ConnectionInfoRepository.kt +++ b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/connection/repository/ConnectionInfoRepository.kt @@ -33,7 +33,6 @@ import javax.inject.Singleton class ConnectionInfoRepository @Inject constructor( @ApplicationContext context: Context, ) { - private val Context.dataStore: DataStore by dataStore(PREFERENCES_NAME, ConnectionInfoSerializer) private val dataStore = context.dataStore diff --git a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/connection/view/ConnectionStatusView.kt b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/connection/view/ConnectionStatusView.kt index 185e8b7..91f3aab 100644 --- a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/connection/view/ConnectionStatusView.kt +++ b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/connection/view/ConnectionStatusView.kt @@ -48,20 +48,22 @@ import org.eclipse.kuksa.companion.feature.connection.viewModel.ConnectionStatus import org.eclipse.kuksa.companion.feature.connection.viewModel.ConnectionStatusViewModel.ConnectionState import kotlin.time.Duration.Companion.milliseconds -const val MaxNumberOfDots = 3 -val StatusBarHeight = 30.dp -val DelayDuration = 500.milliseconds +private const val MAX_NUMBER_OF_DOTS = 3 + +private val StatusBarHeight = 30.dp +private val DelayDuration = 500.milliseconds @Composable fun ConnectionStatusView( viewModel: ConnectionStatusViewModel, + modifier: Modifier = Modifier, ) { val connectionState = viewModel.connectionState val connectionStateLabel = connectionState.toString().lowercase() val backgroundColor = viewModel.backgroundColor Row( - modifier = Modifier + modifier = modifier .fillMaxWidth() .height(StatusBarHeight) .background(backgroundColor) @@ -79,7 +81,7 @@ fun ConnectionStatusView( } LaunchedEffect(Unit) { while (true) { - if (numberOfDots.intValue < MaxNumberOfDots) { + if (numberOfDots.intValue < MAX_NUMBER_OF_DOTS) { numberOfDots.intValue += 1 } else { numberOfDots.intValue = 0 diff --git a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/connection/viewModel/ConnectionStatusViewModel.kt b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/connection/viewModel/ConnectionStatusViewModel.kt index 68840fe..fa88f5b 100644 --- a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/connection/viewModel/ConnectionStatusViewModel.kt +++ b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/connection/viewModel/ConnectionStatusViewModel.kt @@ -28,7 +28,6 @@ import androidx.lifecycle.ViewModel import org.eclipse.kuksa.companion.extension.DarkGreen class ConnectionStatusViewModel : ViewModel() { - enum class ConnectionState { DISCONNECTED, CONNECTING, diff --git a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/door/surface/DoorVehicleSceneThread.kt b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/door/surface/DoorVehicleSceneThread.kt index 9def36f..30a1df8 100644 --- a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/door/surface/DoorVehicleSceneThread.kt +++ b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/door/surface/DoorVehicleSceneThread.kt @@ -51,7 +51,6 @@ class DoorVehicleSceneThread( threadName: String, private val viewModel: DoorControlViewModel, ) : RamsesThread(threadName, viewModel.getApplication()), DoorVehicleScene { - private var doorRow1DriverSide: VssProperty = VssDoor.VssRow1.VssDriverSide.VssIsOpen() private var doorRow1PassengerSide: VssProperty = VssDoor.VssRow1.VssPassengerSide.VssIsOpen() private var doorRow2DriverSide: VssProperty = VssDoor.VssRow2.VssDriverSide.VssIsOpen() @@ -101,7 +100,11 @@ class DoorVehicleSceneThread( doorTrunkRearProperty?.set(doorTrunkRear.value.toFloat) } - fun moveCamera(yawValue: Float, pitchValue: Float, camDistanceValue: Float) { + fun moveCamera( + yawValue: Float, + pitchValue: Float, + camDistanceValue: Float, + ) { addRunnableToThreadQueue { this.yawValue = yawValue this.pitchValue = pitchValue @@ -170,7 +173,10 @@ class DoorVehicleSceneThread( * Overrides the base class method which calls this based on thread scheduling * This method is executed from the correct thread (the one which talks to ramses) */ - override fun onDisplayResize(width: Int, height: Int) { + override fun onDisplayResize( + width: Int, + height: Int, + ) { cameraViewportWProperty?.set(width) cameraViewportHProperty?.set(height) screenWidth = width diff --git a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/door/surface/DoorVehicleSurface.kt b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/door/surface/DoorVehicleSurface.kt index e688677..866ecd1 100644 --- a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/door/surface/DoorVehicleSurface.kt +++ b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/door/surface/DoorVehicleSurface.kt @@ -81,7 +81,12 @@ class DoorVehicleSurface : AndroidRamsesSurface Unit, ) { - composable(HomeScreen) { + composable(HOME_SCREEN) { HomeScreen( connectionStatusViewModel = connectionStatusViewModel, doorControlViewModel = doorControlViewModel, @@ -53,5 +53,5 @@ fun NavGraphBuilder.homeScreen( } fun NavController.navigateToMainScreen(navOptions: NavOptions? = null) { - navigate(HomeScreen, navOptions) + navigate(HOME_SCREEN, navOptions) } diff --git a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/home/view/HomeScreen.kt b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/home/view/HomeScreen.kt index 8cc3949..d683857 100644 --- a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/home/view/HomeScreen.kt +++ b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/home/view/HomeScreen.kt @@ -48,9 +48,13 @@ fun HomeScreen( temperatureViewModel: TemperatureViewModel, lightControlViewModel: LightControlViewModel, wheelPressureViewModel: WheelPressureViewModel, + modifier: Modifier = Modifier, onNavigateToSettingsScreen: () -> Unit, ) { - Scaffold(containerColor = Color.White.copy(alpha = 0f)) { + Scaffold( + containerColor = Color.White.copy(alpha = 0f), + modifier = modifier, + ) { Column( modifier = Modifier .consumeWindowInsets(it) diff --git a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/home/view/RamsesView.kt b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/home/view/RamsesView.kt index b3bed89..fda29e2 100644 --- a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/home/view/RamsesView.kt +++ b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/home/view/RamsesView.kt @@ -30,6 +30,7 @@ import androidx.compose.ui.viewinterop.AndroidView @Composable fun RamsesView( callback: SurfaceHolder.Callback, + modifier: Modifier = Modifier, ) { AndroidView( { context -> @@ -37,7 +38,7 @@ fun RamsesView( holder.addCallback(callback) } }, - modifier = Modifier.fillMaxSize(), + modifier = modifier.fillMaxSize(), ) } @@ -50,7 +51,12 @@ private fun RamsesViewPreview() { // ignored } - override fun surfaceChanged(p0: SurfaceHolder, p1: Int, p2: Int, p3: Int) { + override fun surfaceChanged( + p0: SurfaceHolder, + p1: Int, + p2: Int, + p3: Int, + ) { // ignored } diff --git a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/home/view/TabRowHost.kt b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/home/view/TabRowHost.kt index db1712f..5db1abb 100644 --- a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/home/view/TabRowHost.kt +++ b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/home/view/TabRowHost.kt @@ -53,13 +53,13 @@ import org.eclipse.kuksa.companion.feature.temperature.viewmodel.TemperatureView import org.eclipse.kuksa.companion.feature.wheel.pressure.view.WheelPressureControlView import org.eclipse.kuksa.companion.feature.wheel.pressure.viewmodel.WheelPressureViewModel -private const val TabIndexDoors = 0 -private const val TabIndexTemperature = 1 -private const val TabIndexLight = 2 -private const val TabIndexWheelPressure = 3 +private const val TAB_INDEX_DOORS = 0 +private const val TAB_INDEX_TEMPERATURE = 1 +private const val TAB_INDEX_LIGHT = 2 +private const val TAB_INDEX_WHEEL_PRESSURE = 3 -private const val FabOffsetX = -10 -private const val FabOffsetY = 10 +private const val FAB_OFFSET_X = -10 +private const val FAB_OFFSET_Y = 10 @Composable fun TabRowHost( @@ -67,9 +67,10 @@ fun TabRowHost( temperatureViewModel: TemperatureViewModel, lightControlViewModel: LightControlViewModel, wheelPressureViewModel: WheelPressureViewModel, + modifier: Modifier = Modifier, fabContent: @Composable () -> Unit, ) { - var selectedTabIndex by remember { mutableIntStateOf(TabIndexDoors) } + var selectedTabIndex by remember { mutableIntStateOf(TAB_INDEX_DOORS) } val tabData = listOf( TabData(R.drawable.baseline_sensor_door_24, "Doors"), @@ -78,7 +79,7 @@ fun TabRowHost( TabData(R.drawable.baseline_sports_volleyball_24, "Wheel Pressure"), ) - Column { + Column(modifier = modifier) { TabRow( selectedTabIndex = selectedTabIndex, modifier = Modifier @@ -100,15 +101,15 @@ fun TabRowHost( Box { when (selectedTabIndex) { - TabIndexDoors -> DoorControlView(doorControlViewModel) - TabIndexTemperature -> TemperatureControlView(temperatureViewModel) - TabIndexLight -> LightControlView(lightControlViewModel) - TabIndexWheelPressure -> WheelPressureControlView(wheelPressureViewModel) + TAB_INDEX_DOORS -> DoorControlView(doorControlViewModel) + TAB_INDEX_TEMPERATURE -> TemperatureControlView(temperatureViewModel) + TAB_INDEX_LIGHT -> LightControlView(lightControlViewModel) + TAB_INDEX_WHEEL_PRESSURE -> WheelPressureControlView(wheelPressureViewModel) } Column( modifier = Modifier .align(Alignment.TopEnd) - .offset(FabOffsetX.dp, FabOffsetY.dp), + .offset(FAB_OFFSET_X.dp, FAB_OFFSET_Y.dp), ) { fabContent() } diff --git a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/light/view/LightControlView.kt b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/light/view/LightControlView.kt index aa81505..7871cbf 100644 --- a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/light/view/LightControlView.kt +++ b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/light/view/LightControlView.kt @@ -53,10 +53,14 @@ import org.eclipse.kuksa.vsscore.model.VssProperty @OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class) @Composable -fun LightControlView(viewModel: LightControlViewModel) { +fun LightControlView( + viewModel: LightControlViewModel, + modifier: Modifier = Modifier, +) { BottomSheetScaffold( sheetContent = { BottomSheetContent(viewModel) }, containerColor = Color.White.copy(alpha = 0f), + modifier = modifier, ) { Column( modifier = Modifier diff --git a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/settings/navigation/SettingsNavigation.kt b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/settings/navigation/SettingsNavigation.kt index b72b9b0..ac98df6 100644 --- a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/settings/navigation/SettingsNavigation.kt +++ b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/settings/navigation/SettingsNavigation.kt @@ -26,12 +26,13 @@ import androidx.navigation.compose.composable import org.eclipse.kuksa.companion.feature.settings.view.SettingsView import org.eclipse.kuksa.companion.feature.settings.viewModel.SettingsViewModel -const val SettingsView = "settings" +const val SETTINGS_VIEW = "settings" + fun NavGraphBuilder.settingsScreen( settingsViewModel: SettingsViewModel, onNavigateBack: () -> Unit, ) { - composable(SettingsView) { + composable(SETTINGS_VIEW) { SettingsView( settingsViewModel = settingsViewModel, onNavigateBack = onNavigateBack, @@ -40,5 +41,5 @@ fun NavGraphBuilder.settingsScreen( } fun NavController.navigateToSettingsScreen(navOptions: NavOptions? = null) { - navigate(SettingsView, navOptions) + navigate(SETTINGS_VIEW, navOptions) } diff --git a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/settings/view/SettingsView.kt b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/settings/view/SettingsView.kt index 5f47c64..ae8675f 100644 --- a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/settings/view/SettingsView.kt +++ b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/settings/view/SettingsView.kt @@ -81,6 +81,7 @@ import org.eclipse.kuksa.companion.feature.settings.viewModel.SettingsViewModel @Composable fun SettingsView( settingsViewModel: SettingsViewModel, + modifier: Modifier = Modifier, onNavigateBack: () -> Unit, ) { val connectionInfoState @@ -91,8 +92,8 @@ fun SettingsView( } Scaffold( - topBar = { TopBar(onNavigateBack) }, - modifier = Modifier.fillMaxSize(), + topBar = { TopBar(onNavigateBack = onNavigateBack) }, + modifier = modifier.fillMaxSize(), ) { paddingValues -> Surface( modifier = Modifier @@ -209,6 +210,7 @@ fun TextDialog( label: String, value: String, onClickOk: (String) -> Unit, + modifier: Modifier = Modifier, onClickCancel: () -> Unit, ) { val keyboardController = LocalSoftwareKeyboardController.current @@ -216,7 +218,7 @@ fun TextDialog( var newValue by remember { mutableStateOf(value) } Column( - modifier = Modifier + modifier = modifier .clip(RoundedCornerShape(4.dp)) .background(MaterialTheme.colorScheme.background) .padding(8.dp), @@ -266,13 +268,20 @@ fun TextDialog( } @Suppress( - "SameParameterValue", // re-usability - "MagicNumber", // it does not make sense to create a constant for each elements weight + // re-usability + "SameParameterValue", + // it does not make sense to create a constant for each elements weight + "MagicNumber", ) @Composable -private fun SwitchSetting(label: String, enabled: Boolean, onValueChanged: (Boolean) -> Unit) { +private fun SwitchSetting( + label: String, + enabled: Boolean, + modifier: Modifier = Modifier, + onValueChanged: (Boolean) -> Unit, +) { Row( - modifier = Modifier.padding(10.dp), + modifier = modifier.padding(10.dp), ) { Text( text = label, @@ -331,7 +340,10 @@ private fun FileSelectorSetting( @OptIn(ExperimentalMaterial3Api::class) @Composable -fun TopBar(onNavigateBack: () -> Unit) { +fun TopBar( + modifier: Modifier = Modifier, + onNavigateBack: () -> Unit, +) { TopAppBar( title = { Text("Settings") }, colors = TopAppBarDefaults.mediumTopAppBarColors( @@ -342,6 +354,7 @@ fun TopBar(onNavigateBack: () -> Unit) { Icon(Icons.Filled.ArrowBack, "Back") } }, + modifier = modifier, ) } diff --git a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/temperature/view/TemperatureControlView.kt b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/temperature/view/TemperatureControlView.kt index 68ae295..d5cddd4 100644 --- a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/temperature/view/TemperatureControlView.kt +++ b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/temperature/view/TemperatureControlView.kt @@ -49,10 +49,14 @@ private val DefaultEdgePadding = 25.dp @OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class) @Composable -fun TemperatureControlView(viewModel: TemperatureViewModel) { +fun TemperatureControlView( + viewModel: TemperatureViewModel, + modifier: Modifier = Modifier, +) { BottomSheetScaffold( sheetContent = { BottomSheetContent(viewModel) }, containerColor = Color.White.copy(alpha = 0f), + modifier = modifier, ) { Column( modifier = Modifier diff --git a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/wheel/pressure/view/WheelPressureControlView.kt b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/wheel/pressure/view/WheelPressureControlView.kt index 0309ff7..8eb8ccd 100644 --- a/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/wheel/pressure/view/WheelPressureControlView.kt +++ b/app/src/main/kotlin/org/eclipse/kuksa/companion/feature/wheel/pressure/view/WheelPressureControlView.kt @@ -33,31 +33,41 @@ import androidx.constraintlayout.compose.ConstraintLayout import org.eclipse.kuksa.companion.feature.wheel.pressure.viewmodel.WheelPressureViewModel @Composable -fun WheelPressureControlView(viewModel: WheelPressureViewModel) { - WheelPressureOverlay(viewModel = viewModel) +fun WheelPressureControlView( + viewModel: WheelPressureViewModel, + modifier: Modifier = Modifier, +) { + WheelPressureOverlay( + viewModel.pressureLeftFront, + viewModel.pressureRightFront, + viewModel.pressureLeftBack, + viewModel.pressureRightBack, + modifier, + ) } @Composable -private fun WheelPressureOverlay(viewModel: WheelPressureViewModel) { +private fun WheelPressureOverlay( + pressureLeftFront: Int, + pressureRightFront: Int, + pressureLeftBack: Int, + pressureRightBack: Int, + modifier: Modifier = Modifier, +) { ConstraintLayout( - modifier = Modifier + modifier = modifier .fillMaxSize() .padding(start = 35.dp, end = 35.dp, top = 225.dp, bottom = 90.dp), ) { val (driverSideRef, passengerSideRef, driverSideBackRef, passengerSideBackRef) = createRefs() - val modifier = Modifier val doorsPaddingBottom = 50.dp val unit = "kPa" - val pressureLeftFront = viewModel.pressureLeftFront - val pressureRightFront = viewModel.pressureRightFront - val pressureLeftBack = viewModel.pressureLeftBack - val pressureRightBack = viewModel.pressureRightBack Text( text = "$pressureLeftFront $unit", fontSize = MaterialTheme.typography.titleLarge.fontSize, color = Color.Black, - modifier = modifier + modifier = Modifier .constrainAs(driverSideRef) { start.linkTo(parent.start) }, @@ -66,7 +76,7 @@ private fun WheelPressureOverlay(viewModel: WheelPressureViewModel) { text = "$pressureRightFront $unit", fontSize = MaterialTheme.typography.titleLarge.fontSize, color = Color.Black, - modifier = modifier + modifier = Modifier .constrainAs(passengerSideRef) { end.linkTo(parent.end) }, @@ -75,7 +85,7 @@ private fun WheelPressureOverlay(viewModel: WheelPressureViewModel) { text = "$pressureLeftBack $unit", fontSize = MaterialTheme.typography.titleLarge.fontSize, color = Color.Black, - modifier = modifier + modifier = Modifier .constrainAs(driverSideBackRef) { start.linkTo(parent.start) bottom.linkTo(parent.bottom, doorsPaddingBottom) @@ -85,7 +95,7 @@ private fun WheelPressureOverlay(viewModel: WheelPressureViewModel) { text = "$pressureRightBack $unit", fontSize = MaterialTheme.typography.titleLarge.fontSize, color = Color.Black, - modifier = modifier + modifier = Modifier .constrainAs(passengerSideBackRef) { end.linkTo(parent.end) bottom.linkTo(parent.bottom, doorsPaddingBottom) diff --git a/app/src/main/kotlin/org/eclipse/kuksa/companion/serialization/JsonSerializer.kt b/app/src/main/kotlin/org/eclipse/kuksa/companion/serialization/JsonSerializer.kt index ffe0bec..f927517 100644 --- a/app/src/main/kotlin/org/eclipse/kuksa/companion/serialization/JsonSerializer.kt +++ b/app/src/main/kotlin/org/eclipse/kuksa/companion/serialization/JsonSerializer.kt @@ -46,7 +46,10 @@ abstract class JsonSerializer(private val serializer: KSerializer) : Seria } } - override suspend fun writeTo(t: T, output: OutputStream) { + override suspend fun writeTo( + t: T, + output: OutputStream, + ) { withContext(Dispatchers.IO) { val encodedString = Json.encodeToString(serializer, t) output.write(encodedString.encodeToByteArray()) diff --git a/app/src/main/kotlin/org/eclipse/kuksa/companion/ui/theme/Theme.kt b/app/src/main/kotlin/org/eclipse/kuksa/companion/ui/theme/Theme.kt index d56c7a9..b2f8757 100644 --- a/app/src/main/kotlin/org/eclipse/kuksa/companion/ui/theme/Theme.kt +++ b/app/src/main/kotlin/org/eclipse/kuksa/companion/ui/theme/Theme.kt @@ -44,7 +44,6 @@ private val LightColorScheme = lightColorScheme( primary = Purple40, secondary = PurpleGrey40, tertiary = Pink40, - /* Other default colors to override background = Color(0xFFFFFBFE), surface = Color(0xFFFFFBFE), diff --git a/build.gradle.kts b/build.gradle.kts index acfc7e6..1bead68 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -26,11 +26,12 @@ plugins { } subprojects { - apply { - plugin("ktlint") - plugin("dash") - } afterEvaluate { + apply { + plugin("ktlint") + plugin("dash") + } + tasks.check { finalizedBy("ktlintCheck") } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index c6dd076..2c33654 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -39,4 +39,5 @@ dependencies { implementation(libs.kotlin.gradlePlugin) implementation(libs.detekt.gradlePlugin) implementation(libs.javapoet) + implementation(libs.ktlint.gradlePlugin) } diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts index bc4648e..5971fa2 100644 --- a/buildSrc/settings.gradle.kts +++ b/buildSrc/settings.gradle.kts @@ -37,7 +37,6 @@ plugins { dependencyResolutionManagement { repositories { mavenLocal() - gradlePluginPortal() google() mavenCentral() } diff --git a/buildSrc/src/main/kotlin/detekt.gradle.kts b/buildSrc/src/main/kotlin/detekt.gradle.kts index 1cb03aa..c2c2e4d 100644 --- a/buildSrc/src/main/kotlin/detekt.gradle.kts +++ b/buildSrc/src/main/kotlin/detekt.gradle.kts @@ -29,6 +29,7 @@ plugins { dependencies { detektPlugins(lib("detekt-formatting")) + detektPlugins(lib("detekt-compose-rules")) } detekt { diff --git a/buildSrc/src/main/kotlin/ktlint.gradle.kts b/buildSrc/src/main/kotlin/ktlint.gradle.kts index 0c544b2..9099770 100644 --- a/buildSrc/src/main/kotlin/ktlint.gradle.kts +++ b/buildSrc/src/main/kotlin/ktlint.gradle.kts @@ -1,3 +1,5 @@ +import org.eclipse.kuksa.companion.extension.lib + /* * Copyright (c) 2023 Contributors to the Eclipse Foundation * @@ -16,42 +18,29 @@ * SPDX-License-Identifier: Apache-2.0 * */ +plugins { + id("org.jlleitschuh.gradle.ktlint") +} -val ktlint by configurations.creating +// https://github.com/jlleitschuh/ktlint-gradle#configuration +ktlint { + version.set("1.0.1") + android.set(true) + debug.set(false) + verbose.set(true) + ignoreFailures.set(false) + coloredOutput.set(false) + enableExperimentalRules.set(false) -dependencies { - // can't use Project.lib exension here because the plugin is applied before the versionCatalog is available - ktlint("com.pinterest:ktlint:0.49.0") { - attributes { - attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL)) - } + filter { + exclude( + "**/generated/**", + "**/build/**", + "**/node_modules/**", + ) } } -val ktlintCheck by tasks.registering(JavaExec::class) { - group = LifecycleBasePlugin.VERIFICATION_GROUP - description = "Check Kotlin code style" - classpath = ktlint - mainClass.set("com.pinterest.ktlint.Main") - // see https://pinterest.github.io/ktlint/install/cli/#command-line-usage for more information - args( - "**/src/**/*.kt", - "**.kts", - "!**/build/**", - ) -} - -tasks.register("ktlintFormat") { - group = LifecycleBasePlugin.VERIFICATION_GROUP - description = "Check Kotlin code style and format" - classpath = ktlint - mainClass.set("com.pinterest.ktlint.Main") - jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED") - // see https://pinterest.github.io/ktlint/install/cli/#command-line-usage for more information - args( - "-F", - "**/src/**/*.kt", - "**.kts", - "!**/build/**", - ) +dependencies { + ktlintRuleset(lib("ktlint-compose-rules")) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 293553c..1bf41d3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,7 +10,8 @@ junitVersion = "1.1.5" junit = "4.13.2" kotlin = "1.9.20" detekt = "1.23.3" -ktlint = "0.0" # maintained inside ktlint.gradle.kts +composeRules = "0.0.26" +ktlintGradle = "12.0.2" # ktLint Gradle Plugin Version: https://github.com/JLLeitschuh/ktlint-gradle/releases androidxAppCompat = "1.6.1" androidxLifecycle = "2.6.2" kotlinCompilerExtension = "1.5.4" @@ -41,6 +42,8 @@ androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "androidxLifecycle" } androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigationCompose" } kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" } +ktlint-compose-rules = { module = "com.twitter.compose.rules:ktlint", version.ref = "composeRules" } +detekt-compose-rules = { module = "com.twitter.compose.rules:detekt", version.ref = "composeRules" } kuksa-sdk = { module = "org.eclipse.kuksa:kuksa-sdk", version.ref = "kuksaSdk" } vss-processor = { module = "org.eclipse.kuksa:vss-processor", version.ref = "kuksaSdk" } ramses-aar = { module = "io.github.bmwcarit:ramses-aar", version.ref = "ramsesAar" } @@ -60,6 +63,7 @@ androidx-constraintlayout-compose = { module = "androidx.constraintlayout:constr # buildSrc android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" } kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } +ktlint-gradlePlugin = { module = "org.jlleitschuh.gradle:ktlint-gradle", version.ref = "ktlintGradle" } detekt-gradlePlugin = { group = "io.gitlab.arturbosch.detekt", name = "detekt-gradle-plugin", version.ref = "detekt" } detekt-formatting = { group = "io.gitlab.arturbosch.detekt", name = "detekt-formatting", version.ref = "detekt" }