Compare commits
19 Commits
Homocube_E
...
samplebuff
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5966af95eb | ||
|
|
095f9fb027 | ||
|
|
1fb938bd0d | ||
|
|
865922e90e | ||
|
|
e71496e423 | ||
|
|
472b50562b | ||
|
|
81e8567b49 | ||
|
|
3f8b931684 | ||
|
|
270cee7a9c | ||
|
|
515ab24ce6 | ||
|
|
e455cacf69 | ||
|
|
45613b2709 | ||
|
|
34bed4e5fe | ||
|
|
f019e1897d | ||
|
|
1d542f5562 | ||
|
|
4289d1c399 | ||
|
|
38f2122444 | ||
|
|
d6bacd578c | ||
|
|
f8a7bff5b2 |
2
app/.gitignore
vendored
2
app/.gitignore
vendored
@@ -1,3 +1,3 @@
|
|||||||
/build
|
/build
|
||||||
/google-services.json
|
/google-services*
|
||||||
/idea
|
/idea
|
||||||
@@ -18,8 +18,8 @@ android {
|
|||||||
applicationId "in.sminnovations.hpostesting"
|
applicationId "in.sminnovations.hpostesting"
|
||||||
minSdk 21
|
minSdk 21
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 2
|
versionCode 10
|
||||||
versionName "2.0.1"
|
versionName "2.1.10"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
@@ -52,11 +52,11 @@ android {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
||||||
implementation 'androidx.core:core-ktx:1.10.1'
|
implementation 'androidx.core:core-ktx:1.12.0'
|
||||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||||
implementation 'com.google.android.material:material:1.9.0'
|
implementation 'com.google.android.material:material:1.9.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.1'
|
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2'
|
||||||
|
|
||||||
//firebase
|
//firebase
|
||||||
implementation platform('com.google.firebase:firebase-bom:32.1.0')
|
implementation platform('com.google.firebase:firebase-bom:32.1.0')
|
||||||
@@ -66,10 +66,13 @@ dependencies {
|
|||||||
implementation 'com.google.firebase:firebase-auth-ktx'
|
implementation 'com.google.firebase:firebase-auth-ktx'
|
||||||
implementation 'com.google.firebase:firebase-storage-ktx'
|
implementation 'com.google.firebase:firebase-storage-ktx'
|
||||||
implementation 'com.firebaseui:firebase-ui-firestore:8.0.2'
|
implementation 'com.firebaseui:firebase-ui-firestore:8.0.2'
|
||||||
implementation 'com.google.android.gms:play-services-auth:20.6.0'
|
implementation 'com.google.android.gms:play-services-auth:20.7.0'
|
||||||
implementation 'com.google.android.gms:play-services-location:21.0.1'
|
implementation 'com.google.android.gms:play-services-location:21.0.1'
|
||||||
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
|
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
|
||||||
implementation 'com.google.android.things:androidthings:1.0'
|
implementation 'com.google.android.things:androidthings:1.0'
|
||||||
|
implementation 'com.google.firebase:firebase-appdistribution:16.0.0-beta10'
|
||||||
|
implementation("com.google.firebase:firebase-appdistribution-api-ktx:16.0.0-beta10")
|
||||||
|
|
||||||
|
|
||||||
// Testing
|
// Testing
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
@@ -77,7 +80,7 @@ dependencies {
|
|||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||||
|
|
||||||
|
|
||||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1"
|
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2"
|
||||||
implementation 'com.opencsv:opencsv:4.6'
|
implementation 'com.opencsv:opencsv:4.6'
|
||||||
implementation 'com.github.mik3y:usb-serial-for-android:3.5.1'
|
implementation 'com.github.mik3y:usb-serial-for-android:3.5.1'
|
||||||
|
|
||||||
@@ -102,8 +105,8 @@ dependencies {
|
|||||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.2'
|
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.2'
|
||||||
|
|
||||||
// Navigation Component
|
// Navigation Component
|
||||||
implementation "androidx.navigation:navigation-fragment-ktx:2.7.1"
|
implementation "androidx.navigation:navigation-fragment-ktx:2.7.2"
|
||||||
implementation "androidx.navigation:navigation-ui-ktx:2.7.1"
|
implementation "androidx.navigation:navigation-ui-ktx:2.7.2"
|
||||||
|
|
||||||
//Dagger - Hilt
|
//Dagger - Hilt
|
||||||
implementation "com.google.dagger:hilt-android:2.46"
|
implementation "com.google.dagger:hilt-android:2.46"
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import android.content.Context
|
|||||||
import androidx.room.Room
|
import androidx.room.Room
|
||||||
import com.example.hpostesting.data.dao.MyDatabase
|
import com.example.hpostesting.data.dao.MyDatabase
|
||||||
import com.google.android.datatransport.runtime.dagger.Provides
|
import com.google.android.datatransport.runtime.dagger.Provides
|
||||||
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
|
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
|
||||||
@@ -15,5 +17,14 @@ import javax.inject.Singleton
|
|||||||
class HPOSTestingApplication: Application() {
|
class HPOSTestingApplication: Application() {
|
||||||
val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||||
|
|
||||||
|
override fun onCreate() {
|
||||||
|
super.onCreate()
|
||||||
|
val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||||
|
val firestoreSettings = FirebaseFirestoreSettings.Builder()
|
||||||
|
.setPersistenceEnabled(true) // Enable offline persistence if needed
|
||||||
|
.build()
|
||||||
|
|
||||||
|
val firestore = FirebaseFirestore.getInstance()
|
||||||
|
firestore.firestoreSettings = firestoreSettings
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -9,15 +9,15 @@ import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
|||||||
import com.example.hpostesting.data.model.patient.UserData
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
@Dao
|
@Dao
|
||||||
interface HemoCubeDao {
|
interface HemoCubeDao {
|
||||||
@Query("SELECT * from HemocubeTest_table")
|
@Query("SELECT * from hemo_cube_test_table")
|
||||||
fun getAll(): LiveData<List<HemoCubeTestData>>
|
fun getAll(): LiveData<List<HemoCubeTestData>>
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
suspend fun insertAll(hemoCubeTestData: HemoCubeTestData)
|
suspend fun insertAll(hemoCubeTestData: HemoCubeTestData)
|
||||||
|
|
||||||
@Query("SELECT * FROM hemocubetest_table WHERE _id = :id")
|
@Query("SELECT * FROM hemo_cube_test_table WHERE _id = :id")
|
||||||
suspend fun getUserByID(id: String): HemoCubeTestData
|
suspend fun getUserByID(id: String): HemoCubeTestData
|
||||||
|
|
||||||
@Query("DELETE FROM hemocubetest_table WHERE _id = :id")
|
@Query("DELETE FROM hemo_cube_test_table WHERE _id = :id")
|
||||||
suspend fun deleteById(id: String)
|
suspend fun deleteById(id: String)
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@ package com.example.hpostesting.data.model.patient
|
|||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
import androidx.room.PrimaryKey
|
import androidx.room.PrimaryKey
|
||||||
|
|
||||||
@Entity(tableName = "HemocubeTest_table")
|
@Entity(tableName = "hemo_cube_test_table")
|
||||||
data class HemoCubeTestData(
|
data class HemoCubeTestData(
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
var _id: String = "",
|
var _id: String = "",
|
||||||
@@ -29,5 +29,6 @@ data class HemoCubeTestData(
|
|||||||
var led1Average: Double? = null,
|
var led1Average: Double? = null,
|
||||||
var led2Average: Double? = null,
|
var led2Average: Double? = null,
|
||||||
var deviceRatio: Double? = null,
|
var deviceRatio: Double? = null,
|
||||||
var calculatedRatio: Double? = null
|
var calculatedRatio: Double? = null,
|
||||||
|
var classificationResult: String = ""
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import android.content.Intent
|
|||||||
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 android.view.View
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
@@ -12,6 +13,8 @@ import com.example.hpostesting.data.constant.Constants
|
|||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
||||||
import com.example.hpostesting.presentation.testRight.TestRightActivity
|
import com.example.hpostesting.presentation.testRight.TestRightActivity
|
||||||
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||||
import com.journeyapps.barcodescanner.ScanContract
|
import com.journeyapps.barcodescanner.ScanContract
|
||||||
import com.journeyapps.barcodescanner.ScanIntentResult
|
import com.journeyapps.barcodescanner.ScanIntentResult
|
||||||
import com.journeyapps.barcodescanner.ScanOptions
|
import com.journeyapps.barcodescanner.ScanOptions
|
||||||
@@ -52,20 +55,48 @@ class KitScanActivity : AppCompatActivity() {
|
|||||||
moveToNext()
|
moveToNext()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkHemoCubeKitData()) {
|
// if (checkHemoCubeKitData()) {
|
||||||
DataHolder.selectedTest!!.kitSerial =
|
// DataHolder.selectedTest!!.kitSerial =
|
||||||
sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
// sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
||||||
moveToNext()
|
// moveToNext()
|
||||||
} else {
|
// } else {
|
||||||
with(sharedPreference.edit()) {
|
// with(sharedPreference.edit()) {
|
||||||
putString(Constants.KIT_NUMBER, "")
|
// putString(Constants.KIT_NUMBER, "")
|
||||||
putInt(Constants.KIT_COUNT, 0)
|
// putInt(Constants.KIT_COUNT, 0)
|
||||||
putString(Constants.BUFFER_VALUE_1, "")
|
// putString(Constants.BUFFER_VALUE_1, "")
|
||||||
putString(Constants.BUFFER_VALUE_2, "")
|
// putString(Constants.BUFFER_VALUE_2, "")
|
||||||
apply()
|
// apply()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (checkHemoCubeKitData()) {
|
||||||
|
DataHolder.selectedTest!!.kitSerial =
|
||||||
|
sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
||||||
|
moveToNext()
|
||||||
|
} else {
|
||||||
|
// Handle the case when checkHemoCubeKitData() returns false
|
||||||
|
with(sharedPreference.edit()) {
|
||||||
|
putString(Constants.KIT_NUMBER, "")
|
||||||
|
putInt(Constants.KIT_COUNT, 0)
|
||||||
|
putString(Constants.BUFFER_VALUE_1, "")
|
||||||
|
putString(Constants.BUFFER_VALUE_2, "")
|
||||||
|
apply()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e: NullPointerException) {
|
||||||
|
// Handle the NullPointerException here
|
||||||
|
e.printStackTrace() // You can log the exception for debugging
|
||||||
|
FirebaseCrashlytics.getInstance().recordException(e)
|
||||||
|
val errorMessage = "An error occurred: ${e.message}"
|
||||||
|
val rootView = findViewById<View>(android.R.id.content)
|
||||||
|
Snackbar.make(rootView, errorMessage, Snackbar.LENGTH_LONG).show()
|
||||||
|
// Optionally, show a user-friendly error message to the user
|
||||||
|
// Toast.makeText(applicationContext, "An error occurred", Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
binding.nameEditText.setText("SMI/SC/")
|
binding.nameEditText.setText("SMI/SC/")
|
||||||
|
|
||||||
setSupportActionBar(binding.toolbar)
|
setSupportActionBar(binding.toolbar)
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ import com.example.hpostesting.data.DataHolder
|
|||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
import com.example.hpostesting.data.model.test.TestType
|
import com.example.hpostesting.data.model.test.TestType
|
||||||
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import com.google.android.gms.location.*
|
import com.google.android.gms.location.*
|
||||||
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityMainBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityMainBinding
|
||||||
@@ -83,6 +86,11 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (DataHolder.selectedTest == null) {
|
||||||
|
startActivity(Intent(this, DashboardActivity::class.java))
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// val crashButton = Button(this)
|
// val crashButton = Button(this)
|
||||||
// crashButton.text = "Test Crash"
|
// crashButton.text = "Test Crash"
|
||||||
@@ -159,12 +167,14 @@ class MainActivity : AppCompatActivity() {
|
|||||||
DataHolder.selectedTestType = TestType.SICKLECERT
|
DataHolder.selectedTestType = TestType.SICKLECERT
|
||||||
val i = Intent(applicationContext, KitScanActivity::class.java)
|
val i = Intent(applicationContext, KitScanActivity::class.java)
|
||||||
startActivity(i)
|
startActivity(i)
|
||||||
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.cvItem2.setOnClickListener {
|
binding.cvItem2.setOnClickListener {
|
||||||
DataHolder.selectedTestType = TestType.SICKLEFIND
|
DataHolder.selectedTestType = TestType.SICKLEFIND
|
||||||
val i = Intent(applicationContext, KitScanActivity::class.java)
|
val i = Intent(applicationContext, KitScanActivity::class.java)
|
||||||
startActivity(i)
|
startActivity(i)
|
||||||
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
DataHolder.usbConnected.observe(this) {
|
DataHolder.usbConnected.observe(this) {
|
||||||
@@ -234,18 +244,46 @@ class MainActivity : AppCompatActivity() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fusedLocationClient.lastLocation.addOnSuccessListener { location: Location? ->
|
||||||
|
// location?.let {
|
||||||
|
// DataHolder.selectedTest!!.location =
|
||||||
|
// UserData.Location(location.latitude, location.longitude)
|
||||||
|
// DataHolder.location =
|
||||||
|
// UserData.Location(location.latitude, location.longitude)
|
||||||
|
// } ?: run {
|
||||||
|
// requestLocationUpdates()
|
||||||
|
// }
|
||||||
|
// }.addOnFailureListener { exception: Exception ->
|
||||||
|
// exception.printStackTrace()
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
fusedLocationClient.lastLocation.addOnSuccessListener { location: Location? ->
|
fusedLocationClient.lastLocation.addOnSuccessListener { location: Location? ->
|
||||||
location?.let {
|
location?.let {
|
||||||
DataHolder.selectedTest!!.location =
|
if (DataHolder.selectedTest != null) {
|
||||||
UserData.Location(location.latitude, location.longitude)
|
DataHolder.selectedTest!!.location =
|
||||||
|
UserData.Location(location.latitude, location.longitude)
|
||||||
|
} else {
|
||||||
|
startActivity(Intent(this, DashboardActivity::class.java))
|
||||||
|
finish()
|
||||||
|
}
|
||||||
DataHolder.location =
|
DataHolder.location =
|
||||||
UserData.Location(location.latitude, location.longitude)
|
UserData.Location(location.latitude, location.longitude)
|
||||||
} ?: run {
|
} ?: run {
|
||||||
requestLocationUpdates()
|
requestLocationUpdates()
|
||||||
}
|
}
|
||||||
}.addOnFailureListener { exception: Exception ->
|
}.addOnFailureListener { exception: Exception ->
|
||||||
|
// Handle the exception here
|
||||||
exception.printStackTrace()
|
exception.printStackTrace()
|
||||||
|
FirebaseCrashlytics.getInstance().recordException(exception)
|
||||||
|
// Display an error message to the user using a Snackbar
|
||||||
|
val errorMessage = "An error occurred: ${exception.message}"
|
||||||
|
val rootView = findViewById<View>(android.R.id.content)
|
||||||
|
Snackbar.make(rootView, errorMessage, Snackbar.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun requestLocationUpdates() {
|
private fun requestLocationUpdates() {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class SplashActivity : AppCompatActivity() {
|
|||||||
binding = ActivitySplashBinding.inflate(layoutInflater)
|
binding = ActivitySplashBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
|
||||||
setupFirestoreCache()
|
// setupFirestoreCache()
|
||||||
setupStaticConstants()
|
setupStaticConstants()
|
||||||
|
|
||||||
requestPermissions()
|
requestPermissions()
|
||||||
@@ -50,12 +50,12 @@ class SplashActivity : AppCompatActivity() {
|
|||||||
Settings.Secure.getString(applicationContext.contentResolver, Settings.Secure.ANDROID_ID)
|
Settings.Secure.getString(applicationContext.contentResolver, Settings.Secure.ANDROID_ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupFirestoreCache() {
|
// private fun setupFirestoreCache() {
|
||||||
val settings = FirebaseFirestoreSettings.Builder()
|
// val settings = FirebaseFirestoreSettings.Builder()
|
||||||
.setCacheSizeBytes(FirebaseFirestoreSettings.CACHE_SIZE_UNLIMITED)
|
// .setCacheSizeBytes(FirebaseFirestoreSettings.CACHE_SIZE_UNLIMITED)
|
||||||
.build()
|
// .build()
|
||||||
Firebase.firestore.firestoreSettings = settings
|
// Firebase.firestore.firestoreSettings = settings
|
||||||
}
|
// }
|
||||||
|
|
||||||
private fun requestPermissions() {
|
private fun requestPermissions() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.example.hpostesting.presentation.dashboard
|
|||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.drawerlayout.widget.DrawerLayout
|
import androidx.drawerlayout.widget.DrawerLayout
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
@@ -10,6 +11,8 @@ import androidx.navigation.ui.navigateUp
|
|||||||
import androidx.navigation.ui.setupActionBarWithNavController
|
import androidx.navigation.ui.setupActionBarWithNavController
|
||||||
import androidx.navigation.ui.setupWithNavController
|
import androidx.navigation.ui.setupWithNavController
|
||||||
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.FirebaseAppDistributionException
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityDashboardBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityDashboardBinding
|
||||||
@@ -25,7 +28,6 @@ class DashboardActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
binding = ActivityDashboardBinding.inflate(layoutInflater)
|
binding = ActivityDashboardBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
|
||||||
setSupportActionBar(binding.appBarDashboard.toolbar)
|
setSupportActionBar(binding.appBarDashboard.toolbar)
|
||||||
|
|
||||||
val drawerLayout: DrawerLayout = binding.drawerLayout
|
val drawerLayout: DrawerLayout = binding.drawerLayout
|
||||||
@@ -53,4 +55,31 @@ class DashboardActivity : AppCompatActivity() {
|
|||||||
return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
|
return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
// Copy and paste this into any part of your app - for example, in your main
|
||||||
|
// activity's onResume method.
|
||||||
|
// val firebaseAppDistribution = FirebaseAppDistribution.getInstance()
|
||||||
|
// firebaseAppDistribution.updateIfNewReleaseAvailable()
|
||||||
|
// .addOnProgressListener { updateProgress ->
|
||||||
|
// Toast.makeText(this, "Updating", Toast.LENGTH_SHORT).show()
|
||||||
|
// }
|
||||||
|
// .addOnFailureListener { e ->
|
||||||
|
// // (Optional) Handle errors.
|
||||||
|
// if (e is FirebaseAppDistributionException) {
|
||||||
|
// when (e.errorCode) {
|
||||||
|
// FirebaseAppDistributionException.Status.NOT_IMPLEMENTED -> {
|
||||||
|
// // SDK did nothing. This is expected when building for Play.
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// else -> {
|
||||||
|
// // Handle other errors.
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@ class GalleryFragment : Fragment() {
|
|||||||
// val galleryViewModel =
|
// val galleryViewModel =
|
||||||
// ViewModelProvider(this).get(GalleryViewModel::class.java)
|
// ViewModelProvider(this).get(GalleryViewModel::class.java)
|
||||||
|
|
||||||
// _binding = FragmentGalleryBinding.inflate(inflater, container, false)
|
_binding = FragmentGalleryBinding.inflate(inflater, container, false)
|
||||||
val root: View = binding.root
|
val root: View = binding.root
|
||||||
|
|
||||||
// val textView: TextView = binding.textGallery
|
// val textView: TextView = binding.textGallery
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.example.hpostesting.presentation.adapter.UserListAdapter
|
|||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
||||||
import com.firebase.ui.firestore.FirestoreRecyclerOptions
|
import com.firebase.ui.firestore.FirestoreRecyclerOptions
|
||||||
|
import com.google.firebase.firestore.Query
|
||||||
import com.google.firebase.firestore.ktx.firestore
|
import com.google.firebase.firestore.ktx.firestore
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
@@ -37,8 +38,16 @@ class HomeFragment : Fragment() {
|
|||||||
private lateinit var sharedPreference: SharedPreferences
|
private lateinit var sharedPreference: SharedPreferences
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||||
): View {
|
): View? {
|
||||||
_binding = FragmentHomeBinding.inflate(inflater, container, false)
|
_binding = FragmentHomeBinding.inflate(inflater, container, false)
|
||||||
|
|
||||||
|
// Check if _binding is null
|
||||||
|
if (_binding == null) {
|
||||||
|
// Handle the case where binding could not be initialized
|
||||||
|
// You may want to log an error or return a default view in this case
|
||||||
|
return super.onCreateView(inflater, container, savedInstanceState)
|
||||||
|
}
|
||||||
|
|
||||||
sharedPreference = requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
sharedPreference = requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||||
DataHolder.selectedTest = null
|
DataHolder.selectedTest = null
|
||||||
|
|
||||||
@@ -90,6 +99,7 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private fun loadUserData() {
|
private fun loadUserData() {
|
||||||
|
// val query = Firebase.firestore.collection("patientData").whereEqualTo("testStatus", false).orderBy("createdAt", Query.Direction.DESCENDING)
|
||||||
val query = Firebase.firestore.collection("patientData").whereEqualTo("testStatus", false)
|
val query = Firebase.firestore.collection("patientData").whereEqualTo("testStatus", false)
|
||||||
query.get().addOnSuccessListener {
|
query.get().addOnSuccessListener {
|
||||||
if (it.documents.isEmpty()) {
|
if (it.documents.isEmpty()) {
|
||||||
@@ -154,8 +164,10 @@ class HomeFragment : Fragment() {
|
|||||||
binding.aadharIdRadioButton.isChecked -> "aadharId"
|
binding.aadharIdRadioButton.isChecked -> "aadharId"
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
field?.let { getData(query, it) }
|
field?.let { getData(query, it) }
|
||||||
false
|
false
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
loadUserData()
|
loadUserData()
|
||||||
false
|
false
|
||||||
@@ -252,7 +264,7 @@ class HomeFragment : Fragment() {
|
|||||||
|
|
||||||
private fun deleteHemoCubeIncompleteRegistrations(userDataList: List<HemoCubeTestData>) {
|
private fun deleteHemoCubeIncompleteRegistrations(userDataList: List<HemoCubeTestData>) {
|
||||||
userDataList.forEach { userData ->
|
userDataList.forEach { userData ->
|
||||||
if (userData.testTime?.isEmpty() == false) {
|
if (userData.testTime?.isEmpty() == true) {
|
||||||
hemoCubeViewModel.deleteById(userData._id)
|
hemoCubeViewModel.deleteById(userData._id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import androidx.lifecycle.ViewModelProvider
|
|||||||
import com.example.hpostesting.presentation.dashboard.ui.slideshow.SlideshowViewModel
|
import com.example.hpostesting.presentation.dashboard.ui.slideshow.SlideshowViewModel
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentSlideshowBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentSlideshowBinding
|
||||||
|
|
||||||
|
|
||||||
class SlideshowFragment : Fragment() {
|
class SlideshowFragment : Fragment() {
|
||||||
|
|
||||||
private var _binding: FragmentSlideshowBinding? = null
|
private var _binding: FragmentSlideshowBinding? = null
|
||||||
@@ -20,7 +21,7 @@ class SlideshowFragment : Fragment() {
|
|||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
container: ViewGroup?,
|
container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?,
|
||||||
): View {
|
): View {
|
||||||
val slideshowViewModel =
|
val slideshowViewModel =
|
||||||
ViewModelProvider(this).get(SlideshowViewModel::class.java)
|
ViewModelProvider(this).get(SlideshowViewModel::class.java)
|
||||||
@@ -28,6 +29,12 @@ class SlideshowFragment : Fragment() {
|
|||||||
_binding = FragmentSlideshowBinding.inflate(inflater, container, false)
|
_binding = FragmentSlideshowBinding.inflate(inflater, container, false)
|
||||||
val root: View = binding.root
|
val root: View = binding.root
|
||||||
|
|
||||||
|
val pInfo = requireActivity().packageManager.getPackageInfo(
|
||||||
|
requireActivity().packageName, 0
|
||||||
|
)
|
||||||
|
val version = pInfo.versionName
|
||||||
|
binding.textSlideshow.text = version
|
||||||
|
|
||||||
// val textView: TextView = binding.textSlideshow
|
// val textView: TextView = binding.textSlideshow
|
||||||
// slideshowViewModel.text.observe(viewLifecycleOwner) {
|
// slideshowViewModel.text.observe(viewLifecycleOwner) {
|
||||||
// textView.text = it
|
// textView.text = it
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import android.view.ViewGroup
|
|||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
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
|
||||||
@@ -21,13 +22,14 @@ import com.example.hpostesting.presentation.UsbServiceListener
|
|||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import com.example.hpostesting.presentation.utils.MyDialogListener
|
import com.example.hpostesting.presentation.utils.MyDialogListener
|
||||||
import com.example.hpostesting.presentation.utils.UIUtils
|
import com.example.hpostesting.presentation.utils.UIUtils
|
||||||
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
import com.google.firebase.firestore.FirebaseFirestore
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
import com.google.firebase.firestore.ktx.firestore
|
import com.google.firebase.firestore.ktx.firestore
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import `in`.sminnovations.hpostesting.BuildConfig
|
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentHemoCubeReferenceBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentHemoCubeReferenceBinding
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.tasks.await
|
import kotlinx.coroutines.tasks.await
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
@@ -43,9 +45,9 @@ class HemoCubeFragment : Fragment() {
|
|||||||
private var resultData: String = ""
|
private var resultData: String = ""
|
||||||
private var isUsingExistingBuffer = false
|
private var isUsingExistingBuffer = false
|
||||||
private var isTestOngoing = false
|
private var isTestOngoing = false
|
||||||
private var bloodGroup: String = ""
|
private var startListening = MutableLiveData<Boolean>(false)
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
||||||
): View {
|
): View {
|
||||||
binding = FragmentHemoCubeReferenceBinding.inflate(inflater, container, false)
|
binding = FragmentHemoCubeReferenceBinding.inflate(inflater, container, false)
|
||||||
sharedPreferences =
|
sharedPreferences =
|
||||||
@@ -57,7 +59,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
initViews()
|
initViews()
|
||||||
observeViewModel()
|
observeViewModel()
|
||||||
checkAndStartProcess()
|
// checkAndStartProcess()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initViews() {
|
private fun initViews() {
|
||||||
@@ -78,10 +80,25 @@ class HemoCubeFragment : Fragment() {
|
|||||||
binding.btnSubmit.isEnabled = false
|
binding.btnSubmit.isEnabled = false
|
||||||
binding.btnSubmit.isClickable = false
|
binding.btnSubmit.isClickable = false
|
||||||
|
|
||||||
|
|
||||||
|
binding.btnSamplestart.setOnClickListener {
|
||||||
|
startSampleProcess()
|
||||||
|
it.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.btnPlacebuffer.setOnClickListener {
|
||||||
|
checkAndStartProcess()
|
||||||
|
it.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
binding.btnKit.setOnClickListener {
|
binding.btnKit.setOnClickListener {
|
||||||
if (isTestOngoing) {
|
if (isTestOngoing) {
|
||||||
val title = "WARNING"
|
val title = "WARNING"
|
||||||
val message = "There is a on going test, do you want to stop it"
|
val message =
|
||||||
|
"There is a on going test, do you want to stop it. if Yes please disconnect the device and connect it again, once you reached to kitDetails Screen"
|
||||||
val negativeText = getString(R.string.no)
|
val negativeText = getString(R.string.no)
|
||||||
val positiveText = "Yes"
|
val positiveText = "Yes"
|
||||||
|
|
||||||
@@ -102,6 +119,11 @@ class HemoCubeFragment : Fragment() {
|
|||||||
(activity as HemocubeActivity).finish()
|
(activity as HemocubeActivity).finish()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
resetKitCount()
|
||||||
|
val intent = Intent(context, KitScanActivity::class.java)
|
||||||
|
startActivity(intent)
|
||||||
|
(activity as HemocubeActivity).finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -150,26 +172,50 @@ class HemoCubeFragment : Fragment() {
|
|||||||
|
|
||||||
hemoCubeViewModel.deviceData.observe(viewLifecycleOwner) {
|
hemoCubeViewModel.deviceData.observe(viewLifecycleOwner) {
|
||||||
currentDeviceData = it
|
currentDeviceData = it
|
||||||
showToast(calculateRatio(0.17).toString())
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hemoCubeViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
hemoCubeViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
||||||
isOnline = isNetworkAvailable
|
apply {
|
||||||
|
DataHolder.hemoCubeTestData?.let {
|
||||||
|
currentDeviceData?.coefficients?.let { coefficients ->
|
||||||
|
val coefficient1 = coefficients[0]
|
||||||
|
val coefficient2 = coefficients[1]
|
||||||
|
val result = coefficient1 * coefficient2
|
||||||
|
showToast("coefficients: $coefficient1, $coefficient2")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isOnline = isNetworkAvailable
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hemoCubeViewModel.messages.observe(viewLifecycleOwner) {
|
hemoCubeViewModel.messages.observe(viewLifecycleOwner) {
|
||||||
binding.tvSubtitle4.text = it
|
binding.tvSubtitle4.text = it
|
||||||
}
|
}
|
||||||
|
// startListening.observe(viewLifecycleOwner) {
|
||||||
|
// if (it) {
|
||||||
|
// lifecycleScope.launch {
|
||||||
|
// delay(1000)
|
||||||
|
// if (binding.tvSubtitle4.text.toString().isEmpty()) {
|
||||||
|
// (activity as HemocubeActivity).reconnectDevice()
|
||||||
|
// if (isBufferValueAvailable()) {
|
||||||
|
// showBufferAlertDialog()
|
||||||
|
// } else {
|
||||||
|
// listenToHemoCube()
|
||||||
|
// startBufferProcess()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkAndStartProcess() {
|
private fun checkAndStartProcess() {
|
||||||
if (isBufferValueAvailable()) {
|
// if (isBufferValueAvailable()) {
|
||||||
showBufferAlertDialog()
|
// showBufferAlertDialog()
|
||||||
} else {
|
// } else {
|
||||||
listenToHemoCube()
|
listenToHemoCube()
|
||||||
startBufferProcess()
|
startBufferProcess()
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isBufferValueAvailable(): Boolean {
|
private fun isBufferValueAvailable(): Boolean {
|
||||||
@@ -218,19 +264,26 @@ class HemoCubeFragment : Fragment() {
|
|||||||
hemoCubeViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
val fullReadOutput = StringBuilder()
|
val fullReadOutput = StringBuilder()
|
||||||
(activity as HemocubeActivity).mService.listenToHemoCube(object : UsbServiceListener {
|
startListening.postValue(true)
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
|
||||||
data?.let {
|
|
||||||
val stringData = String(it)
|
|
||||||
fullReadOutput.append(stringData)
|
|
||||||
handleUsbData(stringData, fullReadOutput)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
try {
|
||||||
hemoCubeViewModel.progressBar.postValue(false)
|
(activity as HemocubeActivity).mService.listenToHemoCube(object : UsbServiceListener {
|
||||||
}
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
})
|
data?.let {
|
||||||
|
val stringData = String(it)
|
||||||
|
fullReadOutput.append(stringData)
|
||||||
|
handleUsbData(stringData, fullReadOutput)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (e: Exception) {
|
||||||
|
showToast("test is going on")
|
||||||
|
Firebase.crashlytics.recordException(e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleUsbData(stringData: String, fullReadOutput: StringBuilder) {
|
private fun handleUsbData(stringData: String, fullReadOutput: StringBuilder) {
|
||||||
@@ -242,9 +295,18 @@ class HemoCubeFragment : Fragment() {
|
|||||||
resultData += fullReadOutput.toString()
|
resultData += fullReadOutput.toString()
|
||||||
|
|
||||||
when {
|
when {
|
||||||
stringData.contains("ERROR 500") -> showError500Dialog()
|
stringData.contains("ERROR 500") ->
|
||||||
|
// showError500Dialog()
|
||||||
|
checkAndStartProcess()
|
||||||
stringData.contains("ERROR 501") -> showError501Dialog()
|
stringData.contains("ERROR 501") -> showError501Dialog()
|
||||||
stringData.contains("#Buffer Completed") -> showStartSampleDialog()
|
stringData.contains("#Buffer Completed") ->
|
||||||
|
// showStartSampleDialog()
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
binding.btnSamplestart.visibility = View.VISIBLE
|
||||||
|
binding.btnSamplestart.isClickable = true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
stringData.contains("#Sample Completed") -> {
|
stringData.contains("#Sample Completed") -> {
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
binding.btnSubmit.isEnabled = true
|
binding.btnSubmit.isEnabled = true
|
||||||
@@ -272,6 +334,25 @@ class HemoCubeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun showError() {
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
UIUtils.createAlertDialog(requireContext(),
|
||||||
|
"Device Error",
|
||||||
|
"Something is wrong with the device, please disconnect and reconnect the device and test the user again",
|
||||||
|
getString(R.string.noo),
|
||||||
|
"Yes",
|
||||||
|
object : MyDialogListener {
|
||||||
|
override fun onClickNegativeButton() {}
|
||||||
|
|
||||||
|
override fun onClickPositiveButton() {
|
||||||
|
startActivity(Intent(requireActivity(), DashboardActivity::class.java))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun showError500Dialog() {
|
private fun showError500Dialog() {
|
||||||
UIUtils.createAlertDialog(requireContext(),
|
UIUtils.createAlertDialog(requireContext(),
|
||||||
"BUFFER ERROR",
|
"BUFFER ERROR",
|
||||||
@@ -288,6 +369,19 @@ class HemoCubeFragment : Fragment() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun handleBackButtonPress() {
|
||||||
|
if (isTestOngoing) {
|
||||||
|
// If the test is ongoing, don't allow the back button action
|
||||||
|
// You can optionally show a message to the user indicating why the back button is disabled
|
||||||
|
// For example, show a Toast or Snackbar.
|
||||||
|
showToast("Test is ongoing. Cannot go back.")
|
||||||
|
} else {
|
||||||
|
// If the test is not ongoing, you can trigger the back action of the hosting activity
|
||||||
|
activity?.onBackPressed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun showError501Dialog() {
|
private fun showError501Dialog() {
|
||||||
UIUtils.createAlertDialog(requireContext(),
|
UIUtils.createAlertDialog(requireContext(),
|
||||||
"SAMPLE ERROR",
|
"SAMPLE ERROR",
|
||||||
@@ -315,7 +409,8 @@ class HemoCubeFragment : Fragment() {
|
|||||||
override fun onClickNegativeButton() {}
|
override fun onClickNegativeButton() {}
|
||||||
|
|
||||||
override fun onClickPositiveButton() {
|
override fun onClickPositiveButton() {
|
||||||
|
listenToHemoCube()
|
||||||
|
startSampleProcess()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -336,21 +431,24 @@ class HemoCubeFragment : Fragment() {
|
|||||||
} else {
|
} else {
|
||||||
result[4].toDoubleOrNull()
|
result[4].toDoubleOrNull()
|
||||||
}
|
}
|
||||||
val version = BuildConfig.VERSION_NAME
|
val pInfo = requireActivity().packageManager.getPackageInfo(
|
||||||
|
requireActivity().packageName, 0
|
||||||
|
)
|
||||||
|
val version = pInfo.versionName
|
||||||
val led1Sample = result[5].toDoubleOrNull()
|
val led1Sample = result[5].toDoubleOrNull()
|
||||||
val led2Sample = result[6].toDoubleOrNull()
|
val led2Sample = result[6].toDoubleOrNull()
|
||||||
val led1Average = log10(led1BufferForDevice?.div(led1Sample!!) ?: 0.0)
|
val led1Average = log10(led1BufferForDevice?.div(led1Sample!!) ?: 0.0)
|
||||||
val led2Average = log10(led2BufferForDevice?.div(led2Sample!!) ?: 0.0)
|
val led2Average = log10(led2BufferForDevice?.div(led2Sample!!) ?: 0.0)
|
||||||
val deviceRatio = led1Average / led2Average
|
val deviceRatio = led1Average / led2Average
|
||||||
if (led1BufferForDevice!! > 20000 && led1BufferForDevice < 24000 && led2BufferForDevice!! > 20000 && led2BufferForDevice < 24000) {
|
// if (led1BufferForDevice!! > 20000 && led1BufferForDevice < 24000 && led2BufferForDevice!! > 20000 && led2BufferForDevice < 24000) {
|
||||||
if (led1Sample!! < led1BufferForDevice && led1Sample < 24000 && led2Sample!! < led2BufferForDevice && led2Sample < 24000) {
|
// if (led1Sample!! < led1BufferForDevice && led1Sample < 24000 && led2Sample!! < led2BufferForDevice && led2Sample < 24000) {
|
||||||
if (deviceRatio < 0.08) {
|
// if (deviceRatio < 0.08) {
|
||||||
if (deviceRatio > 1.07) {
|
// if (deviceRatio > 1.07) {
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
DataHolder.hemoCubeTestData?.apply {
|
DataHolder.hemoCubeTestData?.apply {
|
||||||
deviceId = deviceSerialNo
|
deviceId = deviceSerialNo
|
||||||
led1Buffer = led1BufferForDevice
|
led1Buffer = led1BufferForDevice
|
||||||
@@ -362,6 +460,8 @@ class HemoCubeFragment : Fragment() {
|
|||||||
this.led2Average = led2Average
|
this.led2Average = led2Average
|
||||||
this.deviceRatio = deviceRatio
|
this.deviceRatio = deviceRatio
|
||||||
this.calculatedRatio = calculateRatio(deviceRatio)
|
this.calculatedRatio = calculateRatio(deviceRatio)
|
||||||
|
this.classificationResult = findResult(calculatedRatio)
|
||||||
|
hemoCubeViewModel.messages.postValue(this.classificationResult)
|
||||||
this.resultData = fullReadOutput
|
this.resultData = fullReadOutput
|
||||||
if (!isBufferValueAvailable()) {
|
if (!isBufferValueAvailable()) {
|
||||||
with(sharedPreferences.edit()) {
|
with(sharedPreferences.edit()) {
|
||||||
@@ -370,16 +470,50 @@ class HemoCubeFragment : Fragment() {
|
|||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
binding.progressBar.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
hemoCubeViewModel.uploadHemoCubeResultToDatabase(
|
hemoCubeViewModel.uploadHemoCubeResultToDatabase(
|
||||||
isOnline, true, sharedPreferences.getString(Constants.KIT_NUMBER, "")
|
isOnline, true, sharedPreferences.getString(Constants.KIT_NUMBER, "")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
} catch (_: Exception) {
|
Toast.makeText(
|
||||||
|
requireContext(),
|
||||||
|
"Error while processing device data",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
Firebase.crashlytics.recordException(e)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun findResult(calculatedRatio: Double?): String {
|
||||||
|
try {
|
||||||
|
if (calculatedRatio != null) {
|
||||||
|
if (calculatedRatio < 0.085)
|
||||||
|
return "Inconclusive. Very low Absorbance - Repeat test with Higher Blood Volume"
|
||||||
|
if (calculatedRatio in 0.085..0.155)
|
||||||
|
return "Normal"
|
||||||
|
if (calculatedRatio in 0.155..0.175)
|
||||||
|
return "Negative Borderline. Repeat Test"
|
||||||
|
if (calculatedRatio in 0.175..0.22)
|
||||||
|
return "Sickle Cell Trait"
|
||||||
|
if (calculatedRatio in 0.22..0.25)
|
||||||
|
return "Positive for Sickle Cell. HPLC for Confirmation"
|
||||||
|
if (calculatedRatio in 0.25..0.35)
|
||||||
|
return "Sickle Cell Disease"
|
||||||
|
if (calculatedRatio > 0.35)
|
||||||
|
return "Inconclusive. Repeat with test with lower volume of blood"
|
||||||
|
} else {
|
||||||
|
return "NULL"
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
showToast("error while performing classification")
|
||||||
|
Firebase.crashlytics.recordException(e)
|
||||||
|
return "ERROR"
|
||||||
|
}
|
||||||
|
return "NULL"
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showToast(message: String) {
|
private fun showToast(message: String) {
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ 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.patient.DeviceData
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
|
||||||
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
||||||
import com.example.hpostesting.data.repository.DatabaseRepository
|
import com.example.hpostesting.data.repository.DatabaseRepository
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
@@ -34,7 +33,8 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
val progressBar = MutableLiveData(false)
|
val progressBar = MutableLiveData(false)
|
||||||
val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||||
val messages = MutableLiveData<String>()
|
val messages = MutableLiveData<String>()
|
||||||
private val sharedPreference: SharedPreferences = context.getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
private val sharedPreference: SharedPreferences =
|
||||||
|
context.getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||||
|
|
||||||
// Get the device ID of the device you want to retrieve data for (e.g., the first device in the list)
|
// Get the device ID of the device you want to retrieve data for (e.g., the first device in the list)
|
||||||
|
|
||||||
@@ -53,8 +53,10 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (isOnline) {
|
if (isOnline) {
|
||||||
|
parseData()
|
||||||
addResultTestToDb()
|
addResultTestToDb()
|
||||||
} else {
|
} else {
|
||||||
|
parseData()
|
||||||
testDetails?.testTime = SimpleDateFormat(
|
testDetails?.testTime = SimpleDateFormat(
|
||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
).format(Calendar.getInstance().time)
|
).format(Calendar.getInstance().time)
|
||||||
@@ -70,7 +72,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
deviceData.postValue(deviceId?.let { repository.getDeviceDataById(it) })
|
deviceData.postValue(deviceId?.let { repository.getDeviceDataById(it) })
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addResultTestToDb() {
|
private fun parseData() {
|
||||||
testDetails?.deviceRatio = DataHolder.hemocubeResult
|
testDetails?.deviceRatio = DataHolder.hemocubeResult
|
||||||
testDetails?.resultData = DataHolder.hemoCubeTestData?.resultData.toString()
|
testDetails?.resultData = DataHolder.hemoCubeTestData?.resultData.toString()
|
||||||
testDetails?.location = DataHolder.location
|
testDetails?.location = DataHolder.location
|
||||||
@@ -79,7 +81,8 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
).format(Calendar.getInstance().time)
|
).format(Calendar.getInstance().time)
|
||||||
testDetails?.appVersion = DataHolder.hemoCubeTestData?.appVersion
|
testDetails?.appVersion = DataHolder.hemoCubeTestData?.appVersion
|
||||||
testDetails?.deviceId = DataHolder.hemoCubeTestData?.deviceId
|
testDetails?.deviceId = DataHolder.hemoCubeTestData?.deviceId
|
||||||
testDetails?.deviceSerialNumber = sharedPreference.getString(Constants.USER_ID, "").toString()
|
testDetails?.deviceSerialNumber =
|
||||||
|
sharedPreference.getString(Constants.USER_ID, "").toString()
|
||||||
testDetails?.kitSerial = sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
testDetails?.kitSerial = sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
||||||
testDetails?.led1Buffer = DataHolder.hemoCubeTestData?.led1Buffer
|
testDetails?.led1Buffer = DataHolder.hemoCubeTestData?.led1Buffer
|
||||||
testDetails?.led2Buffer = DataHolder.hemoCubeTestData?.led2Buffer
|
testDetails?.led2Buffer = DataHolder.hemoCubeTestData?.led2Buffer
|
||||||
@@ -89,7 +92,10 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
testDetails?.led2Average = DataHolder.hemoCubeTestData?.led2Average
|
testDetails?.led2Average = DataHolder.hemoCubeTestData?.led2Average
|
||||||
testDetails?.deviceRatio = DataHolder.hemoCubeTestData?.deviceRatio
|
testDetails?.deviceRatio = DataHolder.hemoCubeTestData?.deviceRatio
|
||||||
testDetails?.calculatedRatio = DataHolder.hemoCubeTestData?.calculatedRatio
|
testDetails?.calculatedRatio = DataHolder.hemoCubeTestData?.calculatedRatio
|
||||||
|
testDetails?.classificationResult = DataHolder.hemoCubeTestData?.classificationResult!!
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun addResultTestToDb() {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
testDetails!!.reportUploadTime = SimpleDateFormat(
|
testDetails!!.reportUploadTime = SimpleDateFormat(
|
||||||
@@ -100,7 +106,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
val kitCount = sharedPreference.getInt(Constants.KIT_COUNT, 0)
|
val kitCount = sharedPreference.getInt(Constants.KIT_COUNT, 0)
|
||||||
with(sharedPreference.edit()) {
|
with(sharedPreference.edit()) {
|
||||||
putInt(Constants.KIT_COUNT, kitCount.plus(1) ?: 0)
|
putInt(Constants.KIT_COUNT, kitCount.plus(1))
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||||
@@ -108,14 +114,9 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
is Response.Error -> {
|
is Response.Error -> {
|
||||||
Log.e("Testdb", "Error uploading data to Firestore: ${response}")
|
Log.e("Testdb", "Error uploading data to Firestore: $response")
|
||||||
fireBaseUpload.postValue("Error")
|
fireBaseUpload.postValue("Error")
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
|
||||||
Log.e("Testdb", "Unknown response from repository: $response")
|
|
||||||
fireBaseUpload.postValue("Unknown")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("Testdb", "Exception during data upload: ${e.message}")
|
Log.e("Testdb", "Exception during data upload: ${e.message}")
|
||||||
@@ -132,6 +133,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
when (repository.addTestToDatabase(userData)) {
|
when (repository.addTestToDatabase(userData)) {
|
||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
|
deleteById(userData._id)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {}
|
else -> {}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.example.hpostesting.presentation.hemocube
|
|||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
import android.content.BroadcastReceiver
|
import android.content.BroadcastReceiver
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.ContentValues.TAG
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
@@ -11,32 +10,26 @@ 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
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.presentation.testRight.TestRightExpReference
|
|
||||||
import com.example.hpostesting.presentation.testRight.TestRightExpSample
|
|
||||||
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
|
||||||
import com.example.hpostesting.presentation.testRight.UsbService
|
import com.example.hpostesting.presentation.testRight.UsbService
|
||||||
import com.google.android.gms.location.FusedLocationProviderClient
|
|
||||||
import com.google.android.gms.location.LocationCallback
|
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityHemocubeBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityHemocubeBinding
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityMainBinding
|
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class HemocubeActivity : AppCompatActivity() {
|
open class HemocubeActivity : AppCompatActivity() {
|
||||||
private lateinit var binding: ActivityHemocubeBinding
|
private lateinit var binding: ActivityHemocubeBinding
|
||||||
private val viewModel by viewModels<HemoCubeViewModel>()
|
private val viewModel by viewModels<HemoCubeViewModel>()
|
||||||
private var myMenu: Menu? = null
|
private var myMenu: Menu? = null
|
||||||
@@ -91,18 +84,20 @@ class HemocubeActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupListener() {
|
private fun setupListener() {
|
||||||
DataHolder.usbConnected.observe(this){
|
DataHolder.usbConnected.observe(this) {
|
||||||
Log.d("USB OBSERVE", "HemoCube called -> $it")
|
Log.d("USB OBSERVE", "HemoCube called -> $it")
|
||||||
if (it){
|
if (it) {
|
||||||
myMenu?.get(0)?.icon = ContextCompat.getDrawable(this, R.drawable.ic_baseline_usb_24)
|
myMenu?.get(0)?.icon =
|
||||||
|
ContextCompat.getDrawable(this, R.drawable.ic_baseline_usb_24)
|
||||||
} else {
|
} else {
|
||||||
myMenu?.get(0)?.icon = ContextCompat.getDrawable(this, R.drawable.ic_baseline_usb_off_24)
|
myMenu?.get(0)?.icon =
|
||||||
|
ContextCompat.getDrawable(this, R.drawable.ic_baseline_usb_off_24)
|
||||||
Toast.makeText(this, "Device is Disconnected", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, "Device is Disconnected", Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private 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
|
||||||
val availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(manager)
|
val availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(manager)
|
||||||
@@ -126,10 +121,7 @@ class HemocubeActivity : AppCompatActivity() {
|
|||||||
val mPendingIntent: PendingIntent
|
val mPendingIntent: PendingIntent
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||||
mPendingIntent = PendingIntent.getBroadcast(
|
mPendingIntent = PendingIntent.getBroadcast(
|
||||||
this,
|
this, 0, Intent(Constants.HOMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||||
0,
|
|
||||||
Intent(Constants.HOMOCUBE_USB_PERMISSION),
|
|
||||||
PendingIntent.FLAG_MUTABLE
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
mPendingIntent = PendingIntent.getBroadcast(
|
mPendingIntent = PendingIntent.getBroadcast(
|
||||||
@@ -145,30 +137,46 @@ class HemocubeActivity : AppCompatActivity() {
|
|||||||
manager.requestPermission(device, mPendingIntent)
|
manager.requestPermission(device, mPendingIntent)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupService() {
|
fun setupService() {
|
||||||
val intent = Intent(this, UsbService::class.java)
|
val intent = Intent(this, UsbService::class.java)
|
||||||
// startService(intent)
|
|
||||||
bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun moveToNext() {
|
open fun reconnectDevice() {
|
||||||
if (supportFragmentManager.isDestroyed)
|
mService.disconnect()
|
||||||
return
|
unbindService(connection)
|
||||||
|
viewModel.isServiceConnected = false
|
||||||
supportFragmentManager.beginTransaction()
|
connectUsb(true)
|
||||||
.replace(binding.fghemocube.id, HemoCubeFragment()).commit()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun moveToNext() {
|
||||||
|
if (supportFragmentManager.isDestroyed) return
|
||||||
|
|
||||||
|
supportFragmentManager.beginTransaction().replace(binding.fghemocube.id, HemoCubeFragment())
|
||||||
|
.commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun onBackPressed() {
|
||||||
|
val fragment = supportFragmentManager.findFragmentById(R.id.fghemocube)
|
||||||
|
if (fragment is HemoCubeFragment) {
|
||||||
|
fragment.handleBackButtonPress()
|
||||||
|
} else {
|
||||||
|
super.onBackPressed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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)
|
if (!isFinishing) onBackPressed()
|
||||||
onBackPressed()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
|||||||
@@ -58,6 +58,40 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tv_subtitle3" />
|
app:layout_constraintTop_toBottomOf="@id/tv_subtitle3" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:visibility="gone"
|
||||||
|
android:id="@+id/btn_samplestart"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:clickable="false"
|
||||||
|
android:text="@string/Start_Sample"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/til_blood_group" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_placebuffer"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:clickable="false"
|
||||||
|
android:text="@string/place_buffer"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/btn_submit" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn_submit"
|
android:id="@+id/btn_submit"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -71,7 +105,6 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/til_blood_group" />
|
app:layout_constraintTop_toBottomOf="@id/til_blood_group" />
|
||||||
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
android:id="@+id/til_blood_group"
|
android:id="@+id/til_blood_group"
|
||||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
||||||
|
|||||||
@@ -112,6 +112,8 @@
|
|||||||
<string name="sickle_cert">Sickle Cert</string>
|
<string name="sickle_cert">Sickle Cert</string>
|
||||||
<string name="sickle_find">Sickle Find</string>
|
<string name="sickle_find">Sickle Find</string>
|
||||||
<string name="submit">Submit</string>
|
<string name="submit">Submit</string>
|
||||||
|
<string name="place_buffer">Start Buffer</string>
|
||||||
|
<string name="Start_Sample">Start Sample</string>
|
||||||
<string name="new_kit">New Kit</string>
|
<string name="new_kit">New Kit</string>
|
||||||
<string name="new_buffer">New Buffer</string>
|
<string name="new_buffer">New Buffer</string>
|
||||||
<string name="name_error_2">Invalid character, Allowed characters are Letters, Numbers and ( ) _ - , . only</string>
|
<string name="name_error_2">Invalid character, Allowed characters are Letters, Numbers and ( ) _ - , . only</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user