Compare commits
5 Commits
dev-assura
...
dev-Issue-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ba3b98d2d | ||
|
|
8e5294f564 | ||
|
|
547cf714a4 | ||
|
|
fd5fb6db22 | ||
|
|
9b2b64f248 |
@@ -14,13 +14,13 @@ android {
|
|||||||
compileSdk 34
|
compileSdk 34
|
||||||
namespace 'in.sminnovations.hpostesting'
|
namespace 'in.sminnovations.hpostesting'
|
||||||
|
|
||||||
// dev -> development, quality -> qc, uat -> User Acceptance Testing, preprod -> preproduction, prod -> production, iocl -> iocl-iisc production
|
// dev - development, quality - qc, uat - User Acceptance Test, preprod - preproduction, prod - production
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "in.sminnovations.hpostesting.dev"
|
applicationId "in.sminnovations.hpostesting.dev"
|
||||||
minSdk 21
|
minSdk 21
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 114
|
versionCode 111
|
||||||
versionName "2.1.114"
|
versionName "2.1.111"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,10 +48,6 @@
|
|||||||
android:name="com.example.hpostesting.presentation.autodac.AutoDacActivity"
|
android:name="com.example.hpostesting.presentation.autodac.AutoDacActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:theme="@style/Theme.HPOS.NoActionBar" />
|
android:theme="@style/Theme.HPOS.NoActionBar" />
|
||||||
<activity
|
|
||||||
android:name="com.example.hpostesting.presentation.jig.JigActivity"
|
|
||||||
android:exported="false"
|
|
||||||
android:theme="@style/Theme.HPOS.NoActionBar" />
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.deviceprovision.DeviceProvisionActivity"
|
android:name="com.example.hpostesting.presentation.deviceprovision.DeviceProvisionActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
|
|||||||
@@ -61,9 +61,6 @@ object Constants {
|
|||||||
|
|
||||||
const val BLANK_EVERY_TEST = false
|
const val BLANK_EVERY_TEST = false
|
||||||
|
|
||||||
// jig
|
|
||||||
const val NAVIGATE_TO_TEST_JIG_DIRECTLY = false
|
|
||||||
|
|
||||||
val STATICID = listOf(
|
val STATICID = listOf(
|
||||||
"FACTORY",
|
"FACTORY",
|
||||||
"ADMIN",
|
"ADMIN",
|
||||||
@@ -176,7 +173,6 @@ object Constants {
|
|||||||
|
|
||||||
const val KIT_NUMBER = "KitNumber"
|
const val KIT_NUMBER = "KitNumber"
|
||||||
const val KIT_COUNT = "KitCount"
|
const val KIT_COUNT = "KitCount"
|
||||||
const val KIT_CAPACITY = Int.MAX_VALUE // Enforceable
|
|
||||||
const val BUFFER_VALUE_1 = "BufferValue1"
|
const val BUFFER_VALUE_1 = "BufferValue1"
|
||||||
const val BUFFER_VALUE_2 = "BufferValue2"
|
const val BUFFER_VALUE_2 = "BufferValue2"
|
||||||
const val BUFFER_VALUE_3 = "BufferValue3"
|
const val BUFFER_VALUE_3 = "BufferValue3"
|
||||||
@@ -1663,6 +1659,7 @@ object Constants {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
val COEFFICIENTS: Map<String, List<List<Double>>> = mapOf(
|
val COEFFICIENTS: Map<String, List<List<Double>>> = mapOf(
|
||||||
"HC-V1-005" to listOf(
|
"HC-V1-005" to listOf(
|
||||||
listOf(1.5,0.0),
|
listOf(1.5,0.0),
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
package com.example.hpostesting.data.model.jig
|
|
||||||
|
|
||||||
data class JigData (
|
|
||||||
var deviceId: String = "",
|
|
||||||
var appVersion: String? = "",
|
|
||||||
var deviceType: String = "JIG",
|
|
||||||
var scanData: String = "",
|
|
||||||
var createdAt: String = ""
|
|
||||||
)
|
|
||||||
@@ -4,20 +4,20 @@ import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
|||||||
|
|
||||||
data class MolbioV2ResultData(
|
data class MolbioV2ResultData(
|
||||||
val age: Int? = 0,
|
val age: Int? = 0,
|
||||||
val analysisDate: String? = "",
|
val analysisDate: String? = "2024-02-08 16:33:56",
|
||||||
val analysisStatus: String? = "",
|
val analysisStatus: String? = "",
|
||||||
val analysisType: String? = "",
|
val analysisType: String? = "",
|
||||||
val analysisTypeMethod: String? = "",
|
val analysisTypeMethod: String? = "",
|
||||||
val bloodGroup: String? = "",
|
val bloodGroup: String? = "",
|
||||||
val coefficients: List<Int>? = listOf(),
|
val coefficients: List<Int>? = listOf(),
|
||||||
val collectionLocation: List<Any>? = listOf(),
|
val collectionLocation: List<Any>? = listOf(),
|
||||||
val collectionTime: String? = "",
|
val collectionTime: String? = "2024-02-08 16:33:56",
|
||||||
val collector: String? = "",
|
val collector: String? = "",
|
||||||
val createdAt: String? = "",
|
val createdAt: String? = "",
|
||||||
val createdBy: Int? = 0,
|
val createdBy: Int? = 0,
|
||||||
val curveFitting: String? = "",
|
val curveFitting: String? = "",
|
||||||
val deviceId: Int? = 0,
|
val deviceId: Int? = 0,
|
||||||
val expiryTime: String? = "",
|
val expiryTime: String? = "2024-02-08 16:33:56",
|
||||||
val gender: String? = "",
|
val gender: String? = "",
|
||||||
val id: Int? = 0,
|
val id: Int? = 0,
|
||||||
val interpretation: String? = "",
|
val interpretation: String? = "",
|
||||||
@@ -32,7 +32,7 @@ data class MolbioV2ResultData(
|
|||||||
val testId: String? = "",
|
val testId: String? = "",
|
||||||
val testResult: String? = "",
|
val testResult: String? = "",
|
||||||
val testStatus: String? = "",
|
val testStatus: String? = "",
|
||||||
val testTime: String? = "",
|
val testTime: String? = "2024-02-08 16:33:56",
|
||||||
val testType: String? = "",
|
val testType: String? = "",
|
||||||
val thresholds: String? = "",
|
val thresholds: String? = "",
|
||||||
val underMedication: Boolean? = false,
|
val underMedication: Boolean? = false,
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import com.example.hpostesting.data.model.Response
|
|||||||
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
||||||
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionResponse
|
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionResponse
|
||||||
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
||||||
import com.example.hpostesting.data.model.jig.JigData
|
|
||||||
import com.example.hpostesting.data.model.log.UploadLogsResponse
|
import com.example.hpostesting.data.model.log.UploadLogsResponse
|
||||||
import com.example.hpostesting.data.model.login.LoginRequest
|
import com.example.hpostesting.data.model.login.LoginRequest
|
||||||
import com.example.hpostesting.data.model.login.LoginResponse
|
import com.example.hpostesting.data.model.login.LoginResponse
|
||||||
@@ -138,16 +137,6 @@ class DatabaseRepository @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun addTestJigData(data: JigData?): Response<String> {
|
|
||||||
return try {
|
|
||||||
db.collection("jigs").add(data!!).await()
|
|
||||||
Response.Success(data.deviceId)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Firebase.crashlytics.recordException(e)
|
|
||||||
Response.Error(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override suspend fun uploadFileToStorage(
|
override suspend fun uploadFileToStorage(
|
||||||
patientID: String, filePath: String
|
patientID: String, filePath: String
|
||||||
): Response<Boolean> {
|
): Response<Boolean> {
|
||||||
@@ -227,6 +216,9 @@ class DatabaseRepository @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
override suspend fun uploadDeviceId(data: DeviceData): Response<String>? {
|
override suspend fun uploadDeviceId(data: DeviceData): Response<String>? {
|
||||||
return try {
|
return try {
|
||||||
db.collection("devices").add(data!!).await()
|
db.collection("devices").add(data!!).await()
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import com.example.hpostesting.data.model.Response
|
|||||||
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
||||||
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionResponse
|
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionResponse
|
||||||
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
||||||
import com.example.hpostesting.data.model.jig.JigData
|
|
||||||
import com.example.hpostesting.data.model.log.UploadLogsResponse
|
import com.example.hpostesting.data.model.log.UploadLogsResponse
|
||||||
import com.example.hpostesting.data.model.login.LoginRequest
|
import com.example.hpostesting.data.model.login.LoginRequest
|
||||||
import com.example.hpostesting.data.model.login.LoginResponse
|
import com.example.hpostesting.data.model.login.LoginResponse
|
||||||
@@ -30,8 +29,6 @@ interface Repository {
|
|||||||
|
|
||||||
suspend fun addDiagnostics(data: DiagnosticsData?): Response<String>
|
suspend fun addDiagnostics(data: DiagnosticsData?): Response<String>
|
||||||
|
|
||||||
suspend fun addTestJigData(data: JigData?): Response<String>
|
|
||||||
|
|
||||||
suspend fun uploadFileToStorage(patientID: String, filePath: String): Response<Boolean>
|
suspend fun uploadFileToStorage(patientID: String, filePath: String): Response<Boolean>
|
||||||
|
|
||||||
suspend fun getDeviceDataById(deviceId: String): DeviceData?
|
suspend fun getDeviceDataById(deviceId: String): DeviceData?
|
||||||
|
|||||||
@@ -227,8 +227,9 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
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,"Scanner Is not available In this device", Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun pullTrigger() {
|
private fun pullTrigger() {
|
||||||
@@ -270,7 +271,7 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
return sharedPreference.getString(Constants.KIT_NUMBER, "")
|
return sharedPreference.getString(Constants.KIT_NUMBER, "")
|
||||||
?.isNotBlank() == true && sharedPreference.getInt(
|
?.isNotBlank() == true && sharedPreference.getInt(
|
||||||
Constants.KIT_COUNT, 0
|
Constants.KIT_COUNT, 0
|
||||||
) > 0 && sharedPreference.getInt(Constants.KIT_COUNT, 0) < Constants.KIT_CAPACITY
|
) > 0 && sharedPreference.getInt(Constants.KIT_COUNT, 0) < 35
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isSerialValid(s: String): Boolean {
|
private fun isSerialValid(s: String): Boolean {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import android.widget.AdapterView
|
|||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import android.widget.Spinner
|
import android.widget.Spinner
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.core.view.isVisible
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
@@ -103,6 +102,9 @@ class AssuranceControlsFragment: Fragment() {
|
|||||||
id: Long
|
id: Long
|
||||||
) {
|
) {
|
||||||
val selectedValue: String = volumeOptions[position]
|
val selectedValue: String = volumeOptions[position]
|
||||||
|
if (!selectedValue.equals("Select volume")) {
|
||||||
|
DataHolder.hemoCubeTestData!!.volume = selectedValue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||||
@@ -123,19 +125,13 @@ class AssuranceControlsFragment: Fragment() {
|
|||||||
volumeSpinner.setSelection(volumePosition)
|
volumeSpinner.setSelection(volumePosition)
|
||||||
|
|
||||||
binding.btnSubmit.setOnClickListener {
|
binding.btnSubmit.setOnClickListener {
|
||||||
val selectedSolution = binding.spinnerSolutions.selectedItem.toString()
|
val selectedSolution = DataHolder.hemoCubeTestData!!.solution
|
||||||
val selectedConcentration = binding.spinnerConcentration.selectedItem.toString()
|
val selectedVolume = DataHolder.hemoCubeTestData!!.volume
|
||||||
|
if (selectedSolution == "Select solution" || selectedVolume == "Select volume") {
|
||||||
// Check if any of the selections are default values
|
Toast.makeText(requireContext(), "Please select both solution and volume", Toast.LENGTH_SHORT).show()
|
||||||
if (selectedSolution == "Select solution") {
|
return@setOnClickListener
|
||||||
Toast.makeText(requireContext(), "Please select a solution", Toast.LENGTH_LONG).show()
|
|
||||||
return@setOnClickListener // Prevent further execution
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedConcentration == "Select concentration") {
|
|
||||||
Toast.makeText(requireContext(), "Please select a concentration", Toast.LENGTH_LONG).show()
|
|
||||||
return@setOnClickListener // Prevent further execution
|
|
||||||
}
|
|
||||||
DataHolder.hemoCubeTestData!!.quickCapture = true
|
DataHolder.hemoCubeTestData!!.quickCapture = true
|
||||||
val currentUnixTime = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
val currentUnixTime = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
Instant.now().epochSecond
|
Instant.now().epochSecond
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import com.example.hpostesting.data.constant.Constants
|
|||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.NatsManager
|
import com.example.hpostesting.presentation.NatsManager
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
import com.example.hpostesting.presentation.jig.JigActivity
|
|
||||||
import com.google.android.material.navigation.NavigationView
|
import com.google.android.material.navigation.NavigationView
|
||||||
import com.google.firebase.appdistribution.FirebaseAppDistribution
|
import com.google.firebase.appdistribution.FirebaseAppDistribution
|
||||||
import com.google.firebase.appdistribution.FirebaseAppDistributionException
|
import com.google.firebase.appdistribution.FirebaseAppDistributionException
|
||||||
@@ -94,11 +93,11 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
// val apkUrl = "https://dl.dropboxusercontent.com/s/fi/1c3nn7t0co431hicl3hrt/app-debug.apk?rlkey=e4uf13ty1dpcked614vy1aaqp&dl=0"
|
// val apkUrl = "https://dl.dropboxusercontent.com/s/fi/1c3nn7t0co431hicl3hrt/app-debug.apk?rlkey=e4uf13ty1dpcked614vy1aaqp&dl=0"
|
||||||
initiateUpdate(apkUrl.toString())
|
initiateUpdate(apkUrl.toString())
|
||||||
Log.d("ApI", "APK URL: $apkUrl")
|
Log.d("ApI", "APK URL: $apkUrl")
|
||||||
// Toast.makeText(
|
Toast.makeText(
|
||||||
// this,
|
this,
|
||||||
// "APK UPLOAD ${result.data}",
|
"APK UPLOAD ${result.data}",
|
||||||
// Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
// ).show()
|
).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
is Result.Error -> {
|
is Result.Error -> {
|
||||||
@@ -128,11 +127,6 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
)
|
)
|
||||||
setupActionBarWithNavController(navController, appBarConfiguration)
|
setupActionBarWithNavController(navController, appBarConfiguration)
|
||||||
navView.setupWithNavController(navController)
|
navView.setupWithNavController(navController)
|
||||||
|
|
||||||
if (Constants.NAVIGATE_TO_TEST_JIG_DIRECTLY) {
|
|
||||||
startActivity(Intent(this, JigActivity::class.java))
|
|
||||||
finish()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ class HomeFragment : Fragment() {
|
|||||||
if (isConnected) {
|
if (isConnected) {
|
||||||
binding.internetAvailableCL.visibility = View.VISIBLE
|
binding.internetAvailableCL.visibility = View.VISIBLE
|
||||||
binding.internetNotAvailableCL.visibility = View.GONE
|
binding.internetNotAvailableCL.visibility = View.GONE
|
||||||
|
binding.pendingTest.visibility = View.VISIBLE
|
||||||
loadUserData()
|
loadUserData()
|
||||||
setSearch()
|
setSearch()
|
||||||
checkForLocalDBData()
|
checkForLocalDBData()
|
||||||
@@ -149,21 +150,20 @@ class HomeFragment : Fragment() {
|
|||||||
MolbioV2Result(
|
MolbioV2Result(
|
||||||
rawData = userData,
|
rawData = userData,
|
||||||
analysisId = userData._id,
|
analysisId = userData._id,
|
||||||
analysisDate = "2024-02-08 16:33:56",
|
analysisDate = "2024-02-08 16:33:56",//userData.testTime,
|
||||||
analysisStatus = userData.classificationResult,
|
analysisStatus = userData.classificationResult,
|
||||||
thresholds = Constants.BUFFER_INTENSITY_THRESHOLDS[userData.deviceId].toString(),
|
thresholds = Constants.BUFFER_INTENSITY_THRESHOLDS[userData.deviceId].toString(),
|
||||||
interpretation = userData.classificationResult,
|
interpretation = userData.classificationResult,
|
||||||
testId = userData._id,
|
testId = userData._id,
|
||||||
testTime = "2024-02-08 16:33:56",//userData.testTime,
|
testTime = "2024-02-08 16:33:56",//userData.testTime,
|
||||||
collectionTime = "2024-02-08 16:33:56",//userData.testTime,
|
collectionTime = "2024-02-08 16:33:56",//userData.testTime,
|
||||||
expiryTime = "2024-02-08 16:33:56"//userData.testTime,
|
expiryTime = "2024-02-08 16:33:56"//userData.testTime,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
|
||||||
if (!userData.molbioFlag && isTokenAvailable) {
|
|
||||||
userData.molbioFlag = true
|
userData.molbioFlag = true
|
||||||
hemoCubeViewModel.uploadResult(resultList)
|
hemoCubeViewModel.uploadResult(resultList)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!userData.localFlag) {
|
if (!userData.localFlag) {
|
||||||
userData.localFlag = true
|
userData.localFlag = true
|
||||||
hemoCubeViewModel.bulkAddResultTestToDb(userData)
|
hemoCubeViewModel.bulkAddResultTestToDb(userData)
|
||||||
@@ -173,9 +173,9 @@ class HomeFragment : Fragment() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
binding.internetAvailableCL.visibility = View.GONE
|
binding.internetAvailableCL.visibility = View.GONE
|
||||||
|
binding.pendingTest.visibility = View.GONE
|
||||||
binding.internetNotAvailableCL.visibility = View.VISIBLE
|
binding.internetNotAvailableCL.visibility = View.VISIBLE
|
||||||
setUserId()
|
setUserId()
|
||||||
}
|
}
|
||||||
@@ -195,14 +195,13 @@ class HomeFragment : Fragment() {
|
|||||||
logoutUser(requireContext())
|
logoutUser(requireContext())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
binding.uploadData.setOnClickListener {
|
binding.uploadData.setOnClickListener {
|
||||||
showUploadDialog(requireContext())
|
showUploadDialog(requireContext())
|
||||||
}
|
}
|
||||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
||||||
|
|
||||||
val btnSaveLocalVisibility =
|
val btnSaveLocalVisibility =
|
||||||
if (userData.any { it.testStatus == true }) View.VISIBLE else View.GONE
|
if (userData.any { it.testStatus == true }) View.GONE else View.GONE
|
||||||
|
|
||||||
binding.downloadCSV.visibility = btnSaveLocalVisibility
|
binding.downloadCSV.visibility = btnSaveLocalVisibility
|
||||||
|
|
||||||
@@ -320,11 +319,11 @@ class HomeFragment : Fragment() {
|
|||||||
hemoCubeViewModel.uploadLogs.observe(viewLifecycleOwner) { response ->
|
hemoCubeViewModel.uploadLogs.observe(viewLifecycleOwner) { response ->
|
||||||
when (response) {
|
when (response) {
|
||||||
is Result.Success -> {
|
is Result.Success -> {
|
||||||
// Toast.makeText(
|
Toast.makeText(
|
||||||
// requireContext(),
|
requireContext(),
|
||||||
// "Log uploaded ${response.data.data?.filename}",
|
"Log uploaded ${response.data.data?.filename}",
|
||||||
// Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
// ).show()
|
).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
is Result.Error -> {
|
is Result.Error -> {
|
||||||
@@ -749,7 +748,7 @@ class HomeFragment : Fragment() {
|
|||||||
private fun checkUnprocessedCSVData() {
|
private fun checkUnprocessedCSVData() {
|
||||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
val downloadDataVisibility =
|
val downloadDataVisibility =
|
||||||
if (userDataList.any { !it.isCSVCreated && it.testStatus == true }) View.VISIBLE else View.GONE
|
if (userDataList.any { !it.isCSVCreated && it.testStatus == true }) View.GONE else View.GONE
|
||||||
binding.downloadCSV.visibility = downloadDataVisibility
|
binding.downloadCSV.visibility = downloadDataVisibility
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -804,39 +803,6 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
|
||||||
val resultList = MolbioV2ResultRequest(mutableListOf(MolbioV2Result()))
|
|
||||||
userDataList.forEach { userData ->
|
|
||||||
if (!userData.molbioFlag && isTokenAvailable) {
|
|
||||||
resultList.results?.add(
|
|
||||||
MolbioV2Result(
|
|
||||||
rawData = userData,
|
|
||||||
analysisId = userData._id,
|
|
||||||
analysisDate = "2024-02-08 16:33:56", //userData.reportUploadTime,
|
|
||||||
analysisStatus = userData.classificationResult,
|
|
||||||
thresholds = Constants.BUFFER_INTENSITY_THRESHOLDS[userData.deviceId].toString(),
|
|
||||||
interpretation = userData.classificationResult,
|
|
||||||
testId = userData._id,
|
|
||||||
testTime = "2024-02-08 16:33:56",//userData.testTime,
|
|
||||||
collectionTime = "2024-02-08 16:33:56",//userData.testTime,
|
|
||||||
expiryTime = "2024-02-08 16:33:56",//userData.testTime,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!userData.localFlag){
|
|
||||||
userData.localFlag = true
|
|
||||||
hemoCubeViewModel.bulkAddResultTestToDb(userData)
|
|
||||||
}
|
|
||||||
if (!userData.molbioFlag && isTokenAvailable) {
|
|
||||||
userData.molbioFlag = true
|
|
||||||
hemoCubeViewModel.uploadResult(resultList)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dialog.dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
hemoCubeViewModel.allKitTestData.observe(viewLifecycleOwner) { kitDataList ->
|
hemoCubeViewModel.allKitTestData.observe(viewLifecycleOwner) { kitDataList ->
|
||||||
kitDataList.forEach { userData ->
|
kitDataList.forEach { userData ->
|
||||||
if (!userData.localFlag) {
|
if (!userData.localFlag) {
|
||||||
@@ -846,6 +812,37 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
|
val resultList = MolbioV2ResultRequest(mutableListOf(MolbioV2Result()))
|
||||||
|
userDataList.forEach { userData ->
|
||||||
|
if (!userData.molbioFlag && isTokenAvailable) {
|
||||||
|
resultList.results?.add(
|
||||||
|
MolbioV2Result(
|
||||||
|
rawData = userData,
|
||||||
|
analysisId = userData._id,
|
||||||
|
analysisDate = "2024-02-08 16:33:56",//userData.testTime,
|
||||||
|
analysisStatus = userData.classificationResult,
|
||||||
|
thresholds = Constants.BUFFER_INTENSITY_THRESHOLDS[userData.deviceId].toString(),
|
||||||
|
interpretation = userData.classificationResult,
|
||||||
|
testId = userData._id,
|
||||||
|
testTime = "2024-02-08 16:33:56",//userData.testTime,
|
||||||
|
collectionTime = "2024-02-08 16:33:56",//userData.testTime,
|
||||||
|
expiryTime = "2024-02-08 16:33:56"//userData.testTime,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
userData.molbioFlag = true
|
||||||
|
hemoCubeViewModel.uploadResult(resultList)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!userData.localFlag) {
|
||||||
|
userData.localFlag = true
|
||||||
|
hemoCubeViewModel.bulkAddResultTestToDb(userData)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
dialog.dismiss()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private fun downloadLocalDBData(dialog: DialogInterface) {
|
// private fun downloadLocalDBData(dialog: DialogInterface) {
|
||||||
|
|||||||
@@ -1,183 +0,0 @@
|
|||||||
package com.example.hpostesting.presentation.jig
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.app.PendingIntent
|
|
||||||
import android.content.BroadcastReceiver
|
|
||||||
import android.content.ComponentName
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.content.IntentFilter
|
|
||||||
import android.content.ServiceConnection
|
|
||||||
import android.content.pm.ActivityInfo
|
|
||||||
import android.hardware.usb.UsbDevice
|
|
||||||
import android.hardware.usb.UsbDeviceConnection
|
|
||||||
import android.hardware.usb.UsbManager
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.os.IBinder
|
|
||||||
import android.util.Log
|
|
||||||
import android.view.Menu
|
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.activity.viewModels
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import androidx.core.view.get
|
|
||||||
import com.example.hpostesting.data.DataHolder
|
|
||||||
import com.example.hpostesting.data.constant.Constants
|
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
|
||||||
import com.example.hpostesting.presentation.testRight.UsbService
|
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
|
||||||
import `in`.sminnovations.hpostesting.R
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityJigBinding
|
|
||||||
|
|
||||||
@AndroidEntryPoint
|
|
||||||
class JigActivity: AppCompatActivity(){
|
|
||||||
private lateinit var binding: ActivityJigBinding
|
|
||||||
val viewModel: JigViewModel by viewModels()
|
|
||||||
private var myMenu: Menu? = null
|
|
||||||
|
|
||||||
private lateinit var mDriver: UsbSerialDriver
|
|
||||||
private var mConnection: UsbDeviceConnection? = null
|
|
||||||
lateinit var mService: UsbService
|
|
||||||
|
|
||||||
private val TAG = "JIG"
|
|
||||||
|
|
||||||
private val broadcastReceiver = object : BroadcastReceiver() {
|
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
|
||||||
|
|
||||||
synchronized(this) {
|
|
||||||
val device: UsbDevice? = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE)
|
|
||||||
|
|
||||||
if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
|
|
||||||
device?.apply {
|
|
||||||
connectUsb(true)
|
|
||||||
DataHolder.usbConnected.postValue(true)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
onErrorReported("permission denied for device")
|
|
||||||
DataHolder.usbConnected.postValue(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val connection = object : ServiceConnection {
|
|
||||||
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
|
||||||
val binder = service as UsbService.UsbServiceBinder
|
|
||||||
mService = binder.getService()
|
|
||||||
viewModel.isServiceConnected = true
|
|
||||||
mConnection.let { mService.connect(mDriver, mConnection!!) }
|
|
||||||
moveToNext()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onServiceDisconnected(arg0: ComponentName) {
|
|
||||||
viewModel.isServiceConnected = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun attachBaseContext(newBase: Context?) {
|
|
||||||
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
|
||||||
LanguageManager.setLocale(newBase, languageCode)
|
|
||||||
super.attachBaseContext(newBase)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
binding = ActivityJigBinding.inflate(layoutInflater)
|
|
||||||
setContentView(binding.root)
|
|
||||||
// setSupportActionBar(binding.myToolbar)
|
|
||||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
|
||||||
// setupListener()
|
|
||||||
// connectUsb(false)
|
|
||||||
|
|
||||||
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE)
|
|
||||||
|
|
||||||
moveToNext()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupListener() {
|
|
||||||
DataHolder.usbConnected.observe(this) {
|
|
||||||
Log.d("USB OBSERVE", "HemoCube called -> $it")
|
|
||||||
if (it) {
|
|
||||||
myMenu?.get(0)?.icon =
|
|
||||||
ContextCompat.getDrawable(this, R.drawable.ic_baseline_usb_24)
|
|
||||||
} else {
|
|
||||||
myMenu?.get(0)?.icon =
|
|
||||||
ContextCompat.getDrawable(this, R.drawable.ic_baseline_usb_off_24)
|
|
||||||
Toast.makeText(this, "Device is Disconnected", Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
open fun connectUsb(permissionGranted: Boolean) {
|
|
||||||
Log.d(TAG, "connectUsb() called, permission variable = $permissionGranted")
|
|
||||||
val manager = getSystemService(Context.USB_SERVICE) as UsbManager
|
|
||||||
val availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(manager)
|
|
||||||
|
|
||||||
if (availableDrivers.isEmpty()) {
|
|
||||||
onErrorReported("No Device is Connected")
|
|
||||||
} else {
|
|
||||||
mDriver = availableDrivers[0]
|
|
||||||
mConnection = manager.openDevice(mDriver.device)
|
|
||||||
|
|
||||||
if (mConnection == null) {
|
|
||||||
requestUserPermission(manager, mDriver.device)
|
|
||||||
} else {
|
|
||||||
setupService()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun onErrorReported(msg: String) {
|
|
||||||
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
|
|
||||||
if (!isFinishing) onBackPressed()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun moveToNext() {
|
|
||||||
if (supportFragmentManager.isDestroyed) return
|
|
||||||
|
|
||||||
supportFragmentManager.beginTransaction().replace(binding.fgJig.id, JigFragment())
|
|
||||||
.commit()
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("MutableImplicitPendingIntent")
|
|
||||||
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
|
||||||
val mPendingIntent: PendingIntent
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
|
||||||
mPendingIntent = PendingIntent.getBroadcast(
|
|
||||||
this, 0, Intent(Constants.HEMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
mPendingIntent = PendingIntent.getBroadcast(
|
|
||||||
this,
|
|
||||||
0,
|
|
||||||
Intent(Constants.HEMOCUBE_USB_PERMISSION),
|
|
||||||
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
val filter = IntentFilter(Constants.HEMOCUBE_USB_PERMISSION)
|
|
||||||
registerReceiver(broadcastReceiver, filter)
|
|
||||||
manager.requestPermission(device, mPendingIntent)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setupService() {
|
|
||||||
val intent = Intent(this, UsbService::class.java)
|
|
||||||
bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
|
||||||
menuInflater.inflate(R.menu.my_menu, menu)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDestroy() {
|
|
||||||
super.onDestroy()
|
|
||||||
if (viewModel.isServiceConnected) {
|
|
||||||
mService.disconnect()
|
|
||||||
unbindService(connection)
|
|
||||||
viewModel.isServiceConnected = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,241 +0,0 @@
|
|||||||
package com.example.hpostesting.presentation.jig
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.SharedPreferences
|
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.text.Editable
|
|
||||||
import android.util.Log
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.EditText
|
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import androidx.fragment.app.activityViewModels
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
|
||||||
import com.example.hpostesting.data.constant.Constants
|
|
||||||
import com.example.hpostesting.data.model.jig.JigData
|
|
||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
|
||||||
import com.journeyapps.barcodescanner.ScanContract
|
|
||||||
import com.journeyapps.barcodescanner.ScanIntentResult
|
|
||||||
import com.zebra.barcode.sdk.sms.ConfigurationUpdateEvent
|
|
||||||
import com.zebra.scannercontrol.DCSSDKDefs
|
|
||||||
import com.zebra.scannercontrol.DCSScannerInfo
|
|
||||||
import com.zebra.scannercontrol.FirmwareUpdateEvent
|
|
||||||
import com.zebra.scannercontrol.IDcsSdkApiDelegate
|
|
||||||
import com.zebra.scannercontrol.SDKHandler
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentJigBinding
|
|
||||||
import java.text.SimpleDateFormat
|
|
||||||
import java.util.Calendar
|
|
||||||
import java.util.Locale
|
|
||||||
|
|
||||||
class JigFragment : Fragment(), IDcsSdkApiDelegate {
|
|
||||||
private lateinit var binding: FragmentJigBinding
|
|
||||||
private val jigViewModel: JigViewModel by activityViewModels()
|
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
|
||||||
private var currentDeviceData: DeviceData? = null
|
|
||||||
private var resultData: String = ""
|
|
||||||
private val messages = MutableLiveData<String>()
|
|
||||||
private var startListening = MutableLiveData(false)
|
|
||||||
|
|
||||||
override fun onCreateView(
|
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
|
||||||
): View {
|
|
||||||
binding = FragmentJigBinding.inflate(inflater, container, false)
|
|
||||||
sharedPreferences =
|
|
||||||
requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
|
||||||
return binding.root
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
initScanner()
|
|
||||||
initViews()
|
|
||||||
observeViewModel()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun initScanner() {
|
|
||||||
//Setting up the SDK handler
|
|
||||||
sdkHandler = SDKHandler(requireContext())
|
|
||||||
//Registers a particular object which conforms to IDcsSdkApiDelegate interface as a receiver of SDK notifications.
|
|
||||||
sdkHandler!!.dcssdkSetDelegate(this)
|
|
||||||
//this command is telling the sdk that we're going to be connecting to the scanner via USB
|
|
||||||
sdkHandler!!.dcssdkSetOperationalMode(DCSSDKDefs.DCSSDK_MODE.DCSSDK_OPMODE_SNAPI)
|
|
||||||
|
|
||||||
//deciding what kind of notifications we want to receive. Explained more in the function
|
|
||||||
//first we use bitmapping to set these values into the notifications_mask.
|
|
||||||
var notifications_mask = 0
|
|
||||||
// We would like to subscribe to all barcode events
|
|
||||||
notifications_mask =
|
|
||||||
notifications_mask or DCSSDKDefs.DCSSDK_EVENT.DCSSDK_EVENT_BARCODE.value
|
|
||||||
sdkHandler!!.dcssdkSubsribeForEvents(notifications_mask)
|
|
||||||
mScannerInfoList.addAll(sdkHandler!!.dcssdkGetAvailableScannersList())
|
|
||||||
Log.e("scannersize", sdkHandler!!.dcssdkGetAvailableScannersList().size.toString())
|
|
||||||
if (mScannerInfoList.isNotEmpty()) {
|
|
||||||
sdkHandler!!.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
|
|
||||||
} else {
|
|
||||||
Toast.makeText(requireContext(), "Scanner Error", Toast.LENGTH_LONG).show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
|
||||||
private fun initViews() {
|
|
||||||
binding.btnScanNow.setOnClickListener {
|
|
||||||
pullTrigger()
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.btnRefresh.setOnClickListener {
|
|
||||||
activity?.recreate()
|
|
||||||
initScanner()
|
|
||||||
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
binding.tvScanText.text = ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
binding.tvAppVersion.text =
|
|
||||||
getAppVersion(requireContext()) + " [ " + getAppEnvironment(requireContext()) + " ]"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun observeViewModel() {
|
|
||||||
|
|
||||||
jigViewModel.deviceData.observe(viewLifecycleOwner) {
|
|
||||||
currentDeviceData = it
|
|
||||||
}
|
|
||||||
|
|
||||||
messages.observe(viewLifecycleOwner) {
|
|
||||||
binding.tvScanText.text = it
|
|
||||||
}
|
|
||||||
|
|
||||||
jigViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
|
||||||
if (result == "Success") {
|
|
||||||
showToast("Data uploaded successfully")
|
|
||||||
}
|
|
||||||
if (result == "Local") {
|
|
||||||
showToast("Data uploading failed, note it down manually")
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.progressBar.visibility = View.GONE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getAppVersion(context: Context): String {
|
|
||||||
return try {
|
|
||||||
val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
|
|
||||||
pInfo.versionName
|
|
||||||
} catch (e: PackageManager.NameNotFoundException) {
|
|
||||||
"N/A"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getAppEnvironment(context: Context): String {
|
|
||||||
return try {
|
|
||||||
val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
|
|
||||||
pInfo.packageName.substringAfterLast('.')
|
|
||||||
} catch (e: PackageManager.NameNotFoundException) {
|
|
||||||
"N/A"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun showToast(message: String) {
|
|
||||||
Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
var sdkHandler: SDKHandler? = null
|
|
||||||
var editBarcode: EditText? = null
|
|
||||||
var mScannerInfoList = ArrayList<DCSScannerInfo>()
|
|
||||||
|
|
||||||
private val barcodeLauncher = registerForActivityResult(
|
|
||||||
ScanContract()
|
|
||||||
) { result: ScanIntentResult ->
|
|
||||||
if (result.contents.isNullOrEmpty()) {
|
|
||||||
// Toast.makeText(this, R.string.cancelled_unable_scan, Toast.LENGTH_LONG).show()
|
|
||||||
} else {
|
|
||||||
// Log.d(TAG, result.contents)
|
|
||||||
processScannedData(result.contents)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun processScannedData(contents: String) {
|
|
||||||
binding.tvScanText.setText(contents)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun pullTrigger() {
|
|
||||||
// Check if the list is not empty before accessing its elements
|
|
||||||
if (mScannerInfoList.isNotEmpty()) {
|
|
||||||
// Only proceed if the scanner is not active
|
|
||||||
if (!mScannerInfoList[0].isActive) {
|
|
||||||
sdkHandler?.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
|
|
||||||
}
|
|
||||||
val inXML = "<inArgs><scannerID> 1 </scannerID></inArgs>"
|
|
||||||
val outXML = StringBuilder()
|
|
||||||
val result: DCSSDKDefs.DCSSDK_RESULT =
|
|
||||||
sdkHandler!!.dcssdkExecuteCommandOpCodeInXMLForScanner(
|
|
||||||
DCSSDKDefs.DCSSDK_COMMAND_OPCODE.DCSSDK_DEVICE_PULL_TRIGGER,
|
|
||||||
inXML,
|
|
||||||
outXML,
|
|
||||||
mScannerInfoList[0].scannerID // Ensure you're using the correct scanner ID
|
|
||||||
)
|
|
||||||
if (result == DCSSDKDefs.DCSSDK_RESULT.DCSSDK_RESULT_SUCCESS) {
|
|
||||||
Log.d("Scanning", "Success")
|
|
||||||
} else if (result == DCSSDKDefs.DCSSDK_RESULT.DCSSDK_RESULT_FAILURE) {
|
|
||||||
Log.d("Scanning", "Failed")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Handle the case where the list is empty, perhaps notify the user or log an error
|
|
||||||
Log.e("ScannerError", "No scanners are connected or available.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun dcssdkEventBarcode(barcodeData: ByteArray?, barcodeType: Int, fromScannerID: Int) {
|
|
||||||
val result = String(barcodeData!!)
|
|
||||||
Log.d("BARCODE", result)
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
val editableResult: Editable = Editable.Factory.getInstance().newEditable(result)
|
|
||||||
binding.tvScanText.text = result
|
|
||||||
|
|
||||||
jigViewModel.addScanDataToDb(
|
|
||||||
JigData(
|
|
||||||
deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString(),
|
|
||||||
scanData = result,
|
|
||||||
createdAt = SimpleDateFormat(
|
|
||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
|
||||||
).format(Calendar.getInstance().time)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun dcssdkEventScannerAppeared(dcsScannerInfo: DCSScannerInfo?) {}
|
|
||||||
|
|
||||||
override fun dcssdkEventScannerDisappeared(i: Int) {}
|
|
||||||
|
|
||||||
override fun dcssdkEventCommunicationSessionEstablished(dcsScannerInfo: DCSScannerInfo?) {}
|
|
||||||
|
|
||||||
override fun dcssdkEventCommunicationSessionTerminated(i: Int) {}
|
|
||||||
// override fun dcssdkEventBarcode(p0: ByteArray?, p1: Int, p2: Int) {
|
|
||||||
// TODO("Not yet implemented")
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
override fun dcssdkEventImage(bytes: ByteArray?, i: Int) {}
|
|
||||||
|
|
||||||
override fun dcssdkEventVideo(bytes: ByteArray?, i: Int) {}
|
|
||||||
|
|
||||||
override fun dcssdkEventBinaryData(bytes: ByteArray?, i: Int) {}
|
|
||||||
|
|
||||||
override fun dcssdkEventFirmwareUpdate(firmwareUpdateEvent: FirmwareUpdateEvent?) {}
|
|
||||||
|
|
||||||
override fun dcssdkEventAuxScannerAppeared(
|
|
||||||
dcsScannerInfo: DCSScannerInfo?,
|
|
||||||
dcsScannerInfo1: DCSScannerInfo?,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun dcssdkEventConfigurationUpdate(configurationUpdateEvent: ConfigurationUpdateEvent?) {}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package com.example.hpostesting.presentation.jig
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.SharedPreferences
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
|
||||||
import androidx.lifecycle.ViewModel
|
|
||||||
import androidx.lifecycle.viewModelScope
|
|
||||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
|
||||||
import com.example.hpostesting.data.model.Response
|
|
||||||
import com.example.hpostesting.data.model.jig.JigData
|
|
||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
|
||||||
import com.example.hpostesting.data.repository.Repository
|
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@HiltViewModel
|
|
||||||
class JigViewModel @Inject constructor(
|
|
||||||
private val hemoCubeDao: HemoCubeDao,
|
|
||||||
private val repository: Repository,
|
|
||||||
context: Context
|
|
||||||
) : ViewModel() {
|
|
||||||
var isServiceConnected = false
|
|
||||||
val progressBar = MutableLiveData(false)
|
|
||||||
val messages = MutableLiveData<String>()
|
|
||||||
private val sharedPreference: SharedPreferences =
|
|
||||||
context.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
|
||||||
|
|
||||||
val deviceData = MutableLiveData<DeviceData?>()
|
|
||||||
val fireBaseUpload = MutableLiveData<String>()
|
|
||||||
|
|
||||||
fun addScanDataToDb(data: JigData) {
|
|
||||||
viewModelScope.launch {
|
|
||||||
try {
|
|
||||||
when (val response = repository.addTestJigData(data)) {
|
|
||||||
is Response.Success -> {
|
|
||||||
fireBaseUpload.postValue("Success")
|
|
||||||
}
|
|
||||||
|
|
||||||
is Response.Error -> {
|
|
||||||
fireBaseUpload.postValue("Error")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
fireBaseUpload.postValue("Error")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
|
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools">
|
|
||||||
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:id="@+id/cl_parent"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<!-- <androidx.appcompat.widget.Toolbar-->
|
|
||||||
<!-- android:id="@+id/my_toolbar"-->
|
|
||||||
<!-- android:layout_width="match_parent"-->
|
|
||||||
<!-- android:layout_height="?attr/actionBarSize"-->
|
|
||||||
<!-- android:background="?attr/colorPrimary"-->
|
|
||||||
<!-- app:titleTextColor="#FFFFFF"-->
|
|
||||||
<!-- android:elevation="4dp"-->
|
|
||||||
<!-- app:menu="@menu/my_menu"-->
|
|
||||||
<!-- android:theme="@style/ToolbarTheme"-->
|
|
||||||
<!-- app:popupTheme="@style/ThemeOverlay.AppCompat.Light"-->
|
|
||||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
|
||||||
<!-- app:layout_constraintTop_toTopOf="parent"/>-->
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/fg_jig"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
tools:context=".presentation.jig.JigActivity">
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
</layout>
|
|
||||||
@@ -1,10 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context="com.example.hpostesting.presentation.dashboard.GalleryFragment">
|
android:fillViewport="true">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
tools:context="com.example.hpostesting.presentation.dashboard.GalleryFragment">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_subtitle4"
|
android:id="@+id/tv_subtitle4"
|
||||||
@@ -77,22 +82,8 @@
|
|||||||
app:cornerRadius="16dp"
|
app:cornerRadius="16dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_deviceProvision" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/btn_deviceProvision"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:visibility="visible"
|
|
||||||
android:layout_marginHorizontal="16dp"
|
|
||||||
android:layout_marginTop="24dp"
|
|
||||||
android:clickable="false"
|
|
||||||
android:text="@string/deviceProvision"
|
|
||||||
android:textColor="@color/white"
|
|
||||||
app:cornerRadius="16dp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_auto_dac" />
|
app:layout_constraintTop_toBottomOf="@id/btn_auto_dac" />
|
||||||
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/btn_deviceInfo"
|
android:id="@+id/btn_deviceInfo"
|
||||||
@@ -108,6 +99,20 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_calibration" />
|
app:layout_constraintTop_toBottomOf="@id/btn_calibration" />
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btn_deviceProvision"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="visible"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:clickable="false"
|
||||||
|
android:text="@string/deviceProvision"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/btn_deviceInfo" />
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/btn_firefox"
|
android:id="@+id/btn_firefox"
|
||||||
@@ -137,4 +142,5 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_firefox" />
|
app:layout_constraintTop_toBottomOf="@id/btn_firefox" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</ScrollView>
|
||||||
@@ -1,126 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
tools:context="com.example.hpostesting.presentation.jig.JigFragment">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tv_subtitle2"
|
|
||||||
style="@style/title2"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginHorizontal="24dp"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:text="Test Jig"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tv_app_version"
|
|
||||||
style="@style/title2"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginHorizontal="24dp"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:text="0.0.0"
|
|
||||||
app:layout_constraintStart_toEndOf="@id/tv_subtitle2"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/tv_subtitle2"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tv_title"
|
|
||||||
style="@style/title1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginHorizontal="24dp"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:text="Scan to get the code"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/tv_subtitle2" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tv_subtitle3"
|
|
||||||
style="@style/title2"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginHorizontal="24dp"
|
|
||||||
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/tv_subtitle2" />
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/btn_scan_now"
|
|
||||||
android:layout_width="258dp"
|
|
||||||
android:layout_height="56dp"
|
|
||||||
android:layout_margin="24dp"
|
|
||||||
android:drawableLeft="@drawable/baseline_qr_code_scanner_24"
|
|
||||||
android:text="@string/scan_now"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
app:backgroundTint="@color/blue_app_light"
|
|
||||||
app:cornerRadius="100dp"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tv_title" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tv_scan_text"
|
|
||||||
style="@style/title1_1"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="150dp"
|
|
||||||
android:layout_marginHorizontal="24dp"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="no scan"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
android:textSize="22sp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_scan_now" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/btn_refresh"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginHorizontal="16dp"
|
|
||||||
android:layout_marginTop="24dp"
|
|
||||||
android:clickable="false"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="Refresh"
|
|
||||||
android:visibility="visible"
|
|
||||||
android:textColor="@color/white"
|
|
||||||
app:layout_constraintEnd_toEndOf="@id/btn_scan_now"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_scan_now" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/iv_check"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:layout_width="100dp"
|
|
||||||
android:layout_height="100dp"
|
|
||||||
android:layout_marginTop="40dp"
|
|
||||||
android:importantForAccessibility="no"
|
|
||||||
android:src="@drawable/check"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_submit" />
|
|
||||||
|
|
||||||
<ProgressBar
|
|
||||||
android:id="@+id/progressBar"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerInParent="true"
|
|
||||||
android:elevation="12dp"
|
|
||||||
android:indeterminate="true"
|
|
||||||
android:indeterminateDrawable="@drawable/progressbar_drawable"
|
|
||||||
android:visibility="gone"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
Reference in New Issue
Block a user