refactoring
This commit is contained in:
@@ -1,20 +1,15 @@
|
|||||||
package com.example.hpostesting
|
package com.example.hpostesting
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Context
|
|
||||||
import androidx.room.Room
|
|
||||||
import com.example.hpostesting.data.dao.MyDatabase
|
|
||||||
import com.google.android.datatransport.runtime.dagger.Provides
|
|
||||||
import com.google.firebase.firestore.FirebaseFirestore
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
import com.google.firebase.firestore.FirebaseFirestoreSettings
|
import com.google.firebase.firestore.FirebaseFirestoreSettings
|
||||||
import dagger.hilt.android.HiltAndroidApp
|
import dagger.hilt.android.HiltAndroidApp
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.SupervisorJob
|
import kotlinx.coroutines.SupervisorJob
|
||||||
import javax.inject.Singleton
|
|
||||||
|
|
||||||
@HiltAndroidApp
|
@HiltAndroidApp
|
||||||
class HPOSTestingApplication: Application() {
|
class HPOSTestingApplication : Application() {
|
||||||
val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
|
|
||||||
override fun dcssdkEventAuxScannerAppeared(
|
override fun dcssdkEventAuxScannerAppeared(
|
||||||
dcsScannerInfo: DCSScannerInfo?,
|
dcsScannerInfo: DCSScannerInfo?,
|
||||||
dcsScannerInfo1: DCSScannerInfo?
|
dcsScannerInfo1: DCSScannerInfo?,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,11 +223,11 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
notifications_mask or DCSSDKDefs.DCSSDK_EVENT.DCSSDK_EVENT_BARCODE.value
|
notifications_mask or DCSSDKDefs.DCSSDK_EVENT.DCSSDK_EVENT_BARCODE.value
|
||||||
sdkHandler!!.dcssdkSubsribeForEvents(notifications_mask)
|
sdkHandler!!.dcssdkSubsribeForEvents(notifications_mask)
|
||||||
mScannerInfoList.addAll(sdkHandler!!.dcssdkGetAvailableScannersList())
|
mScannerInfoList.addAll(sdkHandler!!.dcssdkGetAvailableScannersList())
|
||||||
Log.e("scannersize",sdkHandler!!.dcssdkGetAvailableScannersList().size.toString())
|
Log.e("scannersize", sdkHandler!!.dcssdkGetAvailableScannersList().size.toString())
|
||||||
if (mScannerInfoList.isNotEmpty()) {
|
if (mScannerInfoList.isNotEmpty()) {
|
||||||
sdkHandler!!.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
|
sdkHandler!!.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(this,"Error", Toast.LENGTH_LONG).show()
|
Toast.makeText(this, "Error", Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +242,10 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
val outXML = StringBuilder()
|
val outXML = StringBuilder()
|
||||||
val result: DCSSDK_RESULT =
|
val result: DCSSDK_RESULT =
|
||||||
sdkHandler!!.dcssdkExecuteCommandOpCodeInXMLForScanner(
|
sdkHandler!!.dcssdkExecuteCommandOpCodeInXMLForScanner(
|
||||||
DCSSDK_COMMAND_OPCODE.DCSSDK_DEVICE_PULL_TRIGGER, inXML, outXML, mScannerInfoList[0].scannerID // Ensure you're using the correct scanner ID
|
DCSSDK_COMMAND_OPCODE.DCSSDK_DEVICE_PULL_TRIGGER,
|
||||||
|
inXML,
|
||||||
|
outXML,
|
||||||
|
mScannerInfoList[0].scannerID // Ensure you're using the correct scanner ID
|
||||||
)
|
)
|
||||||
if (result == DCSSDK_RESULT.DCSSDK_RESULT_SUCCESS) {
|
if (result == DCSSDK_RESULT.DCSSDK_RESULT_SUCCESS) {
|
||||||
Log.d("Scanning", "Success")
|
Log.d("Scanning", "Success")
|
||||||
|
|||||||
@@ -111,7 +111,11 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val deviceType = when {
|
val deviceType = when {
|
||||||
availableDrivers.isNotEmpty() -> {
|
availableDrivers.isNotEmpty() -> {
|
||||||
val device = availableDrivers[0].device
|
val device = availableDrivers[0].device
|
||||||
Toast.makeText(this, "Connected, productId: ${device.productId}, vendorId: ${device.vendorId}", Toast.LENGTH_SHORT).show()
|
Toast.makeText(
|
||||||
|
this,
|
||||||
|
"Connected, productId: ${device.productId}, vendorId: ${device.vendorId}",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
when {
|
when {
|
||||||
device.productId == Constants.HOMO_CUBE_ID && device.vendorId == Constants.VENDOR_ID -> {
|
device.productId == Constants.HOMO_CUBE_ID && device.vendorId == Constants.VENDOR_ID -> {
|
||||||
binding.cvItem1.visibility = View.VISIBLE
|
binding.cvItem1.visibility = View.VISIBLE
|
||||||
@@ -348,7 +352,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onRequestPermissionsResult(
|
override fun onRequestPermissionsResult(
|
||||||
requestCode: Int, permissions: Array<String>, grantResults: IntArray
|
requestCode: Int, permissions: Array<String>, grantResults: IntArray,
|
||||||
) {
|
) {
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
||||||
when (requestCode) {
|
when (requestCode) {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.example.hpostesting.presentation
|
package com.example.hpostesting.presentation
|
||||||
|
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
@@ -16,6 +15,7 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import com.example.hpostesting.util.MyUtils
|
import com.example.hpostesting.util.MyUtils
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivitySplashBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivitySplashBinding
|
||||||
@@ -53,7 +53,10 @@ class SplashActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
private fun setupStaticConstants() {
|
private fun setupStaticConstants() {
|
||||||
DataHolder.mobileUniqueId =
|
DataHolder.mobileUniqueId =
|
||||||
Settings.Secure.getString(applicationContext.contentResolver, Settings.Secure.ANDROID_ID)
|
Settings.Secure.getString(
|
||||||
|
applicationContext.contentResolver,
|
||||||
|
Settings.Secure.ANDROID_ID
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// private fun setupFirestoreCache() {
|
// private fun setupFirestoreCache() {
|
||||||
@@ -98,7 +101,10 @@ class SplashActivity : AppCompatActivity() {
|
|||||||
private fun requestPermissionsBelowAndroidR() {
|
private fun requestPermissionsBelowAndroidR() {
|
||||||
val permissionsToRequest = requiredPermissions
|
val permissionsToRequest = requiredPermissions
|
||||||
.filterNot { permission ->
|
.filterNot { permission ->
|
||||||
ContextCompat.checkSelfPermission(this, permission) == PackageManager.PERMISSION_GRANTED
|
ContextCompat.checkSelfPermission(
|
||||||
|
this,
|
||||||
|
permission
|
||||||
|
) == PackageManager.PERMISSION_GRANTED
|
||||||
}
|
}
|
||||||
.toTypedArray()
|
.toTypedArray()
|
||||||
|
|
||||||
@@ -114,9 +120,18 @@ class SplashActivity : AppCompatActivity() {
|
|||||||
val coarseLocationPermission = Manifest.permission.ACCESS_COARSE_LOCATION
|
val coarseLocationPermission = Manifest.permission.ACCESS_COARSE_LOCATION
|
||||||
val cameraPermission = Manifest.permission.CAMERA
|
val cameraPermission = Manifest.permission.CAMERA
|
||||||
val locationPermissionsGranted =
|
val locationPermissionsGranted =
|
||||||
ContextCompat.checkSelfPermission(this, fineLocationPermission) == PackageManager.PERMISSION_GRANTED &&
|
ContextCompat.checkSelfPermission(
|
||||||
ContextCompat.checkSelfPermission(this, coarseLocationPermission) == PackageManager.PERMISSION_GRANTED
|
this,
|
||||||
val cameraPermissionGranted = ContextCompat.checkSelfPermission(this, cameraPermission) == PackageManager.PERMISSION_GRANTED
|
fineLocationPermission
|
||||||
|
) == PackageManager.PERMISSION_GRANTED &&
|
||||||
|
ContextCompat.checkSelfPermission(
|
||||||
|
this,
|
||||||
|
coarseLocationPermission
|
||||||
|
) == PackageManager.PERMISSION_GRANTED
|
||||||
|
val cameraPermissionGranted = ContextCompat.checkSelfPermission(
|
||||||
|
this,
|
||||||
|
cameraPermission
|
||||||
|
) == PackageManager.PERMISSION_GRANTED
|
||||||
|
|
||||||
if (locationPermissionsGranted && cameraPermissionGranted) {
|
if (locationPermissionsGranted && cameraPermissionGranted) {
|
||||||
handlePermissionsResult(true)
|
handlePermissionsResult(true)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.example.hpostesting.presentation
|
package com.example.hpostesting.presentation
|
||||||
|
|
||||||
interface UsbServiceListener {
|
interface UsbServiceListener {
|
||||||
fun onUsbRead(data: ByteArray?)
|
fun onUsbRead(data: ByteArray?)
|
||||||
fun onUsbError(e: Exception?)
|
fun onUsbError(e: Exception?)
|
||||||
}
|
}
|
||||||
@@ -17,13 +17,11 @@ import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
|||||||
import com.example.hpostesting.data.model.patient.UserData
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.OfflineUserListViewBinding
|
import `in`.sminnovations.hpostesting.databinding.OfflineUserListViewBinding
|
||||||
import org.apache.commons.collections4.MapUtils.getString
|
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
|
|
||||||
class OfflineUserListAdapter(private val view: View, private val batLevel: Int) :
|
class OfflineUserListAdapter(private val view: View, private val batLevel: Int) :
|
||||||
RecyclerView.Adapter<OfflineUserListAdapter.OfflineUserListViewHolder>() {
|
RecyclerView.Adapter<OfflineUserListAdapter.OfflineUserListViewHolder>() {
|
||||||
|
|
||||||
@@ -33,13 +31,13 @@ class OfflineUserListAdapter(private val view: View, private val batLevel: Int)
|
|||||||
|
|
||||||
private val differCallback = object : DiffUtil.ItemCallback<HemoCubeTestData>() {
|
private val differCallback = object : DiffUtil.ItemCallback<HemoCubeTestData>() {
|
||||||
override fun areItemsTheSame(
|
override fun areItemsTheSame(
|
||||||
oldItem: HemoCubeTestData, newItem: HemoCubeTestData
|
oldItem: HemoCubeTestData, newItem: HemoCubeTestData,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
return oldItem._id == newItem._id
|
return oldItem._id == newItem._id
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun areContentsTheSame(
|
override fun areContentsTheSame(
|
||||||
oldItem: HemoCubeTestData, newItem: HemoCubeTestData
|
oldItem: HemoCubeTestData, newItem: HemoCubeTestData,
|
||||||
): Boolean {
|
): Boolean {
|
||||||
return oldItem == newItem
|
return oldItem == newItem
|
||||||
}
|
}
|
||||||
@@ -104,20 +102,20 @@ class OfflineUserListAdapter(private val view: View, private val batLevel: Int)
|
|||||||
).show()
|
).show()
|
||||||
} else
|
} else
|
||||||
if (isBetween15And30Minutes(userList.incubationTime) > Constants.INCUBATION_TIME_MAX) {
|
if (isBetween15And30Minutes(userList.incubationTime) > Constants.INCUBATION_TIME_MAX) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
view.context,
|
view.context,
|
||||||
view.context.getString(R.string.incubation_crossed_30_minutes),
|
view.context.getString(R.string.incubation_crossed_30_minutes),
|
||||||
Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
} else {
|
} else {
|
||||||
DataHolder.selectedTest = UserData(
|
DataHolder.selectedTest = UserData(
|
||||||
_id = userList._id,
|
_id = userList._id,
|
||||||
bloodGroup = userList.bloodGroup,
|
bloodGroup = userList.bloodGroup,
|
||||||
incubationTime = userList.incubationTime
|
incubationTime = userList.incubationTime
|
||||||
)
|
)
|
||||||
view.findNavController()
|
view.findNavController()
|
||||||
.navigate(R.id.action_nav_home_to_mainActivity)
|
.navigate(R.id.action_nav_home_to_mainActivity)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
view.context,
|
view.context,
|
||||||
@@ -143,7 +141,6 @@ class OfflineUserListAdapter(private val view: View, private val batLevel: Int)
|
|||||||
return diffMillis / (60 * 1000)
|
return diffMillis / (60 * 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun showWarningToast(resId: Int) {
|
private fun showWarningToast(resId: Int) {
|
||||||
val contextToUse = view.context ?: return
|
val contextToUse = view.context ?: return
|
||||||
|
|
||||||
|
|||||||
@@ -4,30 +4,28 @@ import android.annotation.SuppressLint
|
|||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Context.INPUT_METHOD_SERVICE
|
import android.content.Context.INPUT_METHOD_SERVICE
|
||||||
import android.view.inputmethod.InputMethodManager
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.view.inputmethod.InputMethodManager
|
||||||
|
import android.widget.AutoCompleteTextView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
import com.firebase.ui.firestore.FirestoreRecyclerAdapter
|
import com.firebase.ui.firestore.FirestoreRecyclerAdapter
|
||||||
import com.firebase.ui.firestore.FirestoreRecyclerOptions
|
import com.firebase.ui.firestore.FirestoreRecyclerOptions
|
||||||
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.UserItemViewBinding
|
import `in`.sminnovations.hpostesting.databinding.UserItemViewBinding
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import android.widget.AutoCompleteTextView
|
|
||||||
import androidx.core.content.ContextCompat.getSystemService
|
|
||||||
import androidx.core.content.getSystemService
|
|
||||||
import androidx.fragment.app.FragmentActivity
|
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
|
||||||
import com.google.firebase.firestore.FirebaseFirestore
|
|
||||||
|
|
||||||
class UserListAdapter(
|
class UserListAdapter(
|
||||||
|
|
||||||
@@ -36,7 +34,7 @@ class UserListAdapter(
|
|||||||
options: FirestoreRecyclerOptions<UserData>,
|
options: FirestoreRecyclerOptions<UserData>,
|
||||||
private val view: View,
|
private val view: View,
|
||||||
private val batLevel: Int,
|
private val batLevel: Int,
|
||||||
private val requireActivity: FragmentActivity
|
private val requireActivity: FragmentActivity,
|
||||||
) : FirestoreRecyclerAdapter<UserData, UserListAdapter.OrderItemViewHolder>(options) {
|
) : FirestoreRecyclerAdapter<UserData, UserListAdapter.OrderItemViewHolder>(options) {
|
||||||
|
|
||||||
class OrderItemViewHolder(val binding: UserItemViewBinding) :
|
class OrderItemViewHolder(val binding: UserItemViewBinding) :
|
||||||
@@ -96,16 +94,21 @@ class UserListAdapter(
|
|||||||
.setView(dialogView)
|
.setView(dialogView)
|
||||||
.setTitle(R.string.blood_group)
|
.setTitle(R.string.blood_group)
|
||||||
|
|
||||||
val etBloodGroup = dialogView.findViewById<AutoCompleteTextView>(R.id.et_blood_group)
|
val etBloodGroup =
|
||||||
|
dialogView.findViewById<AutoCompleteTextView>(R.id.et_blood_group)
|
||||||
|
|
||||||
builder.setPositiveButton(R.string.ok) { dialog, which ->
|
builder.setPositiveButton(R.string.ok) { dialog, which ->
|
||||||
val bloodGroup = etBloodGroup.text.toString()
|
val bloodGroup = etBloodGroup.text.toString()
|
||||||
if (bloodGroup.equals("Select Blood Group") ||bloodGroup.equals("ರಕ್ತ ಗುಂಪು ಆಯ್ಕೆಮಾಡಿ") || bloodGroup.isNullOrBlank()) {
|
if (bloodGroup.equals("Select Blood Group") || bloodGroup.equals("ರಕ್ತ ಗುಂಪು ಆಯ್ಕೆಮಾಡಿ") || bloodGroup.isNullOrBlank()) {
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
etBloodGroup.error =view.context.getString(R.string.blood_group_error)
|
etBloodGroup.error = view.context.getString(R.string.blood_group_error)
|
||||||
}
|
}
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
Toast.makeText(context, view.context.getString(R.string.blood_group_toast), Toast.LENGTH_SHORT).show()
|
Toast.makeText(
|
||||||
|
context,
|
||||||
|
view.context.getString(R.string.blood_group_toast),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Check if hemoCubeViewModel and testDetails are not null
|
// Check if hemoCubeViewModel and testDetails are not null
|
||||||
@@ -119,7 +122,8 @@ class UserListAdapter(
|
|||||||
val document = userdata.documents[0]
|
val document = userdata.documents[0]
|
||||||
db.collection("patientData")
|
db.collection("patientData")
|
||||||
.document(document.id)
|
.document(document.id)
|
||||||
.update("bloodGroup", bloodGroup,
|
.update(
|
||||||
|
"bloodGroup", bloodGroup,
|
||||||
"incubationTime", SimpleDateFormat(
|
"incubationTime", SimpleDateFormat(
|
||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
).format(Calendar.getInstance().time).toString()
|
).format(Calendar.getInstance().time).toString()
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import dagger.hilt.android.AndroidEntryPoint
|
|||||||
import `in`.sminnovations.hpostesting.databinding.ActivityAssuranceControlsBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityAssuranceControlsBinding
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class AssuranceControlsActivity: AppCompatActivity() {
|
class AssuranceControlsActivity : AppCompatActivity() {
|
||||||
lateinit var binding: ActivityAssuranceControlsBinding
|
lateinit var binding: ActivityAssuranceControlsBinding
|
||||||
lateinit var sharedPreference: SharedPreferences
|
lateinit var sharedPreference: SharedPreferences
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
|||||||
import `in`.sminnovations.hpostesting.databinding.FragmentAssuranceControlsBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentAssuranceControlsBinding
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
|
||||||
class AssuranceControlsFragment: Fragment() {
|
class AssuranceControlsFragment : Fragment() {
|
||||||
lateinit var binding: FragmentAssuranceControlsBinding
|
lateinit var binding: FragmentAssuranceControlsBinding
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
|
|
||||||
@@ -47,7 +47,8 @@ class AssuranceControlsFragment: Fragment() {
|
|||||||
|
|
||||||
val solutionSpinner: Spinner = binding.spinnerSolutions
|
val solutionSpinner: Spinner = binding.spinnerSolutions
|
||||||
val solutionOptions = arrayOf("Select solution", "Tartrazine", "Acid Red")
|
val solutionOptions = arrayOf("Select solution", "Tartrazine", "Acid Red")
|
||||||
val solutionAdapter = ArrayAdapter(requireContext(), R.layout.simple_spinner_item, solutionOptions)
|
val solutionAdapter =
|
||||||
|
ArrayAdapter(requireContext(), R.layout.simple_spinner_item, solutionOptions)
|
||||||
solutionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
solutionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||||
solutionSpinner.adapter = solutionAdapter
|
solutionSpinner.adapter = solutionAdapter
|
||||||
solutionSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
solutionSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
@@ -55,7 +56,7 @@ class AssuranceControlsFragment: Fragment() {
|
|||||||
parent: AdapterView<*>?,
|
parent: AdapterView<*>?,
|
||||||
view: View?,
|
view: View?,
|
||||||
position: Int,
|
position: Int,
|
||||||
id: Long
|
id: Long,
|
||||||
) {
|
) {
|
||||||
val selectedValue: String = solutionOptions[position]
|
val selectedValue: String = solutionOptions[position]
|
||||||
if (!selectedValue.equals("Select solution")) {
|
if (!selectedValue.equals("Select solution")) {
|
||||||
@@ -68,8 +69,21 @@ class AssuranceControlsFragment: Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val concentrationSpinner: Spinner = binding.spinnerConcentration
|
val concentrationSpinner: Spinner = binding.spinnerConcentration
|
||||||
val concentrationOptions = arrayOf("Select concentration", "65umol", "45umol", "22.5umol", "12.25umol", "6.125umol", "75umol", "50umol", "25umol", "12.5umol", "6.25umol")
|
val concentrationOptions = arrayOf(
|
||||||
val concentrationAdapter = ArrayAdapter(requireContext(), R.layout.simple_spinner_item, concentrationOptions)
|
"Select concentration",
|
||||||
|
"65umol",
|
||||||
|
"45umol",
|
||||||
|
"22.5umol",
|
||||||
|
"12.25umol",
|
||||||
|
"6.125umol",
|
||||||
|
"75umol",
|
||||||
|
"50umol",
|
||||||
|
"25umol",
|
||||||
|
"12.5umol",
|
||||||
|
"6.25umol"
|
||||||
|
)
|
||||||
|
val concentrationAdapter =
|
||||||
|
ArrayAdapter(requireContext(), R.layout.simple_spinner_item, concentrationOptions)
|
||||||
concentrationAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
concentrationAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||||
concentrationSpinner.adapter = concentrationAdapter
|
concentrationSpinner.adapter = concentrationAdapter
|
||||||
concentrationSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
concentrationSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
@@ -77,7 +91,7 @@ class AssuranceControlsFragment: Fragment() {
|
|||||||
parent: AdapterView<*>?,
|
parent: AdapterView<*>?,
|
||||||
view: View?,
|
view: View?,
|
||||||
position: Int,
|
position: Int,
|
||||||
id: Long
|
id: Long,
|
||||||
) {
|
) {
|
||||||
val selectedValue: String = concentrationOptions[position]
|
val selectedValue: String = concentrationOptions[position]
|
||||||
if (!selectedValue.equals("Select concentration")) {
|
if (!selectedValue.equals("Select concentration")) {
|
||||||
@@ -91,7 +105,8 @@ class AssuranceControlsFragment: Fragment() {
|
|||||||
|
|
||||||
val volumeSpinner: Spinner = binding.spinnerVolume
|
val volumeSpinner: Spinner = binding.spinnerVolume
|
||||||
val volumeOptions = arrayOf("Select volume", "1uml", "2uml", "4uml", "4.5uml", "5uml")
|
val volumeOptions = arrayOf("Select volume", "1uml", "2uml", "4uml", "4.5uml", "5uml")
|
||||||
val volumeAdapter = ArrayAdapter(requireContext(), R.layout.simple_spinner_item, volumeOptions)
|
val volumeAdapter =
|
||||||
|
ArrayAdapter(requireContext(), R.layout.simple_spinner_item, volumeOptions)
|
||||||
volumeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
volumeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||||
volumeSpinner.adapter = volumeAdapter
|
volumeSpinner.adapter = volumeAdapter
|
||||||
volumeSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
volumeSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
@@ -99,7 +114,7 @@ class AssuranceControlsFragment: Fragment() {
|
|||||||
parent: AdapterView<*>?,
|
parent: AdapterView<*>?,
|
||||||
view: View?,
|
view: View?,
|
||||||
position: Int,
|
position: Int,
|
||||||
id: Long
|
id: Long,
|
||||||
) {
|
) {
|
||||||
val selectedValue: String = volumeOptions[position]
|
val selectedValue: String = volumeOptions[position]
|
||||||
if (!selectedValue.equals("Select volume")) {
|
if (!selectedValue.equals("Select volume")) {
|
||||||
@@ -112,12 +127,15 @@ class AssuranceControlsFragment: Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// load saved values
|
// load saved values
|
||||||
val savedSolution = sharedPreferences.getString(Constants.QUICK_CAPTURE_SOLUTION, "").toString()
|
val savedSolution =
|
||||||
|
sharedPreferences.getString(Constants.QUICK_CAPTURE_SOLUTION, "").toString()
|
||||||
val solutionPosition = getPositionOfValue(savedSolution, solutionOptions.toList())
|
val solutionPosition = getPositionOfValue(savedSolution, solutionOptions.toList())
|
||||||
solutionSpinner.setSelection(solutionPosition)
|
solutionSpinner.setSelection(solutionPosition)
|
||||||
|
|
||||||
val savedConcentration = sharedPreferences.getString(Constants.QUICK_CAPTURE_CONCENTRATION, "").toString()
|
val savedConcentration =
|
||||||
val concentrationPosition = getPositionOfValue(savedConcentration, concentrationOptions.toList())
|
sharedPreferences.getString(Constants.QUICK_CAPTURE_CONCENTRATION, "").toString()
|
||||||
|
val concentrationPosition =
|
||||||
|
getPositionOfValue(savedConcentration, concentrationOptions.toList())
|
||||||
concentrationSpinner.setSelection(concentrationPosition)
|
concentrationSpinner.setSelection(concentrationPosition)
|
||||||
|
|
||||||
val savedVolume = sharedPreferences.getString(Constants.QUICK_CAPTURE_VOLUME, "").toString()
|
val savedVolume = sharedPreferences.getString(Constants.QUICK_CAPTURE_VOLUME, "").toString()
|
||||||
@@ -128,7 +146,11 @@ class AssuranceControlsFragment: Fragment() {
|
|||||||
val selectedSolution = DataHolder.hemoCubeTestData!!.solution
|
val selectedSolution = DataHolder.hemoCubeTestData!!.solution
|
||||||
val selectedVolume = DataHolder.hemoCubeTestData!!.volume
|
val selectedVolume = DataHolder.hemoCubeTestData!!.volume
|
||||||
if (selectedSolution == "Select solution" || selectedVolume == "Select volume") {
|
if (selectedSolution == "Select solution" || selectedVolume == "Select volume") {
|
||||||
Toast.makeText(requireContext(), "Please select both solution and volume", Toast.LENGTH_SHORT).show()
|
Toast.makeText(
|
||||||
|
requireContext(),
|
||||||
|
"Please select both solution and volume",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +161,8 @@ class AssuranceControlsFragment: Fragment() {
|
|||||||
""
|
""
|
||||||
}
|
}
|
||||||
DataHolder.hemoCubeTestData!!._id = currentUnixTime.toString() + "SMI"
|
DataHolder.hemoCubeTestData!!._id = currentUnixTime.toString() + "SMI"
|
||||||
DataHolder.hemoCubeTestData!!.name = "${DataHolder.hemoCubeTestData!!.solution} ${DataHolder.hemoCubeTestData!!.concentration} ${DataHolder.hemoCubeTestData!!.volume}"
|
DataHolder.hemoCubeTestData!!.name =
|
||||||
|
"${DataHolder.hemoCubeTestData!!.solution} ${DataHolder.hemoCubeTestData!!.concentration} ${DataHolder.hemoCubeTestData!!.volume}"
|
||||||
|
|
||||||
DataHolder.selectedTest = UserData()
|
DataHolder.selectedTest = UserData()
|
||||||
DataHolder.selectedTest?._id = DataHolder.hemoCubeTestData!!._id
|
DataHolder.selectedTest?._id = DataHolder.hemoCubeTestData!!._id
|
||||||
@@ -147,7 +170,10 @@ class AssuranceControlsFragment: Fragment() {
|
|||||||
|
|
||||||
with(sharedPreferences.edit()) {
|
with(sharedPreferences.edit()) {
|
||||||
putString(Constants.QUICK_CAPTURE_SOLUTION, DataHolder.hemoCubeTestData!!.solution)
|
putString(Constants.QUICK_CAPTURE_SOLUTION, DataHolder.hemoCubeTestData!!.solution)
|
||||||
putString(Constants.QUICK_CAPTURE_CONCENTRATION, DataHolder.hemoCubeTestData!!.concentration)
|
putString(
|
||||||
|
Constants.QUICK_CAPTURE_CONCENTRATION,
|
||||||
|
DataHolder.hemoCubeTestData!!.concentration
|
||||||
|
)
|
||||||
putString(Constants.QUICK_CAPTURE_VOLUME, DataHolder.hemoCubeTestData!!.volume)
|
putString(Constants.QUICK_CAPTURE_VOLUME, DataHolder.hemoCubeTestData!!.volume)
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import `in`.sminnovations.hpostesting.R
|
|||||||
import `in`.sminnovations.hpostesting.databinding.ActivityAutoDacBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityAutoDacBinding
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class AutoDacActivity: AppCompatActivity() {
|
class AutoDacActivity : AppCompatActivity() {
|
||||||
private lateinit var binding: ActivityAutoDacBinding
|
private lateinit var binding: ActivityAutoDacBinding
|
||||||
val viewModel: AutoDacViewModel by viewModels()
|
val viewModel: AutoDacViewModel by viewModels()
|
||||||
private var myMenu: Menu? = null
|
private var myMenu: Menu? = null
|
||||||
@@ -62,7 +62,6 @@ class AutoDacActivity: AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private val connection = object : ServiceConnection {
|
private val connection = object : ServiceConnection {
|
||||||
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
||||||
val binder = service as UsbService.UsbServiceBinder
|
val binder = service as UsbService.UsbServiceBinder
|
||||||
@@ -107,6 +106,7 @@ class AutoDacActivity: AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun connectUsb(permissionGranted: Boolean) {
|
open fun connectUsb(permissionGranted: Boolean) {
|
||||||
Log.d(TAG, "connectUsb() called, permission variable = $permissionGranted")
|
Log.d(TAG, "connectUsb() called, permission variable = $permissionGranted")
|
||||||
val manager = getSystemService(Context.USB_SERVICE) as UsbManager
|
val manager = getSystemService(Context.USB_SERVICE) as UsbManager
|
||||||
@@ -126,7 +126,6 @@ class AutoDacActivity: AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun onErrorReported(msg: String) {
|
fun onErrorReported(msg: String) {
|
||||||
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
|
||||||
if (!isFinishing) onBackPressed()
|
if (!isFinishing) onBackPressed()
|
||||||
@@ -161,17 +160,16 @@ class AutoDacActivity: AppCompatActivity() {
|
|||||||
manager.requestPermission(device, mPendingIntent)
|
manager.requestPermission(device, mPendingIntent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun setupService() {
|
fun setupService() {
|
||||||
val intent = Intent(this, UsbService::class.java)
|
val intent = Intent(this, UsbService::class.java)
|
||||||
bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||||
menuInflater.inflate(R.menu.my_menu, menu)
|
menuInflater.inflate(R.menu.my_menu, menu)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
if (viewModel.isServiceConnected) {
|
if (viewModel.isServiceConnected) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import java.text.SimpleDateFormat
|
|||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
class AutoDacFragment: Fragment() {
|
class AutoDacFragment : Fragment() {
|
||||||
|
|
||||||
private lateinit var binding: FragmentAutoDacBinding
|
private lateinit var binding: FragmentAutoDacBinding
|
||||||
private val autoDacViewModel: AutoDacViewModel by activityViewModels()
|
private val autoDacViewModel: AutoDacViewModel by activityViewModels()
|
||||||
@@ -47,7 +47,6 @@ class AutoDacFragment: Fragment() {
|
|||||||
observeViewModel()
|
observeViewModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun initViews() {
|
private fun initViews() {
|
||||||
binding.btnSubmit.visibility = View.GONE
|
binding.btnSubmit.visibility = View.GONE
|
||||||
listenToHemoCube()
|
listenToHemoCube()
|
||||||
@@ -58,7 +57,6 @@ class AutoDacFragment: Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun observeViewModel() {
|
private fun observeViewModel() {
|
||||||
|
|
||||||
autoDacViewModel.deviceData.observe(viewLifecycleOwner) {
|
autoDacViewModel.deviceData.observe(viewLifecycleOwner) {
|
||||||
@@ -93,6 +91,7 @@ class AutoDacFragment: Fragment() {
|
|||||||
binding.tvSubtitle4.text = stringData
|
binding.tvSubtitle4.text = stringData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
autoDacViewModel.progressBar.postValue(false)
|
autoDacViewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
@@ -106,6 +105,7 @@ class AutoDacFragment: Fragment() {
|
|||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
autoDacViewModel.progressBar.postValue(false)
|
autoDacViewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
@@ -145,10 +145,20 @@ class AutoDacFragment: Fragment() {
|
|||||||
if (resultData.contains("#CC")) {
|
if (resultData.contains("#CC")) {
|
||||||
autoDacViewModel.addAutoDacDataToDb(
|
autoDacViewModel.addAutoDacDataToDb(
|
||||||
DiagnosticsData(
|
DiagnosticsData(
|
||||||
deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString(),
|
deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "")
|
||||||
devicePassword = sharedPreferences.getString(Constants.DEVICE_PASSWORD_API, "").toString(),
|
.toString(),
|
||||||
deviceNatsToken = sharedPreferences.getString(Constants.NATS_TOKEN, "").toString(),
|
devicePassword = sharedPreferences.getString(
|
||||||
accessToken = sharedPreferences.getString(Constants.ACCESS_TOKEN, "").toString(),
|
Constants.DEVICE_PASSWORD_API,
|
||||||
|
""
|
||||||
|
).toString(),
|
||||||
|
deviceNatsToken = sharedPreferences.getString(
|
||||||
|
Constants.NATS_TOKEN,
|
||||||
|
""
|
||||||
|
).toString(),
|
||||||
|
accessToken = sharedPreferences.getString(
|
||||||
|
Constants.ACCESS_TOKEN,
|
||||||
|
""
|
||||||
|
).toString(),
|
||||||
deviceData = resultData,
|
deviceData = resultData,
|
||||||
runTime = SimpleDateFormat(
|
runTime = SimpleDateFormat(
|
||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
|||||||
@@ -2,12 +2,9 @@ package com.example.hpostesting.presentation.autodac
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.util.Log
|
|
||||||
import androidx.lifecycle.LiveData
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.example.hpostesting.data.NetworkStatusLiveData
|
|
||||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||||
import com.example.hpostesting.data.model.Response
|
import com.example.hpostesting.data.model.Response
|
||||||
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
||||||
@@ -18,10 +15,10 @@ import kotlinx.coroutines.launch
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class AutoDacViewModel @Inject constructor(
|
class AutoDacViewModel @Inject constructor(
|
||||||
private val hemoCubeDao: HemoCubeDao,
|
private val hemoCubeDao: HemoCubeDao,
|
||||||
private val repository: Repository,
|
private val repository: Repository,
|
||||||
context: Context
|
context: Context,
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
var isServiceConnected = false
|
var isServiceConnected = false
|
||||||
val progressBar = MutableLiveData(false)
|
val progressBar = MutableLiveData(false)
|
||||||
|
|||||||
@@ -127,18 +127,19 @@ open class HemocubeBufferCheckActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
@SuppressLint("MutableImplicitPendingIntent")
|
@SuppressLint("MutableImplicitPendingIntent")
|
||||||
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
||||||
val mPendingIntent: PendingIntent = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
val mPendingIntent: PendingIntent =
|
||||||
PendingIntent.getBroadcast(
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||||
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
PendingIntent.getBroadcast(
|
||||||
)
|
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||||
} else {
|
)
|
||||||
PendingIntent.getBroadcast(
|
} else {
|
||||||
this,
|
PendingIntent.getBroadcast(
|
||||||
0,
|
this,
|
||||||
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
0,
|
||||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
||||||
)
|
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||||
}
|
)
|
||||||
|
}
|
||||||
|
|
||||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||||
registerReceiver(broadcastReceiver, filter)
|
registerReceiver(broadcastReceiver, filter)
|
||||||
@@ -153,7 +154,8 @@ open class HemocubeBufferCheckActivity : AppCompatActivity() {
|
|||||||
private fun moveToNext() {
|
private fun moveToNext() {
|
||||||
if (supportFragmentManager.isDestroyed) return
|
if (supportFragmentManager.isDestroyed) return
|
||||||
|
|
||||||
supportFragmentManager.beginTransaction().replace(binding.fghemocube.id, HemoCubeBufferCheckFragment())
|
supportFragmentManager.beginTransaction()
|
||||||
|
.replace(binding.fghemocube.id, HemoCubeBufferCheckFragment())
|
||||||
.commit()
|
.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import `in`.sminnovations.hpostesting.R
|
|||||||
import `in`.sminnovations.hpostesting.databinding.ActivityCalibrationBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityCalibrationBinding
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class CalibrationActivity: AppCompatActivity() {
|
class CalibrationActivity : AppCompatActivity() {
|
||||||
private lateinit var binding: ActivityCalibrationBinding
|
private lateinit var binding: ActivityCalibrationBinding
|
||||||
val viewModel: CalibrationViewModel by viewModels()
|
val viewModel: CalibrationViewModel by viewModels()
|
||||||
private var myMenu: Menu? = null
|
private var myMenu: Menu? = null
|
||||||
@@ -107,6 +107,7 @@ class CalibrationActivity: AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun connectUsb(permissionGranted: Boolean) {
|
open fun connectUsb(permissionGranted: Boolean) {
|
||||||
Log.d(TAG, "connectUsb() called, permission variable = $permissionGranted")
|
Log.d(TAG, "connectUsb() called, permission variable = $permissionGranted")
|
||||||
val manager = getSystemService(Context.USB_SERVICE) as UsbManager
|
val manager = getSystemService(Context.USB_SERVICE) as UsbManager
|
||||||
@@ -136,24 +137,26 @@ class CalibrationActivity: AppCompatActivity() {
|
|||||||
private fun moveToNext() {
|
private fun moveToNext() {
|
||||||
if (supportFragmentManager.isDestroyed) return
|
if (supportFragmentManager.isDestroyed) return
|
||||||
|
|
||||||
supportFragmentManager.beginTransaction().replace(binding.fgCalibration.id, CalibrationFragment())
|
supportFragmentManager.beginTransaction()
|
||||||
|
.replace(binding.fgCalibration.id, CalibrationFragment())
|
||||||
.commit()
|
.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("MutableImplicitPendingIntent")
|
@SuppressLint("MutableImplicitPendingIntent")
|
||||||
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
||||||
val mPendingIntent: PendingIntent = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
val mPendingIntent: PendingIntent =
|
||||||
PendingIntent.getBroadcast(
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||||
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
PendingIntent.getBroadcast(
|
||||||
)
|
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||||
} else {
|
)
|
||||||
PendingIntent.getBroadcast(
|
} else {
|
||||||
this,
|
PendingIntent.getBroadcast(
|
||||||
0,
|
this,
|
||||||
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
0,
|
||||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
||||||
)
|
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||||
}
|
)
|
||||||
|
}
|
||||||
|
|
||||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||||
registerReceiver(broadcastReceiver, filter)
|
registerReceiver(broadcastReceiver, filter)
|
||||||
@@ -171,6 +174,7 @@ class CalibrationActivity: AppCompatActivity() {
|
|||||||
menuInflater.inflate(R.menu.my_menu, menu)
|
menuInflater.inflate(R.menu.my_menu, menu)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
if (viewModel.isServiceConnected) {
|
if (viewModel.isServiceConnected) {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import com.google.firebase.crashlytics.ktx.crashlytics
|
|||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentCalibrationBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentCalibrationBinding
|
||||||
|
|
||||||
class CalibrationFragment: Fragment() {
|
class CalibrationFragment : Fragment() {
|
||||||
|
|
||||||
private lateinit var binding: FragmentCalibrationBinding
|
private lateinit var binding: FragmentCalibrationBinding
|
||||||
private val calibrationViewModel: CalibrationViewModel by activityViewModels()
|
private val calibrationViewModel: CalibrationViewModel by activityViewModels()
|
||||||
@@ -226,6 +226,7 @@ class CalibrationFragment: Fragment() {
|
|||||||
binding.tvSubtitle4.text = stringData
|
binding.tvSubtitle4.text = stringData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
calibrationViewModel.progressBar.postValue(false)
|
calibrationViewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,21 +2,12 @@ package com.example.hpostesting.presentation.calibration
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.util.Log
|
|
||||||
import androidx.lifecycle.LiveData
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
|
||||||
import com.example.hpostesting.data.NetworkStatusLiveData
|
|
||||||
import com.example.hpostesting.data.constant.Constants
|
|
||||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
|
||||||
import com.example.hpostesting.data.model.Response
|
|
||||||
import com.example.hpostesting.data.model.calibration.CalibrationData
|
import com.example.hpostesting.data.model.calibration.CalibrationData
|
||||||
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
|
||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
import com.example.hpostesting.data.repository.Repository
|
import com.example.hpostesting.data.repository.Repository
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
@@ -30,12 +21,8 @@ class CalibrationViewModel @Inject constructor(
|
|||||||
private val sharedPreference: SharedPreferences =
|
private val sharedPreference: SharedPreferences =
|
||||||
context.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
context.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
|
|
||||||
// private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
|
||||||
val deviceData = MutableLiveData<DeviceData?>()
|
val deviceData = MutableLiveData<DeviceData?>()
|
||||||
// val networkStatusLiveData: LiveData<Boolean>
|
|
||||||
// get() = _networkStatusLiveData
|
|
||||||
val fireBaseUpload = MutableLiveData<String>()
|
val fireBaseUpload = MutableLiveData<String>()
|
||||||
val savedCalibrationData = MutableLiveData<String>()
|
|
||||||
|
|
||||||
fun loadSavedCalibrationData(): CalibrationData {
|
fun loadSavedCalibrationData(): CalibrationData {
|
||||||
val calibrationData = CalibrationData()
|
val calibrationData = CalibrationData()
|
||||||
|
|||||||
@@ -116,7 +116,6 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val drawerLayout: DrawerLayout = binding.drawerLayout
|
val drawerLayout: DrawerLayout = binding.drawerLayout
|
||||||
val navView: NavigationView = binding.navView
|
val navView: NavigationView = binding.navView
|
||||||
val navController = findNavController(R.id.nav_host_fragment_content_dashboard)
|
val navController = findNavController(R.id.nav_host_fragment_content_dashboard)
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class GalleryFragment : Fragment() {
|
|||||||
private var _binding: FragmentGalleryBinding? = null
|
private var _binding: FragmentGalleryBinding? = null
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
private var userid = ""
|
private var userid = ""
|
||||||
|
|
||||||
// This property is only valid between onCreateView and
|
// This property is only valid between onCreateView and
|
||||||
// onDestroyView.
|
// onDestroyView.
|
||||||
private val binding get() = _binding!!
|
private val binding get() = _binding!!
|
||||||
@@ -37,7 +38,7 @@ class GalleryFragment : Fragment() {
|
|||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
||||||
): View {
|
): View {
|
||||||
// val galleryViewModel =
|
// val galleryViewModel =
|
||||||
// ViewModelProvider(this).get(GalleryViewModel::class.java)
|
// ViewModelProvider(this).get(GalleryViewModel::class.java)
|
||||||
|
|||||||
@@ -538,7 +538,6 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun fetchDeviceCredentials() {
|
private fun fetchDeviceCredentials() {
|
||||||
try {
|
try {
|
||||||
val db = Firebase.firestore
|
val db = Firebase.firestore
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ class SlideshowFragment : PreferenceFragmentCompat() {
|
|||||||
// App Version Preference
|
// App Version Preference
|
||||||
val appVersionPreference = Preference(requireContext())
|
val appVersionPreference = Preference(requireContext())
|
||||||
appVersionPreference.title = "App Version"
|
appVersionPreference.title = "App Version"
|
||||||
appVersionPreference.summary = getAppVersion(requireContext()) + " [ " + getAppEnvironment(requireContext()) + " ]"
|
appVersionPreference.summary =
|
||||||
|
getAppVersion(requireContext()) + " [ " + getAppEnvironment(requireContext()) + " ]"
|
||||||
|
|
||||||
preferenceScreen.addPreference(languagePreference)
|
preferenceScreen.addPreference(languagePreference)
|
||||||
preferenceScreen.addPreference(appVersionPreference)
|
preferenceScreen.addPreference(appVersionPreference)
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ package com.example.hpostesting.presentation.dashboard.ui
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
@@ -20,7 +20,7 @@ class LoginFragment : Fragment() {
|
|||||||
private lateinit var sharedPreference: SharedPreferences
|
private lateinit var sharedPreference: SharedPreferences
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?,
|
||||||
): View {
|
): View {
|
||||||
_binding = FragmentLoginBinding.inflate(inflater, container, false)
|
_binding = FragmentLoginBinding.inflate(inflater, container, false)
|
||||||
sharedPreference =
|
sharedPreference =
|
||||||
@@ -33,7 +33,6 @@ class LoginFragment : Fragment() {
|
|||||||
init()
|
init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun init() {
|
private fun init() {
|
||||||
if (isUserLoggedIn()) {
|
if (isUserLoggedIn()) {
|
||||||
navigateToHomeFragment()
|
navigateToHomeFragment()
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ import android.content.SharedPreferences
|
|||||||
import android.hardware.usb.UsbDevice
|
import android.hardware.usb.UsbDevice
|
||||||
import android.hardware.usb.UsbDeviceConnection
|
import android.hardware.usb.UsbDeviceConnection
|
||||||
import android.hardware.usb.UsbManager
|
import android.hardware.usb.UsbManager
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
@@ -172,6 +172,7 @@ class DeviceActivity : AppCompatActivity(), DeviceCommunicationHandler {
|
|||||||
menuInflater.inflate(R.menu.my_menu, menu)
|
menuInflater.inflate(R.menu.my_menu, menu)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
if (deviceViewModel.isServiceConnected) {
|
if (deviceViewModel.isServiceConnected) {
|
||||||
@@ -182,6 +183,9 @@ class DeviceActivity : AppCompatActivity(), DeviceCommunicationHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun sendAndListenToDevice(command: HemoCubeCommands, listener: UsbServiceListener) {
|
override fun sendAndListenToDevice(command: HemoCubeCommands, listener: UsbServiceListener) {
|
||||||
mService.sendAndListenToHemoCube(command = HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND, listener)
|
mService.sendAndListenToHemoCube(
|
||||||
|
command = HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
||||||
|
listener
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,8 +18,6 @@ import com.google.firebase.crashlytics.ktx.crashlytics
|
|||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentDeviceBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentDeviceBinding
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DeviceFragment : Fragment() {
|
class DeviceFragment : Fragment() {
|
||||||
private lateinit var binding: FragmentDeviceBinding
|
private lateinit var binding: FragmentDeviceBinding
|
||||||
private val deviceViewModel: HemoCubeViewModel by activityViewModels()
|
private val deviceViewModel: HemoCubeViewModel by activityViewModels()
|
||||||
@@ -61,6 +59,7 @@ class DeviceFragment : Fragment() {
|
|||||||
binding.tvSubtitle4.text = "Device ID: ${stringData}"
|
binding.tvSubtitle4.text = "Device ID: ${stringData}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
deviceViewModel.progressBar.postValue(false)
|
deviceViewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
@@ -68,7 +67,6 @@ class DeviceFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private fun listenToHemoCube() {
|
private fun listenToHemoCube() {
|
||||||
|
|
||||||
val fullReadOutput = StringBuilder()
|
val fullReadOutput = StringBuilder()
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.example.hpostesting.data.model.patient.DeviceData
|
|||||||
import com.example.hpostesting.data.repository.Repository
|
import com.example.hpostesting.data.repository.Repository
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class DeviceViewModel @Inject constructor(
|
class DeviceViewModel @Inject constructor(
|
||||||
private val hemoCubeDao: HemoCubeDao,
|
private val hemoCubeDao: HemoCubeDao,
|
||||||
@@ -15,12 +16,6 @@ class DeviceViewModel @Inject constructor(
|
|||||||
var isServiceConnected = false
|
var isServiceConnected = false
|
||||||
val progressBar = MutableLiveData(false)
|
val progressBar = MutableLiveData(false)
|
||||||
val messages = MutableLiveData<String>()
|
val messages = MutableLiveData<String>()
|
||||||
// private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
|
||||||
// val allUserData = hemoCubeDao.getAll()
|
|
||||||
val deviceData = MutableLiveData<DeviceData?>()
|
val deviceData = MutableLiveData<DeviceData?>()
|
||||||
// val networkStatusLiveData: LiveData<Boolean>
|
val fireBaseUpload = MutableLiveData<String>()
|
||||||
// get() = _networkStatusLiveData
|
|
||||||
val fireBaseUpload = MutableLiveData<String>()
|
|
||||||
val fireBaseBulkUpload = MutableLiveData<String>()
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -145,18 +145,19 @@ class DeviceProvisionActivity : AppCompatActivity(), DeviceCommunicationHandler
|
|||||||
|
|
||||||
@SuppressLint("MutableImplicitPendingIntent")
|
@SuppressLint("MutableImplicitPendingIntent")
|
||||||
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
||||||
val mPendingIntent: PendingIntent = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
val mPendingIntent: PendingIntent =
|
||||||
PendingIntent.getBroadcast(
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||||
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
PendingIntent.getBroadcast(
|
||||||
)
|
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||||
} else {
|
)
|
||||||
PendingIntent.getBroadcast(
|
} else {
|
||||||
this,
|
PendingIntent.getBroadcast(
|
||||||
0,
|
this,
|
||||||
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
0,
|
||||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
||||||
)
|
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||||
}
|
)
|
||||||
|
}
|
||||||
|
|
||||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
||||||
registerReceiver(broadcastReceiver, filter)
|
registerReceiver(broadcastReceiver, filter)
|
||||||
@@ -185,6 +186,9 @@ class DeviceProvisionActivity : AppCompatActivity(), DeviceCommunicationHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun sendAndListenToDevice(command: HemoCubeCommands, listener: UsbServiceListener) {
|
override fun sendAndListenToDevice(command: HemoCubeCommands, listener: UsbServiceListener) {
|
||||||
mService.sendAndListenToHemoCube(command = HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND, listener)
|
mService.sendAndListenToHemoCube(
|
||||||
|
command = HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
||||||
|
listener
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,17 +33,19 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
private var isOnline = false
|
private var isOnline = false
|
||||||
val deviceData = MutableLiveData<DeviceData?>()
|
val deviceData = MutableLiveData<DeviceData?>()
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
||||||
): View {
|
): View {
|
||||||
binding = FragmentDeviceProvisionBinding.inflate(inflater, container, false)
|
binding = FragmentDeviceProvisionBinding.inflate(inflater, container, false)
|
||||||
sharedPreferences = requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
sharedPreferences = requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
initViews()
|
initViews()
|
||||||
observeViewModel()
|
observeViewModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initViews() {
|
private fun initViews() {
|
||||||
listenToHemoCube()
|
listenToHemoCube()
|
||||||
getDeviceId()
|
getDeviceId()
|
||||||
@@ -83,7 +85,8 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
response.data.data?.device?.deviceUser?.natsToken
|
response.data.data?.device?.deviceUser?.natsToken
|
||||||
)
|
)
|
||||||
response.data.data?.device?.deviceUser?.natsToken?.let {
|
response.data.data?.device?.deviceUser?.natsToken?.let {
|
||||||
Log.e("natstoken",
|
Log.e(
|
||||||
|
"natstoken",
|
||||||
it
|
it
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -104,7 +107,8 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
).show()
|
).show()
|
||||||
viewModel.addDeviceProvisionDataToDb(
|
viewModel.addDeviceProvisionDataToDb(
|
||||||
DeviceData(
|
DeviceData(
|
||||||
deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString(),
|
deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "")
|
||||||
|
.toString(),
|
||||||
username = response.data.data?.credentials?.username.toString(),
|
username = response.data.data?.credentials?.username.toString(),
|
||||||
password = response.data.data?.credentials?.password.toString(),
|
password = response.data.data?.credentials?.password.toString(),
|
||||||
deviceProvisionResponse = response.data.data.toString(),
|
deviceProvisionResponse = response.data.data.toString(),
|
||||||
@@ -113,9 +117,9 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
// viewModel.addDeviceId(DeviceData(deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString()))
|
// viewModel.addDeviceId(DeviceData(deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString()))
|
||||||
Log.e("idpass",response.toString())
|
Log.e("idpass", response.toString())
|
||||||
Log.e("idpass",response.data.data?.credentials?.username.toString())
|
Log.e("idpass", response.data.data?.credentials?.username.toString())
|
||||||
Log.e("idpass",deviceProvisionResponse)
|
Log.e("idpass", deviceProvisionResponse)
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
activity,
|
activity,
|
||||||
@@ -147,7 +151,9 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
viewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
viewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
||||||
if (result == "Success") {
|
if (result == "Success") {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
activity, "Device provision successfully uploaded to firebase", Toast.LENGTH_LONG
|
activity,
|
||||||
|
"Device provision successfully uploaded to firebase",
|
||||||
|
Toast.LENGTH_LONG
|
||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ import android.content.ServiceConnection
|
|||||||
import android.hardware.usb.UsbDevice
|
import android.hardware.usb.UsbDevice
|
||||||
import android.hardware.usb.UsbDeviceConnection
|
import android.hardware.usb.UsbDeviceConnection
|
||||||
import android.hardware.usb.UsbManager
|
import android.hardware.usb.UsbManager
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
@@ -63,7 +63,6 @@ class DiagnosticsActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private val connection = object : ServiceConnection {
|
private val connection = object : ServiceConnection {
|
||||||
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
||||||
val binder = service as UsbService.UsbServiceBinder
|
val binder = service as UsbService.UsbServiceBinder
|
||||||
@@ -108,6 +107,7 @@ class DiagnosticsActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun connectUsb(permissionGranted: Boolean) {
|
open fun connectUsb(permissionGranted: Boolean) {
|
||||||
Log.d(TAG, "connectUsb() called, permission variable = $permissionGranted")
|
Log.d(TAG, "connectUsb() called, permission variable = $permissionGranted")
|
||||||
val manager = getSystemService(Context.USB_SERVICE) as UsbManager
|
val manager = getSystemService(Context.USB_SERVICE) as UsbManager
|
||||||
@@ -133,11 +133,11 @@ class DiagnosticsActivity : AppCompatActivity() {
|
|||||||
if (!isFinishing) onBackPressed()
|
if (!isFinishing) onBackPressed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun moveToNext() {
|
private fun moveToNext() {
|
||||||
if (supportFragmentManager.isDestroyed) return
|
if (supportFragmentManager.isDestroyed) return
|
||||||
|
|
||||||
supportFragmentManager.beginTransaction().replace(binding.fgDiagnostics.id, DiagnosticsFragment())
|
supportFragmentManager.beginTransaction()
|
||||||
|
.replace(binding.fgDiagnostics.id, DiagnosticsFragment())
|
||||||
.commit()
|
.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,17 +162,16 @@ class DiagnosticsActivity : AppCompatActivity() {
|
|||||||
manager.requestPermission(device, mPendingIntent)
|
manager.requestPermission(device, mPendingIntent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun setupService() {
|
fun setupService() {
|
||||||
val intent = Intent(this, UsbService::class.java)
|
val intent = Intent(this, UsbService::class.java)
|
||||||
bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||||
menuInflater.inflate(R.menu.my_menu, menu)
|
menuInflater.inflate(R.menu.my_menu, menu)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
if (viewModel.isServiceConnected) {
|
if (viewModel.isServiceConnected) {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class DiagnosticsFragment : Fragment() {
|
|||||||
|
|
||||||
messages.observe(viewLifecycleOwner) {
|
messages.observe(viewLifecycleOwner) {
|
||||||
binding.tvSubtitle4.text = it
|
binding.tvSubtitle4.text = it
|
||||||
Log.e("diagnostics",binding.tvSubtitle4.text.toString())
|
Log.e("diagnostics", binding.tvSubtitle4.text.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
diagnosticsViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
diagnosticsViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
||||||
@@ -95,6 +95,7 @@ class DiagnosticsFragment : Fragment() {
|
|||||||
binding.tvSubtitle4.text = stringData
|
binding.tvSubtitle4.text = stringData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
diagnosticsViewModel.progressBar.postValue(false)
|
diagnosticsViewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
@@ -110,6 +111,7 @@ class DiagnosticsFragment : Fragment() {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
diagnosticsViewModel.progressBar.postValue(false)
|
diagnosticsViewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
@@ -122,7 +124,8 @@ class DiagnosticsFragment : Fragment() {
|
|||||||
startListening.postValue(true)
|
startListening.postValue(true)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
(activity as DiagnosticsActivity).mService.listenToHemoCube(object : UsbServiceListener {
|
(activity as DiagnosticsActivity).mService.listenToHemoCube(object :
|
||||||
|
UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
data?.let {
|
data?.let {
|
||||||
val stringData = String(it)
|
val stringData = String(it)
|
||||||
@@ -146,16 +149,28 @@ class DiagnosticsFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (resultData.contains("END") || fullReadOutput.contains("END")) {
|
if (resultData.contains("END") || fullReadOutput.contains("END")) {
|
||||||
diagnosticsViewModel.addDiagnosticsDataToDb(DiagnosticsData(
|
diagnosticsViewModel.addDiagnosticsDataToDb(
|
||||||
deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString(),
|
DiagnosticsData(
|
||||||
devicePassword = sharedPreferences.getString(Constants.DEVICE_PASSWORD_API, "").toString(),
|
deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "")
|
||||||
deviceNatsToken = sharedPreferences.getString(Constants.NATS_TOKEN, "").toString(),
|
.toString(),
|
||||||
accessToken = sharedPreferences.getString(Constants.ACCESS_TOKEN, "").toString(),
|
devicePassword = sharedPreferences.getString(
|
||||||
deviceData = resultData,
|
Constants.DEVICE_PASSWORD_API,
|
||||||
runTime = SimpleDateFormat(
|
""
|
||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
).toString(),
|
||||||
).format(Calendar.getInstance().time)
|
deviceNatsToken = sharedPreferences.getString(
|
||||||
))
|
Constants.NATS_TOKEN,
|
||||||
|
""
|
||||||
|
).toString(),
|
||||||
|
accessToken = sharedPreferences.getString(
|
||||||
|
Constants.ACCESS_TOKEN,
|
||||||
|
""
|
||||||
|
).toString(),
|
||||||
|
deviceData = resultData,
|
||||||
|
runTime = SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
).format(Calendar.getInstance().time)
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
// val inputData = mutableListOf<String>()
|
// val inputData = mutableListOf<String>()
|
||||||
// while (true) {
|
// while (true) {
|
||||||
@@ -178,7 +193,6 @@ class DiagnosticsFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun parseData(inputData: List<String>): List<Pair<String, String>> {
|
fun parseData(inputData: List<String>): List<Pair<String, String>> {
|
||||||
val pattern = Regex("([A-Z]+)\\s(\\d+)")
|
val pattern = Regex("([A-Z]+)\\s(\\d+)")
|
||||||
val parsedData = mutableListOf<Pair<String, String>>()
|
val parsedData = mutableListOf<Pair<String, String>>()
|
||||||
|
|||||||
@@ -10,9 +10,10 @@ import com.example.hpostesting.data.repository.Repository
|
|||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class DiagnosticsViewModel @Inject constructor(
|
class DiagnosticsViewModel @Inject constructor(
|
||||||
private val repository: Repository
|
private val repository: Repository,
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
var isServiceConnected = false
|
var isServiceConnected = false
|
||||||
val progressBar = MutableLiveData(false)
|
val progressBar = MutableLiveData(false)
|
||||||
|
|||||||
@@ -1,25 +1,10 @@
|
|||||||
package com.example.hpostesting.presentation.hemocube
|
package com.example.hpostesting.presentation.hemocube
|
||||||
|
|
||||||
import android.content.BroadcastReceiver
|
|
||||||
import android.content.ComponentName
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
|
||||||
import android.content.ServiceConnection
|
|
||||||
import android.hardware.usb.UsbDevice
|
|
||||||
import android.hardware.usb.UsbDeviceConnection
|
|
||||||
import android.hardware.usb.UsbManager
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.IBinder
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import android.view.Menu
|
|
||||||
import androidx.activity.viewModels
|
|
||||||
import com.example.hpostesting.data.DataHolder
|
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.testRight.UsbService
|
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
|
||||||
import `in`.sminnovations.hpostesting.R
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityDigitalCardBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityDigitalCardBinding
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityHemocubeBinding
|
|
||||||
|
|
||||||
class DigitalCardActivity : AppCompatActivity() {
|
class DigitalCardActivity : AppCompatActivity() {
|
||||||
|
|
||||||
@@ -38,10 +23,10 @@ class DigitalCardActivity : AppCompatActivity() {
|
|||||||
moveToNext()
|
moveToNext()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun moveToNext() {
|
private fun moveToNext() {
|
||||||
if (supportFragmentManager.isDestroyed) return
|
if (supportFragmentManager.isDestroyed) return
|
||||||
supportFragmentManager.beginTransaction().replace(binding.fghemocube.id, DigitalCardFragment())
|
supportFragmentManager.beginTransaction()
|
||||||
|
.replace(binding.fghemocube.id, DigitalCardFragment())
|
||||||
.commit()
|
.commit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,16 +5,14 @@ import android.content.Context
|
|||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
||||||
import `in`.sminnovations.hpostesting.R
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentDigitalCardBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentDigitalCardBinding
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentHemoCubeReferenceBinding
|
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
@@ -61,14 +59,17 @@ class DigitalCardFragment : Fragment() {
|
|||||||
binding.State.text = "State: ${testDetails?.state}"
|
binding.State.text = "State: ${testDetails?.state}"
|
||||||
binding.abhaid.text = "ABHA ID: ${testDetails?.abhaId}"
|
binding.abhaid.text = "ABHA ID: ${testDetails?.abhaId}"
|
||||||
binding.blood.text = "Blood Group: ${testDetails?.bloodGroup}"
|
binding.blood.text = "Blood Group: ${testDetails?.bloodGroup}"
|
||||||
binding.sicklecell.text = "Sickle-Cell: ${DataHolder.hemoCubeTestData?.prdClassification.toString()}"
|
binding.sicklecell.text =
|
||||||
|
"Sickle-Cell: ${DataHolder.hemoCubeTestData?.prdClassification.toString()}"
|
||||||
|
|
||||||
}
|
}
|
||||||
// Update the UI with the fetched details
|
// Update the UI with the fetched details
|
||||||
val originalDateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
val originalDateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
||||||
val originalDate: Date? = originalDateFormat.parse(SimpleDateFormat(
|
val originalDate: Date? = originalDateFormat.parse(
|
||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
SimpleDateFormat(
|
||||||
).format(Calendar.getInstance().time))
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
).format(Calendar.getInstance().time)
|
||||||
|
)
|
||||||
|
|
||||||
// Format the parsed date to "mm date, year"
|
// Format the parsed date to "mm date, year"
|
||||||
val desiredDateFormat = SimpleDateFormat("MMM dd, yyyy", Locale.getDefault())
|
val desiredDateFormat = SimpleDateFormat("MMM dd, yyyy", Locale.getDefault())
|
||||||
|
|||||||
@@ -162,11 +162,16 @@ class HemoCubeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
handleReadingFinish()
|
handleReadingFinish()
|
||||||
}
|
}
|
||||||
|
|
||||||
is Result.Error -> {
|
is Result.Error -> {
|
||||||
binding.btnSubmit.visibility = View.VISIBLE
|
binding.btnSubmit.visibility = View.VISIBLE
|
||||||
//Remove this line of code while deploying to IOCL
|
//Remove this line of code while deploying to IOCL
|
||||||
it.exception.let { message ->
|
it.exception.let { message ->
|
||||||
Toast.makeText(activity, "An error occurred: $message", Toast.LENGTH_LONG)
|
Toast.makeText(
|
||||||
|
activity,
|
||||||
|
"An error occurred: $message",
|
||||||
|
Toast.LENGTH_LONG
|
||||||
|
)
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
handleReadingFinish()
|
handleReadingFinish()
|
||||||
@@ -411,7 +416,8 @@ class HemoCubeFragment : Fragment() {
|
|||||||
(resultData.contains("#SC") || resultData.contains("#SC1")) && this.testStatusCode < TestStatus.SAMPLE_COMPLETED.code -> {
|
(resultData.contains("#SC") || resultData.contains("#SC1")) && this.testStatusCode < TestStatus.SAMPLE_COMPLETED.code -> {
|
||||||
this.testStatusCode = TestStatus.SAMPLE_COMPLETED.code
|
this.testStatusCode = TestStatus.SAMPLE_COMPLETED.code
|
||||||
hemoCubeViewModel.messages.postValue(
|
hemoCubeViewModel.messages.postValue(
|
||||||
getString(R.string.sample_completed) + "\n" + getString(R.string.gathering_data))
|
getString(R.string.sample_completed) + "\n" + getString(R.string.gathering_data)
|
||||||
|
)
|
||||||
fetchResult()
|
fetchResult()
|
||||||
currentResultData = ""
|
currentResultData = ""
|
||||||
}
|
}
|
||||||
@@ -519,7 +525,8 @@ class HemoCubeFragment : Fragment() {
|
|||||||
led1Gain1 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
led1Gain1 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led2Gain1 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
led2Gain1 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led3Gain1 = resultLines[7].split(' ')[1].trim().toDoubleOrNull()!!
|
led3Gain1 = resultLines[7].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led4Gain1 = resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
|
led4Gain1 =
|
||||||
|
resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
|
||||||
}
|
}
|
||||||
|
|
||||||
sendSecondGainCommand()
|
sendSecondGainCommand()
|
||||||
@@ -537,7 +544,8 @@ class HemoCubeFragment : Fragment() {
|
|||||||
led1Gain2 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
led1Gain2 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led2Gain2 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
led2Gain2 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led3Gain2 = resultLines[7].split(' ')[1].trim().toDoubleOrNull()!!
|
led3Gain2 = resultLines[7].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led4Gain2 = resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
|
led4Gain2 =
|
||||||
|
resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
|
||||||
}
|
}
|
||||||
|
|
||||||
sendForthGainCommand()
|
sendForthGainCommand()
|
||||||
@@ -555,7 +563,8 @@ class HemoCubeFragment : Fragment() {
|
|||||||
led1Gain4 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
led1Gain4 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led2Gain4 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
led2Gain4 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led3Gain4 = resultLines[7].split(' ')[1].trim().toDoubleOrNull()!!
|
led3Gain4 = resultLines[7].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led4Gain4 = resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
|
led4Gain4 =
|
||||||
|
resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
|
||||||
}
|
}
|
||||||
|
|
||||||
finishReading()
|
finishReading()
|
||||||
@@ -766,7 +775,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
// testState.allErrorMessages += "Error: Invalid Test. Improper buffer reading (high)" + "\n"
|
// testState.allErrorMessages += "Error: Invalid Test. Improper buffer reading (high)" + "\n"
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
// binding.errorMessage.text =
|
// binding.errorMessage.text =
|
||||||
getString(R.string.error_improper_buffer_high)
|
getString(R.string.error_improper_buffer_high)
|
||||||
// binding.errorMessage.visibility = View.VISIBLE
|
// binding.errorMessage.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -805,7 +814,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
|
|
||||||
calculatedPredictedDenovixRatio = fittedAbs3.div(fittedAbs1)
|
calculatedPredictedDenovixRatio = fittedAbs3.div(fittedAbs1)
|
||||||
|
|
||||||
val slope = (led4Average - led1Average) / (431-411)
|
val slope = (led4Average - led1Average) / (431 - 411)
|
||||||
val calculatedSlopeRatio = abs(led2Average / slope)
|
val calculatedSlopeRatio = abs(led2Average / slope)
|
||||||
val slopeClass = slopeRatioClassification(calculatedSlopeRatio)
|
val slopeClass = slopeRatioClassification(calculatedSlopeRatio)
|
||||||
|
|
||||||
@@ -875,7 +884,13 @@ class HemoCubeFragment : Fragment() {
|
|||||||
this.deviceRatioClass = deviceRatioClassification(deviceRatio)
|
this.deviceRatioClass = deviceRatioClassification(deviceRatio)
|
||||||
this.slopeRatioClass = slopeClass
|
this.slopeRatioClass = slopeClass
|
||||||
this.classificationResult = deviceRatioClass
|
this.classificationResult = deviceRatioClass
|
||||||
hemoCubeViewModel.messages.postValue("${this.classificationResult} \n Device Ratio: ${"%.3f".format(this.deviceRatio)}")
|
hemoCubeViewModel.messages.postValue(
|
||||||
|
"${this.classificationResult} \n Device Ratio: ${
|
||||||
|
"%.3f".format(
|
||||||
|
this.deviceRatio
|
||||||
|
)
|
||||||
|
}"
|
||||||
|
)
|
||||||
if (DataHolder.hemoCubeTestData?.testType == "HB")
|
if (DataHolder.hemoCubeTestData?.testType == "HB")
|
||||||
hemoCubeViewModel.messages.postValue("Hb: $calculatedHb4")
|
hemoCubeViewModel.messages.postValue("Hb: $calculatedHb4")
|
||||||
this.errorMessages = testState.allErrorMessages
|
this.errorMessages = testState.allErrorMessages
|
||||||
@@ -909,7 +924,11 @@ class HemoCubeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun findResultWithAdditionalMethods(deviceRatio: Double?, deviceRatioClass: String?, slopeRatio: Double?): String {
|
fun findResultWithAdditionalMethods(
|
||||||
|
deviceRatio: Double?,
|
||||||
|
deviceRatioClass: String?,
|
||||||
|
slopeRatio: Double?,
|
||||||
|
): String {
|
||||||
try {
|
try {
|
||||||
// hemoCubeViewModel.messages.postValue("post classification checks")
|
// hemoCubeViewModel.messages.postValue("post classification checks")
|
||||||
if (deviceRatio != null) {
|
if (deviceRatio != null) {
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ open class HemocubeActivity : AppCompatActivity() {
|
|||||||
viewModel.isServiceConnected = false
|
viewModel.isServiceConnected = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun attachBaseContext(newBase: Context?) {
|
override fun attachBaseContext(newBase: Context?) {
|
||||||
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||||
LanguageManager.setLocale(newBase, languageCode)
|
LanguageManager.setLocale(newBase, languageCode)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import `in`.sminnovations.hpostesting.R
|
|||||||
import `in`.sminnovations.hpostesting.databinding.ActivityJigBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityJigBinding
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class JigActivity: AppCompatActivity(){
|
class JigActivity : AppCompatActivity() {
|
||||||
private lateinit var binding: ActivityJigBinding
|
private lateinit var binding: ActivityJigBinding
|
||||||
val viewModel: JigViewModel by viewModels()
|
val viewModel: JigViewModel by viewModels()
|
||||||
private var myMenu: Menu? = null
|
private var myMenu: Menu? = null
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ import kotlinx.coroutines.launch
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class JigViewModel @Inject constructor(
|
class JigViewModel @Inject constructor(
|
||||||
private val hemoCubeDao: HemoCubeDao,
|
private val hemoCubeDao: HemoCubeDao,
|
||||||
private val repository: Repository,
|
private val repository: Repository,
|
||||||
context: Context
|
context: Context,
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
var isServiceConnected = false
|
var isServiceConnected = false
|
||||||
val progressBar = MutableLiveData(false)
|
val progressBar = MutableLiveData(false)
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ class TrueHemeActivity : AppCompatActivity() {
|
|||||||
viewModel.isServiceConnected = false
|
viewModel.isServiceConnected = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun attachBaseContext(newBase: Context?) {
|
override fun attachBaseContext(newBase: Context?) {
|
||||||
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||||
LanguageManager.setLocale(newBase, languageCode)
|
LanguageManager.setLocale(newBase, languageCode)
|
||||||
|
|||||||
@@ -165,11 +165,16 @@ class TrueHemeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
handleReadingFinish()
|
handleReadingFinish()
|
||||||
}
|
}
|
||||||
|
|
||||||
is Result.Error -> {
|
is Result.Error -> {
|
||||||
binding.btnSubmit.visibility = View.VISIBLE
|
binding.btnSubmit.visibility = View.VISIBLE
|
||||||
//Remove this line of code while deploying to IOCL
|
//Remove this line of code while deploying to IOCL
|
||||||
it.exception.let { message ->
|
it.exception.let { message ->
|
||||||
Toast.makeText(activity, "An error occurred: $message", Toast.LENGTH_LONG)
|
Toast.makeText(
|
||||||
|
activity,
|
||||||
|
"An error occurred: $message",
|
||||||
|
Toast.LENGTH_LONG
|
||||||
|
)
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
handleReadingFinish()
|
handleReadingFinish()
|
||||||
@@ -410,7 +415,8 @@ class TrueHemeFragment : Fragment() {
|
|||||||
(resultData.contains("#SC") || resultData.contains("#SC1")) && this.testStatusCode < TestStatus.SAMPLE_COMPLETED.code -> {
|
(resultData.contains("#SC") || resultData.contains("#SC1")) && this.testStatusCode < TestStatus.SAMPLE_COMPLETED.code -> {
|
||||||
this.testStatusCode = TestStatus.SAMPLE_COMPLETED.code
|
this.testStatusCode = TestStatus.SAMPLE_COMPLETED.code
|
||||||
hemoCubeViewModel.messages.postValue(
|
hemoCubeViewModel.messages.postValue(
|
||||||
getString(R.string.sample_completed) + "\n" + getString(R.string.gathering_data))
|
getString(R.string.sample_completed) + "\n" + getString(R.string.gathering_data)
|
||||||
|
)
|
||||||
fetchResult()
|
fetchResult()
|
||||||
currentResultData = ""
|
currentResultData = ""
|
||||||
}
|
}
|
||||||
@@ -518,7 +524,8 @@ class TrueHemeFragment : Fragment() {
|
|||||||
led1Gain1 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
led1Gain1 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led2Gain1 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
led2Gain1 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led3Gain1 = resultLines[7].split(' ')[1].trim().toDoubleOrNull()!!
|
led3Gain1 = resultLines[7].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led4Gain1 = resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
|
led4Gain1 =
|
||||||
|
resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
|
||||||
}
|
}
|
||||||
|
|
||||||
sendSecondGainCommand()
|
sendSecondGainCommand()
|
||||||
@@ -536,7 +543,8 @@ class TrueHemeFragment : Fragment() {
|
|||||||
led1Gain2 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
led1Gain2 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led2Gain2 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
led2Gain2 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led3Gain2 = resultLines[7].split(' ')[1].trim().toDoubleOrNull()!!
|
led3Gain2 = resultLines[7].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led4Gain2 = resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
|
led4Gain2 =
|
||||||
|
resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
|
||||||
}
|
}
|
||||||
|
|
||||||
sendForthGainCommand()
|
sendForthGainCommand()
|
||||||
@@ -554,7 +562,8 @@ class TrueHemeFragment : Fragment() {
|
|||||||
led1Gain4 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
led1Gain4 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led2Gain4 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
led2Gain4 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led3Gain4 = resultLines[7].split(' ')[1].trim().toDoubleOrNull()!!
|
led3Gain4 = resultLines[7].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led4Gain4 = resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
|
led4Gain4 =
|
||||||
|
resultLines[8].split(' ')[1].split('\r')[0].trim().toDoubleOrNull()!!
|
||||||
}
|
}
|
||||||
|
|
||||||
finishReading()
|
finishReading()
|
||||||
@@ -828,7 +837,8 @@ class TrueHemeFragment : Fragment() {
|
|||||||
if ((led1Average < 0.7 || led2Average < 0.7 || led3Average < 0.7 || led4Average < 0.7) && calculatedSlopeRatio > 35.0) {
|
if ((led1Average < 0.7 || led2Average < 0.7 || led3Average < 0.7 || led4Average < 0.7) && calculatedSlopeRatio > 35.0) {
|
||||||
validationError = true
|
validationError = true
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
binding.errorMessage.text = "Severely Low Hb. Repeat test with 12 ul in 2 ml Buffer"
|
binding.errorMessage.text =
|
||||||
|
"Severely Low Hb. Repeat test with 12 ul in 2 ml Buffer"
|
||||||
binding.errorMessage.visibility = View.VISIBLE
|
binding.errorMessage.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import com.example.hpostesting.data.api.PropertyProvider
|
|||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.util.Properties
|
import java.util.Properties
|
||||||
|
|
||||||
class PropertyProviderImpl (private val assetManager: AssetManager) : PropertyProvider {
|
class PropertyProviderImpl(private val assetManager: AssetManager) : PropertyProvider {
|
||||||
override fun getProperty(key: String): String {
|
override fun getProperty(key: String): String {
|
||||||
val inputStream: InputStream = assetManager.open("app.properties")
|
val inputStream: InputStream = assetManager.open("app.properties")
|
||||||
val properties = Properties()
|
val properties = Properties()
|
||||||
|
|||||||
Reference in New Issue
Block a user