Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId = "org.eclipse.ecsp"
minSdk = 24
targetSdk = 35
versionCode = 16
versionName = "3.5"
versionCode = 18
versionName = "3.8"
multiDexEnabled = true

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -68,8 +68,7 @@ android {

dependencies {

implementation("org.eclipse.ecsp:vehicleconnectsdk:1.1.5")
// implementation(files("libs/androidVehicleConnectSDK.aar"))
implementation("org.eclipse.ecsp:vehicleconnectsdk:1.1.7")
implementation("androidx.core:core-ktx:1.15.0")
implementation("androidx.activity:activity-compose:1.8.0")
implementation("androidx.compose.ui:ui:1.5.0")
Expand Down Expand Up @@ -105,5 +104,5 @@ dependencies {
implementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
implementation(kotlin("reflect"))

implementation("com.google.firebase:firebase-messaging:24.0.0")
implementation("com.google.firebase:firebase-messaging:24.1.1")
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ import org.eclipse.ecsp.R
import org.eclipse.ecsp.helper.AppConstants.EXTRA_ALERT
import org.eclipse.ecsp.helper.AppConstants.EXTRA_MESSAGE
import org.eclipse.ecsp.helper.AppConstants.EXTRA_VEHICLE_ID
import org.eclipse.ecsp.notificationservice.model.AlertData
import org.eclipse.ecsp.ui.theme.LightBlue
import org.eclipse.ecsp.ui.view.activities.DashboardActivity
import org.eclipse.ecsp.ui.view.activities.LoginActivity
import org.eclipse.ecsp.helper.AppManager
import org.eclipse.ecsp.notificationservice.model.AlertData

/**
* Represents the notification service listener, using firebase messaging service.
Expand All @@ -52,7 +51,15 @@ class FcmNotificationService : FirebaseMessagingService() {
*/
override fun onMessageReceived(message: RemoteMessage) {
if (message.data.isNotEmpty()) {
Log.d("FCM_SERVICE", message.data.toString())
val data = message.data
Log.d("FCM_SERVICE", data.toString())
val body: String = data["body"].toString()
val chanelId =
if (data.keys.contains("channelIdentifier"))
data["channelIdentifier"] ?: ""
else
""
showNotification(chanelId, body, )
}
}

Expand All @@ -72,11 +79,11 @@ class FcmNotificationService : FirebaseMessagingService() {
private fun showNotification(
channelId: String,
message: String,
vehicleId: String,
alert: AlertData,
// vehicleId: String,
// alert: AlertData
) {
val notificationId = (System.currentTimeMillis() and 0xfffffffL).toInt()
val intent = getPendingIntent(message, alert, vehicleId)
val intent = getPendingIntent(message)
val pendingIntent =
PendingIntent.getActivity(
this,
Expand Down Expand Up @@ -134,8 +141,8 @@ class FcmNotificationService : FirebaseMessagingService() {
*/
private fun getPendingIntent(
message: String,
alert: AlertData,
vehicleId: String,
// alert: AlertData,
vehicleId: String?=null
): Intent {
val intent: Intent
if (AppManager.isLoggedIn()) {
Expand All @@ -146,7 +153,7 @@ class FcmNotificationService : FirebaseMessagingService() {
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
}
intent.putExtra(EXTRA_MESSAGE, message)
intent.putExtra(EXTRA_ALERT, alert)
// intent.putExtra(EXTRA_ALERT, alert)
intent.putExtra(EXTRA_VEHICLE_ID, vehicleId)
intent.action = System.currentTimeMillis().toString()
return intent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ import org.eclipse.ecsp.vehicleservice.model.vehicleprofile.VehicleDetailData
@Parcelize
data class VehicleProfileModel(
var associatedDevice: AssociatedDevice,
var vehicleDetailData: VehicleDetailData?,
var vehicleDetailData: VehicleDetailData?=null,
) : Parcelable
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package org.eclipse.ecsp.models.viewmodels

/********************************************************************************
* Copyright (c) 2023-24 Harman International
*
Expand All @@ -17,6 +18,7 @@ package org.eclipse.ecsp.models.viewmodels
********************************************************************************/
import android.app.Activity
import android.util.Log
import android.widget.Toast
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
Expand All @@ -30,6 +32,7 @@ import org.eclipse.ecsp.helper.response.CustomMessage
import org.eclipse.ecsp.notificationservice.model.ChannelData
import org.eclipse.ecsp.notificationservice.model.NotificationConfigData
import org.eclipse.ecsp.userservice.service.UserServiceInterface
import java.lang.ref.WeakReference

/**
* Represents the Dashboard ViewModel
Expand All @@ -40,13 +43,14 @@ import org.eclipse.ecsp.userservice.service.UserServiceInterface
*/
class DashboardVM(activity: Activity) : AndroidViewModel(activity.application) {
private var topBarTitle = MutableLiveData("")
private var _associatedDeviceList = MutableLiveData<Pair<Boolean,HashMap<String, VehicleProfileModel?>>>()
private var _associatedDeviceList = MutableLiveData<HashMap<String, VehicleProfileModel?>>()
private val dashboardRepository: DashboardRepository by lazy {
DashboardRepository()
}
private var isSignOutClicked = MutableLiveData(false)
private var _isPasswordChangeTriggered = MutableLiveData(false)
private var passwordChangeStatus = MutableLiveData<CustomMessage<Any>>()
private var weakReference = WeakReference(activity)

/**
* Represents to get the title value of the screens
Expand All @@ -71,16 +75,30 @@ class DashboardVM(activity: Activity) : AndroidViewModel(activity.application) {
*
* @return [HashMap] of [VehicleProfileModel] LiveData
*/
fun getAssociatedDeviceList(): LiveData<Pair<Boolean,HashMap<String, VehicleProfileModel?>>> {
fun getAssociatedDeviceList(): LiveData<HashMap<String, VehicleProfileModel?>> {
return _associatedDeviceList
}

/**
* Represents to set the associated vehicle list to [_associatedDeviceList]
* Function is calling both associated vehicle list and respective vehicles profile data API
*
*/
fun fetchAssociateDeviceList() {
_associatedDeviceList = dashboardRepository.associateDeviceList()
viewModelScope.launch {
val deviceList = dashboardRepository.getAssociatedDeviceList()
if (deviceList != null) {
val vehicleProfileData = dashboardRepository.getVehicleProfileData(deviceList)
if (vehicleProfileData.isNotEmpty())
_associatedDeviceList.postValue(vehicleProfileData)
else
Toast.makeText(weakReference.get(), "Vehicle Profile API failed during operation ", Toast.LENGTH_SHORT)
.show()
} else {
Toast.makeText(weakReference.get(), "Device list API failed", Toast.LENGTH_SHORT)
.show()
}
}
}

/**
Expand Down Expand Up @@ -131,17 +149,21 @@ class DashboardVM(activity: Activity) : AndroidViewModel(activity.application) {

fun isPasswordChangeTriggered(): LiveData<Boolean> = _isPasswordChangeTriggered

fun setPasswordChangeTriggerValue(value: Boolean){
fun setPasswordChangeTriggerValue(value: Boolean) {
_isPasswordChangeTriggered.value = value
}

fun changePasswordApiCall(userServiceInterface: UserServiceInterface): LiveData<CustomMessage<Any>>{
fun changePasswordApiCall(userServiceInterface: UserServiceInterface): LiveData<CustomMessage<Any>> {
val exception =
CoroutineExceptionHandler { _, exception ->
Log.e("Password change request API failed: ", exception.cause.toString())
}
viewModelScope.launch(exception) {
passwordChangeStatus.postValue(dashboardRepository.requestForChangePassword(userServiceInterface))
passwordChangeStatus.postValue(
dashboardRepository.requestForChangePassword(
userServiceInterface
)
)
}
return passwordChangeStatus
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package org.eclipse.ecsp.models.viewmodels
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
import android.app.Activity
import android.util.Log
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
Expand Down Expand Up @@ -102,9 +103,7 @@ class DeviceAssociationVM(activity: Activity) : AndroidViewModel(activity.applic
imeiString: String,
): MutableLiveData<CustomMessage<DeviceVerificationData>> {
viewModelScope.launch {
vehicleServiceInterface.verifyDeviceImei(imeiString) {
_verifyDeviceIMEI.value = it
}
_verifyDeviceIMEI.postValue(vehicleServiceInterface.verifyDeviceImei(imeiString))
}
return _verifyDeviceIMEI
}
Expand All @@ -120,10 +119,15 @@ class DeviceAssociationVM(activity: Activity) : AndroidViewModel(activity.applic
vehicleServiceInterface: VehicleServiceInterface,
serialString: String,
): MutableLiveData<CustomMessage<AssociatedDeviceInfo>> {
viewModelScope.launch {
vehicleServiceInterface.associateDevice(serialString) {
_associateDevice.value = it
try {
viewModelScope.launch {
val result = vehicleServiceInterface.associateDevice(serialString)
if(result.status.requestStatus){
_associateDevice.value = result
}
}
} catch (e: Exception){
Log.e("DEVICE_ASSOCIATION: ", e.cause.toString())
}
return _associateDevice
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.google.gson.Gson
import kotlinx.coroutines.launch
import org.eclipse.ecsp.helper.response.CustomMessage
import org.eclipse.ecsp.roservice.model.RemoteOperationState
import org.eclipse.ecsp.roservice.model.RoEventHistoryResponse
Expand Down Expand Up @@ -232,20 +234,20 @@ class RemoteOperationVM(activity: Activity) : AndroidViewModel(activity.applicat
userId: String,
vehicleId: String,
) {
dashboardRepository.getRemoteOperationHistory(userId, vehicleId)
.observe(lifecycleOwner) { roEventHistoryResponse ->
isProgressBarLoading?.value = false
if(roEventHistoryResponse.status.requestStatus) {
updateListOnRoHistory(
activity,
roEventHistoryResponse,
lazyStaggeredGridList,
notifyRoUpdate,
)
} else{
toastError(activity, "RO History: ${roEventHistoryResponse.error?.message ?: "Error occurred"}")
}
viewModelScope.launch {
val roEventHistoryResponse = dashboardRepository.getRemoteOperationHistory(userId, vehicleId)
isProgressBarLoading?.value = false
if(roEventHistoryResponse.status.requestStatus){
updateListOnRoHistory(
activity,
roEventHistoryResponse,
lazyStaggeredGridList,
notifyRoUpdate,
)
} else {
toastError(activity, "RO History: ${roEventHistoryResponse.error?.message ?: "Error occurred"}")
}
}
}

/*fun cancelJob() {
Expand Down Expand Up @@ -326,13 +328,14 @@ class RemoteOperationVM(activity: Activity) : AndroidViewModel(activity.applicat
duration: Int? = null,
isFromClickAction: Boolean = false,
) {
dashboardRepository.updateRoState(
userId,
vehicleId,
remoteOperationState,
percentage,
duration,
).observe(lifecycleOwner) { roStatusResponse ->
viewModelScope.launch {
val roStatusResponse = dashboardRepository.updateRoState(
userId,
vehicleId,
remoteOperationState,
percentage,
duration,
)
isProgressBarLoading?.value = false
if (!isFromClickAction) {
updateROStatus(
Expand Down
Loading
Loading