From 9ee654ebada5bad3b857e8706c3736d34cfef214 Mon Sep 17 00:00:00 2001 From: dileephemachandranharman Date: Fri, 23 May 2025 19:48:34 +0530 Subject: [PATCH] Updated RO and vehicle listing UI changes --- app/build.gradle.kts | 3 +- .../org/eclipse/ecsp/helper/AppConstants.kt | 2 + .../models/viewmodels/RemoteOperationVM.kt | 16 ++-- .../ecsp/repository/DashboardRepository.kt | 14 ++-- .../ecsp/services/RemoteOperationService.kt | 2 + .../ui/view/activities/DashboardActivity.kt | 15 ++-- .../ecsp/ui/view/composes/AppCommonCompose.kt | 38 +++++---- .../dashboardcompose/DashboardMainCompose.kt | 80 ++++++++++++------- .../DashboardVehicleListCompose.kt | 1 + .../NotificationCompose.kt | 4 +- 10 files changed, 106 insertions(+), 69 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 7c7266f..3d2fbbb 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -16,7 +16,7 @@ android { minSdk = 24 targetSdk = 35 versionCode = 16 - versionName = "3.3" + versionName = "3.5" multiDexEnabled = true testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" @@ -69,6 +69,7 @@ android { dependencies { implementation("org.eclipse.ecsp:vehicleconnectsdk:1.1.5") +// implementation(files("libs/androidVehicleConnectSDK.aar")) implementation("androidx.core:core-ktx:1.15.0") implementation("androidx.activity:activity-compose:1.8.0") implementation("androidx.compose.ui:ui:1.5.0") diff --git a/app/src/main/java/org/eclipse/ecsp/helper/AppConstants.kt b/app/src/main/java/org/eclipse/ecsp/helper/AppConstants.kt index 71bc1a3..4a28f27 100644 --- a/app/src/main/java/org/eclipse/ecsp/helper/AppConstants.kt +++ b/app/src/main/java/org/eclipse/ecsp/helper/AppConstants.kt @@ -44,6 +44,8 @@ object AppConstants { const val UNLOCKED = "Unlocked" const val STARTED = "Started" const val STOPPED = "Stopped" + const val IGNITION_ENABLED = "IGNITION_ENABLED" + const val IGNITION_DISABLED = "IGNITION_DISABLED" const val WINDOWS = "Windows" const val LIGHT = "Lights" diff --git a/app/src/main/java/org/eclipse/ecsp/models/viewmodels/RemoteOperationVM.kt b/app/src/main/java/org/eclipse/ecsp/models/viewmodels/RemoteOperationVM.kt index 1fb4b21..8983748 100644 --- a/app/src/main/java/org/eclipse/ecsp/models/viewmodels/RemoteOperationVM.kt +++ b/app/src/main/java/org/eclipse/ecsp/models/viewmodels/RemoteOperationVM.kt @@ -235,12 +235,16 @@ class RemoteOperationVM(activity: Activity) : AndroidViewModel(activity.applicat dashboardRepository.getRemoteOperationHistory(userId, vehicleId) .observe(lifecycleOwner) { roEventHistoryResponse -> isProgressBarLoading?.value = false - updateListOnRoHistory( - activity, - roEventHistoryResponse, - lazyStaggeredGridList, - notifyRoUpdate, - ) + if(roEventHistoryResponse.status.requestStatus) { + updateListOnRoHistory( + activity, + roEventHistoryResponse, + lazyStaggeredGridList, + notifyRoUpdate, + ) + } else{ + toastError(activity, "RO History: ${roEventHistoryResponse.error?.message ?: "Error occurred"}") + } } } diff --git a/app/src/main/java/org/eclipse/ecsp/repository/DashboardRepository.kt b/app/src/main/java/org/eclipse/ecsp/repository/DashboardRepository.kt index b842986..2901410 100644 --- a/app/src/main/java/org/eclipse/ecsp/repository/DashboardRepository.kt +++ b/app/src/main/java/org/eclipse/ecsp/repository/DashboardRepository.kt @@ -218,11 +218,15 @@ class DashboardRepository { deviceCall.await()?.forEach { if (it.mDeviceId != null) { vehicleServiceInterface.getVehicleProfile(it.mDeviceId!!) { vehicleProfileData -> - list[it.mDeviceId!!] = - VehicleProfileModel( - it, - vehicleProfileData.response?.data?.get(0) - ) + if (vehicleProfileData.response != null + && vehicleProfileData.response?.data != null + && vehicleProfileData.response!!.data!!.isNotEmpty()) { + list[it.mDeviceId!!] = + VehicleProfileModel( + it, + vehicleProfileData.response?.data?.get(0) + ) + } } success = true } diff --git a/app/src/main/java/org/eclipse/ecsp/services/RemoteOperationService.kt b/app/src/main/java/org/eclipse/ecsp/services/RemoteOperationService.kt index 2ffc90a..558bb8f 100644 --- a/app/src/main/java/org/eclipse/ecsp/services/RemoteOperationService.kt +++ b/app/src/main/java/org/eclipse/ecsp/services/RemoteOperationService.kt @@ -61,6 +61,8 @@ class RemoteOperationService { AppConstants.STARTED.lowercase() -> AppConstants.STOPPED AppConstants.STOPPED.lowercase() -> AppConstants.STARTED AppConstants.PARTIAL_OPENED.lowercase() -> AppConstants.getWindowCurrentState(activity) + AppConstants.IGNITION_ENABLED.lowercase() -> AppConstants.STOPPED + AppConstants.IGNITION_DISABLED.lowercase() -> AppConstants.STARTED else -> "" } } diff --git a/app/src/main/java/org/eclipse/ecsp/ui/view/activities/DashboardActivity.kt b/app/src/main/java/org/eclipse/ecsp/ui/view/activities/DashboardActivity.kt index 2cd4316..554a5a4 100644 --- a/app/src/main/java/org/eclipse/ecsp/ui/view/activities/DashboardActivity.kt +++ b/app/src/main/java/org/eclipse/ecsp/ui/view/activities/DashboardActivity.kt @@ -62,7 +62,7 @@ import org.eclipse.ecsp.ui.view.composes.TopBar import org.eclipse.ecsp.ui.view.composes.dashboardcompose.BottomNavigationBar import org.eclipse.ecsp.ui.view.composes.dashboardcompose.ShowChangePasswordConfirmationDialogBox import org.eclipse.ecsp.ui.view.composes.dashboardcompose.ShowConfirmationDialogBox -import org.eclipse.ecsp.ui.view.composes.dashboardcompose.mainCompose +import org.eclipse.ecsp.ui.view.composes.dashboardcompose.MainCompose import org.eclipse.ecsp.userservice.service.UserServiceInterface /** @@ -138,7 +138,8 @@ class DashboardActivity : BaseAppActivity() { setContent { remoteOperationVM.getRoHistoryData().observeAsState().value.let { if (isInternetAvailable(this)) { - if (it != null) getRoHistory(it) + if (it != null) + getRoHistory(it) } else { toastError(this, "No internet connectivity") } @@ -157,11 +158,11 @@ class DashboardActivity : BaseAppActivity() { mutableStateOf(-1) } processVehicleList( - Gson().fromJson( + HashMap(Gson().fromJson>( AppConstants.getVehicleList( this@DashboardActivity, - ), - ), + ) + )) ) LaunchedEffect(Unit) { dashboardVM.fetchAssociateDeviceList() @@ -192,7 +193,7 @@ class DashboardActivity : BaseAppActivity() { BottomNavigationBar(navController = navController) }, content = { padding -> - mainCompose( + MainCompose( this, padding = padding, navController, @@ -281,7 +282,7 @@ class DashboardActivity : BaseAppActivity() { // dashboardVM.subscribeNotificationConfig(emailId?:"", it) isProgressBarLoading.value = false it.let { - AppConstants.setVehicleList(this@DashboardActivity, Gson().toJson(it)) + AppConstants.setVehicleList(this@DashboardActivity, Gson().toJson(it.second)) processVehicleList(it.second) } } diff --git a/app/src/main/java/org/eclipse/ecsp/ui/view/composes/AppCommonCompose.kt b/app/src/main/java/org/eclipse/ecsp/ui/view/composes/AppCommonCompose.kt index fc4c524..105c1c8 100644 --- a/app/src/main/java/org/eclipse/ecsp/ui/view/composes/AppCommonCompose.kt +++ b/app/src/main/java/org/eclipse/ecsp/ui/view/composes/AppCommonCompose.kt @@ -1,4 +1,5 @@ package org.eclipse.ecsp.ui.view.composes + /******************************************************************************** * Copyright (c) 2023-24 Harman International * @@ -54,26 +55,29 @@ fun TopBar( Text(topBarTextString, color = Black, fontWeight = FontWeight.Bold) }, navigationIcon = { - IconButton(onClick = onClicked) { - Icon( - imageVector = ImageVector.vectorResource(id = R.drawable.ic_back_arrow), - contentDescription = "Back", - modifier = Modifier.testTag("top_bar_back_arrow_icon_tag"), - ) - } + if (topBarTextString != "Remote Control") + IconButton(onClick = onClicked) { + Icon( + imageVector = ImageVector.vectorResource(id = R.drawable.ic_back_arrow), + contentDescription = "Back", + modifier = Modifier.testTag("top_bar_back_arrow_icon_tag"), + ) + } }, colors = TopAppBarDefaults.mediumTopAppBarColors(containerColor = White), modifier = - Modifier.drawWithContent { - drawContent() - val strokeWidth = 2.dp.value * density - val y = size.height - strokeWidth / 2 - drawLine( - DarkGray, - Offset((textFieldPadding).toPx(), y), - Offset(size.width - textFieldPadding.toPx(), y), - ) - }.testTag("topBar_tag"), + Modifier + .drawWithContent { + drawContent() + val strokeWidth = 2.dp.value * density + val y = size.height - strokeWidth / 2 + drawLine( + DarkGray, + Offset((textFieldPadding).toPx(), y), + Offset(size.width - textFieldPadding.toPx(), y), + ) + } + .testTag("topBar_tag"), ) } diff --git a/app/src/main/java/org/eclipse/ecsp/ui/view/composes/dashboardcompose/DashboardMainCompose.kt b/app/src/main/java/org/eclipse/ecsp/ui/view/composes/dashboardcompose/DashboardMainCompose.kt index cfe9cc8..561635f 100644 --- a/app/src/main/java/org/eclipse/ecsp/ui/view/composes/dashboardcompose/DashboardMainCompose.kt +++ b/app/src/main/java/org/eclipse/ecsp/ui/view/composes/dashboardcompose/DashboardMainCompose.kt @@ -1,4 +1,5 @@ package org.eclipse.ecsp.ui.view.composes.dashboardcompose + /******************************************************************************** * Copyright (c) 2023-24 Harman International * @@ -28,6 +29,7 @@ import androidx.compose.material3.NavigationBar import androidx.compose.material3.NavigationBarItem import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.MutableState import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -55,6 +57,7 @@ import org.eclipse.ecsp.ui.theme.DarkGray import org.eclipse.ecsp.ui.theme.LightBlue import org.eclipse.ecsp.ui.theme.White import org.eclipse.ecsp.ui.view.composes.deviceinstallationcompose.ProgressBar +import org.eclipse.ecsp.ui.view.composes.notificationcompose.NotificationMainCompose import org.eclipse.ecsp.ui.view.composes.remoteoperationcompose.BottomSheetOptionsRoCompose import org.eclipse.ecsp.ui.view.composes.remoteoperationcompose.RemoteOperationScreen @@ -67,9 +70,8 @@ fun BottomNavigationBar(navController: NavController) { NavigationBar { val navBackStackEntry = navController.currentBackStackEntryAsState() val currentRoute = navBackStackEntry.value?.destination?.route - BottomNavItem::class.sealedSubclasses.map { - it.objectInstance as BottomNavItem - }.forEach { navItem -> + val bottomItemList = listOf(BottomNavItem.RemoteOperation, BottomNavItem.Settings) + bottomItemList.forEach { navItem -> val selected = currentRoute == navItem.route NavigationBarItem( selected = selected, @@ -117,6 +119,7 @@ fun Activity.NavHostContainer( openConfirmationDialog: MutableState?, notifyRoUpdate: MutableState, lifecycleOwner: LifecycleOwner, + alertList: MutableState>, passwordChangeDialog: MutableState? ) { NavHost( @@ -148,7 +151,6 @@ fun Activity.NavHostContainer( passwordChangeDialog ) } - // disabled for current iteration /*composable(BottomNavItem.Notification.route) { NotificationMainCompose( dashboardVM, @@ -164,7 +166,7 @@ fun Activity.NavHostContainer( } @Composable -fun mainCompose( +fun MainCompose( activity: Activity, padding: PaddingValues, navController: NavHostController, @@ -195,35 +197,50 @@ fun mainCompose( horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Top, ) { + LaunchedEffect(showVehicleList.value.second) { + + } // if (showVehicleList.value.first) { - VehicleSelectionListView( - vehicleList = showVehicleList.value.second, - selectedVehicleId?.value!!.first, - selectedVehicleId.value.second, - onVehicleSelection = { vehicleProfileModel, index -> - selectedVehicleId.value = - Triple( - vehicleProfileModel?.associatedDevice?.mDeviceId.toString(), - vehicleProfileModel?.vehicleDetailData?.vehicleAttributes?.name - ?: "No Name", - vehicleProfileModel?.vehicleDetailData?.vehicleId.toString(), - ) - selectedVehicleIndex?.value = index - if (navController.currentBackStackEntry?.destination?.route == BottomNavItem.RemoteOperation.route) { - notifyRoUpdate.value = notifyRoUpdate.value + 1 - remoteOperationVM.clickOnRoHistory(selectedVehicleId.value.first) - } - }, - ) { - launchActivity() - } + VehicleSelectionListView( + vehicleList = showVehicleList.value.second, + selectedVehicleId?.value!!.first, + selectedVehicleId.value.second, + onVehicleSelection = { vehicleProfileModel, index -> + selectedVehicleId.value = + Triple( + vehicleProfileModel?.associatedDevice?.mDeviceId.toString(), + vehicleProfileModel?.vehicleDetailData?.vehicleAttributes?.name + ?: "No Name", + vehicleProfileModel?.vehicleDetailData?.vehicleId.toString(), + ) + selectedVehicleIndex?.value = index + if (navController.currentBackStackEntry?.destination?.route == BottomNavItem.RemoteOperation.route) { + notifyRoUpdate.value = notifyRoUpdate.value + 1 + remoteOperationVM.clickOnRoHistory(selectedVehicleId.value.first) + } + }, + ) { + launchActivity() + } // } activity.NavHostContainer( activity, - navController = navController, dashboardVM, remoteOperationVM, notificationVM, - vehicleProfileList = vehicleProfileList, isProgressBarLoading, showBottomSheet, - openDialog, selectedVehicleId, lazyStaggeredGridList, - showVehicleList, openConfirmationDialog, notifyRoUpdate, lifecycleOwner,passwordChangeDialog + navController = navController, + dashboardVM, + remoteOperationVM, + notificationVM, + vehicleProfileList = vehicleProfileList, + isProgressBarLoading, + showBottomSheet, + openDialog, + selectedVehicleId, + lazyStaggeredGridList, + showVehicleList, + openConfirmationDialog, + notifyRoUpdate, + lifecycleOwner, + alertList, + passwordChangeDialog ) isProgressBarLoading?.value?.let { @@ -285,7 +302,8 @@ fun mainCompose( AJAR } else { showBottomSheet.value.third - }}", + } + }", Toast.LENGTH_LONG, ).show() } diff --git a/app/src/main/java/org/eclipse/ecsp/ui/view/composes/dashboardcompose/DashboardVehicleListCompose.kt b/app/src/main/java/org/eclipse/ecsp/ui/view/composes/dashboardcompose/DashboardVehicleListCompose.kt index 0c2c532..8cdc90e 100644 --- a/app/src/main/java/org/eclipse/ecsp/ui/view/composes/dashboardcompose/DashboardVehicleListCompose.kt +++ b/app/src/main/java/org/eclipse/ecsp/ui/view/composes/dashboardcompose/DashboardVehicleListCompose.kt @@ -33,6 +33,7 @@ import androidx.compose.material3.CardDefaults import androidx.compose.material3.Icon import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Alignment diff --git a/app/src/main/java/org/eclipse/ecsp/ui/view/composes/notificationcompose/NotificationCompose.kt b/app/src/main/java/org/eclipse/ecsp/ui/view/composes/notificationcompose/NotificationCompose.kt index 4885362..b0872f7 100644 --- a/app/src/main/java/org/eclipse/ecsp/ui/view/composes/notificationcompose/NotificationCompose.kt +++ b/app/src/main/java/org/eclipse/ecsp/ui/view/composes/notificationcompose/NotificationCompose.kt @@ -90,7 +90,7 @@ fun Activity.NotificationMainCompose( alertList: MutableState>, isProgressBarLoading: MutableState?, vehicleProfileDataList: MutableState>?, - selectedVehicleId: MutableState>?, + selectedVehicleId: MutableState>?, lifecycleOwner: LifecycleOwner, ) { LaunchedEffect(Unit) { @@ -225,7 +225,7 @@ private fun getAlertHistoryData( notificationVM: NotificationVM, isProgressBarLoading: MutableState?, vehicleProfileDataList: MutableState>?, - selectedVehicleId: MutableState>?, + selectedVehicleId: MutableState>?, alertList: MutableState>, lifecycleOwner: LifecycleOwner, ) {