From 60e4214a623c6d27b7f136f5de2a0f8b86a0eae0 Mon Sep 17 00:00:00 2001 From: Andre Weber Date: Wed, 15 Nov 2023 09:42:32 +0100 Subject: [PATCH 1/2] feature: Differentiate between DirectionIndicator Left / Right Closes: #7 Signed-off-by: Andre Weber --- .../feature/light/view/LightControlView.kt | 2 +- .../light/viewmodel/LightControlViewModel.kt | 18 ++++++++++ ...=> lights_direction_indicator_both_24.xml} | 12 +++---- .../lights_direction_indicator_left_24.xml | 36 +++++++++++++++++++ .../lights_direction_indicator_none_24.xml | 35 ++++++++++++++++++ .../lights_direction_indicator_right_24.xml | 36 +++++++++++++++++++ 6 files changed, 132 insertions(+), 7 deletions(-) rename app/src/main/res/drawable/{lights_direction_indicator_24.xml => lights_direction_indicator_both_24.xml} (83%) create mode 100644 app/src/main/res/drawable/lights_direction_indicator_left_24.xml create mode 100644 app/src/main/res/drawable/lights_direction_indicator_none_24.xml create mode 100644 app/src/main/res/drawable/lights_direction_indicator_right_24.xml diff --git a/app/src/main/java/org/eclipse/kuksa/demo/feature/light/view/LightControlView.kt b/app/src/main/java/org/eclipse/kuksa/demo/feature/light/view/LightControlView.kt index bb27a59..1242815 100644 --- a/app/src/main/java/org/eclipse/kuksa/demo/feature/light/view/LightControlView.kt +++ b/app/src/main/java/org/eclipse/kuksa/demo/feature/light/view/LightControlView.kt @@ -182,7 +182,7 @@ private fun LightOverlay(viewModel: LightControlViewModel) { ) LightDashboardSymbol( isLightEnabled = viewModel.isDirectionIndicatorSignaling, - painterResource = R.drawable.lights_direction_indicator_24, + painterResource = viewModel.directionIndicatorRes, contentDescription = "Direction Indicator", ) LightDashboardSymbol( diff --git a/app/src/main/java/org/eclipse/kuksa/demo/feature/light/viewmodel/LightControlViewModel.kt b/app/src/main/java/org/eclipse/kuksa/demo/feature/light/viewmodel/LightControlViewModel.kt index 7bff108..43b7efd 100644 --- a/app/src/main/java/org/eclipse/kuksa/demo/feature/light/viewmodel/LightControlViewModel.kt +++ b/app/src/main/java/org/eclipse/kuksa/demo/feature/light/viewmodel/LightControlViewModel.kt @@ -19,11 +19,13 @@ package org.eclipse.kuksa.demo.feature.light.viewmodel +import androidx.annotation.DrawableRes import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import androidx.lifecycle.ViewModel +import org.eclipse.kuksa.demo.R import org.eclipse.kuksa.vss.VssLights import org.eclipse.kuksa.vsscore.model.VssProperty @@ -52,6 +54,22 @@ class LightControlViewModel : ViewModel() { isDirectionIndicatorLeftSignaling.value || isDirectionIndicatorRightSignaling.value } + @get:DrawableRes + val directionIndicatorRes by derivedStateOf { + val isLeftSignalling = isDirectionIndicatorLeftSignaling.value + val isRightSignalling = isDirectionIndicatorRightSignaling.value + + if (isLeftSignalling && isRightSignalling) { + return@derivedStateOf R.drawable.lights_direction_indicator_both_24 + } else if (isLeftSignalling) { + return@derivedStateOf R.drawable.lights_direction_indicator_left_24 + } else if (isRightSignalling) { + return@derivedStateOf R.drawable.lights_direction_indicator_right_24 + } + + return@derivedStateOf R.drawable.lights_direction_indicator_none_24 + } + val isFogLightFrontOn by derivedStateOf { vssLight.fog.front.isOn } diff --git a/app/src/main/res/drawable/lights_direction_indicator_24.xml b/app/src/main/res/drawable/lights_direction_indicator_both_24.xml similarity index 83% rename from app/src/main/res/drawable/lights_direction_indicator_24.xml rename to app/src/main/res/drawable/lights_direction_indicator_both_24.xml index 42f7206..4bc42b8 100644 --- a/app/src/main/res/drawable/lights_direction_indicator_24.xml +++ b/app/src/main/res/drawable/lights_direction_indicator_both_24.xml @@ -23,15 +23,15 @@ android:viewportWidth="6.35" android:viewportHeight="6.35"> diff --git a/app/src/main/res/drawable/lights_direction_indicator_left_24.xml b/app/src/main/res/drawable/lights_direction_indicator_left_24.xml new file mode 100644 index 0000000..2a1878f --- /dev/null +++ b/app/src/main/res/drawable/lights_direction_indicator_left_24.xml @@ -0,0 +1,36 @@ + + + + + + diff --git a/app/src/main/res/drawable/lights_direction_indicator_none_24.xml b/app/src/main/res/drawable/lights_direction_indicator_none_24.xml new file mode 100644 index 0000000..db912d3 --- /dev/null +++ b/app/src/main/res/drawable/lights_direction_indicator_none_24.xml @@ -0,0 +1,35 @@ + + + + + + diff --git a/app/src/main/res/drawable/lights_direction_indicator_right_24.xml b/app/src/main/res/drawable/lights_direction_indicator_right_24.xml new file mode 100644 index 0000000..998b0af --- /dev/null +++ b/app/src/main/res/drawable/lights_direction_indicator_right_24.xml @@ -0,0 +1,36 @@ + + + + + + From c28c18bff210e7873731780ff26104cd32cc6a29 Mon Sep 17 00:00:00 2001 From: Andre Weber Date: Tue, 21 Nov 2023 11:49:56 +0100 Subject: [PATCH 2/2] chore: Resolve Merge Conflicts --- .../companion/feature/light/viewmodel/LightControlViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/eclipse/kuksa/companion/feature/light/viewmodel/LightControlViewModel.kt b/app/src/main/java/org/eclipse/kuksa/companion/feature/light/viewmodel/LightControlViewModel.kt index 04a6094..a89d0ad 100644 --- a/app/src/main/java/org/eclipse/kuksa/companion/feature/light/viewmodel/LightControlViewModel.kt +++ b/app/src/main/java/org/eclipse/kuksa/companion/feature/light/viewmodel/LightControlViewModel.kt @@ -25,7 +25,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import androidx.lifecycle.ViewModel -import org.eclipse.kuksa.demo.R +import org.eclipse.kuksa.companion.R import org.eclipse.kuksa.vss.VssLights import org.eclipse.kuksa.vsscore.model.VssProperty