diff --git a/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt b/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt index 7a194bf..d27d2c6 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt @@ -157,20 +157,13 @@ class HomeFragment : Fragment() { thresholds = Constants.BUFFER_INTENSITY_THRESHOLDS[userData.deviceId].toString(), interpretation = userData.classificationResult, testId = userData._id, -<<<<<<< HEAD - testTime = "2024-02-08 16:33:56",//userData.testTime, -======= testTime = "2024-02-08 16:33:56",//userData.testTime, ->>>>>>> origin/dev-Issue-Fix-Branch collectionTime = "2024-02-08 16:33:56",//userData.testTime, expiryTime = "2024-02-08 16:33:56"//userData.testTime, ) ) -<<<<<<< HEAD } if (!userData.molbioFlag && isTokenAvailable && Constants.MOLBIO_INTEGRATION) { -======= ->>>>>>> origin/dev-Issue-Fix-Branch userData.molbioFlag = true hemoCubeViewModel.uploadResult(resultList) } diff --git a/app/src/main/java/com/example/hpostesting/presentation/diagnostics/DiagnosticsFragment.kt b/app/src/main/java/com/example/hpostesting/presentation/diagnostics/DiagnosticsFragment.kt index 29789e5..f6e293e 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/diagnostics/DiagnosticsFragment.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/diagnostics/DiagnosticsFragment.kt @@ -65,11 +65,11 @@ class DiagnosticsFragment : Fragment() { binding.btnSubmit.setOnClickListener { binding.btnSubmit.visibility = View.GONE runDeviceDiagnostics() - val batteryLevel = diagnosticsViewModel.getBatteryLevel().toString() - val batteryCapacity = context?.let { diagnosticsViewModel.getBatteryCapacity(it).toString() } - val batteryMaxCapacity = context?.let { diagnosticsViewModel.getBatteryMaxCapacity(it).toString() } - val batteryTemperature = diagnosticsViewModel.getBatteryTemperature().toString() - val batteryVoltage = context?.let { diagnosticsViewModel.getBatteryVoltage(it).toString() } + val batteryLevel = "" //diagnosticsViewModel.getBatteryLevel().toString() + val batteryCapacity = "" //context?.let { diagnosticsViewModel.getBatteryCapacity(it).toString() } + val batteryMaxCapacity = "" //context?.let { diagnosticsViewModel.getBatteryMaxCapacity(it).toString() } + val batteryTemperature = "" //diagnosticsViewModel.getBatteryTemperature().toString() + val batteryVoltage = "" // context?.let { diagnosticsViewModel.getBatteryVoltage(it).toString() } val additionalDetails = AdditionalDetails( batteryLevel = batteryLevel, diff --git a/app/src/main/java/com/example/hpostesting/presentation/diagnostics/DiagnosticsViewModel.kt b/app/src/main/java/com/example/hpostesting/presentation/diagnostics/DiagnosticsViewModel.kt index df8b52e..46532c3 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/diagnostics/DiagnosticsViewModel.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/diagnostics/DiagnosticsViewModel.kt @@ -1,9 +1,5 @@ package com.example.hpostesting.presentation.diagnostics -import android.content.Context -import android.content.Intent -import android.content.IntentFilter -import android.os.BatteryManager import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope @@ -11,8 +7,6 @@ import com.example.hpostesting.data.Result import com.example.hpostesting.data.model.Response import com.example.hpostesting.data.model.devicediagnostics.DeviceDiagnosticsRequest import com.example.hpostesting.data.model.devicediagnostics.DeviceDiagnosticsResponse -import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest -import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionResponse import com.example.hpostesting.data.model.diagnostics.DiagnosticsData import com.example.hpostesting.data.model.patient.DeviceData import com.example.hpostesting.data.repository.Repository @@ -22,8 +16,8 @@ import javax.inject.Inject @HiltViewModel class DiagnosticsViewModel @Inject constructor( - private val respository: Repository, - context: Context, + private val repository: Repository, +// context: Context, ) : ViewModel() { var isServiceConnected = false val progressBar = MutableLiveData(false) @@ -32,10 +26,10 @@ class DiagnosticsViewModel @Inject constructor( val deviceData = MutableLiveData() val fireBaseUpload = MutableLiveData() val deviceDiagnosticsResponse = MutableLiveData>() - private val batteryStatus: Intent? = - IntentFilter(Intent.ACTION_BATTERY_CHANGED).let { ifilter -> - context.registerReceiver(null, ifilter) - } +// private val batteryStatus: Intent? = +// IntentFilter(Intent.ACTION_BATTERY_CHANGED).let { ifilter -> +// context.registerReceiver(null, ifilter) +// } fun addDiagnosticsDataToDb(data: DiagnosticsData) { viewModelScope.launch { try { @@ -68,71 +62,71 @@ class DiagnosticsViewModel @Inject constructor( } - fun getBatteryLevel(): Float? { - val batteryPct: Float? = batteryStatus?.let { intent -> - val level: Int = - intent.getIntExtra( - BatteryManager.EXTRA_LEVEL, - -1 - ) - val scale: Int = - intent.getIntExtra( - BatteryManager.EXTRA_SCALE, - -1 - ) - level * 100 / scale.toFloat() - } - - return batteryPct - } - - fun getBatteryTemperature(): Float? { - val batteryTemp: Float? = batteryStatus?.let { intent -> - val temperature = intent.getIntExtra( - BatteryManager.EXTRA_TEMPERATURE, - 0 - ) - temperature.toFloat() / 10 - } - - return batteryTemp - } - - fun getBatteryVoltage(context: Context): Float { - val batteryIntent = - context.registerReceiver( - null, - IntentFilter(Intent.ACTION_BATTERY_CHANGED) - ) - val voltage = batteryIntent?.getIntExtra( - BatteryManager.EXTRA_VOLTAGE, - 0 - ) ?: 0 - - // milli-volts to volts - return voltage.toFloat() / 1000 - } - - - fun getBatteryCapacity(context: Context): Int { - val batteryManager = - context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager - val currentCapacity = - batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER) - - return currentCapacity - } - - fun getBatteryMaxCapacity(context: Context): Float { - val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager - val designCapacity = - batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY) - val currentCapacity = - batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER) - - // Calculate the estimated maximum battery capacity in mAh - val maxCapacity = currentCapacity.toFloat() / designCapacity.toFloat() * 100 - - return maxCapacity - } +// fun getBatteryLevel(): Float? { +// val batteryPct: Float? = batteryStatus?.let { intent -> +// val level: Int = +// intent.getIntExtra( +// BatteryManager.EXTRA_LEVEL, +// -1 +// ) +// val scale: Int = +// intent.getIntExtra( +// BatteryManager.EXTRA_SCALE, +// -1 +// ) +// level * 100 / scale.toFloat() +// } +// +// return batteryPct +// } +// +// fun getBatteryTemperature(): Float? { +// val batteryTemp: Float? = batteryStatus?.let { intent -> +// val temperature = intent.getIntExtra( +// BatteryManager.EXTRA_TEMPERATURE, +// 0 +// ) +// temperature.toFloat() / 10 +// } +// +// return batteryTemp +// } +// +// fun getBatteryVoltage(context: Context): Float { +// val batteryIntent = +// context.registerReceiver( +// null, +// IntentFilter(Intent.ACTION_BATTERY_CHANGED) +// ) +// val voltage = batteryIntent?.getIntExtra( +// BatteryManager.EXTRA_VOLTAGE, +// 0 +// ) ?: 0 +// +// // milli-volts to volts +// return voltage.toFloat() / 1000 +// } +// +// +// fun getBatteryCapacity(context: Context): Int { +// val batteryManager = +// context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager +// val currentCapacity = +// batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER) +// +// return currentCapacity +// } +// +// fun getBatteryMaxCapacity(context: Context): Float { +// val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager +// val designCapacity = +// batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY) +// val currentCapacity = +// batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER) +// +// // Calculate the estimated maximum battery capacity in mAh +// val maxCapacity = currentCapacity.toFloat() / designCapacity.toFloat() * 100 +// +// return maxCapacity +// } } \ No newline at end of file