Compare commits
18 Commits
smi_131_re
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c0d5bc76e | ||
|
|
a82f72ac38 | ||
|
|
7779f362af | ||
|
|
07c778b0cc | ||
|
|
bb2fc0eb8f | ||
|
|
d1a6231716 | ||
|
|
35614e082f | ||
|
|
2637f84cac | ||
|
|
f5dc2f425b | ||
|
|
daf6dc81d4 | ||
|
|
9ed666e6e6 | ||
|
|
21b19188e5 | ||
|
|
04cf366042 | ||
|
|
b81666dffd | ||
|
|
63891fdade | ||
|
|
1400f71d61 | ||
|
|
70ba5077d6 | ||
|
|
179752b0b0 |
@@ -1,7 +1,4 @@
|
|||||||
# Latest hpos app version
|
|
||||||
## current version : 2.1.132
|
|
||||||
|
|
||||||
### Release key
|
### Release key
|
||||||
|
|
||||||
key0: prime24
|
key0: prime24
|
||||||
|
|
||||||
@@ -15,13 +15,13 @@ android {
|
|||||||
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 Testing, preprod -> preproduction, prod -> production, iocl -> iocl-iisc production
|
||||||
// server -> for server switching for internal test
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "in.sminnovations.hpostesting.server"
|
applicationId "in.sminnovations.hpostesting.dev"
|
||||||
minSdk 30
|
minSdk 21
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 134
|
versionCode 128
|
||||||
versionName "2.1.131"
|
versionName "2.1.128"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +30,6 @@ android {
|
|||||||
release {
|
release {
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
signingConfig signingConfigs.debug
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
@@ -77,6 +76,7 @@ dependencies {
|
|||||||
implementation platform('com.google.firebase:firebase-bom:32.1.0')
|
implementation platform('com.google.firebase:firebase-bom:32.1.0')
|
||||||
implementation("com.google.firebase:firebase-perf-ktx")
|
implementation("com.google.firebase:firebase-perf-ktx")
|
||||||
implementation("com.google.firebase:firebase-crashlytics-ktx")
|
implementation("com.google.firebase:firebase-crashlytics-ktx")
|
||||||
|
implementation("com.google.firebase:firebase-config-ktx")
|
||||||
implementation("com.google.firebase:firebase-analytics-ktx")
|
implementation("com.google.firebase:firebase-analytics-ktx")
|
||||||
implementation 'com.google.firebase:firebase-firestore-ktx'
|
implementation 'com.google.firebase:firebase-firestore-ktx'
|
||||||
implementation 'com.google.firebase:firebase-auth-ktx'
|
implementation 'com.google.firebase:firebase-auth-ktx'
|
||||||
@@ -124,6 +124,7 @@ dependencies {
|
|||||||
implementation 'com.github.mik3y:usb-serial-for-android:3.8.0'
|
implementation 'com.github.mik3y:usb-serial-for-android:3.8.0'
|
||||||
|
|
||||||
implementation "androidx.fragment:fragment-ktx:1.6.2"
|
implementation "androidx.fragment:fragment-ktx:1.6.2"
|
||||||
|
|
||||||
// CSV read, write
|
// CSV read, write
|
||||||
implementation 'com.opencsv:opencsv:5.9'
|
implementation 'com.opencsv:opencsv:5.9'
|
||||||
|
|
||||||
|
|||||||
@@ -1,33 +1,202 @@
|
|||||||
{
|
{
|
||||||
"project_info": {
|
"project_info": {
|
||||||
"project_number": "1012719870714",
|
"project_number": "650071678820",
|
||||||
"project_id": "hpos-prod",
|
"project_id": "hpos-af3cc",
|
||||||
"storage_bucket": "hpos-prod.appspot.com"
|
"storage_bucket": "hpos-af3cc.appspot.com"
|
||||||
},
|
},
|
||||||
"client": [
|
"client": [
|
||||||
{
|
{
|
||||||
"client_info": {
|
"client_info": {
|
||||||
"mobilesdk_app_id": "1:1012719870714:android:d8d7c962d96f4097de5f43",
|
"mobilesdk_app_id": "1:650071678820:android:f1435a1c07f710036c6471",
|
||||||
"android_client_info": {
|
"android_client_info": {
|
||||||
"package_name": "in.sminnovations.hpostesting.server"
|
"package_name": "com.example.hposconsentform"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"oauth_client": [
|
"oauth_client": [
|
||||||
{
|
{
|
||||||
"client_id": "1012719870714-uli6cdjea3lfnnueh6e4r15i10ei1vlj.apps.googleusercontent.com",
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
"client_type": 3
|
"client_type": 3
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"api_key": [
|
"api_key": [
|
||||||
{
|
{
|
||||||
"current_key": "AIzaSyA_O0oZGzy3Kiw9fiLQ3OFPME-xQJP88vs"
|
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"services": {
|
"services": {
|
||||||
"appinvite_service": {
|
"appinvite_service": {
|
||||||
"other_platform_oauth_client": [
|
"other_platform_oauth_client": [
|
||||||
{
|
{
|
||||||
"client_id": "1012719870714-uli6cdjea3lfnnueh6e4r15i10ei1vlj.apps.googleusercontent.com",
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:650071678820:android:7865bef608cdee6f6c6471",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "com.smi.counselling"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:650071678820:android:2925e9ce3417d2386c6471",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "in.sminnovations.hemocube"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-srhm9spm9hjn4frcd3r6o02gdhdbtd15.apps.googleusercontent.com",
|
||||||
|
"client_type": 1,
|
||||||
|
"android_info": {
|
||||||
|
"package_name": "in.sminnovations.hemocube",
|
||||||
|
"certificate_hash": "7714b9268a81d0cf0fb178b0af8dbb630f8fc70a"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:650071678820:android:7569c1cad4fc99916c6471",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "in.sminnovations.hposregistration"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-70kp5jvjda4r5diqch2kn4lc40p4f42g.apps.googleusercontent.com",
|
||||||
|
"client_type": 1,
|
||||||
|
"android_info": {
|
||||||
|
"package_name": "in.sminnovations.hposregistration",
|
||||||
|
"certificate_hash": "7714b9268a81d0cf0fb178b0af8dbb630f8fc70a"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:650071678820:android:f96be19e5d43102b6c6471",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "in.sminnovations.hpostesting"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-l87dnr0bdj95get0khgnvfv2an1k6ogq.apps.googleusercontent.com",
|
||||||
|
"client_type": 1,
|
||||||
|
"android_info": {
|
||||||
|
"package_name": "in.sminnovations.hpostesting",
|
||||||
|
"certificate_hash": "7714b9268a81d0cf0fb178b0af8dbb630f8fc70a"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:650071678820:android:a53292637abb7c0d6c6471",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "in.sminnovations.hpostesting.dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
"client_type": 3
|
"client_type": 3
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
"type": "SINGLE",
|
"type": "SINGLE",
|
||||||
"filters": [],
|
"filters": [],
|
||||||
"attributes": [],
|
"attributes": [],
|
||||||
"versionCode": 127,
|
"versionCode": 128,
|
||||||
"versionName": "2.1.127",
|
"versionName": "2.1.128",
|
||||||
"outputFile": "app-release.apk"
|
"outputFile": "app-release.apk"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -25,12 +25,6 @@
|
|||||||
|
|
||||||
<uses-permission android:name="android.permission.USB_PERMISSION" />
|
<uses-permission android:name="android.permission.USB_PERMISSION" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
|
||||||
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
|
|
||||||
<uses-permission android:name="android.permission.ACCOUNT_MANAGER"
|
|
||||||
tools:ignore="ProtectedPermissions" />
|
|
||||||
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name="com.example.hpostesting.HPOSTestingApplication"
|
android:name="com.example.hpostesting.HPOSTestingApplication"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
@@ -44,7 +38,7 @@
|
|||||||
android:theme="@style/Theme.HPOSTesting"
|
android:theme="@style/Theme.HPOSTesting"
|
||||||
tools:targetApi="31">
|
tools:targetApi="31">
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.main_base.UpdateValuesActivity"
|
android:name="com.example.hpostesting.presentation.dashboard.UpdateValuesActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:screenOrientation="portrait"/>
|
android:screenOrientation="portrait"/>
|
||||||
|
|
||||||
@@ -62,7 +56,7 @@
|
|||||||
</service>
|
</service>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.main_base.ui.PasswordResetActivity"
|
android:name="com.example.hpostesting.presentation.dashboard.ui.PasswordResetActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
<activity
|
<activity
|
||||||
@@ -74,7 +68,7 @@
|
|||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:theme="@style/Theme.HPOS.NoActionBar" />
|
android:theme="@style/Theme.HPOS.NoActionBar" />
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.trueheme_test.DigitalCardActivity"
|
android:name="com.example.hpostesting.presentation.hemocube.DigitalCardActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.diagnostics.DiagnosticsActivity"
|
android:name="com.example.hpostesting.presentation.diagnostics.DiagnosticsActivity"
|
||||||
@@ -90,7 +84,7 @@
|
|||||||
android:theme="@style/Theme.HPOS.NoActionBar" />
|
android:theme="@style/Theme.HPOS.NoActionBar" />
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.jig.JigActivity"
|
android:name="com.example.hpostesting.presentation.jig.JigActivity"
|
||||||
android:exported="true"
|
android:exported="false"
|
||||||
android:theme="@style/Theme.HPOS.NoActionBar" />
|
android:theme="@style/Theme.HPOS.NoActionBar" />
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.deviceprovision.DeviceProvisionActivity"
|
android:name="com.example.hpostesting.presentation.deviceprovision.DeviceProvisionActivity"
|
||||||
@@ -106,7 +100,7 @@
|
|||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/Theme.HPOS.NoActionBar" />
|
android:theme="@style/Theme.HPOS.NoActionBar" />
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.trueheme_test.TrueHemeTestActivity"
|
android:name="com.example.hpostesting.presentation.hemocube.HemocubeActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:noHistory="true"
|
android:noHistory="true"
|
||||||
android:parentActivityName="com.example.hpostesting.presentation.MainActivity"
|
android:parentActivityName="com.example.hpostesting.presentation.MainActivity"
|
||||||
@@ -133,8 +127,8 @@
|
|||||||
android:noHistory="true"
|
android:noHistory="true"
|
||||||
android:theme="@style/Theme.HPOS.NoActionBar" />
|
android:theme="@style/Theme.HPOS.NoActionBar" />
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.main_base.DashboardActivity"
|
android:name="com.example.hpostesting.presentation.dashboard.DashboardActivity"
|
||||||
android:exported="true"
|
android:exported="false"
|
||||||
android:label="@string/title_activity_dashboard"
|
android:label="@string/title_activity_dashboard"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/Theme.HPOS.NoActionBar"
|
android:theme="@style/Theme.HPOS.NoActionBar"
|
||||||
@@ -176,7 +170,7 @@
|
|||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.testRight.TestRightActivity"
|
android:name="com.example.hpostesting.presentation.testRight.TestRightActivity"
|
||||||
android:exported="true"
|
android:exported="false"
|
||||||
android:noHistory="true"
|
android:noHistory="true"
|
||||||
android:parentActivityName="com.example.hpostesting.presentation.MainActivity"
|
android:parentActivityName="com.example.hpostesting.presentation.MainActivity"
|
||||||
android:theme="@style/Theme.HPOS.NoActionBar"
|
android:theme="@style/Theme.HPOS.NoActionBar"
|
||||||
|
|||||||
@@ -14,29 +14,25 @@
|
|||||||
package com.example.hpostesting
|
package com.example.hpostesting
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import com.example.hpostesting.firebase.FirebaseManager
|
|
||||||
import com.google.firebase.firestore.FirebaseFirestore
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
import com.google.firebase.firestore.FirebaseFirestoreSettings
|
import com.google.firebase.firestore.FirebaseFirestoreSettings
|
||||||
import dagger.hilt.android.HiltAndroidApp
|
import dagger.hilt.android.HiltAndroidApp
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.SupervisorJob
|
import kotlinx.coroutines.SupervisorJob
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@HiltAndroidApp
|
@HiltAndroidApp
|
||||||
class HPOSTestingApplication : Application() {
|
class HPOSTestingApplication : Application() {
|
||||||
@Inject
|
val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||||
lateinit var firebaseManager: FirebaseManager
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||||
|
|
||||||
// You can now use firebaseManager here after Hilt injects it
|
|
||||||
val firestoreSettings = FirebaseFirestoreSettings.Builder()
|
val firestoreSettings = FirebaseFirestoreSettings.Builder()
|
||||||
.setPersistenceEnabled(true) // Enable offline persistence if needed
|
.setPersistenceEnabled(true) // Enable offline persistence if needed
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val firestore = firebaseManager.getCurrentFirestore()
|
val firestore = FirebaseFirestore.getInstance()
|
||||||
firestore.firestoreSettings = firestoreSettings
|
firestore.firestoreSettings = firestoreSettings
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,8 +28,8 @@ object Constants {
|
|||||||
const val DOCUMENT_ID_FOR_UPDATE ="2o71vBKLqdgEKYtFG8Lb"
|
const val DOCUMENT_ID_FOR_UPDATE ="2o71vBKLqdgEKYtFG8Lb"
|
||||||
const val ABHA_APP_PACKAGE = "in.ndhm.phr"
|
const val ABHA_APP_PACKAGE = "in.ndhm.phr"
|
||||||
|
|
||||||
const val MOLBIO_INTEGRATION = true
|
const val MOLBIO_INTEGRATION = false
|
||||||
const val FIREBASE_INTEGRATION = false
|
const val FIREBASE_INTEGRATION = true
|
||||||
const val deviceProvisionEmail = "HPOS_provisioner@bigtec.co.in"
|
const val deviceProvisionEmail = "HPOS_provisioner@bigtec.co.in"
|
||||||
const val deviceProvisionPassword = "f2ab0e7f9d69"
|
const val deviceProvisionPassword = "f2ab0e7f9d69"
|
||||||
const val DEVICE_ID_API = "deviceIDAPI"
|
const val DEVICE_ID_API = "deviceIDAPI"
|
||||||
@@ -108,6 +108,7 @@ object Constants {
|
|||||||
const val DEVICE_ID = "DEVICE_ID"
|
const val DEVICE_ID = "DEVICE_ID"
|
||||||
const val LABNAME = "LAB_NAME"
|
const val LABNAME = "LAB_NAME"
|
||||||
const val CUVETTE_SIZE = "CUVETTE_SIZE"
|
const val CUVETTE_SIZE = "CUVETTE_SIZE"
|
||||||
|
const val LAST_UPDATED = "LAST_UPDATED"
|
||||||
const val IS_TOKEN_AVAILABLE = "IS_TOKEN_AVAILABLE"
|
const val IS_TOKEN_AVAILABLE = "IS_TOKEN_AVAILABLE"
|
||||||
const val BUFFER_LED_LOWER_BOUND = 21000
|
const val BUFFER_LED_LOWER_BOUND = 21000
|
||||||
const val BUFFER_LED_UPPER_BOUND = 23500
|
const val BUFFER_LED_UPPER_BOUND = 23500
|
||||||
@@ -1583,31 +1584,26 @@ object Constants {
|
|||||||
listOf(0.0, 0.0)
|
listOf(0.0, 0.0)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
//Trueheme for 10mm
|
//Hemocube for 10mm
|
||||||
//Before changing below values review before
|
const val positiveBoderLine10mm1 = 1.3
|
||||||
//classification borderline metric
|
const val positiveBoderLine10mm2 = 1.66
|
||||||
const val positiveBoderLineMetricCheck10mmMin = 1.3
|
const val negativeBoderLine10mm1 = 2.0
|
||||||
const val positiveBoderLineMetricCheck10mmMax = 1.66
|
const val negativeBoderLine10mm2 = 2.4
|
||||||
const val negativeBoderLineMetricCheck10mmMin = 2.0
|
|
||||||
const val negativeBoderLineMetricCheck10mmMax = 2.4
|
|
||||||
//classification device ratio
|
|
||||||
const val normalMin10mm = 0.07
|
const val normalMin10mm = 0.07
|
||||||
const val normalMax10mm = 0.23
|
const val normalMax10mm = 0.23
|
||||||
const val negativeBorderlineMin10mm = 0.23
|
const val negativeBorderlineMin10mm = 0.23
|
||||||
const val negativeBorderlineMax10mm = 0.27
|
const val negativeBorderlineMax10mm = 0.27
|
||||||
const val sickleCellTraitMin10mm = 0.27
|
const val sickleCellTraitMin10mm = 0.27
|
||||||
const val sickleCellTraitMax10mm = 0.31
|
const val sickleCellTraitMax10mm = 0.31
|
||||||
const val positiveBoderlineMin10mm = 0.31
|
const val positiveForSickleCellMin10mm = 0.31
|
||||||
const val positiveBoderlineMax10mm = 0.39
|
const val positiveForSickleCellMax10mm = 0.39
|
||||||
const val sickleCellDiseaseMin10mm = 0.39
|
const val sickleCellDiseaseMin10mm = 0.39
|
||||||
const val sickleCellDiseaseMax10mm = 0.7
|
const val sickleCellDiseaseMax10mm = 0.7
|
||||||
//Trueheme for 2mm
|
//Hemocube for 2mm
|
||||||
//classification borderline metric
|
const val positiveBoderLine2mm1 = 0.8
|
||||||
const val positiveBoderLineMetricCheck2mmMin = 0.8
|
const val positiveBoderLine2mm2 = 1.1
|
||||||
const val positiveBoderLineMetricCheck2mmMax = 1.1
|
const val negativeBoderLine2mm1 = 1.5
|
||||||
const val negativeBoderLineMetricCheck2mmMin = 1.5
|
const val negativeBoderLine2mm2 = 1.9
|
||||||
const val negativeBoderLineMetricCheck2mmMax = 1.9
|
|
||||||
//classification device ratio
|
|
||||||
const val normalMin2mm = 0.1
|
const val normalMin2mm = 0.1
|
||||||
const val normalMax2mm = 0.23
|
const val normalMax2mm = 0.23
|
||||||
const val negativeBorderlineMin2mm = 0.23
|
const val negativeBorderlineMin2mm = 0.23
|
||||||
@@ -1628,7 +1624,6 @@ object Constants {
|
|||||||
const val min10mmLed2 = 0.05
|
const val min10mmLed2 = 0.05
|
||||||
const val max10mmLed2 = 0.41
|
const val max10mmLed2 = 0.41
|
||||||
|
|
||||||
//Check used in handling the buffer values on buffer complete
|
|
||||||
const val bufferMinLed1 = 21000.00
|
const val bufferMinLed1 = 21000.00
|
||||||
const val bufferMaxLed1 = 23000.00
|
const val bufferMaxLed1 = 23000.00
|
||||||
const val bufferMinLed2 = 17000.00
|
const val bufferMinLed2 = 17000.00
|
||||||
|
|||||||
@@ -14,9 +14,6 @@
|
|||||||
package com.example.hpostesting.data.repository
|
package com.example.hpostesting.data.repository
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.annotation.RequiresApi
|
|
||||||
import com.example.hpostesting.util.Result
|
import com.example.hpostesting.util.Result
|
||||||
import com.example.hpostesting.data.api.MolbioAuthApi
|
import com.example.hpostesting.data.api.MolbioAuthApi
|
||||||
import com.example.hpostesting.data.api.MolbioResultApi
|
import com.example.hpostesting.data.api.MolbioResultApi
|
||||||
@@ -40,18 +37,17 @@ import com.example.hpostesting.data.model.patient.UserData
|
|||||||
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
||||||
import com.example.hpostesting.data.model.updates.CheckUpdateResponse
|
import com.example.hpostesting.data.model.updates.CheckUpdateResponse
|
||||||
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
||||||
import com.example.hpostesting.firebase.FirebaseManager
|
|
||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
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.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import com.google.firebase.storage.FirebaseStorage
|
import com.google.firebase.storage.ktx.storage
|
||||||
import kotlinx.coroutines.tasks.await
|
import kotlinx.coroutines.tasks.await
|
||||||
import okhttp3.MultipartBody
|
import okhttp3.MultipartBody
|
||||||
import okhttp3.ResponseBody
|
import okhttp3.ResponseBody
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.ConnectException
|
import java.net.ConnectException
|
||||||
import java.net.SocketTimeoutException
|
import java.net.SocketTimeoutException
|
||||||
import java.time.LocalTime
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Named
|
import javax.inject.Named
|
||||||
|
|
||||||
@@ -59,30 +55,11 @@ class NetworkException(message: String, cause: Throwable) : Exception(message, c
|
|||||||
class DatabaseRepository @Inject constructor(
|
class DatabaseRepository @Inject constructor(
|
||||||
@Named("Auth") private val molbioAuthApi: MolbioAuthApi,
|
@Named("Auth") private val molbioAuthApi: MolbioAuthApi,
|
||||||
private val molbioResultApi: MolbioResultApi,
|
private val molbioResultApi: MolbioResultApi,
|
||||||
private val firebaseManager: FirebaseManager,
|
|
||||||
) : Repository {
|
) : Repository {
|
||||||
|
|
||||||
private val localdb: FirebaseFirestore
|
private val db: FirebaseFirestore = Firebase.firestore
|
||||||
get() = firebaseManager.getCurrentFirestore()
|
private val storage = Firebase.storage
|
||||||
|
|
||||||
private val localStg: FirebaseStorage
|
|
||||||
get() = firebaseManager.getCurrentStorage()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// // Example function to add data to Firestore , like the basic data as test data
|
|
||||||
// @RequiresApi(Build.VERSION_CODES.O)
|
|
||||||
// fun addtodb(data: String) {
|
|
||||||
// val date = LocalTime.now()
|
|
||||||
// localdb.collection("BasicData")
|
|
||||||
// .add(mapOf("data $date" to data))
|
|
||||||
// .addOnSuccessListener {
|
|
||||||
// Log.d("UPLOAD", "Data uploaded successfully ${localdb.app.name}")
|
|
||||||
// }
|
|
||||||
// .addOnFailureListener { exception ->
|
|
||||||
// Log.d("UPLOAD", "Failed to upload data: ${exception.message} ${localdb.app.name}")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
private suspend fun <T : Any> safeApiCall(apiCall: suspend () -> T): Result<T> {
|
private suspend fun <T : Any> safeApiCall(apiCall: suspend () -> T): Result<T> {
|
||||||
return try {
|
return try {
|
||||||
val response = apiCall.invoke()
|
val response = apiCall.invoke()
|
||||||
@@ -131,13 +108,13 @@ class DatabaseRepository @Inject constructor(
|
|||||||
override suspend fun addTestToDatabase(data: HemoCubeTestData?): Response<String> {
|
override suspend fun addTestToDatabase(data: HemoCubeTestData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
val userdata =
|
val userdata =
|
||||||
localdb.collection("patientData").whereEqualTo("_id", data!!._id).get().await()
|
db.collection("patientData").whereEqualTo("_id", data!!._id).get().await()
|
||||||
if (userdata.documents.isNotEmpty()) {
|
if (userdata.documents.isNotEmpty()) {
|
||||||
userdata.documents.forEach {
|
userdata.documents.forEach {
|
||||||
localdb.collection("patientData").document(it.id).update("testStatus", true)
|
db.collection("patientData").document(it.id).update("testStatus", true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
localdb.collection("testData").add(data).await()
|
db.collection("testData").add(data).await()
|
||||||
Response.Success(data._id)
|
Response.Success(data._id)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Response.Error(e)
|
Response.Error(e)
|
||||||
@@ -146,7 +123,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
override suspend fun addQcTestToDatabase(data: HemoCubeTestData?): Response<String> {
|
override suspend fun addQcTestToDatabase(data: HemoCubeTestData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
|
|
||||||
localdb.collection("qcData").add(data!!).await()
|
db.collection("qcData").add(data!!).await()
|
||||||
Response.Success(data._id)
|
Response.Success(data._id)
|
||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@@ -160,7 +137,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
|
|
||||||
override suspend fun addTestToDatabaseforBufferCheck(data: BufferCheckData?): Response<String> {
|
override suspend fun addTestToDatabaseforBufferCheck(data: BufferCheckData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
localdb.collection("buffers").add(data!!).await()
|
db.collection("buffers").add(data!!).await()
|
||||||
Response.Success(data.kitno)
|
Response.Success(data.kitno)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
@@ -170,7 +147,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
|
|
||||||
override suspend fun addDiagnostics(data: DiagnosticsData?): Response<String> {
|
override suspend fun addDiagnostics(data: DiagnosticsData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
localdb.collection("diagnostics").add(data!!).await()
|
db.collection("diagnostics").add(data!!).await()
|
||||||
Response.Success(data.deviceId)
|
Response.Success(data.deviceId)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
@@ -181,7 +158,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
|
|
||||||
override suspend fun addTestJigData(data: JigData?): Response<String> {
|
override suspend fun addTestJigData(data: JigData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
localdb.collection("jigs").add(data!!).await()
|
db.collection("jigs").add(data!!).await()
|
||||||
Response.Success(data.deviceId)
|
Response.Success(data.deviceId)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
@@ -195,7 +172,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
val file = Uri.fromFile(File(filePath))
|
val file = Uri.fromFile(File(filePath))
|
||||||
val riversRef = localStg.reference.child("$patientID/${file.lastPathSegment}")
|
val riversRef = storage.reference.child("$patientID/${file.lastPathSegment}")
|
||||||
riversRef.putFile(file).await()
|
riversRef.putFile(file).await()
|
||||||
return Response.Success(true)
|
return Response.Success(true)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@@ -206,7 +183,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
|
|
||||||
suspend fun addToPendingQueue(pendingUploads: PendingUploads): Response<Boolean> {
|
suspend fun addToPendingQueue(pendingUploads: PendingUploads): Response<Boolean> {
|
||||||
return try {
|
return try {
|
||||||
localdb.collection("pendingUploads").document(pendingUploads.pendingId).set(pendingUploads)
|
db.collection("pendingUploads").document(pendingUploads.pendingId).set(pendingUploads)
|
||||||
.await()
|
.await()
|
||||||
|
|
||||||
Response.Success(true)
|
Response.Success(true)
|
||||||
@@ -219,7 +196,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
suspend fun getAllFromPendingQueue(): List<PendingUploads> {
|
suspend fun getAllFromPendingQueue(): List<PendingUploads> {
|
||||||
val pendingList = mutableListOf<PendingUploads>()
|
val pendingList = mutableListOf<PendingUploads>()
|
||||||
return try {
|
return try {
|
||||||
val querySnapshot = localdb.collection("pendingUploads").orderBy("timeAdded").get().await()
|
val querySnapshot = db.collection("pendingUploads").orderBy("timeAdded").get().await()
|
||||||
|
|
||||||
for (doc in querySnapshot.documents) {
|
for (doc in querySnapshot.documents) {
|
||||||
val pendingFile = doc.toObject(PendingUploads::class.java)
|
val pendingFile = doc.toObject(PendingUploads::class.java)
|
||||||
@@ -237,7 +214,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
|
|
||||||
suspend fun removeFromPendingQueue(fileName: String): Response<Boolean> {
|
suspend fun removeFromPendingQueue(fileName: String): Response<Boolean> {
|
||||||
return try {
|
return try {
|
||||||
localdb.collection("pendingUploads").document(fileName).delete().await()
|
db.collection("pendingUploads").document(fileName).delete().await()
|
||||||
|
|
||||||
Response.Success(true)
|
Response.Success(true)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@@ -247,11 +224,11 @@ class DatabaseRepository @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getDeviceData(): List<DeviceData> {
|
suspend fun getDeviceData(): List<DeviceData> {
|
||||||
return localdb.collection("devices").get().await().toObjects(DeviceData::class.java)
|
return db.collection("devices").get().await().toObjects(DeviceData::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getDeviceDataById(deviceId: String): DeviceData? {
|
override suspend fun getDeviceDataById(deviceId: String): DeviceData? {
|
||||||
val querySnapshot = localdb.collection("devices").get().await()
|
val querySnapshot = db.collection("devices").get().await()
|
||||||
val allDeviceDataList = querySnapshot.toObjects(DeviceData::class.java)
|
val allDeviceDataList = querySnapshot.toObjects(DeviceData::class.java)
|
||||||
|
|
||||||
// Find the DeviceData object with the specified deviceId
|
// Find the DeviceData object with the specified deviceId
|
||||||
@@ -260,7 +237,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
|
|
||||||
override suspend fun getDeviceResponse(data: DeviceData?): Response<String> {
|
override suspend fun getDeviceResponse(data: DeviceData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
localdb.collection("devices").add(data!!).await()
|
db.collection("devices").add(data!!).await()
|
||||||
Response.Success(data.deviceProvisionResponse)
|
Response.Success(data.deviceProvisionResponse)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
@@ -270,7 +247,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
|
|
||||||
override suspend fun uploadDeviceId(data: DeviceData): Response<String>? {
|
override suspend fun uploadDeviceId(data: DeviceData): Response<String>? {
|
||||||
return try {
|
return try {
|
||||||
localdb.collection("devices").add(data!!).await()
|
db.collection("devices").add(data!!).await()
|
||||||
Response.Success(data.deviceId)
|
Response.Success(data.deviceId)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
@@ -285,13 +262,13 @@ class DatabaseRepository @Inject constructor(
|
|||||||
override suspend fun addTestToDatabasefornew(data: HemoCubeTestData?): Response<String> {
|
override suspend fun addTestToDatabasefornew(data: HemoCubeTestData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
val userdata =
|
val userdata =
|
||||||
localdb.collection("patientData").whereEqualTo("_id", data!!._id).get().await()
|
db.collection("patientData").whereEqualTo("_id", data!!._id).get().await()
|
||||||
if (userdata.documents.isNotEmpty()) {
|
if (userdata.documents.isNotEmpty()) {
|
||||||
userdata.documents.forEach {
|
userdata.documents.forEach {
|
||||||
localdb.collection("patientData").document(it.id).update("testStatus", true)
|
db.collection("patientData").document(it.id).update("testStatus", true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
localdb.collection("testData").add(data).await()
|
db.collection("testData").add(data).await()
|
||||||
Response.Success(data._id)
|
Response.Success(data._id)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import androidx.room.Room
|
|||||||
import com.example.hpostesting.data.api.MolbioAuthApi
|
import com.example.hpostesting.data.api.MolbioAuthApi
|
||||||
import com.example.hpostesting.data.api.MolbioResultApi
|
import com.example.hpostesting.data.api.MolbioResultApi
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.util.PropertyProvider
|
||||||
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
||||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||||
import com.example.hpostesting.data.dao.MyDatabase
|
import com.example.hpostesting.data.dao.MyDatabase
|
||||||
@@ -35,14 +36,9 @@ import com.example.hpostesting.domain.LogFileManager
|
|||||||
import com.example.hpostesting.domain.LogFileManagerImpl
|
import com.example.hpostesting.domain.LogFileManagerImpl
|
||||||
import com.example.hpostesting.domain.SaveRawData
|
import com.example.hpostesting.domain.SaveRawData
|
||||||
import com.example.hpostesting.domain.SaveRawDataTest
|
import com.example.hpostesting.domain.SaveRawDataTest
|
||||||
import com.example.hpostesting.firebase.FirebaseManager
|
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListenerImpl
|
import com.example.hpostesting.presentation.utils.UsbServiceListenerImpl
|
||||||
import com.example.hpostesting.util.NetworkMonitor
|
|
||||||
import com.example.hpostesting.util.PropertyProvider
|
|
||||||
import com.example.hpostesting.util.PropertyProviderImpl
|
import com.example.hpostesting.util.PropertyProviderImpl
|
||||||
import com.google.firebase.firestore.FirebaseFirestore
|
|
||||||
import com.google.firebase.storage.FirebaseStorage
|
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import dagger.hilt.InstallIn
|
import dagger.hilt.InstallIn
|
||||||
@@ -111,52 +107,22 @@ object AppModule {
|
|||||||
return SaveRawDataTest(repository)
|
return SaveRawDataTest(repository)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
fun provideFirebaseFirestore(): FirebaseFirestore {
|
|
||||||
return FirebaseFirestore.getInstance()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
fun provideFirebaseStorage(): FirebaseStorage {
|
|
||||||
return FirebaseStorage.getInstance()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
fun provideFirebaseManager(
|
|
||||||
@ApplicationContext context: Context,
|
|
||||||
): FirebaseManager {
|
|
||||||
return FirebaseManager(context)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun provideDatabaseRepository(
|
fun provideDatabaseRepository(
|
||||||
firebaseManager: FirebaseManager,
|
|
||||||
@Named("Auth") molbioAuthApi: MolbioAuthApi,
|
@Named("Auth") molbioAuthApi: MolbioAuthApi,
|
||||||
molbioResultApi: MolbioResultApi
|
molbioResultApi: MolbioResultApi
|
||||||
): DatabaseRepository {
|
): DatabaseRepository {
|
||||||
return DatabaseRepository(
|
return DatabaseRepository(molbioAuthApi = molbioAuthApi, molbioResultApi = molbioResultApi)
|
||||||
firebaseManager = firebaseManager,
|
|
||||||
molbioAuthApi = molbioAuthApi,
|
|
||||||
molbioResultApi = molbioResultApi
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun provideRepository(
|
fun provideRepository(
|
||||||
firebaseManager: FirebaseManager,
|
|
||||||
@Named("Auth") molbioAuthApi: MolbioAuthApi,
|
@Named("Auth") molbioAuthApi: MolbioAuthApi,
|
||||||
molbioResultApi: MolbioResultApi
|
molbioResultApi: MolbioResultApi
|
||||||
): Repository {
|
): Repository {
|
||||||
return DatabaseRepository(
|
return DatabaseRepository(molbioAuthApi, molbioResultApi)
|
||||||
firebaseManager = firebaseManager,
|
|
||||||
molbioAuthApi = molbioAuthApi,
|
|
||||||
molbioResultApi = molbioResultApi
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@@ -240,13 +206,4 @@ object AppModule {
|
|||||||
fun provideUsbServiceListener(context: Context): UsbServiceListener {
|
fun provideUsbServiceListener(context: Context): UsbServiceListener {
|
||||||
return UsbServiceListenerImpl(context)
|
return UsbServiceListenerImpl(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
fun provideNetworkMonitor(
|
|
||||||
@ApplicationContext context: Context
|
|
||||||
): NetworkMonitor {
|
|
||||||
return NetworkMonitor(context).apply { startMonitoring() }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,174 +0,0 @@
|
|||||||
package com.example.hpostesting.firebase
|
|
||||||
/*
|
|
||||||
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
|
||||||
* // Notice: All information contained herein is, and remains
|
|
||||||
* // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
|
||||||
* // if any. The intellectual and technical concepts contained
|
|
||||||
* // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
|
||||||
* // and its suppliers and may be covered by Indian and Foreign Patents,
|
|
||||||
* // patents in process, and are protected by trade secret or copyright law.
|
|
||||||
* // Dissemination of this information or reproduction of this material
|
|
||||||
* // is strictly forbidden unless prior written permission is obtained
|
|
||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
|
||||||
*/
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.os.Process
|
|
||||||
import androidx.core.content.edit
|
|
||||||
import com.google.firebase.FirebaseApp
|
|
||||||
import com.google.firebase.FirebaseOptions
|
|
||||||
import com.google.firebase.firestore.FirebaseFirestore
|
|
||||||
import com.google.firebase.storage.FirebaseStorage
|
|
||||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.GlobalScope
|
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
class FirebaseManager @Inject constructor(private val context: Context) {
|
|
||||||
|
|
||||||
private val sharedPreferencesServerConfig = context.getSharedPreferences("FirebaseConfigPrefs", Context.MODE_PRIVATE)
|
|
||||||
private val sharedPreferencesDev = context.getSharedPreferences("DevMode",Context.MODE_PRIVATE)
|
|
||||||
|
|
||||||
private var currentFirestore: FirebaseFirestore = FirebaseFirestore.getInstance()
|
|
||||||
private var currentStorage: FirebaseStorage = FirebaseStorage.getInstance()
|
|
||||||
var updateStatus = false
|
|
||||||
|
|
||||||
private val defaultServers = listOf(
|
|
||||||
// i have it in different place look down
|
|
||||||
firebaseConfigProd, firebaseConfigDev , firebaseConfigQaQc, firebaseConfigPreProd
|
|
||||||
)
|
|
||||||
|
|
||||||
init {
|
|
||||||
val lastSelectedServer = getLastSelectedServer()
|
|
||||||
switchServer(lastSelectedServer)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fun setDevModeOn(state : Boolean){
|
|
||||||
sharedPreferencesDev.edit {
|
|
||||||
putBoolean( "isDevModeOn",state )
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getDevMode(): Boolean {
|
|
||||||
return sharedPreferencesDev.getBoolean("isDevModeOn",false)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fun getCurrentFirestore(): FirebaseFirestore = currentFirestore
|
|
||||||
fun getCurrentStorage(): FirebaseStorage = currentStorage
|
|
||||||
|
|
||||||
fun switchServer(firebaseConfig: FirebaseConfig) {
|
|
||||||
saveSelectedServer(firebaseConfig)
|
|
||||||
val firebaseApp = getOrInitializeFirebaseApp(firebaseConfig)
|
|
||||||
currentFirestore = FirebaseFirestore.getInstance(firebaseApp)
|
|
||||||
currentStorage = FirebaseStorage.getInstance(firebaseApp)
|
|
||||||
updateStatus = true
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getOrInitializeFirebaseApp(firebaseConfig: FirebaseConfig): FirebaseApp {
|
|
||||||
val existingApp = FirebaseApp.getApps(context).find { it.name == firebaseConfig.serverName }
|
|
||||||
|
|
||||||
return if (existingApp != null) {
|
|
||||||
|
|
||||||
existingApp
|
|
||||||
} else {
|
|
||||||
|
|
||||||
val options = FirebaseOptions.Builder().setProjectId(firebaseConfig.projectId)
|
|
||||||
.setApplicationId(firebaseConfig.appId).setApiKey(firebaseConfig.apiKey)
|
|
||||||
.setStorageBucket(firebaseConfig.storageBucket).build()
|
|
||||||
|
|
||||||
FirebaseApp.initializeApp(context, options, firebaseConfig.serverName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun saveSelectedServer(firebaseConfig: FirebaseConfig) {
|
|
||||||
with(sharedPreferencesServerConfig.edit()) {
|
|
||||||
putString("selectedServerName", firebaseConfig.serverName)
|
|
||||||
putString("projectId", firebaseConfig.projectId)
|
|
||||||
putString("appId", firebaseConfig.appId)
|
|
||||||
putString("apiKey", firebaseConfig.apiKey)
|
|
||||||
putString("storageBucket", firebaseConfig.storageBucket)
|
|
||||||
apply()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fun restartApp() {
|
|
||||||
if (updateStatus) {
|
|
||||||
updateStatus = false
|
|
||||||
delayedRestart(context)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getLastSelectedServer(): FirebaseConfig {
|
|
||||||
val selectedServerName =
|
|
||||||
sharedPreferencesServerConfig.getString("selectedServerName", defaultServers.first().serverName)
|
|
||||||
val projectId = sharedPreferencesServerConfig.getString("projectId", defaultServers.first().projectId)
|
|
||||||
val appId = sharedPreferencesServerConfig.getString("appId", defaultServers.first().appId)
|
|
||||||
val apiKey = sharedPreferencesServerConfig.getString("apiKey", defaultServers.first().apiKey)
|
|
||||||
val storageBucket =
|
|
||||||
sharedPreferencesServerConfig.getString("storageBucket", defaultServers.first().storageBucket)
|
|
||||||
|
|
||||||
return FirebaseConfig(
|
|
||||||
serverName = selectedServerName ?: defaultServers.first().serverName,
|
|
||||||
projectId = projectId ?: defaultServers.first().projectId,
|
|
||||||
appId = appId ?: defaultServers.first().appId,
|
|
||||||
apiKey = apiKey ?: defaultServers.first().apiKey,
|
|
||||||
storageBucket = storageBucket ?: defaultServers.first().storageBucket
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getAvailableServers(): List<FirebaseConfig> {
|
|
||||||
return defaultServers
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun restartApp(context: Context) {
|
|
||||||
val intent = context.packageManager.getLaunchIntentForPackage(context.packageName)
|
|
||||||
intent?.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
||||||
context.startActivity(intent)
|
|
||||||
Process.killProcess(Process.myPid())
|
|
||||||
}
|
|
||||||
@OptIn(DelicateCoroutinesApi::class)
|
|
||||||
fun delayedRestart(context: Context) {
|
|
||||||
GlobalScope.launch(Dispatchers.Main) {
|
|
||||||
delay(5000L)
|
|
||||||
restartApp(context)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val firebaseConfigDev = FirebaseConfig(
|
|
||||||
serverName = "dev",
|
|
||||||
apiKey = "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I",
|
|
||||||
appId = "1:650071678820:android:a53292637abb7c0d6c6471",
|
|
||||||
projectId = "hpos-af3cc",
|
|
||||||
storageBucket = "hpos-af3cc.appspot.com"
|
|
||||||
)
|
|
||||||
|
|
||||||
private val firebaseConfigQaQc = FirebaseConfig(
|
|
||||||
serverName = "qc-qa",
|
|
||||||
apiKey = "AIzaSyC4d4GhWHr_NMJAeBvnztQ_yQ3Qe9MAnLs",
|
|
||||||
appId = "1:1004619739289:android:3dbcefb10ea99654e5c808",
|
|
||||||
projectId = "hpos-qa",
|
|
||||||
storageBucket = "hpos-qa.appspot.com"
|
|
||||||
)
|
|
||||||
|
|
||||||
private val firebaseConfigProd = FirebaseConfig(
|
|
||||||
serverName = "prod",
|
|
||||||
apiKey = "AIzaSyA_O0oZGzy3Kiw9fiLQ3OFPME-xQJP88vs",
|
|
||||||
appId = "1:1012719870714:android:d8d7c962d96f4097de5f43",
|
|
||||||
projectId = "hpos-prod",
|
|
||||||
storageBucket = "hpos-prod.appspot.com"
|
|
||||||
)
|
|
||||||
|
|
||||||
private val firebaseConfigPreProd = FirebaseConfig(
|
|
||||||
serverName = "pre prod",
|
|
||||||
apiKey = "AIzaSyDYySi27LioZGNisP1NfnNU5inJX_0FT38",
|
|
||||||
appId = "1:121176529204:android:e6841fdac57bdc95bbed61",
|
|
||||||
projectId = "hpos-preprod",
|
|
||||||
storageBucket = "hpos-preprod.appspot.com"
|
|
||||||
)
|
|
||||||
@@ -19,6 +19,7 @@ import android.content.SharedPreferences
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.Editable
|
import android.text.Editable
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.view.View
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
@@ -26,10 +27,12 @@ import com.example.hpostesting.data.constant.DataHolder
|
|||||||
import com.example.hpostesting.data.constant.Constants
|
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.data.model.test.TestType
|
import com.example.hpostesting.data.model.test.TestType
|
||||||
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import com.example.hpostesting.presentation.hb_test.HBTestActivity
|
import com.example.hpostesting.presentation.hb_test.HBTestActivity
|
||||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestActivity
|
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
|
||||||
@@ -47,6 +50,7 @@ import java.text.SimpleDateFormat
|
|||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
import kotlin.math.max
|
||||||
|
|
||||||
class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
||||||
private var fromWhere = "Home"
|
private var fromWhere = "Home"
|
||||||
@@ -141,12 +145,7 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
val time = timeDifference(sharedPreference.getString(Constants.KIT_TIME, "").toString())
|
val time = timeDifference(sharedPreference.getString(Constants.KIT_TIME, "").toString())
|
||||||
val kitNum = sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
val kitNum = sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
||||||
// Toast.makeText(this@KitScanActivity,"Test MAx time"+ time+"-Test count-"+kitNum,Toast.LENGTH_SHORT).show()
|
// Toast.makeText(this@KitScanActivity,"Test MAx time"+ time+"-Test count-"+kitNum,Toast.LENGTH_SHORT).show()
|
||||||
// if (sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
|
||||||
// moveToNext()
|
|
||||||
// }else{
|
|
||||||
if (sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
|
||||||
moveToNext()
|
|
||||||
}else{
|
|
||||||
if (DataHolder.sampleReadCounter <= maxTest && kitNum != "" && time < Constants.MAX_KIT_TIME) {
|
if (DataHolder.sampleReadCounter <= maxTest && kitNum != "" && time < Constants.MAX_KIT_TIME) {
|
||||||
moveToNext()
|
moveToNext()
|
||||||
} else {
|
} else {
|
||||||
@@ -161,7 +160,6 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// if (checkHemoCubeKitData()) {
|
// if (checkHemoCubeKitData()) {
|
||||||
// DataHolder.selectedTest!!.kitSerial =
|
// DataHolder.selectedTest!!.kitSerial =
|
||||||
@@ -376,7 +374,7 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
DataHolder.deviceType.observe(this) { deviceType ->
|
DataHolder.deviceType.observe(this) { deviceType ->
|
||||||
when (deviceType) {
|
when (deviceType) {
|
||||||
Constants.DEVICE_TYPE_HEMOCUBE -> {
|
Constants.DEVICE_TYPE_HEMOCUBE -> {
|
||||||
val i = Intent(applicationContext, TrueHemeTestActivity::class.java)
|
val i = Intent(applicationContext, HemocubeActivity::class.java)
|
||||||
startActivity(i)
|
startActivity(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,7 +384,7 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Constants.DEVICE_TYPE_TRUEHEME -> {
|
Constants.DEVICE_TYPE_TRUEHEME -> {
|
||||||
val i = Intent(applicationContext, TrueHemeTestActivity::class.java)
|
val i = Intent(applicationContext, HemocubeActivity::class.java)
|
||||||
startActivity(i)
|
startActivity(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import android.content.BroadcastReceiver
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
import android.content.SharedPreferences
|
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.hardware.usb.UsbManager
|
import android.hardware.usb.UsbManager
|
||||||
import android.location.Location
|
import android.location.Location
|
||||||
@@ -31,11 +30,12 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
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.constant.Constants
|
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
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.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.main_base.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import com.google.android.gms.location.FusedLocationProviderClient
|
import com.google.android.gms.location.FusedLocationProviderClient
|
||||||
import com.google.android.gms.location.LocationCallback
|
import com.google.android.gms.location.LocationCallback
|
||||||
import com.google.android.gms.location.LocationRequest
|
import com.google.android.gms.location.LocationRequest
|
||||||
@@ -48,12 +48,12 @@ import `in`.sminnovations.hpostesting.R
|
|||||||
import `in`.sminnovations.hpostesting.databinding.ActivityMainBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityMainBinding
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private lateinit var binding: ActivityMainBinding
|
private lateinit var binding: ActivityMainBinding
|
||||||
private var myMenu: Menu? = null
|
private var myMenu: Menu? = null
|
||||||
private val TAG = "MainActivity"
|
private val TAG = "MainActivity"
|
||||||
private lateinit var fusedLocationClient: FusedLocationProviderClient
|
private lateinit var fusedLocationClient: FusedLocationProviderClient
|
||||||
private lateinit var locationCallback: LocationCallback
|
private lateinit var locationCallback: LocationCallback
|
||||||
private lateinit var sharedPreference: SharedPreferences
|
|
||||||
|
|
||||||
private val usbReceiver = object : BroadcastReceiver() {
|
private val usbReceiver = object : BroadcastReceiver() {
|
||||||
override fun onReceive(context: Context?, intent: Intent) {
|
override fun onReceive(context: Context?, intent: Intent) {
|
||||||
@@ -73,21 +73,14 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
sharedPreference = getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
|
||||||
|
|
||||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
binding.myToolbar.title = "Test Type"
|
binding.myToolbar.title = "Test Type"
|
||||||
setSupportActionBar(binding.myToolbar)
|
setSupportActionBar(binding.myToolbar)
|
||||||
if ((sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN")) {
|
|
||||||
binding.cvItem3.visibility = View.VISIBLE
|
|
||||||
}else{
|
|
||||||
binding.cvItem3.visibility = View.GONE
|
|
||||||
}
|
|
||||||
setupListeners()
|
setupListeners()
|
||||||
fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)
|
fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)
|
||||||
getLocation()
|
getLocation()
|
||||||
|
|
||||||
locationCallback = object : LocationCallback() {
|
locationCallback = object : LocationCallback() {
|
||||||
override fun onLocationResult(locationResult: LocationResult) {
|
override fun onLocationResult(locationResult: LocationResult) {
|
||||||
locationResult.lastLocation?.let { location ->
|
locationResult.lastLocation?.let { location ->
|
||||||
@@ -99,6 +92,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val usbFilter = IntentFilter().apply {
|
val usbFilter = IntentFilter().apply {
|
||||||
addAction(UsbManager.ACTION_USB_DEVICE_DETACHED)
|
addAction(UsbManager.ACTION_USB_DEVICE_DETACHED)
|
||||||
addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED)
|
addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED)
|
||||||
@@ -123,7 +117,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun checkAndUpdateUsbConnection() {
|
private fun checkAndUpdateUsbConnection() {
|
||||||
val availableDrivers = UsbSerialProber.getDefaultProber()
|
val availableDrivers = UsbSerialProber.getDefaultProber()
|
||||||
.findAllDrivers(getSystemService(Context.USB_SERVICE) as UsbManager)
|
.findAllDrivers(getSystemService(Context.USB_SERVICE) as UsbManager)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import com.example.hpostesting.util.MyUtils
|
import com.example.hpostesting.util.MyUtils
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivitySplashBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivitySplashBinding
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
import com.firebase.ui.firestore.FirestoreRecyclerAdapter
|
import com.firebase.ui.firestore.FirestoreRecyclerAdapter
|
||||||
import com.firebase.ui.firestore.FirestoreRecyclerOptions
|
import com.firebase.ui.firestore.FirestoreRecyclerOptions
|
||||||
import com.google.firebase.firestore.FirebaseFirestore
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
@@ -42,7 +42,7 @@ import java.util.Locale
|
|||||||
|
|
||||||
class UserListAdapter(
|
class UserListAdapter(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val trueHemeTestViewModel: TrueHemeTestViewModel,
|
private val hemoCubeViewModel: HemoCubeViewModel,
|
||||||
options: FirestoreRecyclerOptions<UserData>,
|
options: FirestoreRecyclerOptions<UserData>,
|
||||||
private val view: View,
|
private val view: View,
|
||||||
private val batLevel: Int,
|
private val batLevel: Int,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import androidx.fragment.app.Fragment
|
|||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.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.presentation.trueheme_test.TrueHemeTestActivity
|
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentAssuranceControlsBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentAssuranceControlsBinding
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
|
||||||
@@ -259,7 +259,7 @@ class AssuranceControlsFragment : Fragment() {
|
|||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
val i = Intent(requireContext(), TrueHemeTestActivity::class.java)
|
val i = Intent(requireContext(), HemocubeActivity::class.java)
|
||||||
startActivity(i)
|
startActivity(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ import com.example.hpostesting.data.constant.HemoCubeCommands
|
|||||||
import com.example.hpostesting.data.model.patient.BufferCheckData
|
import com.example.hpostesting.data.model.patient.BufferCheckData
|
||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
@@ -44,7 +44,7 @@ import kotlin.math.log10
|
|||||||
class HemoCubeBufferCheckFragment : Fragment() {
|
class HemoCubeBufferCheckFragment : Fragment() {
|
||||||
|
|
||||||
private lateinit var binding: FragmentHemoCubeReferenceBinding
|
private lateinit var binding: FragmentHemoCubeReferenceBinding
|
||||||
private val trueHemeTestViewModel: TrueHemeTestViewModel by activityViewModels()
|
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
private var currentDeviceData: DeviceData? = null
|
private var currentDeviceData: DeviceData? = null
|
||||||
private var resultData: String = ""
|
private var resultData: String = ""
|
||||||
@@ -123,13 +123,13 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun observeViewModel() {
|
private fun observeViewModel() {
|
||||||
trueHemeTestViewModel.deviceData.observe(viewLifecycleOwner) {
|
hemoCubeViewModel.deviceData.observe(viewLifecycleOwner) {
|
||||||
currentDeviceData = it
|
currentDeviceData = it
|
||||||
}
|
}
|
||||||
|
|
||||||
trueHemeTestViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
hemoCubeViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
||||||
if (isNetworkAvailable) {
|
if (isNetworkAvailable) {
|
||||||
trueHemeTestViewModel.getDeviceData(sharedPreferences.getString(Constants.USER_ID, ""))
|
hemoCubeViewModel.getDeviceData(sharedPreferences.getString(Constants.USER_ID, ""))
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
requireContext(), R.string.internt_not, Toast.LENGTH_SHORT
|
requireContext(), R.string.internt_not, Toast.LENGTH_SHORT
|
||||||
@@ -137,7 +137,7 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
isOnline = isNetworkAvailable
|
isOnline = isNetworkAvailable
|
||||||
}
|
}
|
||||||
trueHemeTestViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
hemoCubeViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
||||||
if (result == "Success") {
|
if (result == "Success") {
|
||||||
showToast(R.string.kit_uploaded)
|
showToast(R.string.kit_uploaded)
|
||||||
}
|
}
|
||||||
@@ -152,11 +152,11 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
binding.progressBar.visibility = View.GONE
|
binding.progressBar.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
trueHemeTestViewModel.messages.observe(viewLifecycleOwner) {
|
hemoCubeViewModel.messages.observe(viewLifecycleOwner) {
|
||||||
binding.tvSubtitle4.text = it
|
binding.tvSubtitle4.text = it
|
||||||
}
|
}
|
||||||
|
|
||||||
trueHemeTestViewModel.deviceMessages.observe(viewLifecycleOwner) {
|
hemoCubeViewModel.deviceMessages.observe(viewLifecycleOwner) {
|
||||||
binding.tvDeviceMessages.text = it
|
binding.tvDeviceMessages.text = it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,7 +192,7 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resultData += stringData
|
resultData += stringData
|
||||||
trueHemeTestViewModel.deviceMessages.postValue(resultData)
|
hemoCubeViewModel.deviceMessages.postValue(resultData)
|
||||||
|
|
||||||
when {
|
when {
|
||||||
stringData.contains("SN") -> {
|
stringData.contains("SN") -> {
|
||||||
@@ -209,11 +209,11 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
binding.tvSubtitle4.visibility = View.VISIBLE
|
binding.tvSubtitle4.visibility = View.VISIBLE
|
||||||
binding.btnPlacebuffer.visibility = View.VISIBLE
|
binding.btnPlacebuffer.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
trueHemeTestViewModel.messages.postValue("Start")
|
hemoCubeViewModel.messages.postValue("Start")
|
||||||
}
|
}
|
||||||
|
|
||||||
stringData.contains("#BS") -> {
|
stringData.contains("#BS") -> {
|
||||||
trueHemeTestViewModel.messages.postValue("Buffer Started")
|
hemoCubeViewModel.messages.postValue("Buffer Started")
|
||||||
}
|
}
|
||||||
|
|
||||||
stringData.contains("#BC") -> {
|
stringData.contains("#BC") -> {
|
||||||
@@ -232,7 +232,7 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stringData.contains("#SC") -> {
|
stringData.contains("#SC") -> {
|
||||||
trueHemeTestViewModel.messages.postValue("Sample Completed \nGathering data")
|
hemoCubeViewModel.messages.postValue("Sample Completed \nGathering data")
|
||||||
fetchResult()
|
fetchResult()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,7 +351,7 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val prdClassification = absorbanceBasedClassification(_predictedDenovixRatio)
|
val prdClassification = absorbanceBasedClassification(_predictedDenovixRatio)
|
||||||
trueHemeTestViewModel.messages.postValue(prdClassification)
|
hemoCubeViewModel.messages.postValue(prdClassification)
|
||||||
|
|
||||||
val bufferData = BufferCheckData(
|
val bufferData = BufferCheckData(
|
||||||
_id = UUID.randomUUID().toString(),
|
_id = UUID.randomUUID().toString(),
|
||||||
@@ -385,15 +385,15 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
testTime = SimpleDateFormat(
|
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),
|
||||||
batteryLevel = trueHemeTestViewModel.getBatteryLevel().toString(),
|
batteryLevel = hemoCubeViewModel.getBatteryLevel().toString(),
|
||||||
batteryCapacity = trueHemeTestViewModel.getBatteryCapacity(requireContext()).toString(),
|
batteryCapacity = hemoCubeViewModel.getBatteryCapacity(requireContext()).toString(),
|
||||||
batteryMaxCapacity = trueHemeTestViewModel.getBatteryMaxCapacity(requireContext())
|
batteryMaxCapacity = hemoCubeViewModel.getBatteryMaxCapacity(requireContext())
|
||||||
.toString(),
|
.toString(),
|
||||||
batteryTemperature = trueHemeTestViewModel.getBatteryTemperature().toString(),
|
batteryTemperature = hemoCubeViewModel.getBatteryTemperature().toString(),
|
||||||
batteryVoltage = trueHemeTestViewModel.getBatteryVoltage(requireContext()).toString()
|
batteryVoltage = hemoCubeViewModel.getBatteryVoltage(requireContext()).toString()
|
||||||
)
|
)
|
||||||
|
|
||||||
trueHemeTestViewModel.uploadHemoCubeResultToDatabaseForBufferCheck(isOnline, bufferData)
|
hemoCubeViewModel.uploadHemoCubeResultToDatabaseForBufferCheck(isOnline, bufferData)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
requireContext(), "Error while processing device data", Toast.LENGTH_SHORT
|
requireContext(), "Error while processing device data", Toast.LENGTH_SHORT
|
||||||
@@ -404,7 +404,7 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
|
|
||||||
private fun findResult(calculatedRatio: Double?): String {
|
private fun findResult(calculatedRatio: Double?): String {
|
||||||
try {
|
try {
|
||||||
trueHemeTestViewModel.messages.postValue("result classification")
|
hemoCubeViewModel.messages.postValue("result classification")
|
||||||
if (calculatedRatio != null) {
|
if (calculatedRatio != null) {
|
||||||
if (calculatedRatio < 0.05) return "Inconclusive. Very low Absorbance - Repeat test with Higher Blood Volume"
|
if (calculatedRatio < 0.05) return "Inconclusive. Very low Absorbance - Repeat test with Higher Blood Volume"
|
||||||
if (calculatedRatio in 0.05..0.155) return "Normal"
|
if (calculatedRatio in 0.05..0.155) return "Normal"
|
||||||
@@ -426,7 +426,7 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
|
|
||||||
private fun absorbanceBasedClassification(predictedDenovixRatio: Double?): String {
|
private fun absorbanceBasedClassification(predictedDenovixRatio: Double?): String {
|
||||||
try {
|
try {
|
||||||
trueHemeTestViewModel.messages.postValue("result classification")
|
hemoCubeViewModel.messages.postValue("result classification")
|
||||||
if (predictedDenovixRatio != null) {
|
if (predictedDenovixRatio != null) {
|
||||||
if (predictedDenovixRatio in 0.0..0.16) return "Kit Passed"
|
if (predictedDenovixRatio in 0.0..0.16) return "Kit Passed"
|
||||||
if (predictedDenovixRatio in 0.16..0.165) return "Kit Passed"
|
if (predictedDenovixRatio in 0.16..0.165) return "Kit Passed"
|
||||||
@@ -482,20 +482,20 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getDeviceInfo() {
|
private fun getDeviceInfo() {
|
||||||
trueHemeTestViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
(activity as HemocubeBufferCheckActivity).mService.sendAndListenToHemoCube(
|
(activity as HemocubeBufferCheckActivity).mService.sendAndListenToHemoCube(
|
||||||
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
data?.let {
|
data?.let {
|
||||||
val stringData = String(it)
|
val stringData = String(it)
|
||||||
trueHemeTestViewModel.messages.postValue(stringData)
|
hemoCubeViewModel.messages.postValue(stringData)
|
||||||
binding.tvSubtitle4.text = stringData
|
binding.tvSubtitle4.text = stringData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
trueHemeTestViewModel.progressBar.postValue(false)
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import androidx.core.view.get
|
|||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
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.trueheme_test.TrueHemeTestViewModel
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
import com.example.hpostesting.util.UsbService
|
import com.example.hpostesting.util.UsbService
|
||||||
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
|
||||||
@@ -47,7 +47,7 @@ import `in`.sminnovations.hpostesting.databinding.ActivityHemocubeBinding
|
|||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
open class HemocubeBufferCheckActivity : AppCompatActivity() {
|
open class HemocubeBufferCheckActivity : AppCompatActivity() {
|
||||||
private lateinit var binding: ActivityHemocubeBinding
|
private lateinit var binding: ActivityHemocubeBinding
|
||||||
private val viewModel by viewModels<TrueHemeTestViewModel>()
|
private val viewModel by viewModels<HemoCubeViewModel>()
|
||||||
private var myMenu: Menu? = null
|
private var myMenu: Menu? = null
|
||||||
|
|
||||||
private lateinit var mDriver: UsbSerialDriver
|
private lateinit var mDriver: UsbSerialDriver
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import com.example.hpostesting.data.constant.HemoCubeCommands
|
|||||||
import com.example.hpostesting.data.model.calibration.CalibrationData
|
import com.example.hpostesting.data.model.calibration.CalibrationData
|
||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentCalibrationBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentCalibrationBinding
|
||||||
|
|||||||
@@ -11,14 +11,29 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.main_base
|
package com.example.hpostesting.presentation.dashboard
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.os.BatteryManager
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.fragment.app.activityViewModels
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
|
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
||||||
|
import com.example.hpostesting.presentation.adapter.UserListAdapter
|
||||||
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
|
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
||||||
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentAboutBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentAboutBinding
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.FragmentActivitiesBinding
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.FragmentHomeBinding
|
||||||
|
|
||||||
class AboutFragment : Fragment() {
|
class AboutFragment : Fragment() {
|
||||||
private lateinit var binding: FragmentAboutBinding
|
private lateinit var binding: FragmentAboutBinding
|
||||||
@@ -11,20 +11,28 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.main_base
|
package com.example.hpostesting.presentation.dashboard
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
import android.os.BatteryManager
|
import android.os.BatteryManager
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
||||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
import com.example.hpostesting.presentation.adapter.UserListAdapter
|
||||||
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
|
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
||||||
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentActivitiesBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentActivitiesBinding
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.FragmentHomeBinding
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
@@ -32,7 +40,7 @@ import java.util.Locale
|
|||||||
|
|
||||||
class ActivitiesFragment : Fragment() {
|
class ActivitiesFragment : Fragment() {
|
||||||
private lateinit var binding: FragmentActivitiesBinding
|
private lateinit var binding: FragmentActivitiesBinding
|
||||||
private val trueHemeTestViewModel: TrueHemeTestViewModel by activityViewModels()
|
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
||||||
private lateinit var adapter: OfflineUserListAdapter
|
private lateinit var adapter: OfflineUserListAdapter
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
@@ -46,12 +54,12 @@ class ActivitiesFragment : Fragment() {
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
trueHemeTestViewModel.allPendingUserToUpload.observe(viewLifecycleOwner) { userData ->
|
hemoCubeViewModel.allPendingUserToUpload.observe(viewLifecycleOwner) { userData ->
|
||||||
|
|
||||||
if (userData.isNotEmpty()) {
|
if (userData.isNotEmpty()) {
|
||||||
userData.forEach { user ->
|
userData.forEach { user ->
|
||||||
if((isBetween15And30Minutes(user.incubationTime) > 30 || isBetween15And30Minutes(user.incubationTime) < 0) && user.testStatus == false){
|
if((isBetween15And30Minutes(user.incubationTime) > 30 || isBetween15And30Minutes(user.incubationTime) < 0) && user.testStatus == false){
|
||||||
trueHemeTestViewModel.deleteByStatus()
|
hemoCubeViewModel.deleteByStatus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.main_base
|
package com.example.hpostesting.presentation.dashboard
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
@@ -23,6 +23,7 @@ import android.os.Build
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.FileProvider
|
import androidx.core.content.FileProvider
|
||||||
@@ -32,22 +33,29 @@ import androidx.navigation.ui.AppBarConfiguration
|
|||||||
import androidx.navigation.ui.navigateUp
|
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.example.hpostesting.util.Result
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
|
import com.example.hpostesting.data.model.login.LoginRequest
|
||||||
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
||||||
import com.example.hpostesting.data.repository.DatabaseRepository
|
|
||||||
import com.example.hpostesting.firebase.FirebaseManager
|
|
||||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
|
||||||
import com.example.hpostesting.presentation.jig.JigActivity
|
|
||||||
import com.example.hpostesting.presentation.utils.NatsManager
|
import com.example.hpostesting.presentation.utils.NatsManager
|
||||||
|
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.FirebaseAppDistributionException
|
||||||
|
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||||
|
import com.google.firebase.ktx.Firebase
|
||||||
|
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
|
||||||
|
import com.google.firebase.remoteconfig.ktx.remoteConfig
|
||||||
|
import com.google.firebase.remoteconfig.ktx.remoteConfigSettings
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import `in`.sminnovations.hpostesting.BuildConfig
|
import `in`.sminnovations.hpostesting.BuildConfig
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityDashboardBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityDashboardBinding
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
interface NatsMessageCallback {
|
interface NatsMessageCallback {
|
||||||
fun onMessageReceived(topic: String, message: String)
|
fun onMessageReceived(topic: String, message: String)
|
||||||
@@ -60,8 +68,7 @@ open interface IDataCollector: NatsMessageCallback {
|
|||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class DashboardActivity : AppCompatActivity(), IDataCollector {
|
class DashboardActivity : AppCompatActivity(), IDataCollector {
|
||||||
@Inject
|
private val remoteConfig: FirebaseRemoteConfig = Firebase.remoteConfig
|
||||||
lateinit var databaseRepository: DatabaseRepository
|
|
||||||
val TAG = "DashboardActivity"
|
val TAG = "DashboardActivity"
|
||||||
private var isRegistered = false
|
private var isRegistered = false
|
||||||
private lateinit var appBarConfiguration: AppBarConfiguration
|
private lateinit var appBarConfiguration: AppBarConfiguration
|
||||||
@@ -69,10 +76,9 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
lateinit var sharedPreferences: SharedPreferences
|
lateinit var sharedPreferences: SharedPreferences
|
||||||
var responses: String = ""
|
var responses: String = ""
|
||||||
lateinit var nats: NatsManager
|
lateinit var nats: NatsManager
|
||||||
|
|
||||||
private var downloadId: Long = 0
|
private var downloadId: Long = 0
|
||||||
// TODO: Remove hemocube viewmodel
|
// TODO: Remove hemocube viewmodel
|
||||||
private val hemocubeViewModel: TrueHemeTestViewModel by viewModels()
|
private val hemocubeViewModel: HemoCubeViewModel by viewModels()
|
||||||
|
|
||||||
override fun attachBaseContext(newBase: Context?) {
|
override fun attachBaseContext(newBase: Context?) {
|
||||||
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||||
@@ -80,7 +86,6 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
super.attachBaseContext(newBase)
|
super.attachBaseContext(newBase)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onMessageReceived(topic: String, message: String) {
|
override fun onMessageReceived(topic: String, message: String) {
|
||||||
// Handle incoming messages from NATS
|
// Handle incoming messages from NATS
|
||||||
|
|
||||||
@@ -90,15 +95,11 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
@SuppressLint("SetWorldReadable")
|
@SuppressLint("SetWorldReadable")
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
val firebaseManager = FirebaseManager(this)
|
|
||||||
binding = ActivityDashboardBinding.inflate(layoutInflater)
|
binding = ActivityDashboardBinding.inflate(layoutInflater)
|
||||||
sharedPreferences = this.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
sharedPreferences = this.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
setSupportActionBar(binding.appBarDashboard.toolbar)
|
setSupportActionBar(binding.appBarDashboard.toolbar)
|
||||||
nats = NatsManager(this)
|
nats = NatsManager(this)
|
||||||
|
|
||||||
val currentServer = firebaseManager.getLastSelectedServer().serverName
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
nats.connect()
|
nats.connect()
|
||||||
}
|
}
|
||||||
@@ -107,7 +108,7 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
Log.d("DashboardActivity", "Saved Kit Serial: $savedKitSerial")
|
Log.d("DashboardActivity", "Saved Kit Serial: $savedKitSerial")
|
||||||
// Toast.makeText(this, "Saved Kit Serial: $savedKitSerial", Toast.LENGTH_SHORT).show()
|
// Toast.makeText(this, "Saved Kit Serial: $savedKitSerial", Toast.LENGTH_SHORT).show()
|
||||||
|
|
||||||
val versionName = getAppVersion(this@DashboardActivity) + " [ " + getAppEnvironment(this@DashboardActivity) +"->"+currentServer+"]"
|
val versionName = getAppVersion(this@DashboardActivity) + " [ " + getAppEnvironment(this@DashboardActivity) + " ]"
|
||||||
binding.appBarDashboard.versionName.text = versionName
|
binding.appBarDashboard.versionName.text = versionName
|
||||||
|
|
||||||
|
|
||||||
@@ -116,6 +117,90 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
nats.sub("server.hpos.${deviceId}.ping")
|
nats.sub("server.hpos.${deviceId}.ping")
|
||||||
nats.pub("server.hpos.${deviceId}.ping", "THIS IS A TEST MSG")
|
nats.pub("server.hpos.${deviceId}.ping", "THIS IS A TEST MSG")
|
||||||
|
|
||||||
|
val configSettings = remoteConfigSettings {
|
||||||
|
minimumFetchIntervalInSeconds = 3600
|
||||||
|
}
|
||||||
|
remoteConfig.setConfigSettingsAsync(configSettings)
|
||||||
|
remoteConfig.setDefaultsAsync(R.xml.remote_config_defaults)
|
||||||
|
|
||||||
|
remoteConfig.fetchAndActivate()
|
||||||
|
.addOnCompleteListener(this) { task ->
|
||||||
|
if (task.isSuccessful) {
|
||||||
|
val normalMin2mm = remoteConfig.getDouble("normalMin2mm")
|
||||||
|
val normalMax2mm = remoteConfig.getDouble("normalMax2mm")
|
||||||
|
val negativeBorderlineMin2mm = remoteConfig.getDouble("negativeBorderlineMin2mm")
|
||||||
|
val negativeBorderlineMax2mm = remoteConfig.getDouble("negativeBorderlineMax2mm")
|
||||||
|
val positiveForSickleCellMin2mm = remoteConfig.getDouble("positiveForSickleCellMin2mm")
|
||||||
|
val positiveForSickleCellMax2mm = remoteConfig.getDouble("positiveForSickleCellMax2mm")
|
||||||
|
val sickleCellTraitMin2mm = remoteConfig.getDouble("sickleCellTraitMin2mm")
|
||||||
|
val sickleCellTraitMax2mm = remoteConfig.getDouble("sickleCellTraitMax2mm")
|
||||||
|
val sickleCellDiseaseMin2mm = remoteConfig.getDouble("sickleCellDiseaseMin2mm")
|
||||||
|
val sickleCellDiseaseMax2mm = remoteConfig.getDouble("sickleCellDiseaseMax2mm")
|
||||||
|
val positiveBoderLine2mm1 = remoteConfig.getDouble("positiveBoderLine2mm1")
|
||||||
|
val positiveBoderLine2mm2 = remoteConfig.getDouble("positiveBoderLine2mm2")
|
||||||
|
val negativeBoderLine2mm1 = remoteConfig.getDouble("negativeBoderLine2mm1")
|
||||||
|
val negativeBoderLine2mm2 = remoteConfig.getDouble("negativeBoderLine2mm2")
|
||||||
|
|
||||||
|
val normalMin10mm = remoteConfig.getDouble("normalMin10mm")
|
||||||
|
val normalMax10mm = remoteConfig.getDouble("normalMax10mm")
|
||||||
|
val negativeBorderlineMin10mm = remoteConfig.getDouble("negativeBorderlineMin10mm")
|
||||||
|
val negativeBorderlineMax10mm = remoteConfig.getDouble("negativeBorderlineMax10mm")
|
||||||
|
val positiveForSickleCellMin10mm = remoteConfig.getDouble("positiveForSickleCellMin10mm")
|
||||||
|
val positiveForSickleCellMax10mm = remoteConfig.getDouble("positiveForSickleCellMax10mm")
|
||||||
|
val sickleCellTraitMin10mm = remoteConfig.getDouble("sickleCellTraitMin10mm")
|
||||||
|
val sickleCellTraitMax10mm = remoteConfig.getDouble("sickleCellTraitMax10mm")
|
||||||
|
val sickleCellDiseaseMin10mm = remoteConfig.getDouble("sickleCellDiseaseMin10mm")
|
||||||
|
val sickleCellDiseaseMax10mm = remoteConfig.getDouble("sickleCellDiseaseMax10mm")
|
||||||
|
val positiveBoderLine10mm1 = remoteConfig.getDouble("positiveBoderLine10mm1")
|
||||||
|
val positiveBoderLine10mm2 = remoteConfig.getDouble("positiveBoderLine10mm2")
|
||||||
|
val negativeBoderLine10mm1 = remoteConfig.getDouble("negativeBoderLine10mm1")
|
||||||
|
val negativeBoderLine10mm2 = remoteConfig.getDouble("negativeBoderLine10mm2")
|
||||||
|
|
||||||
|
val bufferMinLed1 = remoteConfig.getDouble("bufferMinLed1")
|
||||||
|
val bufferMaxLed1 = remoteConfig.getDouble("bufferMaxLed1")
|
||||||
|
val bufferMinLed2 = remoteConfig.getDouble("bufferMinLed2")
|
||||||
|
val bufferMaxLed2 = remoteConfig.getDouble("bufferMaxLed2")
|
||||||
|
with(sharedPreferences.edit()) {
|
||||||
|
putString("bufferMinLed1", bufferMinLed1.toString())
|
||||||
|
putString("bufferMaxLed1", bufferMaxLed1.toString())
|
||||||
|
putString("bufferMinLed2", bufferMinLed2.toString())
|
||||||
|
putString("bufferMaxLed2", bufferMaxLed2.toString())//buffer
|
||||||
|
putString("normalMin2mm", normalMin2mm.toString())//2mm
|
||||||
|
putString("normalMax2mm", normalMax2mm.toString())
|
||||||
|
putString("negativeBorderlineMin2mm", negativeBorderlineMin2mm.toString())
|
||||||
|
putString("negativeBorderlineMax2mm", negativeBorderlineMax2mm.toString())
|
||||||
|
putString("positiveForSickleCellMin2mm", positiveForSickleCellMin2mm.toString())
|
||||||
|
putString("positiveForSickleCellMax2mm", positiveForSickleCellMax2mm.toString())
|
||||||
|
putString("sickleCellTraitMin2mm", sickleCellTraitMin2mm.toString())
|
||||||
|
putString("sickleCellTraitMax2mm", sickleCellTraitMax2mm.toString())
|
||||||
|
putString("sickleCellDiseaseMin2mm", sickleCellDiseaseMin2mm.toString())
|
||||||
|
putString("sickleCellDiseaseMax2mm", sickleCellDiseaseMax2mm.toString())
|
||||||
|
putString("positiveBoderLine2mm1", positiveBoderLine2mm1.toString())
|
||||||
|
putString("positiveBoderLine2mm2", positiveBoderLine2mm2.toString())
|
||||||
|
putString("negativeBoderLine2mm1", negativeBoderLine2mm1.toString())
|
||||||
|
putString("negativeBoderLine2mm2", negativeBoderLine2mm2.toString())//2mm
|
||||||
|
putString("normalMin10mm", normalMin10mm.toString())//10mm
|
||||||
|
putString("normalMax10mm", normalMax10mm.toString())
|
||||||
|
putString("negativeBorderlineMin10mm", negativeBorderlineMin10mm.toString())
|
||||||
|
putString("negativeBorderlineMax10mm", negativeBorderlineMax10mm.toString())
|
||||||
|
putString("positiveForSickleCellMin10mm", positiveForSickleCellMin10mm.toString())
|
||||||
|
putString("positiveForSickleCellMax10mm", positiveForSickleCellMax10mm.toString())
|
||||||
|
putString("sickleCellTraitMin10mm", sickleCellTraitMin10mm.toString())
|
||||||
|
putString("sickleCellTraitMax10mm", sickleCellTraitMax10mm.toString())
|
||||||
|
putString("sickleCellDiseaseMin10mm", sickleCellDiseaseMin10mm.toString())
|
||||||
|
putString("sickleCellDiseaseMax10mm", sickleCellDiseaseMax10mm.toString())
|
||||||
|
putString("positiveBoderLine10mm1", positiveBoderLine10mm1.toString())
|
||||||
|
putString("positiveBoderLine10mm2", positiveBoderLine10mm2.toString())
|
||||||
|
putString("negativeBoderLine10mm1", negativeBoderLine10mm1.toString())
|
||||||
|
putString("negativeBoderLine10mm2", negativeBoderLine10mm2.toString())//10mm
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
Log.d(TAG, "Config params updated")
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "Config params Fetch failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
hemocubeViewModel.deviceUpdate.observe(this) {
|
hemocubeViewModel.deviceUpdate.observe(this) {
|
||||||
Log.d("DashboardLogs",it.toString())
|
Log.d("DashboardLogs",it.toString())
|
||||||
|
|
||||||
@@ -165,12 +250,6 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// fun sendData(data:String){ this was used to send the basic data for server validation
|
|
||||||
// databaseRepository.addtodb(data)
|
|
||||||
// Toast.makeText(this, "data uploaded", Toast.LENGTH_SHORT).show()
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
// Inflate the menu; this adds items to the action bar if it is present.
|
// Inflate the menu; this adds items to the action bar if it is present.
|
||||||
menuInflater.inflate(R.menu.dashboard, menu)
|
menuInflater.inflate(R.menu.dashboard, menu)
|
||||||
@@ -296,7 +375,6 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
return try {
|
return try {
|
||||||
val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
|
val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
|
||||||
pInfo.versionName
|
pInfo.versionName
|
||||||
|
|
||||||
} catch (e: PackageManager.NameNotFoundException) {
|
} catch (e: PackageManager.NameNotFoundException) {
|
||||||
"N/A"
|
"N/A"
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.main_base
|
package com.example.hpostesting.presentation.dashboard
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
@@ -28,16 +28,16 @@ import com.example.hpostesting.data.constant.Constants
|
|||||||
import com.example.hpostesting.presentation.autodac.AutoDacActivity
|
import com.example.hpostesting.presentation.autodac.AutoDacActivity
|
||||||
import com.example.hpostesting.presentation.buffercheck.HemocubeBufferCheckActivity
|
import com.example.hpostesting.presentation.buffercheck.HemocubeBufferCheckActivity
|
||||||
import com.example.hpostesting.presentation.calibration.CalibrationActivity
|
import com.example.hpostesting.presentation.calibration.CalibrationActivity
|
||||||
import com.example.hpostesting.presentation.main_base.ui.PasswordResetActivity
|
import com.example.hpostesting.presentation.dashboard.ui.PasswordResetActivity
|
||||||
import com.example.hpostesting.presentation.deviceinfo.DeviceActivity
|
import com.example.hpostesting.presentation.deviceinfo.DeviceActivity
|
||||||
import com.example.hpostesting.presentation.deviceprovision.DeviceProvisionActivity
|
import com.example.hpostesting.presentation.deviceprovision.DeviceProvisionActivity
|
||||||
import com.example.hpostesting.presentation.diagnostics.DiagnosticsActivity
|
import com.example.hpostesting.presentation.diagnostics.DiagnosticsActivity
|
||||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
import com.example.hpostesting.presentation.usb_teminal.UsbTerminalActivity
|
import com.example.hpostesting.presentation.usb_teminal.UsbTerminalActivity
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentGalleryBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentGalleryBinding
|
||||||
|
|
||||||
|
|
||||||
class PanelFragment : Fragment() {
|
class GalleryFragment : Fragment() {
|
||||||
|
|
||||||
private var _binding: FragmentGalleryBinding? = null
|
private var _binding: FragmentGalleryBinding? = null
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
@@ -49,7 +49,7 @@ class PanelFragment : Fragment() {
|
|||||||
|
|
||||||
private lateinit var sharedPreference: SharedPreferences
|
private lateinit var sharedPreference: SharedPreferences
|
||||||
|
|
||||||
private val trueHemeTestViewModel: TrueHemeTestViewModel by activityViewModels()
|
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.main_base
|
package com.example.hpostesting.presentation.dashboard
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
@@ -30,6 +30,8 @@ import android.net.Uri
|
|||||||
import android.os.BatteryManager
|
import android.os.BatteryManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Environment
|
||||||
|
import android.provider.ContactsContract.Data
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
import android.util.Base64
|
import android.util.Base64
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
@@ -43,6 +45,7 @@ import androidx.core.content.FileProvider
|
|||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
import androidx.navigation.findNavController
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
@@ -59,7 +62,7 @@ import com.example.hpostesting.presentation.KitScanActivity
|
|||||||
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
||||||
import com.example.hpostesting.presentation.adapter.UserListAdapter
|
import com.example.hpostesting.presentation.adapter.UserListAdapter
|
||||||
import com.example.hpostesting.presentation.assurance.AssuranceControlsActivity
|
import com.example.hpostesting.presentation.assurance.AssuranceControlsActivity
|
||||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
||||||
import com.example.hpostesting.presentation.utils.DeviceCommunicationHandler
|
import com.example.hpostesting.presentation.utils.DeviceCommunicationHandler
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||||
@@ -100,12 +103,12 @@ class HomeFragment : Fragment() {
|
|||||||
private var downloadId: Long = 0
|
private var downloadId: Long = 0
|
||||||
private lateinit var binding: FragmentHomeBinding
|
private lateinit var binding: FragmentHomeBinding
|
||||||
private val viewModel: TestRightViewModel by activityViewModels()
|
private val viewModel: TestRightViewModel by activityViewModels()
|
||||||
private val trueHemeTestViewModel: TrueHemeTestViewModel by activityViewModels()
|
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
||||||
private lateinit var rvAdapter: UserListAdapter
|
private lateinit var rvAdapter: UserListAdapter
|
||||||
private var batLevel: Int =
|
private var batLevel: Int =
|
||||||
0 // Initialize with a default value, or obtain the actual battery level
|
0 // Initialize with a default value, or obtain the actual battery level
|
||||||
private lateinit var adapter: OfflineUserListAdapter
|
private lateinit var adapter: OfflineUserListAdapter
|
||||||
private val homeViewModel: TrueHemeTestViewModel by activityViewModels()
|
private val homeViewModel: HemoCubeViewModel by activityViewModels()
|
||||||
private var isTokenAvailable by Delegates.notNull<Boolean>()
|
private var isTokenAvailable by Delegates.notNull<Boolean>()
|
||||||
private var natsToken: String = ""
|
private var natsToken: String = ""
|
||||||
private var deviceId: String = ""
|
private var deviceId: String = ""
|
||||||
@@ -139,7 +142,7 @@ class HomeFragment : Fragment() {
|
|||||||
deleteIncompleteRegistrations(userData)
|
deleteIncompleteRegistrations(userData)
|
||||||
}
|
}
|
||||||
// getLocationIP()
|
// getLocationIP()
|
||||||
trueHemeTestViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
||||||
deleteHemoCubeIncompleteRegistrations(userData)
|
deleteHemoCubeIncompleteRegistrations(userData)
|
||||||
if (userData.isNotEmpty()) {
|
if (userData.isNotEmpty()) {
|
||||||
val userList = mutableListOf<HemoCubeTestData>()
|
val userList = mutableListOf<HemoCubeTestData>()
|
||||||
@@ -170,12 +173,12 @@ class HomeFragment : Fragment() {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
trueHemeTestViewModel.fireBaseBulkUpload.observe(viewLifecycleOwner) { result ->
|
hemoCubeViewModel.fireBaseBulkUpload.observe(viewLifecycleOwner) { result ->
|
||||||
if (result == "Success") {
|
if (result == "Success") {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
requireContext(), R.string.test_upload, Toast.LENGTH_SHORT
|
requireContext(), R.string.test_upload, Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
trueHemeTestViewModel.fireBaseBulkUpload.postValue("Done")
|
hemoCubeViewModel.fireBaseBulkUpload.postValue("Done")
|
||||||
}
|
}
|
||||||
if (result == "Error") {
|
if (result == "Error") {
|
||||||
Toast.makeText(requireContext(), R.string.test_upload_failed, Toast.LENGTH_SHORT)
|
Toast.makeText(requireContext(), R.string.test_upload_failed, Toast.LENGTH_SHORT)
|
||||||
@@ -193,7 +196,7 @@ class HomeFragment : Fragment() {
|
|||||||
// binding.uploadData.setOnClickListener {
|
// binding.uploadData.setOnClickListener {
|
||||||
//// showUploadDialog(requireContext())
|
//// showUploadDialog(requireContext())
|
||||||
// }
|
// }
|
||||||
trueHemeTestViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
||||||
// if (sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
// if (sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
||||||
//
|
//
|
||||||
// }else{
|
// }else{
|
||||||
@@ -288,7 +291,7 @@ class HomeFragment : Fragment() {
|
|||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.P)
|
@RequiresApi(Build.VERSION_CODES.P)
|
||||||
private fun checkNetworkStatus() {
|
private fun checkNetworkStatus() {
|
||||||
trueHemeTestViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isConnected ->
|
hemoCubeViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isConnected ->
|
||||||
// Toast.makeText(requireContext(),"connected"+isConnected+wasConnected, Toast.LENGTH_SHORT).show()
|
// Toast.makeText(requireContext(),"connected"+isConnected+wasConnected, Toast.LENGTH_SHORT).show()
|
||||||
if(isConnected){
|
if(isConnected){
|
||||||
binding.tvTitleNoInternet.text = "Please enter the user id and select blood group to start the test."
|
binding.tvTitleNoInternet.text = "Please enter the user id and select blood group to start the test."
|
||||||
@@ -378,10 +381,10 @@ class HomeFragment : Fragment() {
|
|||||||
|
|
||||||
}*/
|
}*/
|
||||||
if(Constants.MOLBIO_INTEGRATION){
|
if(Constants.MOLBIO_INTEGRATION){
|
||||||
trueHemeTestViewModel.sendDataToMolbio()
|
hemoCubeViewModel.sendDataToMolbio()
|
||||||
}
|
}
|
||||||
if(Constants.FIREBASE_INTEGRATION) {
|
if(Constants.FIREBASE_INTEGRATION) {
|
||||||
trueHemeTestViewModel.sendDataToFirebase()
|
hemoCubeViewModel.sendDataToFirebase()
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -434,7 +437,7 @@ class HomeFragment : Fragment() {
|
|||||||
// hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
// hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||||
//hemoCubeViewModel.startPeriodicCheckUpdate()
|
//hemoCubeViewModel.startPeriodicCheckUpdate()
|
||||||
}else{
|
}else{
|
||||||
trueHemeTestViewModel.checkUpdate(createCheckUpdateRequestData())
|
hemoCubeViewModel.checkUpdate(createCheckUpdateRequestData())
|
||||||
}
|
}
|
||||||
//isTokenAvailable = true
|
//isTokenAvailable = true
|
||||||
// hemoCubeViewModel.startPeriodicCheckUpdate()
|
// hemoCubeViewModel.startPeriodicCheckUpdate()
|
||||||
@@ -460,7 +463,7 @@ class HomeFragment : Fragment() {
|
|||||||
callLogin(userID, password)
|
callLogin(userID, password)
|
||||||
//hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
//hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||||
}else{
|
}else{
|
||||||
trueHemeTestViewModel.checkUpdate(createCheckUpdateRequestData())
|
hemoCubeViewModel.checkUpdate(createCheckUpdateRequestData())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -471,7 +474,7 @@ class HomeFragment : Fragment() {
|
|||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
trueHemeTestViewModel.loginResponse.observe(viewLifecycleOwner) { response ->
|
hemoCubeViewModel.loginResponse.observe(viewLifecycleOwner) { response ->
|
||||||
when (response) {
|
when (response) {
|
||||||
is Result.Success -> {
|
is Result.Success -> {
|
||||||
updateTokens(response)
|
updateTokens(response)
|
||||||
@@ -502,14 +505,14 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trueHemeTestViewModel.resultUpload.observe(viewLifecycleOwner) {
|
hemoCubeViewModel.resultUpload.observe(viewLifecycleOwner) {
|
||||||
when (it) {
|
when (it) {
|
||||||
is Result.Success -> {
|
is Result.Success -> {
|
||||||
|
|
||||||
Log.d("success,", "uploded")
|
Log.d("success,", "uploded")
|
||||||
it.data.data?.forEach { id ->
|
it.data.data?.forEach { id ->
|
||||||
id.rawData?.let { it1 ->
|
id.rawData?.let { it1 ->
|
||||||
trueHemeTestViewModel.updateMolbioFlag(
|
hemoCubeViewModel.updateMolbioFlag(
|
||||||
it1._id
|
it1._id
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -536,7 +539,7 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trueHemeTestViewModel.uploadLogs.observe(viewLifecycleOwner) { response ->
|
hemoCubeViewModel.uploadLogs.observe(viewLifecycleOwner) { response ->
|
||||||
when (response) {
|
when (response) {
|
||||||
is Result.Success -> {
|
is Result.Success -> {
|
||||||
// Toast.makeText(
|
// Toast.makeText(
|
||||||
@@ -566,7 +569,7 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trueHemeTestViewModel.checkUpdate.observe(viewLifecycleOwner) { response ->
|
hemoCubeViewModel.checkUpdate.observe(viewLifecycleOwner) { response ->
|
||||||
when (response) {
|
when (response) {
|
||||||
is Result.Success -> {
|
is Result.Success -> {
|
||||||
val updatedversion = response.data.data?.version.toString()
|
val updatedversion = response.data.data?.version.toString()
|
||||||
@@ -592,7 +595,7 @@ class HomeFragment : Fragment() {
|
|||||||
Log.d("versionnow", currentversion.toString())
|
Log.d("versionnow", currentversion.toString())
|
||||||
Log.d("versionnow", updatedversion.toString())
|
Log.d("versionnow", updatedversion.toString())
|
||||||
if (updatedversion > currentversion.toString()) {
|
if (updatedversion > currentversion.toString()) {
|
||||||
trueHemeTestViewModel.deviceUpdate(createDeviceUpdateRequestData())
|
hemoCubeViewModel.deviceUpdate(createDeviceUpdateRequestData())
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
activity,
|
activity,
|
||||||
"new version ${response.data.data?.version} Available",
|
"new version ${response.data.data?.version} Available",
|
||||||
@@ -628,7 +631,7 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trueHemeTestViewModel.downloadcertificate.observe(viewLifecycleOwner) { response ->
|
hemoCubeViewModel.downloadcertificate.observe(viewLifecycleOwner) { response ->
|
||||||
when (response) {
|
when (response) {
|
||||||
is Result.Success -> {
|
is Result.Success -> {
|
||||||
val url = response.data
|
val url = response.data
|
||||||
@@ -815,7 +818,7 @@ class HomeFragment : Fragment() {
|
|||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
// Add user first, ensuring it's done before fetching the user
|
// Add user first, ensuring it's done before fetching the user
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
trueHemeTestViewModel.addUser(
|
hemoCubeViewModel.addUser(
|
||||||
HemoCubeTestData(
|
HemoCubeTestData(
|
||||||
_id = userId,
|
_id = userId,
|
||||||
age = age,
|
age = age,
|
||||||
@@ -829,7 +832,7 @@ class HomeFragment : Fragment() {
|
|||||||
|
|
||||||
// Now fetch the user after the addUser operation is complete
|
// Now fetch the user after the addUser operation is complete
|
||||||
val user = withContext(Dispatchers.IO) {
|
val user = withContext(Dispatchers.IO) {
|
||||||
trueHemeTestViewModel.hemoCubeDao.getUserByID(userId)
|
hemoCubeViewModel.hemoCubeDao.getUserByID(userId)
|
||||||
}
|
}
|
||||||
|
|
||||||
user?.let {
|
user?.let {
|
||||||
@@ -861,7 +864,6 @@ class HomeFragment : Fragment() {
|
|||||||
binding.userId.setText("")
|
binding.userId.setText("")
|
||||||
binding.age.setText("")
|
binding.age.setText("")
|
||||||
binding.etBloodGroup.setText("")
|
binding.etBloodGroup.setText("")
|
||||||
|
|
||||||
// val userData = UserData(_id = userId)
|
// val userData = UserData(_id = userId)
|
||||||
// DataHolder.selectedTest = userData
|
// DataHolder.selectedTest = userData
|
||||||
// findNavController().navigate(R.id.action_nav_home_to_mainActivity)
|
// findNavController().navigate(R.id.action_nav_home_to_mainActivity)
|
||||||
@@ -951,7 +953,7 @@ class HomeFragment : Fragment() {
|
|||||||
rvAdapter = view?.let {
|
rvAdapter = view?.let {
|
||||||
UserListAdapter(
|
UserListAdapter(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
trueHemeTestViewModel,
|
hemoCubeViewModel,
|
||||||
recyclerViewOptions,
|
recyclerViewOptions,
|
||||||
it,
|
it,
|
||||||
batLevel,
|
batLevel,
|
||||||
@@ -1020,7 +1022,7 @@ class HomeFragment : Fragment() {
|
|||||||
rvAdapter = view?.let {
|
rvAdapter = view?.let {
|
||||||
UserListAdapter(
|
UserListAdapter(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
trueHemeTestViewModel,
|
hemoCubeViewModel,
|
||||||
recyclerViewOptions,
|
recyclerViewOptions,
|
||||||
it,
|
it,
|
||||||
batLevel,
|
batLevel,
|
||||||
@@ -1096,7 +1098,7 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun checkUnprocessedCSVData() {
|
private fun checkUnprocessedCSVData() {
|
||||||
trueHemeTestViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
if (sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
if (sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
||||||
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.VISIBLE else View.GONE
|
||||||
@@ -1217,7 +1219,7 @@ class HomeFragment : Fragment() {
|
|||||||
|
|
||||||
private fun downloadLocalDBData(dialog: DialogInterface) {
|
private fun downloadLocalDBData(dialog: DialogInterface) {
|
||||||
var csvDownloaded = false
|
var csvDownloaded = false
|
||||||
trueHemeTestViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
|
|
||||||
//
|
//
|
||||||
// userDataList.forEach { userData ->
|
// userDataList.forEach { userData ->
|
||||||
@@ -1256,7 +1258,7 @@ class HomeFragment : Fragment() {
|
|||||||
|
|
||||||
if (downloadList.isNotEmpty()) {
|
if (downloadList.isNotEmpty()) {
|
||||||
// Call ViewModel function to create CSV with filtered data
|
// Call ViewModel function to create CSV with filtered data
|
||||||
trueHemeTestViewModel.createCSV(downloadList, requireContext())
|
hemoCubeViewModel.createCSV(downloadList, requireContext())
|
||||||
csvDownloaded = true
|
csvDownloaded = true
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
@@ -1288,19 +1290,19 @@ class HomeFragment : Fragment() {
|
|||||||
private fun deleteHemoCubeIncompleteRegistrations(userDataList: List<HemoCubeTestData>) {
|
private fun deleteHemoCubeIncompleteRegistrations(userDataList: List<HemoCubeTestData>) {
|
||||||
userDataList.forEach { userData ->
|
userDataList.forEach { userData ->
|
||||||
if (userData._id.isEmpty()) {
|
if (userData._id.isEmpty()) {
|
||||||
trueHemeTestViewModel.deleteById(userData._id)
|
hemoCubeViewModel.deleteById(userData._id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
trueHemeTestViewModel.networkStatusLiveData.removeObservers(viewLifecycleOwner)
|
hemoCubeViewModel.networkStatusLiveData.removeObservers(viewLifecycleOwner)
|
||||||
trueHemeTestViewModel.allKitTestData.removeObservers(viewLifecycleOwner)
|
hemoCubeViewModel.allKitTestData.removeObservers(viewLifecycleOwner)
|
||||||
trueHemeTestViewModel.allUserData.removeObservers(viewLifecycleOwner)
|
hemoCubeViewModel.allUserData.removeObservers(viewLifecycleOwner)
|
||||||
trueHemeTestViewModel.uploadLogs.removeObservers(viewLifecycleOwner)
|
hemoCubeViewModel.uploadLogs.removeObservers(viewLifecycleOwner)
|
||||||
trueHemeTestViewModel.checkUpdate.removeObservers(viewLifecycleOwner)
|
hemoCubeViewModel.checkUpdate.removeObservers(viewLifecycleOwner)
|
||||||
trueHemeTestViewModel.downloadcertificate.removeObservers(viewLifecycleOwner)
|
hemoCubeViewModel.downloadcertificate.removeObservers(viewLifecycleOwner)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun downloadCsv() {
|
private fun downloadCsv() {
|
||||||
@@ -1676,10 +1678,10 @@ class HomeFragment : Fragment() {
|
|||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
trueHemeTestViewModel.login(createLoginRequestData(userID, password))
|
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
trueHemeTestViewModel.login(createLoginRequestData(userID, password))
|
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private fun timeDifference(createdAt: String): Long {
|
private fun timeDifference(createdAt: String): Long {
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
package com.example.hpostesting.firebase
|
|
||||||
/*
|
/*
|
||||||
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
||||||
* // Notice: All information contained herein is, and remains
|
* // Notice: All information contained herein is, and remains
|
||||||
@@ -11,11 +10,9 @@ package com.example.hpostesting.firebase
|
|||||||
* // is strictly forbidden unless prior written permission is obtained
|
* // is strictly forbidden unless prior written permission is obtained
|
||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
data class FirebaseConfig(
|
|
||||||
val serverName: String,
|
|
||||||
val apiKey: String,
|
|
||||||
val appId: String,
|
|
||||||
val projectId: String,
|
|
||||||
val storageBucket: String
|
|
||||||
)
|
|
||||||
|
|
||||||
|
package com.example.hpostesting.presentation.dashboard
|
||||||
|
|
||||||
|
interface ItemClickListener {
|
||||||
|
fun onClick(pos: Int)
|
||||||
|
}
|
||||||
@@ -0,0 +1,172 @@
|
|||||||
|
/*
|
||||||
|
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
||||||
|
* // Notice: All information contained herein is, and remains
|
||||||
|
* // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
||||||
|
* // if any. The intellectual and technical concepts contained
|
||||||
|
* // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
||||||
|
* // and its suppliers and may be covered by Indian and Foreign Patents,
|
||||||
|
* // patents in process, and are protected by trade secret or copyright law.
|
||||||
|
* // Dissemination of this information or reproduction of this material
|
||||||
|
* // is strictly forbidden unless prior written permission is obtained
|
||||||
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.example.hpostesting.presentation.dashboard
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.content.pm.PackageManager
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.AdapterView
|
||||||
|
import android.widget.ArrayAdapter
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.preference.ListPreference
|
||||||
|
import androidx.preference.Preference
|
||||||
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
|
import com.example.hpostesting.data.model.TestState
|
||||||
|
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
||||||
|
import `in`.sminnovations.hpostesting.R
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.FragmentHemoCubeReferenceBinding
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.FragmentSlideshowBinding
|
||||||
|
|
||||||
|
private var isLanguageChanged = false
|
||||||
|
|
||||||
|
class SlideshowFragment : Fragment(){
|
||||||
|
private var selectedItem = "10mm"
|
||||||
|
private val values = arrayOf("10mm", "2mm")
|
||||||
|
private lateinit var binding: FragmentSlideshowBinding
|
||||||
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
||||||
|
): View {
|
||||||
|
binding = FragmentSlideshowBinding.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)
|
||||||
|
|
||||||
|
binding.nameEditText.setText(sharedPreferences.getString(Constants.LABNAME,""))
|
||||||
|
|
||||||
|
selectedItem = sharedPreferences.getString(Constants.CUVETTE_SIZE,"10mm").toString()
|
||||||
|
val time = sharedPreferences.getString(Constants.LAST_UPDATED,"NA").toString()
|
||||||
|
binding.lastUpdated.text = "Last updated config: $time"
|
||||||
|
binding.btnGo.setOnClickListener {
|
||||||
|
var labname = binding.nameEditText.text.toString()
|
||||||
|
DataHolder.hemoCubeTestData?.apply {
|
||||||
|
this.labName = labname
|
||||||
|
}
|
||||||
|
|
||||||
|
with(sharedPreferences.edit()) {
|
||||||
|
putString(Constants.LABNAME, labname)
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.makeText(
|
||||||
|
requireContext(),
|
||||||
|
"Lab Name is Added successfully.",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
val adapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, values)
|
||||||
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||||
|
val pos: Int
|
||||||
|
if(selectedItem == "10mm"){
|
||||||
|
pos = 0
|
||||||
|
}else{
|
||||||
|
pos = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.spinnerCuvette.adapter = adapter
|
||||||
|
binding.spinnerCuvette.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
|
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||||
|
// Handle item selection here
|
||||||
|
selectedItem = values[position]
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||||
|
// Do nothing here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
binding.spinnerCuvette.setSelection(pos)
|
||||||
|
binding.btnAddSize.setOnClickListener {
|
||||||
|
with(sharedPreferences.edit()) {
|
||||||
|
putString(Constants.CUVETTE_SIZE, selectedItem)
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
Toast.makeText(requireContext(), "Selected cuvette size: $selectedItem", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
childFragmentManager.beginTransaction().replace(binding.container.id,PrefsFragment()).commit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class PrefsFragment: PreferenceFragmentCompat(){
|
||||||
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
|
val preferenceScreen = preferenceManager.createPreferenceScreen(requireContext())
|
||||||
|
|
||||||
|
val languagePreference = ListPreference(requireContext())
|
||||||
|
languagePreference.key = "language_preference"
|
||||||
|
languagePreference.title = getString(R.string.app_language)
|
||||||
|
languagePreference.summary = getString(R.string.select_language)
|
||||||
|
languagePreference.entries = arrayOf("English", "Kannada", "Hindi")
|
||||||
|
languagePreference.entryValues = arrayOf("en", "kn", "hi")
|
||||||
|
languagePreference.setDefaultValue("en")
|
||||||
|
|
||||||
|
languagePreference.onPreferenceChangeListener =
|
||||||
|
Preference.OnPreferenceChangeListener { _, newValue ->
|
||||||
|
val languageCode = newValue as String
|
||||||
|
updateLanguage(requireContext(), languageCode)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
preferenceScreen.addPreference(languagePreference)
|
||||||
|
setPreferenceScreen(preferenceScreen)
|
||||||
|
|
||||||
|
// App Version Preference
|
||||||
|
val appVersionPreference = Preference(requireContext())
|
||||||
|
appVersionPreference.title = "App Version SMI"
|
||||||
|
appVersionPreference.summary =
|
||||||
|
getAppVersion(requireContext()) + " [ " + getAppEnvironment(requireContext()) + " ]"
|
||||||
|
|
||||||
|
preferenceScreen.addPreference(languagePreference)
|
||||||
|
preferenceScreen.addPreference(appVersionPreference)
|
||||||
|
setPreferenceScreen(preferenceScreen)
|
||||||
|
if (isLanguageChanged) {
|
||||||
|
Toast.makeText(requireContext(), R.string.language_update, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private fun updateLanguage(context: Context, languageCode: String) {
|
||||||
|
LanguageManager.persistLanguagePreference(context, languageCode)
|
||||||
|
LanguageManager.setLocale(context, languageCode)
|
||||||
|
requireActivity().recreate() // Recreate activity to apply language changes
|
||||||
|
isLanguageChanged = true
|
||||||
|
}
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,13 +11,18 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.main_base
|
package com.example.hpostesting.presentation.dashboard
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import androidx.activity.enableEdgeToEdge
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import `in`.sminnovations.hpostesting.R
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.ActivityDashboardBinding
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityUpdateValuesBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityUpdateValuesBinding
|
||||||
|
|
||||||
class UpdateValuesActivity : AppCompatActivity() {
|
class UpdateValuesActivity : AppCompatActivity() {
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.main_base.ui
|
package com.example.hpostesting.presentation.dashboard.ui
|
||||||
|
|
||||||
import com.example.hpostesting.util.SecureStorage
|
import com.example.hpostesting.util.SecureStorage
|
||||||
import android.accounts.Account
|
import android.accounts.Account
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.example.hpostesting.presentation.main_base.ui
|
package com.example.hpostesting.presentation.dashboard.ui
|
||||||
|
|
||||||
import com.example.hpostesting.util.SecureStorage
|
import com.example.hpostesting.util.SecureStorage
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
||||||
|
* // Notice: All information contained herein is, and remains
|
||||||
|
* // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
||||||
|
* // if any. The intellectual and technical concepts contained
|
||||||
|
* // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
||||||
|
* // and its suppliers and may be covered by Indian and Foreign Patents,
|
||||||
|
* // patents in process, and are protected by trade secret or copyright law.
|
||||||
|
* // Dissemination of this information or reproduction of this material
|
||||||
|
* // is strictly forbidden unless prior written permission is obtained
|
||||||
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.example.hpostesting.presentation.dashboard.ui.gallery
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
|
||||||
|
class mGalleryViewModel : ViewModel() {
|
||||||
|
|
||||||
|
private val _text = MutableLiveData<String>().apply {
|
||||||
|
value = "This is gallery Fragment"
|
||||||
|
}
|
||||||
|
val text: LiveData<String> = _text
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
||||||
|
* // Notice: All information contained herein is, and remains
|
||||||
|
* // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
||||||
|
* // if any. The intellectual and technical concepts contained
|
||||||
|
* // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
||||||
|
* // and its suppliers and may be covered by Indian and Foreign Patents,
|
||||||
|
* // patents in process, and are protected by trade secret or copyright law.
|
||||||
|
* // Dissemination of this information or reproduction of this material
|
||||||
|
* // is strictly forbidden unless prior written permission is obtained
|
||||||
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.example.hpostesting.presentation.dashboard.ui.slideshow
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
|
||||||
|
class SlideshowViewModel : ViewModel() {
|
||||||
|
|
||||||
|
private val _text = MutableLiveData<String>().apply {
|
||||||
|
value = "This is slideshow Fragment"
|
||||||
|
}
|
||||||
|
val text: LiveData<String> = _text
|
||||||
|
}
|
||||||
@@ -26,14 +26,14 @@ import androidx.lifecycle.MutableLiveData
|
|||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentDeviceBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentDeviceBinding
|
||||||
|
|
||||||
class DeviceFragment : Fragment() {
|
class DeviceFragment : Fragment() {
|
||||||
private lateinit var binding: FragmentDeviceBinding
|
private lateinit var binding: FragmentDeviceBinding
|
||||||
private val deviceViewModel: TrueHemeTestViewModel by activityViewModels()
|
private val deviceViewModel: HemoCubeViewModel by activityViewModels()
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
private var deviceId = ""
|
private var deviceId = ""
|
||||||
private var startListening = MutableLiveData(false)
|
private var startListening = MutableLiveData(false)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Environment
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
@@ -33,11 +34,13 @@ import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
|||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
import com.example.hpostesting.encryption.Encryption
|
import com.example.hpostesting.encryption.Encryption
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
|
import com.google.android.gms.ads.identifier.AdvertisingIdClient
|
||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentDeviceProvisionBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentDeviceProvisionBinding
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.io.FileOutputStream
|
||||||
|
|
||||||
class DeviceProvisionFragment : Fragment() {
|
class DeviceProvisionFragment : Fragment() {
|
||||||
private var resultData: String = ""
|
private var resultData: String = ""
|
||||||
|
|||||||
@@ -33,24 +33,19 @@ import androidx.activity.viewModels
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
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.constant.Constants
|
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
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.data.repository.DatabaseRepository
|
|
||||||
import com.example.hpostesting.firebase.FirebaseManager
|
|
||||||
import com.example.hpostesting.util.UsbService
|
import com.example.hpostesting.util.UsbService
|
||||||
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.ActivityAutoDacBinding
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityHbTestBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityHbTestBinding
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class HBTestActivity : AppCompatActivity() {
|
class HBTestActivity : AppCompatActivity() {
|
||||||
|
|
||||||
@Inject
|
|
||||||
lateinit var databaseRepository: DatabaseRepository
|
|
||||||
private lateinit var binding: ActivityHbTestBinding
|
private lateinit var binding: ActivityHbTestBinding
|
||||||
val viewModel: HBTestViewModel by viewModels()
|
val viewModel: HBTestViewModel by viewModels()
|
||||||
private var myMenu: Menu? = null
|
private var myMenu: Menu? = null
|
||||||
@@ -102,10 +97,6 @@ class HBTestActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
val firebaseManager = FirebaseManager(this)
|
|
||||||
val lastSelectedServer = firebaseManager.getLastSelectedServer()
|
|
||||||
// switchFirebaseServer(lastSelectedServer)
|
|
||||||
Log.d("CURRENT SERVR......","server : ${lastSelectedServer.serverName}")
|
|
||||||
binding = ActivityHbTestBinding.inflate(layoutInflater)
|
binding = ActivityHbTestBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
// setSupportActionBar(binding.myToolbar)
|
// setSupportActionBar(binding.myToolbar)
|
||||||
@@ -114,11 +105,7 @@ class HBTestActivity : AppCompatActivity() {
|
|||||||
connectUsb(false)
|
connectUsb(false)
|
||||||
|
|
||||||
}
|
}
|
||||||
// private fun switchFirebaseServer(config: FirebaseConfig) {
|
|
||||||
// val (newFirestore, newStorage) = firebaseManager.switchFirestoreServer(config)
|
|
||||||
// databaseRepository.switchServer(newFirestore, newStorage)
|
|
||||||
//// Toast.makeText(this, "server switched", Toast.LENGTH_SHORT).show()// Update repository with new Firestore and Storage
|
|
||||||
// }
|
|
||||||
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")
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ class HBTestFragment : Fragment() {
|
|||||||
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)
|
||||||
|
//Toast.makeText(requireContext(), "deviceID"+deviceId, Toast.LENGTH_LONG).show()
|
||||||
hBTestViewModel.uploadFirebaseQc(testDetails)
|
hBTestViewModel.uploadFirebaseQc(testDetails)
|
||||||
}
|
}
|
||||||
binding.btnBuffer.setOnClickListener {
|
binding.btnBuffer.setOnClickListener {
|
||||||
@@ -176,7 +177,6 @@ class HBTestFragment : Fragment() {
|
|||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
data?.let {
|
data?.let {
|
||||||
val stringData = String(it)
|
val stringData = String(it)
|
||||||
//deviceId = stringData
|
|
||||||
hBTestViewModel.messages.postValue(stringData)
|
hBTestViewModel.messages.postValue(stringData)
|
||||||
binding.tvSubtitle4.text = stringData
|
binding.tvSubtitle4.text = stringData
|
||||||
}
|
}
|
||||||
@@ -232,7 +232,6 @@ class HBTestFragment : Fragment() {
|
|||||||
|
|
||||||
return matchResult?.groups?.get(1)?.value
|
return matchResult?.groups?.get(1)?.value
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun listenToHemoCube() {
|
private fun listenToHemoCube() {
|
||||||
|
|
||||||
val fullReadOutput = StringBuilder()
|
val fullReadOutput = StringBuilder()
|
||||||
@@ -251,7 +250,6 @@ class HBTestFragment : Fragment() {
|
|||||||
if (stringData.contains("SNE")) {
|
if (stringData.contains("SNE")) {
|
||||||
val slData = stringData.split(" ")
|
val slData = stringData.split(" ")
|
||||||
if (slData.size > 1) {
|
if (slData.size > 1) {
|
||||||
val hardwareId = slData[1].trim()
|
|
||||||
deviceId = extractV2HardwareId(resultData).toString()
|
deviceId = extractV2HardwareId(resultData).toString()
|
||||||
hBTestViewModel.messages.postValue("Place buffer and click below button to start test")
|
hBTestViewModel.messages.postValue("Place buffer and click below button to start test")
|
||||||
// with(sharedPreferences.edit()) {
|
// with(sharedPreferences.edit()) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.trueheme_test
|
package com.example.hpostesting.presentation.hemocube
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.trueheme_test
|
package com.example.hpostesting.presentation.hemocube
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
@@ -33,7 +33,7 @@ import java.util.Locale
|
|||||||
|
|
||||||
class DigitalCardFragment : Fragment() {
|
class DigitalCardFragment : Fragment() {
|
||||||
private lateinit var binding: FragmentDigitalCardBinding
|
private lateinit var binding: FragmentDigitalCardBinding
|
||||||
private val trueHemeTestViewModel: TrueHemeTestViewModel by activityViewModels()
|
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.trueheme_test
|
package com.example.hpostesting.presentation.hemocube
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
@@ -38,7 +38,8 @@ import com.example.hpostesting.data.model.TestState
|
|||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
|
import com.example.hpostesting.presentation.deviceinfo.DeviceActivity
|
||||||
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.crashlytics.ktx.crashlytics
|
||||||
@@ -48,29 +49,28 @@ import `in`.sminnovations.hpostesting.databinding.FragmentHemoCubeReferenceBindi
|
|||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import kotlin.math.log10
|
import kotlin.math.log10
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
//This is TrueHemeTestFragment, where actual tests are done first buffer check and then sample check
|
|
||||||
//and finally on submit test data to database if online or store in offline database
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
class TrueHemeTestFragment : Fragment() {
|
class HemoCubeFragment : Fragment() {
|
||||||
private var positiveBoderLine10mm1=Constants.positiveBoderLineMetricCheck10mmMin
|
private var positiveBoderLine10mm1=Constants.positiveBoderLine10mm1
|
||||||
private var positiveBoderLine10mm2=Constants.positiveBoderLineMetricCheck10mmMax
|
private var positiveBoderLine10mm2=Constants.positiveBoderLine10mm2
|
||||||
private var negativeBoderLine10mm1=Constants.negativeBoderLineMetricCheck10mmMin
|
private var negativeBoderLine10mm1=Constants.negativeBoderLine10mm1
|
||||||
private var negativeBoderLine10mm2=Constants.negativeBoderLineMetricCheck10mmMax
|
private var negativeBoderLine10mm2=Constants.negativeBoderLine10mm2
|
||||||
private var normalMin10mm=Constants.normalMin10mm
|
private var normalMin10mm=Constants.normalMin10mm
|
||||||
private var normalMax10mm=Constants.normalMax10mm
|
private var normalMax10mm=Constants.normalMax10mm
|
||||||
private var negativeBorderlineMin10mm=Constants.negativeBorderlineMin10mm
|
private var negativeBorderlineMin10mm=Constants.negativeBorderlineMin10mm
|
||||||
private var negativeBorderlineMax10mm=Constants.negativeBorderlineMax10mm
|
private var negativeBorderlineMax10mm=Constants.negativeBorderlineMax10mm
|
||||||
private var sickleCellTraitMin10mm=Constants.sickleCellTraitMin10mm
|
private var sickleCellTraitMin10mm=Constants.sickleCellTraitMin10mm
|
||||||
private var sickleCellTraitMax10mm=Constants.sickleCellTraitMax10mm
|
private var sickleCellTraitMax10mm=Constants.sickleCellTraitMax10mm
|
||||||
private var positiveForSickleCellMin10mm=Constants.positiveBoderlineMin10mm
|
private var positiveForSickleCellMin10mm=Constants.positiveForSickleCellMin10mm
|
||||||
private var positiveForSickleCellMax10mm=Constants.positiveBoderlineMax10mm
|
private var positiveForSickleCellMax10mm=Constants.positiveForSickleCellMax10mm
|
||||||
private var sickleCellDiseaseMin10mm=Constants.sickleCellDiseaseMin10mm
|
private var sickleCellDiseaseMin10mm=Constants.sickleCellDiseaseMin10mm
|
||||||
private var sickleCellDiseaseMax10mm=Constants.sickleCellDiseaseMax10mm
|
private var sickleCellDiseaseMax10mm=Constants.sickleCellDiseaseMax10mm
|
||||||
|
|
||||||
private var positiveBoderLine2mm1=Constants.positiveBoderLineMetricCheck2mmMin
|
private var positiveBoderLine2mm1=Constants.positiveBoderLine2mm1
|
||||||
private var positiveBoderLine2mm2=Constants.positiveBoderLineMetricCheck2mmMax
|
private var positiveBoderLine2mm2=Constants.positiveBoderLine2mm2
|
||||||
private var negativeBoderLine2mm1=Constants.negativeBoderLineMetricCheck2mmMin
|
private var negativeBoderLine2mm1=Constants.negativeBoderLine2mm1
|
||||||
private var negativeBoderLine2mm2=Constants.negativeBoderLineMetricCheck2mmMax
|
private var negativeBoderLine2mm2=Constants.negativeBoderLine2mm2
|
||||||
private var normalMin2mm=Constants.normalMin2mm
|
private var normalMin2mm=Constants.normalMin2mm
|
||||||
private var normalMax2mm=Constants.normalMax2mm
|
private var normalMax2mm=Constants.normalMax2mm
|
||||||
private var negativeBorderlineMin2mm=Constants.negativeBorderlineMin2mm
|
private var negativeBorderlineMin2mm=Constants.negativeBorderlineMin2mm
|
||||||
@@ -83,7 +83,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
private var sickleCellDiseaseMax2mm=Constants.sickleCellDiseaseMax2mm
|
private var sickleCellDiseaseMax2mm=Constants.sickleCellDiseaseMax2mm
|
||||||
|
|
||||||
private var temperature=""
|
private var temperature=""
|
||||||
private var cuvetteSizeSP = "10mm"
|
private var cuvetteSize = "10mm"
|
||||||
private var checkCuvette = false
|
private var checkCuvette = false
|
||||||
private var checkRefreshCuvette = false
|
private var checkRefreshCuvette = false
|
||||||
private var checkCuvetteSam = false
|
private var checkCuvetteSam = false
|
||||||
@@ -92,7 +92,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
private var sampleClick = false
|
private var sampleClick = false
|
||||||
private var refreshClick = false
|
private var refreshClick = false
|
||||||
private lateinit var binding: FragmentHemoCubeReferenceBinding
|
private lateinit var binding: FragmentHemoCubeReferenceBinding
|
||||||
private val trueHemeTestViewModel: TrueHemeTestViewModel by activityViewModels()
|
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||||
private var isOnline = false
|
private var isOnline = false
|
||||||
@@ -133,7 +133,36 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
sharedPreferences =
|
sharedPreferences =
|
||||||
requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
|
|
||||||
cuvetteSizeSP = sharedPreferences.getString(Constants.CUVETTE_SIZE,"10mm").toString()
|
cuvetteSize = sharedPreferences.getString(Constants.CUVETTE_SIZE,"10mm").toString()
|
||||||
|
positiveBoderLine10mm1 = sharedPreferences.getString("positiveBoderLine10mm1", Constants.positiveBoderLine10mm1.toString())?.toDoubleOrNull() ?: Constants.positiveBoderLine10mm1
|
||||||
|
positiveBoderLine10mm2 = sharedPreferences.getString("positiveBoderLine10mm2", Constants.positiveBoderLine10mm2.toString())?.toDoubleOrNull() ?: Constants.positiveBoderLine10mm2
|
||||||
|
negativeBoderLine10mm1 = sharedPreferences.getString("negativeBoderLine10mm1", Constants.negativeBoderLine10mm1.toString())?.toDoubleOrNull() ?: Constants.negativeBoderLine10mm1
|
||||||
|
negativeBoderLine10mm2 = sharedPreferences.getString("negativeBoderLine10mm2", Constants.negativeBoderLine10mm2.toString())?.toDoubleOrNull() ?: Constants.negativeBoderLine10mm2
|
||||||
|
normalMin10mm = sharedPreferences.getString("normalMin10mm", Constants.normalMin10mm.toString())?.toDoubleOrNull() ?: Constants.normalMin10mm
|
||||||
|
normalMax10mm = sharedPreferences.getString("normalMax10mm", Constants.normalMax10mm.toString())?.toDoubleOrNull() ?: Constants.normalMax10mm
|
||||||
|
negativeBorderlineMin10mm = sharedPreferences.getString("negativeBorderlineMin10mm", Constants.negativeBorderlineMin10mm.toString())?.toDoubleOrNull() ?: Constants.negativeBorderlineMin10mm
|
||||||
|
negativeBorderlineMax10mm = sharedPreferences.getString("negativeBorderlineMax10mm", Constants.negativeBorderlineMax10mm.toString())?.toDoubleOrNull() ?: Constants.negativeBorderlineMax10mm
|
||||||
|
sickleCellTraitMin10mm = sharedPreferences.getString("sickleCellTraitMin10mm", Constants.sickleCellTraitMin10mm.toString())?.toDoubleOrNull() ?: Constants.sickleCellTraitMin10mm
|
||||||
|
sickleCellTraitMax10mm = sharedPreferences.getString("sickleCellTraitMax10mm", Constants.sickleCellTraitMax10mm.toString())?.toDoubleOrNull() ?: Constants.sickleCellTraitMax10mm
|
||||||
|
positiveForSickleCellMin10mm = sharedPreferences.getString("positiveForSickleCellMin10mm", Constants.positiveForSickleCellMin10mm.toString())?.toDoubleOrNull() ?: Constants.positiveForSickleCellMin10mm
|
||||||
|
positiveForSickleCellMax10mm = sharedPreferences.getString("positiveForSickleCellMax10mm", Constants.positiveForSickleCellMax10mm.toString())?.toDoubleOrNull() ?: Constants.positiveForSickleCellMax10mm
|
||||||
|
sickleCellDiseaseMin10mm = sharedPreferences.getString("sickleCellDiseaseMin10mm", Constants.sickleCellDiseaseMin10mm.toString())?.toDoubleOrNull() ?: Constants.sickleCellDiseaseMin10mm
|
||||||
|
sickleCellDiseaseMax10mm = sharedPreferences.getString("sickleCellDiseaseMax10mm", Constants.sickleCellDiseaseMax10mm.toString())?.toDoubleOrNull() ?: Constants.sickleCellDiseaseMax10mm
|
||||||
|
|
||||||
|
positiveBoderLine2mm1 = sharedPreferences.getString("positiveBoderLine2mm1", Constants.positiveBoderLine2mm1.toString())?.toDoubleOrNull() ?: Constants.positiveBoderLine2mm1
|
||||||
|
positiveBoderLine2mm2 = sharedPreferences.getString("positiveBoderLine2mm2", Constants.positiveBoderLine2mm2.toString())?.toDoubleOrNull() ?: Constants.positiveBoderLine2mm2
|
||||||
|
negativeBoderLine2mm1 = sharedPreferences.getString("negativeBoderLine2mm1", Constants.negativeBoderLine2mm1.toString())?.toDoubleOrNull() ?: Constants.negativeBoderLine2mm1
|
||||||
|
negativeBoderLine2mm2 = sharedPreferences.getString("negativeBoderLine2mm2", Constants.negativeBoderLine2mm2.toString())?.toDoubleOrNull() ?: Constants.negativeBoderLine2mm2
|
||||||
|
normalMin2mm = sharedPreferences.getString("normalMin2mm", Constants.normalMin2mm.toString())?.toDoubleOrNull() ?: Constants.normalMin2mm
|
||||||
|
normalMax2mm = sharedPreferences.getString("normalMax2mm", Constants.normalMax2mm.toString())?.toDoubleOrNull() ?: Constants.normalMax2mm
|
||||||
|
negativeBorderlineMin2mm = sharedPreferences.getString("negativeBorderlineMin2mm", Constants.negativeBorderlineMin2mm.toString())?.toDoubleOrNull() ?: Constants.negativeBorderlineMin2mm
|
||||||
|
negativeBorderlineMax2mm = sharedPreferences.getString("negativeBorderlineMax2mm", Constants.negativeBorderlineMax2mm.toString())?.toDoubleOrNull() ?: Constants.negativeBorderlineMax2mm
|
||||||
|
sickleCellTraitMin2mm = sharedPreferences.getString("sickleCellTraitMin2mm", Constants.sickleCellTraitMin2mm.toString())?.toDoubleOrNull() ?: Constants.sickleCellTraitMin2mm
|
||||||
|
sickleCellTraitMax2mm = sharedPreferences.getString("sickleCellTraitMax2mm", Constants.sickleCellTraitMax2mm.toString())?.toDoubleOrNull() ?: Constants.sickleCellTraitMax2mm
|
||||||
|
positiveForSickleCellMin2mm = sharedPreferences.getString("positiveForSickleCellMin2mm", Constants.positiveForSickleCellMin2mm.toString())?.toDoubleOrNull() ?: Constants.positiveForSickleCellMin2mm
|
||||||
|
positiveForSickleCellMax2mm = sharedPreferences.getString("positiveForSickleCellMax2mm", Constants.positiveForSickleCellMax2mm.toString())?.toDoubleOrNull() ?: Constants.positiveForSickleCellMax2mm
|
||||||
|
sickleCellDiseaseMin2mm = sharedPreferences.getString("sickleCellDiseaseMin2mm", Constants.sickleCellDiseaseMin2mm.toString())?.toDoubleOrNull() ?: Constants.sickleCellDiseaseMin2mm
|
||||||
|
sickleCellDiseaseMax2mm = sharedPreferences.getString("sickleCellDiseaseMax2mm", Constants.sickleCellDiseaseMax2mm.toString())?.toDoubleOrNull() ?: Constants.sickleCellDiseaseMax2mm
|
||||||
|
|
||||||
testState = TestState(
|
testState = TestState(
|
||||||
testDetails = DataHolder.selectedTest?.toHemoCubeTestData(),
|
testDetails = DataHolder.selectedTest?.toHemoCubeTestData(),
|
||||||
@@ -155,20 +184,6 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
binding.tvSubtitle4.movementMethod = ScrollingMovementMethod()
|
binding.tvSubtitle4.movementMethod = ScrollingMovementMethod()
|
||||||
binding.tvDeviceMessages.movementMethod = ScrollingMovementMethod()
|
binding.tvDeviceMessages.movementMethod = ScrollingMovementMethod()
|
||||||
binding.btnSubmit.setOnClickListener {
|
binding.btnSubmit.setOnClickListener {
|
||||||
// with(sharedPreferences.edit()) {
|
|
||||||
// putBoolean(Constants.QUICK_CAPTURE, false)
|
|
||||||
// apply()
|
|
||||||
// }
|
|
||||||
// if(DataHolder.hemoCubeTestData!!.classificationResult != "Invalid"){
|
|
||||||
// DataHolder.sampleReadCounter++
|
|
||||||
// }
|
|
||||||
// binding.btnSubmit.isEnabled = false
|
|
||||||
// binding.btnSubmit.isClickable = false
|
|
||||||
// activity?.runOnUiThread {
|
|
||||||
// Log.d("HemoCubeFragment","Test Process completed, result saved")
|
|
||||||
// binding.progressBar.visibility = View.VISIBLE
|
|
||||||
// binding.btnSubmit.visibility = View.GONE
|
|
||||||
// }
|
|
||||||
submitClick = true
|
submitClick = true
|
||||||
if(checkSubmit){
|
if(checkSubmit){
|
||||||
with(sharedPreferences.edit()) {
|
with(sharedPreferences.edit()) {
|
||||||
@@ -185,7 +200,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
binding.progressBar.visibility = View.VISIBLE
|
binding.progressBar.visibility = View.VISIBLE
|
||||||
binding.btnSubmit.visibility = View.GONE
|
binding.btnSubmit.visibility = View.GONE
|
||||||
}
|
}
|
||||||
trueHemeTestViewModel.uploadHemoCubeResultToDatabase(
|
hemoCubeViewModel.uploadHemoCubeResultToDatabase(
|
||||||
isOnline, true, sharedPreferences.getString(Constants.KIT_NUMBER, ""),quickCapture
|
isOnline, true, sharedPreferences.getString(Constants.KIT_NUMBER, ""),quickCapture
|
||||||
)
|
)
|
||||||
}else{
|
}else{
|
||||||
@@ -193,6 +208,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
binding.btnSubmit.isEnabled = true
|
binding.btnSubmit.isEnabled = true
|
||||||
binding.btnSubmit.isClickable = true
|
binding.btnSubmit.isClickable = true
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.tvTitle2.visibility = View.GONE
|
binding.tvTitle2.visibility = View.GONE
|
||||||
@@ -207,7 +223,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
binding.tvSubtitle4.text = "Config"
|
binding.tvSubtitle4.text = "Config"
|
||||||
|
|
||||||
if (isBufferValueAvailable()){
|
if (isBufferValueAvailable()){
|
||||||
trueHemeTestViewModel.messages.postValue("Ready to test")
|
hemoCubeViewModel.messages.postValue("Ready to test")
|
||||||
isUsingExistingBuffer = true
|
isUsingExistingBuffer = true
|
||||||
binding.btnPlaceRefreshbuffer.visibility = View.VISIBLE
|
binding.btnPlaceRefreshbuffer.visibility = View.VISIBLE
|
||||||
binding.btnPlacebuffer.visibility = View.GONE
|
binding.btnPlacebuffer.visibility = View.GONE
|
||||||
@@ -218,7 +234,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
binding.btnSamplestart.isClickable = true
|
binding.btnSamplestart.isClickable = true
|
||||||
binding.btnSamplestart.isEnabled = true
|
binding.btnSamplestart.isEnabled = true
|
||||||
}else{
|
}else{
|
||||||
trueHemeTestViewModel.messages.postValue("Fresh Kit - Please take Buffer Blank reading")
|
hemoCubeViewModel.messages.postValue("Fresh Kit - Please take Buffer Blank reading")
|
||||||
binding.btnPlacebuffer.visibility = View.VISIBLE
|
binding.btnPlacebuffer.visibility = View.VISIBLE
|
||||||
binding.btnPlaceRefreshbuffer.visibility = View.GONE
|
binding.btnPlaceRefreshbuffer.visibility = View.GONE
|
||||||
binding.btnPlacebuffer.apply {
|
binding.btnPlacebuffer.apply {
|
||||||
@@ -302,24 +318,24 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun observeViewModel() {
|
private fun observeViewModel() {
|
||||||
trueHemeTestViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
hemoCubeViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
||||||
if (result == "Success") {
|
if (result == "Success") {
|
||||||
uploadedToCloud = true
|
uploadedToCloud = true
|
||||||
var accessToken = sharedPreferences.getString(Constants.ACCESS_TOKEN, "").toString()
|
var accessToken = sharedPreferences.getString(Constants.ACCESS_TOKEN, "").toString()
|
||||||
showToast(R.string.test_upload)
|
showToast(R.string.test_upload)
|
||||||
if (Constants.MOLBIO_INTEGRATION) {
|
if (Constants.MOLBIO_INTEGRATION) {
|
||||||
trueHemeTestViewModel.resultUpload.observe(viewLifecycleOwner) {
|
hemoCubeViewModel.resultUpload.observe(viewLifecycleOwner) {
|
||||||
when (it) {
|
when (it) {
|
||||||
is Result.Success -> {
|
is Result.Success -> {
|
||||||
uploadedToMolbio = true
|
uploadedToMolbio = true
|
||||||
it.data.data?.get(0)?.rawData?.let { it1 ->
|
it.data.data?.get(0)?.rawData?.let { it1 ->
|
||||||
trueHemeTestViewModel.updateMolbioFlag(
|
hemoCubeViewModel.updateMolbioFlag(
|
||||||
it1._id
|
it1._id
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
handleReadingFinish()
|
handleReadingFinish()
|
||||||
trueHemeTestViewModel.uploadLogs()
|
hemoCubeViewModel.uploadLogs()
|
||||||
trueHemeTestViewModel.downloadClientCertificate()
|
hemoCubeViewModel.downloadClientCertificate()
|
||||||
}
|
}
|
||||||
|
|
||||||
is Result.Error -> {
|
is Result.Error -> {
|
||||||
@@ -356,13 +372,13 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
binding.progressBar.visibility = View.GONE
|
binding.progressBar.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
trueHemeTestViewModel.getDeviceData(sharedPreferences.getString(Constants.USER_ID, ""))
|
hemoCubeViewModel.getDeviceData(sharedPreferences.getString(Constants.USER_ID, ""))
|
||||||
|
|
||||||
trueHemeTestViewModel.deviceData.observe(viewLifecycleOwner) {
|
hemoCubeViewModel.deviceData.observe(viewLifecycleOwner) {
|
||||||
currentDeviceData = it
|
currentDeviceData = it
|
||||||
}
|
}
|
||||||
|
|
||||||
trueHemeTestViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
hemoCubeViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
||||||
apply {
|
apply {
|
||||||
DataHolder.hemoCubeTestData?.let {
|
DataHolder.hemoCubeTestData?.let {
|
||||||
currentDeviceData?.coefficients?.let { coefficients ->
|
currentDeviceData?.coefficients?.let { coefficients ->
|
||||||
@@ -375,11 +391,11 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trueHemeTestViewModel.messages.observe(viewLifecycleOwner) {
|
hemoCubeViewModel.messages.observe(viewLifecycleOwner) {
|
||||||
binding.tvSubtitle4.text = it
|
binding.tvSubtitle4.text = it
|
||||||
}
|
}
|
||||||
|
|
||||||
trueHemeTestViewModel.deviceMessages.observe(viewLifecycleOwner) {
|
hemoCubeViewModel.deviceMessages.observe(viewLifecycleOwner) {
|
||||||
binding.tvDeviceMessages.text = it
|
binding.tvDeviceMessages.text = it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -387,7 +403,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
private fun handleReadingFinish() {
|
private fun handleReadingFinish() {
|
||||||
if (allReadingsComplete(repeatReadingCount, readingsPerSample) && uploadedToCloud) {
|
if (allReadingsComplete(repeatReadingCount, readingsPerSample) && uploadedToCloud) {
|
||||||
if (validationError) {
|
if (validationError) {
|
||||||
trueHemeTestViewModel.messages.postValue("Error")
|
hemoCubeViewModel.messages.postValue("Error")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
@@ -398,7 +414,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
startActivity(i)
|
startActivity(i)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
trueHemeTestViewModel.messages.postValue("Reading $repeatReadingCount completed")
|
hemoCubeViewModel.messages.postValue("Reading $repeatReadingCount completed")
|
||||||
resetTest()
|
resetTest()
|
||||||
startSampleProcess()
|
startSampleProcess()
|
||||||
}
|
}
|
||||||
@@ -480,13 +496,13 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
|
|
||||||
private fun listenToHemoCube() {
|
private fun listenToHemoCube() {
|
||||||
DataHolder.hemoCubeTestData = DataHolder.selectedTest?.toHemoCubeTestData()
|
DataHolder.hemoCubeTestData = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||||
trueHemeTestViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
val fullReadOutput = StringBuilder()
|
val fullReadOutput = StringBuilder()
|
||||||
startListening.postValue(true)
|
startListening.postValue(true)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
(activity as TrueHemeTestActivity).mService.listenToHemoCube(object : UsbServiceListener {
|
(activity as HemocubeActivity).mService.listenToHemoCube(object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
data?.let {
|
data?.let {
|
||||||
val stringData = String(it)
|
val stringData = String(it)
|
||||||
@@ -496,7 +512,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
trueHemeTestViewModel.progressBar.postValue(false)
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@@ -506,34 +522,34 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getDeviceInfo() {
|
private fun getDeviceInfo() {
|
||||||
trueHemeTestViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||||
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
data?.let {
|
data?.let {
|
||||||
val stringData = String(it)
|
val stringData = String(it)
|
||||||
trueHemeTestViewModel.messages.postValue(stringData)
|
hemoCubeViewModel.messages.postValue(stringData)
|
||||||
binding.tvSubtitle4.text = stringData
|
binding.tvSubtitle4.text = stringData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
trueHemeTestViewModel.progressBar.postValue(false)
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadDACValues() {
|
private fun loadDACValues() {
|
||||||
trueHemeTestViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||||
HemoCubeCommands.LOAD_DAC_VALUES,
|
HemoCubeCommands.LOAD_DAC_VALUES,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
trueHemeTestViewModel.progressBar.postValue(false)
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -545,7 +561,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
|
|
||||||
resultData += stringData
|
resultData += stringData
|
||||||
currentResultData += stringData
|
currentResultData += stringData
|
||||||
trueHemeTestViewModel.deviceMessages.postValue(currentResultData)
|
hemoCubeViewModel.deviceMessages.postValue(currentResultData)
|
||||||
Log.e("testStatus",this.testStatusCode.toString())
|
Log.e("testStatus",this.testStatusCode.toString())
|
||||||
when {
|
when {
|
||||||
resultData.contains("SNE") && this.testStatusCode < TestStatus.CONFIG_COMPLETED.code -> {
|
resultData.contains("SNE") && this.testStatusCode < TestStatus.CONFIG_COMPLETED.code -> {
|
||||||
@@ -560,13 +576,13 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
(resultData.contains("#LS") && this.testStatusCode < TestStatus.FIRST_EMPTY_AIR_READING_STARTED.code) -> {
|
(resultData.contains("#LS") && this.testStatusCode < TestStatus.FIRST_EMPTY_AIR_READING_STARTED.code) -> {
|
||||||
// air reading 1
|
// air reading 1
|
||||||
this.testStatusCode = TestStatus.FIRST_EMPTY_AIR_READING_STARTED.code
|
this.testStatusCode = TestStatus.FIRST_EMPTY_AIR_READING_STARTED.code
|
||||||
trueHemeTestViewModel.messages.postValue("Air reading started")
|
hemoCubeViewModel.messages.postValue("Air reading started")
|
||||||
}
|
}
|
||||||
|
|
||||||
(resultData.contains("#LC") && this.testStatusCode < TestStatus.FIRST_EMPTY_AIR_READING_COMPLETED.code) -> {
|
(resultData.contains("#LC") && this.testStatusCode < TestStatus.FIRST_EMPTY_AIR_READING_COMPLETED.code) -> {
|
||||||
// air reading 1, send command to print
|
// air reading 1, send command to print
|
||||||
this.testStatusCode = TestStatus.FIRST_EMPTY_AIR_READING_COMPLETED.code
|
this.testStatusCode = TestStatus.FIRST_EMPTY_AIR_READING_COMPLETED.code
|
||||||
trueHemeTestViewModel.messages.postValue("Air reading completed")
|
hemoCubeViewModel.messages.postValue("Air reading completed")
|
||||||
fetchResult()
|
fetchResult()
|
||||||
}
|
}
|
||||||
//#EC for v0 and v1 and #RC for v2
|
//#EC for v0 and v1 and #RC for v2
|
||||||
@@ -592,7 +608,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
//hemoCubeViewModel.messages.postValue("Ready to test \n Temperature : $temperature")
|
//hemoCubeViewModel.messages.postValue("Ready to test \n Temperature : $temperature")
|
||||||
}
|
}
|
||||||
resultData.contains("#CIN") && sampleClick && this.testStatusCode < TestStatus.CUVETTE_PRESENTS.code -> {
|
resultData.contains("#CIN") && sampleClick && this.testStatusCode < TestStatus.CUVETTE_PRESENTS.code -> {
|
||||||
trueHemeTestViewModel.messages.postValue(getString(R.string.cuvette_present))
|
hemoCubeViewModel.messages.postValue(getString(R.string.cuvette_present))
|
||||||
this.testStatusCode = TestStatus.CUVETTE_PRESENTS.code
|
this.testStatusCode = TestStatus.CUVETTE_PRESENTS.code
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
checkCuvetteSam = true
|
checkCuvetteSam = true
|
||||||
@@ -604,7 +620,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
resultData.contains("#AIN") && sampleClick && this.testStatusCode <= TestStatus.CUVETTE_ABSENTS.code -> {
|
resultData.contains("#AIN") && sampleClick && this.testStatusCode <= TestStatus.CUVETTE_ABSENTS.code -> {
|
||||||
trueHemeTestViewModel.messages.postValue(getString(R.string.cuvette_absent))
|
hemoCubeViewModel.messages.postValue(getString(R.string.cuvette_absent))
|
||||||
this.testStatusCode = TestStatus.CUVETTE_ABSENTS.code
|
this.testStatusCode = TestStatus.CUVETTE_ABSENTS.code
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
binding.testing.visibility = View.GONE
|
binding.testing.visibility = View.GONE
|
||||||
@@ -612,7 +628,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
showRetryButtonForCuvette()
|
showRetryButtonForCuvette()
|
||||||
}
|
}
|
||||||
resultData.contains("#CIN") && refreshClick && this.testStatusCode < TestStatus.CUVETTE_PRESENTR.code -> {
|
resultData.contains("#CIN") && refreshClick && this.testStatusCode < TestStatus.CUVETTE_PRESENTR.code -> {
|
||||||
trueHemeTestViewModel.messages.postValue(getString(R.string.cuvette_present))
|
hemoCubeViewModel.messages.postValue(getString(R.string.cuvette_present))
|
||||||
this.testStatusCode = TestStatus.CUVETTE_PRESENTR.code
|
this.testStatusCode = TestStatus.CUVETTE_PRESENTR.code
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
checkRefreshCuvette = true
|
checkRefreshCuvette = true
|
||||||
@@ -626,7 +642,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
resultData.contains("#AIN") && refreshClick && this.testStatusCode <= TestStatus.CUVETTE_ABSENTR.code -> {
|
resultData.contains("#AIN") && refreshClick && this.testStatusCode <= TestStatus.CUVETTE_ABSENTR.code -> {
|
||||||
trueHemeTestViewModel.messages.postValue(getString(R.string.cuvette_absent))
|
hemoCubeViewModel.messages.postValue(getString(R.string.cuvette_absent))
|
||||||
this.testStatusCode = TestStatus.CUVETTE_ABSENTR.code
|
this.testStatusCode = TestStatus.CUVETTE_ABSENTR.code
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
binding.testing.visibility = View.GONE
|
binding.testing.visibility = View.GONE
|
||||||
@@ -636,7 +652,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
showRetryButtonForCuvette()
|
showRetryButtonForCuvette()
|
||||||
}
|
}
|
||||||
resultData.contains("#CIN") && this.testStatusCode < TestStatus.CUVETTE_PRESENT.code -> {
|
resultData.contains("#CIN") && this.testStatusCode < TestStatus.CUVETTE_PRESENT.code -> {
|
||||||
trueHemeTestViewModel.messages.postValue(getString(R.string.cuvette_present))
|
hemoCubeViewModel.messages.postValue(getString(R.string.cuvette_present))
|
||||||
this.testStatusCode = TestStatus.CUVETTE_PRESENT.code
|
this.testStatusCode = TestStatus.CUVETTE_PRESENT.code
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
checkCuvette = true
|
checkCuvette = true
|
||||||
@@ -649,7 +665,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
resultData.contains("#AIN") && this.testStatusCode <= TestStatus.CUVETTE_ABSENT.code -> {
|
resultData.contains("#AIN") && this.testStatusCode <= TestStatus.CUVETTE_ABSENT.code -> {
|
||||||
trueHemeTestViewModel.messages.postValue(getString(R.string.cuvette_absent))
|
hemoCubeViewModel.messages.postValue(getString(R.string.cuvette_absent))
|
||||||
this.testStatusCode = TestStatus.CUVETTE_ABSENT.code
|
this.testStatusCode = TestStatus.CUVETTE_ABSENT.code
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
binding.testing.visibility = View.GONE
|
binding.testing.visibility = View.GONE
|
||||||
@@ -659,23 +675,22 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
showRetryButtonForCuvette()
|
showRetryButtonForCuvette()
|
||||||
}
|
}
|
||||||
resultData.contains("#CIN") && this.submitClick && this.testStatusCode < TestStatus.CUVETTE_PRESENTT.code -> {
|
resultData.contains("#CIN") && this.submitClick && this.testStatusCode < TestStatus.CUVETTE_PRESENTT.code -> {
|
||||||
trueHemeTestViewModel.messages.postValue(getString(R.string.cuvette_presentt))
|
hemoCubeViewModel.messages.postValue(getString(R.string.cuvette_presentt))
|
||||||
this.testStatusCode = TestStatus.CUVETTE_PRESENTT.code
|
this.testStatusCode = TestStatus.CUVETTE_PRESENTT.code
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
binding.testing.visibility = View.GONE
|
binding.testing.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resultData.contains("#AIN") && this.submitClick && this.testStatusCode <= TestStatus.CUVETTE_ABSENTT.code -> {
|
resultData.contains("#AIN") && this.submitClick && this.testStatusCode <= TestStatus.CUVETTE_ABSENTT.code -> {
|
||||||
trueHemeTestViewModel.messages.postValue(getString(R.string.cuvette_absentt))
|
hemoCubeViewModel.messages.postValue(getString(R.string.cuvette_absentt))
|
||||||
this.testStatusCode = TestStatus.CUVETTE_ABSENTT.code
|
this.testStatusCode = TestStatus.CUVETTE_ABSENTT.code
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
checkSubmit = true
|
checkSubmit = true
|
||||||
binding.testing.visibility = View.GONE
|
binding.testing.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resultData.contains("#BS") && this.testStatusCode < TestStatus.BUFFER_STARTED.code -> {
|
resultData.contains("#BS") && this.testStatusCode < TestStatus.BUFFER_STARTED.code -> {
|
||||||
trueHemeTestViewModel.messages.postValue(getString(R.string.buffer_started))
|
hemoCubeViewModel.messages.postValue(getString(R.string.buffer_started))
|
||||||
this.testStatusCode = TestStatus.BUFFER_STARTED.code
|
this.testStatusCode = TestStatus.BUFFER_STARTED.code
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
binding.btnPlacebuffer.visibility = View.GONE
|
binding.btnPlacebuffer.visibility = View.GONE
|
||||||
@@ -709,7 +724,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
resultData.contains("REND") && this.testStatusCode < TestStatus.BUFFER_PRINT_COMPLETED.code -> {
|
resultData.contains("REND") && this.testStatusCode < TestStatus.BUFFER_PRINT_COMPLETED.code -> {
|
||||||
resultData = resultData.replace("REND","Buffer print complete"+ generateTwoDigitRandomNumber())
|
resultData = resultData.replace("REND","Buffer print complete"+ generateTwoDigitRandomNumber())
|
||||||
trueHemeTestViewModel.deviceMessages.postValue(resultData)
|
hemoCubeViewModel.deviceMessages.postValue(resultData)
|
||||||
if(handleBufferCompleted()){
|
if(handleBufferCompleted()){
|
||||||
this.testStatusCode = TestStatus.TEMPERATURE_CHECK.code
|
this.testStatusCode = TestStatus.TEMPERATURE_CHECK.code
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
@@ -745,77 +760,79 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
(resultData.contains("#SC") || resultData.contains("#SC1")) && this.testStatusCode < TestStatus.SAMPLE_COMPLETED.code -> {
|
(resultData.contains("#SC") || resultData.contains("#SC1")) && this.testStatusCode < TestStatus.SAMPLE_COMPLETED.code -> {
|
||||||
this.testStatusCode = TestStatus.SAMPLE_COMPLETED.code
|
this.testStatusCode = TestStatus.SAMPLE_COMPLETED.code
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
binding.testing.visibility = View.GONE
|
binding.testing.visibility = View.GONE
|
||||||
binding.btnSamplestart.visibility = View.GONE
|
binding.btnSamplestart.visibility = View.GONE
|
||||||
}
|
}
|
||||||
trueHemeTestViewModel.messages.postValue(
|
hemoCubeViewModel.messages.postValue(
|
||||||
getString(R.string.sample_completed) + "\n" + getString(R.string.gathering_data)
|
getString(R.string.sample_completed) + "\n" + getString(R.string.gathering_data)
|
||||||
)
|
)
|
||||||
currentResultData = ""
|
currentResultData = ""
|
||||||
fetchResult()
|
fetchResult()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
resultData.contains("ovf") -> {
|
resultData.contains("ovf") -> {
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
binding.testing.visibility = View.GONE
|
binding.testing.visibility = View.GONE
|
||||||
}
|
}
|
||||||
trueHemeTestViewModel.messages.postValue(
|
hemoCubeViewModel.messages.postValue(
|
||||||
getString(R.string.power_bank)
|
getString(R.string.power_bank)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
currentResultData.contains("#SS2") && this.testStatusCode < TestStatus.FIRST_GAIN_STARTED.code -> {
|
currentResultData.contains("#SS2") && this.testStatusCode < TestStatus.FIRST_GAIN_STARTED.code -> {
|
||||||
this.testStatusCode = TestStatus.FIRST_GAIN_STARTED.code
|
this.testStatusCode = TestStatus.FIRST_GAIN_STARTED.code
|
||||||
trueHemeTestViewModel.messages.postValue("1.3X Gain Started")
|
hemoCubeViewModel.messages.postValue("1.3X Gain Started")
|
||||||
}
|
}
|
||||||
|
|
||||||
currentResultData.contains("#SC2") && this.testStatusCode < TestStatus.FIRST_GAIN_COMPLETED.code -> {
|
currentResultData.contains("#SC2") && this.testStatusCode < TestStatus.FIRST_GAIN_COMPLETED.code -> {
|
||||||
this.testStatusCode = TestStatus.FIRST_GAIN_COMPLETED.code
|
this.testStatusCode = TestStatus.FIRST_GAIN_COMPLETED.code
|
||||||
trueHemeTestViewModel.messages.postValue("1.3X Gain Completed")
|
hemoCubeViewModel.messages.postValue("1.3X Gain Completed")
|
||||||
fetchResult()
|
fetchResult()
|
||||||
}
|
}
|
||||||
|
|
||||||
currentResultData.contains("#SS3") && this.testStatusCode < TestStatus.SECOND_GAIN_STARTED.code -> {
|
currentResultData.contains("#SS3") && this.testStatusCode < TestStatus.SECOND_GAIN_STARTED.code -> {
|
||||||
this.testStatusCode = TestStatus.SECOND_GAIN_STARTED.code
|
this.testStatusCode = TestStatus.SECOND_GAIN_STARTED.code
|
||||||
trueHemeTestViewModel.messages.postValue("2X Gain Started")
|
hemoCubeViewModel.messages.postValue("2X Gain Started")
|
||||||
}
|
}
|
||||||
|
|
||||||
currentResultData.contains("#SC3") && this.testStatusCode < TestStatus.SECOND_GAIN_COMPLETED.code -> {
|
currentResultData.contains("#SC3") && this.testStatusCode < TestStatus.SECOND_GAIN_COMPLETED.code -> {
|
||||||
this.testStatusCode = TestStatus.SECOND_GAIN_COMPLETED.code
|
this.testStatusCode = TestStatus.SECOND_GAIN_COMPLETED.code
|
||||||
trueHemeTestViewModel.messages.postValue("2X Gain Completed")
|
hemoCubeViewModel.messages.postValue("2X Gain Completed")
|
||||||
fetchResult()
|
fetchResult()
|
||||||
}
|
}
|
||||||
|
|
||||||
currentResultData.contains("#SS5") && this.testStatusCode < TestStatus.FORTH_GAIN_STARTED.code -> {
|
currentResultData.contains("#SS5") && this.testStatusCode < TestStatus.FORTH_GAIN_STARTED.code -> {
|
||||||
this.testStatusCode = TestStatus.FORTH_GAIN_STARTED.code
|
this.testStatusCode = TestStatus.FORTH_GAIN_STARTED.code
|
||||||
trueHemeTestViewModel.messages.postValue("7.6X Gain Started")
|
hemoCubeViewModel.messages.postValue("7.6X Gain Started")
|
||||||
}
|
}
|
||||||
|
|
||||||
currentResultData.contains("#SC5") && this.testStatusCode < TestStatus.FORTH_GAIN_COMPLETED.code -> {
|
currentResultData.contains("#SC5") && this.testStatusCode < TestStatus.FORTH_GAIN_COMPLETED.code -> {
|
||||||
this.testStatusCode = TestStatus.FORTH_GAIN_COMPLETED.code
|
this.testStatusCode = TestStatus.FORTH_GAIN_COMPLETED.code
|
||||||
trueHemeTestViewModel.messages.postValue("7.6X Gain Completed")
|
hemoCubeViewModel.messages.postValue("7.6X Gain Completed")
|
||||||
fetchResult()
|
fetchResult()
|
||||||
}
|
}
|
||||||
|
|
||||||
(resultData.contains("#LS") && this.testStatusCode < TestStatus.SECOND_EMPTY_AIR_READING_STARTED.code) -> {
|
(resultData.contains("#LS") && this.testStatusCode < TestStatus.SECOND_EMPTY_AIR_READING_STARTED.code) -> {
|
||||||
// air reading 2
|
// air reading 2
|
||||||
this.testStatusCode = TestStatus.SECOND_EMPTY_AIR_READING_STARTED.code
|
this.testStatusCode = TestStatus.SECOND_EMPTY_AIR_READING_STARTED.code
|
||||||
trueHemeTestViewModel.messages.postValue("Air reading started")
|
hemoCubeViewModel.messages.postValue("Air reading started")
|
||||||
}
|
}
|
||||||
|
|
||||||
(resultData.contains("#LC") && this.testStatusCode < TestStatus.SECOND_EMPTY_AIR_READING_COMPLETED.code) -> {
|
(resultData.contains("#LC") && this.testStatusCode < TestStatus.SECOND_EMPTY_AIR_READING_COMPLETED.code) -> {
|
||||||
// air reading 2, print values
|
// air reading 2, print values
|
||||||
this.testStatusCode = TestStatus.SECOND_EMPTY_AIR_READING_COMPLETED.code
|
this.testStatusCode = TestStatus.SECOND_EMPTY_AIR_READING_COMPLETED.code
|
||||||
trueHemeTestViewModel.messages.postValue("Air reading completed")
|
hemoCubeViewModel.messages.postValue("Air reading completed")
|
||||||
fetchResult()
|
fetchResult()
|
||||||
}
|
}
|
||||||
|
|
||||||
resultData.contains("REND") && this.testStatusCode < TestStatus.SAMPLE_PRINT_COMPLETED.code -> {
|
resultData.contains("REND") && this.testStatusCode < TestStatus.SAMPLE_PRINT_COMPLETED.code -> {
|
||||||
resultData = resultData.replace("REND","Sample print complete"+ generateTwoDigitRandomNumber())
|
resultData = resultData.replace("REND","Sample print complete"+ generateTwoDigitRandomNumber())
|
||||||
trueHemeTestViewModel.deviceMessages.postValue(resultData)
|
hemoCubeViewModel.deviceMessages.postValue(resultData)
|
||||||
handleSampleCompleted()
|
handleSampleCompleted()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -823,7 +840,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
&& this.testStatusCode >= TestStatus.FIRST_EMPTY_AIR_READING_COMPLETED.code
|
&& this.testStatusCode >= TestStatus.FIRST_EMPTY_AIR_READING_COMPLETED.code
|
||||||
&& this.testStatusCode < TestStatus.FIRST_EMPTY_AIR_READING_PRINT_COMPLETED.code -> {
|
&& this.testStatusCode < TestStatus.FIRST_EMPTY_AIR_READING_PRINT_COMPLETED.code -> {
|
||||||
this.testStatusCode = TestStatus.FIRST_GAIN_PRINT_COMPLETED.code
|
this.testStatusCode = TestStatus.FIRST_GAIN_PRINT_COMPLETED.code
|
||||||
trueHemeTestViewModel.messages.postValue("First air reading completed")
|
hemoCubeViewModel.messages.postValue("First air reading completed")
|
||||||
|
|
||||||
val resultLines = currentResultData.split("\\s+(?=LB|LS)".toRegex())
|
val resultLines = currentResultData.split("\\s+(?=LB|LS)".toRegex())
|
||||||
DataHolder.hemoCubeTestData?.apply {
|
DataHolder.hemoCubeTestData?.apply {
|
||||||
@@ -841,7 +858,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
&& this.testStatusCode >= TestStatus.SECOND_EMPTY_AIR_READING_COMPLETED.code
|
&& this.testStatusCode >= TestStatus.SECOND_EMPTY_AIR_READING_COMPLETED.code
|
||||||
&& this.testStatusCode < TestStatus.SECOND_EMPTY_AIR_PRINT_COMPLETED.code -> {
|
&& this.testStatusCode < TestStatus.SECOND_EMPTY_AIR_PRINT_COMPLETED.code -> {
|
||||||
this.testStatusCode = TestStatus.SECOND_EMPTY_AIR_PRINT_COMPLETED.code
|
this.testStatusCode = TestStatus.SECOND_EMPTY_AIR_PRINT_COMPLETED.code
|
||||||
trueHemeTestViewModel.messages.postValue("Second air reading completed")
|
hemoCubeViewModel.messages.postValue("Second air reading completed")
|
||||||
|
|
||||||
val resultLines = currentResultData.split("\\s+(?=LB|LS)".toRegex())
|
val resultLines = currentResultData.split("\\s+(?=LB|LS)".toRegex())
|
||||||
DataHolder.hemoCubeTestData?.apply {
|
DataHolder.hemoCubeTestData?.apply {
|
||||||
@@ -859,7 +876,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
&& this.testStatusCode >= TestStatus.FIRST_GAIN_COMPLETED.code
|
&& this.testStatusCode >= TestStatus.FIRST_GAIN_COMPLETED.code
|
||||||
&& this.testStatusCode < TestStatus.FIRST_GAIN_PRINT_COMPLETED.code -> {
|
&& this.testStatusCode < TestStatus.FIRST_GAIN_PRINT_COMPLETED.code -> {
|
||||||
this.testStatusCode = TestStatus.FIRST_GAIN_PRINT_COMPLETED.code
|
this.testStatusCode = TestStatus.FIRST_GAIN_PRINT_COMPLETED.code
|
||||||
trueHemeTestViewModel.messages.postValue("1.3X gain data gathered")
|
hemoCubeViewModel.messages.postValue("1.3X gain data gathered")
|
||||||
|
|
||||||
val resultLines = currentResultData.split("\\s+(?=LB|LS)".toRegex())
|
val resultLines = currentResultData.split("\\s+(?=LB|LS)".toRegex())
|
||||||
DataHolder.hemoCubeTestData?.apply {
|
DataHolder.hemoCubeTestData?.apply {
|
||||||
@@ -878,7 +895,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
&& this.testStatusCode >= TestStatus.FIRST_GAIN_PRINT_COMPLETED.code
|
&& this.testStatusCode >= TestStatus.FIRST_GAIN_PRINT_COMPLETED.code
|
||||||
&& this.testStatusCode < TestStatus.SECOND_GAIN_PRINT_COMPLETED.code -> {
|
&& this.testStatusCode < TestStatus.SECOND_GAIN_PRINT_COMPLETED.code -> {
|
||||||
this.testStatusCode = TestStatus.SECOND_GAIN_PRINT_COMPLETED.code
|
this.testStatusCode = TestStatus.SECOND_GAIN_PRINT_COMPLETED.code
|
||||||
trueHemeTestViewModel.messages.postValue("2X gain data gathered")
|
hemoCubeViewModel.messages.postValue("2X gain data gathered")
|
||||||
|
|
||||||
val resultLines = currentResultData.split("\\s+(?=LB|LS)".toRegex())
|
val resultLines = currentResultData.split("\\s+(?=LB|LS)".toRegex())
|
||||||
DataHolder.hemoCubeTestData?.apply {
|
DataHolder.hemoCubeTestData?.apply {
|
||||||
@@ -897,7 +914,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
&& this.testStatusCode >= TestStatus.SECOND_GAIN_PRINT_COMPLETED.code
|
&& this.testStatusCode >= TestStatus.SECOND_GAIN_PRINT_COMPLETED.code
|
||||||
&& this.testStatusCode < TestStatus.FORTH_GAIN_PRINT_COMPLETED.code -> {
|
&& this.testStatusCode < TestStatus.FORTH_GAIN_PRINT_COMPLETED.code -> {
|
||||||
this.testStatusCode = TestStatus.FORTH_GAIN_PRINT_COMPLETED.code
|
this.testStatusCode = TestStatus.FORTH_GAIN_PRINT_COMPLETED.code
|
||||||
trueHemeTestViewModel.messages.postValue("7.6X gain data gathered")
|
hemoCubeViewModel.messages.postValue("7.6X gain data gathered")
|
||||||
|
|
||||||
val resultLines = currentResultData.split("\\s+(?=LB|LS)".toRegex())
|
val resultLines = currentResultData.split("\\s+(?=LB|LS)".toRegex())
|
||||||
DataHolder.hemoCubeTestData?.apply {
|
DataHolder.hemoCubeTestData?.apply {
|
||||||
@@ -923,16 +940,16 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
val lb2Value = lb2Match!!.groupValues[1].toFloat()
|
val lb2Value = lb2Match!!.groupValues[1].toFloat()
|
||||||
|
|
||||||
// val led1Min = sharedPreferences.getString("bufferMinLed1", "21000.00")?.toDouble()
|
// val led1Min = sharedPreferences.getString("bufferMinLed1", "21000.00")?.toDouble()
|
||||||
val led1Min = Constants.bufferMinLed1
|
val led1Min = sharedPreferences.getString("bufferMinLed1", Constants.bufferMinLed1.toString())?.toDoubleOrNull() ?: Constants.bufferMinLed1
|
||||||
val led1Max = Constants.bufferMaxLed1
|
val led1Max = sharedPreferences.getString("bufferMaxLed1", Constants.bufferMaxLed1.toString())?.toDoubleOrNull() ?: Constants.bufferMaxLed1
|
||||||
|
|
||||||
val led2Min = Constants.bufferMinLed2
|
val led2Min = sharedPreferences.getString("bufferMinLed2", Constants.bufferMinLed2.toString())?.toDoubleOrNull() ?: Constants.bufferMinLed2
|
||||||
val led2Max = Constants.bufferMaxLed2
|
val led2Max = sharedPreferences.getString("bufferMaxLed2", Constants.bufferMaxLed2.toString())?.toDoubleOrNull() ?: Constants.bufferMaxLed2
|
||||||
|
|
||||||
val isLb1InRange = lb1Value in led1Min..led1Max
|
val isLb1InRange = lb1Value in led1Min..led1Max
|
||||||
val isLb2InRange = lb2Value in led2Min..led2Max
|
val isLb2InRange = lb2Value in led2Min..led2Max
|
||||||
if(!isLb1InRange || !isLb2InRange){
|
if(!isLb1InRange || !isLb2InRange){
|
||||||
trueHemeTestViewModel.messages.postValue("Buffer Reading Out of Range - Please Take Buffer/Blank Reading. If problem persists, Calibrate device")
|
hemoCubeViewModel.messages.postValue("Buffer Reading Out of Range - Please Take Buffer/Blank Reading. If problem persists, Calibrate device")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -964,7 +981,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
binding.ivCheck.visibility = View.VISIBLE
|
binding.ivCheck.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
trueHemeTestViewModel.uploadHemoCubeResultToDatabase(
|
hemoCubeViewModel.uploadHemoCubeResultToDatabase(
|
||||||
isOnline, true, sharedPreferences.getString(Constants.KIT_NUMBER, ""),false
|
isOnline, true, sharedPreferences.getString(Constants.KIT_NUMBER, ""),false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -973,7 +990,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
fun handleSampleCompleted() {
|
fun handleSampleCompleted() {
|
||||||
|
|
||||||
this.testStatusCode = TestStatus.SAMPLE_PRINT_COMPLETED.code
|
this.testStatusCode = TestStatus.SAMPLE_PRINT_COMPLETED.code
|
||||||
trueHemeTestViewModel.messages.postValue(
|
hemoCubeViewModel.messages.postValue(
|
||||||
getString(R.string.data_collected_processing_data)
|
getString(R.string.data_collected_processing_data)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1018,7 +1035,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
if (!hardwareId.isNullOrBlank()) {
|
if (!hardwareId.isNullOrBlank()) {
|
||||||
updateDeviceId(hardwareId)
|
updateDeviceId(hardwareId)
|
||||||
} else {
|
} else {
|
||||||
trueHemeTestViewModel.messages.postValue("Config error")
|
hemoCubeViewModel.messages.postValue("Config error")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Constants.DEVICE_CONFIGURATION.containsKey(deviceHardwareId)) {
|
if (!Constants.DEVICE_CONFIGURATION.containsKey(deviceHardwareId)) {
|
||||||
@@ -1065,7 +1082,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
// }
|
// }
|
||||||
// hemoCubeViewModel.messages.postValue(getString(R.string.start))
|
// hemoCubeViewModel.messages.postValue(getString(R.string.start))
|
||||||
} else {
|
} else {
|
||||||
trueHemeTestViewModel.messages.postValue("Config error")
|
hemoCubeViewModel.messages.postValue("Config error")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Constants.DEVICE_CONFIGURATION.containsKey(deviceHardwareId)) {
|
if (!Constants.DEVICE_CONFIGURATION.containsKey(deviceHardwareId)) {
|
||||||
@@ -1115,7 +1132,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
|
|
||||||
private fun processResult() {
|
private fun processResult() {
|
||||||
try {
|
try {
|
||||||
trueHemeTestViewModel.messages.postValue(getString(R.string.processing_result))
|
hemoCubeViewModel.messages.postValue(getString(R.string.processing_result))
|
||||||
val deviceLog = resultData
|
val deviceLog = resultData
|
||||||
|
|
||||||
val pInfo = requireActivity().packageManager.getPackageInfo(
|
val pInfo = requireActivity().packageManager.getPackageInfo(
|
||||||
@@ -1134,7 +1151,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
// Toast.makeText(requireContext(),"count: ${DataHolder.sampleReadCounter}",Toast.LENGTH_LONG).show()
|
// Toast.makeText(requireContext(),"count: ${DataHolder.sampleReadCounter}",Toast.LENGTH_LONG).show()
|
||||||
// }
|
// }
|
||||||
if(led1Average < 0 || led2Average < 0){
|
if(led1Average < 0 || led2Average < 0){
|
||||||
trueHemeTestViewModel.messages.postValue("Negative Absorbance - Repeat test with reading Buffer first and sample second")
|
hemoCubeViewModel.messages.postValue("Negative Absorbance - Repeat test with reading Buffer first and sample second")
|
||||||
this.testStatusCode = TestStatus.BUFFER_PRINT_COMPLETED.code
|
this.testStatusCode = TestStatus.BUFFER_PRINT_COMPLETED.code
|
||||||
binding.testing.visibility = View.GONE
|
binding.testing.visibility = View.GONE
|
||||||
binding.btnPlacebuffer.visibility = View.GONE
|
binding.btnPlacebuffer.visibility = View.GONE
|
||||||
@@ -1158,7 +1175,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
val min10mmLed2 = getDoubleFromPreferences(Constants.ABS10LED2MMLL, Constants.min10mmLed2)
|
val min10mmLed2 = getDoubleFromPreferences(Constants.ABS10LED2MMLL, Constants.min10mmLed2)
|
||||||
val max10mmLed2 = getDoubleFromPreferences(Constants.ABS10LED2MMUL, Constants.max10mmLed2)
|
val max10mmLed2 = getDoubleFromPreferences(Constants.ABS10LED2MMUL, Constants.max10mmLed2)
|
||||||
if(led1Average < 0 || led2Average < 0){
|
if(led1Average < 0 || led2Average < 0){
|
||||||
trueHemeTestViewModel.messages.postValue("Negative Absorbance - Repeat test with reading Buffer first and sample second")
|
hemoCubeViewModel.messages.postValue("Negative Absorbance - Repeat test with reading Buffer first and sample second")
|
||||||
this.testStatusCode = TestStatus.BUFFER_PRINT_COMPLETED.code
|
this.testStatusCode = TestStatus.BUFFER_PRINT_COMPLETED.code
|
||||||
binding.testing.visibility = View.GONE
|
binding.testing.visibility = View.GONE
|
||||||
binding.btnPlaceRefreshbuffer.visibility = View.GONE
|
binding.btnPlaceRefreshbuffer.visibility = View.GONE
|
||||||
@@ -1168,11 +1185,11 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
binding.btnSamplestart.isEnabled = true
|
binding.btnSamplestart.isEnabled = true
|
||||||
return
|
return
|
||||||
}else{
|
}else{
|
||||||
if(cuvetteSizeSP == "10mm"){
|
if(cuvetteSize == "10mm"){
|
||||||
inRange10mmLed1 = led1Average in min10mmLed1..max10mmLed1
|
inRange10mmLed1 = led1Average in min10mmLed1..max10mmLed1
|
||||||
inRange10mmLed2 = led2Average in min10mmLed2..max10mmLed2
|
inRange10mmLed2 = led2Average in min10mmLed2..max10mmLed2
|
||||||
if(!inRange10mmLed1 || !inRange10mmLed2){
|
if(!inRange10mmLed1 || !inRange10mmLed2){
|
||||||
trueHemeTestViewModel.messages.postValue("Absorbance out-of-Range - Repeat test with adequate blood volume and Incubation time")
|
hemoCubeViewModel.messages.postValue("Absorbance out-of-Range - Repeat test with adequate blood volume and Incubation time")
|
||||||
this.testStatusCode = TestStatus.BUFFER_PRINT_COMPLETED.code
|
this.testStatusCode = TestStatus.BUFFER_PRINT_COMPLETED.code
|
||||||
binding.testing.visibility = View.GONE
|
binding.testing.visibility = View.GONE
|
||||||
binding.btnPlaceRefreshbuffer.visibility = View.GONE
|
binding.btnPlaceRefreshbuffer.visibility = View.GONE
|
||||||
@@ -1182,11 +1199,11 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
binding.btnSamplestart.isEnabled = true
|
binding.btnSamplestart.isEnabled = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}else if(cuvetteSizeSP == "2mm"){
|
}else if(cuvetteSize == "2mm"){
|
||||||
inRange2mmLed1 = led1Average in min2mmLed1..max2mmLed1
|
inRange2mmLed1 = led1Average in min2mmLed1..max2mmLed1
|
||||||
inRange2mmLed2 = led2Average in min2mmLed2..max2mmLed2
|
inRange2mmLed2 = led2Average in min2mmLed2..max2mmLed2
|
||||||
if(!inRange2mmLed1 || !inRange2mmLed2){
|
if(!inRange2mmLed1 || !inRange2mmLed2){
|
||||||
trueHemeTestViewModel.messages.postValue("Absorbance out-of-Range - Repeat test with adequate blood volume and Incubation time")
|
hemoCubeViewModel.messages.postValue("Absorbance out-of-Range - Repeat test with adequate blood volume and Incubation time")
|
||||||
this.testStatusCode = TestStatus.BUFFER_PRINT_COMPLETED.code
|
this.testStatusCode = TestStatus.BUFFER_PRINT_COMPLETED.code
|
||||||
binding.testing.visibility = View.GONE
|
binding.testing.visibility = View.GONE
|
||||||
binding.btnPlaceRefreshbuffer.visibility = View.GONE
|
binding.btnPlaceRefreshbuffer.visibility = View.GONE
|
||||||
@@ -1346,17 +1363,16 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
this.coefficients = currentDeviceData?.coefficients?.get(0)
|
this.coefficients = currentDeviceData?.coefficients?.get(0)
|
||||||
.toString() + ", " + currentDeviceData?.coefficients?.get(1).toString()
|
.toString() + ", " + currentDeviceData?.coefficients?.get(1).toString()
|
||||||
this.prdClassification = absorbanceBasedClassification(predictedDenovixRatio)
|
this.prdClassification = absorbanceBasedClassification(predictedDenovixRatio)
|
||||||
this.deviceRatioClass = deviceRatioClassification(cuvetteSizeSP,deviceRatio)
|
this.deviceRatioClass = deviceRatioClassification(deviceRatio)
|
||||||
this.borderlineMethod2Class = reclassifyWithBorderlineMethod2(deviceRatio, deviceRatioBorderlineThresholds(deviceRatio), led2Average)
|
this.borderlineMethod2Class = reclassifyWithBorderlineMethod2(deviceRatio, deviceRatioBorderlineThresholds(deviceRatio), led2Average)
|
||||||
this.slopeRatioClass = slopeClass
|
this.slopeRatioClass = slopeClass
|
||||||
this.classificationResult = findResultWithAdditionalMethods(
|
this.classificationResult = findResultWithAdditionalMethods(
|
||||||
cuvetteSizeSP,
|
|
||||||
deviceRatio,
|
deviceRatio,
|
||||||
deviceRatioClass,
|
deviceRatioClass,
|
||||||
borderlineMetric
|
borderlineMetric
|
||||||
)
|
)
|
||||||
Log.d("HemoCubeFragment",this.classificationResult)
|
Log.d("HemoCubeFragment",this.classificationResult)
|
||||||
trueHemeTestViewModel.messages.postValue(
|
hemoCubeViewModel.messages.postValue(
|
||||||
"${this.classificationResult} \n Device Ratio: ${
|
"${this.classificationResult} \n Device Ratio: ${
|
||||||
"%.3f".format(
|
"%.3f".format(
|
||||||
this.deviceRatio
|
this.deviceRatio
|
||||||
@@ -1365,20 +1381,20 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
"%.3f".format(
|
"%.3f".format(
|
||||||
borderlineMetric
|
borderlineMetric
|
||||||
)
|
)
|
||||||
}"
|
} \n Remove Cuvette & Click Submit"
|
||||||
)
|
)
|
||||||
if (DataHolder.hemoCubeTestData?.testType == "HB")
|
if (DataHolder.hemoCubeTestData?.testType == "HB")
|
||||||
trueHemeTestViewModel.messages.postValue("Hb: $calculatedHb4")
|
hemoCubeViewModel.messages.postValue("Hb: $calculatedHb4")
|
||||||
this.errorMessages = testState.allErrorMessages
|
this.errorMessages = testState.allErrorMessages
|
||||||
this.resultData = deviceLog
|
this.resultData = deviceLog
|
||||||
this.batteryLevel = trueHemeTestViewModel.getBatteryLevel().toString()
|
this.batteryLevel = hemoCubeViewModel.getBatteryLevel().toString()
|
||||||
this.batteryCapacity =
|
this.batteryCapacity =
|
||||||
trueHemeTestViewModel.getBatteryCapacity(requireContext()).toString()
|
hemoCubeViewModel.getBatteryCapacity(requireContext()).toString()
|
||||||
this.batteryMaxCapacity =
|
this.batteryMaxCapacity =
|
||||||
trueHemeTestViewModel.getBatteryMaxCapacity(requireContext()).toString()
|
hemoCubeViewModel.getBatteryMaxCapacity(requireContext()).toString()
|
||||||
this.batteryTemperature = trueHemeTestViewModel.getBatteryTemperature().toString()
|
this.batteryTemperature = hemoCubeViewModel.getBatteryTemperature().toString()
|
||||||
this.batteryVoltage =
|
this.batteryVoltage =
|
||||||
trueHemeTestViewModel.getBatteryVoltage(requireContext()).toString()
|
hemoCubeViewModel.getBatteryVoltage(requireContext()).toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isUsingExistingBuffer) {
|
if (!isUsingExistingBuffer) {
|
||||||
@@ -1390,7 +1406,6 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
trueHemeTestViewModel.updateLocalData()
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
@@ -1432,7 +1447,6 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun findResultWithAdditionalMethods(
|
fun findResultWithAdditionalMethods(
|
||||||
cuvetteSizeSP: String,
|
|
||||||
deviceRatio: Double?,
|
deviceRatio: Double?,
|
||||||
deviceRatioClass: String?,
|
deviceRatioClass: String?,
|
||||||
borderlineMetric: Double?,
|
borderlineMetric: Double?,
|
||||||
@@ -1440,26 +1454,44 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
try {
|
try {
|
||||||
// hemoCubeViewModel.messages.postValue("post classification checks")
|
// hemoCubeViewModel.messages.postValue("post classification checks")
|
||||||
if (deviceRatio != null && borderlineMetric != null) {
|
if (deviceRatio != null && borderlineMetric != null) {
|
||||||
if(cuvetteSizeSP == "10mm"){
|
if(cuvetteSize == "10mm"){
|
||||||
if (deviceRatioClass == "Negative Borderline") {
|
if (deviceRatioClass == "Negative Borderline") {
|
||||||
if (borderlineMetric < negativeBoderLine10mm1){//2.0
|
if (borderlineMetric < negativeBoderLine10mm1){//1.34
|
||||||
return "Sickle Cell Trait"
|
return "Sickle Cell Trait"
|
||||||
}else if(borderlineMetric > negativeBoderLine10mm1){
|
}else if(borderlineMetric > negativeBoderLine10mm2){
|
||||||
return "Normal"
|
return "Normal"
|
||||||
}else if(borderlineMetric == negativeBoderLine10mm1){//borderlineMetric > negativeBoderLine10mm1 && borderlineMetric < negativeBoderLine10mm2
|
}else if(borderlineMetric > negativeBoderLine10mm1 && borderlineMetric < negativeBoderLine10mm2){
|
||||||
return "Sickle Cell Trait"//"Negative borderline. Confirm with HPLC"
|
return "Negative borderline. Confirm with HPLC"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (deviceRatioClass == "Positive for Sickle Cell. HPLC for Confirmation") {
|
if (deviceRatioClass == "Positive for Sickle Cell. HPLC for Confirmation") {
|
||||||
if (borderlineMetric < positiveBoderLine10mm1){//1.3
|
if (borderlineMetric < positiveBoderLine10mm1){//1.34
|
||||||
return "Sickle Cell Disease"
|
return "Sickle Cell Disease"
|
||||||
}else if(borderlineMetric > positiveBoderLine10mm1){
|
}else if(borderlineMetric > positiveBoderLine10mm2){
|
||||||
return "Sickle Cell Trait"
|
return "Sickle Cell Trait"
|
||||||
}else if(borderlineMetric == positiveBoderLine10mm1){//borderlineMetric > positiveBoderLine10mm1 && borderlineMetric < positiveBoderLine10mm2
|
}else if(borderlineMetric > positiveBoderLine10mm1 && borderlineMetric < positiveBoderLine10mm2){
|
||||||
return "Sickle Cell Disease"//"Positive for Sickle Cell. Confirm with HPLC"
|
return "Positive for Sickle Cell. Confirm with HPLC"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if(cuvetteSizeSP == "2mm"){
|
// if (deviceRatioClass == "Negative Borderline") {
|
||||||
|
// if (borderlineMetric < negativeBoderLine10mm1){//1.34
|
||||||
|
// return "Sickle Cell Trait"
|
||||||
|
// }else if(borderlineMetric > negativeBoderLine10mm1){
|
||||||
|
// return "Normal"
|
||||||
|
// }else if(borderlineMetric == negativeBoderLine10mm1){
|
||||||
|
// return "Sickle Cell Trait"
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (deviceRatioClass == "Positive for Sickle Cell. HPLC for Confirmation") {
|
||||||
|
// if (borderlineMetric < positiveBoderLine10mm1){//1.34
|
||||||
|
// return "Sickle Cell Disease"
|
||||||
|
// }else if(borderlineMetric > positiveBoderLine10mm1){
|
||||||
|
// return "Sickle Cell Trait"
|
||||||
|
// }else if(borderlineMetric == positiveBoderLine10mm1){
|
||||||
|
// return "Sickle Cell Disease"
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}else if(cuvetteSize == "2mm"){
|
||||||
if (deviceRatioClass == "Negative Borderline") {
|
if (deviceRatioClass == "Negative Borderline") {
|
||||||
if (borderlineMetric < negativeBoderLine2mm1){//1.34
|
if (borderlineMetric < negativeBoderLine2mm1){//1.34
|
||||||
return "Sickle Cell Trait"
|
return "Sickle Cell Trait"
|
||||||
@@ -1513,11 +1545,12 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
return "Invalid"
|
return "Invalid"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deviceRatioClassification(cuvetteSize : String,ratio: Double?): String {
|
fun deviceRatioClassification(ratio: Double?): String {
|
||||||
try {
|
try {
|
||||||
if (ratio != null) {
|
if (ratio != null) {
|
||||||
if(cuvetteSize == "10mm"){
|
if(cuvetteSize == "10mm"){
|
||||||
if (ratio in normalMin10mm..normalMax10mm) {
|
if (ratio in normalMin10mm..normalMax10mm) {
|
||||||
|
// setSubtitleTextColor(R.color.green_2)
|
||||||
return "Normal"
|
return "Normal"
|
||||||
}
|
}
|
||||||
if (ratio in negativeBorderlineMin10mm..negativeBorderlineMax10mm){
|
if (ratio in negativeBorderlineMin10mm..negativeBorderlineMax10mm){
|
||||||
@@ -1534,6 +1567,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}else if(cuvetteSize == "2mm"){
|
}else if(cuvetteSize == "2mm"){
|
||||||
if (ratio in normalMin2mm..normalMax2mm) {
|
if (ratio in normalMin2mm..normalMax2mm) {
|
||||||
|
// setSubtitleTextColor(R.color.green_2)
|
||||||
return "Normal"
|
return "Normal"
|
||||||
}
|
}
|
||||||
if (ratio in negativeBorderlineMin2mm..negativeBorderlineMax2mm){
|
if (ratio in negativeBorderlineMin2mm..negativeBorderlineMax2mm){
|
||||||
@@ -1574,7 +1608,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
|
|
||||||
fun slopeRatioClassification(ratio: Double?): String {
|
fun slopeRatioClassification(ratio: Double?): String {
|
||||||
try {
|
try {
|
||||||
trueHemeTestViewModel.messages.postValue("result classification")
|
hemoCubeViewModel.messages.postValue("result classification")
|
||||||
if (ratio != null) {
|
if (ratio != null) {
|
||||||
if (ratio in 0.0..30.0)
|
if (ratio in 0.0..30.0)
|
||||||
return getString(R.string.normal)
|
return getString(R.string.normal)
|
||||||
@@ -1599,7 +1633,7 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
|
|
||||||
private fun absorbanceBasedClassification(predictedDenovixRatio: Double?): String {
|
private fun absorbanceBasedClassification(predictedDenovixRatio: Double?): String {
|
||||||
try {
|
try {
|
||||||
trueHemeTestViewModel.messages.postValue("result classification")
|
hemoCubeViewModel.messages.postValue("result classification")
|
||||||
if (predictedDenovixRatio != null) {
|
if (predictedDenovixRatio != null) {
|
||||||
if (predictedDenovixRatio in 0.0..0.16) {
|
if (predictedDenovixRatio in 0.0..0.16) {
|
||||||
// activity?.runOnUiThread {
|
// activity?.runOnUiThread {
|
||||||
@@ -1642,118 +1676,118 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
binding.btnRetryCheckCuvette.visibility = View.GONE
|
binding.btnRetryCheckCuvette.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
trueHemeTestViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.CHECK_CUVETTE_COMMAND,
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.CHECK_CUVETTE_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
trueHemeTestViewModel.progressBar.postValue(false)
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
private fun startBufferProcess() {
|
private fun startBufferProcess() {
|
||||||
trueHemeTestViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
// activity?.runOnUiThread {
|
// activity?.runOnUiThread {
|
||||||
// binding.btnPlacebuffer.visibility = View.GONE
|
// binding.btnPlacebuffer.visibility = View.GONE
|
||||||
// }
|
// }
|
||||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.START_BUFFER_COMMAND,
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.START_BUFFER_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
trueHemeTestViewModel.progressBar.postValue(false)
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun startSampleProcess() {
|
private fun startSampleProcess() {
|
||||||
trueHemeTestViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.START_SAMPLE,
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.START_SAMPLE,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
trueHemeTestViewModel.progressBar.postValue(false)
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sendFirstGainCommand() {
|
private fun sendFirstGainCommand() {
|
||||||
trueHemeTestViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.FIRST_GAIN_COMMAND,
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.FIRST_GAIN_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
trueHemeTestViewModel.progressBar.postValue(false)
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sendSecondGainCommand() {
|
private fun sendSecondGainCommand() {
|
||||||
trueHemeTestViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.SECOND_GAIN_COMMAND,
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.SECOND_GAIN_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
trueHemeTestViewModel.progressBar.postValue(false)
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sendThirdGainCommand() {
|
private fun sendThirdGainCommand() {
|
||||||
trueHemeTestViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.THIRD_GAIN_COMMAND,
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.THIRD_GAIN_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
trueHemeTestViewModel.progressBar.postValue(false)
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sendForthGainCommand() {
|
private fun sendForthGainCommand() {
|
||||||
trueHemeTestViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.FORTH_GAIN_COMMAND,
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.FORTH_GAIN_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
trueHemeTestViewModel.progressBar.postValue(false)
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
private fun getTemp() {
|
private fun getTemp() {
|
||||||
trueHemeTestViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.CHECK_TEMP_COMMAND,
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.CHECK_TEMP_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
trueHemeTestViewModel.progressBar.postValue(false)
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
private fun fetchResult() {
|
private fun fetchResult() {
|
||||||
trueHemeTestViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.PRINT_COMMAND,
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.PRINT_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
trueHemeTestViewModel.progressBar.postValue(false)
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.trueheme_test
|
package com.example.hpostesting.presentation.hemocube
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
@@ -27,6 +27,7 @@ import androidx.work.PeriodicWorkRequestBuilder
|
|||||||
import androidx.work.WorkManager
|
import androidx.work.WorkManager
|
||||||
import com.example.hpostesting.util.CsvWriter
|
import com.example.hpostesting.util.CsvWriter
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
import com.example.hpostesting.util.NetworkStatusLiveData
|
||||||
import com.example.hpostesting.util.Result
|
import com.example.hpostesting.util.Result
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
||||||
@@ -49,7 +50,6 @@ import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
|||||||
import com.example.hpostesting.data.repository.Repository
|
import com.example.hpostesting.data.repository.Repository
|
||||||
import com.example.hpostesting.domain.CheckUpdateWorker
|
import com.example.hpostesting.domain.CheckUpdateWorker
|
||||||
import com.example.hpostesting.domain.LogFileManager
|
import com.example.hpostesting.domain.LogFileManager
|
||||||
import com.example.hpostesting.util.NetworkMonitor
|
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -66,13 +66,12 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class TrueHemeTestViewModel @Inject constructor(
|
class HemoCubeViewModel @Inject constructor(
|
||||||
val hemoCubeDao: HemoCubeDao,
|
val hemoCubeDao: HemoCubeDao,
|
||||||
private val hemoCubeBufferDao: HemoCubeBufferDao,
|
private val hemoCubeBufferDao: HemoCubeBufferDao,
|
||||||
private val repository: Repository,
|
private val repository: Repository,
|
||||||
private val logFileManager: LogFileManager,
|
private val logFileManager: LogFileManager,
|
||||||
private val localFileDataSource: LocalFileDataSource,
|
private val localFileDataSource: LocalFileDataSource,
|
||||||
networkMonitor: NetworkMonitor,
|
|
||||||
context: Context,
|
context: Context,
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
private var testUpload: Boolean = false
|
private var testUpload: Boolean = false
|
||||||
@@ -88,9 +87,6 @@ class TrueHemeTestViewModel @Inject constructor(
|
|||||||
// init {
|
// init {
|
||||||
// startPeriodicCheckUpdate()
|
// startPeriodicCheckUpdate()
|
||||||
// }
|
// }
|
||||||
init {
|
|
||||||
networkMonitor.startMonitoring()
|
|
||||||
}
|
|
||||||
|
|
||||||
val loginResponse = MutableLiveData<Result<LoginResponse>>()
|
val loginResponse = MutableLiveData<Result<LoginResponse>>()
|
||||||
|
|
||||||
@@ -107,7 +103,7 @@ class TrueHemeTestViewModel @Inject constructor(
|
|||||||
|
|
||||||
// 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)
|
||||||
|
|
||||||
private val _networkStatusLiveData =networkMonitor.isConnected
|
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||||
val allUserData = hemoCubeDao.getAll()
|
val allUserData = hemoCubeDao.getAll()
|
||||||
val allLocalData = hemoCubeDao.getAll()
|
val allLocalData = hemoCubeDao.getAll()
|
||||||
val allPendingUserToUpload = hemoCubeDao.getPendingUser()
|
val allPendingUserToUpload = hemoCubeDao.getPendingUser()
|
||||||
@@ -500,6 +496,7 @@ class TrueHemeTestViewModel @Inject constructor(
|
|||||||
testDetails?.centerName = sharedPreference.getString(Constants.CENTER_NAME, "").toString()
|
testDetails?.centerName = sharedPreference.getString(Constants.CENTER_NAME, "").toString()
|
||||||
testDetails?.district = sharedPreference.getString(Constants.DISTRICT, "").toString()
|
testDetails?.district = sharedPreference.getString(Constants.DISTRICT, "").toString()
|
||||||
testDetails?.ipAddress = sharedPreference.getString(Constants.IP_ADDRESS, "").toString()
|
testDetails?.ipAddress = sharedPreference.getString(Constants.IP_ADDRESS, "").toString()
|
||||||
|
testDetails?.configUpdatedRecent = sharedPreference.getString(Constants.LAST_UPDATED, "NA").toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addResultTestToDb(quickCapture: Boolean) {
|
private fun addResultTestToDb(quickCapture: Boolean) {
|
||||||
@@ -795,11 +792,4 @@ class TrueHemeTestViewModel @Inject constructor(
|
|||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
).format(Calendar.getInstance().time)
|
).format(Calendar.getInstance().time)
|
||||||
}
|
}
|
||||||
fun updateLocalData() {
|
|
||||||
viewModelScope.launch {
|
|
||||||
parseData()
|
|
||||||
hemoCubeDao.updateTest(testDetails!!)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.trueheme_test
|
package com.example.hpostesting.presentation.hemocube
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
@@ -25,6 +25,7 @@ import android.content.SharedPreferences
|
|||||||
import android.hardware.usb.UsbDevice
|
import android.hardware.usb.UsbDevice
|
||||||
import android.hardware.usb.UsbDeviceConnection
|
import android.hardware.usb.UsbDeviceConnection
|
||||||
import android.hardware.usb.UsbManager
|
import android.hardware.usb.UsbManager
|
||||||
|
import android.icu.text.SimpleDateFormat
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
@@ -36,20 +37,27 @@ import androidx.annotation.RequiresApi
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
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.constant.Constants
|
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
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.util.UsbService
|
import com.example.hpostesting.util.UsbService
|
||||||
|
import com.google.firebase.ktx.Firebase
|
||||||
|
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
|
||||||
|
import com.google.firebase.remoteconfig.ktx.remoteConfig
|
||||||
|
import com.google.firebase.remoteconfig.ktx.remoteConfigSettings
|
||||||
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 java.util.Calendar
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
open class TrueHemeTestActivity : AppCompatActivity() {
|
open class HemocubeActivity : AppCompatActivity() {
|
||||||
|
private val remoteConfig: FirebaseRemoteConfig = Firebase.remoteConfig
|
||||||
private lateinit var binding: ActivityHemocubeBinding
|
private lateinit var binding: ActivityHemocubeBinding
|
||||||
private val viewModel by viewModels<TrueHemeTestViewModel>()
|
private val viewModel by viewModels<HemoCubeViewModel>()
|
||||||
private var myMenu: Menu? = null
|
private var myMenu: Menu? = null
|
||||||
lateinit var sharedPreferences: SharedPreferences
|
lateinit var sharedPreferences: SharedPreferences
|
||||||
private lateinit var mDriver: UsbSerialDriver
|
private lateinit var mDriver: UsbSerialDriver
|
||||||
@@ -109,6 +117,95 @@ open class TrueHemeTestActivity : AppCompatActivity() {
|
|||||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
setupListener()
|
setupListener()
|
||||||
connectUsb(false)
|
connectUsb(false)
|
||||||
|
val configSettings = remoteConfigSettings {
|
||||||
|
minimumFetchIntervalInSeconds = 10//3600
|
||||||
|
}
|
||||||
|
sharedPreferences = this.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
|
remoteConfig.setConfigSettingsAsync(configSettings)
|
||||||
|
remoteConfig.setDefaultsAsync(R.xml.remote_config_defaults)
|
||||||
|
|
||||||
|
remoteConfig.fetchAndActivate()
|
||||||
|
.addOnCompleteListener(this) { task ->
|
||||||
|
if (task.isSuccessful) {
|
||||||
|
val normalMin2mm = remoteConfig.getDouble("normalMin2mm")
|
||||||
|
val normalMax2mm = remoteConfig.getDouble("normalMax2mm")
|
||||||
|
val negativeBorderlineMin2mm = remoteConfig.getDouble("negativeBorderlineMin2mm")
|
||||||
|
val negativeBorderlineMax2mm = remoteConfig.getDouble("negativeBorderlineMax2mm")
|
||||||
|
val positiveForSickleCellMin2mm = remoteConfig.getDouble("positiveForSickleCellMin2mm")
|
||||||
|
val positiveForSickleCellMax2mm = remoteConfig.getDouble("positiveForSickleCellMax2mm")
|
||||||
|
val sickleCellTraitMin2mm = remoteConfig.getDouble("sickleCellTraitMin2mm")
|
||||||
|
val sickleCellTraitMax2mm = remoteConfig.getDouble("sickleCellTraitMax2mm")
|
||||||
|
val sickleCellDiseaseMin2mm = remoteConfig.getDouble("sickleCellDiseaseMin2mm")
|
||||||
|
val sickleCellDiseaseMax2mm = remoteConfig.getDouble("sickleCellDiseaseMax2mm")
|
||||||
|
val positiveBoderLine2mm1 = remoteConfig.getDouble("positiveBoderLine2mm1")
|
||||||
|
val positiveBoderLine2mm2 = remoteConfig.getDouble("positiveBoderLine2mm2")
|
||||||
|
val negativeBoderLine2mm1 = remoteConfig.getDouble("negativeBoderLine2mm1")
|
||||||
|
val negativeBoderLine2mm2 = remoteConfig.getDouble("negativeBoderLine2mm2")
|
||||||
|
|
||||||
|
val normalMin10mm = remoteConfig.getDouble("normalMin10mm")
|
||||||
|
val normalMax10mm = remoteConfig.getDouble("normalMax10mm")
|
||||||
|
val negativeBorderlineMin10mm = remoteConfig.getDouble("negativeBorderlineMin10mm")
|
||||||
|
val negativeBorderlineMax10mm = remoteConfig.getDouble("negativeBorderlineMax10mm")
|
||||||
|
val positiveForSickleCellMin10mm = remoteConfig.getDouble("positiveForSickleCellMin10mm")
|
||||||
|
val positiveForSickleCellMax10mm = remoteConfig.getDouble("positiveForSickleCellMax10mm")
|
||||||
|
val sickleCellTraitMin10mm = remoteConfig.getDouble("sickleCellTraitMin10mm")
|
||||||
|
val sickleCellTraitMax10mm = remoteConfig.getDouble("sickleCellTraitMax10mm")
|
||||||
|
val sickleCellDiseaseMin10mm = remoteConfig.getDouble("sickleCellDiseaseMin10mm")
|
||||||
|
val sickleCellDiseaseMax10mm = remoteConfig.getDouble("sickleCellDiseaseMax10mm")
|
||||||
|
val positiveBoderLine10mm1 = remoteConfig.getDouble("positiveBoderLine10mm1")
|
||||||
|
val positiveBoderLine10mm2 = remoteConfig.getDouble("positiveBoderLine10mm2")
|
||||||
|
val negativeBoderLine10mm1 = remoteConfig.getDouble("negativeBoderLine10mm1")
|
||||||
|
val negativeBoderLine10mm2 = remoteConfig.getDouble("negativeBoderLine10mm2")
|
||||||
|
|
||||||
|
val bufferMinLed1 = remoteConfig.getDouble("bufferMinLed1")
|
||||||
|
val bufferMaxLed1 = remoteConfig.getDouble("bufferMaxLed1")
|
||||||
|
val bufferMinLed2 = remoteConfig.getDouble("bufferMinLed2")
|
||||||
|
val bufferMaxLed2 = remoteConfig.getDouble("bufferMaxLed2")
|
||||||
|
val time = SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
).format(Calendar.getInstance().time).toString()
|
||||||
|
with(sharedPreferences.edit()) {
|
||||||
|
putString(Constants.LAST_UPDATED, time)
|
||||||
|
putString("bufferMinLed1", bufferMinLed1.toString())
|
||||||
|
putString("bufferMaxLed1", bufferMaxLed1.toString())
|
||||||
|
putString("bufferMinLed2", bufferMinLed2.toString())
|
||||||
|
putString("bufferMaxLed2", bufferMaxLed2.toString())//buffer
|
||||||
|
putString("normalMin2mm", normalMin2mm.toString())//2mm
|
||||||
|
putString("normalMax2mm", normalMax2mm.toString())
|
||||||
|
putString("negativeBorderlineMin2mm", negativeBorderlineMin2mm.toString())
|
||||||
|
putString("negativeBorderlineMax2mm", negativeBorderlineMax2mm.toString())
|
||||||
|
putString("positiveForSickleCellMin2mm", positiveForSickleCellMin2mm.toString())
|
||||||
|
putString("positiveForSickleCellMax2mm", positiveForSickleCellMax2mm.toString())
|
||||||
|
putString("sickleCellTraitMin2mm", sickleCellTraitMin2mm.toString())
|
||||||
|
putString("sickleCellTraitMax2mm", sickleCellTraitMax2mm.toString())
|
||||||
|
putString("sickleCellDiseaseMin2mm", sickleCellDiseaseMin2mm.toString())
|
||||||
|
putString("sickleCellDiseaseMax2mm", sickleCellDiseaseMax2mm.toString())
|
||||||
|
putString("positiveBoderLine2mm1", positiveBoderLine2mm1.toString())
|
||||||
|
putString("positiveBoderLine2mm2", positiveBoderLine2mm2.toString())
|
||||||
|
putString("negativeBoderLine2mm1", negativeBoderLine2mm1.toString())
|
||||||
|
putString("negativeBoderLine2mm2", negativeBoderLine2mm2.toString())//2mm
|
||||||
|
putString("normalMin10mm", normalMin10mm.toString())//10mm
|
||||||
|
putString("normalMax10mm", normalMax10mm.toString())
|
||||||
|
putString("negativeBorderlineMin10mm", negativeBorderlineMin10mm.toString())
|
||||||
|
putString("negativeBorderlineMax10mm", negativeBorderlineMax10mm.toString())
|
||||||
|
putString("positiveForSickleCellMin10mm", positiveForSickleCellMin10mm.toString())
|
||||||
|
putString("positiveForSickleCellMax10mm", positiveForSickleCellMax10mm.toString())
|
||||||
|
putString("sickleCellTraitMin10mm", sickleCellTraitMin10mm.toString())
|
||||||
|
putString("sickleCellTraitMax10mm", sickleCellTraitMax10mm.toString())
|
||||||
|
putString("sickleCellDiseaseMin10mm", sickleCellDiseaseMin10mm.toString())
|
||||||
|
putString("sickleCellDiseaseMax10mm", sickleCellDiseaseMax10mm.toString())
|
||||||
|
putString("positiveBoderLine10mm1", positiveBoderLine10mm1.toString())
|
||||||
|
putString("positiveBoderLine10mm2", positiveBoderLine10mm2.toString())
|
||||||
|
putString("negativeBoderLine10mm1", negativeBoderLine10mm1.toString())
|
||||||
|
putString("negativeBoderLine10mm2", negativeBoderLine10mm2.toString())//10mm
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
Toast.makeText(this@HemocubeActivity, "Config params updated", Toast.LENGTH_SHORT).show()
|
||||||
|
Log.d(TAG, "Config params updated")
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "Config params Fetch failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupListener() {
|
private fun setupListener() {
|
||||||
@@ -192,7 +289,7 @@ open class TrueHemeTestActivity : AppCompatActivity() {
|
|||||||
private fun moveToNext() {
|
private fun moveToNext() {
|
||||||
if (supportFragmentManager.isDestroyed) return
|
if (supportFragmentManager.isDestroyed) return
|
||||||
|
|
||||||
supportFragmentManager.beginTransaction().replace(binding.fghemocube.id, TrueHemeTestFragment())
|
supportFragmentManager.beginTransaction().replace(binding.fghemocube.id, HemoCubeFragment())
|
||||||
.commit()
|
.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +304,7 @@ open class TrueHemeTestActivity : AppCompatActivity() {
|
|||||||
// }
|
// }
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
val fragment = supportFragmentManager.findFragmentById(R.id.fghemocube)
|
val fragment = supportFragmentManager.findFragmentById(R.id.fghemocube)
|
||||||
if (fragment is TrueHemeTestFragment) {
|
if (fragment is HemoCubeFragment) {
|
||||||
if (fragment.handleBackButtonPress()) {
|
if (fragment.handleBackButtonPress()) {
|
||||||
// If the fragment handled the back press, return to avoid calling super.onBackPressed
|
// If the fragment handled the back press, return to avoid calling super.onBackPressed
|
||||||
return
|
return
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.example.hpostesting.presentation.main_base
|
|
||||||
|
|
||||||
import com.example.hpostesting.data.constant.Constants.FIREBASE_INTEGRATION
|
|
||||||
import com.example.hpostesting.data.constant.Constants.MOLBIO_INTEGRATION
|
|
||||||
|
|
||||||
class AppVersionTapManager {
|
|
||||||
|
|
||||||
private var tapCount = 0
|
|
||||||
private val maxTapCount = 5
|
|
||||||
val shouldEnable = FIREBASE_INTEGRATION && !MOLBIO_INTEGRATION
|
|
||||||
val notEnable = MOLBIO_INTEGRATION && !FIREBASE_INTEGRATION
|
|
||||||
|
|
||||||
fun registerTap(onMaxTapsReached: () -> Unit) {
|
|
||||||
tapCount++
|
|
||||||
if (tapCount >= maxTapCount && shouldEnable) {
|
|
||||||
onMaxTapsReached()
|
|
||||||
reset()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private fun reset() {
|
|
||||||
tapCount = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,342 +0,0 @@
|
|||||||
/*
|
|
||||||
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
|
||||||
* // Notice: All information contained herein is, and remains
|
|
||||||
* // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
|
||||||
* // if any. The intellectual and technical concepts contained
|
|
||||||
* // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
|
||||||
* // and its suppliers and may be covered by Indian and Foreign Patents,
|
|
||||||
* // patents in process, and are protected by trade secret or copyright law.
|
|
||||||
* // Dissemination of this information or reproduction of this material
|
|
||||||
* // is strictly forbidden unless prior written permission is obtained
|
|
||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.example.hpostesting.presentation.main_base
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.SharedPreferences
|
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.AdapterView
|
|
||||||
import android.widget.ArrayAdapter
|
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import androidx.preference.ListPreference
|
|
||||||
import androidx.preference.Preference
|
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
|
||||||
import androidx.preference.PreferenceManager
|
|
||||||
import androidx.preference.SwitchPreferenceCompat
|
|
||||||
import com.example.hpostesting.data.constant.Constants
|
|
||||||
import com.example.hpostesting.data.constant.Constants.FIREBASE_INTEGRATION
|
|
||||||
import com.example.hpostesting.data.constant.Constants.MOLBIO_INTEGRATION
|
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
|
||||||
import com.example.hpostesting.data.repository.DatabaseRepository
|
|
||||||
import com.example.hpostesting.firebase.FirebaseConfig
|
|
||||||
import com.example.hpostesting.firebase.FirebaseManager
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|
||||||
import `in`.sminnovations.hpostesting.R
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentSlideshowBinding
|
|
||||||
|
|
||||||
|
|
||||||
private var isLanguageChanged = false
|
|
||||||
|
|
||||||
class SlideshowFragment : Fragment() {
|
|
||||||
private var selectedItem = "10mm"
|
|
||||||
private val values = arrayOf("10mm", "2mm")
|
|
||||||
private lateinit var binding: FragmentSlideshowBinding
|
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
|
||||||
|
|
||||||
override fun onCreateView(
|
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
|
||||||
): View {
|
|
||||||
binding = FragmentSlideshowBinding.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)
|
|
||||||
|
|
||||||
binding.nameEditText.setText(sharedPreferences.getString(Constants.LABNAME, ""))
|
|
||||||
selectedItem = sharedPreferences.getString(Constants.CUVETTE_SIZE, "10mm").toString()
|
|
||||||
binding.btnGo.setOnClickListener {
|
|
||||||
var labname = binding.nameEditText.text.toString()
|
|
||||||
DataHolder.hemoCubeTestData?.apply {
|
|
||||||
this.labName = labname
|
|
||||||
}
|
|
||||||
with(sharedPreferences.edit()) {
|
|
||||||
putString(Constants.LABNAME, labname)
|
|
||||||
apply()
|
|
||||||
}
|
|
||||||
|
|
||||||
Toast.makeText(
|
|
||||||
requireContext(), "Lab Name is Added successfully.", Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
val adapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, values)
|
|
||||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
|
||||||
val pos: Int
|
|
||||||
if (selectedItem == "10mm") {
|
|
||||||
pos = 0
|
|
||||||
} else {
|
|
||||||
pos = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.spinnerCuvette.adapter = adapter
|
|
||||||
binding.spinnerCuvette.onItemSelectedListener =
|
|
||||||
object : AdapterView.OnItemSelectedListener {
|
|
||||||
override fun onItemSelected(
|
|
||||||
parent: AdapterView<*>?, view: View?, position: Int, id: Long
|
|
||||||
) {
|
|
||||||
// Handle item selection here
|
|
||||||
selectedItem = values[position]
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
|
||||||
// Do nothing here
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.spinnerCuvette.setSelection(pos)
|
|
||||||
binding.btnAddSize.setOnClickListener {
|
|
||||||
with(sharedPreferences.edit()) {
|
|
||||||
putString(Constants.CUVETTE_SIZE, selectedItem)
|
|
||||||
apply()
|
|
||||||
}
|
|
||||||
Toast.makeText(
|
|
||||||
requireContext(), "Selected cuvette size: $selectedItem", Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
childFragmentManager.beginTransaction().replace(binding.container.id, PrefsFragment())
|
|
||||||
.commit()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class PrefsFragment : PreferenceFragmentCompat() {
|
|
||||||
private lateinit var tapManager: AppVersionTapManager
|
|
||||||
private lateinit var serverPreference: Preference
|
|
||||||
private lateinit var currentServerPreference: Preference
|
|
||||||
lateinit var firebaseManager: FirebaseManager
|
|
||||||
private var topDevMode = false
|
|
||||||
lateinit var databaseRepository: DatabaseRepository
|
|
||||||
|
|
||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
|
||||||
firebaseManager = FirebaseManager(requireContext())
|
|
||||||
databaseRepository = (activity as DashboardActivity).databaseRepository
|
|
||||||
tapManager = AppVersionTapManager()
|
|
||||||
topDevMode = firebaseManager.getDevMode()
|
|
||||||
val sharedPreference =
|
|
||||||
requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
|
||||||
val preferenceScreen = preferenceManager.createPreferenceScreen(requireContext())
|
|
||||||
val currentServer = firebaseManager.getLastSelectedServer().serverName
|
|
||||||
|
|
||||||
|
|
||||||
// Language Preference
|
|
||||||
val languagePreference = ListPreference(requireContext()).apply {
|
|
||||||
key = "language_preference"
|
|
||||||
title = getString(R.string.app_language)
|
|
||||||
summary = getString(R.string.select_language)
|
|
||||||
entries = arrayOf("English", "Kannada", "Hindi")
|
|
||||||
entryValues = arrayOf("en", "kn", "hi")
|
|
||||||
setDefaultValue("en")
|
|
||||||
icon = ContextCompat.getDrawable(requireContext(), R.drawable.baseline_translate_24)
|
|
||||||
onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
|
||||||
val languageCode = newValue as String
|
|
||||||
updateLanguage(requireContext(), languageCode)
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
val servers = firebaseManager.getAvailableServers()
|
|
||||||
val serverNames = servers.map { it.serverName }.toTypedArray()
|
|
||||||
|
|
||||||
val serverSelectorPreference = CustomDialogPreference(requireContext()).apply {
|
|
||||||
key = "server_preference"
|
|
||||||
title = "Select the Server"
|
|
||||||
summary = "Current server: $currentServer"
|
|
||||||
setEntries(serverNames)
|
|
||||||
setEntryValues(serverNames)
|
|
||||||
setValue(currentServer)
|
|
||||||
icon = ContextCompat.getDrawable(requireContext(), R.drawable.baseline_cloud_sync_24)
|
|
||||||
setOnPreferenceChangeListener { newValue ->
|
|
||||||
val preferenceConfig = servers.find { it.serverName == newValue }
|
|
||||||
switchFirebaseServer(preferenceConfig!!)
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add preferences to screen
|
|
||||||
preferenceScreen.addPreference(languagePreference)
|
|
||||||
preferenceScreen.addPreference(languagePreference)
|
|
||||||
|
|
||||||
|
|
||||||
val developerToggle = SwitchPreferenceCompat(requireContext()).apply {
|
|
||||||
title = "Developer Options"
|
|
||||||
summary = "Enable or disable developer options"
|
|
||||||
icon =
|
|
||||||
ContextCompat.getDrawable(requireContext(), R.drawable.baseline_developer_mode_24)
|
|
||||||
key = "developer_options" // Unique key for SharedPreferences
|
|
||||||
|
|
||||||
// Load toggle state from SharedPreferences
|
|
||||||
isChecked = firebaseManager.getDevMode()
|
|
||||||
|
|
||||||
setOnPreferenceChangeListener { _, newValue ->
|
|
||||||
val isEnabled = newValue as Boolean
|
|
||||||
firebaseManager.setDevModeOn(isEnabled)
|
|
||||||
|
|
||||||
if (!isEnabled) {
|
|
||||||
preferenceScreen.removePreference(this)
|
|
||||||
preferenceScreen.removePreference(serverSelectorPreference)
|
|
||||||
}
|
|
||||||
if (!firebaseManager.getDevMode() && currentServer != "prod"){
|
|
||||||
val prodConfig = servers.find { it.serverName == "prod" }
|
|
||||||
switchFirebaseServer(prodConfig!!)
|
|
||||||
}
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val shouldEnableCurrentServerVersion = FIREBASE_INTEGRATION && !MOLBIO_INTEGRATION
|
|
||||||
val appVersionPreference = Preference(requireContext()).apply {
|
|
||||||
title = "App Version"
|
|
||||||
summary =
|
|
||||||
getAppVersion(requireContext()) + " [ " + getAppEnvironment(requireContext()) + "->" + if (shouldEnableCurrentServerVersion) currentServer else "molbio"+ "]"
|
|
||||||
icon = ContextCompat.getDrawable(requireContext(), R.drawable.baseline_info_24)
|
|
||||||
|
|
||||||
setOnPreferenceClickListener {
|
|
||||||
tapManager.registerTap {
|
|
||||||
firebaseManager.setDevModeOn(true)
|
|
||||||
|
|
||||||
val devConfig = servers.find { it.serverName == "dev" }
|
|
||||||
if (firebaseManager.getDevMode() && currentServer != "dev") {
|
|
||||||
Toast.makeText(requireContext(), "Now you are a Developer", Toast.LENGTH_SHORT).show()
|
|
||||||
Toast.makeText(requireContext(), "Setting Up developer Environmnet", Toast.LENGTH_SHORT).show()
|
|
||||||
switchFirebaseServer(devConfig!!)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (preferenceScreen.findPreference<SwitchPreferenceCompat>("developer_options") == null) {
|
|
||||||
preferenceScreen.addPreference(developerToggle)
|
|
||||||
}
|
|
||||||
if (preferenceScreen.findPreference<ListPreference>("server_preference") == null) {
|
|
||||||
preferenceScreen.addPreference(serverSelectorPreference)
|
|
||||||
}
|
|
||||||
|
|
||||||
developerToggle.isChecked = true
|
|
||||||
updateServerPreference(currentServer)
|
|
||||||
}
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
preferenceScreen.addPreference(appVersionPreference)
|
|
||||||
if (firebaseManager.getDevMode()) {
|
|
||||||
developerToggle.isChecked = true // Ensure it's checked
|
|
||||||
preferenceScreen.addPreference(developerToggle)
|
|
||||||
preferenceScreen.addPreference(serverSelectorPreference)
|
|
||||||
}
|
|
||||||
|
|
||||||
setPreferenceScreen(preferenceScreen)
|
|
||||||
|
|
||||||
if (isLanguageChanged) {
|
|
||||||
Toast.makeText(requireContext(), R.string.language_update, Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private fun updateServerPreference(newServer: String) {
|
|
||||||
(findPreference<CustomDialogPreference>("server_preference"))?.let { pref ->
|
|
||||||
pref.setValue(newServer)
|
|
||||||
pref.summary = "Current server: $newServer"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun switchFirebaseServer(firebaseConfig: FirebaseConfig) {
|
|
||||||
firebaseManager.switchServer(firebaseConfig)
|
|
||||||
Toast.makeText(
|
|
||||||
requireContext(),
|
|
||||||
"Switched to ${firebaseConfig.serverName}, Please wait for few seconds",
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
Toast.makeText(requireContext(), "Restart needed restarting the app", Toast.LENGTH_SHORT)
|
|
||||||
.show()
|
|
||||||
firebaseManager.restartApp()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateLanguage(context: Context, languageCode: String) {
|
|
||||||
LanguageManager.persistLanguagePreference(context, languageCode)
|
|
||||||
LanguageManager.setLocale(context, languageCode)
|
|
||||||
requireActivity().recreate()
|
|
||||||
isLanguageChanged = true
|
|
||||||
}
|
|
||||||
|
|
||||||
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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// CustomDialogPreference.kt
|
|
||||||
class CustomDialogPreference(context: Context) : Preference(context) {
|
|
||||||
private var entries: Array<String> = arrayOf()
|
|
||||||
private var entryValues: Array<String> = arrayOf()
|
|
||||||
private var currentValue: String = ""
|
|
||||||
private var onValueChangeListener: ((String) -> Boolean)? = null
|
|
||||||
|
|
||||||
fun setEntries(entries: Array<String>) {
|
|
||||||
this.entries = entries
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setEntryValues(values: Array<String>) {
|
|
||||||
this.entryValues = values
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setValue(value: String) {
|
|
||||||
currentValue = value
|
|
||||||
persistString(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setOnPreferenceChangeListener(listener: (String) -> Boolean) {
|
|
||||||
onValueChangeListener = listener
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onClick() {
|
|
||||||
val builder = MaterialAlertDialogBuilder(context)
|
|
||||||
builder.setTitle(title)
|
|
||||||
|
|
||||||
builder.setSingleChoiceItems(entries, entries.indexOf(currentValue)) { dialog, which ->
|
|
||||||
val newValue = entryValues[which]
|
|
||||||
if (onValueChangeListener?.invoke(newValue) == true) {
|
|
||||||
setValue(newValue)
|
|
||||||
dialog.dismiss()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.setNegativeButton("Cancel") { dialog, _ ->
|
|
||||||
dialog.dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
package com.example.hpostesting.presentation.testRight
|
package com.example.hpostesting.presentation.testRight
|
||||||
|
|
||||||
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import androidx.lifecycle.MutableLiveData
|
|||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
import com.example.hpostesting.util.NetworkStatusLiveData
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.dao.UserDao
|
import com.example.hpostesting.data.dao.UserDao
|
||||||
import com.example.hpostesting.data.model.CalculationVariableForTest
|
import com.example.hpostesting.data.model.CalculationVariableForTest
|
||||||
@@ -35,7 +36,6 @@ import com.example.hpostesting.domain.SaveRawDataTest
|
|||||||
import com.example.hpostesting.domain.SickleFindResultCaluculationWithMaxImpl
|
import com.example.hpostesting.domain.SickleFindResultCaluculationWithMaxImpl
|
||||||
import com.example.hpostesting.domain.TestRightResultCalculation
|
import com.example.hpostesting.domain.TestRightResultCalculation
|
||||||
import com.example.hpostesting.util.MyUtils
|
import com.example.hpostesting.util.MyUtils
|
||||||
import com.example.hpostesting.util.NetworkMonitor
|
|
||||||
import com.google.firebase.storage.FirebaseStorage
|
import com.google.firebase.storage.FirebaseStorage
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -55,10 +55,10 @@ class TestRightViewModel @Inject constructor(
|
|||||||
private val saveRawDataTest: SaveRawDataTest,
|
private val saveRawDataTest: SaveRawDataTest,
|
||||||
private val repository: DatabaseRepository,
|
private val repository: DatabaseRepository,
|
||||||
private val userDao: UserDao,
|
private val userDao: UserDao,
|
||||||
networkMonitor: NetworkMonitor,
|
|
||||||
context: Context?
|
context: Context?
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
|
|
||||||
|
|
||||||
var isServiceConnected = false
|
var isServiceConnected = false
|
||||||
val progressBar = MutableLiveData(false)
|
val progressBar = MutableLiveData(false)
|
||||||
|
|
||||||
@@ -69,8 +69,9 @@ class TestRightViewModel @Inject constructor(
|
|||||||
|
|
||||||
var testDetails = DataHolder.selectedTest
|
var testDetails = DataHolder.selectedTest
|
||||||
|
|
||||||
private var _networkStatusLiveData = networkMonitor.isConnected
|
private val _networkStatusLiveData = context?.let { NetworkStatusLiveData(it) }
|
||||||
val networkStatusLiveData = _networkStatusLiveData
|
val networkStatusLiveData: NetworkStatusLiveData?
|
||||||
|
get() = _networkStatusLiveData
|
||||||
|
|
||||||
val allUserData = userDao.getAll()
|
val allUserData = userDao.getAll()
|
||||||
|
|
||||||
@@ -81,11 +82,6 @@ class TestRightViewModel @Inject constructor(
|
|||||||
|
|
||||||
val calculationVariableList = ArrayList<CalculationVariableForTest>()
|
val calculationVariableList = ArrayList<CalculationVariableForTest>()
|
||||||
|
|
||||||
init {
|
|
||||||
networkMonitor.startMonitoring()
|
|
||||||
_networkStatusLiveData = networkMonitor.isConnected
|
|
||||||
}
|
|
||||||
|
|
||||||
fun mapDeviceConstants(string: String) {
|
fun mapDeviceConstants(string: String) {
|
||||||
if (string.isNotEmpty()) {
|
if (string.isNotEmpty()) {
|
||||||
val listOfStrings = string.split(",")
|
val listOfStrings = string.split(",")
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ import androidx.core.view.get
|
|||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
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.trueheme_test.TrueHemeTestFragment
|
import com.example.hpostesting.presentation.hemocube.HemoCubeFragment
|
||||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
import com.example.hpostesting.util.UsbService
|
import com.example.hpostesting.util.UsbService
|
||||||
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
|
||||||
@@ -48,7 +48,7 @@ import `in`.sminnovations.hpostesting.databinding.ActivityHemocubeBinding
|
|||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class TrueHemeActivity : AppCompatActivity() {
|
class TrueHemeActivity : AppCompatActivity() {
|
||||||
private lateinit var binding: ActivityHemocubeBinding
|
private lateinit var binding: ActivityHemocubeBinding
|
||||||
private val viewModel by viewModels<TrueHemeTestViewModel>()
|
private val viewModel by viewModels<HemoCubeViewModel>()
|
||||||
private var myMenu: Menu? = null
|
private var myMenu: Menu? = null
|
||||||
|
|
||||||
private lateinit var mDriver: UsbSerialDriver
|
private lateinit var mDriver: UsbSerialDriver
|
||||||
@@ -177,14 +177,14 @@ class TrueHemeActivity : AppCompatActivity() {
|
|||||||
private fun moveToNext() {
|
private fun moveToNext() {
|
||||||
if (supportFragmentManager.isDestroyed) return
|
if (supportFragmentManager.isDestroyed) return
|
||||||
|
|
||||||
supportFragmentManager.beginTransaction().replace(binding.fghemocube.id, TrueHemeTestFragment())
|
supportFragmentManager.beginTransaction().replace(binding.fghemocube.id, HemoCubeFragment())
|
||||||
.commit()
|
.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
val fragment = supportFragmentManager.findFragmentById(R.id.fghemocube)
|
val fragment = supportFragmentManager.findFragmentById(R.id.fghemocube)
|
||||||
if (fragment is TrueHemeTestFragment) {
|
if (fragment is HemoCubeFragment) {
|
||||||
fragment.handleBackButtonPress()
|
fragment.handleBackButtonPress()
|
||||||
} else {
|
} else {
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ import com.example.hpostesting.data.model.TestState
|
|||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestActivity
|
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
||||||
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.crashlytics.ktx.crashlytics
|
||||||
@@ -336,7 +336,7 @@ class TrueHemeFragment : Fragment() {
|
|||||||
startListening.postValue(true)
|
startListening.postValue(true)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
(activity as TrueHemeTestActivity).mService.listenToHemoCube(object : UsbServiceListener {
|
(activity as HemocubeActivity).mService.listenToHemoCube(object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
data?.let {
|
data?.let {
|
||||||
val stringData = String(it)
|
val stringData = String(it)
|
||||||
@@ -357,7 +357,7 @@ class TrueHemeFragment : Fragment() {
|
|||||||
|
|
||||||
private fun getDeviceInfo() {
|
private fun getDeviceInfo() {
|
||||||
hemoCubeViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||||
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
@@ -1067,7 +1067,7 @@ class TrueHemeFragment : Fragment() {
|
|||||||
binding.btnPlacebuffer.visibility = View.GONE
|
binding.btnPlacebuffer.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||||
HemoCubeCommands.START_BUFFER_COMMAND,
|
HemoCubeCommands.START_BUFFER_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
@@ -1081,7 +1081,7 @@ class TrueHemeFragment : Fragment() {
|
|||||||
private fun startSampleProcess() {
|
private fun startSampleProcess() {
|
||||||
hemoCubeViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||||
HemoCubeCommands.START_SAMPLE,
|
HemoCubeCommands.START_SAMPLE,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
@@ -1095,7 +1095,7 @@ class TrueHemeFragment : Fragment() {
|
|||||||
private fun sendFirstGainCommand() {
|
private fun sendFirstGainCommand() {
|
||||||
hemoCubeViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||||
HemoCubeCommands.FIRST_GAIN_COMMAND,
|
HemoCubeCommands.FIRST_GAIN_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
@@ -1109,7 +1109,7 @@ class TrueHemeFragment : Fragment() {
|
|||||||
private fun sendSecondGainCommand() {
|
private fun sendSecondGainCommand() {
|
||||||
hemoCubeViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||||
HemoCubeCommands.SECOND_GAIN_COMMAND,
|
HemoCubeCommands.SECOND_GAIN_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
@@ -1123,7 +1123,7 @@ class TrueHemeFragment : Fragment() {
|
|||||||
private fun sendThirdGainCommand() {
|
private fun sendThirdGainCommand() {
|
||||||
hemoCubeViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||||
HemoCubeCommands.THIRD_GAIN_COMMAND,
|
HemoCubeCommands.THIRD_GAIN_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
@@ -1137,7 +1137,7 @@ class TrueHemeFragment : Fragment() {
|
|||||||
private fun sendForthGainCommand() {
|
private fun sendForthGainCommand() {
|
||||||
hemoCubeViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||||
HemoCubeCommands.FORTH_GAIN_COMMAND,
|
HemoCubeCommands.FORTH_GAIN_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
@@ -1151,7 +1151,7 @@ class TrueHemeFragment : Fragment() {
|
|||||||
private fun fetchResult() {
|
private fun fetchResult() {
|
||||||
hemoCubeViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
(activity as TrueHemeTestActivity).mService.sendAndListenToHemoCube(
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(
|
||||||
HemoCubeCommands.PRINT_COMMAND,
|
HemoCubeCommands.PRINT_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {}
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
@@ -1170,7 +1170,7 @@ class TrueHemeFragment : Fragment() {
|
|||||||
|
|
||||||
private fun reconnect() {
|
private fun reconnect() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
(activity as TrueHemeTestActivity).reconnectDevice()
|
(activity as HemocubeActivity).reconnectDevice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,8 +25,11 @@ import androidx.lifecycle.viewModelScope
|
|||||||
import androidx.work.ExistingPeriodicWorkPolicy
|
import androidx.work.ExistingPeriodicWorkPolicy
|
||||||
import androidx.work.PeriodicWorkRequestBuilder
|
import androidx.work.PeriodicWorkRequestBuilder
|
||||||
import androidx.work.WorkManager
|
import androidx.work.WorkManager
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.util.CsvWriter
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
import com.example.hpostesting.util.NetworkStatusLiveData
|
||||||
|
import com.example.hpostesting.util.Result
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
||||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||||
import com.example.hpostesting.data.datasource.LocalFileDataSource
|
import com.example.hpostesting.data.datasource.LocalFileDataSource
|
||||||
@@ -43,12 +46,10 @@ import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
|||||||
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
||||||
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
||||||
import com.example.hpostesting.data.model.updates.CheckUpdateResponse
|
import com.example.hpostesting.data.model.updates.CheckUpdateResponse
|
||||||
|
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
||||||
import com.example.hpostesting.data.repository.Repository
|
import com.example.hpostesting.data.repository.Repository
|
||||||
import com.example.hpostesting.domain.CheckUpdateWorker
|
import com.example.hpostesting.domain.CheckUpdateWorker
|
||||||
import com.example.hpostesting.domain.LogFileManager
|
import com.example.hpostesting.domain.LogFileManager
|
||||||
import com.example.hpostesting.util.CsvWriter
|
|
||||||
import com.example.hpostesting.util.NetworkMonitor
|
|
||||||
import com.example.hpostesting.util.Result
|
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||||
@@ -69,22 +70,20 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
private val repository: Repository,
|
private val repository: Repository,
|
||||||
private val logFileManager: LogFileManager,
|
private val logFileManager: LogFileManager,
|
||||||
private val localFileDataSource: LocalFileDataSource,
|
private val localFileDataSource: LocalFileDataSource,
|
||||||
networkMonitor: NetworkMonitor,
|
|
||||||
context: Context,
|
context: Context,
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
var isServiceConnected = false
|
var isServiceConnected = false
|
||||||
val progressBar = MutableLiveData(false)
|
val progressBar = MutableLiveData(false)
|
||||||
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||||
val messages = MutableLiveData<String>()
|
val messages = MutableLiveData<String>()
|
||||||
private val sharedPreference = context.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
private val sharedPreference =
|
||||||
|
context.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
|
|
||||||
private val workManager = WorkManager.getInstance(context)
|
private val workManager = WorkManager.getInstance(context)
|
||||||
|
|
||||||
// init {
|
// init {
|
||||||
// startPeriodicCheckUpdate()
|
// startPeriodicCheckUpdate()
|
||||||
// }
|
// }
|
||||||
init {
|
|
||||||
networkMonitor.startMonitoring()
|
|
||||||
}
|
|
||||||
|
|
||||||
val loginResponse = MutableLiveData<Result<LoginResponse>>()
|
val loginResponse = MutableLiveData<Result<LoginResponse>>()
|
||||||
|
|
||||||
@@ -98,7 +97,7 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
|
|
||||||
// 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)
|
||||||
|
|
||||||
private val _networkStatusLiveData = networkMonitor.isConnected
|
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||||
val allUserData = hemoCubeDao.getAll()
|
val allUserData = hemoCubeDao.getAll()
|
||||||
val allKitTestData = hemoCubeBufferDao.getAll()
|
val allKitTestData = hemoCubeBufferDao.getAll()
|
||||||
val deviceData = MutableLiveData<DeviceData?>()
|
val deviceData = MutableLiveData<DeviceData?>()
|
||||||
@@ -182,7 +181,7 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
val logFile = logFileManager.createLogFile().let { file ->
|
val logFile = logFileManager.createLogFile().let { file ->
|
||||||
val requestBody = file?.asRequestBody("multipart/form-data".toMediaTypeOrNull())
|
val requestBody = file?.asRequestBody("multipart/form-data".toMediaTypeOrNull())
|
||||||
val multipartFile =
|
val multipartFile =
|
||||||
requestBody?.let { MultipartBody.Part.createFormData("logFile", file.name, it) }
|
requestBody?.let { MultipartBody.Part.createFormData("logFile", file?.name, it) }
|
||||||
multipartFile?.let { partFile ->
|
multipartFile?.let { partFile ->
|
||||||
repository.uploadLogs(partFile).let { result ->
|
repository.uploadLogs(partFile).let { result ->
|
||||||
uploadLogs.postValue(result)
|
uploadLogs.postValue(result)
|
||||||
@@ -194,10 +193,12 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
fun uploadHemoCubeResultToDatabaseForBufferCheck(
|
fun uploadHemoCubeResultToDatabaseForBufferCheck(
|
||||||
isOnline: Boolean,
|
isOnline: Boolean,
|
||||||
bufferCheckData: BufferCheckData,
|
bufferCheckData: BufferCheckData,
|
||||||
) = viewModelScope.launch {
|
) =
|
||||||
|
viewModelScope.launch {
|
||||||
if (isOnline) {
|
if (isOnline) {
|
||||||
try {
|
try {
|
||||||
when (val response = repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
when (val response =
|
||||||
|
repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
@@ -395,7 +396,8 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
when (val response = repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
when (val response =
|
||||||
|
repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
@@ -413,7 +415,8 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateBufferLocalFlag(bufferId: String) = viewModelScope.launch {
|
private fun updateBufferLocalFlag(bufferId: String) =
|
||||||
|
viewModelScope.launch {
|
||||||
hemoCubeBufferDao.updateFieldById(id = bufferId, true)
|
hemoCubeBufferDao.updateFieldById(id = bufferId, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -452,11 +455,15 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
|
|
||||||
fun getBatteryLevel(): Float? {
|
fun getBatteryLevel(): Float? {
|
||||||
val batteryPct: Float? = batteryStatus?.let { intent ->
|
val batteryPct: Float? = batteryStatus?.let { intent ->
|
||||||
val level: Int = intent.getIntExtra(
|
val level: Int =
|
||||||
BatteryManager.EXTRA_LEVEL, -1
|
intent.getIntExtra(
|
||||||
|
BatteryManager.EXTRA_LEVEL,
|
||||||
|
-1
|
||||||
)
|
)
|
||||||
val scale: Int = intent.getIntExtra(
|
val scale: Int =
|
||||||
BatteryManager.EXTRA_SCALE, -1
|
intent.getIntExtra(
|
||||||
|
BatteryManager.EXTRA_SCALE,
|
||||||
|
-1
|
||||||
)
|
)
|
||||||
level * 100 / scale.toFloat()
|
level * 100 / scale.toFloat()
|
||||||
}
|
}
|
||||||
@@ -467,7 +474,8 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
fun getBatteryTemperature(): Float? {
|
fun getBatteryTemperature(): Float? {
|
||||||
val batteryTemp: Float? = batteryStatus?.let { intent ->
|
val batteryTemp: Float? = batteryStatus?.let { intent ->
|
||||||
val temperature = intent.getIntExtra(
|
val temperature = intent.getIntExtra(
|
||||||
BatteryManager.EXTRA_TEMPERATURE, 0
|
BatteryManager.EXTRA_TEMPERATURE,
|
||||||
|
0
|
||||||
)
|
)
|
||||||
temperature.toFloat() / 10
|
temperature.toFloat() / 10
|
||||||
}
|
}
|
||||||
@@ -476,11 +484,14 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getBatteryVoltage(context: Context): Float {
|
fun getBatteryVoltage(context: Context): Float {
|
||||||
val batteryIntent = context.registerReceiver(
|
val batteryIntent =
|
||||||
null, IntentFilter(Intent.ACTION_BATTERY_CHANGED)
|
context.registerReceiver(
|
||||||
|
null,
|
||||||
|
IntentFilter(Intent.ACTION_BATTERY_CHANGED)
|
||||||
)
|
)
|
||||||
val voltage = batteryIntent?.getIntExtra(
|
val voltage = batteryIntent?.getIntExtra(
|
||||||
BatteryManager.EXTRA_VOLTAGE, 0
|
BatteryManager.EXTRA_VOLTAGE,
|
||||||
|
0
|
||||||
) ?: 0
|
) ?: 0
|
||||||
|
|
||||||
// milli-volts to volts
|
// milli-volts to volts
|
||||||
@@ -489,7 +500,8 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
|
|
||||||
|
|
||||||
fun getBatteryCapacity(context: Context): Int {
|
fun getBatteryCapacity(context: Context): Int {
|
||||||
val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
val batteryManager =
|
||||||
|
context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
||||||
val currentCapacity =
|
val currentCapacity =
|
||||||
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
|
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
|
||||||
|
|
||||||
@@ -498,7 +510,8 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
|
|
||||||
fun getBatteryMaxCapacity(context: Context): Float {
|
fun getBatteryMaxCapacity(context: Context): Float {
|
||||||
val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
||||||
val designCapacity = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
|
val designCapacity =
|
||||||
|
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
|
||||||
val currentCapacity =
|
val currentCapacity =
|
||||||
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
|
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
|
||||||
|
|
||||||
@@ -515,7 +528,8 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
hemoCubeTestData.forEach { data ->
|
hemoCubeTestData.forEach { data ->
|
||||||
data.localFlag = true
|
data.localFlag = true
|
||||||
hemoCubeDao.updateCSVFieldById(
|
hemoCubeDao.updateCSVFieldById(
|
||||||
data._id, true
|
data._id,
|
||||||
|
true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import android.os.Build
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import io.nats.client.AuthHandler
|
import io.nats.client.AuthHandler
|
||||||
import io.nats.client.Connection
|
import io.nats.client.Connection
|
||||||
import io.nats.client.Message
|
import io.nats.client.Message
|
||||||
|
|||||||
@@ -1,117 +0,0 @@
|
|||||||
package com.example.hpostesting.util
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.content.Context
|
|
||||||
import android.net.ConnectivityManager
|
|
||||||
import android.net.Network
|
|
||||||
import android.net.NetworkCapabilities
|
|
||||||
import android.net.NetworkRequest
|
|
||||||
import androidx.lifecycle.LiveData
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.SupervisorJob
|
|
||||||
import kotlinx.coroutines.cancel
|
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import kotlinx.coroutines.isActive
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import java.net.HttpURLConnection
|
|
||||||
import java.net.URL
|
|
||||||
import javax.inject.Inject
|
|
||||||
import javax.inject.Singleton
|
|
||||||
|
|
||||||
|
|
||||||
@Singleton
|
|
||||||
class NetworkMonitor @Inject constructor(
|
|
||||||
@ApplicationContext private val context: Context
|
|
||||||
) {
|
|
||||||
private var isMonitoringStarted = false
|
|
||||||
private val connectivityManager =
|
|
||||||
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
|
||||||
|
|
||||||
private val _isConnected = MutableLiveData(false)
|
|
||||||
val isConnected: LiveData<Boolean> get() = _isConnected
|
|
||||||
|
|
||||||
private val networkScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
|
||||||
|
|
||||||
private val networkCallback = object : ConnectivityManager.NetworkCallback() {
|
|
||||||
override fun onAvailable(network: Network) {
|
|
||||||
performPingCheck()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onLost(network: Network) {
|
|
||||||
_isConnected.postValue(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCapabilitiesChanged(
|
|
||||||
network: Network, networkCapabilities: NetworkCapabilities
|
|
||||||
) {
|
|
||||||
// Recheck connectivity when capabilities change (e.g., network becomes validated)
|
|
||||||
performPingCheck()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
|
||||||
fun startMonitoring() {
|
|
||||||
if (isMonitoringStarted) return // Already started, do nothing.
|
|
||||||
isMonitoringStarted = true
|
|
||||||
// Check initial connectivity status
|
|
||||||
val network = connectivityManager.activeNetwork
|
|
||||||
val capabilities = connectivityManager.getNetworkCapabilities(network)
|
|
||||||
val isInitiallyConnected = capabilities?.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) == true
|
|
||||||
|
|
||||||
if (isInitiallyConnected) {
|
|
||||||
performPingCheck()
|
|
||||||
} else {
|
|
||||||
_isConnected.postValue(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
val networkRequest =
|
|
||||||
NetworkRequest.Builder().addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
connectivityManager.registerNetworkCallback(networkRequest, networkCallback)
|
|
||||||
// Start periodic checks:
|
|
||||||
startPeriodicPingCheck()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun stopMonitoring() { // never needed to call
|
|
||||||
try {
|
|
||||||
connectivityManager.unregisterNetworkCallback(networkCallback)
|
|
||||||
} catch (_: IllegalArgumentException) {
|
|
||||||
// Ignore if callback was not registered
|
|
||||||
}
|
|
||||||
networkScope.cancel()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun performPingCheck() {
|
|
||||||
networkScope.launch {
|
|
||||||
try {
|
|
||||||
val url = URL("https://www.google.com")
|
|
||||||
val connection = url.openConnection() as HttpURLConnection
|
|
||||||
connection.connectTimeout = 2000
|
|
||||||
connection.readTimeout = 2000
|
|
||||||
connection.setRequestProperty("Connection", "close")
|
|
||||||
connection.connect()
|
|
||||||
|
|
||||||
// Consider any 2xx response as successful
|
|
||||||
val isReachable = connection.responseCode in 200..299
|
|
||||||
_isConnected.postValue(isReachable)
|
|
||||||
connection.disconnect()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
_isConnected.postValue(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun startPeriodicPingCheck(intervalMillis: Long = 1 * 60_000L) {
|
|
||||||
networkScope.launch {
|
|
||||||
while (isActive) {
|
|
||||||
performPingCheck()
|
|
||||||
delay(intervalMillis)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
||||||
|
* // Notice: All information contained herein is, and remains
|
||||||
|
* // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
||||||
|
* // if any. The intellectual and technical concepts contained
|
||||||
|
* // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
||||||
|
* // and its suppliers and may be covered by Indian and Foreign Patents,
|
||||||
|
* // patents in process, and are protected by trade secret or copyright law.
|
||||||
|
* // Dissemination of this information or reproduction of this material
|
||||||
|
* // is strictly forbidden unless prior written permission is obtained
|
||||||
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.example.hpostesting.util
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.net.ConnectivityManager
|
||||||
|
import android.net.Network
|
||||||
|
import android.net.NetworkCapabilities
|
||||||
|
import android.net.NetworkRequest
|
||||||
|
import android.os.Build
|
||||||
|
import androidx.annotation.RequiresApi
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
|
||||||
|
class NetworkStatusLiveData(context: Context) : LiveData<Boolean>() {
|
||||||
|
|
||||||
|
private val connectivityManager: ConnectivityManager =
|
||||||
|
context.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||||
|
|
||||||
|
private val networkCallback = object : ConnectivityManager.NetworkCallback() {
|
||||||
|
override fun onAvailable(network: Network) {
|
||||||
|
postValue(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onLost(network: Network) {
|
||||||
|
postValue(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.M)
|
||||||
|
override fun onActive() {
|
||||||
|
super.onActive()
|
||||||
|
postValue(isNetworkAvailable())
|
||||||
|
registerNetworkCallback()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onInactive() {
|
||||||
|
super.onInactive()
|
||||||
|
unregisterNetworkCallback()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun registerNetworkCallback() {
|
||||||
|
val networkRequest = NetworkRequest.Builder()
|
||||||
|
.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
|
||||||
|
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
|
||||||
|
.addTransportType(NetworkCapabilities.TRANSPORT_ETHERNET)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
connectivityManager.registerNetworkCallback(networkRequest, networkCallback)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun unregisterNetworkCallback() {
|
||||||
|
connectivityManager.unregisterNetworkCallback(networkCallback)
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.M)
|
||||||
|
private fun isNetworkAvailable(): Boolean {
|
||||||
|
val network = connectivityManager.activeNetwork
|
||||||
|
val networkCapabilities = connectivityManager.getNetworkCapabilities(network)
|
||||||
|
return networkCapabilities != null &&
|
||||||
|
networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) &&
|
||||||
|
networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
|
||||||
|
|
||||||
<path android:fillColor="@android:color/white" android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96z"/>
|
|
||||||
|
|
||||||
</vector>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
|
||||||
|
|
||||||
<path android:fillColor="@android:color/white" android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96zM10,17l-3.5,-3.5 1.41,-1.41L10,14.17 15.18,9l1.41,1.41L10,17z"/>
|
|
||||||
|
|
||||||
</vector>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
|
||||||
|
|
||||||
<path android:fillColor="@android:color/white" android:pathData="M21.5,14.98c-0.02,0 -0.03,0 -0.05,0.01C21.2,13.3 19.76,12 18,12c-1.4,0 -2.6,0.83 -3.16,2.02C13.26,14.1 12,15.4 12,17c0,1.66 1.34,3 3,3l6.5,-0.02c1.38,0 2.5,-1.12 2.5,-2.5S22.88,14.98 21.5,14.98zM10,4.26v2.09C7.67,7.18 6,9.39 6,12c0,1.77 0.78,3.34 2,4.44V14h2v6H4v-2h2.73C5.06,16.54 4,14.4 4,12C4,8.27 6.55,5.15 10,4.26zM20,6h-2.73c1.43,1.26 2.41,3.01 2.66,5l-2.02,0C17.68,9.64 16.98,8.45 16,7.56V10h-2V4h6V6z"/>
|
|
||||||
|
|
||||||
</vector>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
|
||||||
|
|
||||||
<path android:fillColor="@android:color/white" android:pathData="M7,5h10v2h2L19,3c0,-1.1 -0.9,-1.99 -2,-1.99L7,1c-1.1,0 -2,0.9 -2,2v4h2L7,5zM15.41,16.59L20,12l-4.59,-4.59L14,8.83 17.17,12 14,15.17l1.41,1.42zM10,15.17L6.83,12 10,8.83 8.59,7.41 4,12l4.59,4.59L10,15.17zM17,19L7,19v-2L5,17v4c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2v-4h-2v2z"/>
|
|
||||||
|
|
||||||
</vector>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
|
||||||
|
|
||||||
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z"/>
|
|
||||||
|
|
||||||
</vector>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
|
||||||
|
|
||||||
<path android:fillColor="@android:color/white" android:pathData="M12.87,15.07l-2.54,-2.51 0.03,-0.03c1.74,-1.94 2.98,-4.17 3.71,-6.53L17,6L17,4h-7L10,2L8,2v2L1,4v1.99h11.17C11.5,7.92 10.44,9.75 9,11.35 8.07,10.32 7.3,9.19 6.69,8h-2c0.73,1.63 1.73,3.17 2.98,4.56l-5.09,5.02L4,19l5,-5 3.11,3.11 0.76,-2.04zM18.5,10h-2L12,22h2l1.12,-3h4.75L21,22h2l-4.5,-12zM15.88,17l1.62,-4.33L19.12,17h-3.24z"/>
|
|
||||||
|
|
||||||
</vector>
|
|
||||||
@@ -45,7 +45,6 @@
|
|||||||
android:layout_marginHorizontal="24dp"
|
android:layout_marginHorizontal="24dp"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:text="@string/scan_qr_code_of_the_kit"
|
android:text="@string/scan_qr_code_of_the_kit"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/app_bar_layout" />
|
app:layout_constraintTop_toBottomOf="@id/app_bar_layout" />
|
||||||
|
|
||||||
@@ -59,7 +58,6 @@
|
|||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
app:backgroundTint="@color/blue_app_light"
|
app:backgroundTint="@color/blue_app_light"
|
||||||
app:cornerRadius="100dp"
|
app:cornerRadius="100dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tv_title" />
|
app:layout_constraintTop_toBottomOf="@+id/tv_title" />
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
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"
|
||||||
tools:context="com.example.hpostesting.presentation.trueheme_test.DigitalCardFragment">
|
tools:context="com.example.hpostesting.presentation.hemocube.DigitalCardFragment">
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:id="@+id/userCard"
|
android:id="@+id/userCard"
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
tools:context="com.example.hpostesting.presentation.main_base.PanelFragment">
|
tools:context="com.example.hpostesting.presentation.dashboard.GalleryFragment">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_subtitle4"
|
android:id="@+id/tv_subtitle4"
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout 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"
|
||||||
tools:context="com.example.hpostesting.presentation.trueheme_test.TrueHemeTestFragment">
|
tools:context="com.example.hpostesting.presentation.hemocube.HemoCubeFragment">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/cl_parent"
|
android:id="@+id/cl_parent"
|
||||||
|
|||||||
@@ -76,7 +76,6 @@
|
|||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
app:backgroundTint="@color/blue_app_light"
|
app:backgroundTint="@color/blue_app_light"
|
||||||
app:cornerRadius="100dp"
|
app:cornerRadius="100dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tv_title" />
|
app:layout_constraintTop_toBottomOf="@+id/tv_title" />
|
||||||
|
|
||||||
@@ -104,9 +103,9 @@
|
|||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="Refresh"
|
android:text="Refresh"
|
||||||
android:textColor="@color/white"
|
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
android:textColor="@color/white"
|
||||||
|
app:layout_constraintEnd_toEndOf="@id/btn_scan_now"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_scan_now" />
|
app:layout_constraintTop_toBottomOf="@id/btn_scan_now" />
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
tools:context="com.example.hpostesting.presentation.main_base.ui.LoginFragment">
|
tools:context="com.example.hpostesting.presentation.dashboard.ui.LoginFragment">
|
||||||
|
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
|
|||||||
@@ -53,7 +53,6 @@
|
|||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
app:backgroundTint="@color/blue_app_light"
|
app:backgroundTint="@color/blue_app_light"
|
||||||
app:cornerRadius="100dp"
|
app:cornerRadius="100dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tv_title2" />
|
app:layout_constraintTop_toBottomOf="@+id/tv_title2" />
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout 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"
|
||||||
tools:context="com.example.hpostesting.presentation.main_base.SlideshowFragment">
|
tools:context="com.example.hpostesting.presentation.dashboard.SlideshowFragment">
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/cl_parent"
|
android:id="@+id/cl_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -88,12 +88,24 @@
|
|||||||
app:layout_constraintBottom_toBottomOf="@id/spinnerCuvette"
|
app:layout_constraintBottom_toBottomOf="@id/spinnerCuvette"
|
||||||
app:layout_constraintStart_toEndOf="@id/spinnerCuvette"
|
app:layout_constraintStart_toEndOf="@id/spinnerCuvette"
|
||||||
app:layout_constraintTop_toTopOf="@id/spinnerCuvette" />
|
app:layout_constraintTop_toTopOf="@id/spinnerCuvette" />
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/last_updated"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:text="Last"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="17sp"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/btn_add_size"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_marginStart="30dp"/>
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/container"
|
android:id="@+id/container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/btn_add_size"
|
app:layout_constraintTop_toBottomOf="@+id/last_updated"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:layout_marginTop="10dp"/>
|
android:layout_marginTop="10dp"/>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/nav_home"
|
android:id="@+id/nav_home"
|
||||||
android:name="com.example.hpostesting.presentation.main_base.HomeFragment"
|
android:name="com.example.hpostesting.presentation.dashboard.HomeFragment"
|
||||||
android:label="@string/menu_home"
|
android:label="@string/menu_home"
|
||||||
app:popUpToInclusive="true"
|
app:popUpToInclusive="true"
|
||||||
app:popUpTo="@id/nav_home"
|
app:popUpTo="@id/nav_home"
|
||||||
@@ -36,23 +36,23 @@
|
|||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/nav_profile"
|
android:id="@+id/nav_profile"
|
||||||
android:name="com.example.hpostesting.presentation.main_base.PanelFragment"
|
android:name="com.example.hpostesting.presentation.dashboard.GalleryFragment"
|
||||||
android:label="@string/profile"
|
android:label="@string/profile"
|
||||||
tools:layout="@layout/fragment_gallery" />
|
tools:layout="@layout/fragment_gallery" />
|
||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/nav_settings"
|
android:id="@+id/nav_settings"
|
||||||
android:name="com.example.hpostesting.presentation.main_base.SlideshowFragment"
|
android:name="com.example.hpostesting.presentation.dashboard.SlideshowFragment"
|
||||||
android:label="@string/action_settings"
|
android:label="@string/action_settings"
|
||||||
tools:layout="@layout/fragment_slideshow" />
|
tools:layout="@layout/fragment_slideshow" />
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/nav_about"
|
android:id="@+id/nav_about"
|
||||||
android:name="com.example.hpostesting.presentation.main_base.AboutFragment"
|
android:name="com.example.hpostesting.presentation.dashboard.AboutFragment"
|
||||||
android:label="@string/action_about"
|
android:label="@string/action_about"
|
||||||
tools:layout="@layout/fragment_about" />
|
tools:layout="@layout/fragment_about" />
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/nav_activity"
|
android:id="@+id/nav_activity"
|
||||||
android:name="com.example.hpostesting.presentation.main_base.ActivitiesFragment"
|
android:name="com.example.hpostesting.presentation.dashboard.ActivitiesFragment"
|
||||||
android:label="@string/action_activity"
|
android:label="@string/action_activity"
|
||||||
tools:layout="@layout/fragment_activities" />
|
tools:layout="@layout/fragment_activities" />
|
||||||
<activity
|
<activity
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
android:label="MainActivity" />
|
android:label="MainActivity" />
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/loginFragment"
|
android:id="@+id/loginFragment"
|
||||||
android:name="com.example.hpostesting.presentation.main_base.ui.LoginFragment"
|
android:name="com.example.hpostesting.presentation.dashboard.ui.LoginFragment"
|
||||||
android:label="@string/login"
|
android:label="@string/login"
|
||||||
tools:layout="@layout/fragment_login" >
|
tools:layout="@layout/fragment_login" >
|
||||||
<action
|
<action
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/hemoCubeFragment"
|
android:id="@+id/hemoCubeFragment"
|
||||||
android:name="com.example.hpostesting.presentation.trueheme_test.TrueHemeTestFragment"
|
android:name="com.example.hpostesting.presentation.hemocube.HemoCubeFragment"
|
||||||
android:label="fragment_hemo_cube_reference"
|
android:label="fragment_hemo_cube_reference"
|
||||||
tools:layout="@layout/fragment_hemo_cube_reference" >
|
tools:layout="@layout/fragment_hemo_cube_reference" >
|
||||||
<action
|
<action
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
</fragment>
|
</fragment>
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/digitalCardFragment"
|
android:id="@+id/digitalCardFragment"
|
||||||
android:name="com.example.hpostesting.presentation.trueheme_test.DigitalCardFragment"
|
android:name="com.example.hpostesting.presentation.hemocube.DigitalCardFragment"
|
||||||
android:label="fragment_digital_card"
|
android:label="fragment_digital_card"
|
||||||
tools:layout="@layout/fragment_digital_card" />
|
tools:layout="@layout/fragment_digital_card" />
|
||||||
</navigation>
|
</navigation>
|
||||||
@@ -13,68 +13,9 @@
|
|||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<string-array name="district">
|
<string-array name="district">
|
||||||
<item>अररिया</item>
|
<item>Mysuru</item>
|
||||||
<item>अरवल</item>
|
<item>Kodagu</item>
|
||||||
<item>औरंगाबाद</item>
|
<item>Chamarajanagar</item>
|
||||||
<item>बांका</item>
|
|
||||||
<item>बेगूसराय</item>
|
|
||||||
<item>भागलपुर</item>
|
|
||||||
<item>भोजपुर</item>
|
|
||||||
<item>बक्सर</item>
|
|
||||||
<item>दरभंगा</item>
|
|
||||||
<item>पूर्वी चंपारण</item>
|
|
||||||
<item>गया</item>
|
|
||||||
<item>गोपालगंज</item>
|
|
||||||
<item>जमुई</item>
|
|
||||||
<item>जहानाबाद</item>
|
|
||||||
<item>कैमूर</item>
|
|
||||||
<item>कटिहार</item>
|
|
||||||
<item>खगड़िया</item>
|
|
||||||
<item>किशनगंज</item>
|
|
||||||
<item>लखीसराय</item>
|
|
||||||
<item>मधेपुरा</item>
|
|
||||||
<item>मधुबनी</item>
|
|
||||||
<item>मुंगेर</item>
|
|
||||||
<item>मुजफ्फरपुर</item>
|
|
||||||
<item>नालंदा</item>
|
|
||||||
<item>नवादा</item>
|
|
||||||
<item>पटना</item>
|
|
||||||
<item>पूर्णिया</item>
|
|
||||||
<item>रोहतास</item>
|
|
||||||
<item>सहरसा</item>
|
|
||||||
<item>समस्तीपुर</item>
|
|
||||||
<item>सारण</item>
|
|
||||||
<item>शेखपुरा</item>
|
|
||||||
<item>शिवहर</item>
|
|
||||||
<item>सीतामढ़ी</item>
|
|
||||||
<item>सिवान</item>
|
|
||||||
<item>सुपौल</item>
|
|
||||||
<item>वैशाली</item>
|
|
||||||
<item>पश्चिमी चंपारण</item>
|
|
||||||
<item>बोकारो</item>
|
|
||||||
<item>चतरा</item>
|
|
||||||
<item>देवघर</item>
|
|
||||||
<item>धनबाद</item>
|
|
||||||
<item>दुमका</item>
|
|
||||||
<item>पूर्वी सिंहभूम</item>
|
|
||||||
<item>गढवा</item>
|
|
||||||
<item>गिरिडीह</item>
|
|
||||||
<item>गोड्डा</item>
|
|
||||||
<item>गुमला</item>
|
|
||||||
<item>हजारीबाग</item>
|
|
||||||
<item>जामताड़ा</item>
|
|
||||||
<item>खूंटी</item>
|
|
||||||
<item>कोडरमा</item>
|
|
||||||
<item>लातेहार</item>
|
|
||||||
<item>लोहरदगा</item>
|
|
||||||
<item>पाकुड़</item>
|
|
||||||
<item>पलामू</item>
|
|
||||||
<item>रामगढ़</item>
|
|
||||||
<item>रांची</item>
|
|
||||||
<item>साहिबगंज</item>
|
|
||||||
<item>सरायकेला खरसावां</item>
|
|
||||||
<item>सिमडेगा</item>
|
|
||||||
<item>पश्चिमी सिंहभूम</item>
|
|
||||||
<item>Other</item>
|
<item>Other</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -289,6 +289,8 @@
|
|||||||
<string name="check_cuvette">Checking cuvette presence</string>
|
<string name="check_cuvette">Checking cuvette presence</string>
|
||||||
<string name="cuvette_present">Cuvette present</string>
|
<string name="cuvette_present">Cuvette present</string>
|
||||||
<string name="cuvette_absent">Cuvette absent</string>
|
<string name="cuvette_absent">Cuvette absent</string>
|
||||||
|
<string name="cuvette_presentt">Cuvette Present , Please Remove Cuvette And Try Again</string>
|
||||||
|
<string name="cuvette_absentt">Cuvette Absent,Now You Can Submit</string>
|
||||||
<string name="retry">Retry</string>
|
<string name="retry">Retry</string>
|
||||||
<string name="Firefox">Firefox</string>
|
<string name="Firefox">Firefox</string>
|
||||||
<string name="Files">Files</string>
|
<string name="Files">Files</string>
|
||||||
@@ -305,7 +307,4 @@
|
|||||||
<string name="quick_capture">Quick Capture</string>
|
<string name="quick_capture">Quick Capture</string>
|
||||||
<string name="reset_password_for_this_device">Reset password for this device</string>
|
<string name="reset_password_for_this_device">Reset password for this device</string>
|
||||||
<string name="calibrate_device">Calibrate the device</string>
|
<string name="calibrate_device">Calibrate the device</string>
|
||||||
<string name="cuvette_presentt">Cuvette Present , Please Remove Cuvette And Try Again</string>
|
|
||||||
<string name="cuvette_absentt">Cuvette Absent,Now You Can Submit</string>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -13,68 +13,9 @@
|
|||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<string-array name="district">
|
<string-array name="district">
|
||||||
<item>Araria</item>
|
<item>Mysuru</item>
|
||||||
<item>Arwal</item>
|
<item>Kodagu</item>
|
||||||
<item>Aurangabad</item>
|
<item>Chamarajanagar</item>
|
||||||
<item>Banka</item>
|
|
||||||
<item>Begusarai</item>
|
|
||||||
<item>Bhagalpur</item>
|
|
||||||
<item>Bhojpur</item>
|
|
||||||
<item>Buxar</item>
|
|
||||||
<item>Darbhanga</item>
|
|
||||||
<item>East Champaran</item>
|
|
||||||
<item>Gaya</item>
|
|
||||||
<item>Gopalganj</item>
|
|
||||||
<item>Jamui</item>
|
|
||||||
<item>Jehanabad</item>
|
|
||||||
<item>Kaimur</item>
|
|
||||||
<item>Katihar</item>
|
|
||||||
<item>Khagaria</item>
|
|
||||||
<item>Kishanganj</item>
|
|
||||||
<item>Lakhisarai</item>
|
|
||||||
<item>Madhepura</item>
|
|
||||||
<item>Madhubani</item>
|
|
||||||
<item>Munger</item>
|
|
||||||
<item>Muzaffarpur</item>
|
|
||||||
<item>Nalanda</item>
|
|
||||||
<item>Nawada</item>
|
|
||||||
<item>Patna</item>
|
|
||||||
<item>Purnia</item>
|
|
||||||
<item>Rohtas</item>
|
|
||||||
<item>Saharsa</item>
|
|
||||||
<item>Samastipur</item>
|
|
||||||
<item>Saran</item>
|
|
||||||
<item>Sheikhpura</item>
|
|
||||||
<item>Sheohar</item>
|
|
||||||
<item>Sitamarhi</item>
|
|
||||||
<item>Siwan</item>
|
|
||||||
<item>Supaul</item>
|
|
||||||
<item>Vaishali</item>
|
|
||||||
<item>West Champaran</item>
|
|
||||||
<item>Bokaro</item>
|
|
||||||
<item>Chatra</item>
|
|
||||||
<item>Deoghar</item>
|
|
||||||
<item>Dhanbad</item>
|
|
||||||
<item>Dumka</item>
|
|
||||||
<item>East Singhbhum</item>
|
|
||||||
<item>Garhwa</item>
|
|
||||||
<item>Giridih</item>
|
|
||||||
<item>Godda</item>
|
|
||||||
<item>Gumla</item>
|
|
||||||
<item>Hazaribagh</item>
|
|
||||||
<item>Jamtara</item>
|
|
||||||
<item>Khunti</item>
|
|
||||||
<item>Koderma</item>
|
|
||||||
<item>Latehar</item>
|
|
||||||
<item>Lohardaga</item>
|
|
||||||
<item>Pakur</item>
|
|
||||||
<item>Palamu</item>
|
|
||||||
<item>Ramgarh</item>
|
|
||||||
<item>Ranchi</item>
|
|
||||||
<item>Sahibganj</item>
|
|
||||||
<item>Seraikela Kharsawan</item>
|
|
||||||
<item>Simdega</item>
|
|
||||||
<item>West Singhbhum</item>
|
|
||||||
<item>Other</item>
|
<item>Other</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -288,6 +288,8 @@
|
|||||||
<string name="check_cuvette">ಕುವೆಟ್ ಇರುವಿಕೆಯನ್ನು ಪರಿಶೀಲಿಸಲಾಗುತ್ತಿದೆ</string>
|
<string name="check_cuvette">ಕುವೆಟ್ ಇರುವಿಕೆಯನ್ನು ಪರಿಶೀಲಿಸಲಾಗುತ್ತಿದೆ</string>
|
||||||
<string name="cuvette_present">ಕುವೆಟ್ಟೆ ಇರುತ್ತದೆ</string>
|
<string name="cuvette_present">ಕುವೆಟ್ಟೆ ಇರುತ್ತದೆ</string>
|
||||||
<string name="cuvette_absent">ಕುವೆಟ್ಟೆ ಇರುವುದಿಲ್ಲ </string>
|
<string name="cuvette_absent">ಕುವೆಟ್ಟೆ ಇರುವುದಿಲ್ಲ </string>
|
||||||
|
<string name="cuvette_presentt">Cuvette Present , Please Remove Cuvette And Try Again</string>
|
||||||
|
<string name="cuvette_absentt">Cuvette Absent,Now You Can Submit</string>
|
||||||
<string name="retry">ಮರುಪ್ರಯತ್ನಿಸಿ</string>
|
<string name="retry">ಮರುಪ್ರಯತ್ನಿಸಿ</string>
|
||||||
<string name="Firefox">ಫೈರ್ಫಾಕ್ಸ್</string>
|
<string name="Firefox">ಫೈರ್ಫಾಕ್ಸ್</string>
|
||||||
<string name="Files">ಫೈಲ್</string>
|
<string name="Files">ಫೈಲ್</string>
|
||||||
@@ -304,9 +306,6 @@
|
|||||||
<string name="quick_capture">ತ್ವರಿತ ಕ್ಯಾಪ್ಚರ್</string>
|
<string name="quick_capture">ತ್ವರಿತ ಕ್ಯಾಪ್ಚರ್</string>
|
||||||
<string name="reset_password_for_this_device">ಈ ಸಾಧನಕ್ಕಾಗಿ ಪಾಸ್ವರ್ಡ್ ಅನ್ನು ಮರುಹೊಂದಿಸಿ</string>
|
<string name="reset_password_for_this_device">ಈ ಸಾಧನಕ್ಕಾಗಿ ಪಾಸ್ವರ್ಡ್ ಅನ್ನು ಮರುಹೊಂದಿಸಿ</string>
|
||||||
<string name="calibrate_device">ಸಾಧನವನ್ನು ಮಾಪನಾಂಕ ಮಾಡಿ</string>
|
<string name="calibrate_device">ಸಾಧನವನ್ನು ಮಾಪನಾಂಕ ಮಾಡಿ</string>
|
||||||
<string name="cuvette_presentt">Cuvette Present , Please Remove Cuvette And Try Again</string>
|
|
||||||
<string name="cuvette_absentt">Cuvette Absent,Now You Can Submit</string>
|
|
||||||
|
|
||||||
<!-- Add translations for other strings -->
|
<!-- Add translations for other strings -->
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -26,68 +26,9 @@
|
|||||||
<!-- Use language codes (e.g., en, kn) as values -->
|
<!-- Use language codes (e.g., en, kn) as values -->
|
||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="district">
|
<string-array name="district">
|
||||||
<item>Araria</item>
|
<item>Mysuru</item>
|
||||||
<item>Arwal</item>
|
<item>Kodagu</item>
|
||||||
<item>Aurangabad</item>
|
<item>Chamarajanagar</item>
|
||||||
<item>Banka</item>
|
|
||||||
<item>Begusarai</item>
|
|
||||||
<item>Bhagalpur</item>
|
|
||||||
<item>Bhojpur</item>
|
|
||||||
<item>Buxar</item>
|
|
||||||
<item>Darbhanga</item>
|
|
||||||
<item>East Champaran</item>
|
|
||||||
<item>Gaya</item>
|
|
||||||
<item>Gopalganj</item>
|
|
||||||
<item>Jamui</item>
|
|
||||||
<item>Jehanabad</item>
|
|
||||||
<item>Kaimur</item>
|
|
||||||
<item>Katihar</item>
|
|
||||||
<item>Khagaria</item>
|
|
||||||
<item>Kishanganj</item>
|
|
||||||
<item>Lakhisarai</item>
|
|
||||||
<item>Madhepura</item>
|
|
||||||
<item>Madhubani</item>
|
|
||||||
<item>Munger</item>
|
|
||||||
<item>Muzaffarpur</item>
|
|
||||||
<item>Nalanda</item>
|
|
||||||
<item>Nawada</item>
|
|
||||||
<item>Patna</item>
|
|
||||||
<item>Purnia</item>
|
|
||||||
<item>Rohtas</item>
|
|
||||||
<item>Saharsa</item>
|
|
||||||
<item>Samastipur</item>
|
|
||||||
<item>Saran</item>
|
|
||||||
<item>Sheikhpura</item>
|
|
||||||
<item>Sheohar</item>
|
|
||||||
<item>Sitamarhi</item>
|
|
||||||
<item>Siwan</item>
|
|
||||||
<item>Supaul</item>
|
|
||||||
<item>Vaishali</item>
|
|
||||||
<item>West Champaran</item>
|
|
||||||
<item>Bokaro</item>
|
|
||||||
<item>Chatra</item>
|
|
||||||
<item>Deoghar</item>
|
|
||||||
<item>Dhanbad</item>
|
|
||||||
<item>Dumka</item>
|
|
||||||
<item>East Singhbhum</item>
|
|
||||||
<item>Garhwa</item>
|
|
||||||
<item>Giridih</item>
|
|
||||||
<item>Godda</item>
|
|
||||||
<item>Gumla</item>
|
|
||||||
<item>Hazaribagh</item>
|
|
||||||
<item>Jamtara</item>
|
|
||||||
<item>Khunti</item>
|
|
||||||
<item>Koderma</item>
|
|
||||||
<item>Latehar</item>
|
|
||||||
<item>Lohardaga</item>
|
|
||||||
<item>Pakur</item>
|
|
||||||
<item>Palamu</item>
|
|
||||||
<item>Ramgarh</item>
|
|
||||||
<item>Ranchi</item>
|
|
||||||
<item>Sahibganj</item>
|
|
||||||
<item>Seraikela Kharsawan</item>
|
|
||||||
<item>Simdega</item>
|
|
||||||
<item>West Singhbhum</item>
|
|
||||||
<item>Other</item>
|
<item>Other</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
|||||||
@@ -291,6 +291,8 @@
|
|||||||
<string name="check_cuvette">Checking cuvette presence</string>
|
<string name="check_cuvette">Checking cuvette presence</string>
|
||||||
<string name="cuvette_present">Cuvette present , you can start the test</string>
|
<string name="cuvette_present">Cuvette present , you can start the test</string>
|
||||||
<string name="cuvette_absent">Cuvette is absent , please place the cuvette and retry again</string>
|
<string name="cuvette_absent">Cuvette is absent , please place the cuvette and retry again</string>
|
||||||
|
<string name="cuvette_presentt">Cuvette Present , Please Remove Cuvette And Try Again</string>
|
||||||
|
<string name="cuvette_absentt">Cuvette Absent,Now You Can Submit</string>
|
||||||
<string name="retry">Retry again</string>
|
<string name="retry">Retry again</string>
|
||||||
<string name="usb_terminal">Usb Terminal</string>
|
<string name="usb_terminal">Usb Terminal</string>
|
||||||
<string name="menu_about">About</string>
|
<string name="menu_about">About</string>
|
||||||
@@ -305,7 +307,4 @@
|
|||||||
<string name="quick_capture">Quick Capture</string>
|
<string name="quick_capture">Quick Capture</string>
|
||||||
<string name="reset_password_for_this_device">Reset password for this device</string>
|
<string name="reset_password_for_this_device">Reset password for this device</string>
|
||||||
<string name="calibrate_device">Calibrate Device</string>
|
<string name="calibrate_device">Calibrate Device</string>
|
||||||
<string name="cuvette_presentt">Cuvette Present , Please Remove Cuvette And Try Again</string>
|
|
||||||
<string name="cuvette_absentt">Cuvette Absent,Now You Can Submit</string>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
146
app/src/main/res/xml/remote_config_defaults.xml
Normal file
146
app/src/main/res/xml/remote_config_defaults.xml
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
~ // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
||||||
|
~ // Notice: All information contained herein is, and remains
|
||||||
|
~ // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
||||||
|
~ // if any. The intellectual and technical concepts contained
|
||||||
|
~ // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
||||||
|
~ // and its suppliers and may be covered by Indian and Foreign Patents,
|
||||||
|
~ // patents in process, and are protected by trade secret or copyright law.
|
||||||
|
~ // Dissemination of this information or reproduction of this material
|
||||||
|
~ // is strictly forbidden unless prior written permission is obtained
|
||||||
|
~ // from ShanMukha Innovations Pvt. Ltd.
|
||||||
|
-->
|
||||||
|
<defaultsMap>
|
||||||
|
<entry>
|
||||||
|
<key>BUFFER_FLAGS_ENABLED</key>
|
||||||
|
<value>true</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>positiveBoderLine10mm1</key>
|
||||||
|
<value>1.3</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>positiveBoderLine10mm2</key>
|
||||||
|
<value>1.66</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>negativeBoderLine10mm1</key>
|
||||||
|
<value>2.0</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>negativeBoderLine10mm2</key>
|
||||||
|
<value>2.4</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>normalMin10mm</key>
|
||||||
|
<value>0.1</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>normalMax10mm</key>
|
||||||
|
<value>0.23</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>negativeBorderlineMin10mm</key>
|
||||||
|
<value>0.23</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>negativeBorderlineMax10mm</key>
|
||||||
|
<value>0.25</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>sickleCellTraitMin10mm</key>
|
||||||
|
<value>0.25</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>sickleCellTraitMax10mm</key>
|
||||||
|
<value>0.31</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>positiveForSickleCellMin10mm</key>
|
||||||
|
<value>0.31</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>positiveForSickleCellMax10mm</key>
|
||||||
|
<value>0.43</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>sickleCellDiseaseMin10mm</key>
|
||||||
|
<value>0.43</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>sickleCellDiseaseMax10mm</key>
|
||||||
|
<value>0.7</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>positiveBoderLine2mm1</key>
|
||||||
|
<value>0.8</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>positiveBoderLine2mm2</key>
|
||||||
|
<value>1.1</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>negativeBoderLine2mm1</key>
|
||||||
|
<value>1.5</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>negativeBoderLine2mm2</key>
|
||||||
|
<value>1.9</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>normalMin2mm</key>
|
||||||
|
<value>0.1</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>normalMax2mm</key>
|
||||||
|
<value>0.23</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>negativeBorderlineMin2mm</key>
|
||||||
|
<value>0.23</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>negativeBorderlineMax2mm</key>
|
||||||
|
<value>0.25</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>sickleCellTraitMin2mm</key>
|
||||||
|
<value>0.25</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>sickleCellTraitMax2mm</key>
|
||||||
|
<value>0.31</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>positiveForSickleCellMin2mm</key>
|
||||||
|
<value>0.31</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>positiveForSickleCellMax2mm</key>
|
||||||
|
<value>0.45</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>sickleCellDiseaseMin2mm</key>
|
||||||
|
<value>0.45</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>sickleCellDiseaseMax2mm</key>
|
||||||
|
<value>0.7</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>bufferMinLed1</key>
|
||||||
|
<value>21000.00</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>bufferMaxLed1</key>
|
||||||
|
<value>23000.00</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>bufferMinLed2</key>
|
||||||
|
<value>17000.00</value>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
<key>bufferMaxLed2</key>
|
||||||
|
<value>19000.00</value>
|
||||||
|
</entry>
|
||||||
|
</defaultsMap>
|
||||||
@@ -16,12 +16,12 @@ package com.example.hpostesting
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.example.hpostesting.util.NetworkStatusLiveData
|
||||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||||
import com.example.hpostesting.data.model.Response
|
import com.example.hpostesting.data.model.Response
|
||||||
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
||||||
import com.example.hpostesting.data.repository.Repository
|
import com.example.hpostesting.data.repository.Repository
|
||||||
import com.example.hpostesting.presentation.autodac.AutoDacViewModel
|
import com.example.hpostesting.presentation.autodac.AutoDacViewModel
|
||||||
import com.example.hpostesting.util.NetworkMonitor
|
|
||||||
import io.mockk.*
|
import io.mockk.*
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
@@ -43,7 +43,7 @@ class AutoDacViewModelTest {
|
|||||||
private val repository = mockk<Repository>()
|
private val repository = mockk<Repository>()
|
||||||
private val context = mockk<Context>()
|
private val context = mockk<Context>()
|
||||||
private val sharedPreferences = mockk<SharedPreferences>()
|
private val sharedPreferences = mockk<SharedPreferences>()
|
||||||
private val networkStatusLiveData = mockk<NetworkMonitor>()
|
private val networkStatusLiveData = mockk<NetworkStatusLiveData>()
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
@@ -54,7 +54,7 @@ class AutoDacViewModelTest {
|
|||||||
every { context.getSystemService(any()) } returns networkStatusLiveData
|
every { context.getSystemService(any()) } returns networkStatusLiveData
|
||||||
|
|
||||||
// Mocking the NetworkStatusLiveData
|
// Mocking the NetworkStatusLiveData
|
||||||
every { networkStatusLiveData.startMonitoring() } just Runs
|
every { networkStatusLiveData.observe(any(), any()) } just Runs
|
||||||
|
|
||||||
every { hemoCubeDao.getAll() } returns mockk()
|
every { hemoCubeDao.getAll() } returns mockk()
|
||||||
// every { repository.addDiagnostics(any()) } returns Response.Success(Unit)
|
// every { repository.addDiagnostics(any()) } returns Response.Success(Unit)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
package com.example.hpostesting
|
package com.example.hpostesting
|
||||||
|
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestFragment
|
import com.example.hpostesting.presentation.hemocube.HemoCubeFragment
|
||||||
import junit.framework.TestCase.assertEquals
|
import junit.framework.TestCase.assertEquals
|
||||||
import junit.framework.TestCase.assertNull
|
import junit.framework.TestCase.assertNull
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
@@ -24,17 +24,17 @@ import org.mockito.Mock
|
|||||||
import org.mockito.Mockito
|
import org.mockito.Mockito
|
||||||
import org.mockito.MockitoAnnotations
|
import org.mockito.MockitoAnnotations
|
||||||
|
|
||||||
class TrueHemeTestFragmentTest {
|
class HemoCubeFragmentTest {
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private lateinit var mockSharedPreferences: SharedPreferences
|
private lateinit var mockSharedPreferences: SharedPreferences
|
||||||
|
|
||||||
private lateinit var trueHemeTestFragment: TrueHemeTestFragment
|
private lateinit var hemoCubeFragment: HemoCubeFragment
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
MockitoAnnotations.initMocks(this)
|
MockitoAnnotations.initMocks(this)
|
||||||
trueHemeTestFragment = TrueHemeTestFragment()
|
hemoCubeFragment = HemoCubeFragment()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -48,7 +48,7 @@ class TrueHemeTestFragmentTest {
|
|||||||
).thenReturn("dummy_value")
|
).thenReturn("dummy_value")
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val deviceId = trueHemeTestFragment.extractV2HardwareId("SNS HPP1-9000 SNE")
|
val deviceId = hemoCubeFragment.extractV2HardwareId("SNS HPP1-9000 SNE")
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("HPP1-9000", deviceId)
|
assertEquals("HPP1-9000", deviceId)
|
||||||
@@ -81,11 +81,11 @@ class TrueHemeTestFragmentTest {
|
|||||||
val readingsPerSample = 1
|
val readingsPerSample = 1
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = trueHemeTestFragment.allReadingsComplete(repeatReadingCount, readingsPerSample)
|
val result = hemoCubeFragment.allReadingsComplete(repeatReadingCount, readingsPerSample)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals(true, result)
|
assertEquals(true, result)
|
||||||
assertEquals(trueHemeTestFragment.allReadingsComplete(0, 1), false)
|
assertEquals(hemoCubeFragment.allReadingsComplete(0, 1), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -94,7 +94,7 @@ class TrueHemeTestFragmentTest {
|
|||||||
val input = "Some text SN ABC123 some more text"
|
val input = "Some text SN ABC123 some more text"
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = trueHemeTestFragment.extractV1HardwareId(input)
|
val result = hemoCubeFragment.extractV1HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("ABC123", result)
|
assertEquals("ABC123", result)
|
||||||
@@ -106,7 +106,7 @@ class TrueHemeTestFragmentTest {
|
|||||||
val input = "Some text without SN"
|
val input = "Some text without SN"
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = trueHemeTestFragment.extractV1HardwareId(input)
|
val result = hemoCubeFragment.extractV1HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertNull(result)
|
assertNull(result)
|
||||||
@@ -118,7 +118,7 @@ class TrueHemeTestFragmentTest {
|
|||||||
val input = ""
|
val input = ""
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = trueHemeTestFragment.extractV1HardwareId(input)
|
val result = hemoCubeFragment.extractV1HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertNull(result)
|
assertNull(result)
|
||||||
@@ -130,7 +130,7 @@ class TrueHemeTestFragmentTest {
|
|||||||
val input: String? = null
|
val input: String? = null
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = input?.let { trueHemeTestFragment.extractV1HardwareId(it) }
|
val result = input?.let { hemoCubeFragment.extractV1HardwareId(it) }
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertNull(result)
|
assertNull(result)
|
||||||
@@ -158,7 +158,7 @@ class TrueHemeTestFragmentTest {
|
|||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = trueHemeTestFragment.extractV1HardwareId(input)
|
val result = hemoCubeFragment.extractV1HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("HCV-000-3001", result)
|
assertEquals("HCV-000-3001", result)
|
||||||
@@ -170,7 +170,7 @@ class TrueHemeTestFragmentTest {
|
|||||||
val input = "SNS ABC123 SNE"
|
val input = "SNS ABC123 SNE"
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
val result = hemoCubeFragment.extractV2HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("ABC123", result)
|
assertEquals("ABC123", result)
|
||||||
@@ -182,7 +182,7 @@ class TrueHemeTestFragmentTest {
|
|||||||
val input = "No hardware ID in this input"
|
val input = "No hardware ID in this input"
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
val result = hemoCubeFragment.extractV2HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertNull(result)
|
assertNull(result)
|
||||||
@@ -194,7 +194,7 @@ class TrueHemeTestFragmentTest {
|
|||||||
val input = "SNS XYZ789 SNE"
|
val input = "SNS XYZ789 SNE"
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
val result = hemoCubeFragment.extractV2HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("XYZ789", result)
|
assertEquals("XYZ789", result)
|
||||||
@@ -218,7 +218,7 @@ class TrueHemeTestFragmentTest {
|
|||||||
"REND\n"
|
"REND\n"
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
val result = hemoCubeFragment.extractV2HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("HCV-000-3013", result)
|
assertEquals("HCV-000-3013", result)
|
||||||
@@ -241,7 +241,7 @@ class TrueHemeTestFragmentTest {
|
|||||||
"REND\n"
|
"REND\n"
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
val result = hemoCubeFragment.extractV2HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("HPP1-4001", result)
|
assertEquals("HPP1-4001", result)
|
||||||
@@ -264,7 +264,7 @@ class TrueHemeTestFragmentTest {
|
|||||||
"REND\n"
|
"REND\n"
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
val result = hemoCubeFragment.extractV2HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("HPP1-000-4001", result)
|
assertEquals("HPP1-000-4001", result)
|
||||||
@@ -287,7 +287,7 @@ class TrueHemeTestFragmentTest {
|
|||||||
"REND\n"
|
"REND\n"
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
val result = hemoCubeFragment.extractV2HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("HPP-000-4001", result)
|
assertEquals("HPP-000-4001", result)
|
||||||
@@ -310,7 +310,7 @@ class TrueHemeTestFragmentTest {
|
|||||||
"REND\n"
|
"REND\n"
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = trueHemeTestFragment.extractV2HardwareId(input)
|
val result = hemoCubeFragment.extractV2HardwareId(input)
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assertEquals("HPP-000-5001", result)
|
assertEquals("HPP-000-5001", result)
|
||||||
@@ -318,123 +318,111 @@ class TrueHemeTestFragmentTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDeviceRatioClassificationNormalWithStartRange() {
|
fun testDeviceRatioClassificationNormalWithStartRange() {
|
||||||
val ratio = 0.08
|
val ratio = 0.16
|
||||||
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||||
assertEquals("Normal", result)
|
assertEquals("Normal", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDeviceRatioClassificationNormal() {
|
fun testDeviceRatioClassificationNormal() {
|
||||||
val ratio = 0.22
|
val ratio = 0.22
|
||||||
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||||
assertEquals("Normal", result)
|
assertEquals("Normal", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDeviceRatioClassificationNegativeBorderline() {
|
fun testDeviceRatioClassificationNegativeBorderline() {
|
||||||
val ratio = 0.235
|
val ratio = 0.235
|
||||||
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||||
assertEquals("Negative Borderline", result)
|
|
||||||
}
|
|
||||||
@Test
|
|
||||||
fun testDeviceRatioClassificationNegativeBorderlineUpperBound() {
|
|
||||||
val ratio = 0.265
|
|
||||||
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
|
||||||
assertEquals("Negative Borderline", result)
|
assertEquals("Negative Borderline", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDeviceRatioClassificationSickleCellTraitLowerBound() {
|
fun testDeviceRatioClassificationSickleCellTraitLowerBound() {
|
||||||
val ratio = 0.271
|
val ratio = 0.251
|
||||||
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||||
assertEquals("Sickle Cell Trait", result)
|
assertEquals("Negative Borderline", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDeviceRatioClassificationSickleCellTraitUpperBound() {
|
fun testDeviceRatioClassificationSickleCellTraitUpperBound() {
|
||||||
val ratio = 0.309
|
val ratio = 0.309
|
||||||
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||||
assertEquals("Sickle Cell Trait", result)
|
assertEquals("Sickle Cell Trait", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDeviceRatioClassificationPositiveForSickleCell() {
|
fun testDeviceRatioClassificationPositiveForSickleCell() {
|
||||||
val ratio = 0.312
|
|
||||||
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
|
||||||
assertEquals("Positive for Sickle Cell. HPLC for Confirmation", result)
|
|
||||||
}
|
|
||||||
@Test
|
|
||||||
fun testDeviceRatioClassificationPositiveForSickleCellUpperBound() {
|
|
||||||
val ratio = 0.39
|
val ratio = 0.39
|
||||||
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||||
assertEquals("Positive for Sickle Cell. HPLC for Confirmation", result)
|
assertEquals("Positive for Sickle Cell. HPLC for Confirmation", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDeviceRatioClassificationSickleCellDiseaseLowerBound() {
|
fun testDeviceRatioClassificationSickleCellDiseaseLowerBound() {
|
||||||
val ratio = 0.391
|
val ratio = 0.391
|
||||||
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||||
assertEquals("Sickle Cell Disease", result)
|
assertEquals("Sickle Cell Disease", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDeviceRatioClassificationSickleCellDisease() {
|
fun testDeviceRatioClassificationSickleCellDisease() {
|
||||||
val ratio = 0.691
|
val ratio = 0.45
|
||||||
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||||
assertEquals("Sickle Cell Disease", result)
|
assertEquals("Sickle Cell Disease", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testDeviceRatioClassificationInvalid() {
|
fun testDeviceRatioClassificationInvalid() {
|
||||||
val ratio: Double? = null
|
val ratio: Double? = null
|
||||||
val result = trueHemeTestFragment.deviceRatioClassification("10mm",ratio)
|
val result = hemoCubeFragment.deviceRatioClassification(ratio)
|
||||||
assertEquals("Invalid", result)
|
assertEquals("Invalid", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineNormal() {
|
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineNormal() {
|
||||||
val result =
|
val result =
|
||||||
trueHemeTestFragment.findResultWithAdditionalMethods("10mm",0.5, "Negative Borderline", 2.5)
|
hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Negative Borderline", 2.5)
|
||||||
assertEquals("Normal", result)
|
assertEquals("Normal", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellTrait1() {
|
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellTrait1() {
|
||||||
val result =
|
val result =
|
||||||
trueHemeTestFragment.findResultWithAdditionalMethods("10mm",0.5, "Negative Borderline", 2.2)
|
hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Negative Borderline", 2.2)
|
||||||
assertEquals("Normal", result)
|
assertEquals("Negative borderline. Confirm with HPLC", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellTrait2() {
|
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellTrait2() {
|
||||||
val result = trueHemeTestFragment.findResultWithAdditionalMethods(
|
val result = hemoCubeFragment.findResultWithAdditionalMethods(
|
||||||
"10mm",0.5,
|
0.5,
|
||||||
"Positive for Sickle Cell. HPLC for Confirmation",
|
"Positive for Sickle Cell. HPLC for Confirmation",
|
||||||
1.4
|
1.4
|
||||||
)
|
)
|
||||||
assertEquals("Sickle Cell Trait", result)
|
assertEquals("Positive for Sickle Cell. Confirm with HPLC", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellDisease() {
|
fun findResultWithAdditionalMethods_ValidInput_ReturnsBorderlineSickleCellDisease() {
|
||||||
val result = trueHemeTestFragment.findResultWithAdditionalMethods(
|
val result = hemoCubeFragment.findResultWithAdditionalMethods(
|
||||||
"10mm",0.5,
|
0.5,
|
||||||
"Positive for Sickle Cell. HPLC for Confirmation",
|
"Positive for Sickle Cell. HPLC for Confirmation",
|
||||||
1.33
|
1.33
|
||||||
)
|
)
|
||||||
assertEquals("Sickle Cell Trait", result)
|
assertEquals("Positive for Sickle Cell. Confirm with HPLC", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_NormalDeviceRatio_ReturnsNormalBelowSlopeRatioThreshold() {
|
fun findResultWithAdditionalMethods_NormalDeviceRatio_ReturnsNormalBelowSlopeRatioThreshold() {
|
||||||
val result = trueHemeTestFragment.findResultWithAdditionalMethods("10mm",0.5, "Normal", 30.0)
|
val result = hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Normal", 30.0)
|
||||||
assertEquals("Normal", result)
|
assertEquals("Normal", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_NBL_ReturnsNBL() {
|
fun findResultWithAdditionalMethods_NBL_ReturnsNBL() {
|
||||||
val result = trueHemeTestFragment.findResultWithAdditionalMethods(
|
val result = hemoCubeFragment.findResultWithAdditionalMethods(
|
||||||
"10mm",0.5,
|
0.5,
|
||||||
"Negative Borderline, Repeat Test",
|
"Negative Borderline, Repeat Test",
|
||||||
70.0
|
70.0
|
||||||
)
|
)
|
||||||
@@ -444,14 +432,14 @@ class TrueHemeTestFragmentTest {
|
|||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_SCT_ReturnsSCT() {
|
fun findResultWithAdditionalMethods_SCT_ReturnsSCT() {
|
||||||
val result =
|
val result =
|
||||||
trueHemeTestFragment.findResultWithAdditionalMethods("10mm",0.5, "Sickle Cell Trait", 70.0)
|
hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Sickle Cell Trait", 70.0)
|
||||||
assertEquals("Sickle Cell Trait", result)
|
assertEquals("Sickle Cell Trait", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_PBL_ReturnsPBL() {
|
fun findResultWithAdditionalMethods_PBL_ReturnsPBL() {
|
||||||
val result = trueHemeTestFragment.findResultWithAdditionalMethods(
|
val result = hemoCubeFragment.findResultWithAdditionalMethods(
|
||||||
"10mm",0.5,
|
0.5,
|
||||||
"Positive for Sickle Cell. HPLC for Confirmation",
|
"Positive for Sickle Cell. HPLC for Confirmation",
|
||||||
1.67
|
1.67
|
||||||
)
|
)
|
||||||
@@ -461,7 +449,7 @@ class TrueHemeTestFragmentTest {
|
|||||||
@Test
|
@Test
|
||||||
fun findResultWithAdditionalMethods_SCD_ReturnsSCD() {
|
fun findResultWithAdditionalMethods_SCD_ReturnsSCD() {
|
||||||
val result =
|
val result =
|
||||||
trueHemeTestFragment.findResultWithAdditionalMethods("10mm",0.5, "Sickle Cell Disease", 70.0)
|
hemoCubeFragment.findResultWithAdditionalMethods(0.5, "Sickle Cell Disease", 70.0)
|
||||||
assertEquals("Sickle Cell Disease", result)
|
assertEquals("Sickle Cell Disease", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,7 +461,7 @@ class TrueHemeTestFragmentTest {
|
|||||||
val led2Average = 0.2
|
val led2Average = 0.2
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = trueHemeTestFragment.reclassifyWithBorderlineMethod2(
|
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
||||||
deviceRatio,
|
deviceRatio,
|
||||||
deviceRatioClass,
|
deviceRatioClass,
|
||||||
led2Average
|
led2Average
|
||||||
@@ -491,7 +479,7 @@ class TrueHemeTestFragmentTest {
|
|||||||
val led2Average = 0.14
|
val led2Average = 0.14
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = trueHemeTestFragment.reclassifyWithBorderlineMethod2(
|
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
||||||
deviceRatio,
|
deviceRatio,
|
||||||
deviceRatioClass,
|
deviceRatioClass,
|
||||||
led2Average
|
led2Average
|
||||||
@@ -509,7 +497,7 @@ class TrueHemeTestFragmentTest {
|
|||||||
val led2Average = 0.18
|
val led2Average = 0.18
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = trueHemeTestFragment.reclassifyWithBorderlineMethod2(
|
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
||||||
deviceRatio,
|
deviceRatio,
|
||||||
deviceRatioClass,
|
deviceRatioClass,
|
||||||
led2Average
|
led2Average
|
||||||
@@ -527,7 +515,7 @@ class TrueHemeTestFragmentTest {
|
|||||||
val led2Average = 0.195
|
val led2Average = 0.195
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = trueHemeTestFragment.reclassifyWithBorderlineMethod2(
|
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
||||||
deviceRatio,
|
deviceRatio,
|
||||||
deviceRatioClass,
|
deviceRatioClass,
|
||||||
led2Average
|
led2Average
|
||||||
@@ -545,7 +533,7 @@ class TrueHemeTestFragmentTest {
|
|||||||
val led2Average = 0.189
|
val led2Average = 0.189
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
val result = trueHemeTestFragment.reclassifyWithBorderlineMethod2(
|
val result = hemoCubeFragment.reclassifyWithBorderlineMethod2(
|
||||||
deviceRatio,
|
deviceRatio,
|
||||||
deviceRatioClass,
|
deviceRatioClass,
|
||||||
led2Average
|
led2Average
|
||||||
@@ -20,7 +20,7 @@ import com.example.hpostesting.util.Result
|
|||||||
import com.example.hpostesting.data.model.login.LoginResponse
|
import com.example.hpostesting.data.model.login.LoginResponse
|
||||||
import com.example.hpostesting.data.repository.Repository
|
import com.example.hpostesting.data.repository.Repository
|
||||||
import com.example.hpostesting.domain.LogFileManager
|
import com.example.hpostesting.domain.LogFileManager
|
||||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestViewModel
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
import com.example.hpostesting.util.TestCoroutineRule
|
import com.example.hpostesting.util.TestCoroutineRule
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.impl.annotations.MockK
|
import io.mockk.impl.annotations.MockK
|
||||||
@@ -59,7 +59,7 @@ class HemocubeViewModelTest {
|
|||||||
@MockK(relaxed = true)
|
@MockK(relaxed = true)
|
||||||
lateinit var observer: Observer<Result<LoginResponse>>
|
lateinit var observer: Observer<Result<LoginResponse>>
|
||||||
|
|
||||||
private lateinit var viewModel: TrueHemeTestViewModel
|
private lateinit var viewModel: HemoCubeViewModel
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
|
|||||||
3768
hs_err_pid3592.log
Normal file
3768
hs_err_pid3592.log
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user