Skip to content

Commit

Permalink
Merge pull request #35 from boschglobal/feature-22
Browse files Browse the repository at this point in the history
feature: Update KtLint to 1.0.1
  • Loading branch information
Chrylo authored Dec 15, 2023
2 parents bc48cc1 + 781bbd6 commit 308a4ce
Show file tree
Hide file tree
Showing 27 changed files with 170 additions and 108 deletions.
11 changes: 7 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ android {
noCompress += "ramses"
noCompress += "rlogic"
}
sourceSets.getByName("main") {
java.srcDir("src/main/java")
java.srcDir("src/main/kotlin")
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import javax.inject.Singleton
class ConnectionInfoRepository @Inject constructor(
@ApplicationContext context: Context,
) {

private val Context.dataStore: DataStore<ConnectionInfo> by dataStore(PREFERENCES_NAME, ConnectionInfoSerializer)
private val dataStore = context.dataStore

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import androidx.lifecycle.ViewModel
import org.eclipse.kuksa.companion.extension.DarkGreen

class ConnectionStatusViewModel : ViewModel() {

enum class ConnectionState {
DISCONNECTED,
CONNECTING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class DoorVehicleSceneThread(
threadName: String,
private val viewModel: DoorControlViewModel,
) : RamsesThread(threadName, viewModel.getApplication()), DoorVehicleScene {

private var doorRow1DriverSide: VssProperty<Boolean> = VssDoor.VssRow1.VssDriverSide.VssIsOpen()
private var doorRow1PassengerSide: VssProperty<Boolean> = VssDoor.VssRow1.VssPassengerSide.VssIsOpen()
private var doorRow2DriverSide: VssProperty<Boolean> = VssDoor.VssRow2.VssDriverSide.VssIsOpen()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ class DoorVehicleSurface : AndroidRamsesSurface<DoorVehicleScene, DoorControlVie
}
}

override fun surfaceChanged(holder: SurfaceHolder, format: Int, width: Int, height: Int) {
override fun surfaceChanged(
holder: SurfaceHolder,
format: Int,
width: Int,
height: Int,
) {
Log.d(TAG, "surfaceChanged: holder = $holder, format = $format, width = $width, height = $height")

doorVehicleSceneThread.resizeDisplay(width, height)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ import org.eclipse.kuksa.companion.feature.door.viewModel.DoorControlViewModel

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun DoorControlView(
doorControlViewModel: DoorControlViewModel,
) {
fun DoorControlView(doorControlViewModel: DoorControlViewModel) {
BottomSheetScaffold(
sheetContent = { BottomSheetContent(doorControlViewModel) },
containerColor = Color.White.copy(alpha = 0f),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import org.eclipse.kuksa.companion.feature.light.viewmodel.LightControlViewModel
import org.eclipse.kuksa.companion.feature.temperature.viewmodel.TemperatureViewModel
import org.eclipse.kuksa.companion.feature.wheel.pressure.viewmodel.WheelPressureViewModel

const val HomeScreen = "home"
const val HOME_SCREEN = "home"

@Suppress("LongParameterList") // calls compose code for which LongParameterList is disabled
fun NavGraphBuilder.homeScreen(
Expand All @@ -40,7 +40,7 @@ fun NavGraphBuilder.homeScreen(
wheelPressureViewModel: WheelPressureViewModel,
onNavigateToSettingsScreen: () -> Unit,
) {
composable(HomeScreen) {
composable(HOME_SCREEN) {
HomeScreen(
connectionStatusViewModel = connectionStatusViewModel,
doorControlViewModel = doorControlViewModel,
Expand All @@ -53,5 +53,5 @@ fun NavGraphBuilder.homeScreen(
}

fun NavController.navigateToMainScreen(navOptions: NavOptions? = null) {
navigate(HomeScreen, navOptions)
navigate(HOME_SCREEN, navOptions)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ import androidx.compose.ui.viewinterop.AndroidView
@Composable
fun RamsesView(
callback: SurfaceHolder.Callback,
modifier: Modifier = Modifier,
) {
AndroidView(
{ context ->
SurfaceView(context).apply {
holder.addCallback(callback)
}
},
modifier = Modifier.fillMaxSize(),
modifier = modifier.fillMaxSize(),
)
}

Expand All @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,24 @@ 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(
doorControlViewModel: DoorControlViewModel,
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"),
Expand All @@ -78,7 +79,7 @@ fun TabRowHost(
TabData(R.drawable.baseline_sports_volleyball_24, "Wheel Pressure"),
)

Column {
Column(modifier = modifier) {
TabRow(
selectedTabIndex = selectedTabIndex,
modifier = Modifier
Expand All @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -40,5 +41,5 @@ fun NavGraphBuilder.settingsScreen(
}

fun NavController.navigateToSettingsScreen(navOptions: NavOptions? = null) {
navigate(SettingsView, navOptions)
navigate(SETTINGS_VIEW, navOptions)
}
Loading

0 comments on commit 308a4ce

Please sign in to comment.