Compare commits
211 Commits
crashanaly
...
preprod-te
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da9a2296d6 | ||
|
|
30fde87f95 | ||
|
|
47888172fd | ||
|
|
7ba0124f1a | ||
|
|
f9b8df970d | ||
|
|
46d2c2f57b | ||
|
|
18ed6c4e11 | ||
|
|
ae42c96256 | ||
|
|
b0d348cf6d | ||
|
|
214a834740 | ||
|
|
d362a7fa86 | ||
|
|
dfbcb4af6a | ||
|
|
e8b380a4c4 | ||
|
|
ba45346fba | ||
|
|
4b205185d3 | ||
|
|
00a3124fbf | ||
|
|
0faf4adbd7 | ||
|
|
d1b5ca32bf | ||
|
|
3e690345c2 | ||
|
|
4f7aa74314 | ||
|
|
590abb5c73 | ||
|
|
7fe8202968 | ||
|
|
11d4c99e02 | ||
|
|
2e700601fe | ||
|
|
41798aa37b | ||
|
|
e7600dafec | ||
|
|
d6b3df25f8 | ||
|
|
0d7e8b0cd0 | ||
|
|
3c8570c46b | ||
|
|
96f9d4d6da | ||
|
|
e7505077ce | ||
|
|
41e30cf178 | ||
|
|
a34c095fde | ||
|
|
80fa523ec9 | ||
|
|
7a2e5ead51 | ||
|
|
f109c52288 | ||
|
|
a3a5c0d6fb | ||
|
|
fb5e6f3b49 | ||
|
|
8a22b44496 | ||
|
|
10d822c5d6 | ||
|
|
4a248f7c49 | ||
|
|
2123b2a7b4 | ||
|
|
704223e403 | ||
|
|
6097a05701 | ||
|
|
290bf77950 | ||
|
|
ad595a6299 | ||
|
|
22bf66fc94 | ||
|
|
1dd66bcd6e | ||
|
|
a02ba3e9ea | ||
|
|
457c652161 | ||
|
|
5bebd88dfd | ||
|
|
657b9aea65 | ||
|
|
90590ee535 | ||
|
|
3d39c43c22 | ||
|
|
6fa5e760c1 | ||
|
|
8940352e05 | ||
|
|
47fabf036f | ||
|
|
d7a41e8f31 | ||
|
|
f26f3098bb | ||
|
|
4d454ea031 | ||
|
|
e92a80caec | ||
|
|
28bd9cbd43 | ||
|
|
fc3e4d506a | ||
|
|
60fbd70f2d | ||
|
|
7f2cafeef4 | ||
|
|
b37d3f1fce | ||
|
|
1d22fa54c9 | ||
|
|
3b3bc1adf4 | ||
|
|
a1206dbe0d | ||
|
|
6e9850c492 | ||
|
|
5982ce822f | ||
|
|
5c32a17871 | ||
|
|
16528bd165 | ||
|
|
f86caf0448 | ||
|
|
a7a57c7ff4 | ||
|
|
3c70142c15 | ||
|
|
467dde9a24 | ||
|
|
ae50d6a603 | ||
|
|
c0825a1c58 | ||
|
|
78763d8624 | ||
|
|
fcac603ce0 | ||
|
|
0a2f1ba2fd | ||
|
|
dcc7a921a0 | ||
|
|
b6f8999078 | ||
|
|
84e2a4bed9 | ||
|
|
74ad03bf8b | ||
|
|
f00a639028 | ||
|
|
d3083c8dbc | ||
|
|
29846ddf7d | ||
|
|
9deac8e278 | ||
|
|
264c4ebe74 | ||
|
|
2a976caac5 | ||
|
|
fb61b89850 | ||
|
|
e42183099c | ||
|
|
bf9288d0a1 | ||
|
|
d57bc713d1 | ||
|
|
f37cfb57e1 | ||
|
|
9d86d874af | ||
|
|
f0d0740cd7 | ||
|
|
27949352dd | ||
|
|
36eb659e3a | ||
|
|
2d0f11cfb2 | ||
|
|
3e8933de1b | ||
|
|
edf1d70608 | ||
|
|
a6d57fb52a | ||
|
|
babb3dd364 | ||
|
|
51f3e31f27 | ||
|
|
044c5db161 | ||
|
|
f4085545ea | ||
|
|
8872e484a1 | ||
|
|
88aab7c527 | ||
|
|
81298f9634 | ||
|
|
8824fb6b11 | ||
|
|
0e847bad0a | ||
|
|
9d06a77091 | ||
|
|
7ece136cb5 | ||
|
|
5f44666387 | ||
|
|
2cccfc6a63 | ||
|
|
50bfd3f962 | ||
|
|
d750930b7a | ||
|
|
4214c32829 | ||
|
|
481169a181 | ||
|
|
441e7d14b8 | ||
|
|
71f3169ee3 | ||
|
|
5edeef0021 | ||
|
|
5f5037f300 | ||
|
|
a99c24dd86 | ||
|
|
feabcebd92 | ||
|
|
5df58a3630 | ||
|
|
c6d2e2a7c5 | ||
|
|
e974637744 | ||
|
|
220fea4c2e | ||
|
|
f67dc04916 | ||
|
|
d90dfc0695 | ||
|
|
2b1f8a07ae | ||
|
|
26246cd902 | ||
|
|
f2f927cd23 | ||
|
|
3249811c0d | ||
|
|
c076da3bb4 | ||
|
|
1f31b0bff0 | ||
|
|
8b833ca02d | ||
|
|
2c50890b0d | ||
|
|
0b52dc42b0 | ||
|
|
137eb7dd55 | ||
|
|
12df83db7b | ||
|
|
9849921833 | ||
|
|
8662e03dad | ||
|
|
ac2bb91648 | ||
|
|
0408ef3fbd | ||
|
|
9db8e962d7 | ||
|
|
7c4717ebb7 | ||
|
|
eb668c631c | ||
|
|
3e362a22fa | ||
|
|
e2c07d6252 | ||
|
|
497a61c16b | ||
|
|
acd9262dfe | ||
|
|
f8ac0e81ce | ||
|
|
5a7a09817f | ||
|
|
ab09c659b9 | ||
|
|
14c15bb9ab | ||
|
|
0ca4083c16 | ||
|
|
662e2644f2 | ||
|
|
63aeebd4e1 | ||
|
|
315c46c014 | ||
|
|
27bf068df0 | ||
|
|
23d382395f | ||
|
|
31d3458cd1 | ||
|
|
1ec79853de | ||
|
|
744735d7ba | ||
|
|
211429fb8f | ||
|
|
8a56d0eb5f | ||
|
|
ed6cb58b69 | ||
|
|
67d8ffe502 | ||
|
|
dadc24cb88 | ||
|
|
118b17bee1 | ||
|
|
d42f5e31e5 | ||
|
|
f1f45fb958 | ||
|
|
8482de6aeb | ||
|
|
d6ffcba70a | ||
|
|
381b351309 | ||
|
|
c01676cc4f | ||
|
|
a61aab377e | ||
|
|
e1dbfc9d89 | ||
|
|
3671dc9db8 | ||
|
|
e613bbd12b | ||
|
|
1d017f0578 | ||
|
|
e34e7ada52 | ||
|
|
9cd0ee21b6 | ||
|
|
f3598c9699 | ||
|
|
9b38a5dff7 | ||
|
|
a7adb02593 | ||
|
|
5647340b90 | ||
|
|
94894f34a5 | ||
|
|
095f9fb027 | ||
|
|
1fb938bd0d | ||
|
|
865922e90e | ||
|
|
e71496e423 | ||
|
|
472b50562b | ||
|
|
81e8567b49 | ||
|
|
3f8b931684 | ||
|
|
270cee7a9c | ||
|
|
515ab24ce6 | ||
|
|
e455cacf69 | ||
|
|
45613b2709 | ||
|
|
34bed4e5fe | ||
|
|
f019e1897d | ||
|
|
1d542f5562 | ||
|
|
4289d1c399 | ||
|
|
38f2122444 | ||
|
|
d6bacd578c | ||
|
|
f8a7bff5b2 |
2
.idea/gradle.xml
generated
2
.idea/gradle.xml
generated
@@ -5,7 +5,6 @@
|
|||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="testRunner" value="GRADLE" />
|
<option name="testRunner" value="GRADLE" />
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="jbr-17" />
|
<option name="gradleJvm" value="jbr-17" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
@@ -14,6 +13,7 @@
|
|||||||
<option value="$PROJECT_DIR$/app" />
|
<option value="$PROJECT_DIR$/app" />
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
|
<option name="resolveExternalAnnotations" value="false" />
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
43
.idea/misc.xml
generated
43
.idea/misc.xml
generated
@@ -1,43 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="DesignSurface">
|
|
||||||
<option name="filePathToZoomLevelMap">
|
|
||||||
<map>
|
|
||||||
<entry key="app/src/main/res/drawable/ic_baseline_auto_graph_24.xml" value="0.1555" />
|
|
||||||
<entry key="app/src/main/res/drawable/ic_baseline_cancel_24.xml" value="0.1965" />
|
|
||||||
<entry key="app/src/main/res/drawable/ic_baseline_check_circle_24.xml" value="0.243" />
|
|
||||||
<entry key="app/src/main/res/drawable/ic_baseline_dot_24.xml" value="0.1785" />
|
|
||||||
<entry key="app/src/main/res/drawable/ic_baseline_file_download_24.xml" value="0.243" />
|
|
||||||
<entry key="app/src/main/res/drawable/ic_baseline_home_24.xml" value="0.243" />
|
|
||||||
<entry key="app/src/main/res/drawable/ic_baseline_new_label_24.xml" value="0.243" />
|
|
||||||
<entry key="app/src/main/res/drawable/ic_baseline_usb_24.xml" value="0.157" />
|
|
||||||
<entry key="app/src/main/res/drawable/ic_baseline_usb_off_24.xml" value="0.157" />
|
|
||||||
<entry key="app/src/main/res/drawable/progressbar_drawable.xml" value="0.1885" />
|
|
||||||
<entry key="app/src/main/res/drawable/result_background_green.xml" value="0.243" />
|
|
||||||
<entry key="app/src/main/res/drawable/result_background_red.xml" value="0.1785" />
|
|
||||||
<entry key="app/src/main/res/drawable/result_background_tellow.xml" value="0.1785" />
|
|
||||||
<entry key="app/src/main/res/font/inter_bold.xml" value="0.33487179487179486" />
|
|
||||||
<entry key="app/src/main/res/layout/activity_main.xml" value="0.165" />
|
|
||||||
<entry key="app/src/main/res/layout/activity_splash.xml" value="0.24375" />
|
|
||||||
<entry key="app/src/main/res/layout/activity_test_right.xml" value="0.24375" />
|
|
||||||
<entry key="app/src/main/res/layout/fragment_graph.xml" value="0.19791666666666666" />
|
|
||||||
<entry key="app/src/main/res/layout/fragment_test_right_exp_reference.xml" value="0.25" />
|
|
||||||
<entry key="app/src/main/res/layout/fragment_test_right_exp_sample.xml" value="0.24583333333333332" />
|
|
||||||
<entry key="app/src/main/res/layout/fragment_test_right_exp_scanner.xml" value="0.24583333333333332" />
|
|
||||||
<entry key="app/src/main/res/layout/fragment_test_right_process.xml" value="0.24375" />
|
|
||||||
<entry key="app/src/main/res/layout/fragment_test_right_results.xml" value="0.30512820512820515" />
|
|
||||||
<entry key="app/src/main/res/layout/table_item.xml" value="0.22407407407407406" />
|
|
||||||
<entry key="app/src/main/res/menu/menu.xml" value="0.25" />
|
|
||||||
<entry key="app/src/main/res/menu/my_menu.xml" value="0.25" />
|
|
||||||
<entry key="app/src/main/res/mipmap-anydpi-v26/hpos_icon.xml" value="0.1505" />
|
|
||||||
<entry key="app/src/main/res/mipmap-anydpi-v26/hpos_icon_round.xml" value="0.1505" />
|
|
||||||
</map>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
|
||||||
</component>
|
|
||||||
<component name="ProjectType">
|
|
||||||
<option name="id" value="Android" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
2
app/.gitignore
vendored
2
app/.gitignore
vendored
@@ -1,3 +1,3 @@
|
|||||||
/build
|
/build
|
||||||
/google-services.json
|
/google-services*
|
||||||
/idea
|
/idea
|
||||||
@@ -14,12 +14,13 @@ android {
|
|||||||
compileSdk 34
|
compileSdk 34
|
||||||
namespace 'in.sminnovations.hpostesting'
|
namespace 'in.sminnovations.hpostesting'
|
||||||
|
|
||||||
|
// prod - production, preprod - preproduction, quality - qc
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "in.sminnovations.hpostesting"
|
applicationId "in.sminnovations.hpostesting"
|
||||||
minSdk 21
|
minSdk 21
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 2
|
versionCode 26
|
||||||
versionName "2.0.1"
|
versionName "2.1.26"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
@@ -48,18 +49,25 @@ android {
|
|||||||
abortOnError false
|
abortOnError false
|
||||||
checkReleaseBuilds false
|
checkReleaseBuilds false
|
||||||
}
|
}
|
||||||
|
packagingOptions {
|
||||||
|
exclude 'mockito-extensions/org.mockito.plugins.MockMaker'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation "com.google.dagger:hilt-android:2.46"
|
||||||
|
kapt "com.google.dagger:hilt-android-compiler:2.46"
|
||||||
|
|
||||||
implementation 'androidx.core:core-ktx:1.12.0'
|
implementation 'androidx.core:core-ktx:1.12.0'
|
||||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||||
implementation 'com.google.android.material:material:1.9.0'
|
implementation 'com.google.android.material:material:1.11.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2'
|
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2'
|
||||||
|
implementation 'androidx.fragment:fragment-ktx:1.6.2'
|
||||||
|
|
||||||
//firebase
|
//firebase
|
||||||
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-crashlytics-ktx")
|
implementation("com.google.firebase:firebase-crashlytics-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'
|
||||||
@@ -70,21 +78,35 @@ dependencies {
|
|||||||
implementation 'com.google.android.gms:play-services-location:21.0.1'
|
implementation 'com.google.android.gms:play-services-location:21.0.1'
|
||||||
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
|
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
|
||||||
implementation 'com.google.android.things:androidthings:1.0'
|
implementation 'com.google.android.things:androidthings:1.0'
|
||||||
|
implementation 'com.google.firebase:firebase-appdistribution:16.0.0-beta11'
|
||||||
|
implementation("com.google.firebase:firebase-appdistribution-api-ktx:16.0.0-beta11")
|
||||||
|
implementation 'androidx.preference:preference-ktx:1.2.1'
|
||||||
|
implementation 'androidx.preference:preference-ktx:1.2.1'
|
||||||
|
implementation 'com.google.android.play:core:1.10.3'
|
||||||
|
implementation 'io.nats:jnats:2.11.2'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Testing
|
// Testing
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||||
|
// Mockito dependencies
|
||||||
|
testImplementation 'org.mockito:mockito-core:3.12.4'
|
||||||
|
androidTestImplementation 'org.mockito:mockito-android:3.12.4'
|
||||||
|
androidTestImplementation 'org.mockito:mockito-inline:3.12.4'
|
||||||
|
testImplementation "androidx.arch.core:core-testing:2.2.0"
|
||||||
|
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.1'
|
||||||
|
|
||||||
|
|
||||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2"
|
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2"
|
||||||
implementation 'com.opencsv:opencsv:4.6'
|
implementation 'com.opencsv:opencsv:5.5'
|
||||||
implementation 'com.github.mik3y:usb-serial-for-android:3.5.1'
|
implementation 'com.github.mik3y:usb-serial-for-android:3.5.1'
|
||||||
|
|
||||||
implementation "androidx.fragment:fragment-ktx:1.6.1"
|
implementation "androidx.fragment:fragment-ktx:1.6.2"
|
||||||
|
|
||||||
// CSV read, write
|
// CSV read, write
|
||||||
implementation 'com.opencsv:opencsv:4.6'
|
implementation 'com.opencsv:opencsv:5.5'
|
||||||
|
|
||||||
// Barcode scanner
|
// Barcode scanner
|
||||||
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
|
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'
|
||||||
@@ -93,25 +115,30 @@ dependencies {
|
|||||||
implementation 'com.google.android.gms:play-services-code-scanner:16.1.0'
|
implementation 'com.google.android.gms:play-services-code-scanner:16.1.0'
|
||||||
|
|
||||||
//Room
|
//Room
|
||||||
implementation "androidx.room:room-ktx:2.6.0-beta01"
|
implementation "androidx.room:room-ktx:2.6.1"
|
||||||
implementation "androidx.room:room-runtime:2.6.0-beta01"
|
implementation "androidx.room:room-runtime:2.6.1"
|
||||||
kapt ("androidx.room:room-compiler:2.6.0-beta01")
|
kapt ("androidx.room:room-compiler:2.6.1")
|
||||||
|
|
||||||
//image
|
//image
|
||||||
implementation 'com.github.bumptech.glide:glide:4.13.2'
|
implementation 'com.github.bumptech.glide:glide:4.13.2'
|
||||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.2'
|
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.2'
|
||||||
|
|
||||||
// Navigation Component
|
// Navigation Component
|
||||||
implementation "androidx.navigation:navigation-fragment-ktx:2.7.2"
|
implementation "androidx.navigation:navigation-fragment-ktx:2.7.6"
|
||||||
implementation "androidx.navigation:navigation-ui-ktx:2.7.2"
|
implementation "androidx.navigation:navigation-ui-ktx:2.7.6"
|
||||||
|
|
||||||
//Dagger - Hilt
|
//Dagger - Hilt
|
||||||
implementation "com.google.dagger:hilt-android:2.46"
|
implementation "com.google.dagger:hilt-android:2.46"
|
||||||
kapt "com.google.dagger:hilt-android-compiler:2.46"
|
kapt "com.google.dagger:hilt-android-compiler:2.46"
|
||||||
kapt "androidx.hilt:hilt-compiler:1.0.0"
|
kapt "androidx.hilt:hilt-compiler:1.1.0"
|
||||||
|
|
||||||
// Retrofit + GSON
|
// Retrofit + GSON
|
||||||
implementation "com.squareup.retrofit2:retrofit:2.9.0"
|
implementation "com.squareup.retrofit2:retrofit:2.9.0"
|
||||||
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
|
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
|
||||||
|
implementation("com.squareup.okhttp3:okhttp:4.9.3")
|
||||||
|
|
||||||
|
implementation "androidx.preference:preference-ktx:1.2.1"
|
||||||
|
implementation 'io.nats:jnats:2.11.2'
|
||||||
|
implementation 'com.google.android.play:core:1.10.3'
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,11 @@
|
|||||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||||
|
|
||||||
|
<uses-permission
|
||||||
|
android:name="android.permission.BATTERY_STATS"
|
||||||
|
tools:ignore="ProtectedPermissions" />
|
||||||
|
|
||||||
<uses-feature android:name="android.hardware.camera" />
|
<uses-feature android:name="android.hardware.camera" />
|
||||||
|
|
||||||
@@ -30,10 +35,11 @@
|
|||||||
android:theme="@style/Theme.HPOSTesting"
|
android:theme="@style/Theme.HPOSTesting"
|
||||||
tools:targetApi="31">
|
tools:targetApi="31">
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.BloodCollectingMethodActivity"
|
android:name="com.example.hpostesting.presentation.hemocube.DigitalCardActivity"
|
||||||
android:exported="true"
|
android:exported="false" />
|
||||||
android:noHistory="true"
|
<activity
|
||||||
android:theme="@style/Theme.HPOS.NoActionBar" />
|
android:name="com.example.hpostesting.presentation.diagnostics.DiagnosticsActivity"
|
||||||
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.hemocube.HemocubeActivity"
|
android:name="com.example.hpostesting.presentation.hemocube.HemocubeActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
@@ -41,6 +47,13 @@
|
|||||||
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"
|
||||||
android:windowSoftInputMode="adjustPan" />
|
android:windowSoftInputMode="adjustPan" />
|
||||||
|
<activity
|
||||||
|
android:name="com.example.hpostesting.presentation.buffercheck.HemocubeBufferCheckActivity"
|
||||||
|
android:exported="false"
|
||||||
|
android:noHistory="true"
|
||||||
|
android:parentActivityName="com.example.hpostesting.presentation.MainActivity"
|
||||||
|
android:theme="@style/Theme.HPOS.NoActionBar"
|
||||||
|
android:windowSoftInputMode="adjustPan" />
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.KitScanActivity"
|
android:name="com.example.hpostesting.presentation.KitScanActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
@@ -50,7 +63,18 @@
|
|||||||
android:name="com.example.hpostesting.presentation.dashboard.DashboardActivity"
|
android:name="com.example.hpostesting.presentation.dashboard.DashboardActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:label="@string/title_activity_dashboard"
|
android:label="@string/title_activity_dashboard"
|
||||||
android:theme="@style/Theme.HPOS.NoActionBar" />
|
android:theme="@style/Theme.HPOS.NoActionBar"
|
||||||
|
tools:ignore="AppLinkUrlError,MissingClass">
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<data android:scheme="content" />
|
||||||
|
<data android:scheme="file" />
|
||||||
|
<data android:mimeType="application/vnd.android.package-archive" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name="com.example.hpostesting.presentation.testRight.UsbService"
|
android:name="com.example.hpostesting.presentation.testRight.UsbService"
|
||||||
@@ -99,9 +123,20 @@
|
|||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name="com.journeyapps.barcodescanner.CaptureActivity"
|
android:name="com.journeyapps.barcodescanner.CaptureActivity"
|
||||||
android:screenOrientation="fullSensor"
|
android:screenOrientation="portrait"
|
||||||
android:stateNotNeeded="true"
|
android:stateNotNeeded="true"
|
||||||
tools:replace="android:screenOrientation" />
|
tools:replace="android:screenOrientation" />
|
||||||
|
|
||||||
|
<provider
|
||||||
|
android:name="androidx.core.content.FileProvider"
|
||||||
|
android:authorities="com.example.hpostesting.fileprovider"
|
||||||
|
android:exported="false"
|
||||||
|
android:grantUriPermissions="true">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
|
android:resource="@xml/file_paths" />
|
||||||
|
</provider>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
1
app/src/main/assets/app.properties
Normal file
1
app/src/main/assets/app.properties
Normal file
@@ -0,0 +1 @@
|
|||||||
|
BASE_URL= https://datacollection.micropcr.com/api/
|
||||||
@@ -15,6 +15,8 @@ import javax.inject.Singleton
|
|||||||
|
|
||||||
@HiltAndroidApp
|
@HiltAndroidApp
|
||||||
class HPOSTestingApplication: Application() {
|
class HPOSTestingApplication: Application() {
|
||||||
|
val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||||
|
|||||||
@@ -1,46 +0,0 @@
|
|||||||
package com.example.hpostesting.data
|
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import com.example.hpostesting.data.model.Response
|
|
||||||
import com.example.hpostesting.data.repository.DatabaseRepository
|
|
||||||
import com.example.hpostesting.util.MyUtils
|
|
||||||
import kotlinx.coroutines.GlobalScope
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
|
|
||||||
class FileUploader {
|
|
||||||
|
|
||||||
private val TAG = "FileUploader"
|
|
||||||
val repository = DatabaseRepository()
|
|
||||||
|
|
||||||
suspend fun start() {
|
|
||||||
|
|
||||||
val listOfFiles = repository.getAllFromPendingQueue()
|
|
||||||
|
|
||||||
for (each in listOfFiles){
|
|
||||||
// Checking internet connectivity & mobile as same or not
|
|
||||||
if (MyUtils.isInternetConnected() && each.mobileId == DataHolder.mobileUniqueId) {
|
|
||||||
|
|
||||||
Log.d(TAG, "uploading file ${each.pendingId}")
|
|
||||||
GlobalScope.launch {
|
|
||||||
val response = repository.uploadFileToStorage(each.patientId, each.filePath)
|
|
||||||
|
|
||||||
when (response) {
|
|
||||||
is Response.Success -> {
|
|
||||||
Log.d(TAG, "File Uploaded ${each.pendingId}")
|
|
||||||
repository.removeFromPendingQueue(each.pendingId)
|
|
||||||
}
|
|
||||||
|
|
||||||
is Response.Error -> {
|
|
||||||
Log.d(TAG, response.exception.toString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.join()
|
|
||||||
|
|
||||||
} else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
7
app/src/main/java/com/example/hpostesting/data/Result.kt
Normal file
7
app/src/main/java/com/example/hpostesting/data/Result.kt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package com.example.hpostesting.data
|
||||||
|
|
||||||
|
sealed class Result<out T : Any> {
|
||||||
|
data class Success<out T : Any>(val data: T) : Result<T>()
|
||||||
|
data class Error(val exception: Exception) : Result<Nothing>()
|
||||||
|
class Loading<T : Any> : Result<T>()
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.example.hpostesting.data.api
|
||||||
|
|
||||||
|
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
||||||
|
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionResponse
|
||||||
|
import com.example.hpostesting.data.model.login.LoginRequest
|
||||||
|
import com.example.hpostesting.data.model.login.LoginResponse
|
||||||
|
import retrofit2.http.Body
|
||||||
|
import retrofit2.http.POST
|
||||||
|
|
||||||
|
interface MolbioAuthApi {
|
||||||
|
|
||||||
|
@POST("deviceManagement/device/provision")
|
||||||
|
suspend fun deviceProvision(
|
||||||
|
@Body deviceProvisionRequest: DeviceProvisionRequest
|
||||||
|
): DeviceProvisionResponse
|
||||||
|
|
||||||
|
@POST("deviceService/device/login")
|
||||||
|
suspend fun login(
|
||||||
|
@Body loginRequest: LoginRequest
|
||||||
|
): LoginResponse
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.example.hpostesting.data.api
|
||||||
|
|
||||||
|
import com.example.hpostesting.data.model.log.UploadLogsResponse
|
||||||
|
import com.example.hpostesting.data.model.molbioresult.MolbioV2ResultRequest
|
||||||
|
import com.example.hpostesting.data.model.molbioresult.MolbioV2ResultResponse
|
||||||
|
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
||||||
|
import com.example.hpostesting.data.model.updates.CheckUpdateResponse
|
||||||
|
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
||||||
|
import okhttp3.MultipartBody
|
||||||
|
import okhttp3.ResponseBody
|
||||||
|
import retrofit2.http.Body
|
||||||
|
import retrofit2.http.Multipart
|
||||||
|
import retrofit2.http.POST
|
||||||
|
import retrofit2.http.PUT
|
||||||
|
import retrofit2.http.Part
|
||||||
|
|
||||||
|
interface MolbioResultApi {
|
||||||
|
|
||||||
|
@PUT("deviceService/results/HPOS")
|
||||||
|
suspend fun uploadResults(
|
||||||
|
@Body molbioV2ResultRequest: MolbioV2ResultRequest
|
||||||
|
): MolbioV2ResultResponse
|
||||||
|
|
||||||
|
@POST("deviceService/device/checkUpdate")
|
||||||
|
suspend fun checkUpdate(
|
||||||
|
@Body checkUpdateRequest: CheckUpdateRequest
|
||||||
|
): CheckUpdateResponse
|
||||||
|
|
||||||
|
@POST("deviceService/device/getUpdate")
|
||||||
|
suspend fun deviceUpdate(
|
||||||
|
@Body deviceUpdateRequest: DeviceUpdateRequest
|
||||||
|
): ResponseBody
|
||||||
|
|
||||||
|
@Multipart
|
||||||
|
@POST("deviceService/device/uploadLogs")
|
||||||
|
suspend fun uploadLogs(
|
||||||
|
@Part logFile: MultipartBody.Part
|
||||||
|
): UploadLogsResponse
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.example.hpostesting.data.api
|
||||||
|
|
||||||
|
interface PropertyProvider {
|
||||||
|
|
||||||
|
fun getProperty(key: String): String
|
||||||
|
}
|
||||||
@@ -4,8 +4,21 @@ object Constants {
|
|||||||
const val ACTION_USB_PERMISSION = "shanmukha.in.sickle_cell.USB_PERMISSION"
|
const val ACTION_USB_PERMISSION = "shanmukha.in.sickle_cell.USB_PERMISSION"
|
||||||
const val HOMOCUBE_USB_PERMISSION = "shanmukha.in.sickle_cell_homocube.USB_PERMISSION"
|
const val HOMOCUBE_USB_PERMISSION = "shanmukha.in.sickle_cell_homocube.USB_PERMISSION"
|
||||||
|
|
||||||
|
const val BASE_URL = "www.google.com"
|
||||||
|
|
||||||
const val ABHA_APP_PACKAGE = "in.ndhm.phr"
|
const val ABHA_APP_PACKAGE = "in.ndhm.phr"
|
||||||
|
|
||||||
|
const val serialNumber = "NKH5555AH"
|
||||||
|
const val deviceTypeName = "HPOS"
|
||||||
|
const val uid = "NKH5555AH"
|
||||||
|
const val deviceProvisionEmail = "HPOS_provisioner@bigtec.co.in"
|
||||||
|
const val deviceProvisionPassword = "f2ab0e7f9d69"
|
||||||
|
const val deviceID = "HCV-000-3001"
|
||||||
|
const val devicePassword = "810516d8f4c7"
|
||||||
|
|
||||||
|
const val ACCESS_TOKEN = "accessToken"
|
||||||
|
const val NATS_TOKEN = "natsToken"
|
||||||
|
|
||||||
const val WRITE_TIMEOUT_MILLIS = 30000 // 30 sec
|
const val WRITE_TIMEOUT_MILLIS = 30000 // 30 sec
|
||||||
const val READ_TIMEOUT_MILLIS = 60000 // 1 min
|
const val READ_TIMEOUT_MILLIS = 60000 // 1 min
|
||||||
const val DELAY_BETWEEN_COMMANDS: Long = 1000
|
const val DELAY_BETWEEN_COMMANDS: Long = 1000
|
||||||
@@ -29,6 +42,8 @@ object Constants {
|
|||||||
const val DEVICE_VENDOR_ID = 1027
|
const val DEVICE_VENDOR_ID = 1027
|
||||||
const val HOMO_CUBE_ID = 29987
|
const val HOMO_CUBE_ID = 29987
|
||||||
const val VENDOR_ID = 6790
|
const val VENDOR_ID = 6790
|
||||||
|
const val HEMO_CUBE_V2_PRODUCT_ID = 24577
|
||||||
|
const val HEMO_CUBE_V2_VENDOR_ID = 1027
|
||||||
|
|
||||||
const val ERROR_NORMAL = 400
|
const val ERROR_NORMAL = 400
|
||||||
const val ERROR_CRITICAL = 401
|
const val ERROR_CRITICAL = 401
|
||||||
@@ -38,6 +53,7 @@ object Constants {
|
|||||||
const val USER_ID = "usernameId"
|
const val USER_ID = "usernameId"
|
||||||
|
|
||||||
val STATICID = listOf(
|
val STATICID = listOf(
|
||||||
|
"ADMIN",
|
||||||
"VIZ-1000-0004",
|
"VIZ-1000-0004",
|
||||||
"VIZ-1000-0005",
|
"VIZ-1000-0005",
|
||||||
"VIZ-1000-0006",
|
"VIZ-1000-0006",
|
||||||
@@ -47,6 +63,30 @@ object Constants {
|
|||||||
"HC-V1-004",
|
"HC-V1-004",
|
||||||
"HC-V1-005",
|
"HC-V1-005",
|
||||||
"HC-V1-006",
|
"HC-V1-006",
|
||||||
|
"HC-V1-007",
|
||||||
|
"HC-V1-008",
|
||||||
|
"HC-V1-009",
|
||||||
|
"HC-V1-010",
|
||||||
|
"HC-V1-011",
|
||||||
|
"HC-V1-012",
|
||||||
|
"HC-V1-013",
|
||||||
|
"HC-V1-014",
|
||||||
|
"HC-V1-015",
|
||||||
|
"HC-V1-016",
|
||||||
|
"HC-V1-017",
|
||||||
|
"HC-V1-018",
|
||||||
|
"HC-V1-019",
|
||||||
|
"HC-V1-020",
|
||||||
|
"HCV-000-3001",
|
||||||
|
"HCV-000-3002",
|
||||||
|
"HCV-000-3003",
|
||||||
|
"HCV-000-3004",
|
||||||
|
"HCV-000-3005",
|
||||||
|
"HCV-000-3006",
|
||||||
|
"HCV-000-3007",
|
||||||
|
"HCV-000-3008",
|
||||||
|
"HCV-000-3009",
|
||||||
|
"HCV-000-3010"
|
||||||
)
|
)
|
||||||
|
|
||||||
const val password = "SMI@12345"
|
const val password = "SMI@12345"
|
||||||
@@ -55,8 +95,153 @@ object Constants {
|
|||||||
const val KIT_COUNT = "KitCount"
|
const val KIT_COUNT = "KitCount"
|
||||||
const val BUFFER_VALUE_1 = "BufferValue1"
|
const val BUFFER_VALUE_1 = "BufferValue1"
|
||||||
const val BUFFER_VALUE_2 = "BufferValue2"
|
const val BUFFER_VALUE_2 = "BufferValue2"
|
||||||
|
const val BUFFER_VALUE_3 = "BufferValue3"
|
||||||
|
const val BUFFER_VALUE_4 = "BufferValue4"
|
||||||
|
const val DEVICE_ID = "DEVICE_ID"
|
||||||
|
|
||||||
const val BLOOD_COLLECTING_METHOD = "bloodCollectingMethod"
|
const val BUFFER_LED_LOWER_BOUND = 21000
|
||||||
const val VENOUS_BLOOD = "venousBlood"
|
const val BUFFER_LED_UPPER_BOUND = 24500
|
||||||
const val FINGER_PRICK_BLOOD = "fingerPrickBlood"
|
|
||||||
|
const val TEST_STATUS_CODE_TEST_STARTED = 1.0
|
||||||
|
const val TEST_STATUS_CODE_CONFIG_STARTED = 2.0
|
||||||
|
const val TEST_STATUS_CODE_CONFIG_COMPLETED = 3.0
|
||||||
|
const val TEST_STATUS_CODE_BUFFER_STARTED = 4.0
|
||||||
|
const val TEST_STATUS_CODE_BUFFER_COMPLETED = 5.0
|
||||||
|
const val TEST_STATUS_CODE_BUFFER_PRINT_STARTED = 6.0
|
||||||
|
const val TEST_STATUS_CODE_BUFFER_PRINT_COMPLETED = 7.0
|
||||||
|
const val TEST_STATUS_CODE_SAMPLE_STARTED = 8.0
|
||||||
|
const val TEST_STATUS_CODE_SAMPLE_COMPLETED = 9.0
|
||||||
|
const val TEST_STATUS_CODE_SAMPLE_PRINT_STARTED = 10.0
|
||||||
|
const val TEST_STATUS_CODE_SAMPLE_PRINT_COMPLETED = 11.0
|
||||||
|
const val TEST_STATUS_CODE_TEST_COMPLETED = 12.0
|
||||||
|
|
||||||
|
val DEVICE_CONFIGURATION: Map<String, List<List<Double>>> = mapOf<String, List<List<Double>>>(
|
||||||
|
"HCV-000-3001" to listOf(
|
||||||
|
listOf(1.313, -0.89), // LED1, 435nm
|
||||||
|
listOf(0.581462456, -0.58502), // LED2, 415nm
|
||||||
|
listOf(0.2012, 0.0092), // LED3, 555nm
|
||||||
|
listOf(1.0, 0.0) // LED4
|
||||||
|
),
|
||||||
|
"HCV-000-3002" to listOf(
|
||||||
|
listOf(0.723142, -0.09135), // LED1, 435nm
|
||||||
|
listOf(0.581462456, -0.58502), // LED2, 415nm
|
||||||
|
listOf(0.1964, 0.011565), // LED3, 555nm
|
||||||
|
listOf(1.0, 0.0) // LED4
|
||||||
|
),
|
||||||
|
"HCV-000-3003" to listOf(
|
||||||
|
listOf(0.723142, -0.09135), // LED1, 435nm
|
||||||
|
listOf(0.581462456, -0.58502), // LED2, 415nm
|
||||||
|
listOf(0.1964, 0.011565), // LED3, 555nm
|
||||||
|
listOf(1.0, 0.0) // LED4
|
||||||
|
),
|
||||||
|
"HCV-000-3004" to listOf(
|
||||||
|
listOf(1.7272, -1.1977), // LED1, 435nm
|
||||||
|
listOf(0.581462456, -0.58502), // LED2, 415nm
|
||||||
|
listOf(0.2304, -0.0145), // LED3, 555nm
|
||||||
|
listOf(1.0, 0.0) // LED4
|
||||||
|
),
|
||||||
|
"HCV-000-3005" to listOf(
|
||||||
|
listOf(1.7272, -1.1977), // LED1, 435nm
|
||||||
|
listOf(0.581462456, -0.58502), // LED2, 415nm
|
||||||
|
listOf(0.2304, -0.0145), // LED3, 555nm
|
||||||
|
listOf(1.0, 0.0) // LED4
|
||||||
|
),
|
||||||
|
"HCV-000-3006" to listOf(
|
||||||
|
listOf(1.7272, -1.1977), // LED1, 435nm
|
||||||
|
listOf(0.581462456, -0.58502), // LED2, 415nm
|
||||||
|
listOf(0.2304, -0.0145), // LED3, 555nm
|
||||||
|
listOf(1.0, 0.0) // LED4
|
||||||
|
),
|
||||||
|
"HCV-000-3007" to listOf(
|
||||||
|
listOf(1.7272, -1.1977), // LED1, 435nm
|
||||||
|
listOf(0.581462456, -0.58502), // LED2, 415nm
|
||||||
|
listOf(0.2304, -0.0145), // LED3, 555nm
|
||||||
|
listOf(1.0, 0.0) // LED4
|
||||||
|
),
|
||||||
|
"HCV-000-3008" to listOf(
|
||||||
|
listOf(1.7272, -1.1977), // LED1, 435nm
|
||||||
|
listOf(0.581462456, -0.58502), // LED2, 415nm
|
||||||
|
listOf(0.2304, -0.0145), // LED3, 555nm
|
||||||
|
listOf(1.0, 0.0) // LED4
|
||||||
|
),
|
||||||
|
"HCV-000-3009" to listOf(
|
||||||
|
listOf(1.7272, -1.1977), // LED1, 435nm
|
||||||
|
listOf(0.581462456, -0.58502), // LED2, 415nm
|
||||||
|
listOf(0.2304, -0.0145), // LED3, 555nm
|
||||||
|
listOf(1.0, 0.0) // LED4
|
||||||
|
),
|
||||||
|
"HCV-000-3010" to listOf(
|
||||||
|
listOf(1.7272, -1.1977), // LED1, 435nm
|
||||||
|
listOf(0.581462456, -0.58502), // LED2, 415nm
|
||||||
|
listOf(0.2304, -0.0145), // LED3, 555nm
|
||||||
|
listOf(1.0, 0.0) // LED4
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
const val INCUBATION_TIME_MIN = 0
|
||||||
|
const val INCUBATION_TIME_MAX = 1400
|
||||||
|
const val BATTERY_LEVEL_MIN = 0
|
||||||
|
|
||||||
|
val BUFFER_INTENSITY_THRESHOLDS: Map<String, List<List<Int>>> = mapOf<String, List<List<Int>>>(
|
||||||
|
"HCV-000-3001" to listOf(
|
||||||
|
listOf(20000, 25074),
|
||||||
|
listOf(20000, 24596),
|
||||||
|
listOf(20000, 26065),
|
||||||
|
listOf(20000, 27093),
|
||||||
|
),
|
||||||
|
"HCV-000-3002" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
),
|
||||||
|
"HCV-000-3003" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
),
|
||||||
|
"HCV-000-3004" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
),
|
||||||
|
"HCV-000-3005" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
),
|
||||||
|
"HCV-000-3006" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
),
|
||||||
|
"HCV-000-3007" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
),
|
||||||
|
"HCV-000-3008" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
),
|
||||||
|
"HCV-000-3009" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
),
|
||||||
|
"HCV-000-3010" to listOf(
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
listOf(24500, 26250),
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,8 @@ package com.example.hpostesting.data.constant
|
|||||||
|
|
||||||
enum class HemoCubeCommands(val command: String) {
|
enum class HemoCubeCommands(val command: String) {
|
||||||
startBuffer("B\r"),
|
startBuffer("B\r"),
|
||||||
getBuffer("Q\r"),
|
runDiagnostics("D\r"),
|
||||||
startSample("S\r"),
|
startSample("S\r"),
|
||||||
getSample("P\r"),
|
getSample("P\r"),
|
||||||
|
getDeviceId("I\r"),
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.example.hpostesting.data.constant
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
|
object LanguageManager {
|
||||||
|
private const val LANGUAGE_PREF_KEY = "language_pref"
|
||||||
|
|
||||||
|
fun setLocale(context: Context, languageCode: String) {
|
||||||
|
val locale = Locale(languageCode)
|
||||||
|
Locale.setDefault(locale)
|
||||||
|
|
||||||
|
val resources = context.resources
|
||||||
|
val configuration = resources.configuration
|
||||||
|
configuration.setLocale(locale)
|
||||||
|
|
||||||
|
context.createConfigurationContext(configuration)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun persistLanguagePreference(context: Context, languageCode: String) {
|
||||||
|
val prefs: SharedPreferences = context.getSharedPreferences("AppPrefs", Context.MODE_PRIVATE)
|
||||||
|
prefs.edit().putString(LANGUAGE_PREF_KEY, languageCode).apply()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSavedLanguage(context: Context): String {
|
||||||
|
val prefs: SharedPreferences = context.getSharedPreferences("AppPrefs", Context.MODE_PRIVATE)
|
||||||
|
return prefs.getString(LANGUAGE_PREF_KEY, "en") ?: "en"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,15 +9,18 @@ import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
|||||||
import com.example.hpostesting.data.model.patient.UserData
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
@Dao
|
@Dao
|
||||||
interface HemoCubeDao {
|
interface HemoCubeDao {
|
||||||
@Query("SELECT * from HemocubeTest_table")
|
@Query("SELECT * from hemo_cube_test_table")
|
||||||
fun getAll(): LiveData<List<HemoCubeTestData>>
|
fun getAll(): LiveData<List<HemoCubeTestData>>
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
suspend fun insertAll(hemoCubeTestData: HemoCubeTestData)
|
suspend fun insertAll(hemoCubeTestData: HemoCubeTestData)
|
||||||
|
|
||||||
@Query("SELECT * FROM hemocubetest_table WHERE _id = :id")
|
@Query("SELECT * FROM hemo_cube_test_table WHERE _id = :id")
|
||||||
suspend fun getUserByID(id: String): HemoCubeTestData
|
suspend fun getUserByID(id: String): HemoCubeTestData
|
||||||
|
|
||||||
@Query("DELETE FROM hemocubetest_table WHERE _id = :id")
|
@Query("DELETE FROM hemo_cube_test_table WHERE _id = :id")
|
||||||
suspend fun deleteById(id: String)
|
suspend fun deleteById(id: String)
|
||||||
|
|
||||||
|
@Query("UPDATE hemo_cube_test_table SET localFlag = :newValue WHERE _id = :id")
|
||||||
|
suspend fun updateFieldById(id: String, newValue: Boolean)
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
|||||||
import com.google.android.datatransport.runtime.dagger.Provides
|
import com.google.android.datatransport.runtime.dagger.Provides
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Database(entities = [UserData::class, HemoCubeTestData::class, DeviceData::class], version = 3, exportSchema = false)
|
@Database(entities = [UserData::class, HemoCubeTestData::class, DeviceData::class], version = 14, exportSchema = false)
|
||||||
@TypeConverters(Converters::class)
|
@TypeConverters(Converters::class)
|
||||||
abstract class MyDatabase : RoomDatabase() {
|
abstract class MyDatabase : RoomDatabase() {
|
||||||
abstract fun userDao(): UserDao
|
abstract fun userDao(): UserDao
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.example.hpostesting.data.model.deviceprovision
|
||||||
|
|
||||||
|
data class Credentials(
|
||||||
|
val password: String? = "",
|
||||||
|
val username: String? = ""
|
||||||
|
)
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.example.hpostesting.data.model.deviceprovision
|
||||||
|
|
||||||
|
data class Device(
|
||||||
|
val assigned: Boolean? = false,
|
||||||
|
val createdAt: String? = "",
|
||||||
|
val createdBy: Int? = 0,
|
||||||
|
val deviceType: DeviceType? = DeviceType(),
|
||||||
|
val deviceTypeId: Int? = 0,
|
||||||
|
val deviceUser: DeviceUser? = DeviceUser(),
|
||||||
|
val enabled: Boolean? = false,
|
||||||
|
val id: Int? = 0,
|
||||||
|
val name: String? = "",
|
||||||
|
val serialNumber: String? = "",
|
||||||
|
val uid: String? = "",
|
||||||
|
val updatedAt: String? = "",
|
||||||
|
val updatedBy: Int? = 0
|
||||||
|
)
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.example.hpostesting.data.model.deviceprovision
|
||||||
|
|
||||||
|
data class DeviceProvisionData(
|
||||||
|
val credentials: Credentials? = Credentials(),
|
||||||
|
val device: Device? = Device()
|
||||||
|
)
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.example.hpostesting.data.model.deviceprovision
|
||||||
|
|
||||||
|
data class DeviceProvisionRequest(
|
||||||
|
val deviceTypeName: String? = "",
|
||||||
|
val email: String? = "",
|
||||||
|
val password: String? = "",
|
||||||
|
val serialNumber: String? = "",
|
||||||
|
val uid: String? = ""
|
||||||
|
)
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.example.hpostesting.data.model.deviceprovision
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
|
data class DeviceProvisionResponse(
|
||||||
|
@SerializedName("Data")
|
||||||
|
val data: DeviceProvisionData? = DeviceProvisionData(),
|
||||||
|
@SerializedName("Message")
|
||||||
|
val message: String? = "",
|
||||||
|
@SerializedName("Result")
|
||||||
|
val result: String? = ""
|
||||||
|
)
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.example.hpostesting.data.model.deviceprovision
|
||||||
|
|
||||||
|
data class DeviceType(
|
||||||
|
val createdAt: String? = "",
|
||||||
|
val createdBy: Int? = 0,
|
||||||
|
val description: String? = "",
|
||||||
|
val enabled: Boolean? = false,
|
||||||
|
val id: Int? = 0,
|
||||||
|
val name: String? = "",
|
||||||
|
val updatedAt: String? = "",
|
||||||
|
val updatedBy: Int? = 0
|
||||||
|
)
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.example.hpostesting.data.model.deviceprovision
|
||||||
|
|
||||||
|
data class DeviceUser(
|
||||||
|
val createdAt: String? = "",
|
||||||
|
val createdBy: Int? = 0,
|
||||||
|
val deviceId: Int? = 0,
|
||||||
|
val enabled: Boolean? = false,
|
||||||
|
val id: Int? = 0,
|
||||||
|
val lastLogin: Any? = Any(),
|
||||||
|
val natsToken: String? = "",
|
||||||
|
val natsTokenExpiry: String? = "",
|
||||||
|
val updatedAt: String? = "",
|
||||||
|
val updatedBy: Int? = 0,
|
||||||
|
val username: String? = ""
|
||||||
|
)
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.example.hpostesting.data.model.diagnostics
|
||||||
|
|
||||||
|
data class DiagnosticsData (
|
||||||
|
var deviceId: String = "",
|
||||||
|
var appVersion: String? = "",
|
||||||
|
var deviceType: String = "HEMOCUBE",
|
||||||
|
var deviceData: String = "",
|
||||||
|
var runTime: String = ""
|
||||||
|
)
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.example.hpostesting.data.model.log
|
||||||
|
|
||||||
|
data class UploadLogsData(
|
||||||
|
val filename: String? = ""
|
||||||
|
)
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.example.hpostesting.data.model.log
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
|
data class UploadLogsResponse(
|
||||||
|
@SerializedName("Data")
|
||||||
|
val data: UploadLogsData? = UploadLogsData(),
|
||||||
|
@SerializedName("Message")
|
||||||
|
val message: String? = "",
|
||||||
|
@SerializedName("Result")
|
||||||
|
val result: String? = ""
|
||||||
|
)
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.example.hpostesting.data.model.login
|
||||||
|
|
||||||
|
data class Device(
|
||||||
|
val assigned: Boolean? = false,
|
||||||
|
val createdAt: String? = "",
|
||||||
|
val createdBy: Int? = 0,
|
||||||
|
val deviceType: DeviceType? = DeviceType(),
|
||||||
|
val deviceTypeId: Int? = 0,
|
||||||
|
val enabled: Boolean? = false,
|
||||||
|
val id: Int? = 0,
|
||||||
|
val name: String? = "",
|
||||||
|
val serialNumber: String? = "",
|
||||||
|
val uid: String? = "",
|
||||||
|
val updatedAt: String? = "",
|
||||||
|
val updatedBy: Int? = 0
|
||||||
|
)
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.example.hpostesting.data.model.login
|
||||||
|
|
||||||
|
data class DeviceType(
|
||||||
|
val createdAt: String? = "",
|
||||||
|
val createdBy: Int? = 0,
|
||||||
|
val description: String? = "",
|
||||||
|
val enabled: Boolean? = false,
|
||||||
|
val id: Int? = 0,
|
||||||
|
val name: String? = "",
|
||||||
|
val updatedAt: String? = "",
|
||||||
|
val updatedBy: Int? = 0
|
||||||
|
)
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.example.hpostesting.data.model.login
|
||||||
|
|
||||||
|
data class DeviceUser(
|
||||||
|
val createdAt: String? = "",
|
||||||
|
val createdBy: Int? = 0,
|
||||||
|
val device: Device? = Device(),
|
||||||
|
val deviceId: Int? = 0,
|
||||||
|
val enabled: Boolean? = false,
|
||||||
|
val id: Int? = 0,
|
||||||
|
val lastLogin: String? = "",
|
||||||
|
val natsToken: String? = "",
|
||||||
|
val natsTokenExpiry: String? = "",
|
||||||
|
val updatedAt: String? = "",
|
||||||
|
val updatedBy: Int? = 0,
|
||||||
|
val username: String? = ""
|
||||||
|
)
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package com.example.hpostesting.data.model.login
|
||||||
|
|
||||||
|
data class LoginData(
|
||||||
|
val accessToken: String? = "",
|
||||||
|
val deviceUser: DeviceUser? = DeviceUser()
|
||||||
|
)
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.example.hpostesting.data.model.login
|
||||||
|
|
||||||
|
data class LoginRequest(
|
||||||
|
val lab: String? = "",
|
||||||
|
val latitude: String? = "",
|
||||||
|
val location: String? = "",
|
||||||
|
val longitude: String? = "",
|
||||||
|
val mode: String? = "",
|
||||||
|
val password: String? = "",
|
||||||
|
val serialNumber: String? = "",
|
||||||
|
val username: String? = "",
|
||||||
|
val version: String? = "2.1.26"
|
||||||
|
)
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.example.hpostesting.data.model.login
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
|
data class LoginResponse(
|
||||||
|
@SerializedName("Data")
|
||||||
|
val data: LoginData? = LoginData(),
|
||||||
|
@SerializedName("Message")
|
||||||
|
val message: String? = "",
|
||||||
|
@SerializedName("Result")
|
||||||
|
val result: String? = ""
|
||||||
|
)
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.example.hpostesting.data.model.molbioresult
|
||||||
|
|
||||||
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
|
|
||||||
|
data class MolbioV2Result(
|
||||||
|
val age: Int? = 0,
|
||||||
|
val analysisDate: String? = "",
|
||||||
|
val analysisId: String? = "",
|
||||||
|
val analysisStatus: String? = "",
|
||||||
|
val analysisType: String? = "",
|
||||||
|
val analysisTypeMethod: String? = "",
|
||||||
|
val bloodGroup: String? = "",
|
||||||
|
val coefficients: List<Int>? = listOf(),
|
||||||
|
val collectionLocation: List<Any>? = listOf(),
|
||||||
|
val collectionTime: String? = "",
|
||||||
|
val collector: String? = "",
|
||||||
|
val curveFitting: String? = "",
|
||||||
|
val deviceName: String? = "",
|
||||||
|
val expiryTime: String? = "",
|
||||||
|
val gender: String? = "",
|
||||||
|
val interpretation: String? = "",
|
||||||
|
val `operator`: String? = "",
|
||||||
|
val patientId: Int? = 0,
|
||||||
|
val pregnancy: Boolean? = false,
|
||||||
|
val rawData: HemoCubeTestData? = HemoCubeTestData(),
|
||||||
|
val recommendation: String? = "",
|
||||||
|
val sampleId: String? = "",
|
||||||
|
val sampleType: String? = "",
|
||||||
|
val sickleCellHistory: Boolean? = false,
|
||||||
|
val testId: String? = "",
|
||||||
|
val testResult: String? = "",
|
||||||
|
val testStatus: String? = "",
|
||||||
|
val testTime: String? = "",
|
||||||
|
val testType: String? = "",
|
||||||
|
val thresholds: String? = "",
|
||||||
|
val underMedication: Boolean? = false,
|
||||||
|
val volume: Int? = 0
|
||||||
|
)
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.example.hpostesting.data.model.molbioresult
|
||||||
|
|
||||||
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
|
|
||||||
|
data class MolbioV2ResultData(
|
||||||
|
val age: Int? = 0,
|
||||||
|
val analysisDate: String? = "",
|
||||||
|
val analysisStatus: String? = "",
|
||||||
|
val analysisType: String? = "",
|
||||||
|
val analysisTypeMethod: String? = "",
|
||||||
|
val bloodGroup: String? = "",
|
||||||
|
val coefficients: List<Int>? = listOf(),
|
||||||
|
val collectionLocation: List<Any>? = listOf(),
|
||||||
|
val collectionTime: String? = "",
|
||||||
|
val collector: String? = "",
|
||||||
|
val createdAt: String? = "",
|
||||||
|
val createdBy: Int? = 0,
|
||||||
|
val curveFitting: String? = "",
|
||||||
|
val deviceId: Int? = 0,
|
||||||
|
val expiryTime: String? = "",
|
||||||
|
val gender: String? = "",
|
||||||
|
val id: Int? = 0,
|
||||||
|
val interpretation: String? = "",
|
||||||
|
val `operator`: String? = "",
|
||||||
|
val patientId: Int? = 0,
|
||||||
|
val pregnancy: Boolean? = false,
|
||||||
|
val rawData: HemoCubeTestData? = HemoCubeTestData(),
|
||||||
|
val recommendation: String? = "",
|
||||||
|
val sampleId: String? = "",
|
||||||
|
val sampleType: String? = "",
|
||||||
|
val sickleCellHistory: Boolean? = false,
|
||||||
|
val testId: String? = "",
|
||||||
|
val testResult: String? = "",
|
||||||
|
val testStatus: String? = "",
|
||||||
|
val testTime: String? = "",
|
||||||
|
val testType: String? = "",
|
||||||
|
val thresholds: String? = "",
|
||||||
|
val underMedication: Boolean? = false,
|
||||||
|
val updatedAt: String? = "",
|
||||||
|
val updatedBy: Int? = 0,
|
||||||
|
val volume: Int? = 0
|
||||||
|
)
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.example.hpostesting.data.model.molbioresult
|
||||||
|
|
||||||
|
data class MolbioV2ResultRequest(
|
||||||
|
val results: List<MolbioV2Result>? = listOf()
|
||||||
|
)
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.example.hpostesting.data.model.molbioresult
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
|
data class MolbioV2ResultResponse(
|
||||||
|
@SerializedName("Data")
|
||||||
|
val data: List<MolbioV2ResultData>? = listOf(),
|
||||||
|
@SerializedName("Message")
|
||||||
|
val message: String? = "",
|
||||||
|
@SerializedName("Result")
|
||||||
|
val result: String? = ""
|
||||||
|
)
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.example.hpostesting.data.model.molbioresult
|
||||||
|
|
||||||
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
|
|
||||||
|
data class RawData(
|
||||||
|
var _id: String = "",
|
||||||
|
var name: String = "",
|
||||||
|
var incubationTime: String = "",
|
||||||
|
var bloodGroup: String = "",
|
||||||
|
var birthYear: String = "",
|
||||||
|
var state: String = "",
|
||||||
|
var abhaId: String = "",
|
||||||
|
var userImageURL: String = "",
|
||||||
|
var location: UserData.Location? = null,
|
||||||
|
var reportUploadTime: String? = "",
|
||||||
|
var testType: String? = "HEMOCUBE",
|
||||||
|
var testTime: String? = "",
|
||||||
|
var testStatus: Boolean? = false,
|
||||||
|
var gender: String = "",
|
||||||
|
var localFlag: Boolean = false,
|
||||||
|
var deviceId: String? = "",
|
||||||
|
var appVersion:String? = "",
|
||||||
|
var deviceSerialNumber: String = "",
|
||||||
|
var deviceType: String = "HEMOCUBE",
|
||||||
|
var kitSerial: String = "",
|
||||||
|
var resultData: String = "",
|
||||||
|
var led1Buffer: Double? = null,
|
||||||
|
var led2Buffer: Double? = null,
|
||||||
|
var led3Buffer: Double? = null,
|
||||||
|
var led4Buffer: Double? = null,
|
||||||
|
var led1Sample: Double? = null,
|
||||||
|
var led2Sample: Double? = null,
|
||||||
|
var led3Sample: Double? = null,
|
||||||
|
var led4Sample: Double? = null,
|
||||||
|
var led1Average: Double? = null,
|
||||||
|
var led2Average: Double? = null,
|
||||||
|
var led3Average: Double? = null,
|
||||||
|
var led4Average: Double? = null,
|
||||||
|
var abs1: Double? = null,
|
||||||
|
var abs2: Double? = null,
|
||||||
|
var abs3: Double? = null,
|
||||||
|
var abs4: Double? = null,
|
||||||
|
var deviceRatio: Double? = null,
|
||||||
|
var calculatedRatio: Double? = null,
|
||||||
|
var predictedDenovixRatio: Double? = null,
|
||||||
|
var coefficients: String? = "",
|
||||||
|
var classificationResult: String = "",
|
||||||
|
var prdClassification: String = "",
|
||||||
|
var errorMessages: String = "",
|
||||||
|
var batteryLevel: String = "",
|
||||||
|
var batteryCapacity: String = "",
|
||||||
|
var batteryMaxCapacity: String = "",
|
||||||
|
var batteryTemperature: String = "",
|
||||||
|
var batteryVoltage: String = "",
|
||||||
|
)
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.example.hpostesting.data.model.patient
|
||||||
|
|
||||||
|
data class BufferCheckData(
|
||||||
|
var kitno: String = "",
|
||||||
|
var deviceId: String? = "",
|
||||||
|
var appVersion:String? = "",
|
||||||
|
var deviceSerialNumber: String = "",
|
||||||
|
var deviceType: String = "HEMOCUBE",
|
||||||
|
var resultData: String = "",
|
||||||
|
var led1Buffer: Double? = null,
|
||||||
|
var led2Buffer: Double? = null,
|
||||||
|
var led1Sample: Double? = null,
|
||||||
|
var led2Sample: Double? = null,
|
||||||
|
var led1Average: Double? = null,
|
||||||
|
var led2Average: Double? = null,
|
||||||
|
var deviceRatio: Double? = null,
|
||||||
|
var calculatedRatio: Double? = null,
|
||||||
|
var coefficients: String? = "",
|
||||||
|
var classificationResult: String = "",
|
||||||
|
var testTime: String = ""
|
||||||
|
)
|
||||||
@@ -3,18 +3,23 @@ package com.example.hpostesting.data.model.patient
|
|||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
import androidx.room.PrimaryKey
|
import androidx.room.PrimaryKey
|
||||||
|
|
||||||
@Entity(tableName = "HemocubeTest_table")
|
@Entity(tableName = "hemo_cube_test_table")
|
||||||
data class HemoCubeTestData(
|
data class HemoCubeTestData(
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
var _id: String = "",
|
var _id: String = "",
|
||||||
var name: String = "",
|
var name: String = "",
|
||||||
|
var incubationTime: String = "",
|
||||||
|
var bloodGroup: String = "",
|
||||||
var birthYear: String = "",
|
var birthYear: String = "",
|
||||||
|
var state: String = "",
|
||||||
|
var abhaId: String = "",
|
||||||
var userImageURL: String = "",
|
var userImageURL: String = "",
|
||||||
var location: UserData.Location? = null,
|
var location: UserData.Location? = null,
|
||||||
var reportUploadTime: String? = "",
|
var reportUploadTime: String? = "",
|
||||||
var testType: String? = "HEMOCUBE",
|
var testType: String? = "HEMOCUBE",
|
||||||
var testTime: String? = "",
|
var testTime: String? = "",
|
||||||
var testStatus: Boolean? = false,
|
var testStatus: Boolean? = false,
|
||||||
|
var gender: String = "",
|
||||||
var localFlag: Boolean = false,
|
var localFlag: Boolean = false,
|
||||||
var deviceId: String? = "",
|
var deviceId: String? = "",
|
||||||
var appVersion:String? = "",
|
var appVersion:String? = "",
|
||||||
@@ -24,10 +29,31 @@ data class HemoCubeTestData(
|
|||||||
var resultData: String = "",
|
var resultData: String = "",
|
||||||
var led1Buffer: Double? = null,
|
var led1Buffer: Double? = null,
|
||||||
var led2Buffer: Double? = null,
|
var led2Buffer: Double? = null,
|
||||||
|
var led3Buffer: Double? = null,
|
||||||
|
var led4Buffer: Double? = null,
|
||||||
var led1Sample: Double? = null,
|
var led1Sample: Double? = null,
|
||||||
var led2Sample: Double? = null,
|
var led2Sample: Double? = null,
|
||||||
|
var led3Sample: Double? = null,
|
||||||
|
var led4Sample: Double? = null,
|
||||||
var led1Average: Double? = null,
|
var led1Average: Double? = null,
|
||||||
var led2Average: Double? = null,
|
var led2Average: Double? = null,
|
||||||
|
var led3Average: Double? = null,
|
||||||
|
var led4Average: Double? = null,
|
||||||
|
var abs1: Double? = null,
|
||||||
|
var abs2: Double? = null,
|
||||||
|
var abs3: Double? = null,
|
||||||
|
var abs4: Double? = null,
|
||||||
var deviceRatio: Double? = null,
|
var deviceRatio: Double? = null,
|
||||||
var calculatedRatio: Double? = null
|
var calculatedRatio: Double? = null,
|
||||||
|
var predictedDenovixRatio: Double? = null,
|
||||||
|
var coefficients: String? = "",
|
||||||
|
var classificationResult: String = "",
|
||||||
|
var prdClassification: String = "",
|
||||||
|
var errorMessages: String = "",
|
||||||
|
var batteryLevel: String = "",
|
||||||
|
var batteryCapacity: String = "",
|
||||||
|
var batteryMaxCapacity: String = "",
|
||||||
|
var batteryTemperature: String = "",
|
||||||
|
var batteryVoltage: String = "",
|
||||||
|
var molbioFlag: Boolean = false
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,8 +9,12 @@ data class UserData(
|
|||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
var _id: String = "",
|
var _id: String = "",
|
||||||
var name: String = "",
|
var name: String = "",
|
||||||
|
var incubationTime: String = "",
|
||||||
var birthYear: String = "",
|
var birthYear: String = "",
|
||||||
|
var abhaId: String = "",
|
||||||
|
var bloodGroup: String = "",
|
||||||
var userImageURL: String = "",
|
var userImageURL: String = "",
|
||||||
|
var gender: String ="",
|
||||||
var location: Location? = null,
|
var location: Location? = null,
|
||||||
var createdBy: String? = "",
|
var createdBy: String? = "",
|
||||||
var reportUploadTime: String? = "",
|
var reportUploadTime: String? = "",
|
||||||
@@ -18,12 +22,14 @@ data class UserData(
|
|||||||
var testStatus: Boolean? = false,
|
var testStatus: Boolean? = false,
|
||||||
var mobileId: String = "",
|
var mobileId: String = "",
|
||||||
var deviceId: String = "",
|
var deviceId: String = "",
|
||||||
|
var state: String = "",
|
||||||
var deviceSerialNumber: String = "",
|
var deviceSerialNumber: String = "",
|
||||||
var kitSerial: String = "",
|
var kitSerial: String = "",
|
||||||
var csvPath: String = "",
|
var csvPath: String = "",
|
||||||
var reportPath: String = "",
|
var reportPath: String = "",
|
||||||
var result: TestRightResultType? = null,
|
var result: TestRightResultType? = null,
|
||||||
var resultRatio: Double? = null
|
var resultRatio: Double? = null,
|
||||||
|
var prdClassification: String = ""
|
||||||
) {
|
) {
|
||||||
enum class Gender {
|
enum class Gender {
|
||||||
MALE,
|
MALE,
|
||||||
@@ -43,5 +49,11 @@ fun UserData.toHemoCubeTestData() = HemoCubeTestData(
|
|||||||
birthYear = birthYear,
|
birthYear = birthYear,
|
||||||
userImageURL = userImageURL,
|
userImageURL = userImageURL,
|
||||||
testStatus = testStatus,
|
testStatus = testStatus,
|
||||||
location = location
|
location = location,
|
||||||
|
gender = gender,
|
||||||
|
state = state,
|
||||||
|
abhaId = abhaId,
|
||||||
|
bloodGroup = bloodGroup,
|
||||||
|
prdClassification = prdClassification,
|
||||||
|
testTime = testTime
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
package com.example.hpostesting.data.model.test
|
|
||||||
|
|
||||||
import com.example.hpostesting.data.model.Location
|
|
||||||
import java.util.Date
|
|
||||||
|
|
||||||
data class TestDetails(
|
|
||||||
val testID: String,
|
|
||||||
var testStatus: Status,
|
|
||||||
val patientID: String,
|
|
||||||
val patientName: String,
|
|
||||||
val patientAge: Int?,
|
|
||||||
|
|
||||||
var resultRatio: Double?,
|
|
||||||
var result: TestRightResultType?,
|
|
||||||
|
|
||||||
val reportPath: String?,
|
|
||||||
val csvPath: String?,
|
|
||||||
val logPath: String?,
|
|
||||||
|
|
||||||
// Meta Data
|
|
||||||
var deviceId: String?,
|
|
||||||
val mobileId: String,
|
|
||||||
var kitSerial: String?,
|
|
||||||
val location: Location?,
|
|
||||||
val appVersion: String,
|
|
||||||
|
|
||||||
val registeredTime: Date?,
|
|
||||||
var uploadTime: Date?
|
|
||||||
) {
|
|
||||||
constructor() : this(
|
|
||||||
"",
|
|
||||||
Status.PENDING,
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
"",
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
"",
|
|
||||||
null,
|
|
||||||
null
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class Status {
|
|
||||||
COMPLETED,
|
|
||||||
PENDING,
|
|
||||||
INPROGRESS
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package com.example.hpostesting.data.model.test
|
|
||||||
|
|
||||||
data class TestInfo(
|
|
||||||
val value: String,
|
|
||||||
val number1: String,
|
|
||||||
val number2: String,
|
|
||||||
val result: String,
|
|
||||||
val resultConfirmatory: String,
|
|
||||||
val directoryPath: String,
|
|
||||||
val fullPath: String
|
|
||||||
)
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.example.hpostesting.data.model.updates
|
||||||
|
|
||||||
|
data class CheckUpdateData(
|
||||||
|
val version: String? = ""
|
||||||
|
)
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.example.hpostesting.data.model.updates
|
||||||
|
|
||||||
|
data class CheckUpdateRequest(
|
||||||
|
val currentVersion: String? = ""
|
||||||
|
)
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.example.hpostesting.data.model.updates
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
|
data class CheckUpdateResponse(
|
||||||
|
@SerializedName("Data")
|
||||||
|
val data: CheckUpdateData? = CheckUpdateData(),
|
||||||
|
@SerializedName("Message")
|
||||||
|
val message: String? = "",
|
||||||
|
@SerializedName("Result")
|
||||||
|
val result: String? = ""
|
||||||
|
)
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package com.example.hpostesting.data.model.updates
|
||||||
|
|
||||||
|
data class DeviceUpdateRequest(
|
||||||
|
val serial_no: String? = ""
|
||||||
|
)
|
||||||
@@ -1,75 +1,150 @@
|
|||||||
package com.example.hpostesting.data.repository
|
package com.example.hpostesting.data.repository
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import androidx.room.Room
|
import com.example.hpostesting.data.Result
|
||||||
import com.example.hpostesting.data.dao.MyDatabase
|
import com.example.hpostesting.data.api.MolbioAuthApi
|
||||||
|
import com.example.hpostesting.data.api.MolbioResultApi
|
||||||
import com.example.hpostesting.data.model.PendingUploads
|
import com.example.hpostesting.data.model.PendingUploads
|
||||||
import com.example.hpostesting.data.model.Response
|
import com.example.hpostesting.data.model.Response
|
||||||
|
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
||||||
|
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionResponse
|
||||||
|
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
||||||
|
import com.example.hpostesting.data.model.log.UploadLogsResponse
|
||||||
|
import com.example.hpostesting.data.model.login.LoginRequest
|
||||||
|
import com.example.hpostesting.data.model.login.LoginResponse
|
||||||
|
import com.example.hpostesting.data.model.molbioresult.MolbioV2ResultRequest
|
||||||
|
import com.example.hpostesting.data.model.molbioresult.MolbioV2ResultResponse
|
||||||
|
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.data.model.patient.HemoCubeTestData
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
import com.google.android.datatransport.runtime.dagger.Provides
|
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
||||||
|
import com.example.hpostesting.data.model.updates.CheckUpdateResponse
|
||||||
|
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
||||||
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
import com.google.firebase.firestore.FirebaseFirestore
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
import com.google.firebase.firestore.ktx.firestore
|
import com.google.firebase.firestore.ktx.firestore
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import com.google.firebase.storage.ktx.storage
|
import com.google.firebase.storage.ktx.storage
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.tasks.await
|
import kotlinx.coroutines.tasks.await
|
||||||
import kotlinx.coroutines.withContext
|
import okhttp3.MultipartBody
|
||||||
|
import okhttp3.ResponseBody
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import javax.inject.Singleton
|
import java.net.ConnectException
|
||||||
|
import java.net.SocketTimeoutException
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Named
|
||||||
|
|
||||||
class DatabaseRepository : Repository {
|
class NetworkException(message: String, cause: Throwable) : Exception(message, cause)
|
||||||
|
class DatabaseRepository @Inject constructor(
|
||||||
|
@Named("Auth")private val molbioAuthApi: MolbioAuthApi,
|
||||||
|
private val molbioResultApi: MolbioResultApi
|
||||||
|
) : Repository {
|
||||||
|
|
||||||
private val db: FirebaseFirestore = Firebase.firestore
|
private val db: FirebaseFirestore = Firebase.firestore
|
||||||
private val storage = Firebase.storage
|
private val storage = Firebase.storage
|
||||||
|
|
||||||
suspend fun addTestToDatabase(data: HemoCubeTestData?): Response<String> {
|
private suspend fun <T : Any> safeApiCall(apiCall: suspend () -> T): Result<T> {
|
||||||
return try {
|
return try {
|
||||||
val userdata = db.collection("patientData").whereEqualTo("_id", data!!._id).get().await()
|
val response = apiCall.invoke()
|
||||||
|
Result.Success(response)
|
||||||
|
} catch (e: SocketTimeoutException) {
|
||||||
|
Result.Error(NetworkException("Network timeout", e))
|
||||||
|
} catch (e: ConnectException) {
|
||||||
|
Result.Error(NetworkException("Network connection failed", e))
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Result.Error(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun deviceProvision(deviceProvisionRequest: DeviceProvisionRequest): Result<DeviceProvisionResponse> {
|
||||||
|
return safeApiCall { molbioAuthApi.deviceProvision(deviceProvisionRequest) }
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun login(loginRequest: LoginRequest): Result<LoginResponse> {
|
||||||
|
return safeApiCall { molbioAuthApi.login(loginRequest) }
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun uploadResults(molbioV2ResultRequest: MolbioV2ResultRequest): Result<MolbioV2ResultResponse> {
|
||||||
|
return safeApiCall { molbioResultApi.uploadResults(molbioV2ResultRequest) }
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun checkUpdate(checkUpdateRequest: CheckUpdateRequest): Result<CheckUpdateResponse> {
|
||||||
|
return safeApiCall { molbioResultApi.checkUpdate(checkUpdateRequest) }
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun deviceUpdate(deviceUpdateRequest: DeviceUpdateRequest): Result<ResponseBody> {
|
||||||
|
return safeApiCall { molbioResultApi.deviceUpdate(deviceUpdateRequest) }
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun uploadLogs(logFile: MultipartBody.Part): Result<UploadLogsResponse> {
|
||||||
|
return safeApiCall { molbioResultApi.uploadLogs(logFile) }
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun addTestToDatabase(data: HemoCubeTestData?): Response<String> {
|
||||||
|
return try {
|
||||||
|
val userdata =
|
||||||
|
db.collection("patientData").whereEqualTo("_id", data!!._id).get().await()
|
||||||
if (userdata.documents.isNotEmpty()) {
|
if (userdata.documents.isNotEmpty()) {
|
||||||
userdata.documents.forEach {
|
userdata.documents.forEach {
|
||||||
db.collection("patientData").document(it.id).update("testStatus", true)
|
db.collection("patientData").document(it.id).update("testStatus", true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
db.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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun addTestToDatabase(data: UserData?): Response<String> {
|
||||||
suspend fun addTestToDatabase(data: UserData?): Response<String> {
|
|
||||||
return try {
|
return try {
|
||||||
val userdata = db.collection("patientData").whereEqualTo("_id", data!!._id).get().await()
|
val userdata =
|
||||||
|
db.collection("patientData").whereEqualTo("_id", data!!._id).get().await()
|
||||||
if (userdata.documents.isNotEmpty()) {
|
if (userdata.documents.isNotEmpty()) {
|
||||||
userdata.documents.forEach {
|
userdata.documents.forEach {
|
||||||
db.collection("patientData").document(it.id).update("testStatus", true)
|
db.collection("patientData").document(it.id).update("testStatus", true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
db.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)
|
||||||
Response.Error(e)
|
Response.Error(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun addTestToDatabaseforBufferCheck(data: BufferCheckData?): Response<String> {
|
||||||
|
return try {
|
||||||
|
db.collection("buffers").add(data!!).await()
|
||||||
|
Response.Success(data.kitno)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Firebase.crashlytics.recordException(e)
|
||||||
|
Response.Error(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun addDiagnostics(data: DiagnosticsData?): Response<String> {
|
||||||
|
return try {
|
||||||
|
db.collection("diagnostics").add(data!!).await()
|
||||||
|
Response.Success(data.deviceId)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Firebase.crashlytics.recordException(e)
|
||||||
|
Response.Error(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun uploadFileToStorage(
|
||||||
|
patientID: String, filePath: String
|
||||||
suspend fun uploadFileToStorage(patientID: String, filePath: String): Response<Boolean> {
|
): Response<Boolean> {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
val file = Uri.fromFile(File(filePath))
|
val file = Uri.fromFile(File(filePath))
|
||||||
val riversRef = storage.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) {
|
||||||
e.printStackTrace()
|
Firebase.crashlytics.recordException(e)
|
||||||
return Response.Error(e)
|
return Response.Error(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,7 +156,7 @@ class DatabaseRepository : Repository {
|
|||||||
|
|
||||||
Response.Success(true)
|
Response.Success(true)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
Firebase.crashlytics.recordException(e)
|
||||||
Response.Error(e)
|
Response.Error(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,7 +175,7 @@ class DatabaseRepository : Repository {
|
|||||||
pendingList
|
pendingList
|
||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
Firebase.crashlytics.recordException(e)
|
||||||
pendingList
|
pendingList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,7 +186,7 @@ class DatabaseRepository : Repository {
|
|||||||
|
|
||||||
Response.Success(true)
|
Response.Success(true)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
Firebase.crashlytics.recordException(e)
|
||||||
Response.Error(e)
|
Response.Error(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,15 +195,11 @@ class DatabaseRepository : Repository {
|
|||||||
return db.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? {
|
||||||
suspend fun getDeviceDataById(deviceId: String): DeviceData? {
|
|
||||||
val querySnapshot = db.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
|
||||||
return allDeviceDataList.find { it.deviceId == deviceId }
|
return allDeviceDataList.find { it.deviceId == deviceId }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,22 @@
|
|||||||
package com.example.hpostesting.data.repository
|
package com.example.hpostesting.data.repository
|
||||||
|
|
||||||
|
import com.example.hpostesting.data.model.Response
|
||||||
|
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
||||||
|
import com.example.hpostesting.data.model.patient.BufferCheckData
|
||||||
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
|
|
||||||
interface Repository {
|
interface Repository {
|
||||||
// suspend fun addToDatabase(data: PatientDetails)
|
suspend fun addTestToDatabase(data: HemoCubeTestData?): Response<String>
|
||||||
|
|
||||||
|
suspend fun addTestToDatabase(data: UserData?): Response<String>
|
||||||
|
|
||||||
|
suspend fun addTestToDatabaseforBufferCheck(data: BufferCheckData?): Response<String>
|
||||||
|
|
||||||
|
suspend fun addDiagnostics(data: DiagnosticsData?): Response<String>
|
||||||
|
|
||||||
|
suspend fun uploadFileToStorage(patientID: String, filePath: String): Response<Boolean>
|
||||||
|
|
||||||
|
suspend fun getDeviceDataById(deviceId: String): DeviceData?
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.example.hpostesting.domain
|
||||||
|
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import okhttp3.Interceptor
|
||||||
|
import okhttp3.Response
|
||||||
|
|
||||||
|
class AuthInterceptor(private val sharedPreferences: SharedPreferences) : Interceptor {
|
||||||
|
|
||||||
|
override fun intercept(chain: Interceptor.Chain): Response {
|
||||||
|
var request = chain.request()
|
||||||
|
|
||||||
|
val token = sharedPreferences.getString(Constants.ACCESS_TOKEN, null)
|
||||||
|
|
||||||
|
if (token != null) {
|
||||||
|
request = request.newBuilder()
|
||||||
|
.addHeader("Authorization", "Bearer $token")
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
|
||||||
|
return chain.proceed(request)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.example.hpostesting.domain
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.Log
|
||||||
|
import java.io.File
|
||||||
|
import java.io.FileOutputStream
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
|
class LogFileManager(private val context: Context) {
|
||||||
|
|
||||||
|
fun createLogFile(): File? {
|
||||||
|
val unixTime = System.currentTimeMillis() / 1000L
|
||||||
|
val logFileName = "hpos_$unixTime.log"
|
||||||
|
|
||||||
|
return try {
|
||||||
|
val process = Runtime.getRuntime().exec("logcat -d -v threadtime")
|
||||||
|
val logBuilder = StringBuilder()
|
||||||
|
val input = process.inputStream
|
||||||
|
val bufferedReader = input.bufferedReader()
|
||||||
|
|
||||||
|
bufferedReader.forEachLine { line ->
|
||||||
|
logBuilder.append(line).append("\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
val logContent = logBuilder.toString()
|
||||||
|
|
||||||
|
val file = File(context.filesDir, logFileName)
|
||||||
|
val fileOutputStream = FileOutputStream(file)
|
||||||
|
fileOutputStream.write(logContent.toByteArray())
|
||||||
|
fileOutputStream.close()
|
||||||
|
|
||||||
|
file
|
||||||
|
} catch (e: IOException) {
|
||||||
|
Log.e("LogFileManager", "Error creating log file: ${e.message}")
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,20 +2,34 @@ package com.example.hpostesting.domain.di
|
|||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.content.res.AssetManager
|
||||||
import androidx.room.Room
|
import androidx.room.Room
|
||||||
|
import com.example.hpostesting.data.api.MolbioAuthApi
|
||||||
|
import com.example.hpostesting.data.api.MolbioResultApi
|
||||||
|
import com.example.hpostesting.data.api.PropertyProvider
|
||||||
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
|
||||||
import com.example.hpostesting.data.dao.UserDao
|
import com.example.hpostesting.data.dao.UserDao
|
||||||
import com.example.hpostesting.data.datasource.LocalFileDataSource
|
import com.example.hpostesting.data.datasource.LocalFileDataSource
|
||||||
import com.example.hpostesting.data.repository.DatabaseRepository
|
import com.example.hpostesting.data.repository.DatabaseRepository
|
||||||
import com.example.hpostesting.data.repository.LocalFileRepository
|
import com.example.hpostesting.data.repository.LocalFileRepository
|
||||||
|
import com.example.hpostesting.data.repository.Repository
|
||||||
|
import com.example.hpostesting.domain.AuthInterceptor
|
||||||
|
import com.example.hpostesting.domain.LogFileManager
|
||||||
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.util.PropertyProviderImpl
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import dagger.hilt.InstallIn
|
import dagger.hilt.InstallIn
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
import dagger.hilt.components.SingletonComponent
|
import dagger.hilt.components.SingletonComponent
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import retrofit2.Retrofit
|
||||||
|
import retrofit2.converter.gson.GsonConverterFactory
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
import javax.inject.Named
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
@@ -27,9 +41,7 @@ object AppModule {
|
|||||||
fun provideMyDatabase(@ApplicationContext context: Context): MyDatabase {
|
fun provideMyDatabase(@ApplicationContext context: Context): MyDatabase {
|
||||||
return Room.databaseBuilder(
|
return Room.databaseBuilder(
|
||||||
context, MyDatabase::class.java, "my_database"
|
context, MyDatabase::class.java, "my_database"
|
||||||
)
|
).fallbackToDestructiveMigration().build()
|
||||||
.fallbackToDestructiveMigration()
|
|
||||||
.build()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@@ -66,7 +78,89 @@ object AppModule {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun provideDatabaseRepository(): DatabaseRepository {
|
fun provideDatabaseRepository(
|
||||||
return DatabaseRepository()
|
@Named("Auth") molbioAuthApi: MolbioAuthApi,
|
||||||
|
molbioResultApi: MolbioResultApi
|
||||||
|
): DatabaseRepository {
|
||||||
|
return DatabaseRepository(molbioAuthApi = molbioAuthApi, molbioResultApi = molbioResultApi)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideRepository(
|
||||||
|
@Named("Auth") molbioAuthApi: MolbioAuthApi,
|
||||||
|
molbioResultApi: MolbioResultApi
|
||||||
|
): Repository {
|
||||||
|
return DatabaseRepository(molbioAuthApi, molbioResultApi)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideAssetManager(@ApplicationContext context: Context): AssetManager {
|
||||||
|
return context.assets
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun providePropertyProvider(assetManager: AssetManager): PropertyProvider {
|
||||||
|
return PropertyProviderImpl(assetManager)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideSharedPreferences(@ApplicationContext context: Context): SharedPreferences {
|
||||||
|
return context.getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideAuthInterceptor(sharedPreferences: SharedPreferences): AuthInterceptor {
|
||||||
|
return AuthInterceptor(sharedPreferences)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
@Named("Auth")
|
||||||
|
fun provideAuthOkHttpClient(authInterceptor: AuthInterceptor): OkHttpClient {
|
||||||
|
return OkHttpClient.Builder().addInterceptor(authInterceptor)
|
||||||
|
.connectTimeout(30, TimeUnit.SECONDS).readTimeout(30, TimeUnit.SECONDS).build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideOkHttpClient(): OkHttpClient =
|
||||||
|
OkHttpClient.Builder().connectTimeout(30, TimeUnit.SECONDS)
|
||||||
|
.readTimeout(30, TimeUnit.SECONDS).build()
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideRetrofit(
|
||||||
|
propertyProvider: PropertyProvider,@Named("Auth") client: OkHttpClient
|
||||||
|
): Retrofit {
|
||||||
|
return Retrofit.Builder().baseUrl(propertyProvider.getProperty("BASE_URL")).client(client)
|
||||||
|
.addConverterFactory(GsonConverterFactory.create()).build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
@Named("Auth")
|
||||||
|
fun provideAuthRetrofit(propertyProvider: PropertyProvider, client: OkHttpClient): Retrofit {
|
||||||
|
return Retrofit.Builder().baseUrl(propertyProvider.getProperty("BASE_URL")).client(client)
|
||||||
|
.addConverterFactory(GsonConverterFactory.create()).build()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
@Named("Auth")
|
||||||
|
fun provideAuthApi(@Named("Auth") retrofit: Retrofit): MolbioAuthApi =
|
||||||
|
retrofit.create(MolbioAuthApi::class.java)
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideResultApi(retrofit: Retrofit): MolbioResultApi =
|
||||||
|
retrofit.create(MolbioResultApi::class.java)
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
fun provideLogFileManager(context: Context): LogFileManager = LogFileManager(context)
|
||||||
}
|
}
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
package com.example.hpostesting.presentation
|
|
||||||
|
|
||||||
import android.content.Intent
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import com.example.hpostesting.data.DataHolder
|
|
||||||
import com.example.hpostesting.data.constant.Constants
|
|
||||||
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
|
||||||
import com.example.hpostesting.presentation.testRight.TestRightActivity
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityBloodCollectingMethodBinding
|
|
||||||
|
|
||||||
class BloodCollectingMethodActivity : AppCompatActivity() {
|
|
||||||
|
|
||||||
private lateinit var binding: ActivityBloodCollectingMethodBinding
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
binding = ActivityBloodCollectingMethodBinding.inflate(layoutInflater)
|
|
||||||
setContentView(binding.root)
|
|
||||||
init()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun init() {
|
|
||||||
setSupportActionBar(binding.toolbar)
|
|
||||||
binding.btnGo.setOnClickListener {
|
|
||||||
DataHolder.usbConnected.observe(this) {
|
|
||||||
if (it) {
|
|
||||||
if (binding.venousBloodRadioButton.isChecked) {
|
|
||||||
moveToNext(Constants.VENOUS_BLOOD)
|
|
||||||
} else {
|
|
||||||
moveToNext(Constants.FINGER_PRICK_BLOOD)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Toast.makeText(this, "No Device Connected", Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun moveToNext(bloodCollectingMethod: String) {
|
|
||||||
DataHolder.deviceType.observe(this) { deviceType ->
|
|
||||||
when (deviceType) {
|
|
||||||
Constants.DEVICE_TYPE_HOMOCUBE -> {
|
|
||||||
val intent = Intent(applicationContext, HemocubeActivity::class.java)
|
|
||||||
intent.putExtra(Constants.BLOOD_COLLECTING_METHOD, bloodCollectingMethod)
|
|
||||||
startActivity(intent)
|
|
||||||
}
|
|
||||||
|
|
||||||
Constants.DEVICE_TYPE_TEST_RIGHT -> {
|
|
||||||
val intent = Intent(applicationContext, TestRightActivity::class.java)
|
|
||||||
intent.putExtra(Constants.BLOOD_COLLECTING_METHOD, bloodCollectingMethod)
|
|
||||||
startActivity(intent)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.example.hpostesting.presentation
|
package com.example.hpostesting.presentation
|
||||||
|
|
||||||
|
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
|
||||||
@@ -10,7 +11,10 @@ import android.widget.Toast
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
|
|
||||||
|
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
||||||
|
import com.example.hpostesting.presentation.testRight.TestRightActivity
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||||
import com.journeyapps.barcodescanner.ScanContract
|
import com.journeyapps.barcodescanner.ScanContract
|
||||||
@@ -30,7 +34,7 @@ class KitScanActivity : AppCompatActivity() {
|
|||||||
ScanContract()
|
ScanContract()
|
||||||
) { result: ScanIntentResult ->
|
) { result: ScanIntentResult ->
|
||||||
if (result.contents.isNullOrEmpty()) {
|
if (result.contents.isNullOrEmpty()) {
|
||||||
Toast.makeText(this, "Cancelled: Unable to scan, Try Again!!", Toast.LENGTH_LONG).show()
|
Toast.makeText(this, R.string.cancelled_unable_scan, Toast.LENGTH_LONG).show()
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, result.contents)
|
Log.d(TAG, result.contents)
|
||||||
processScannedData(result.contents)
|
processScannedData(result.contents)
|
||||||
@@ -41,6 +45,12 @@ class KitScanActivity : AppCompatActivity() {
|
|||||||
binding.nameEditText.setText(contents)
|
binding.nameEditText.setText(contents)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun attachBaseContext(newBase: Context?) {
|
||||||
|
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||||
|
LanguageManager.setLocale(newBase, languageCode)
|
||||||
|
super.attachBaseContext(newBase)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
@@ -65,35 +75,36 @@ class KitScanActivity : AppCompatActivity() {
|
|||||||
// putString(Constants.BUFFER_VALUE_2, "")
|
// putString(Constants.BUFFER_VALUE_2, "")
|
||||||
// apply()
|
// apply()
|
||||||
// }
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
if (checkHemoCubeKitData()) {
|
try {
|
||||||
try {
|
if (checkHemoCubeKitData()) {
|
||||||
DataHolder.selectedTest!!.kitSerial =
|
DataHolder.selectedTest!!.kitSerial =
|
||||||
sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
||||||
moveToNext()
|
moveToNext()
|
||||||
} catch (e: NullPointerException) {
|
} else {
|
||||||
// Handle the NullPointerException here
|
// Handle the case when checkHemoCubeKitData() returns false
|
||||||
e.printStackTrace() // You can log the exception for debugging
|
with(sharedPreference.edit()) {
|
||||||
FirebaseCrashlytics.getInstance().recordException(e)
|
putString(Constants.KIT_NUMBER, "")
|
||||||
val errorMessage = "An error occurred: ${e.message}"
|
putInt(Constants.KIT_COUNT, 0)
|
||||||
val rootView = findViewById<View>(android.R.id.content)
|
putString(Constants.BUFFER_VALUE_1, "")
|
||||||
Snackbar.make(rootView, errorMessage, Snackbar.LENGTH_LONG).show()
|
putString(Constants.BUFFER_VALUE_2, "")
|
||||||
// Optionally, show a user-friendly error message to the user
|
apply()
|
||||||
// Toast.makeText(applicationContext, "An error occurred", Toast.LENGTH_SHORT).show()
|
}
|
||||||
}
|
|
||||||
} else {
|
|
||||||
with(sharedPreference.edit()) {
|
|
||||||
putString(Constants.KIT_NUMBER, "")
|
|
||||||
putInt(Constants.KIT_COUNT, 0)
|
|
||||||
putString(Constants.BUFFER_VALUE_1, "")
|
|
||||||
putString(Constants.BUFFER_VALUE_2, "")
|
|
||||||
apply()
|
|
||||||
}
|
}
|
||||||
|
} catch (e: NullPointerException) {
|
||||||
|
// Handle the NullPointerException here
|
||||||
|
e.printStackTrace() // You can log the exception for debugging
|
||||||
|
FirebaseCrashlytics.getInstance().recordException(e)
|
||||||
|
val errorMessage = "An error occurred: ${e.message}"
|
||||||
|
val rootView = findViewById<View>(android.R.id.content)
|
||||||
|
Snackbar.make(rootView, errorMessage, Snackbar.LENGTH_LONG).show()
|
||||||
|
// Optionally, show a user-friendly error message to the user
|
||||||
|
// Toast.makeText(applicationContext, "An error occurred", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.nameEditText.setText("SMI/SC/")
|
binding.nameEditText.setText("SMI/SC/")
|
||||||
|
|
||||||
setSupportActionBar(binding.toolbar)
|
setSupportActionBar(binding.toolbar)
|
||||||
@@ -105,7 +116,42 @@ class KitScanActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
binding.btnGo.setOnClickListener {
|
binding.btnGo.setOnClickListener {
|
||||||
val serialNumber = binding.nameEditText.text.toString().trim()
|
val serialNumber = binding.nameEditText.text.toString().trim()
|
||||||
if (serialNumber.isNotEmpty() && checkDataNotNull() && isSerialValid(serialNumber)) {
|
if (serialNumber.isNotEmpty() && isSerialValid(serialNumber)) {
|
||||||
|
if (DataHolder.selectedTest == null) {
|
||||||
|
with(sharedPreference.edit()) {
|
||||||
|
putString(
|
||||||
|
Constants.KIT_NUMBER, binding.nameEditText.text.toString()
|
||||||
|
)
|
||||||
|
putInt(Constants.KIT_COUNT, 1)
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
Toast.makeText(
|
||||||
|
applicationContext,
|
||||||
|
R.string.kit_updated,
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
|
||||||
|
val i = Intent(applicationContext, DashboardActivity::class.java)
|
||||||
|
startActivity(i)
|
||||||
|
finish()
|
||||||
|
} else {
|
||||||
|
DataHolder.kitSerial = binding.nameEditText.text.toString()
|
||||||
|
DataHolder.selectedTest?.kitSerial = binding.nameEditText.text.toString()
|
||||||
|
with(sharedPreference.edit()) {
|
||||||
|
putString(Constants.KIT_NUMBER, binding.nameEditText.text.toString())
|
||||||
|
putInt(Constants.KIT_COUNT, 1)
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
moveToNext()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Toast.makeText(this, R.string.invalid_kit_number, Toast.LENGTH_LONG).show()
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
|
if (serialNumber.isNotEmpty() && checkDataNotNull() && isSerialValid(
|
||||||
|
serialNumber
|
||||||
|
)
|
||||||
|
) {
|
||||||
DataHolder.kitSerial = binding.nameEditText.text.toString()
|
DataHolder.kitSerial = binding.nameEditText.text.toString()
|
||||||
DataHolder.selectedTest?.kitSerial = binding.nameEditText.text.toString()
|
DataHolder.selectedTest?.kitSerial = binding.nameEditText.text.toString()
|
||||||
with(sharedPreference.edit()) {
|
with(sharedPreference.edit()) {
|
||||||
@@ -115,15 +161,16 @@ class KitScanActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
moveToNext()
|
moveToNext()
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(this, "Invalid KIT Number", Toast.LENGTH_LONG).show()
|
Toast.makeText(this, R.string.invalid_kit_number, Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkHemoCubeKitData(): Boolean {
|
private fun checkHemoCubeKitData(): Boolean {
|
||||||
return sharedPreference.getString(Constants.KIT_NUMBER, "")
|
return sharedPreference.getString(Constants.KIT_NUMBER, "")
|
||||||
?.isNotBlank() == true && sharedPreference.getInt(Constants.KIT_COUNT, 0) > 0
|
?.isNotBlank() == true && sharedPreference.getInt(
|
||||||
&& sharedPreference.getInt(Constants.KIT_COUNT, 0) < 35
|
Constants.KIT_COUNT, 0
|
||||||
|
) > 0 && sharedPreference.getInt(Constants.KIT_COUNT, 0) < 35
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isSerialValid(s: String): Boolean {
|
private fun isSerialValid(s: String): Boolean {
|
||||||
@@ -135,8 +182,20 @@ class KitScanActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun moveToNext() {
|
private fun moveToNext() {
|
||||||
val i = Intent(applicationContext, BloodCollectingMethodActivity::class.java)
|
|
||||||
startActivity(i)
|
DataHolder.deviceType.observe(this) { deviceType ->
|
||||||
|
when (deviceType) {
|
||||||
|
Constants.DEVICE_TYPE_HOMOCUBE -> {
|
||||||
|
val i = Intent(applicationContext, HemocubeActivity::class.java)
|
||||||
|
startActivity(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
Constants.DEVICE_TYPE_TEST_RIGHT -> {
|
||||||
|
val i = Intent(applicationContext, TestRightActivity::class.java)
|
||||||
|
startActivity(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun startScanningNow() {
|
private fun startScanningNow() {
|
||||||
@@ -158,7 +217,7 @@ class KitScanActivity : AppCompatActivity() {
|
|||||||
private fun checkDataNotNull(): Boolean {
|
private fun checkDataNotNull(): Boolean {
|
||||||
return if (DataHolder.selectedTest?._id == null) {
|
return if (DataHolder.selectedTest?._id == null) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
applicationContext, "Please Select patient before starting test", Toast.LENGTH_SHORT
|
applicationContext, R.string.select_patient, Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
|
|
||||||
val i = Intent(applicationContext, DashboardActivity::class.java)
|
val i = Intent(applicationContext, DashboardActivity::class.java)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.example.hpostesting.presentation
|
package com.example.hpostesting.presentation
|
||||||
|
|
||||||
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
import android.content.*
|
import android.content.*
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
@@ -9,8 +10,6 @@ import android.os.Bundle
|
|||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.Button
|
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
@@ -18,6 +17,7 @@ import androidx.core.content.ContextCompat
|
|||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
import com.example.hpostesting.data.model.test.TestType
|
import com.example.hpostesting.data.model.test.TestType
|
||||||
import com.google.android.gms.location.*
|
import com.google.android.gms.location.*
|
||||||
@@ -45,6 +45,12 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun attachBaseContext(newBase: Context?) {
|
||||||
|
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||||
|
LanguageManager.setLocale(newBase, languageCode)
|
||||||
|
super.attachBaseContext(newBase)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||||
@@ -85,17 +91,10 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (DataHolder.selectedTest == null) {
|
||||||
// val crashButton = Button(this)
|
startActivity(Intent(this, DashboardActivity::class.java))
|
||||||
// crashButton.text = "Test Crash"
|
finish()
|
||||||
// crashButton.setOnClickListener {
|
}
|
||||||
// throw RuntimeException("Test Crash") // Force a crash
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// addContentView(crashButton, ViewGroup.LayoutParams(
|
|
||||||
// ViewGroup.LayoutParams.MATCH_PARENT,
|
|
||||||
// ViewGroup.LayoutParams.WRAP_CONTENT))
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkAndUpdateUsbConnection() {
|
private fun checkAndUpdateUsbConnection() {
|
||||||
@@ -105,6 +104,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val deviceType = when {
|
val deviceType = when {
|
||||||
availableDrivers.isNotEmpty() -> {
|
availableDrivers.isNotEmpty() -> {
|
||||||
val device = availableDrivers[0].device
|
val device = availableDrivers[0].device
|
||||||
|
Toast.makeText(this, R.string.device, Toast.LENGTH_SHORT).show()
|
||||||
when {
|
when {
|
||||||
device.productId == Constants.HOMO_CUBE_ID && device.vendorId == Constants.VENDOR_ID -> {
|
device.productId == Constants.HOMO_CUBE_ID && device.vendorId == Constants.VENDOR_ID -> {
|
||||||
binding.cvItem1.visibility = View.VISIBLE
|
binding.cvItem1.visibility = View.VISIBLE
|
||||||
@@ -115,6 +115,15 @@ class MainActivity : AppCompatActivity() {
|
|||||||
Constants.DEVICE_TYPE_HOMOCUBE
|
Constants.DEVICE_TYPE_HOMOCUBE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
device.productId == Constants.HEMO_CUBE_V2_PRODUCT_ID && device.vendorId == Constants.HEMO_CUBE_V2_VENDOR_ID -> {
|
||||||
|
binding.cvItem1.visibility = View.VISIBLE
|
||||||
|
binding.cvItem3.visibility = View.VISIBLE
|
||||||
|
binding.cvItem2.visibility = View.GONE
|
||||||
|
binding.cvItem4.visibility = View.GONE
|
||||||
|
DataHolder.deviceType.postValue(Constants.DEVICE_TYPE_HOMOCUBE)
|
||||||
|
Constants.DEVICE_TYPE_HOMOCUBE
|
||||||
|
}
|
||||||
|
|
||||||
device.productId == Constants.DEVICE_PRODUCT_ID && device.vendorId == Constants.DEVICE_VENDOR_ID -> {
|
device.productId == Constants.DEVICE_PRODUCT_ID && device.vendorId == Constants.DEVICE_VENDOR_ID -> {
|
||||||
Log.d(
|
Log.d(
|
||||||
TAG,
|
TAG,
|
||||||
@@ -144,7 +153,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
Log.d(TAG, "Device NOT Connected")
|
Log.d(TAG, "Device NOT Connected")
|
||||||
Toast.makeText(this, "Device Not Connected", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, R.string.device_not, Toast.LENGTH_SHORT).show()
|
||||||
DataHolder.usbConnected.value = false
|
DataHolder.usbConnected.value = false
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
@@ -161,12 +170,14 @@ class MainActivity : AppCompatActivity() {
|
|||||||
DataHolder.selectedTestType = TestType.SICKLECERT
|
DataHolder.selectedTestType = TestType.SICKLECERT
|
||||||
val i = Intent(applicationContext, KitScanActivity::class.java)
|
val i = Intent(applicationContext, KitScanActivity::class.java)
|
||||||
startActivity(i)
|
startActivity(i)
|
||||||
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.cvItem2.setOnClickListener {
|
binding.cvItem2.setOnClickListener {
|
||||||
DataHolder.selectedTestType = TestType.SICKLEFIND
|
DataHolder.selectedTestType = TestType.SICKLEFIND
|
||||||
val i = Intent(applicationContext, KitScanActivity::class.java)
|
val i = Intent(applicationContext, KitScanActivity::class.java)
|
||||||
startActivity(i)
|
startActivity(i)
|
||||||
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
DataHolder.usbConnected.observe(this) {
|
DataHolder.usbConnected.observe(this) {
|
||||||
@@ -230,7 +241,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
) != PackageManager.PERMISSION_GRANTED
|
) != PackageManager.PERMISSION_GRANTED
|
||||||
) {
|
) {
|
||||||
// Handle location permission request if needed
|
// Handle location permission request if needed
|
||||||
Toast.makeText(this, "Please enable location services", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, R.string.enable_location, Toast.LENGTH_SHORT).show()
|
||||||
requestCoarseLocationPermission()
|
requestCoarseLocationPermission()
|
||||||
requestFineLocationPermission()
|
requestFineLocationPermission()
|
||||||
return
|
return
|
||||||
@@ -250,28 +261,29 @@ class MainActivity : AppCompatActivity() {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
fusedLocationClient.lastLocation.addOnSuccessListener { location: Location? ->
|
||||||
|
location?.let {
|
||||||
fusedLocationClient.lastLocation.addOnSuccessListener { location: Location? ->
|
if (DataHolder.selectedTest != null) {
|
||||||
location?.let {
|
|
||||||
DataHolder.selectedTest!!.location =
|
DataHolder.selectedTest!!.location =
|
||||||
UserData.Location(location.latitude, location.longitude)
|
UserData.Location(location.latitude, location.longitude)
|
||||||
DataHolder.location =
|
} else {
|
||||||
UserData.Location(location.latitude, location.longitude)
|
startActivity(Intent(this, DashboardActivity::class.java))
|
||||||
} ?: run {
|
finish()
|
||||||
requestLocationUpdates()
|
|
||||||
}
|
}
|
||||||
}.addOnFailureListener { exception: Exception ->
|
DataHolder.location =
|
||||||
// Handle the exception here
|
UserData.Location(location.latitude, location.longitude)
|
||||||
exception.printStackTrace()
|
} ?: run {
|
||||||
FirebaseCrashlytics.getInstance().recordException(exception)
|
requestLocationUpdates()
|
||||||
// Display an error message to the user using a Snackbar
|
|
||||||
val errorMessage = "An error occurred: ${exception.message}"
|
|
||||||
val rootView = findViewById<View>(android.R.id.content)
|
|
||||||
Snackbar.make(rootView, errorMessage, Snackbar.LENGTH_LONG).show()
|
|
||||||
}
|
}
|
||||||
|
}.addOnFailureListener { exception: Exception ->
|
||||||
|
// Handle the exception here
|
||||||
|
exception.printStackTrace()
|
||||||
|
FirebaseCrashlytics.getInstance().recordException(exception)
|
||||||
|
// Display an error message to the user using a Snackbar
|
||||||
|
val errorMessage = "An error occurred: ${exception.message}"
|
||||||
|
val rootView = findViewById<View>(android.R.id.content)
|
||||||
|
Snackbar.make(rootView, errorMessage, Snackbar.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -316,7 +328,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
requestFineLocationPermission()
|
requestFineLocationPermission()
|
||||||
} else {
|
} else {
|
||||||
// Coarse location permission denied
|
// Coarse location permission denied
|
||||||
Toast.makeText(this, "Coarse location permission denied", Toast.LENGTH_SHORT)
|
Toast.makeText(this, R.string.coarse_location_denied, Toast.LENGTH_SHORT)
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -327,7 +339,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
getLocation()
|
getLocation()
|
||||||
} else {
|
} else {
|
||||||
// Fine location permission denied
|
// Fine location permission denied
|
||||||
Toast.makeText(this, "Fine location permission denied", Toast.LENGTH_SHORT)
|
Toast.makeText(this, R.string.location_denied, Toast.LENGTH_SHORT)
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.example.hpostesting.presentation
|
package com.example.hpostesting.presentation
|
||||||
|
|
||||||
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
@@ -13,11 +15,9 @@ 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 com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.util.MyUtils
|
import com.example.hpostesting.util.MyUtils
|
||||||
import com.google.firebase.firestore.FirebaseFirestoreSettings
|
import `in`.sminnovations.hpostesting.R
|
||||||
import com.google.firebase.firestore.ktx.firestore
|
|
||||||
import com.google.firebase.ktx.Firebase
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivitySplashBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivitySplashBinding
|
||||||
|
|
||||||
class SplashActivity : AppCompatActivity() {
|
class SplashActivity : AppCompatActivity() {
|
||||||
@@ -34,6 +34,12 @@ class SplashActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
private var allPermissionsGranted = false
|
private var allPermissionsGranted = false
|
||||||
|
|
||||||
|
override fun attachBaseContext(newBase: Context?) {
|
||||||
|
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||||
|
LanguageManager.setLocale(newBase, languageCode)
|
||||||
|
super.attachBaseContext(newBase)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = ActivitySplashBinding.inflate(layoutInflater)
|
binding = ActivitySplashBinding.inflate(layoutInflater)
|
||||||
@@ -77,7 +83,7 @@ class SplashActivity : AppCompatActivity() {
|
|||||||
} else {
|
} else {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
this,
|
this,
|
||||||
"You must grant permission to access all files to use the app",
|
R.string.permission_grant,
|
||||||
Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
finish()
|
finish()
|
||||||
@@ -139,7 +145,7 @@ class SplashActivity : AppCompatActivity() {
|
|||||||
if (allGranted) {
|
if (allGranted) {
|
||||||
moveToLandingPage()
|
moveToLandingPage()
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(this, "All permissions are required to use the app.", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, R.string.permission_required, Toast.LENGTH_SHORT).show()
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,126 @@
|
|||||||
|
package com.example.hpostesting.presentation.adapter
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.navigation.findNavController
|
||||||
|
import androidx.recyclerview.widget.AsyncListDiffer
|
||||||
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.example.hpostesting.data.DataHolder
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
|
import `in`.sminnovations.hpostesting.R
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.OfflineUserListViewBinding
|
||||||
|
import org.apache.commons.collections4.MapUtils.getString
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Calendar
|
||||||
|
import java.util.Date
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
|
|
||||||
|
class OfflineUserListAdapter(private val view: View, private val batLevel: Int) :
|
||||||
|
RecyclerView.Adapter<OfflineUserListAdapter.OfflineUserListViewHolder>() {
|
||||||
|
|
||||||
|
inner class OfflineUserListViewHolder(val binding: OfflineUserListViewBinding) :
|
||||||
|
RecyclerView.ViewHolder(binding.root)
|
||||||
|
|
||||||
|
private val differCallback = object : DiffUtil.ItemCallback<HemoCubeTestData>() {
|
||||||
|
override fun areItemsTheSame(
|
||||||
|
oldItem: HemoCubeTestData, newItem: HemoCubeTestData
|
||||||
|
): Boolean {
|
||||||
|
return oldItem._id == newItem._id
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun areContentsTheSame(
|
||||||
|
oldItem: HemoCubeTestData, newItem: HemoCubeTestData
|
||||||
|
): Boolean {
|
||||||
|
return oldItem == newItem
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val differ = AsyncListDiffer(this, differCallback)
|
||||||
|
private val context: Context? = null
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OfflineUserListViewHolder {
|
||||||
|
return OfflineUserListViewHolder(
|
||||||
|
OfflineUserListViewBinding.inflate(LayoutInflater.from(parent.context), parent, false)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount(): Int {
|
||||||
|
return differ.currentList.size
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: OfflineUserListViewHolder, position: Int) {
|
||||||
|
val userList = differ.currentList[position]
|
||||||
|
holder.binding.apply {
|
||||||
|
userID.text = "User ID: ${userList._id}"
|
||||||
|
bloodGroup.text = "Blood group: ${userList.bloodGroup}"
|
||||||
|
time.text = "Time: ${userList.incubationTime}"
|
||||||
|
userCard.setOnClickListener {
|
||||||
|
if (batLevel < 40) {
|
||||||
|
Toast.makeText(
|
||||||
|
view.context,
|
||||||
|
view.context.getString(R.string.low_battery_warning),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
|
if (userList.testStatus != null) {
|
||||||
|
if (userList.testStatus!!) {
|
||||||
|
Toast.makeText(
|
||||||
|
view.context,
|
||||||
|
view.context.getString(R.string.test_already_conducted),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
} else {
|
||||||
|
if (userList.incubationTime != "") {
|
||||||
|
if (isBetween15And30Minutes(userList.incubationTime) < Constants.INCUBATION_TIME_MIN) {
|
||||||
|
Toast.makeText(
|
||||||
|
view.context,
|
||||||
|
view.context.getString(R.string.incubation_not_completed),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
} else
|
||||||
|
if (isBetween15And30Minutes(userList.incubationTime) > Constants.INCUBATION_TIME_MAX) {
|
||||||
|
Toast.makeText(
|
||||||
|
view.context,
|
||||||
|
view.context.getString(R.string.incubation_crossed_30_minutes),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
} else {
|
||||||
|
DataHolder.selectedTest = UserData(
|
||||||
|
_id = userList._id,
|
||||||
|
bloodGroup = userList.bloodGroup,
|
||||||
|
incubationTime = userList.incubationTime
|
||||||
|
)
|
||||||
|
view.findNavController()
|
||||||
|
.navigate(R.id.action_nav_home_to_mainActivity)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Toast.makeText(
|
||||||
|
view.context,
|
||||||
|
view.context.getString(R.string.incubation_not_started),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun isBetween15And30Minutes(createdAt: String): Long {
|
||||||
|
val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
||||||
|
val createdAtDate: Date = formatter.parse(createdAt)!!
|
||||||
|
|
||||||
|
val currentTime = Calendar.getInstance().time
|
||||||
|
|
||||||
|
val diffMillis = currentTime.time - createdAtDate.time
|
||||||
|
|
||||||
|
return diffMillis / (60 * 1000)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
package com.example.hpostesting.presentation.adapter
|
package com.example.hpostesting.presentation.adapter
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
|
import android.app.AlertDialog
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Context.INPUT_METHOD_SERVICE
|
||||||
|
import android.view.inputmethod.InputMethodManager
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@@ -10,17 +14,31 @@ import androidx.recyclerview.widget.RecyclerView
|
|||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
|
||||||
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 `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.UserItemViewBinding
|
import `in`.sminnovations.hpostesting.databinding.UserItemViewBinding
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Calendar
|
||||||
|
import java.util.Date
|
||||||
|
import java.util.Locale
|
||||||
|
import android.widget.AutoCompleteTextView
|
||||||
|
import androidx.core.content.ContextCompat.getSystemService
|
||||||
|
import androidx.core.content.getSystemService
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
|
|
||||||
class UserListAdapter(
|
class UserListAdapter(
|
||||||
|
|
||||||
|
private val context: Context,
|
||||||
|
private val hemoCubeViewModel: HemoCubeViewModel,
|
||||||
options: FirestoreRecyclerOptions<UserData>,
|
options: FirestoreRecyclerOptions<UserData>,
|
||||||
private val view: View
|
private val view: View,
|
||||||
) :
|
private val batLevel: Int,
|
||||||
FirestoreRecyclerAdapter<UserData, UserListAdapter.OrderItemViewHolder>(options) {
|
private val requireActivity: FragmentActivity
|
||||||
|
) : FirestoreRecyclerAdapter<UserData, UserListAdapter.OrderItemViewHolder>(options) {
|
||||||
|
|
||||||
class OrderItemViewHolder(val binding: UserItemViewBinding) :
|
class OrderItemViewHolder(val binding: UserItemViewBinding) :
|
||||||
RecyclerView.ViewHolder(binding.root)
|
RecyclerView.ViewHolder(binding.root)
|
||||||
@@ -36,27 +54,206 @@ class UserListAdapter(
|
|||||||
holder.binding.apply {
|
holder.binding.apply {
|
||||||
userName.text = "Name: ${model.name}"
|
userName.text = "Name: ${model.name}"
|
||||||
userId.text = "User ID:${model._id}"
|
userId.text = "User ID:${model._id}"
|
||||||
|
if (model.incubationTime == "") {
|
||||||
|
btnBlood.visibility = View.VISIBLE
|
||||||
|
} else {
|
||||||
|
userId.text =
|
||||||
|
"User ID:${model._id} \n Time: ${isBetween15And30Minutes(model.incubationTime)} \n Started at: ${
|
||||||
|
SimpleDateFormat("HH:mm:ss").format(
|
||||||
|
SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
).parse(model.incubationTime)!!
|
||||||
|
)
|
||||||
|
}"
|
||||||
|
btnBlood.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Glide.with(view).load(model.userImageURL).into(userImage)
|
Glide.with(view).load(model.userImageURL).into(userImage)
|
||||||
if (model.testStatus!!) {
|
if (model.testStatus!!) {
|
||||||
teststatus.text = "Test concluded"
|
teststatus.text = view.context.getString(R.string.test_concluded)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
teststatus.text = "Test is Pending"
|
teststatus.text = view.context.getString(R.string.test_pending)
|
||||||
|
}
|
||||||
|
|
||||||
|
holder.binding.btnBlood.setOnClickListener {
|
||||||
|
val view: View? = requireActivity.currentFocus
|
||||||
|
|
||||||
|
// on below line checking if view is not null.
|
||||||
|
if (view != null) {
|
||||||
|
// on below line we are creating a variable
|
||||||
|
// for input manager and initializing it.
|
||||||
|
val inputMethodManager =
|
||||||
|
context.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
|
|
||||||
|
// on below line hiding our keyboard.
|
||||||
|
inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0)
|
||||||
|
}
|
||||||
|
val inflater = LayoutInflater.from(context)
|
||||||
|
val dialogView = inflater.inflate(R.layout.dialog_custom, null)
|
||||||
|
|
||||||
|
val builder = AlertDialog.Builder(context)
|
||||||
|
.setView(dialogView)
|
||||||
|
.setTitle(R.string.blood_group)
|
||||||
|
|
||||||
|
val etBloodGroup = dialogView.findViewById<AutoCompleteTextView>(R.id.et_blood_group)
|
||||||
|
|
||||||
|
builder.setPositiveButton(R.string.ok) { dialog, which ->
|
||||||
|
val bloodGroup = etBloodGroup.text.toString()
|
||||||
|
if (bloodGroup.equals("Select Blood Group") ||bloodGroup.equals("ರಕ್ತ ಗುಂಪು ಆಯ್ಕೆಮಾಡಿ") || bloodGroup.isNullOrBlank()) {
|
||||||
|
if (view != null) {
|
||||||
|
etBloodGroup.error =view.context.getString(R.string.blood_group_error)
|
||||||
|
}
|
||||||
|
if (view != null) {
|
||||||
|
Toast.makeText(context, view.context.getString(R.string.blood_group_toast), Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Check if hemoCubeViewModel and testDetails are not null
|
||||||
|
val db: FirebaseFirestore = FirebaseFirestore.getInstance()
|
||||||
|
|
||||||
|
db.collection("patientData")
|
||||||
|
.whereEqualTo("_id", model._id)
|
||||||
|
.get()
|
||||||
|
.addOnSuccessListener { userdata ->
|
||||||
|
try {
|
||||||
|
val document = userdata.documents[0]
|
||||||
|
db.collection("patientData")
|
||||||
|
.document(document.id)
|
||||||
|
.update("bloodGroup", bloodGroup,
|
||||||
|
"incubationTime", SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
).format(Calendar.getInstance().time).toString()
|
||||||
|
)
|
||||||
|
.addOnSuccessListener {
|
||||||
|
if (view != null) {
|
||||||
|
Toast.makeText(
|
||||||
|
view.context,
|
||||||
|
context?.getString(R.string.blood_group_updated_successfully),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
btnBlood.visibility = View.GONE
|
||||||
|
}
|
||||||
|
.addOnFailureListener { e ->
|
||||||
|
if (view != null) {
|
||||||
|
Toast.makeText(
|
||||||
|
view.context,
|
||||||
|
context?.getString(R.string.failed_to_update_blood_group),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: IndexOutOfBoundsException) {
|
||||||
|
// Handle the case where no documents are found for the specified ID
|
||||||
|
if (view != null) {
|
||||||
|
Toast.makeText(
|
||||||
|
view.context,
|
||||||
|
context?.getString(R.string.no_user_data_found),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
.addOnFailureListener { e ->
|
||||||
|
Toast.makeText(
|
||||||
|
context,
|
||||||
|
"Error fetching user data: ${e.message}",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Handle the selected blood group here
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.setNegativeButton(R.string.cancel) { dialog, which ->
|
||||||
|
dialog.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
val alertDialog = builder.create()
|
||||||
|
alertDialog.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
btnStartIncubation.setOnClickListener {
|
||||||
|
// it.visibility = View.GONE
|
||||||
|
// Firebase.firestore.collection("patientData").whereEqualTo("_id", model._id).get()
|
||||||
|
// .addOnSuccessListener { data ->
|
||||||
|
// if (data.documents.isNotEmpty()) {
|
||||||
|
// data.documents.forEach { userData ->
|
||||||
|
// Firebase.firestore.collection("patientData").document(userData.id)
|
||||||
|
// .update(
|
||||||
|
// "incubationTime", SimpleDateFormat(
|
||||||
|
// "yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
// ).format(Calendar.getInstance().time).toString()
|
||||||
|
// ).addOnSuccessListener {
|
||||||
|
// Toast.makeText(
|
||||||
|
// view.context, "Incubation started", Toast.LENGTH_SHORT
|
||||||
|
// ).show()
|
||||||
|
// startListening()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
userCard.setOnClickListener {
|
userCard.setOnClickListener {
|
||||||
|
if (false) {
|
||||||
|
Toast.makeText(
|
||||||
|
view.context,
|
||||||
|
context?.getString(R.string.low_battery_warning),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
if (model.testStatus != null) {
|
if (model.testStatus != null) {
|
||||||
if (model.testStatus!!) {
|
if (model.testStatus!!) {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
view.context,
|
view.context,
|
||||||
"Test has been already conducted for this user",
|
context?.getString(R.string.test_already_conducted),
|
||||||
Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
} else {
|
} else {
|
||||||
DataHolder.selectedTest = model
|
if (model.incubationTime != "") {
|
||||||
view.findNavController().navigate(R.id.action_nav_home_to_mainActivity)
|
if (isBetween15And30Minutes(model.incubationTime) < 15) {
|
||||||
|
Toast.makeText(
|
||||||
|
view.context,
|
||||||
|
context?.getString(R.string.incubation_not_completed),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
} else if (isBetween15And30Minutes(model.incubationTime) > 30) {
|
||||||
|
Toast.makeText(
|
||||||
|
view.context,
|
||||||
|
context?.getString(R.string.incubation_crossed_30_minutes),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
} else {
|
||||||
|
DataHolder.selectedTest = model
|
||||||
|
view.findNavController()
|
||||||
|
.navigate(R.id.action_nav_home_to_mainActivity)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Toast.makeText(
|
||||||
|
view.context,
|
||||||
|
context?.getString(R.string.incubation_not_started),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private fun isBetween15And30Minutes(createdAt: String): Long {
|
||||||
|
val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
||||||
|
val createdAtDate: Date = formatter.parse(createdAt)!!
|
||||||
|
|
||||||
|
val currentTime = Calendar.getInstance().time
|
||||||
|
|
||||||
|
val diffMillis = currentTime.time - createdAtDate.time
|
||||||
|
|
||||||
|
return diffMillis / (60 * 1000)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,354 @@
|
|||||||
|
package com.example.hpostesting.presentation.buffercheck
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.view.inputmethod.InputMethodManager
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.fragment.app.activityViewModels
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import com.example.hpostesting.data.DataHolder
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
|
import com.example.hpostesting.data.model.patient.BufferCheckData
|
||||||
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
|
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
||||||
|
import com.example.hpostesting.presentation.UsbServiceListener
|
||||||
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
|
import com.example.hpostesting.presentation.utils.MyDialogListener
|
||||||
|
import com.example.hpostesting.presentation.utils.UIUtils
|
||||||
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
|
import com.google.firebase.ktx.Firebase
|
||||||
|
import `in`.sminnovations.hpostesting.R
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.FragmentHemoCubeReferenceBinding
|
||||||
|
import kotlin.math.log10
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Calendar
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
|
class HemoCubeBufferCheckFragment : Fragment() {
|
||||||
|
|
||||||
|
private lateinit var binding: FragmentHemoCubeReferenceBinding
|
||||||
|
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
||||||
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
|
private var currentDeviceData: DeviceData? = null
|
||||||
|
private var resultData: String = ""
|
||||||
|
private var kitno: String = ""
|
||||||
|
private var isOnline = false
|
||||||
|
private val messages = MutableLiveData<String>()
|
||||||
|
private var isTestOngoing = false
|
||||||
|
private var startListening = MutableLiveData(false)
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
||||||
|
): View {
|
||||||
|
binding = FragmentHemoCubeReferenceBinding.inflate(inflater, container, false)
|
||||||
|
sharedPreferences =
|
||||||
|
requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
initViews()
|
||||||
|
observeViewModel()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initViews() {
|
||||||
|
|
||||||
|
binding.nameEditText.setText("SMI/SC/")
|
||||||
|
binding.tvTitle.visibility = View.GONE
|
||||||
|
binding.tvName.visibility = View.GONE
|
||||||
|
|
||||||
|
binding.btnGo.setOnClickListener {
|
||||||
|
val serialNumber = binding.nameEditText.text.toString().trim()
|
||||||
|
if (serialNumber.isNotEmpty() && isSerialValid(serialNumber)) {
|
||||||
|
kitno = serialNumber
|
||||||
|
listenToHemoCube()
|
||||||
|
startBufferProcess()
|
||||||
|
} else {
|
||||||
|
Toast.makeText(context, R.string.invalid_kit_number, Toast.LENGTH_LONG).show()
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
binding.tvSubtitle2.visibility = View.GONE
|
||||||
|
binding.etAbhaId.visibility = View.GONE
|
||||||
|
binding.tvTitle.visibility = View.GONE
|
||||||
|
binding.tvTitle2.visibility = View.GONE
|
||||||
|
binding.btnGo.visibility = View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
binding.btnSubmit.isEnabled = true
|
||||||
|
binding.btnSubmit.isClickable = true
|
||||||
|
}
|
||||||
|
binding.btnSubmit.setOnClickListener {
|
||||||
|
|
||||||
|
}
|
||||||
|
binding.btnSubmit.isEnabled = false
|
||||||
|
binding.btnSubmit.isClickable = false
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun observeViewModel() {
|
||||||
|
hemoCubeViewModel.deviceData.observe(viewLifecycleOwner) {
|
||||||
|
currentDeviceData = it
|
||||||
|
}
|
||||||
|
|
||||||
|
hemoCubeViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
||||||
|
if (isNetworkAvailable) {
|
||||||
|
hemoCubeViewModel.getDeviceData(sharedPreferences.getString(Constants.USER_ID, ""))
|
||||||
|
} else {
|
||||||
|
Toast.makeText(
|
||||||
|
requireContext(), R.string.internt_not, Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
isOnline = isNetworkAvailable
|
||||||
|
}
|
||||||
|
hemoCubeViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
||||||
|
if (result == "Success") {
|
||||||
|
showToast(R.string.kit_uploaded)
|
||||||
|
}
|
||||||
|
if (result == "Local") {
|
||||||
|
showToast(R.string.kit_upload_failed)
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.progressBar.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
messages.observe(viewLifecycleOwner) {
|
||||||
|
binding.tvSubtitle4.text = it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun listenToHemoCube() {
|
||||||
|
if (DataHolder.hemoCubeTestData == null) {
|
||||||
|
DataHolder.hemoCubeTestData = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||||
|
}
|
||||||
|
|
||||||
|
val fullReadOutput = StringBuilder()
|
||||||
|
startListening.postValue(true)
|
||||||
|
|
||||||
|
try {
|
||||||
|
(activity as HemocubeBufferCheckActivity).mService.listenToHemoCube(object :
|
||||||
|
UsbServiceListener {
|
||||||
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
|
data?.let {
|
||||||
|
val stringData = String(it)
|
||||||
|
fullReadOutput.append(stringData)
|
||||||
|
handleUsbData(stringData, fullReadOutput)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (e: Exception) {
|
||||||
|
showToast(R.string.test_ongoing)
|
||||||
|
Firebase.crashlytics.recordException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleUsbData(stringData: String, fullReadOutput: StringBuilder) {
|
||||||
|
if (stringData.contains("#")) {
|
||||||
|
messages.postValue(stringData)
|
||||||
|
isTestOngoing = true
|
||||||
|
}
|
||||||
|
|
||||||
|
resultData += fullReadOutput.toString()
|
||||||
|
|
||||||
|
when {
|
||||||
|
stringData.contains("#Buffer Completed") -> showStartSampleDialog()
|
||||||
|
stringData.contains("#Sample Completed") -> {
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
binding.btnSubmit.isEnabled = true
|
||||||
|
binding.btnSubmit.isClickable = true
|
||||||
|
}
|
||||||
|
fetchResult()
|
||||||
|
}
|
||||||
|
|
||||||
|
stringData.contains("RESULT") || resultData.contains("REND") -> {
|
||||||
|
var validString: String
|
||||||
|
val results: List<String>
|
||||||
|
if (stringData.contains("RESULT")) {
|
||||||
|
validString = isValidResult(stringData)
|
||||||
|
if (validString.isEmpty()) {
|
||||||
|
results = resultData.split("\n")
|
||||||
|
validString = parseResult(results)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
results = resultData.split("\n")
|
||||||
|
validString = parseResult(results)
|
||||||
|
}
|
||||||
|
if (validString.isNotEmpty()) {
|
||||||
|
handleValidResult(validString)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showStartSampleDialog() {
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
UIUtils.createAlertDialog(requireContext(),
|
||||||
|
"Start Sample",
|
||||||
|
"Do you want to start sample reading?",
|
||||||
|
getString(R.string.no),
|
||||||
|
"Yes",
|
||||||
|
object : MyDialogListener {
|
||||||
|
override fun onClickNegativeButton() {}
|
||||||
|
|
||||||
|
override fun onClickPositiveButton() {
|
||||||
|
listenToHemoCube()
|
||||||
|
startSampleProcess()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun handleValidResult(validString: String) {
|
||||||
|
try {
|
||||||
|
val result = validString.split(" ")
|
||||||
|
if (result.size == 8) {
|
||||||
|
val deviceId = result[2]
|
||||||
|
val led1BufferForDevice = result[3].toDoubleOrNull()
|
||||||
|
val led2BufferForDevice = result[4].toDoubleOrNull()
|
||||||
|
val led1Sample = result[5].toDoubleOrNull()
|
||||||
|
val led2Sample = result[6].toDoubleOrNull()
|
||||||
|
val led1Average = log10(led1BufferForDevice?.div(led1Sample!!) ?: 0.0)
|
||||||
|
val led2Average = log10(led2BufferForDevice?.div(led2Sample!!) ?: 0.0)
|
||||||
|
val deviceRatio = led1Average / led2Average
|
||||||
|
val calculateRatio = calculateRatio(deviceRatio)
|
||||||
|
val classificationResult = findResult(calculateRatio)
|
||||||
|
messages.postValue(classificationResult)
|
||||||
|
val bufferData = BufferCheckData(
|
||||||
|
deviceId= deviceId,
|
||||||
|
kitno = kitno,
|
||||||
|
led1Buffer = led1BufferForDevice,
|
||||||
|
led2Buffer = led2BufferForDevice,
|
||||||
|
led1Average = led1Average,
|
||||||
|
led2Average = led2Average,
|
||||||
|
led1Sample = led1Sample,
|
||||||
|
led2Sample = led2Sample,
|
||||||
|
deviceRatio = deviceRatio,
|
||||||
|
calculatedRatio = calculateRatio,
|
||||||
|
coefficients = currentDeviceData?.coefficients?.get(0).toString() + ", " + currentDeviceData?.coefficients?.get(1).toString(),
|
||||||
|
classificationResult = classificationResult,
|
||||||
|
deviceSerialNumber = sharedPreferences.getString(Constants.USER_ID, "").toString(),
|
||||||
|
testTime = SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
).format(Calendar.getInstance().time)
|
||||||
|
)
|
||||||
|
hemoCubeViewModel.uploadHemoCubeResultToDatabaseforbuffercheckN(bufferData)
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Toast.makeText(
|
||||||
|
requireContext(), "Error while processing device data", Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
Firebase.crashlytics.recordException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun findResult(calculatedRatio: Double?): String {
|
||||||
|
try {
|
||||||
|
if (calculatedRatio != null) {
|
||||||
|
if (calculatedRatio < 0.085) return "Kit Failed"
|
||||||
|
if (calculatedRatio in 0.085..0.155) return "Kit Passed"
|
||||||
|
if (calculatedRatio in 0.155..0.175) return "Kit Failed"
|
||||||
|
if (calculatedRatio in 0.175..0.22) return "Kit Failed"
|
||||||
|
if (calculatedRatio in 0.22..0.25) return "Kit Failed"
|
||||||
|
if (calculatedRatio in 0.25..0.35) return "Kit Failed"
|
||||||
|
if (calculatedRatio > 0.35) return "Kit Failed"
|
||||||
|
} else {
|
||||||
|
return "NULL"
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
showToast(R.string.error_classification)
|
||||||
|
Firebase.crashlytics.recordException(e)
|
||||||
|
return "ERROR"
|
||||||
|
}
|
||||||
|
return "NULL"
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showToast(messageResId: Int) {
|
||||||
|
Toast.makeText(requireContext(), getString(messageResId), Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun startBufferProcess() {
|
||||||
|
|
||||||
|
(activity as HemocubeBufferCheckActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.startBuffer,
|
||||||
|
object : UsbServiceListener {
|
||||||
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
|
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun startSampleProcess() {
|
||||||
|
|
||||||
|
(activity as HemocubeBufferCheckActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.startSample,
|
||||||
|
object : UsbServiceListener {
|
||||||
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
|
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun fetchResult() {
|
||||||
|
|
||||||
|
(activity as HemocubeBufferCheckActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.getSample,
|
||||||
|
object : UsbServiceListener {
|
||||||
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
|
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun calculateRatio(ratio: Double): Double {
|
||||||
|
val coefficient1 = currentDeviceData?.coefficients?.get(0) ?: 0.0
|
||||||
|
val coefficient2 = currentDeviceData?.coefficients?.get(1) ?: 1.0
|
||||||
|
return coefficient1 * ratio + coefficient2
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun parseResult(frames: List<String>): String {
|
||||||
|
val lines = mutableListOf<String>()
|
||||||
|
for (frame in frames.reversed()) {
|
||||||
|
if (frame.contains("REND") || frame.contains("RESULT")) lines += frame
|
||||||
|
if (frame.contains("RESULT")) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val line = lines.reversed().joinToString("").trim()
|
||||||
|
if (line.contains("RESULT") && line.split(" ").size == 8) {
|
||||||
|
return line
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun isSerialValid(s: String): Boolean {
|
||||||
|
if (s.length != 17) {
|
||||||
|
binding.nameEditText.error = getString(R.string.invalid_kit)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun isValidResult(line: String): String {
|
||||||
|
return if (line.contains("RESULT") && line.split(" ").size == 8) {
|
||||||
|
line
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
package com.example.hpostesting.presentation.buffercheck
|
||||||
|
|
||||||
|
import android.app.PendingIntent
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
|
import android.content.ComponentName
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.IntentFilter
|
||||||
|
import android.content.ServiceConnection
|
||||||
|
import android.hardware.usb.UsbDevice
|
||||||
|
import android.hardware.usb.UsbDeviceConnection
|
||||||
|
import android.hardware.usb.UsbManager
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.os.IBinder
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.Menu
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.activity.viewModels
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.view.get
|
||||||
|
import com.example.hpostesting.data.DataHolder
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
|
import com.example.hpostesting.presentation.testRight.UsbService
|
||||||
|
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||||
|
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import `in`.sminnovations.hpostesting.R
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.ActivityHemocubeBinding
|
||||||
|
|
||||||
|
@AndroidEntryPoint
|
||||||
|
open class HemocubeBufferCheckActivity : AppCompatActivity() {
|
||||||
|
private lateinit var binding: ActivityHemocubeBinding
|
||||||
|
private val viewModel by viewModels<HemoCubeViewModel>()
|
||||||
|
private var myMenu: Menu? = null
|
||||||
|
|
||||||
|
private lateinit var mDriver: UsbSerialDriver
|
||||||
|
private var mConnection: UsbDeviceConnection? = null
|
||||||
|
lateinit var mService: UsbService
|
||||||
|
|
||||||
|
private val TAG = "HemoCube"
|
||||||
|
|
||||||
|
private val broadcastReceiver = object : BroadcastReceiver() {
|
||||||
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
|
|
||||||
|
synchronized(this) {
|
||||||
|
val device: UsbDevice? = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE)
|
||||||
|
|
||||||
|
if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
|
||||||
|
device?.apply {
|
||||||
|
connectUsb(true)
|
||||||
|
DataHolder.usbConnected.postValue(true)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DataHolder.usbConnected.postValue(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private val connection = object : ServiceConnection {
|
||||||
|
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
||||||
|
val binder = service as UsbService.UsbServiceBinder
|
||||||
|
mService = binder.getService()
|
||||||
|
viewModel.isServiceConnected = true
|
||||||
|
mConnection.let { mService.connect(mDriver, mConnection!!) }
|
||||||
|
moveToNext()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onServiceDisconnected(arg0: ComponentName) {
|
||||||
|
viewModel.isServiceConnected = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun attachBaseContext(newBase: Context?) {
|
||||||
|
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||||
|
LanguageManager.setLocale(newBase, languageCode)
|
||||||
|
super.attachBaseContext(newBase)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
binding = ActivityHemocubeBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
|
setSupportActionBar(binding.myToolbar)
|
||||||
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
|
setupListener()
|
||||||
|
connectUsb(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupListener() {
|
||||||
|
DataHolder.usbConnected.observe(this) {
|
||||||
|
Log.d("USB OBSERVE", "HemoCube called -> $it")
|
||||||
|
if (it) {
|
||||||
|
myMenu?.get(0)?.icon =
|
||||||
|
ContextCompat.getDrawable(this, R.drawable.ic_baseline_usb_24)
|
||||||
|
} else {
|
||||||
|
myMenu?.get(0)?.icon =
|
||||||
|
ContextCompat.getDrawable(this, R.drawable.ic_baseline_usb_off_24)
|
||||||
|
Toast.makeText(this, R.string.device_disconnected, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun connectUsb(permissionGranted: Boolean) {
|
||||||
|
Log.d(TAG, "connectUsb() called, permission variable = $permissionGranted")
|
||||||
|
val manager = getSystemService(Context.USB_SERVICE) as UsbManager
|
||||||
|
val availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(manager)
|
||||||
|
|
||||||
|
if (availableDrivers.isEmpty()) {
|
||||||
|
Toast.makeText(this, R.string.no_device_found, Toast.LENGTH_SHORT).show()
|
||||||
|
} else {
|
||||||
|
mDriver = availableDrivers[0]
|
||||||
|
mConnection = manager.openDevice(mDriver.device)
|
||||||
|
|
||||||
|
if (mConnection == null) {
|
||||||
|
requestUserPermission(manager, mDriver.device)
|
||||||
|
} else {
|
||||||
|
setupService()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
||||||
|
val mPendingIntent: PendingIntent = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||||
|
PendingIntent.getBroadcast(
|
||||||
|
this, 0, Intent(Constants.HOMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
PendingIntent.getBroadcast(
|
||||||
|
this,
|
||||||
|
0,
|
||||||
|
Intent(Constants.HOMOCUBE_USB_PERMISSION),
|
||||||
|
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val filter = IntentFilter(Constants.HOMOCUBE_USB_PERMISSION)
|
||||||
|
registerReceiver(broadcastReceiver, filter)
|
||||||
|
manager.requestPermission(device, mPendingIntent)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupService() {
|
||||||
|
val intent = Intent(this, UsbService::class.java)
|
||||||
|
bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun moveToNext() {
|
||||||
|
if (supportFragmentManager.isDestroyed) return
|
||||||
|
|
||||||
|
supportFragmentManager.beginTransaction().replace(binding.fghemocube.id, HemoCubeBufferCheckFragment())
|
||||||
|
.commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||||
|
menuInflater.inflate(R.menu.my_menu, menu)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
if (viewModel.isServiceConnected) {
|
||||||
|
mService.disconnect()
|
||||||
|
unbindService(connection)
|
||||||
|
viewModel.isServiceConnected = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,33 +1,95 @@
|
|||||||
package com.example.hpostesting.presentation.dashboard
|
package com.example.hpostesting.presentation.dashboard
|
||||||
|
|
||||||
|
import android.app.DownloadManager
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.IntentFilter
|
||||||
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.activity.viewModels
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.content.FileProvider
|
||||||
import androidx.drawerlayout.widget.DrawerLayout
|
import androidx.drawerlayout.widget.DrawerLayout
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
import androidx.navigation.ui.AppBarConfiguration
|
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.data.Result
|
||||||
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
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 dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityDashboardBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityDashboardBinding
|
||||||
|
import okhttp3.ResponseBody
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class DashboardActivity : AppCompatActivity() {
|
class DashboardActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private lateinit var appBarConfiguration: AppBarConfiguration
|
private lateinit var appBarConfiguration: AppBarConfiguration
|
||||||
private lateinit var binding: ActivityDashboardBinding
|
private lateinit var binding: ActivityDashboardBinding
|
||||||
|
private var downloadId: Long = 0
|
||||||
|
private val hemocubeViewModel: HemoCubeViewModel by viewModels()
|
||||||
|
|
||||||
|
override fun attachBaseContext(newBase: Context?) {
|
||||||
|
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||||
|
LanguageManager.setLocale(newBase, languageCode)
|
||||||
|
super.attachBaseContext(newBase)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
binding = ActivityDashboardBinding.inflate(layoutInflater)
|
binding = ActivityDashboardBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
|
||||||
setSupportActionBar(binding.appBarDashboard.toolbar)
|
setSupportActionBar(binding.appBarDashboard.toolbar)
|
||||||
|
|
||||||
|
hemocubeViewModel.deviceUpdate.observe(this) { result ->
|
||||||
|
when (result) {
|
||||||
|
is Result.Success -> {
|
||||||
|
// val apkUrl = result.data
|
||||||
|
val apkUrl = "https://dl.dropboxusercontent.com/s/fi/1c3nn7t0co431hicl3hrt/app-debug.apk?rlkey=e4uf13ty1dpcked614vy1aaqp&dl=0"
|
||||||
|
initiateUpdate(apkUrl.toString())
|
||||||
|
Log.d("ApI", "APK URL For App Update: $apkUrl")
|
||||||
|
Toast.makeText(
|
||||||
|
this,
|
||||||
|
"APK UPLOAD ${result.data}",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
// The APK URL LiveData will be updated automatically
|
||||||
|
}
|
||||||
|
|
||||||
|
is Result.Error -> {
|
||||||
|
result.exception.let { message ->
|
||||||
|
Toast.makeText(this, "An error occurred On Updating App: $message", Toast.LENGTH_LONG)
|
||||||
|
.show()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
is Result.Loading -> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
val drawerLayout: DrawerLayout = binding.drawerLayout
|
val drawerLayout: DrawerLayout = binding.drawerLayout
|
||||||
val navView: NavigationView = binding.navView
|
val navView: NavigationView = binding.navView
|
||||||
val navController = findNavController(R.id.nav_host_fragment_content_dashboard)
|
val navController = findNavController(R.id.nav_host_fragment_content_dashboard)
|
||||||
@@ -40,6 +102,8 @@ class DashboardActivity : AppCompatActivity() {
|
|||||||
setupActionBarWithNavController(navController, appBarConfiguration)
|
setupActionBarWithNavController(navController, appBarConfiguration)
|
||||||
navView.setupWithNavController(navController)
|
navView.setupWithNavController(navController)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
@@ -53,4 +117,122 @@ class DashboardActivity : AppCompatActivity() {
|
|||||||
return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
|
return navController.navigateUp(appBarConfiguration) || super.onSupportNavigateUp()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun initiateUpdate(responseBody: String) {
|
||||||
|
// Extract the URL from the ResponseBody
|
||||||
|
val apkUrl = responseBody
|
||||||
|
|
||||||
|
// Check if the extracted APK URL is valid
|
||||||
|
if (!isValidHttpUrl(apkUrl)) {
|
||||||
|
// Handle the case where the URL is not valid
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val request = DownloadManager.Request(Uri.parse(apkUrl))
|
||||||
|
request.setTitle("App Update")
|
||||||
|
request.setDescription("Downloading update...")
|
||||||
|
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
||||||
|
request.setDestinationInExternalFilesDir(this, "Updates", "update.apk")
|
||||||
|
|
||||||
|
val downloadManager = getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
|
||||||
|
downloadId = downloadManager.enqueue(request)
|
||||||
|
|
||||||
|
// Register a BroadcastReceiver to receive the download complete event
|
||||||
|
val filter = IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)
|
||||||
|
registerReceiver(downloadReceiver, filter)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to check if a URL has a valid HTTP/HTTPS scheme
|
||||||
|
// Function to extract the APK URL from the ResponseBody
|
||||||
|
private fun extractApkUrl(responseBody: ResponseBody): String {
|
||||||
|
// Assuming your ResponseBody contains the APK URL as a string
|
||||||
|
return responseBody.string()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to check if a URL has a valid HTTP/HTTPS scheme
|
||||||
|
private fun isValidHttpUrl(url: String): Boolean {
|
||||||
|
return url.startsWith("http://") || url.startsWith("https://")
|
||||||
|
}
|
||||||
|
private val downloadReceiver = object : BroadcastReceiver() {
|
||||||
|
override fun onReceive(context: Context?, intent: Intent?) {
|
||||||
|
val id = intent?.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1)
|
||||||
|
if (id == downloadId) {
|
||||||
|
// Install the downloaded APK
|
||||||
|
installApk()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun installApk() {
|
||||||
|
val file = File(getExternalFilesDir("Updates"), "update.apk")
|
||||||
|
file.setReadable(true, false) // Ensure the file is readable
|
||||||
|
|
||||||
|
val uri: Uri = FileProvider.getUriForFile(
|
||||||
|
this,
|
||||||
|
"com.example.hpostesting.fileprovider",
|
||||||
|
file
|
||||||
|
)
|
||||||
|
|
||||||
|
// Create an intent to install the APK
|
||||||
|
val installIntent = Intent(Intent.ACTION_INSTALL_PACKAGE)
|
||||||
|
installIntent.data = uri
|
||||||
|
installIntent.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or
|
||||||
|
Intent.FLAG_ACTIVITY_NEW_TASK or
|
||||||
|
Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||||
|
installIntent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true)
|
||||||
|
|
||||||
|
// Start the installation
|
||||||
|
startActivity(installIntent)
|
||||||
|
|
||||||
|
Log.d("InstallApk", "Install Intent URI: $uri")
|
||||||
|
Log.d("InstallApk", "Package Name: $packageName")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
unregisterReceiver(downloadReceiver)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun onResume() {
|
||||||
|
super.onResume()
|
||||||
|
|
||||||
|
val firebaseAppDistribution = FirebaseAppDistribution.getInstance()
|
||||||
|
firebaseAppDistribution.updateIfNewReleaseAvailable()
|
||||||
|
.addOnProgressListener { updateProgress ->
|
||||||
|
|
||||||
|
if (updateProgress.apkBytesDownloaded > 0) {
|
||||||
|
Toast.makeText(
|
||||||
|
this,
|
||||||
|
"${updateProgress.updateStatus}. ${updateProgress.apkBytesDownloaded / 1048576} /${updateProgress.apkFileTotalBytes / 1048576} MB",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.addOnFailureListener { e ->
|
||||||
|
// (Optional) Handle errors.
|
||||||
|
if (e is FirebaseAppDistributionException) {
|
||||||
|
when (e.errorCode) {
|
||||||
|
FirebaseAppDistributionException.Status.NOT_IMPLEMENTED -> {
|
||||||
|
// SDK did nothing. This is expected when building for Play.
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
// Handle other errors.
|
||||||
|
Toast.makeText(
|
||||||
|
this,
|
||||||
|
"AppDistribution error, status: ${e.errorCode}",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FirebaseCrashlytics.getInstance().recordException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.addOnSuccessListener {
|
||||||
|
// Toast.makeText(this, "App Update: Success!", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
package com.example.hpostesting.presentation.dashboard
|
package com.example.hpostesting.presentation.dashboard
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
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.Fragment
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import com.example.hpostesting.presentation.buffercheck.HemocubeBufferCheckActivity
|
||||||
//import com.example.hpostesting.presentation.dashboard.ui.gallery.GalleryViewModel
|
import com.example.hpostesting.presentation.diagnostics.DiagnosticsActivity
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentGalleryBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentGalleryBinding
|
||||||
|
|
||||||
class GalleryFragment : Fragment() {
|
class GalleryFragment : Fragment() {
|
||||||
@@ -32,6 +33,15 @@ class GalleryFragment : Fragment() {
|
|||||||
// galleryViewModel.text.observe(viewLifecycleOwner) {
|
// galleryViewModel.text.observe(viewLifecycleOwner) {
|
||||||
//// textView.text = it
|
//// textView.text = it
|
||||||
// }
|
// }
|
||||||
|
binding.btnSubmit.setOnClickListener {
|
||||||
|
startActivity(Intent(requireContext(), HemocubeBufferCheckActivity::class.java))
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.btnDiagnostics.setOnClickListener {
|
||||||
|
startActivity(Intent(requireContext(), DiagnosticsActivity::class.java))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return root
|
return root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,13 @@ package com.example.hpostesting.presentation.dashboard
|
|||||||
|
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.Context.BATTERY_SERVICE
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
|
import android.content.Intent
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
|
import android.os.BatteryManager
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Base64
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@@ -13,18 +17,32 @@ import androidx.fragment.app.Fragment
|
|||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
|
import com.example.hpostesting.data.Result
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.model.login.LoginRequest
|
||||||
|
import com.example.hpostesting.data.model.login.LoginResponse
|
||||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
|
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
||||||
|
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
||||||
|
import com.example.hpostesting.presentation.KitScanActivity
|
||||||
|
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.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
||||||
import com.firebase.ui.firestore.FirestoreRecyclerOptions
|
import com.firebase.ui.firestore.FirestoreRecyclerOptions
|
||||||
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
|
import com.google.firebase.firestore.Query
|
||||||
import com.google.firebase.firestore.ktx.firestore
|
import com.google.firebase.firestore.ktx.firestore
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
|
import com.google.firebase.perf.ktx.performance
|
||||||
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.FragmentHomeBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentHomeBinding
|
||||||
|
import org.json.JSONObject
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Calendar
|
||||||
|
import java.util.Date
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
@@ -34,6 +52,12 @@ class HomeFragment : Fragment() {
|
|||||||
private val viewModel: TestRightViewModel by activityViewModels()
|
private val viewModel: TestRightViewModel by activityViewModels()
|
||||||
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
||||||
private lateinit var rvAdapter: UserListAdapter
|
private lateinit var rvAdapter: UserListAdapter
|
||||||
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
|
private var batLevel: Int =
|
||||||
|
0 // Initialize with a default value, or obtain the actual battery level
|
||||||
|
private lateinit var adapter: OfflineUserListAdapter
|
||||||
|
|
||||||
|
|
||||||
private lateinit var sharedPreference: SharedPreferences
|
private lateinit var sharedPreference: SharedPreferences
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
||||||
@@ -47,21 +71,33 @@ class HomeFragment : Fragment() {
|
|||||||
return super.onCreateView(inflater, container, savedInstanceState)
|
return super.onCreateView(inflater, container, savedInstanceState)
|
||||||
}
|
}
|
||||||
|
|
||||||
sharedPreference = requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
sharedPreference =
|
||||||
|
requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||||
DataHolder.selectedTest = null
|
DataHolder.selectedTest = null
|
||||||
|
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
viewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
viewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
||||||
if (userData.isNotEmpty()) {
|
|
||||||
|
|
||||||
}
|
|
||||||
deleteIncompleteRegistrations(userData)
|
deleteIncompleteRegistrations(userData)
|
||||||
}
|
}
|
||||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
||||||
deleteHemoCubeIncompleteRegistrations(userData)
|
deleteHemoCubeIncompleteRegistrations(userData)
|
||||||
|
if (userData.isNotEmpty()) {
|
||||||
|
val userList = mutableListOf<HemoCubeTestData>()
|
||||||
|
userData.forEach {
|
||||||
|
if (it.testStatus == false) {
|
||||||
|
userList.add(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val bm = requireContext().getSystemService(BATTERY_SERVICE) as BatteryManager
|
||||||
|
val batLevel: Int = bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
|
||||||
|
adapter = OfflineUserListAdapter(binding.root, batLevel)
|
||||||
|
adapter.differ.submitList(userList)
|
||||||
|
binding.rvOrderOffline.adapter = adapter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
viewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isConnected ->
|
viewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isConnected ->
|
||||||
if (isConnected) {
|
if (isConnected) {
|
||||||
@@ -70,26 +106,189 @@ class HomeFragment : Fragment() {
|
|||||||
loadUserData()
|
loadUserData()
|
||||||
setSearch()
|
setSearch()
|
||||||
checkForLocalDBData()
|
checkForLocalDBData()
|
||||||
|
checkForTokenAndUpdate()
|
||||||
} else {
|
} else {
|
||||||
binding.internetAvailableCL.visibility = View.GONE
|
binding.internetAvailableCL.visibility = View.GONE
|
||||||
binding.internetNotAvailableCL.visibility = View.VISIBLE
|
binding.internetNotAvailableCL.visibility = View.VISIBLE
|
||||||
setUserId()
|
setUserId()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
hemoCubeViewModel.fireBaseBulkUpload.observe(viewLifecycleOwner) { result ->
|
||||||
|
if (result == "Success") {
|
||||||
|
Toast.makeText(
|
||||||
|
requireContext(), R.string.test_upload, Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
if (result == "Error") {
|
||||||
|
Toast.makeText(requireContext(), R.string.test_upload_failed, Toast.LENGTH_SHORT)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
binding.btnLogout.setOnClickListener {
|
binding.btnLogout.setOnClickListener {
|
||||||
logoutUser(requireContext())
|
logoutUser(requireContext())
|
||||||
}
|
}
|
||||||
binding.uploadData.setOnClickListener {
|
binding.uploadData.setOnClickListener {
|
||||||
showUploadDialog(requireContext())
|
showUploadDialog(requireContext())
|
||||||
}
|
}
|
||||||
|
binding.btnNewKit.setOnClickListener {
|
||||||
|
with(sharedPreference.edit()) {
|
||||||
|
putString(Constants.KIT_NUMBER, "")
|
||||||
|
putInt(Constants.KIT_COUNT, 0)
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
startActivity(Intent(requireContext(), KitScanActivity::class.java))
|
||||||
|
requireActivity().finish()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun checkForTokenAndUpdate() {
|
||||||
|
val accessToken = sharedPreference.getString(Constants.ACCESS_TOKEN, "").toString()
|
||||||
|
val natsToken = sharedPreference.getString(Constants.NATS_TOKEN, "").toString()
|
||||||
|
if (accessToken.isEmpty() && natsToken.isEmpty()) {
|
||||||
|
hemoCubeViewModel.login(createLoginRequestData())
|
||||||
|
} else {
|
||||||
|
if (isTokenExpired(accessToken)) {
|
||||||
|
hemoCubeViewModel.login(createLoginRequestData())
|
||||||
|
} else {
|
||||||
|
hemoCubeViewModel.checkUpdate(createCheckUpdateRequestData())
|
||||||
|
hemoCubeViewModel.uploadLogs()
|
||||||
|
hemoCubeViewModel.deviceUpdate(createDeviceRequestData())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hemoCubeViewModel.loginResponse.observe(viewLifecycleOwner) { response ->
|
||||||
|
when (response) {
|
||||||
|
is Result.Success -> {
|
||||||
|
updateTokens(response)
|
||||||
|
checkForTokenAndUpdate()
|
||||||
|
}
|
||||||
|
|
||||||
|
is Result.Error -> {
|
||||||
|
response.exception.let { message ->
|
||||||
|
Toast.makeText(activity, "An error occurred: $message", Toast.LENGTH_LONG)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
is Result.Loading -> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hemoCubeViewModel.checkUpdate.observe(viewLifecycleOwner) { response ->
|
||||||
|
when (response) {
|
||||||
|
is Result.Success -> {
|
||||||
|
Toast.makeText(
|
||||||
|
requireContext(), response.data.data?.version, Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
is Result.Error -> {
|
||||||
|
response.exception.let { message ->
|
||||||
|
Toast.makeText(activity, "An error occurred: $message", Toast.LENGTH_LONG)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
is Result.Loading -> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hemoCubeViewModel.uploadLogs.observe(viewLifecycleOwner) { response ->
|
||||||
|
when (response) {
|
||||||
|
is Result.Success -> {
|
||||||
|
Toast.makeText(
|
||||||
|
requireContext(),
|
||||||
|
"Log uploaded ${response.data.data?.filename}",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
|
||||||
|
is Result.Error -> {
|
||||||
|
response.exception.let { message ->
|
||||||
|
Toast.makeText(activity, "An error occurred: $message", Toast.LENGTH_LONG)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
is Result.Loading -> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isTokenExpired(token: String): Boolean {
|
||||||
|
val parts = token.split("\\.".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||||
|
val decodedPayload = String(Base64.decode(parts[1], Base64.DEFAULT))
|
||||||
|
val jsonPayload = JSONObject(decodedPayload)
|
||||||
|
|
||||||
|
val exp = jsonPayload.optLong("exp", 0)
|
||||||
|
val currentTimeSeconds = System.currentTimeMillis() / 1000
|
||||||
|
|
||||||
|
return exp <= currentTimeSeconds
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateTokens(response: Result.Success<LoginResponse>) {
|
||||||
|
with(sharedPreference.edit()) {
|
||||||
|
putString(Constants.ACCESS_TOKEN, response.data.data?.accessToken)
|
||||||
|
putString(Constants.NATS_TOKEN, response.data.data?.deviceUser?.natsToken)
|
||||||
|
putString(Constants.DEVICE_ID, response.data.data?.deviceUser?.deviceId?.toString())
|
||||||
|
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createLoginRequestData(): LoginRequest {
|
||||||
|
return LoginRequest(
|
||||||
|
password = Constants.devicePassword,
|
||||||
|
serialNumber = Constants.deviceID,
|
||||||
|
username = Constants.deviceID
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createCheckUpdateRequestData(): CheckUpdateRequest {
|
||||||
|
val pInfo = requireActivity().packageManager.getPackageInfo(
|
||||||
|
requireActivity().packageName, 0
|
||||||
|
)
|
||||||
|
val version = pInfo.versionName
|
||||||
|
return CheckUpdateRequest(
|
||||||
|
currentVersion = version
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createDeviceRequestData(): DeviceUpdateRequest {
|
||||||
|
return DeviceUpdateRequest(
|
||||||
|
serial_no = Constants.DEVICE_ID
|
||||||
|
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private fun setUserId() {
|
private fun setUserId() {
|
||||||
binding.btnSubmit.setOnClickListener {
|
binding.btnSubmit.setOnClickListener {
|
||||||
val userId = binding.userId.text.toString()
|
val userId = binding.userId.text.toString()
|
||||||
if (userId.length >= 18) {
|
val bloodGroup = binding.etBloodGroup.text
|
||||||
val userData = UserData(_id = userId)
|
if (userId.length >= 18 && !bloodGroup.equals("Select Blood Group") || !bloodGroup.isNullOrBlank()) {
|
||||||
DataHolder.selectedTest = userData
|
hemoCubeViewModel.addUser(
|
||||||
findNavController().navigate(R.id.action_nav_home_to_mainActivity)
|
HemoCubeTestData(
|
||||||
|
_id = userId,
|
||||||
|
bloodGroup = bloodGroup.toString(),
|
||||||
|
incubationTime = SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
).format(Calendar.getInstance().time).toString()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
// val userData = UserData(_id = userId)
|
||||||
|
// DataHolder.selectedTest = userData
|
||||||
|
// findNavController().navigate(R.id.action_nav_home_to_mainActivity)
|
||||||
} else {
|
} else {
|
||||||
val errorMessage = getString(R.string.user_id_error_message)
|
val errorMessage = getString(R.string.user_id_error_message)
|
||||||
Toast.makeText(requireContext(), errorMessage, Toast.LENGTH_SHORT).show()
|
Toast.makeText(requireContext(), errorMessage, Toast.LENGTH_SHORT).show()
|
||||||
@@ -97,60 +296,115 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadUserData() {
|
private fun loadUserData() {
|
||||||
val query = Firebase.firestore.collection("patientData").whereEqualTo("testStatus", false)
|
try {
|
||||||
query.get().addOnSuccessListener {
|
val dateFormat = SimpleDateFormat("yyyy-MM-dd")
|
||||||
if (it.documents.isEmpty()) {
|
val currentDate = Date()
|
||||||
binding.pendingTest.visibility = View.VISIBLE
|
val formattedDate = dateFormat.format(currentDate)
|
||||||
} else {
|
val query = Firebase.firestore.collection("patientData")
|
||||||
binding.pendingTest.visibility = View.GONE
|
.whereGreaterThanOrEqualTo("createdAt", formattedDate)
|
||||||
|
.orderBy("createdAt", Query.Direction.DESCENDING)
|
||||||
|
// val query = Firebase.firestore.collection("patientData").whereEqualTo("testStatus", false)
|
||||||
|
query.get().addOnSuccessListener {
|
||||||
|
if (it.documents.isEmpty()) {
|
||||||
|
binding.pendingTest.visibility = View.VISIBLE
|
||||||
|
} else {
|
||||||
|
binding.pendingTest.visibility = View.GONE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
val recyclerViewOptions =
|
||||||
|
FirestoreRecyclerOptions.Builder<UserData>().setQuery(query, UserData::class.java)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
val bm = requireContext().getSystemService(BATTERY_SERVICE) as BatteryManager
|
||||||
|
val batLevel: Int = bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
|
||||||
|
|
||||||
|
rvAdapter = view?.let {
|
||||||
|
UserListAdapter(
|
||||||
|
requireContext(),
|
||||||
|
hemoCubeViewModel,
|
||||||
|
recyclerViewOptions,
|
||||||
|
it,
|
||||||
|
batLevel,
|
||||||
|
requireActivity()
|
||||||
|
)
|
||||||
|
}!!
|
||||||
|
binding.rvOrder.adapter = rvAdapter
|
||||||
|
|
||||||
|
rvAdapter.startListening()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Firebase.crashlytics.recordException(e)
|
||||||
}
|
}
|
||||||
val recyclerViewOptions =
|
|
||||||
FirestoreRecyclerOptions.Builder<UserData>().setQuery(query, UserData::class.java)
|
|
||||||
.build()
|
|
||||||
rvAdapter = UserListAdapter(recyclerViewOptions, binding.root)
|
|
||||||
binding.rvOrder.adapter = rvAdapter
|
|
||||||
rvAdapter.startListening()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveUserId(userId: String) {
|
private fun saveUserId(userId: String) {
|
||||||
with(sharedPreference.edit()) {
|
with(sharedPreference.edit()) {
|
||||||
putString(Constants.USER_ID, userId)
|
putString(Constants.USER_ID, userId)
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun logoutUser(context: Context) {
|
private fun logoutUser(context: Context) {
|
||||||
val builder = AlertDialog.Builder(context)
|
val builder = AlertDialog.Builder(context)
|
||||||
builder.setTitle("Log Out")
|
builder.setTitle(R.string.log_out)
|
||||||
builder.setMessage("Do you want to LogOut the Application?")
|
builder.setMessage(R.string.do_log_out)
|
||||||
builder.setPositiveButton("Yes") { dialog, _ ->
|
builder.setPositiveButton(R.string.yes) { dialog, _ ->
|
||||||
saveUserId("")
|
saveUserId("")
|
||||||
findNavController().navigate(R.id.action_nav_home_to_loginFragment)
|
findNavController().navigate(R.id.action_nav_home_to_loginFragment)
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
builder.setNegativeButton("No") { dialog, _ ->
|
builder.setNegativeButton(R.string.no) { dialog, _ ->
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
val dialog = builder.create()
|
val dialog = builder.create()
|
||||||
dialog.show()
|
dialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getData(search: String?, field: String) {
|
private fun getData(search: String?, field: String) {
|
||||||
val capitalizedSearch = search?.replaceFirstChar {
|
val userSearchTrace = Firebase.performance.newTrace("user_search_trace")
|
||||||
|
userSearchTrace.start()
|
||||||
|
|
||||||
|
search?.replaceFirstChar {
|
||||||
if (search.lowercase()
|
if (search.lowercase()
|
||||||
.startsWith(it.lowercase())
|
.startsWith(it.lowercase())
|
||||||
) it.titlecase(Locale.getDefault()) else it.toString()
|
) it.titlecase(Locale.getDefault()) else it.toString()
|
||||||
|
|
||||||
}
|
}
|
||||||
val query = Firebase.firestore.collection("patientData").orderBy(field).startAt(search)
|
val currentDate = Date()
|
||||||
.endAt(search + "\uf8ff")
|
val dateFormat = SimpleDateFormat("yyyyMMdd")
|
||||||
|
val partition = dateFormat.format(currentDate)
|
||||||
|
val searchTerm = partition + search
|
||||||
|
val searchField = field + "Search"
|
||||||
|
val query =
|
||||||
|
Firebase.firestore.collection("patientData").orderBy(searchField).startAt(searchTerm)
|
||||||
|
.endAt(searchTerm + "\uf8ff")
|
||||||
|
query.get().addOnSuccessListener {
|
||||||
|
userSearchTrace.stop()
|
||||||
|
}
|
||||||
val recyclerViewOptions =
|
val recyclerViewOptions =
|
||||||
FirestoreRecyclerOptions.Builder<UserData>().setQuery(query, UserData::class.java)
|
FirestoreRecyclerOptions.Builder<UserData>().setQuery(query, UserData::class.java)
|
||||||
.build()
|
.build()
|
||||||
rvAdapter = UserListAdapter(recyclerViewOptions, binding.root)
|
val bm = requireContext().getSystemService(BATTERY_SERVICE) as BatteryManager
|
||||||
|
batLevel = bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
|
||||||
|
|
||||||
|
rvAdapter = view?.let {
|
||||||
|
UserListAdapter(
|
||||||
|
requireContext(),
|
||||||
|
hemoCubeViewModel,
|
||||||
|
recyclerViewOptions,
|
||||||
|
it,
|
||||||
|
batLevel,
|
||||||
|
requireActivity()
|
||||||
|
)
|
||||||
|
}!!
|
||||||
binding.rvOrder.adapter = rvAdapter
|
binding.rvOrder.adapter = rvAdapter
|
||||||
rvAdapter.startListening()
|
rvAdapter.startListening()
|
||||||
|
|
||||||
|
userSearchTrace.stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setSearch() {
|
private fun setSearch() {
|
||||||
binding.searchProduct.setOnQueryTextListener(object :
|
binding.searchProduct.setOnQueryTextListener(object :
|
||||||
androidx.appcompat.widget.SearchView.OnQueryTextListener {
|
androidx.appcompat.widget.SearchView.OnQueryTextListener {
|
||||||
@@ -162,13 +416,16 @@ class HomeFragment : Fragment() {
|
|||||||
binding.aadharIdRadioButton.isChecked -> "aadharId"
|
binding.aadharIdRadioButton.isChecked -> "aadharId"
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
field?.let { getData(query, it) }
|
field?.let { getData(query, it) }
|
||||||
false
|
false
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
loadUserData()
|
loadUserData()
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onQueryTextChange(query: String?): Boolean {
|
override fun onQueryTextChange(query: String?): Boolean {
|
||||||
return if (!query.isNullOrEmpty()) {
|
return if (!query.isNullOrEmpty()) {
|
||||||
val field = when {
|
val field = when {
|
||||||
@@ -186,6 +443,7 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkForLocalDBData() {
|
private fun checkForLocalDBData() {
|
||||||
viewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
viewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
val uploadDataVisibility = if (userDataList.isEmpty()) View.GONE else View.VISIBLE
|
val uploadDataVisibility = if (userDataList.isEmpty()) View.GONE else View.VISIBLE
|
||||||
@@ -193,10 +451,12 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
val uploadDataVisibility = if (userDataList.isEmpty()) View.GONE else View.VISIBLE
|
val uploadDataVisibility =
|
||||||
|
if (userDataList.any { !it.localFlag && it.testStatus == true }) View.VISIBLE else View.GONE
|
||||||
binding.uploadData.visibility = uploadDataVisibility
|
binding.uploadData.visibility = uploadDataVisibility
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showUploadDialog(context: Context) {
|
private fun showUploadDialog(context: Context) {
|
||||||
val builder = AlertDialog.Builder(context)
|
val builder = AlertDialog.Builder(context)
|
||||||
builder.setTitle(R.string.upload_db_registration_title)
|
builder.setTitle(R.string.upload_db_registration_title)
|
||||||
@@ -225,28 +485,19 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
requireContext(),
|
requireContext(), R.string.upload_success_message, Toast.LENGTH_SHORT
|
||||||
R.string.upload_success_message,
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
if (userDataList.isEmpty()) {
|
userDataList.forEach { userData ->
|
||||||
dialog.dismiss()
|
if (!userData.localFlag) {
|
||||||
} else {
|
|
||||||
userDataList.forEach { userData ->
|
|
||||||
userData.localFlag = true
|
userData.localFlag = true
|
||||||
hemoCubeViewModel.bulkAddResultTestToDb(userData)
|
hemoCubeViewModel.bulkAddResultTestToDb(userData)
|
||||||
}
|
}
|
||||||
dialog.dismiss()
|
|
||||||
Toast.makeText(
|
|
||||||
requireContext(),
|
|
||||||
R.string.upload_success_message,
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
}
|
||||||
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +511,7 @@ class HomeFragment : Fragment() {
|
|||||||
|
|
||||||
private fun deleteHemoCubeIncompleteRegistrations(userDataList: List<HemoCubeTestData>) {
|
private fun deleteHemoCubeIncompleteRegistrations(userDataList: List<HemoCubeTestData>) {
|
||||||
userDataList.forEach { userData ->
|
userDataList.forEach { userData ->
|
||||||
if (userData.testTime?.isEmpty() == false) {
|
if (userData._id.isEmpty()) {
|
||||||
hemoCubeViewModel.deleteById(userData._id)
|
hemoCubeViewModel.deleteById(userData._id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,42 +1,66 @@
|
|||||||
package com.example.hpostesting.presentation.dashboard
|
package com.example.hpostesting.presentation.dashboard
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.pm.PackageManager
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.widget.Toast
|
||||||
import android.view.View
|
import androidx.preference.ListPreference
|
||||||
import android.view.ViewGroup
|
import androidx.preference.Preference
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.dashboard.ui.slideshow.SlideshowViewModel
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentSlideshowBinding
|
|
||||||
|
|
||||||
class SlideshowFragment : Fragment() {
|
private var isLanguageChanged = false
|
||||||
|
|
||||||
private var _binding: FragmentSlideshowBinding? = null
|
class SlideshowFragment : PreferenceFragmentCompat() {
|
||||||
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
|
val preferenceScreen = preferenceManager.createPreferenceScreen(requireContext())
|
||||||
|
|
||||||
// This property is only valid between onCreateView and
|
val languagePreference = ListPreference(requireContext())
|
||||||
// onDestroyView.
|
languagePreference.key = "language_preference"
|
||||||
private val binding get() = _binding!!
|
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")
|
||||||
|
|
||||||
override fun onCreateView(
|
languagePreference.onPreferenceChangeListener =
|
||||||
inflater: LayoutInflater,
|
Preference.OnPreferenceChangeListener { _, newValue ->
|
||||||
container: ViewGroup?,
|
val languageCode = newValue as String
|
||||||
savedInstanceState: Bundle?
|
updateLanguage(requireContext(), languageCode)
|
||||||
): View {
|
true
|
||||||
val slideshowViewModel =
|
}
|
||||||
ViewModelProvider(this).get(SlideshowViewModel::class.java)
|
|
||||||
|
|
||||||
_binding = FragmentSlideshowBinding.inflate(inflater, container, false)
|
preferenceScreen.addPreference(languagePreference)
|
||||||
val root: View = binding.root
|
setPreferenceScreen(preferenceScreen)
|
||||||
|
|
||||||
// val textView: TextView = binding.textSlideshow
|
// App Version Preference
|
||||||
// slideshowViewModel.text.observe(viewLifecycleOwner) {
|
val appVersionPreference = Preference(requireContext())
|
||||||
// textView.text = it
|
appVersionPreference.title = "App Version"
|
||||||
// }
|
appVersionPreference.summary = getAppVersion(requireContext())
|
||||||
return root
|
|
||||||
|
preferenceScreen.addPreference(languagePreference)
|
||||||
|
preferenceScreen.addPreference(appVersionPreference)
|
||||||
|
setPreferenceScreen(preferenceScreen)
|
||||||
|
|
||||||
|
if (isLanguageChanged) {
|
||||||
|
Toast.makeText(requireContext(), R.string.language_update, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
private fun updateLanguage(context: Context, languageCode: String) {
|
||||||
super.onDestroyView()
|
LanguageManager.persistLanguagePreference(context, languageCode)
|
||||||
_binding = null
|
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"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,8 @@ class LoginFragment : Fragment() {
|
|||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
): View {
|
): View {
|
||||||
_binding = FragmentLoginBinding.inflate(inflater, container, false)
|
_binding = FragmentLoginBinding.inflate(inflater, container, false)
|
||||||
sharedPreference = requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
sharedPreference =
|
||||||
|
requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,10 +48,10 @@ class LoginFragment : Fragment() {
|
|||||||
performLogin(loginId, password)
|
performLogin(loginId, password)
|
||||||
} else {
|
} else {
|
||||||
if (loginId.isBlank()) {
|
if (loginId.isBlank()) {
|
||||||
binding.loginId.error = "Please enter a proper Login ID"
|
binding.loginId.error = R.string.enter_proper_login_id.toString()
|
||||||
}
|
}
|
||||||
if (password.isBlank()) {
|
if (password.isBlank()) {
|
||||||
binding.password.error = "Please enter a proper password"
|
binding.password.error = R.string.enter_proper_password.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,10 +73,10 @@ class LoginFragment : Fragment() {
|
|||||||
navigateToHomeFragment()
|
navigateToHomeFragment()
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(requireContext(), "Wrong Password", Toast.LENGTH_SHORT).show()
|
Toast.makeText(requireContext(), R.string.wrong_password, Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Toast.makeText(requireContext(), "Wrong UserID", Toast.LENGTH_SHORT).show()
|
Toast.makeText(requireContext(), R.string.wrong_user_id, Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveUserId(userId: String) {
|
private fun saveUserId(userId: String) {
|
||||||
|
|||||||
@@ -0,0 +1,183 @@
|
|||||||
|
package com.example.hpostesting.presentation.diagnostics
|
||||||
|
|
||||||
|
import android.app.PendingIntent
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
|
import android.content.ComponentName
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.IntentFilter
|
||||||
|
import android.content.ServiceConnection
|
||||||
|
import android.hardware.usb.UsbDevice
|
||||||
|
import android.hardware.usb.UsbDeviceConnection
|
||||||
|
import android.hardware.usb.UsbManager
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.os.IBinder
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.Menu
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.activity.viewModels
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.view.get
|
||||||
|
import com.example.hpostesting.data.DataHolder
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
|
import com.example.hpostesting.presentation.hemocube.HemoCubeFragment
|
||||||
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
|
import com.example.hpostesting.presentation.testRight.UsbService
|
||||||
|
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||||
|
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||||
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
import `in`.sminnovations.hpostesting.R
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.ActivityDiagnosticsBinding
|
||||||
|
|
||||||
|
@AndroidEntryPoint
|
||||||
|
class DiagnosticsActivity : AppCompatActivity() {
|
||||||
|
private lateinit var binding: ActivityDiagnosticsBinding
|
||||||
|
val viewModel: DiagnosticsViewModel by viewModels()
|
||||||
|
private var myMenu: Menu? = null
|
||||||
|
|
||||||
|
private lateinit var mDriver: UsbSerialDriver
|
||||||
|
private var mConnection: UsbDeviceConnection? = null
|
||||||
|
lateinit var mService: UsbService
|
||||||
|
|
||||||
|
private val TAG = "HemoCube"
|
||||||
|
|
||||||
|
private val broadcastReceiver = object : BroadcastReceiver() {
|
||||||
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
|
|
||||||
|
synchronized(this) {
|
||||||
|
val device: UsbDevice? = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE)
|
||||||
|
|
||||||
|
if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
|
||||||
|
device?.apply {
|
||||||
|
connectUsb(true)
|
||||||
|
DataHolder.usbConnected.postValue(true)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
onErrorReported("permission denied for device")
|
||||||
|
DataHolder.usbConnected.postValue(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private val connection = object : ServiceConnection {
|
||||||
|
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
||||||
|
val binder = service as UsbService.UsbServiceBinder
|
||||||
|
mService = binder.getService()
|
||||||
|
viewModel.isServiceConnected = true
|
||||||
|
mConnection.let { mService.connect(mDriver, mConnection!!) }
|
||||||
|
moveToNext()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onServiceDisconnected(arg0: ComponentName) {
|
||||||
|
viewModel.isServiceConnected = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun attachBaseContext(newBase: Context?) {
|
||||||
|
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||||
|
LanguageManager.setLocale(newBase, languageCode)
|
||||||
|
super.attachBaseContext(newBase)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
binding = ActivityDiagnosticsBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
|
// setSupportActionBar(binding.myToolbar)
|
||||||
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
|
setupListener()
|
||||||
|
connectUsb(false)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupListener() {
|
||||||
|
DataHolder.usbConnected.observe(this) {
|
||||||
|
Log.d("USB OBSERVE", "HemoCube called -> $it")
|
||||||
|
if (it) {
|
||||||
|
myMenu?.get(0)?.icon =
|
||||||
|
ContextCompat.getDrawable(this, R.drawable.ic_baseline_usb_24)
|
||||||
|
} else {
|
||||||
|
myMenu?.get(0)?.icon =
|
||||||
|
ContextCompat.getDrawable(this, R.drawable.ic_baseline_usb_off_24)
|
||||||
|
Toast.makeText(this, "Device is Disconnected", Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
open fun connectUsb(permissionGranted: Boolean) {
|
||||||
|
Log.d(TAG, "connectUsb() called, permission variable = $permissionGranted")
|
||||||
|
val manager = getSystemService(Context.USB_SERVICE) as UsbManager
|
||||||
|
val availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(manager)
|
||||||
|
|
||||||
|
if (availableDrivers.isEmpty()) {
|
||||||
|
onErrorReported("No Device is Connected")
|
||||||
|
} else {
|
||||||
|
mDriver = availableDrivers[0]
|
||||||
|
mConnection = manager.openDevice(mDriver.device)
|
||||||
|
|
||||||
|
if (mConnection == null) {
|
||||||
|
requestUserPermission(manager, mDriver.device)
|
||||||
|
} else {
|
||||||
|
setupService()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun onErrorReported(msg: String) {
|
||||||
|
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
|
||||||
|
if (!isFinishing) onBackPressed()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun moveToNext() {
|
||||||
|
if (supportFragmentManager.isDestroyed) return
|
||||||
|
|
||||||
|
supportFragmentManager.beginTransaction().replace(binding.fgDiagnostics.id, DiagnosticsFragment())
|
||||||
|
.commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
||||||
|
val mPendingIntent: PendingIntent
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||||
|
mPendingIntent = PendingIntent.getBroadcast(
|
||||||
|
this, 0, Intent(Constants.HOMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
mPendingIntent = PendingIntent.getBroadcast(
|
||||||
|
this,
|
||||||
|
0,
|
||||||
|
Intent(Constants.HOMOCUBE_USB_PERMISSION),
|
||||||
|
PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
val filter = IntentFilter(Constants.HOMOCUBE_USB_PERMISSION)
|
||||||
|
registerReceiver(broadcastReceiver, filter)
|
||||||
|
manager.requestPermission(device, mPendingIntent)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun setupService() {
|
||||||
|
val intent = Intent(this, UsbService::class.java)
|
||||||
|
bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||||
|
menuInflater.inflate(R.menu.my_menu, menu)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
override fun onDestroy() {
|
||||||
|
super.onDestroy()
|
||||||
|
if (viewModel.isServiceConnected) {
|
||||||
|
mService.disconnect()
|
||||||
|
unbindService(connection)
|
||||||
|
viewModel.isServiceConnected = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,197 @@
|
|||||||
|
package com.example.hpostesting.presentation.diagnostics
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.fragment.app.activityViewModels
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
|
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
||||||
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
|
import com.example.hpostesting.presentation.UsbServiceListener
|
||||||
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
|
import com.google.firebase.ktx.Firebase
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.FragmentDiagnosticsBinding
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Calendar
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
|
class DiagnosticsFragment : Fragment() {
|
||||||
|
|
||||||
|
private lateinit var binding: FragmentDiagnosticsBinding
|
||||||
|
private val diagnosticsViewModel: DiagnosticsViewModel by activityViewModels()
|
||||||
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
|
private var currentDeviceData: DeviceData? = null
|
||||||
|
private var resultData: String = ""
|
||||||
|
private val messages = MutableLiveData<String>()
|
||||||
|
private var startListening = MutableLiveData(false)
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
||||||
|
): View {
|
||||||
|
binding = FragmentDiagnosticsBinding.inflate(inflater, container, false)
|
||||||
|
sharedPreferences =
|
||||||
|
requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
initViews()
|
||||||
|
observeViewModel()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun initViews() {
|
||||||
|
binding.btnSubmit.visibility = View.GONE
|
||||||
|
listenToHemoCube()
|
||||||
|
getDeviceId()
|
||||||
|
binding.btnSubmit.setOnClickListener {
|
||||||
|
binding.btnSubmit.visibility = View.GONE
|
||||||
|
runDeviceDiagnostics()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun observeViewModel() {
|
||||||
|
|
||||||
|
diagnosticsViewModel.deviceData.observe(viewLifecycleOwner) {
|
||||||
|
currentDeviceData = it
|
||||||
|
}
|
||||||
|
|
||||||
|
messages.observe(viewLifecycleOwner) {
|
||||||
|
binding.tvSubtitle4.text = it
|
||||||
|
Log.e("diagnostics",binding.tvSubtitle4.text.toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
diagnosticsViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
||||||
|
if (result == "Success") {
|
||||||
|
showToast("Diagnostics data uploaded successfully")
|
||||||
|
}
|
||||||
|
if (result == "Local") {
|
||||||
|
showToast("Diagnostics uploading failed, note it down manually")
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.progressBar.visibility = View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getDeviceId() {
|
||||||
|
diagnosticsViewModel.progressBar.postValue(true)
|
||||||
|
(activity as DiagnosticsActivity).mService.sendAndListenToHemoCube(
|
||||||
|
HemoCubeCommands.getDeviceId,
|
||||||
|
object : UsbServiceListener {
|
||||||
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
|
data?.let {
|
||||||
|
val stringData = String(it)
|
||||||
|
diagnosticsViewModel.messages.postValue(stringData)
|
||||||
|
binding.tvSubtitle4.text = stringData
|
||||||
|
}
|
||||||
|
}
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
diagnosticsViewModel.progressBar.postValue(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun runDeviceDiagnostics() {
|
||||||
|
diagnosticsViewModel.progressBar.postValue(true)
|
||||||
|
(activity as DiagnosticsActivity).mService.sendAndListenToHemoCube(
|
||||||
|
HemoCubeCommands.runDiagnostics,
|
||||||
|
object : UsbServiceListener {
|
||||||
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
diagnosticsViewModel.progressBar.postValue(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun listenToHemoCube() {
|
||||||
|
|
||||||
|
val fullReadOutput = StringBuilder()
|
||||||
|
startListening.postValue(true)
|
||||||
|
|
||||||
|
try {
|
||||||
|
(activity as DiagnosticsActivity).mService.listenToHemoCube(object : UsbServiceListener {
|
||||||
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
|
data?.let {
|
||||||
|
val stringData = String(it)
|
||||||
|
diagnosticsViewModel.messages.postValue(stringData)
|
||||||
|
fullReadOutput.append(stringData)
|
||||||
|
resultData += stringData
|
||||||
|
binding.tvSubtitle4.text = resultData
|
||||||
|
if (stringData.contains("SN")) {
|
||||||
|
val slData = stringData.split(" ")
|
||||||
|
if (slData.size > 1) {
|
||||||
|
val hardwareId = slData[1].trim()
|
||||||
|
with(sharedPreferences.edit()) {
|
||||||
|
putString(Constants.DEVICE_ID, hardwareId)
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
binding.btnSubmit.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resultData.contains("END") || fullReadOutput.contains("END")) {
|
||||||
|
diagnosticsViewModel.addDiagnosticsDataToDb(DiagnosticsData(
|
||||||
|
deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString(),
|
||||||
|
deviceData = resultData,
|
||||||
|
runTime = SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
).format(Calendar.getInstance().time)
|
||||||
|
))
|
||||||
|
}
|
||||||
|
// val inputData = mutableListOf<String>()
|
||||||
|
// while (true) {
|
||||||
|
// if (fullReadOutput.toString().lowercase() == "end") {
|
||||||
|
// break
|
||||||
|
// }
|
||||||
|
// inputData.add(fullReadOutput.toString())
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// val parsedData = parseData(inputData)
|
||||||
|
// Log.i("D-Data", parsedData.toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
diagnosticsViewModel.progressBar.postValue(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Firebase.crashlytics.recordException(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun parseData(inputData: List<String>): List<Pair<String, String>> {
|
||||||
|
val pattern = Regex("([A-Z]+)\\s(\\d+)")
|
||||||
|
val parsedData = mutableListOf<Pair<String, String>>()
|
||||||
|
|
||||||
|
for (item in inputData) {
|
||||||
|
val matchResult = pattern.find(item)
|
||||||
|
if (matchResult != null) {
|
||||||
|
val (letters, numbers) = matchResult.destructured
|
||||||
|
parsedData.add(Pair(letters, numbers))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return parsedData
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showToast(message: String) {
|
||||||
|
Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package com.example.hpostesting.presentation.diagnostics
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import androidx.lifecycle.viewModelScope
|
||||||
|
import com.example.hpostesting.data.DataHolder
|
||||||
|
import com.example.hpostesting.data.NetworkStatusLiveData
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||||
|
import com.example.hpostesting.data.model.Response
|
||||||
|
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
||||||
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
|
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
||||||
|
import com.example.hpostesting.data.repository.DatabaseRepository
|
||||||
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Calendar
|
||||||
|
import java.util.Locale
|
||||||
|
import javax.inject.Inject
|
||||||
|
@HiltViewModel
|
||||||
|
class DiagnosticsViewModel @Inject constructor(
|
||||||
|
private val hemoCubeDao: HemoCubeDao,
|
||||||
|
private val repository: DatabaseRepository,
|
||||||
|
context: Context
|
||||||
|
) : ViewModel() {
|
||||||
|
var isServiceConnected = false
|
||||||
|
val progressBar = MutableLiveData(false)
|
||||||
|
val messages = MutableLiveData<String>()
|
||||||
|
private val sharedPreference: SharedPreferences =
|
||||||
|
context.getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||||
|
|
||||||
|
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||||
|
val allUserData = hemoCubeDao.getAll()
|
||||||
|
val deviceData = MutableLiveData<DeviceData?>()
|
||||||
|
val networkStatusLiveData: LiveData<Boolean>
|
||||||
|
get() = _networkStatusLiveData
|
||||||
|
val fireBaseUpload = MutableLiveData<String>()
|
||||||
|
|
||||||
|
fun addDiagnosticsDataToDb(data: DiagnosticsData) {
|
||||||
|
viewModelScope.launch {
|
||||||
|
try {
|
||||||
|
when (val response = repository.addDiagnostics(data)) {
|
||||||
|
is Response.Success -> {
|
||||||
|
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||||
|
fireBaseUpload.postValue("Success")
|
||||||
|
}
|
||||||
|
|
||||||
|
is Response.Error -> {
|
||||||
|
Log.e("Testdb", "Error uploading data to Firestore: $response")
|
||||||
|
fireBaseUpload.postValue("Error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("Testdb", "Exception during data upload: ${e.message}")
|
||||||
|
fireBaseUpload.postValue("Error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.example.hpostesting.presentation.hemocube
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver
|
||||||
|
import android.content.ComponentName
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.ServiceConnection
|
||||||
|
import android.hardware.usb.UsbDevice
|
||||||
|
import android.hardware.usb.UsbDeviceConnection
|
||||||
|
import android.hardware.usb.UsbManager
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.os.IBinder
|
||||||
|
import android.view.Menu
|
||||||
|
import androidx.activity.viewModels
|
||||||
|
import com.example.hpostesting.data.DataHolder
|
||||||
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
|
import com.example.hpostesting.presentation.testRight.UsbService
|
||||||
|
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||||
|
import `in`.sminnovations.hpostesting.R
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.ActivityDigitalCardBinding
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.ActivityHemocubeBinding
|
||||||
|
|
||||||
|
class DigitalCardActivity : AppCompatActivity() {
|
||||||
|
|
||||||
|
private lateinit var binding: ActivityDigitalCardBinding
|
||||||
|
|
||||||
|
override fun attachBaseContext(newBase: Context?) {
|
||||||
|
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||||
|
LanguageManager.setLocale(newBase, languageCode)
|
||||||
|
super.attachBaseContext(newBase)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
binding = ActivityDigitalCardBinding.inflate(layoutInflater)
|
||||||
|
setContentView(binding.root)
|
||||||
|
moveToNext()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun moveToNext() {
|
||||||
|
if (supportFragmentManager.isDestroyed) return
|
||||||
|
supportFragmentManager.beginTransaction().replace(binding.fghemocube.id, DigitalCardFragment())
|
||||||
|
.commit()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
package com.example.hpostesting.presentation.hemocube
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.fragment.app.activityViewModels
|
||||||
|
import com.example.hpostesting.data.DataHolder
|
||||||
|
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
||||||
|
import `in`.sminnovations.hpostesting.R
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.FragmentDigitalCardBinding
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.FragmentHemoCubeReferenceBinding
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Calendar
|
||||||
|
import java.util.Date
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
|
class DigitalCardFragment : Fragment() {
|
||||||
|
private lateinit var binding: FragmentDigitalCardBinding
|
||||||
|
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
||||||
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
|
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||||
|
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
||||||
|
): View {
|
||||||
|
binding = FragmentDigitalCardBinding.inflate(inflater, container, false)
|
||||||
|
sharedPreferences =
|
||||||
|
requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||||
|
return binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
initViews()
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
|
private fun initViews() {
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
binding.progressBar.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
Log.d("DigitalCardFragment", "Name: ${DataHolder.hemoCubeTestData?.name}")
|
||||||
|
Log.d("DigitalCardFragment", "DOB: ${testDetails?.birthYear}")
|
||||||
|
Log.d("DigitalCardFragment", "Gender: ${testDetails?.gender}")
|
||||||
|
Log.d("DigitalCardFragment", "State: ${testDetails?.state}")
|
||||||
|
Log.d("DigitalCardFragment", "ABHA ID: ${testDetails?.abhaId}")
|
||||||
|
Log.d("DigitalCardFragment", "Blood Group: ${testDetails?.bloodGroup}")
|
||||||
|
Log.d("DigitalCardFragment", "Sickle-Cell: ${testDetails?.classificationResult}")
|
||||||
|
// Log.d("DigitalCardFragment", "Issue Date: $formattedDate")
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
binding.progressBar.visibility = View.GONE
|
||||||
|
binding.name.text = "Name: ${DataHolder.hemoCubeTestData?.name}"
|
||||||
|
binding.dob.text = "DOB: ${testDetails?.birthYear}"
|
||||||
|
binding.gender.text = "Gender: ${testDetails?.gender}"
|
||||||
|
binding.State.text = "State: ${testDetails?.state}"
|
||||||
|
binding.abhaid.text = "ABHA ID: ${testDetails?.abhaId}"
|
||||||
|
binding.blood.text = "Blood Group: ${testDetails?.bloodGroup}"
|
||||||
|
binding.sicklecell.text = "Sickle-Cell: ${DataHolder.hemoCubeTestData?.prdClassification.toString()}"
|
||||||
|
|
||||||
|
}
|
||||||
|
// Update the UI with the fetched details
|
||||||
|
val originalDateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
||||||
|
val originalDate: Date? = originalDateFormat.parse(SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
).format(Calendar.getInstance().time))
|
||||||
|
|
||||||
|
// Format the parsed date to "mm date, year"
|
||||||
|
val desiredDateFormat = SimpleDateFormat("MMM dd, yyyy", Locale.getDefault())
|
||||||
|
val formattedDate: String = originalDate?.let { desiredDateFormat.format(it) } ?: "N/A"
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
binding.issueDate.text = "Issue Date: ${formattedDate}"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,10 @@
|
|||||||
package com.example.hpostesting.presentation.hemocube
|
package com.example.hpostesting.presentation.hemocube
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.content.IntentFilter
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
|
import android.os.BatteryManager
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
@@ -9,16 +12,35 @@ import androidx.lifecycle.ViewModel
|
|||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.NetworkStatusLiveData
|
import com.example.hpostesting.data.NetworkStatusLiveData
|
||||||
|
import com.example.hpostesting.data.Result
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
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.deviceprovision.DeviceProvisionRequest
|
||||||
|
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionResponse
|
||||||
|
import com.example.hpostesting.data.model.log.UploadLogsResponse
|
||||||
|
import com.example.hpostesting.data.model.login.LoginRequest
|
||||||
|
import com.example.hpostesting.data.model.login.LoginResponse
|
||||||
|
import com.example.hpostesting.data.model.molbioresult.MolbioV2Result
|
||||||
|
import com.example.hpostesting.data.model.molbioresult.MolbioV2ResultRequest
|
||||||
|
import com.example.hpostesting.data.model.molbioresult.MolbioV2ResultResponse
|
||||||
|
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.data.model.patient.HemoCubeTestData
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
|
||||||
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
||||||
|
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
||||||
|
import com.example.hpostesting.data.model.updates.CheckUpdateResponse
|
||||||
|
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
||||||
import com.example.hpostesting.data.repository.DatabaseRepository
|
import com.example.hpostesting.data.repository.DatabaseRepository
|
||||||
|
import com.example.hpostesting.data.repository.Repository
|
||||||
|
import com.example.hpostesting.domain.LogFileManager
|
||||||
|
import com.example.hpostesting.presentation.hemocube.HemoCubeFragmentDirections.Companion
|
||||||
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.MultipartBody
|
||||||
|
import okhttp3.RequestBody.Companion.asRequestBody
|
||||||
|
import okhttp3.ResponseBody
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
@@ -27,50 +49,133 @@ import javax.inject.Inject
|
|||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class HemoCubeViewModel @Inject constructor(
|
class HemoCubeViewModel @Inject constructor(
|
||||||
private val hemoCubeDao: HemoCubeDao,
|
private val hemoCubeDao: HemoCubeDao,
|
||||||
private val repository: DatabaseRepository,
|
private val repository: Repository,
|
||||||
context: Context,
|
private val databaseRepository: DatabaseRepository,
|
||||||
|
private val logFileManager: LogFileManager,
|
||||||
|
context: Context
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
var isServiceConnected = false
|
var isServiceConnected = false
|
||||||
val progressBar = MutableLiveData(false)
|
val progressBar = MutableLiveData(false)
|
||||||
val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||||
val messages = MutableLiveData<String>()
|
val messages = MutableLiveData<String>()
|
||||||
private val sharedPreference: SharedPreferences = context.getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
private val sharedPreference: SharedPreferences =
|
||||||
|
context.getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||||
|
|
||||||
|
val deviceProvisionResponse = MutableLiveData<Result<DeviceProvisionResponse>>()
|
||||||
|
|
||||||
|
val loginResponse = MutableLiveData<Result<LoginResponse>>()
|
||||||
|
|
||||||
|
val resultUpload = MutableLiveData<Result<MolbioV2ResultResponse>>()
|
||||||
|
|
||||||
|
val checkUpdate = MutableLiveData<Result<CheckUpdateResponse>>()
|
||||||
|
|
||||||
|
val deviceUpdate = MutableLiveData<Result<ResponseBody>>()
|
||||||
|
|
||||||
|
val uploadLogs = MutableLiveData<Result<UploadLogsResponse>?>()
|
||||||
|
|
||||||
|
|
||||||
// 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 = NetworkStatusLiveData(context)
|
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||||
val allUserData = hemoCubeDao.getAll()
|
val allUserData = hemoCubeDao.getAll()
|
||||||
val deviceData = MutableLiveData<DeviceData?>()
|
val deviceData = MutableLiveData<DeviceData?>()
|
||||||
|
|
||||||
|
|
||||||
val networkStatusLiveData: LiveData<Boolean>
|
val networkStatusLiveData: LiveData<Boolean>
|
||||||
get() = _networkStatusLiveData
|
get() = _networkStatusLiveData
|
||||||
|
val deviceMessages = MutableLiveData<String?>()
|
||||||
val fireBaseUpload = MutableLiveData<String>()
|
val fireBaseUpload = MutableLiveData<String>()
|
||||||
fun uploadHemoCubeResultToDatabase(isOnline: Boolean, testStatus: Boolean, kitSerial: String?) =
|
val fireBaseBulkUpload = MutableLiveData<String>()
|
||||||
viewModelScope.launch {
|
|
||||||
if (kitSerial != null) {
|
|
||||||
testDetails?.kitSerial = kitSerial
|
|
||||||
}
|
|
||||||
testDetails?.testStatus = testStatus
|
|
||||||
|
|
||||||
try {
|
private val batteryStatus: Intent? =
|
||||||
if (isOnline) {
|
IntentFilter(Intent.ACTION_BATTERY_CHANGED).let { ifilter ->
|
||||||
addResultTestToDb()
|
context.registerReceiver(null, ifilter)
|
||||||
} else {
|
}
|
||||||
testDetails?.testTime = SimpleDateFormat(
|
|
||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
fun uploadHemoCubeResultToDatabase(
|
||||||
).format(Calendar.getInstance().time)
|
isOnline: Boolean, testStatus: Boolean, kitSerial: String?
|
||||||
hemoCubeDao.insertAll(testDetails!!)
|
) = viewModelScope.launch {
|
||||||
fireBaseUpload.postValue("Local")
|
if (kitSerial != null) {
|
||||||
}
|
testDetails?.kitSerial = kitSerial
|
||||||
} catch (e: Exception) {
|
}
|
||||||
Log.e("Testdb", "Upload failed: ${e.message}")
|
testDetails?.testStatus = testStatus
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (isOnline) {
|
||||||
|
parseData()
|
||||||
|
addResultTestToDb()
|
||||||
|
} else {
|
||||||
|
parseData()
|
||||||
|
testDetails?.testTime = SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
).format(Calendar.getInstance().time)
|
||||||
|
hemoCubeDao.insertAll(testDetails!!)
|
||||||
|
fireBaseUpload.postValue("Local")
|
||||||
}
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("Testdb", "Upload failed: ${e.message}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun deviceProvision(deviceProvisionRequest: DeviceProvisionRequest) = viewModelScope.launch {
|
||||||
|
deviceProvisionResponse.postValue(Result.Loading())
|
||||||
|
databaseRepository.deviceProvision(deviceProvisionRequest).let {
|
||||||
|
deviceProvisionResponse.postValue(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun login(loginRequest: LoginRequest) = viewModelScope.launch {
|
||||||
|
loginResponse.postValue(Result.Loading())
|
||||||
|
databaseRepository.login(loginRequest).let {
|
||||||
|
loginResponse.postValue(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun uploadResult(molbioV2ResultRequest: MolbioV2ResultRequest) = viewModelScope.launch {
|
||||||
|
resultUpload.postValue(Result.Loading())
|
||||||
|
databaseRepository.uploadResults(molbioV2ResultRequest).let {
|
||||||
|
resultUpload.postValue(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun checkUpdate(checkUpdateRequest: CheckUpdateRequest) = viewModelScope.launch {
|
||||||
|
checkUpdate.postValue(Result.Loading())
|
||||||
|
databaseRepository.checkUpdate(checkUpdateRequest).let {
|
||||||
|
checkUpdate.postValue(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun deviceUpdate(deviceUpdateRequest: DeviceUpdateRequest) = viewModelScope.launch {
|
||||||
|
deviceUpdate.postValue(Result.Loading())
|
||||||
|
databaseRepository.deviceUpdate(deviceUpdateRequest).let {
|
||||||
|
deviceUpdate.postValue(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun uploadLogs() = viewModelScope.launch {
|
||||||
|
uploadLogs.postValue(Result.Loading())
|
||||||
|
val logFile = logFileManager.createLogFile().let { file ->
|
||||||
|
val requestBody = file?.asRequestBody("multipart/form-data".toMediaTypeOrNull())
|
||||||
|
val multipartFile =
|
||||||
|
requestBody?.let { MultipartBody.Part.createFormData("logFile", file?.name, it) }
|
||||||
|
multipartFile?.let { partFile ->
|
||||||
|
databaseRepository.uploadLogs(partFile).let { result ->
|
||||||
|
uploadLogs.postValue(result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun uploadHemoCubeResultToDatabaseforbuffercheckN(bufferCheckData: BufferCheckData) =
|
||||||
|
viewModelScope.launch {
|
||||||
|
addResultTestToDbforbuffercheck(bufferCheckData)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getDeviceData(deviceId: String?) = viewModelScope.launch {
|
fun getDeviceData(deviceId: String?) = viewModelScope.launch {
|
||||||
deviceData.postValue(deviceId?.let { repository.getDeviceDataById(it) })
|
deviceData.postValue(deviceId?.let { repository.getDeviceDataById(it) })
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addResultTestToDb() {
|
private fun parseData() {
|
||||||
testDetails?.deviceRatio = DataHolder.hemocubeResult
|
testDetails?.deviceRatio = DataHolder.hemocubeResult
|
||||||
testDetails?.resultData = DataHolder.hemoCubeTestData?.resultData.toString()
|
testDetails?.resultData = DataHolder.hemoCubeTestData?.resultData.toString()
|
||||||
testDetails?.location = DataHolder.location
|
testDetails?.location = DataHolder.location
|
||||||
@@ -79,17 +184,39 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
).format(Calendar.getInstance().time)
|
).format(Calendar.getInstance().time)
|
||||||
testDetails?.appVersion = DataHolder.hemoCubeTestData?.appVersion
|
testDetails?.appVersion = DataHolder.hemoCubeTestData?.appVersion
|
||||||
testDetails?.deviceId = DataHolder.hemoCubeTestData?.deviceId
|
testDetails?.deviceId = DataHolder.hemoCubeTestData?.deviceId
|
||||||
testDetails?.deviceSerialNumber = sharedPreference.getString(Constants.USER_ID, "").toString()
|
testDetails?.deviceSerialNumber =
|
||||||
|
sharedPreference.getString(Constants.USER_ID, "").toString()
|
||||||
testDetails?.kitSerial = sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
testDetails?.kitSerial = sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
||||||
testDetails?.led1Buffer = DataHolder.hemoCubeTestData?.led1Buffer
|
testDetails?.led1Buffer = DataHolder.hemoCubeTestData?.led1Buffer
|
||||||
testDetails?.led2Buffer = DataHolder.hemoCubeTestData?.led2Buffer
|
testDetails?.led2Buffer = DataHolder.hemoCubeTestData?.led2Buffer
|
||||||
|
testDetails?.led3Buffer = DataHolder.hemoCubeTestData?.led3Buffer
|
||||||
|
testDetails?.led4Buffer = DataHolder.hemoCubeTestData?.led4Buffer
|
||||||
testDetails?.led1Sample = DataHolder.hemoCubeTestData?.led1Sample
|
testDetails?.led1Sample = DataHolder.hemoCubeTestData?.led1Sample
|
||||||
testDetails?.led2Sample = DataHolder.hemoCubeTestData?.led2Sample
|
testDetails?.led2Sample = DataHolder.hemoCubeTestData?.led2Sample
|
||||||
|
testDetails?.led3Sample = DataHolder.hemoCubeTestData?.led3Sample
|
||||||
|
testDetails?.led4Sample = DataHolder.hemoCubeTestData?.led4Sample
|
||||||
testDetails?.led1Average = DataHolder.hemoCubeTestData?.led1Average
|
testDetails?.led1Average = DataHolder.hemoCubeTestData?.led1Average
|
||||||
testDetails?.led2Average = DataHolder.hemoCubeTestData?.led2Average
|
testDetails?.led2Average = DataHolder.hemoCubeTestData?.led2Average
|
||||||
|
testDetails?.led3Average = DataHolder.hemoCubeTestData?.led3Average
|
||||||
|
testDetails?.led4Average = DataHolder.hemoCubeTestData?.led4Average
|
||||||
|
testDetails?.abs1 = DataHolder.hemoCubeTestData?.abs1
|
||||||
|
testDetails?.abs2 = DataHolder.hemoCubeTestData?.abs2
|
||||||
|
testDetails?.abs3 = DataHolder.hemoCubeTestData?.abs3
|
||||||
|
testDetails?.abs4 = DataHolder.hemoCubeTestData?.abs4
|
||||||
testDetails?.deviceRatio = DataHolder.hemoCubeTestData?.deviceRatio
|
testDetails?.deviceRatio = DataHolder.hemoCubeTestData?.deviceRatio
|
||||||
|
testDetails?.predictedDenovixRatio = DataHolder.hemoCubeTestData?.predictedDenovixRatio
|
||||||
testDetails?.calculatedRatio = DataHolder.hemoCubeTestData?.calculatedRatio
|
testDetails?.calculatedRatio = DataHolder.hemoCubeTestData?.calculatedRatio
|
||||||
|
testDetails?.coefficients = DataHolder.hemoCubeTestData?.coefficients
|
||||||
|
testDetails?.classificationResult = DataHolder.hemoCubeTestData?.classificationResult!!
|
||||||
|
testDetails?.prdClassification = DataHolder.hemoCubeTestData?.prdClassification.toString()
|
||||||
|
testDetails?.batteryLevel = DataHolder.hemoCubeTestData?.batteryLevel.toString()
|
||||||
|
testDetails?.batteryCapacity = DataHolder.hemoCubeTestData?.batteryCapacity.toString()
|
||||||
|
testDetails?.batteryMaxCapacity = DataHolder.hemoCubeTestData?.batteryMaxCapacity.toString()
|
||||||
|
testDetails?.batteryTemperature = DataHolder.hemoCubeTestData?.batteryTemperature.toString()
|
||||||
|
testDetails?.batteryVoltage = DataHolder.hemoCubeTestData?.batteryVoltage.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun addResultTestToDb() {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
testDetails!!.reportUploadTime = SimpleDateFormat(
|
testDetails!!.reportUploadTime = SimpleDateFormat(
|
||||||
@@ -100,22 +227,47 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
val kitCount = sharedPreference.getInt(Constants.KIT_COUNT, 0)
|
val kitCount = sharedPreference.getInt(Constants.KIT_COUNT, 0)
|
||||||
with(sharedPreference.edit()) {
|
with(sharedPreference.edit()) {
|
||||||
putInt(Constants.KIT_COUNT, kitCount.plus(1) ?: 0)
|
putInt(Constants.KIT_COUNT, kitCount.plus(1))
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
|
testDetails.localFlag = true
|
||||||
|
uploadResult(MolbioV2ResultRequest(listOf(MolbioV2Result(rawData = testDetails))))
|
||||||
|
hemoCubeDao.insertAll(testDetails)
|
||||||
|
}
|
||||||
|
|
||||||
|
is Response.Error -> {
|
||||||
|
Log.e("Testdb", "Error uploading data to Firestore: $response")
|
||||||
|
fireBaseUpload.postValue("Error")
|
||||||
|
hemoCubeDao.insertAll(testDetails)
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("Testdb", "Exception during data upload: ${e.message}")
|
||||||
|
fireBaseUpload.postValue("Error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun addResultTestToDbforbuffercheck(bufferCheckData: BufferCheckData) {
|
||||||
|
viewModelScope.launch {
|
||||||
|
try {
|
||||||
|
|
||||||
|
when (val response = repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
||||||
|
is Response.Success -> {
|
||||||
|
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||||
|
fireBaseUpload.postValue("Success")
|
||||||
}
|
}
|
||||||
|
|
||||||
is Response.Error -> {
|
is Response.Error -> {
|
||||||
Log.e("Testdb", "Error uploading data to Firestore: ${response}")
|
Log.e("Testdb", "Error uploading data to Firestore: $response")
|
||||||
fireBaseUpload.postValue("Error")
|
fireBaseUpload.postValue("Error")
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {}
|
||||||
Log.e("Testdb", "Unknown response from repository: $response")
|
|
||||||
fireBaseUpload.postValue("Unknown")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("Testdb", "Exception during data upload: ${e.message}")
|
Log.e("Testdb", "Exception during data upload: ${e.message}")
|
||||||
@@ -131,15 +283,75 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
).format(Calendar.getInstance().time)
|
).format(Calendar.getInstance().time)
|
||||||
when (repository.addTestToDatabase(userData)) {
|
when (repository.addTestToDatabase(userData)) {
|
||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseBulkUpload.postValue("Success")
|
||||||
|
updateLocalFlag(userData._id)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {}
|
else -> {
|
||||||
|
fireBaseBulkUpload.postValue("Error")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updateLocalFlag(userId: String) = viewModelScope.launch {
|
||||||
|
hemoCubeDao.updateFieldById(id = userId, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updateMolbioFlag(userId: String) = viewModelScope.launch {
|
||||||
|
hemoCubeDao.updateFieldById(id = userId, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun addUser(userData: HemoCubeTestData) = viewModelScope.launch {
|
||||||
|
hemoCubeDao.insertAll(userData)
|
||||||
|
}
|
||||||
|
|
||||||
fun deleteById(userId: String) = viewModelScope.launch {
|
fun deleteById(userId: String) = viewModelScope.launch {
|
||||||
hemoCubeDao.deleteById(id = userId)
|
hemoCubeDao.deleteById(id = userId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getBatteryLevel(): Float? {
|
||||||
|
val batteryPct: Float? = batteryStatus?.let { intent ->
|
||||||
|
val level: Int = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1)
|
||||||
|
val scale: Int = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1)
|
||||||
|
level * 100 / scale.toFloat()
|
||||||
|
}
|
||||||
|
|
||||||
|
return batteryPct
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getBatteryTemperature(): Float? {
|
||||||
|
val batteryTemp: Float? = batteryStatus?.let { intent ->
|
||||||
|
val temperature = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, 0)
|
||||||
|
temperature.toFloat() / 10
|
||||||
|
}
|
||||||
|
|
||||||
|
return batteryTemp
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getBatteryVoltage(context: Context): Float {
|
||||||
|
val batteryIntent =
|
||||||
|
context.registerReceiver(null, IntentFilter(Intent.ACTION_BATTERY_CHANGED))
|
||||||
|
val voltage = batteryIntent?.getIntExtra(BatteryManager.EXTRA_VOLTAGE, 0) ?: 0
|
||||||
|
|
||||||
|
// milli-volts to volts
|
||||||
|
return voltage.toFloat() / 1000
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getBatteryCapacity(context: Context): Int {
|
||||||
|
val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
||||||
|
|
||||||
|
return batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getBatteryMaxCapacity(context: Context): Float {
|
||||||
|
val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
||||||
|
val designCapacity = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
|
||||||
|
val currentCapacity =
|
||||||
|
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
|
||||||
|
|
||||||
|
// Calculate the estimated maximum battery capacity in mAh
|
||||||
|
|
||||||
|
return currentCapacity.toFloat() / designCapacity.toFloat() * 100
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -21,6 +21,7 @@ import androidx.core.content.ContextCompat
|
|||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.testRight.UsbService
|
import com.example.hpostesting.presentation.testRight.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
|
||||||
@@ -29,7 +30,7 @@ import `in`.sminnovations.hpostesting.R
|
|||||||
import `in`.sminnovations.hpostesting.databinding.ActivityHemocubeBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityHemocubeBinding
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class HemocubeActivity : AppCompatActivity() {
|
open class HemocubeActivity : AppCompatActivity() {
|
||||||
private lateinit var binding: ActivityHemocubeBinding
|
private lateinit var binding: ActivityHemocubeBinding
|
||||||
private val viewModel by viewModels<HemoCubeViewModel>()
|
private val viewModel by viewModels<HemoCubeViewModel>()
|
||||||
private var myMenu: Menu? = null
|
private var myMenu: Menu? = null
|
||||||
@@ -40,8 +41,6 @@ class HemocubeActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
private val TAG = "HemoCube"
|
private val TAG = "HemoCube"
|
||||||
|
|
||||||
var bloodCollectingMethod = ""
|
|
||||||
|
|
||||||
private val broadcastReceiver = object : BroadcastReceiver() {
|
private val broadcastReceiver = object : BroadcastReceiver() {
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
|
|
||||||
@@ -74,12 +73,17 @@ class HemocubeActivity : AppCompatActivity() {
|
|||||||
viewModel.isServiceConnected = false
|
viewModel.isServiceConnected = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
override fun attachBaseContext(newBase: Context?) {
|
||||||
|
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||||
|
LanguageManager.setLocale(newBase, languageCode)
|
||||||
|
super.attachBaseContext(newBase)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = ActivityHemocubeBinding.inflate(layoutInflater)
|
binding = ActivityHemocubeBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
bloodCollectingMethod = intent.getStringExtra(Constants.BLOOD_COLLECTING_METHOD).toString()
|
|
||||||
setSupportActionBar(binding.myToolbar)
|
setSupportActionBar(binding.myToolbar)
|
||||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
setupListener()
|
setupListener()
|
||||||
@@ -100,7 +104,7 @@ class HemocubeActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun connectUsb(permissionGranted: Boolean) {
|
open fun connectUsb(permissionGranted: Boolean) {
|
||||||
Log.d(TAG, "connectUsb() called, permission variable = $permissionGranted")
|
Log.d(TAG, "connectUsb() called, permission variable = $permissionGranted")
|
||||||
val manager = getSystemService(Context.USB_SERVICE) as UsbManager
|
val manager = getSystemService(Context.USB_SERVICE) as UsbManager
|
||||||
val availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(manager)
|
val availableDrivers = UsbSerialProber.getDefaultProber().findAllDrivers(manager)
|
||||||
@@ -121,15 +125,13 @@ class HemocubeActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
|
|
||||||
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
||||||
val mPendingIntent: PendingIntent = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
val mPendingIntent: PendingIntent
|
||||||
PendingIntent.getBroadcast(
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
|
||||||
this,
|
mPendingIntent = PendingIntent.getBroadcast(
|
||||||
0,
|
this, 0, Intent(Constants.HOMOCUBE_USB_PERMISSION), PendingIntent.FLAG_MUTABLE
|
||||||
Intent(Constants.HOMOCUBE_USB_PERMISSION),
|
|
||||||
PendingIntent.FLAG_MUTABLE
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
PendingIntent.getBroadcast(
|
mPendingIntent = PendingIntent.getBroadcast(
|
||||||
this,
|
this,
|
||||||
0,
|
0,
|
||||||
Intent(Constants.HOMOCUBE_USB_PERMISSION),
|
Intent(Constants.HOMOCUBE_USB_PERMISSION),
|
||||||
@@ -142,24 +144,39 @@ class HemocubeActivity : AppCompatActivity() {
|
|||||||
manager.requestPermission(device, mPendingIntent)
|
manager.requestPermission(device, mPendingIntent)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupService() {
|
fun setupService() {
|
||||||
val intent = Intent(this, UsbService::class.java)
|
val intent = Intent(this, UsbService::class.java)
|
||||||
// startService(intent)
|
|
||||||
bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
bindService(intent, connection, Context.BIND_AUTO_CREATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun moveToNext() {
|
open fun reconnectDevice() {
|
||||||
if (supportFragmentManager.isDestroyed)
|
mService.disconnect()
|
||||||
return
|
unbindService(connection)
|
||||||
|
viewModel.isServiceConnected = false
|
||||||
supportFragmentManager.beginTransaction()
|
connectUsb(true)
|
||||||
.replace(binding.fghemocube.id, HemoCubeFragment()).commit()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun moveToNext() {
|
||||||
|
if (supportFragmentManager.isDestroyed) return
|
||||||
|
|
||||||
|
supportFragmentManager.beginTransaction().replace(binding.fghemocube.id, HemoCubeFragment())
|
||||||
|
.commit()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun onBackPressed() {
|
||||||
|
val fragment = supportFragmentManager.findFragmentById(R.id.fghemocube)
|
||||||
|
if (fragment is HemoCubeFragment) {
|
||||||
|
fragment.handleBackButtonPress()
|
||||||
|
} else {
|
||||||
|
super.onBackPressed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fun onErrorReported(msg: String) {
|
fun onErrorReported(msg: String) {
|
||||||
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
|
||||||
if (!isFinishing)
|
if (!isFinishing) onBackPressed()
|
||||||
onBackPressed()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.example.hpostesting.presentation.testRight
|
package com.example.hpostesting.presentation.testRight
|
||||||
|
|
||||||
|
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
|
||||||
@@ -14,7 +15,6 @@ import com.example.hpostesting.data.DataHolder
|
|||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.model.test.TestRightResultType
|
import com.example.hpostesting.data.model.test.TestRightResultType
|
||||||
import com.example.hpostesting.data.model.test.TestType
|
import com.example.hpostesting.data.model.test.TestType
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
|
||||||
import com.example.hpostesting.util.MyUtils.calculateAgeFromYOB
|
import com.example.hpostesting.util.MyUtils.calculateAgeFromYOB
|
||||||
import com.google.firebase.firestore.FirebaseFirestore
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
import com.google.firebase.firestore.ktx.firestore
|
import com.google.firebase.firestore.ktx.firestore
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.example.hpostesting.presentation.testRight
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.util.Log
|
|
||||||
import androidx.lifecycle.LiveData
|
import androidx.lifecycle.LiveData
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class UsbService : Service() {
|
|||||||
fun connect(driver: UsbSerialDriver, connection: UsbDeviceConnection) {
|
fun connect(driver: UsbSerialDriver, connection: UsbDeviceConnection) {
|
||||||
mPort = driver.ports[0] // Most devices have just one port (port 0)
|
mPort = driver.ports[0] // Most devices have just one port (port 0)
|
||||||
mPort.open(connection)
|
mPort.open(connection)
|
||||||
mPort.setParameters(115200, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE)
|
mPort.setParameters(9600, 8, UsbSerialPort.STOPBITS_1, UsbSerialPort.PARITY_NONE)
|
||||||
isUsbConnected = true
|
isUsbConnected = true
|
||||||
Log.d(TAG, "My Usb Connected ${mPort.driver}")
|
Log.d(TAG, "My Usb Connected ${mPort.driver}")
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.example.hpostesting.util
|
||||||
|
|
||||||
|
import android.content.res.AssetManager
|
||||||
|
import com.example.hpostesting.data.api.PropertyProvider
|
||||||
|
import java.io.InputStream
|
||||||
|
import java.util.Properties
|
||||||
|
|
||||||
|
class PropertyProviderImpl (private val assetManager: AssetManager) : PropertyProvider {
|
||||||
|
override fun getProperty(key: String): String {
|
||||||
|
val inputStream: InputStream = assetManager.open("app.properties")
|
||||||
|
val properties = Properties()
|
||||||
|
properties.load(inputStream)
|
||||||
|
return properties.getProperty(key)
|
||||||
|
}
|
||||||
|
}
|
||||||
5
app/src/main/res/drawable/ic_add.xml
Normal file
5
app/src/main/res/drawable/ic_add.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<vector android:autoMirrored="true" android:height="24dp"
|
||||||
|
android:tint="#000000" android:viewportHeight="24"
|
||||||
|
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@color/black" android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
|
||||||
|
</vector>
|
||||||
BIN
app/src/main/res/drawable/indianoil.jpg
Normal file
BIN
app/src/main/res/drawable/indianoil.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
BIN
app/src/main/res/drawable/karnataka.png
Normal file
BIN
app/src/main/res/drawable/karnataka.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.0 KiB |
5
app/src/main/res/drawable/person.xml
Normal file
5
app/src/main/res/drawable/person.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<vector android:height="24dp" android:tint="#000000"
|
||||||
|
android:viewportHeight="24" android:viewportWidth="24"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M12,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM12,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"/>
|
||||||
|
</vector>
|
||||||
BIN
app/src/main/res/drawable/user.png
Normal file
BIN
app/src/main/res/drawable/user.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
@@ -1,74 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
tools:context="com.example.hpostesting.presentation.BloodCollectingMethodActivity">
|
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
|
||||||
android:id="@+id/app_bar_layout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
android:theme="@style/Theme.HPOS.AppBarOverlay">
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
|
||||||
android:id="@+id/toolbar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="?attr/actionBarSize"
|
|
||||||
android:background="?attr/colorPrimary"
|
|
||||||
app:popupTheme="@style/Theme.HPOS.PopupOverlay" />
|
|
||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tv_title"
|
|
||||||
style="@style/title1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginHorizontal="24dp"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:text="@string/select_blood_collecting_method"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/app_bar_layout" />
|
|
||||||
|
|
||||||
<RadioGroup
|
|
||||||
android:id="@+id/bloodTypeRadioGroup"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginHorizontal="24dp"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tv_title">
|
|
||||||
|
|
||||||
<RadioButton
|
|
||||||
android:id="@+id/venousBloodRadioButton"
|
|
||||||
style="@style/title1_1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/venous_blood" />
|
|
||||||
|
|
||||||
<RadioButton
|
|
||||||
android:id="@+id/fingerPrickBloodRadioButton"
|
|
||||||
style="@style/title1_1"
|
|
||||||
android:checked="true"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/finger_prick_blood" />
|
|
||||||
|
|
||||||
</RadioGroup>
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
|
||||||
android:id="@+id/btn_go"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="24dp"
|
|
||||||
android:text="@string/go"
|
|
||||||
app:cornerRadius="16dp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/bloodTypeRadioGroup" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
41
app/src/main/res/layout/activity_buffer_check.xml
Normal file
41
app/src/main/res/layout/activity_buffer_check.xml
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/cl_parent"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/my_toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
app:titleTextColor="#FFFFFF"
|
||||||
|
android:elevation="4dp"
|
||||||
|
app:menu="@menu/my_menu"
|
||||||
|
android:theme="@style/ToolbarTheme"
|
||||||
|
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"/>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/fg_hc_buffer_check"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/my_toolbar"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
tools:context=".presentation.buffercheck.HemocubeBufferCheckActivity">
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</layout>
|
||||||
40
app/src/main/res/layout/activity_diagnostics.xml
Normal file
40
app/src/main/res/layout/activity_diagnostics.xml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/cl_parent"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<!-- <androidx.appcompat.widget.Toolbar-->
|
||||||
|
<!-- android:id="@+id/my_toolbar"-->
|
||||||
|
<!-- android:layout_width="match_parent"-->
|
||||||
|
<!-- android:layout_height="?attr/actionBarSize"-->
|
||||||
|
<!-- android:background="?attr/colorPrimary"-->
|
||||||
|
<!-- app:titleTextColor="#FFFFFF"-->
|
||||||
|
<!-- android:elevation="4dp"-->
|
||||||
|
<!-- app:menu="@menu/my_menu"-->
|
||||||
|
<!-- android:theme="@style/ToolbarTheme"-->
|
||||||
|
<!-- app:popupTheme="@style/ThemeOverlay.AppCompat.Light"-->
|
||||||
|
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||||
|
<!-- app:layout_constraintTop_toTopOf="parent"/>-->
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/fg_diagnostics"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
tools:context=".presentation.diagnostics.DiagnosticsActivity">
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</layout>
|
||||||
38
app/src/main/res/layout/activity_digital_card.xml
Normal file
38
app/src/main/res/layout/activity_digital_card.xml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/cl_parent"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:visibility="gone"
|
||||||
|
android:id="@+id/my_toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
app:titleTextColor="#FFFFFF"
|
||||||
|
android:elevation="4dp"
|
||||||
|
app:menu="@menu/my_menu"
|
||||||
|
android:theme="@style/ToolbarTheme"
|
||||||
|
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/fghemocube"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/my_toolbar"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent">
|
||||||
|
|
||||||
|
<!-- NavHostFragment for navigation -->
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</layout>
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<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">
|
||||||
|
|
||||||
|
|
||||||
<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"
|
||||||
@@ -21,21 +19,17 @@
|
|||||||
android:theme="@style/ToolbarTheme"
|
android:theme="@style/ToolbarTheme"
|
||||||
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
|
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"/>
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/fghemocube"
|
android:id="@+id/fghemocube"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/my_toolbar"
|
app:layout_constraintTop_toBottomOf="@id/my_toolbar"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
tools:context=".presentation.hemocube.HemocubeActivity">
|
tools:context=".presentation.hemocube.HemocubeActivity">
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
</layout>
|
</layout>
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context="com.example.hpostesting.presentation.KitScanActivity">
|
tools:context=".presentation.KitScanActivity">
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:id="@+id/app_bar_layout"
|
android:id="@+id/app_bar_layout"
|
||||||
|
|||||||
@@ -18,4 +18,6 @@
|
|||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:navGraph="@navigation/dashboard_navigation" />
|
app:navGraph="@navigation/dashboard_navigation" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
24
app/src/main/res/layout/dialog_custom.xml
Normal file
24
app/src/main/res/layout/dialog_custom.xml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:id="@+id/til_blood_group"
|
||||||
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<AutoCompleteTextView
|
||||||
|
android:id="@+id/et_blood_group"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/select_blood_group"
|
||||||
|
android:inputType="none"
|
||||||
|
android:labelFor="@id/til_blood_group"
|
||||||
|
app:simpleItems="@array/blood_group" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
</LinearLayout>
|
||||||
102
app/src/main/res/layout/fragment_diagnostics.xml
Normal file
102
app/src/main/res/layout/fragment_diagnostics.xml
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context="com.example.hpostesting.presentation.diagnostics.DiagnosticsFragment">
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <TextView-->
|
||||||
|
<!-- android:id="@+id/tv_title"-->
|
||||||
|
<!-- style="@style/title1"-->
|
||||||
|
<!-- android:layout_width="wrap_content"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- android:layout_marginHorizontal="24dp"-->
|
||||||
|
<!-- android:text="@string/diagnostics"-->
|
||||||
|
<!-- android:layout_marginTop="16dp"-->
|
||||||
|
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||||
|
<!-- app:layout_constraintTop_toTopOf="parent" />-->
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_subtitle2"
|
||||||
|
style="@style/title2"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="@string/diagnostics"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_subtitle3"
|
||||||
|
style="@style/title2"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tv_subtitle2" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_subtitle4"
|
||||||
|
style="@style/title1_1"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="380dp"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="Start"
|
||||||
|
android:textColor="@color/red"
|
||||||
|
android:textSize="22sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tv_subtitle3" />
|
||||||
|
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_submit"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:clickable="false"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="Start"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tv_subtitle4" />
|
||||||
|
|
||||||
|
<!-- <Button-->
|
||||||
|
<!-- android:id="@+id/btn_read"-->
|
||||||
|
<!-- android:layout_width="wrap_content"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- android:text="@string/read"-->
|
||||||
|
<!-- android:layout_margin="16dp"-->
|
||||||
|
<!-- android:clickable="false"-->
|
||||||
|
<!-- app:layout_constraintTop_toBottomOf="@id/btn_set_reference"-->
|
||||||
|
<!-- app:layout_constraintStart_toStartOf="parent" />-->
|
||||||
|
|
||||||
|
<!-- </androidx.constraintlayout.widget.ConstraintLayout>-->
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBar"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:elevation="12dp"
|
||||||
|
android:indeterminate="true"
|
||||||
|
android:indeterminateDrawable="@drawable/progressbar_drawable"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
242
app/src/main/res/layout/fragment_digital_card.xml
Normal file
242
app/src/main/res/layout/fragment_digital_card.xml
Normal file
@@ -0,0 +1,242 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
tools:context="com.example.hpostesting.presentation.hemocube.DigitalCardFragment">
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:id="@+id/userCard"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="350dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
app:cardBackgroundColor="#C0C0C0"
|
||||||
|
app:cardCornerRadius="25dp"
|
||||||
|
app:cardElevation="0dp"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/fragment_container_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@android:color/background_light"/>
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="22dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/userImage"
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="100dp"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
android:src="@drawable/karnataka" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/userName"
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="100dp"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
app:layout_constraintTop_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/userImage"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/userImage"
|
||||||
|
android:src="@drawable/sickle_cell_gov_logo"/>
|
||||||
|
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/userImage3"
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="100dp"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/userName"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/userName"
|
||||||
|
android:src="@drawable/indianoil"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:id="@+id/userdetails"
|
||||||
|
android:layout_width="150dp"
|
||||||
|
android:layout_height="120dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
app:cardBackgroundColor="#FFFFFF"
|
||||||
|
app:cardCornerRadius="5dp"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/userImage"
|
||||||
|
app:cardElevation="0dp"
|
||||||
|
tools:ignore="MissingConstraints">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/name"
|
||||||
|
style="@style/title1_1"
|
||||||
|
android:layout_width="80dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="10sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/userImage"
|
||||||
|
android:text="name: Mariya" />
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/dob"
|
||||||
|
style="@style/title1_1"
|
||||||
|
android:layout_width="80dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginTop="30dp"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="10sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/name"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/name"
|
||||||
|
android:text="DOB: 1998" />
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/gender"
|
||||||
|
style="@style/title1_1"
|
||||||
|
android:layout_width="80dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginTop="50dp"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="10sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/dob"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/dob"
|
||||||
|
android:text="gender: female" />
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/State"
|
||||||
|
style="@style/title1_1"
|
||||||
|
android:layout_width="130dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginTop="70dp"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="10sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/gender"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/gender"
|
||||||
|
android:text="State: Kerala" />
|
||||||
|
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:id="@+id/userdetails2"
|
||||||
|
android:layout_width="150dp"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_height="120dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
app:cardBackgroundColor="#FFFFFF"
|
||||||
|
app:cardCornerRadius="5dp"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/userImage3"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/userdetails"
|
||||||
|
app:cardElevation="0dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/abhaid"
|
||||||
|
style="@style/title1_1"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:gravity="start"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="10sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/userImage3"
|
||||||
|
android:text="ABHA-ID: XXXX-8734" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/blood"
|
||||||
|
style="@style/title1_1"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="30dp"
|
||||||
|
android:gravity="start"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="10sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/userImage3"
|
||||||
|
android:text="Blood Group: O +ve" />
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/sicklecell"
|
||||||
|
style="@style/title1_1"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_marginStart="6dp"
|
||||||
|
android:layout_marginTop="50dp"
|
||||||
|
android:gravity="start"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="10sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/userImage3"
|
||||||
|
android:text="Sickle-Cell: Normal (HbA)" />
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/issueDate"
|
||||||
|
style="@style/title1_1"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="70dp"
|
||||||
|
android:gravity="start"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="10sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/userImage3"
|
||||||
|
android:text="Issue Date: Oct 2,2023" />
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/digitalcard"
|
||||||
|
android:backgroundTint="#00008B"
|
||||||
|
app:cardBackgroundColor="#00008B"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
android:text="@string/digital_card"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/userdetails" />
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBar"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:elevation="12dp"
|
||||||
|
android:indeterminate="true"
|
||||||
|
android:indeterminateDrawable="@drawable/progressbar_drawable"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -4,19 +4,33 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".presentation.dashboard.GalleryFragment">
|
tools:context="com.example.hpostesting.presentation.dashboard.GalleryFragment">
|
||||||
|
|
||||||
<TextView
|
<Button
|
||||||
android:id="@+id/text_gallery"
|
android:id="@+id/btn_submit"
|
||||||
style="@style/title1"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="24dp"
|
android:layout_marginHorizontal="16dp"
|
||||||
android:textAlignment="center"
|
android:layout_marginTop="24dp"
|
||||||
android:textSize="20sp"
|
android:clickable="false"
|
||||||
android:text="@string/to_be_launched_in_next_version_of_the_app"
|
android:text="@string/check_buffer"
|
||||||
|
android:textColor="@color/white"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_diagnostics"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:clickable="false"
|
||||||
|
android:text="@string/diagnostics"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/btn_submit" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
187
app/src/main/res/layout/fragment_hemo_cube_buffer_check.xml
Normal file
187
app/src/main/res/layout/fragment_hemo_cube_buffer_check.xml
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
tools:context="com.example.hpostesting.presentation.buffercheck.HemoCubeBufferCheckFragment">
|
||||||
|
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/cl_parent"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_title"
|
||||||
|
style="@style/title1"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="@string/Instructions"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_subtitle2"
|
||||||
|
style="@style/title2"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="@string/step4"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tv_title" />
|
||||||
|
|
||||||
|
<!-- <TextView-->
|
||||||
|
<!-- android:id="@+id/tv_subtitle3"-->
|
||||||
|
<!-- style="@style/title2"-->
|
||||||
|
<!-- android:layout_width="0dp"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- android:layout_marginHorizontal="24dp"-->
|
||||||
|
<!-- android:layout_marginTop="16dp"-->
|
||||||
|
<!-- android:text="@string/step5"-->
|
||||||
|
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||||
|
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||||
|
<!-- app:layout_constraintTop_toBottomOf="@id/tv_subtitle2" />-->
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_name"
|
||||||
|
style="@style/title2"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/btn_submit" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_subtitle4"
|
||||||
|
style="@style/title1_1"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="80dp"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textColor="@color/red"
|
||||||
|
android:textSize="18sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tv_subtitle2" />
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <Button-->
|
||||||
|
<!-- android:visibility="gone"-->
|
||||||
|
<!-- android:id="@+id/btn_samplestart"-->
|
||||||
|
<!-- android:layout_width="wrap_content"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- android:layout_marginHorizontal="16dp"-->
|
||||||
|
<!-- android:layout_marginTop="24dp"-->
|
||||||
|
<!-- android:clickable="false"-->
|
||||||
|
<!-- android:text="@string/Start_Sample"-->
|
||||||
|
<!-- android:textColor="@color/white"-->
|
||||||
|
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||||
|
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||||
|
<!-- app:layout_constraintTop_toBottomOf="@id/til_blood_group" />-->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <Button-->
|
||||||
|
<!-- android:id="@+id/btn_placebuffer"-->
|
||||||
|
<!-- android:layout_width="wrap_content"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- android:layout_marginHorizontal="16dp"-->
|
||||||
|
<!-- android:layout_marginTop="24dp"-->
|
||||||
|
<!-- android:clickable="false"-->
|
||||||
|
<!-- android:text="@string/place_buffer"-->
|
||||||
|
<!-- android:textColor="@color/white"-->
|
||||||
|
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||||
|
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||||
|
<!-- app:layout_constraintTop_toBottomOf="@id/btn_submit" />-->
|
||||||
|
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_submit"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:clickable="false"
|
||||||
|
android:text="@string/submit"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tv_subtitle4" />
|
||||||
|
|
||||||
|
<!-- <com.google.android.material.textfield.TextInputLayout-->
|
||||||
|
<!-- android:id="@+id/til_blood_group"-->
|
||||||
|
<!-- style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"-->
|
||||||
|
<!-- android:layout_width="match_parent"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- android:layout_marginHorizontal="24dp"-->
|
||||||
|
<!-- android:layout_marginTop="16dp"-->
|
||||||
|
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||||
|
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||||
|
<!-- app:layout_constraintTop_toBottomOf="@id/tv_subtitle4">-->
|
||||||
|
|
||||||
|
<!-- <AutoCompleteTextView-->
|
||||||
|
<!-- android:id="@+id/et_blood_group"-->
|
||||||
|
<!-- android:layout_width="match_parent"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- android:hint="@string/select_blood_group"-->
|
||||||
|
<!-- android:inputType="none"-->
|
||||||
|
<!-- android:labelFor="@id/til_blood_group"-->
|
||||||
|
<!-- app:simpleItems="@array/blood_group" />-->
|
||||||
|
|
||||||
|
<!-- </com.google.android.material.textfield.TextInputLayout>-->
|
||||||
|
|
||||||
|
<!-- <Button-->
|
||||||
|
<!-- android:id="@+id/btn_kit"-->
|
||||||
|
<!-- android:layout_width="wrap_content"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- android:layout_margin="10dp"-->
|
||||||
|
<!-- android:text="@string/new_kit"-->
|
||||||
|
<!-- android:textColor="@color/white"-->
|
||||||
|
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||||
|
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||||
|
<!-- app:layout_constraintStart_toStartOf="parent" />-->
|
||||||
|
|
||||||
|
<!-- <Button-->
|
||||||
|
<!-- android:id="@+id/btn_buffer"-->
|
||||||
|
<!-- android:layout_width="wrap_content"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- android:text="@string/new_buffer"-->
|
||||||
|
<!-- android:textColor="@color/white"-->
|
||||||
|
<!-- android:layout_margin="10dp"-->
|
||||||
|
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
||||||
|
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||||
|
<!-- app:layout_constraintEnd_toStartOf="@id/btn_kit"/>-->
|
||||||
|
|
||||||
|
<!-- <Button-->
|
||||||
|
<!-- android:id="@+id/btn_read"-->
|
||||||
|
<!-- android:layout_width="wrap_content"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- android:text="@string/read"-->
|
||||||
|
<!-- android:layout_margin="16dp"-->
|
||||||
|
<!-- android:clickable="false"-->
|
||||||
|
<!-- app:layout_constraintTop_toBottomOf="@id/btn_set_reference"-->
|
||||||
|
<!-- app:layout_constraintStart_toStartOf="parent" />-->
|
||||||
|
|
||||||
|
<!-- </androidx.constraintlayout.widget.ConstraintLayout>-->
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBar"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:elevation="12dp"
|
||||||
|
android:indeterminate="true"
|
||||||
|
android:indeterminateDrawable="@drawable/progressbar_drawable"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
</layout>
|
||||||
@@ -27,22 +27,36 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginHorizontal="24dp"
|
android:layout_marginHorizontal="24dp"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:text="@string/step4"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tv_title" />
|
app:layout_constraintTop_toBottomOf="@id/tv_title" />
|
||||||
|
|
||||||
|
<!-- <TextView-->
|
||||||
|
<!-- android:id="@+id/tv_subtitle3"-->
|
||||||
|
<!-- style="@style/title2"-->
|
||||||
|
<!-- android:layout_width="0dp"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- android:layout_marginHorizontal="24dp"-->
|
||||||
|
<!-- android:layout_marginTop="16dp"-->
|
||||||
|
<!-- android:text="@string/step5"-->
|
||||||
|
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||||
|
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||||
|
<!-- app:layout_constraintTop_toBottomOf="@id/tv_subtitle2" />-->
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_subtitle3"
|
android:id="@+id/tv_name"
|
||||||
style="@style/title2"
|
style="@style/title2"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginHorizontal="24dp"
|
android:layout_marginHorizontal="24dp"
|
||||||
android:layout_marginTop="16dp"
|
android:gravity="center"
|
||||||
android:text="@string/step5"
|
android:padding="12dp"
|
||||||
|
android:layout_marginTop="26dp"
|
||||||
|
android:textFontWeight="700"
|
||||||
|
android:text="Name: SMI\n ID: 1672282828"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tv_subtitle2" />
|
tools:ignore="MissingConstraints" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_subtitle4"
|
android:id="@+id/tv_subtitle4"
|
||||||
@@ -50,15 +64,120 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="80dp"
|
android:layout_height="80dp"
|
||||||
android:layout_marginHorizontal="24dp"
|
android:layout_marginHorizontal="24dp"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="72dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textColor="@color/red"
|
android:textColor="@color/red"
|
||||||
android:textSize="22sp"
|
android:textSize="18sp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tv_subtitle3" />
|
app:layout_constraintTop_toBottomOf="@id/et_abha_id" />
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <Button-->
|
||||||
|
<!-- android:visibility="gone"-->
|
||||||
|
<!-- android:id="@+id/btn_samplestart"-->
|
||||||
|
<!-- android:layout_width="wrap_content"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- android:layout_marginHorizontal="16dp"-->
|
||||||
|
<!-- android:layout_marginTop="24dp"-->
|
||||||
|
<!-- android:clickable="false"-->
|
||||||
|
<!-- android:text="@string/Start_Sample"-->
|
||||||
|
<!-- android:textColor="@color/white"-->
|
||||||
|
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||||
|
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||||
|
<!-- app:layout_constraintTop_toBottomOf="@id/til_blood_group" />-->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <Button-->
|
||||||
|
<!-- android:id="@+id/btn_placebuffer"-->
|
||||||
|
<!-- android:layout_width="wrap_content"-->
|
||||||
|
<!-- android:layout_height="wrap_content"-->
|
||||||
|
<!-- android:layout_marginHorizontal="16dp"-->
|
||||||
|
<!-- android:layout_marginTop="24dp"-->
|
||||||
|
<!-- android:clickable="false"-->
|
||||||
|
<!-- android:text="@string/place_buffer"-->
|
||||||
|
<!-- android:textColor="@color/white"-->
|
||||||
|
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
||||||
|
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
||||||
|
<!-- app:layout_constraintTop_toBottomOf="@id/btn_submit" />-->
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_title2"
|
||||||
|
style="@style/title1"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
android:layout_marginTop="48dp"
|
||||||
|
android:text="@string/enter_kit_serial_number_manually"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
tools:ignore="MissingConstraints" />
|
||||||
|
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:id="@+id/et_abha_id"
|
||||||
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="24dp"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
app:layout_constraintEnd_toStartOf="@id/btn_go"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/tv_title2">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/name_edit_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:maxLength="17"
|
||||||
|
android:inputType="text"
|
||||||
|
android:hint="@string/serial_number" />
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btn_go"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="24dp"
|
||||||
|
android:text="@string/go"
|
||||||
|
app:cornerRadius="16dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/et_abha_id"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="1.0"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/et_abha_id"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/et_abha_id" />
|
||||||
|
<Button
|
||||||
|
android:visibility="gone"
|
||||||
|
android:id="@+id/btn_samplestart"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:clickable="false"
|
||||||
|
android:text="@string/Start_Sample"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/btn_placebuffer" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
android:id="@+id/btn_placebuffer"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:clickable="false"
|
||||||
|
android:text="@string/place_buffer"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/btn_submit" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:visibility="gone"
|
||||||
android:id="@+id/btn_submit"
|
android:id="@+id/btn_submit"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -69,65 +188,51 @@
|
|||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/til_blood_group" />
|
app:layout_constraintTop_toBottomOf="@id/tv_subtitle4" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
android:id="@+id/error_message"
|
||||||
android:id="@+id/til_blood_group"
|
style="@style/title1_1"
|
||||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
android:visibility="gone"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="40dp"
|
||||||
android:layout_marginHorizontal="24dp"
|
android:layout_marginHorizontal="24dp"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="72dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textColor="@color/red"
|
||||||
|
android:textSize="12sp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/tv_subtitle4">
|
app:layout_constraintTop_toBottomOf="@id/btn_submit" />
|
||||||
|
|
||||||
<AutoCompleteTextView
|
<TextView
|
||||||
android:id="@+id/et_blood_group"
|
android:id="@+id/tv_device_messages"
|
||||||
android:layout_width="match_parent"
|
style="@style/title1_1"
|
||||||
android:layout_height="wrap_content"
|
android:visibility="gone"
|
||||||
android:hint="@string/select_blood_group"
|
android:layout_width="0dp"
|
||||||
android:inputType="none"
|
android:layout_height="180dp"
|
||||||
android:labelFor="@id/til_blood_group"
|
android:layout_marginHorizontal="24dp"
|
||||||
app:simpleItems="@array/blood_group" />
|
android:layout_marginTop="72dp"
|
||||||
|
android:gravity="center"
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
android:textColor="@color/black"
|
||||||
|
android:textSize="11sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/error_message" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn_kit"
|
android:visibility="gone"
|
||||||
|
android:id="@+id/btn_digitalCard"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp"
|
android:layout_marginHorizontal="16dp"
|
||||||
android:text="@string/new_kit"
|
android:layout_marginTop="24dp"
|
||||||
|
android:clickable="false"
|
||||||
|
android:text="DigitalCard View"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/error_message" />
|
||||||
<!-- <Button-->
|
|
||||||
<!-- android:id="@+id/btn_buffer"-->
|
|
||||||
<!-- android:layout_width="wrap_content"-->
|
|
||||||
<!-- android:layout_height="wrap_content"-->
|
|
||||||
<!-- android:text="@string/new_buffer"-->
|
|
||||||
<!-- android:textColor="@color/white"-->
|
|
||||||
<!-- android:layout_margin="10dp"-->
|
|
||||||
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
|
||||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
|
||||||
<!-- app:layout_constraintEnd_toStartOf="@id/btn_kit"/>-->
|
|
||||||
|
|
||||||
<!-- <Button-->
|
|
||||||
<!-- android:id="@+id/btn_read"-->
|
|
||||||
<!-- android:layout_width="wrap_content"-->
|
|
||||||
<!-- android:layout_height="wrap_content"-->
|
|
||||||
<!-- android:text="@string/read"-->
|
|
||||||
<!-- android:layout_margin="16dp"-->
|
|
||||||
<!-- android:clickable="false"-->
|
|
||||||
<!-- app:layout_constraintTop_toBottomOf="@id/btn_set_reference"-->
|
|
||||||
<!-- app:layout_constraintStart_toStartOf="parent" />-->
|
|
||||||
|
|
||||||
<!-- </androidx.constraintlayout.widget.ConstraintLayout>-->
|
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progressBar"
|
android:id="@+id/progressBar"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -142,7 +247,6 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</layout>
|
||||||
|
|
||||||
</layout>
|
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
android:id="@+id/internetNotAvailableCL"
|
android:id="@+id/internetNotAvailableCL"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:visibility="gone"
|
android:visibility="visible"
|
||||||
android:padding="24dp">
|
android:padding="24dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -57,6 +57,27 @@
|
|||||||
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:id="@+id/til_blood_group"
|
||||||
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="24dp"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/til_name">
|
||||||
|
|
||||||
|
<AutoCompleteTextView
|
||||||
|
android:id="@+id/et_blood_group"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/select_blood_group"
|
||||||
|
android:inputType="none"
|
||||||
|
android:labelFor="@id/til_blood_group"
|
||||||
|
app:simpleItems="@array/blood_group" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/btn_submit"
|
android:id="@+id/btn_submit"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -66,7 +87,18 @@
|
|||||||
app:cornerRadius="100dp"
|
app:cornerRadius="100dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/til_name" />
|
app:layout_constraintTop_toBottomOf="@+id/til_blood_group" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rv_order_offline"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/btn_submit"
|
||||||
|
tools:listitem="@layout/offline_user_list_view" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
@@ -74,7 +106,7 @@
|
|||||||
android:id="@+id/internetAvailableCL"
|
android:id="@+id/internetAvailableCL"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:visibility="visible"
|
android:visibility="gone"
|
||||||
android:padding="24dp">
|
android:padding="24dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@@ -194,6 +226,27 @@
|
|||||||
app:layout_constraintTop_toBottomOf="@+id/radioGroup"
|
app:layout_constraintTop_toBottomOf="@+id/radioGroup"
|
||||||
tools:listitem="@layout/user_item_view"/>
|
tools:listitem="@layout/user_item_view"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/label"
|
||||||
|
style="@style/title1_1"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/new_kit"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/btnNewKit"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent" />
|
||||||
|
|
||||||
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
android:id="@+id/btnNewKit"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="8dp"
|
||||||
|
android:backgroundTint="@color/primary"
|
||||||
|
android:contentDescription="@string/new_kit"
|
||||||
|
android:src="@drawable/ic_add"
|
||||||
|
app:elevation="1dp"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent" />
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -4,19 +4,6 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".presentation.dashboard.SlideshowFragment">
|
tools:context="com.example.hpostesting.presentation.dashboard.SlideshowFragment">
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/text_slideshow"
|
|
||||||
style="@style/title1"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="24dp"
|
|
||||||
android:textAlignment="center"
|
|
||||||
android:textSize="20sp"
|
|
||||||
android:text="@string/to_be_launched_in_next_version_of_the_app"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
23
app/src/main/res/layout/language_spinner_preference.xml
Normal file
23
app/src/main/res/layout/language_spinner_preference.xml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<!-- language_spinner_preference.xml -->
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<!-- Select Language -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textSelectLanguage"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Select Language"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textSize="18sp"/>
|
||||||
|
|
||||||
|
<!-- Language Spinner -->
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/languageSpinner"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"/>
|
||||||
|
</LinearLayout>
|
||||||
71
app/src/main/res/layout/offline_user_list_view.xml
Normal file
71
app/src/main/res/layout/offline_user_list_view.xml
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:id="@+id/userCard"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
app:cardBackgroundColor="@color/primary_light"
|
||||||
|
app:cardCornerRadius="25dp"
|
||||||
|
app:cardElevation="0dp"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="12dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/userID"
|
||||||
|
style="@style/title1_1"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:gravity="start"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="14sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:text="Name: MohamedKaif" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/bloodGroup"
|
||||||
|
style="@style/title1_1"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:gravity="start"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="14sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/userID"
|
||||||
|
tools:text="UserID: MohamedKaif" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/time"
|
||||||
|
style="@style/title1_1"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:gravity="start"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="14sp"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/bloodGroup"
|
||||||
|
tools:text="Test Status: Completed" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -72,6 +72,25 @@
|
|||||||
app:layout_constraintTop_toBottomOf="@id/userId"
|
app:layout_constraintTop_toBottomOf="@id/userId"
|
||||||
tools:text="Test Status: Completed"/>
|
tools:text="Test Status: Completed"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_startIncubation"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:text="@string/start_incubation"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/btn_blood"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/btn_blood" />
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btn_blood"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="16dp"
|
||||||
|
android:text="@string/blood_group"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/btn_startIncubation"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/teststatus" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user