Compare commits
18 Commits
review_usb
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c0d5bc76e | ||
|
|
a82f72ac38 | ||
|
|
7779f362af | ||
|
|
07c778b0cc | ||
|
|
bb2fc0eb8f | ||
|
|
d1a6231716 | ||
|
|
35614e082f | ||
|
|
2637f84cac | ||
|
|
f5dc2f425b | ||
|
|
daf6dc81d4 | ||
|
|
9ed666e6e6 | ||
|
|
21b19188e5 | ||
|
|
04cf366042 | ||
|
|
b81666dffd | ||
|
|
63891fdade | ||
|
|
1400f71d61 | ||
|
|
70ba5077d6 | ||
|
|
179752b0b0 |
105
.gitlab-ci.yml
105
.gitlab-ci.yml
@@ -1,63 +1,31 @@
|
|||||||
# This file is a template, and might need editing before it works on your project.
|
|
||||||
# To contribute improvements to CI/CD templates, please follow the Development guide at:
|
|
||||||
# https://docs.gitlab.com/ee/development/cicd/templates.html
|
|
||||||
# This specific template is located at:
|
|
||||||
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Android.gitlab-ci.yml
|
|
||||||
|
|
||||||
# Read more about this script on this blog post https://about.gitlab.com/2018/10/24/setting-up-gitlab-ci-for-android-projects/, by Jason Lenny
|
|
||||||
# If you are interested in using Android with FastLane for publishing take a look at the Android-Fastlane template.
|
|
||||||
|
|
||||||
image: eclipse-temurin:17-jdk-jammy
|
image: eclipse-temurin:17-jdk-jammy
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
|
|
||||||
# ANDROID_COMPILE_SDK is the version of Android you're compiling with.
|
|
||||||
# It should match compileSdkVersion.
|
|
||||||
ANDROID_COMPILE_SDK: "34"
|
ANDROID_COMPILE_SDK: "34"
|
||||||
|
|
||||||
# ANDROID_BUILD_TOOLS is the version of the Android build tools you are using.
|
|
||||||
# It should match buildToolsVersion.
|
|
||||||
ANDROID_BUILD_TOOLS: "33.0.2"
|
ANDROID_BUILD_TOOLS: "33.0.2"
|
||||||
|
|
||||||
# It's what version of the command line tools we're going to download from the official site.
|
|
||||||
# Official Site-> https://developer.android.com/studio/index.html
|
|
||||||
# There, look down below at the cli tools only, sdk tools package is of format:
|
|
||||||
# commandlinetools-os_type-ANDROID_SDK_TOOLS_latest.zip
|
|
||||||
# when the script was last modified for latest compileSdkVersion, it was which is written down below
|
|
||||||
ANDROID_SDK_TOOLS: "9477386"
|
ANDROID_SDK_TOOLS: "9477386"
|
||||||
|
|
||||||
# Packages installation before running script
|
# Keystore credentials stored as GitLab CI/CD variables
|
||||||
|
KEYSTORE_PASSWORD: $KS_PASSWORD
|
||||||
|
KEY_ALIAS: $KS_ALIAS
|
||||||
|
KEY_PASSWORD: $KS_KEY_PASSWORD
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- apt-get --quiet update --yes
|
- apt-get --quiet update --yes
|
||||||
- apt-get --quiet install --yes wget unzip
|
- apt-get --quiet install --yes wget unzip
|
||||||
|
|
||||||
# Setup path as android_home for moving/exporting the downloaded sdk into it
|
|
||||||
- export ANDROID_HOME="${PWD}/android-sdk-root"
|
- export ANDROID_HOME="${PWD}/android-sdk-root"
|
||||||
# Create a new directory at specified location
|
|
||||||
- install -d $ANDROID_HOME
|
- install -d $ANDROID_HOME
|
||||||
# Here we are installing androidSDK tools from official source,
|
|
||||||
# (the key thing here is the url from where you are downloading these sdk tool for command line, so please do note this url pattern there and here as well)
|
|
||||||
# after that unzipping those tools and
|
|
||||||
# then running a series of SDK manager commands to install necessary android SDK packages that'll allow the app to build
|
|
||||||
- wget --no-verbose --output-document=$ANDROID_HOME/cmdline-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS}_latest.zip
|
- wget --no-verbose --output-document=$ANDROID_HOME/cmdline-tools.zip https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS}_latest.zip
|
||||||
- unzip -q -d "$ANDROID_HOME/cmdline-tools" "$ANDROID_HOME/cmdline-tools.zip"
|
- unzip -q -d "$ANDROID_HOME/cmdline-tools" "$ANDROID_HOME/cmdline-tools.zip"
|
||||||
- mv -T "$ANDROID_HOME/cmdline-tools/cmdline-tools" "$ANDROID_HOME/cmdline-tools/tools"
|
- mv -T "$ANDROID_HOME/cmdline-tools/cmdline-tools" "$ANDROID_HOME/cmdline-tools/tools"
|
||||||
- export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/cmdline-tools/tools/bin
|
- export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/cmdline-tools/tools/bin
|
||||||
|
|
||||||
# Nothing fancy here, just checking sdkManager version
|
|
||||||
- sdkmanager --version
|
- sdkmanager --version
|
||||||
|
|
||||||
# use yes to accept all licenses
|
|
||||||
- yes | sdkmanager --licenses > /dev/null || true
|
- yes | sdkmanager --licenses > /dev/null || true
|
||||||
- sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}"
|
- sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}"
|
||||||
- sdkmanager "platform-tools"
|
- sdkmanager "platform-tools"
|
||||||
- sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}"
|
- sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}"
|
||||||
|
|
||||||
# Not necessary, but just for surity
|
|
||||||
- chmod +x ./gradlew
|
- chmod +x ./gradlew
|
||||||
|
|
||||||
# Basic android and gradle stuff
|
|
||||||
# Check linting
|
|
||||||
lintDebug:
|
lintDebug:
|
||||||
interruptible: true
|
interruptible: true
|
||||||
stage: build
|
stage: build
|
||||||
@@ -69,7 +37,6 @@ lintDebug:
|
|||||||
expose_as: "lint-report"
|
expose_as: "lint-report"
|
||||||
when: always
|
when: always
|
||||||
|
|
||||||
# Make Project
|
|
||||||
assembleDebug:
|
assembleDebug:
|
||||||
interruptible: true
|
interruptible: true
|
||||||
stage: build
|
stage: build
|
||||||
@@ -79,7 +46,67 @@ assembleDebug:
|
|||||||
paths:
|
paths:
|
||||||
- app/build/outputs/
|
- app/build/outputs/
|
||||||
|
|
||||||
# Run all tests, if any fails, interrupt the pipeline(fail it)
|
# Job for building signed release APK for tags containing "release" on any branch
|
||||||
|
assembleRelease:
|
||||||
|
stage: build
|
||||||
|
script:
|
||||||
|
- |
|
||||||
|
if [[ "$CI_COMMIT_TAG" =~ release ]]; then
|
||||||
|
echo "Decoding keystore file from Base64"
|
||||||
|
|
||||||
|
# Debug: Print the first few characters of BASE64_KEYSTORE
|
||||||
|
echo "First 20 characters of BASE64_KEYSTORE: ${BASE64_KEYSTORE:0:20}..."
|
||||||
|
|
||||||
|
# Check if BASE64_KEYSTORE is a file path
|
||||||
|
if [[ "$BASE64_KEYSTORE" == /* ]] && [[ -f "$BASE64_KEYSTORE" ]]; then
|
||||||
|
echo "BASE64_KEYSTORE appears to be a file path. Reading content..."
|
||||||
|
BASE64_CONTENT=$(cat "$BASE64_KEYSTORE")
|
||||||
|
else
|
||||||
|
echo "BASE64_KEYSTORE is not a file path. Using as-is."
|
||||||
|
BASE64_CONTENT="$BASE64_KEYSTORE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove any potential whitespace or newline characters
|
||||||
|
CLEANED_KEYSTORE=$(echo "$BASE64_CONTENT" | tr -d '[:space:]')
|
||||||
|
|
||||||
|
# Attempt to decode and save to a file
|
||||||
|
if echo "$CLEANED_KEYSTORE" | base64 -d > "$CI_PROJECT_DIR/app/keystore.jks" 2>/tmp/base64_error; then
|
||||||
|
echo "Keystore file decoded successfully"
|
||||||
|
else
|
||||||
|
echo "Error decoding keystore file:"
|
||||||
|
cat /tmp/base64_error
|
||||||
|
echo "First 20 characters of cleaned content: ${CLEANED_KEYSTORE:0:20}..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if the keystore file was created and has content
|
||||||
|
if [ -s "$CI_PROJECT_DIR/app/keystore.jks" ]; then
|
||||||
|
echo "Keystore file created successfully"
|
||||||
|
# Print file size for verification
|
||||||
|
ls -l "$CI_PROJECT_DIR/app/keystore.jks"
|
||||||
|
else
|
||||||
|
echo "Error: Keystore file is empty or not created"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Building signed release APK"
|
||||||
|
./gradlew assembleRelease \
|
||||||
|
-Pandroid.injected.signing.store.file="$CI_PROJECT_DIR/app/keystore.jks" \
|
||||||
|
-Pandroid.injected.signing.store.password="$KEYSTORE_PASSWORD" \
|
||||||
|
-Pandroid.injected.signing.key.alias="$KEY_ALIAS" \
|
||||||
|
-Pandroid.injected.signing.key.password="$KEY_PASSWORD"
|
||||||
|
else
|
||||||
|
echo "Tag '$CI_COMMIT_TAG' does not contain 'release'. Skipping release build."
|
||||||
|
fi
|
||||||
|
artifacts:
|
||||||
|
paths:
|
||||||
|
- app/build/outputs/
|
||||||
|
expire_in: never
|
||||||
|
rules:
|
||||||
|
- if: $CI_COMMIT_TAG =~ /release/
|
||||||
|
when: always
|
||||||
|
- when: never
|
||||||
|
|
||||||
debugTests:
|
debugTests:
|
||||||
needs: [lintDebug, assembleDebug]
|
needs: [lintDebug, assembleDebug]
|
||||||
interruptible: true
|
interruptible: true
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ android {
|
|||||||
namespace 'in.sminnovations.hpostesting'
|
namespace 'in.sminnovations.hpostesting'
|
||||||
|
|
||||||
// dev -> development, quality -> qc, uat -> User Acceptance Testing, preprod -> preproduction, prod -> production, iocl -> iocl-iisc production
|
// dev -> development, quality -> qc, uat -> User Acceptance Testing, preprod -> preproduction, prod -> production, iocl -> iocl-iisc production
|
||||||
// server -> for server switching for internal test
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "in.sminnovations.hpostesting.server"
|
applicationId "in.sminnovations.hpostesting.dev"
|
||||||
minSdk 21
|
minSdk 21
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 130
|
versionCode 128
|
||||||
versionName "2.1.130"
|
versionName "2.1.128"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,6 @@ android {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation "com.google.dagger:hilt-android:2.46"
|
implementation "com.google.dagger:hilt-android:2.46"
|
||||||
implementation 'androidx.activity:activity:1.8.0'
|
implementation 'androidx.activity:activity:1.8.0'
|
||||||
implementation 'androidx.compose.ui:ui-android:1.7.6'
|
|
||||||
kapt "com.google.dagger:hilt-android-compiler: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'
|
||||||
@@ -125,6 +124,7 @@ dependencies {
|
|||||||
implementation 'com.github.mik3y:usb-serial-for-android:3.8.0'
|
implementation 'com.github.mik3y:usb-serial-for-android:3.8.0'
|
||||||
|
|
||||||
implementation "androidx.fragment:fragment-ktx:1.6.2"
|
implementation "androidx.fragment:fragment-ktx:1.6.2"
|
||||||
|
|
||||||
// CSV read, write
|
// CSV read, write
|
||||||
implementation 'com.opencsv:opencsv:5.9'
|
implementation 'com.opencsv:opencsv:5.9'
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,178 @@
|
|||||||
"client": [
|
"client": [
|
||||||
{
|
{
|
||||||
"client_info": {
|
"client_info": {
|
||||||
"mobilesdk_app_id": "1:650071678820:android:f6fd45e2f6a63aef6c6471",
|
"mobilesdk_app_id": "1:650071678820:android:f1435a1c07f710036c6471",
|
||||||
"android_client_info": {
|
"android_client_info": {
|
||||||
"package_name": "in.sminnovations.hpostesting.server"
|
"package_name": "com.example.hposconsentform"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:650071678820:android:7865bef608cdee6f6c6471",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "com.smi.counselling"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:650071678820:android:2925e9ce3417d2386c6471",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "in.sminnovations.hemocube"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-srhm9spm9hjn4frcd3r6o02gdhdbtd15.apps.googleusercontent.com",
|
||||||
|
"client_type": 1,
|
||||||
|
"android_info": {
|
||||||
|
"package_name": "in.sminnovations.hemocube",
|
||||||
|
"certificate_hash": "7714b9268a81d0cf0fb178b0af8dbb630f8fc70a"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:650071678820:android:7569c1cad4fc99916c6471",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "in.sminnovations.hposregistration"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-70kp5jvjda4r5diqch2kn4lc40p4f42g.apps.googleusercontent.com",
|
||||||
|
"client_type": 1,
|
||||||
|
"android_info": {
|
||||||
|
"package_name": "in.sminnovations.hposregistration",
|
||||||
|
"certificate_hash": "7714b9268a81d0cf0fb178b0af8dbb630f8fc70a"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:650071678820:android:f96be19e5d43102b6c6471",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "in.sminnovations.hpostesting"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-l87dnr0bdj95get0khgnvfv2an1k6ogq.apps.googleusercontent.com",
|
||||||
|
"client_type": 1,
|
||||||
|
"android_info": {
|
||||||
|
"package_name": "in.sminnovations.hpostesting",
|
||||||
|
"certificate_hash": "7714b9268a81d0cf0fb178b0af8dbb630f8fc70a"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"api_key": [
|
||||||
|
{
|
||||||
|
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"services": {
|
||||||
|
"appinvite_service": {
|
||||||
|
"other_platform_oauth_client": [
|
||||||
|
{
|
||||||
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
|
"client_type": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"client_info": {
|
||||||
|
"mobilesdk_app_id": "1:650071678820:android:a53292637abb7c0d6c6471",
|
||||||
|
"android_client_info": {
|
||||||
|
"package_name": "in.sminnovations.hpostesting.dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"oauth_client": [
|
"oauth_client": [
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
"type": "SINGLE",
|
"type": "SINGLE",
|
||||||
"filters": [],
|
"filters": [],
|
||||||
"attributes": [],
|
"attributes": [],
|
||||||
"versionCode": 127,
|
"versionCode": 128,
|
||||||
"versionName": "2.1.127",
|
"versionName": "2.1.128",
|
||||||
"outputFile": "app-release.apk"
|
"outputFile": "app-release.apk"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -25,12 +25,6 @@
|
|||||||
|
|
||||||
<uses-permission android:name="android.permission.USB_PERMISSION" />
|
<uses-permission android:name="android.permission.USB_PERMISSION" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
|
||||||
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
|
|
||||||
<uses-permission android:name="android.permission.ACCOUNT_MANAGER"
|
|
||||||
tools:ignore="ProtectedPermissions" />
|
|
||||||
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name="com.example.hpostesting.HPOSTestingApplication"
|
android:name="com.example.hpostesting.HPOSTestingApplication"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
@@ -68,7 +62,6 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.usb_teminal.UsbTerminalActivity"
|
android:name="com.example.hpostesting.presentation.usb_teminal.UsbTerminalActivity"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:launchMode="singleInstance"
|
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.deviceinfo.DeviceActivity"
|
android:name="com.example.hpostesting.presentation.deviceinfo.DeviceActivity"
|
||||||
@@ -135,8 +128,7 @@
|
|||||||
android:theme="@style/Theme.HPOS.NoActionBar" />
|
android:theme="@style/Theme.HPOS.NoActionBar" />
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.dashboard.DashboardActivity"
|
android:name="com.example.hpostesting.presentation.dashboard.DashboardActivity"
|
||||||
android:exported="true"
|
android:exported="false"
|
||||||
android:permission=""
|
|
||||||
android:label="@string/title_activity_dashboard"
|
android:label="@string/title_activity_dashboard"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:theme="@style/Theme.HPOS.NoActionBar"
|
android:theme="@style/Theme.HPOS.NoActionBar"
|
||||||
@@ -178,9 +170,8 @@
|
|||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.testRight.TestRightActivity"
|
android:name="com.example.hpostesting.presentation.testRight.TestRightActivity"
|
||||||
android:exported="true"
|
android:exported="false"
|
||||||
android:noHistory="true"
|
android:noHistory="true"
|
||||||
android:permission=""
|
|
||||||
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">
|
||||||
@@ -197,9 +188,7 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name="com.example.hpostesting.presentation.MainActivity"
|
android:name="com.example.hpostesting.presentation.MainActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:permission=""
|
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:launchMode="singleInstance"
|
|
||||||
android:theme="@style/AppTheme.NoActionBar">
|
android:theme="@style/AppTheme.NoActionBar">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
|
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
|
||||||
|
|||||||
@@ -14,28 +14,25 @@
|
|||||||
package com.example.hpostesting
|
package com.example.hpostesting
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import com.example.hpostesting.firebase.FirebaseManager
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
import com.google.firebase.firestore.FirebaseFirestoreSettings
|
import com.google.firebase.firestore.FirebaseFirestoreSettings
|
||||||
import dagger.hilt.android.HiltAndroidApp
|
import dagger.hilt.android.HiltAndroidApp
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.SupervisorJob
|
import kotlinx.coroutines.SupervisorJob
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@HiltAndroidApp
|
@HiltAndroidApp
|
||||||
class HPOSTestingApplication : Application() {
|
class HPOSTestingApplication : Application() {
|
||||||
@Inject
|
val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||||
lateinit var firebaseManager: FirebaseManager
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||||
|
|
||||||
// You can now use firebaseManager here after Hilt injects it
|
|
||||||
val firestoreSettings = FirebaseFirestoreSettings.Builder()
|
val firestoreSettings = FirebaseFirestoreSettings.Builder()
|
||||||
.setPersistenceEnabled(true) // Enable offline persistence if needed
|
.setPersistenceEnabled(true) // Enable offline persistence if needed
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val firestore = firebaseManager.getCurrentFirestoreF()
|
val firestore = FirebaseFirestore.getInstance()
|
||||||
firestore.firestoreSettings = firestoreSettings
|
firestore.firestoreSettings = firestoreSettings
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,6 +43,10 @@ interface MolbioResultApi {
|
|||||||
@Body checkUpdateRequest: CheckUpdateRequest,
|
@Body checkUpdateRequest: CheckUpdateRequest,
|
||||||
): CheckUpdateResponse
|
): CheckUpdateResponse
|
||||||
|
|
||||||
|
// @POST("deviceService/device/getUpdate")
|
||||||
|
// suspend fun deviceUpdate(
|
||||||
|
// @Body deviceUpdateRequest: DeviceUpdateRequest,
|
||||||
|
// ): ResponseBody
|
||||||
@POST("deviceService/device/getUpdate")
|
@POST("deviceService/device/getUpdate")
|
||||||
suspend fun deviceUpdate(
|
suspend fun deviceUpdate(
|
||||||
@Body deviceUpdateRequest: DeviceUpdateRequest,
|
@Body deviceUpdateRequest: DeviceUpdateRequest,
|
||||||
|
|||||||
@@ -1628,4 +1628,177 @@ object Constants {
|
|||||||
const val bufferMaxLed1 = 23000.00
|
const val bufferMaxLed1 = 23000.00
|
||||||
const val bufferMinLed2 = 17000.00
|
const val bufferMinLed2 = 17000.00
|
||||||
const val bufferMaxLed2 = 19000.00
|
const val bufferMaxLed2 = 19000.00
|
||||||
|
|
||||||
|
|
||||||
|
// val STATICID = listOf(
|
||||||
|
// "FACTORY",
|
||||||
|
// "ADMIN",
|
||||||
|
// "PQUSER",
|
||||||
|
// "QCUSER",
|
||||||
|
// "VIZ-1000-0004",
|
||||||
|
// "VIZ-1000-0005",
|
||||||
|
// "VIZ-1000-0006",
|
||||||
|
// "HC-V1-001",
|
||||||
|
// "HC-V1-002",
|
||||||
|
// "HC-V1-003",
|
||||||
|
// "HC-V1-004",
|
||||||
|
// "HC-V1-005",
|
||||||
|
// "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-1015",
|
||||||
|
// "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",
|
||||||
|
// "HCV-000-3011",
|
||||||
|
// "HCV-000-3012",
|
||||||
|
// "HCV-000-3013",
|
||||||
|
// "HCV-000-3014",
|
||||||
|
// "HCV-000-3015",
|
||||||
|
// "HCV-000-3016",
|
||||||
|
// "HCV-000-3017",
|
||||||
|
// "HCV-000-3018",
|
||||||
|
// "HCV-000-3019",
|
||||||
|
// "HCV-000-3020",
|
||||||
|
// "HCV-000-3021",
|
||||||
|
// "HCV-000-3022",
|
||||||
|
// "HCV-000-3023",
|
||||||
|
// "HCV-000-3024",
|
||||||
|
// "HCV-000-3025",
|
||||||
|
// "HCV-000-3026",
|
||||||
|
// "HCV-000-3027",
|
||||||
|
// "HCV-000-3028",
|
||||||
|
// "HCV-000-3029",
|
||||||
|
// "HCV-000-3030",
|
||||||
|
// "HPP1-0124-0001",
|
||||||
|
// "HPP1-0124-0002",
|
||||||
|
// "HPP1-0124-0003",
|
||||||
|
// "HPP1-0124-0004",
|
||||||
|
// "HPP1-0124-0005",
|
||||||
|
// "HPP1-0124-0006",
|
||||||
|
// "HPP1-0124-0007",
|
||||||
|
// "HPP1-0124-0008",
|
||||||
|
// "HPP1-0124-0009",
|
||||||
|
// "HPP1-0124-0010",
|
||||||
|
// "HPP1-0124-0011",
|
||||||
|
// "HPP1-0124-0012",
|
||||||
|
// "HPP1-0124-0013",
|
||||||
|
// "HPP1-0124-0014",
|
||||||
|
// "HPP1-0124-0015",
|
||||||
|
// "HPP1-0124-0016",
|
||||||
|
// "HPP1-0124-0017",
|
||||||
|
// "HPP1-0124-0018",
|
||||||
|
// "HPP1-0124-0019",
|
||||||
|
// "HPP1-0124-0020",
|
||||||
|
// "HPP1-0124-0021",
|
||||||
|
// "HPP1-0124-0022",
|
||||||
|
// "HPP1-0124-0023",
|
||||||
|
// "HPP1-0124-0024",
|
||||||
|
// "HPP1-0124-0025",
|
||||||
|
// "HPP1-0124-0026",
|
||||||
|
// "HPP1-0124-0027",
|
||||||
|
// "HPP1-0124-0028",
|
||||||
|
// "HPP1-0124-0029",
|
||||||
|
// "HPP1-0124-0030",
|
||||||
|
// "HPP1-0124-0031",
|
||||||
|
// "HPP1-0124-0032",
|
||||||
|
// "HPP1-0124-0033",
|
||||||
|
// "HPP1-0124-0034",
|
||||||
|
// "HPP1-0124-0035",
|
||||||
|
// "HPP1-0124-0036",
|
||||||
|
// "HPP1-0124-0037",
|
||||||
|
// "HPP1-0124-0038",
|
||||||
|
// "HPP1-0124-0039",
|
||||||
|
// "HPP1-0124-0040",
|
||||||
|
// "HPP1-0124-0041",
|
||||||
|
// "HPP1-0124-0042",
|
||||||
|
// "HPP1-0124-0043",
|
||||||
|
// "HPP1-0124-0044",
|
||||||
|
// "HPP1-0124-0045",
|
||||||
|
// "HPP1-0124-0046",
|
||||||
|
// "HPP1-0124-0047",
|
||||||
|
// "HPP1-0124-0048",
|
||||||
|
// "HPP1-0124-0049",
|
||||||
|
// "HPP1-0124-0050",
|
||||||
|
// "HCV-001-0001",
|
||||||
|
// "HCV-001-0002",
|
||||||
|
// "HCV-001-0003",
|
||||||
|
// "HCV-001-0004",
|
||||||
|
// "HCV-001-0005",
|
||||||
|
// "HCV-001-0006",
|
||||||
|
// "HCV-001-0007",
|
||||||
|
// "HCV-001-0008",
|
||||||
|
// "HCV-001-0009",
|
||||||
|
// "HCV-001-0010",
|
||||||
|
// "HCV-001-0011",
|
||||||
|
// "HCV-001-0012",
|
||||||
|
// "HCV-001-0013",
|
||||||
|
// "HCV-001-0014",
|
||||||
|
// "HCV-001-0015",
|
||||||
|
// "HCV-001-0016",
|
||||||
|
// "HCV-001-0017",
|
||||||
|
// "HCV-001-0018",
|
||||||
|
// "HCV-001-0019",
|
||||||
|
// "HCV-001-0020",
|
||||||
|
// "HCV-001-0021",
|
||||||
|
// "HCV-001-0022",
|
||||||
|
// "HCV-001-0023",
|
||||||
|
// "HCV-001-0024",
|
||||||
|
// "HCV-001-0025",
|
||||||
|
// "HCV-001-0026",
|
||||||
|
// "HCV-001-0027",
|
||||||
|
// "HCV-001-0028",
|
||||||
|
// "HCV-001-0029",
|
||||||
|
// "HCV-001-0030",
|
||||||
|
// "HCV-001-0031",
|
||||||
|
// "HCV-001-0032",
|
||||||
|
// "HCV-001-0033",
|
||||||
|
// "HCV-001-0034",
|
||||||
|
// "HCV-001-0003",
|
||||||
|
// "HCV-001-0035",
|
||||||
|
// "HCV-001-0036",
|
||||||
|
// "HCV-001-0037",
|
||||||
|
// "HCV-001-0038",
|
||||||
|
// "HCV-001-0039",
|
||||||
|
// "HCV-001-0040",
|
||||||
|
// "HCV-001-0041",
|
||||||
|
// "HCV-001-0042",
|
||||||
|
// "HCV-001-0043",
|
||||||
|
// "HCV-001-0044",
|
||||||
|
// "HCV-001-0045",
|
||||||
|
// "HCV-001-0046",
|
||||||
|
// "HCV-001-0047",
|
||||||
|
// "HCV-001-0048",
|
||||||
|
// "HCV-001-0049",
|
||||||
|
// "HCV-001-0050",
|
||||||
|
// "HCV-000-6001",
|
||||||
|
// "HCV-000-6002",
|
||||||
|
// "HCV-000-6003",
|
||||||
|
// "HCV-000-6004",
|
||||||
|
// "HCV-000-6005",
|
||||||
|
// "HCV-000-6006",
|
||||||
|
// "HCV-000-6007",
|
||||||
|
// "HCV-000-6008",
|
||||||
|
// "HCV-000-6009",
|
||||||
|
// "HCV-000-6010",
|
||||||
|
// )
|
||||||
|
//
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
package com.example.hpostesting.data.repository
|
package com.example.hpostesting.data.repository
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import com.example.hpostesting.util.Result
|
||||||
import com.example.hpostesting.data.api.MolbioAuthApi
|
import com.example.hpostesting.data.api.MolbioAuthApi
|
||||||
import com.example.hpostesting.data.api.MolbioResultApi
|
import com.example.hpostesting.data.api.MolbioResultApi
|
||||||
import com.example.hpostesting.data.model.PendingUploads
|
import com.example.hpostesting.data.model.PendingUploads
|
||||||
@@ -36,12 +37,11 @@ import com.example.hpostesting.data.model.patient.UserData
|
|||||||
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
||||||
import com.example.hpostesting.data.model.updates.CheckUpdateResponse
|
import com.example.hpostesting.data.model.updates.CheckUpdateResponse
|
||||||
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
||||||
import com.example.hpostesting.firebase.FirebaseManager
|
|
||||||
import com.example.hpostesting.util.Result
|
|
||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
import com.google.firebase.firestore.FirebaseFirestore
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
|
import com.google.firebase.firestore.ktx.firestore
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import com.google.firebase.storage.FirebaseStorage
|
import com.google.firebase.storage.ktx.storage
|
||||||
import kotlinx.coroutines.tasks.await
|
import kotlinx.coroutines.tasks.await
|
||||||
import okhttp3.MultipartBody
|
import okhttp3.MultipartBody
|
||||||
import okhttp3.ResponseBody
|
import okhttp3.ResponseBody
|
||||||
@@ -55,15 +55,10 @@ class NetworkException(message: String, cause: Throwable) : Exception(message, c
|
|||||||
class DatabaseRepository @Inject constructor(
|
class DatabaseRepository @Inject constructor(
|
||||||
@Named("Auth") private val molbioAuthApi: MolbioAuthApi,
|
@Named("Auth") private val molbioAuthApi: MolbioAuthApi,
|
||||||
private val molbioResultApi: MolbioResultApi,
|
private val molbioResultApi: MolbioResultApi,
|
||||||
private val firebaseManager: FirebaseManager,
|
|
||||||
) : Repository {
|
) : Repository {
|
||||||
|
|
||||||
private val localdb: FirebaseFirestore
|
private val db: FirebaseFirestore = Firebase.firestore
|
||||||
get() = firebaseManager.getCurrentFirestoreF()
|
private val storage = Firebase.storage
|
||||||
|
|
||||||
private val localStg: FirebaseStorage
|
|
||||||
get() = firebaseManager.getCurrentStorageF()
|
|
||||||
|
|
||||||
|
|
||||||
private suspend fun <T : Any> safeApiCall(apiCall: suspend () -> T): Result<T> {
|
private suspend fun <T : Any> safeApiCall(apiCall: suspend () -> T): Result<T> {
|
||||||
return try {
|
return try {
|
||||||
@@ -113,13 +108,13 @@ class DatabaseRepository @Inject constructor(
|
|||||||
override suspend fun addTestToDatabase(data: HemoCubeTestData?): Response<String> {
|
override suspend fun addTestToDatabase(data: HemoCubeTestData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
val userdata =
|
val userdata =
|
||||||
localdb.collection("patientData").whereEqualTo("_id", data!!._id).get().await()
|
db.collection("patientData").whereEqualTo("_id", data!!._id).get().await()
|
||||||
if (userdata.documents.isNotEmpty()) {
|
if (userdata.documents.isNotEmpty()) {
|
||||||
userdata.documents.forEach {
|
userdata.documents.forEach {
|
||||||
localdb.collection("patientData").document(it.id).update("testStatus", true)
|
db.collection("patientData").document(it.id).update("testStatus", true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
localdb.collection("testData").add(data).await()
|
db.collection("testData").add(data).await()
|
||||||
Response.Success(data._id)
|
Response.Success(data._id)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Response.Error(e)
|
Response.Error(e)
|
||||||
@@ -128,7 +123,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
override suspend fun addQcTestToDatabase(data: HemoCubeTestData?): Response<String> {
|
override suspend fun addQcTestToDatabase(data: HemoCubeTestData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
|
|
||||||
localdb.collection("qcData").add(data!!).await()
|
db.collection("qcData").add(data!!).await()
|
||||||
Response.Success(data._id)
|
Response.Success(data._id)
|
||||||
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@@ -142,7 +137,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
|
|
||||||
override suspend fun addTestToDatabaseforBufferCheck(data: BufferCheckData?): Response<String> {
|
override suspend fun addTestToDatabaseforBufferCheck(data: BufferCheckData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
localdb.collection("buffers").add(data!!).await()
|
db.collection("buffers").add(data!!).await()
|
||||||
Response.Success(data.kitno)
|
Response.Success(data.kitno)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
@@ -152,7 +147,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
|
|
||||||
override suspend fun addDiagnostics(data: DiagnosticsData?): Response<String> {
|
override suspend fun addDiagnostics(data: DiagnosticsData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
localdb.collection("diagnostics").add(data!!).await()
|
db.collection("diagnostics").add(data!!).await()
|
||||||
Response.Success(data.deviceId)
|
Response.Success(data.deviceId)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
@@ -163,7 +158,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
|
|
||||||
override suspend fun addTestJigData(data: JigData?): Response<String> {
|
override suspend fun addTestJigData(data: JigData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
localdb.collection("jigs").add(data!!).await()
|
db.collection("jigs").add(data!!).await()
|
||||||
Response.Success(data.deviceId)
|
Response.Success(data.deviceId)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
@@ -177,7 +172,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
val file = Uri.fromFile(File(filePath))
|
val file = Uri.fromFile(File(filePath))
|
||||||
val riversRef = localStg.reference.child("$patientID/${file.lastPathSegment}")
|
val riversRef = storage.reference.child("$patientID/${file.lastPathSegment}")
|
||||||
riversRef.putFile(file).await()
|
riversRef.putFile(file).await()
|
||||||
return Response.Success(true)
|
return Response.Success(true)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@@ -188,7 +183,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
|
|
||||||
suspend fun addToPendingQueue(pendingUploads: PendingUploads): Response<Boolean> {
|
suspend fun addToPendingQueue(pendingUploads: PendingUploads): Response<Boolean> {
|
||||||
return try {
|
return try {
|
||||||
localdb.collection("pendingUploads").document(pendingUploads.pendingId).set(pendingUploads)
|
db.collection("pendingUploads").document(pendingUploads.pendingId).set(pendingUploads)
|
||||||
.await()
|
.await()
|
||||||
|
|
||||||
Response.Success(true)
|
Response.Success(true)
|
||||||
@@ -201,7 +196,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
suspend fun getAllFromPendingQueue(): List<PendingUploads> {
|
suspend fun getAllFromPendingQueue(): List<PendingUploads> {
|
||||||
val pendingList = mutableListOf<PendingUploads>()
|
val pendingList = mutableListOf<PendingUploads>()
|
||||||
return try {
|
return try {
|
||||||
val querySnapshot = localdb.collection("pendingUploads").orderBy("timeAdded").get().await()
|
val querySnapshot = db.collection("pendingUploads").orderBy("timeAdded").get().await()
|
||||||
|
|
||||||
for (doc in querySnapshot.documents) {
|
for (doc in querySnapshot.documents) {
|
||||||
val pendingFile = doc.toObject(PendingUploads::class.java)
|
val pendingFile = doc.toObject(PendingUploads::class.java)
|
||||||
@@ -219,7 +214,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
|
|
||||||
suspend fun removeFromPendingQueue(fileName: String): Response<Boolean> {
|
suspend fun removeFromPendingQueue(fileName: String): Response<Boolean> {
|
||||||
return try {
|
return try {
|
||||||
localdb.collection("pendingUploads").document(fileName).delete().await()
|
db.collection("pendingUploads").document(fileName).delete().await()
|
||||||
|
|
||||||
Response.Success(true)
|
Response.Success(true)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@@ -229,11 +224,11 @@ class DatabaseRepository @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun getDeviceData(): List<DeviceData> {
|
suspend fun getDeviceData(): List<DeviceData> {
|
||||||
return localdb.collection("devices").get().await().toObjects(DeviceData::class.java)
|
return db.collection("devices").get().await().toObjects(DeviceData::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getDeviceDataById(deviceId: String): DeviceData? {
|
override suspend fun getDeviceDataById(deviceId: String): DeviceData? {
|
||||||
val querySnapshot = localdb.collection("devices").get().await()
|
val querySnapshot = db.collection("devices").get().await()
|
||||||
val allDeviceDataList = querySnapshot.toObjects(DeviceData::class.java)
|
val allDeviceDataList = querySnapshot.toObjects(DeviceData::class.java)
|
||||||
|
|
||||||
// Find the DeviceData object with the specified deviceId
|
// Find the DeviceData object with the specified deviceId
|
||||||
@@ -242,7 +237,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
|
|
||||||
override suspend fun getDeviceResponse(data: DeviceData?): Response<String> {
|
override suspend fun getDeviceResponse(data: DeviceData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
localdb.collection("devices").add(data!!).await()
|
db.collection("devices").add(data!!).await()
|
||||||
Response.Success(data.deviceProvisionResponse)
|
Response.Success(data.deviceProvisionResponse)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
@@ -252,7 +247,7 @@ class DatabaseRepository @Inject constructor(
|
|||||||
|
|
||||||
override suspend fun uploadDeviceId(data: DeviceData): Response<String>? {
|
override suspend fun uploadDeviceId(data: DeviceData): Response<String>? {
|
||||||
return try {
|
return try {
|
||||||
localdb.collection("devices").add(data!!).await()
|
db.collection("devices").add(data!!).await()
|
||||||
Response.Success(data.deviceId)
|
Response.Success(data.deviceId)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
@@ -267,13 +262,13 @@ class DatabaseRepository @Inject constructor(
|
|||||||
override suspend fun addTestToDatabasefornew(data: HemoCubeTestData?): Response<String> {
|
override suspend fun addTestToDatabasefornew(data: HemoCubeTestData?): Response<String> {
|
||||||
return try {
|
return try {
|
||||||
val userdata =
|
val userdata =
|
||||||
localdb.collection("patientData").whereEqualTo("_id", data!!._id).get().await()
|
db.collection("patientData").whereEqualTo("_id", data!!._id).get().await()
|
||||||
if (userdata.documents.isNotEmpty()) {
|
if (userdata.documents.isNotEmpty()) {
|
||||||
userdata.documents.forEach {
|
userdata.documents.forEach {
|
||||||
localdb.collection("patientData").document(it.id).update("testStatus", true)
|
db.collection("patientData").document(it.id).update("testStatus", true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
localdb.collection("testData").add(data).await()
|
db.collection("testData").add(data).await()
|
||||||
Response.Success(data._id)
|
Response.Success(data._id)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
|
|||||||
@@ -13,7 +13,13 @@
|
|||||||
|
|
||||||
package com.example.hpostesting.data.repository
|
package com.example.hpostesting.data.repository
|
||||||
|
|
||||||
|
import android.os.Environment
|
||||||
import com.example.hpostesting.data.datasource.LocalFileDataSource
|
import com.example.hpostesting.data.datasource.LocalFileDataSource
|
||||||
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
|
import com.opencsv.CSVWriter
|
||||||
|
import java.io.File
|
||||||
|
import java.io.FileWriter
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
class LocalFileRepository(private val localFileDataSource: LocalFileDataSource) {
|
class LocalFileRepository(private val localFileDataSource: LocalFileDataSource) {
|
||||||
fun saveCsvToDisk(filepath: String, contents: ArrayList<Array<String>>) =
|
fun saveCsvToDisk(filepath: String, contents: ArrayList<Array<String>>) =
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import androidx.room.Room
|
|||||||
import com.example.hpostesting.data.api.MolbioAuthApi
|
import com.example.hpostesting.data.api.MolbioAuthApi
|
||||||
import com.example.hpostesting.data.api.MolbioResultApi
|
import com.example.hpostesting.data.api.MolbioResultApi
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.util.PropertyProvider
|
||||||
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
||||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||||
import com.example.hpostesting.data.dao.MyDatabase
|
import com.example.hpostesting.data.dao.MyDatabase
|
||||||
@@ -35,13 +36,9 @@ import com.example.hpostesting.domain.LogFileManager
|
|||||||
import com.example.hpostesting.domain.LogFileManagerImpl
|
import com.example.hpostesting.domain.LogFileManagerImpl
|
||||||
import com.example.hpostesting.domain.SaveRawData
|
import com.example.hpostesting.domain.SaveRawData
|
||||||
import com.example.hpostesting.domain.SaveRawDataTest
|
import com.example.hpostesting.domain.SaveRawDataTest
|
||||||
import com.example.hpostesting.firebase.FirebaseManager
|
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListenerImpl
|
import com.example.hpostesting.presentation.utils.UsbServiceListenerImpl
|
||||||
import com.example.hpostesting.util.PropertyProvider
|
|
||||||
import com.example.hpostesting.util.PropertyProviderImpl
|
import com.example.hpostesting.util.PropertyProviderImpl
|
||||||
import com.google.firebase.firestore.FirebaseFirestore
|
|
||||||
import com.google.firebase.storage.FirebaseStorage
|
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
import dagger.hilt.InstallIn
|
import dagger.hilt.InstallIn
|
||||||
@@ -110,52 +107,22 @@ object AppModule {
|
|||||||
return SaveRawDataTest(repository)
|
return SaveRawDataTest(repository)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
fun provideFirebaseFirestore(): FirebaseFirestore {
|
|
||||||
return FirebaseFirestore.getInstance()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
fun provideFirebaseStorage(): FirebaseStorage {
|
|
||||||
return FirebaseStorage.getInstance()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
fun provideFirebaseManager(
|
|
||||||
@ApplicationContext context: Context,
|
|
||||||
): FirebaseManager {
|
|
||||||
return FirebaseManager(context)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun provideDatabaseRepository(
|
fun provideDatabaseRepository(
|
||||||
firebaseManager: FirebaseManager,
|
|
||||||
@Named("Auth") molbioAuthApi: MolbioAuthApi,
|
@Named("Auth") molbioAuthApi: MolbioAuthApi,
|
||||||
molbioResultApi: MolbioResultApi
|
molbioResultApi: MolbioResultApi
|
||||||
): DatabaseRepository {
|
): DatabaseRepository {
|
||||||
return DatabaseRepository(
|
return DatabaseRepository(molbioAuthApi = molbioAuthApi, molbioResultApi = molbioResultApi)
|
||||||
firebaseManager = firebaseManager,
|
|
||||||
molbioAuthApi = molbioAuthApi,
|
|
||||||
molbioResultApi = molbioResultApi
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun provideRepository(
|
fun provideRepository(
|
||||||
firebaseManager: FirebaseManager,
|
|
||||||
@Named("Auth") molbioAuthApi: MolbioAuthApi,
|
@Named("Auth") molbioAuthApi: MolbioAuthApi,
|
||||||
molbioResultApi: MolbioResultApi
|
molbioResultApi: MolbioResultApi
|
||||||
): Repository {
|
): Repository {
|
||||||
return DatabaseRepository(
|
return DatabaseRepository(molbioAuthApi, molbioResultApi)
|
||||||
firebaseManager = firebaseManager,
|
|
||||||
molbioAuthApi = molbioAuthApi,
|
|
||||||
molbioResultApi = molbioResultApi
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@@ -239,9 +206,4 @@ object AppModule {
|
|||||||
fun provideUsbServiceListener(context: Context): UsbServiceListener {
|
fun provideUsbServiceListener(context: Context): UsbServiceListener {
|
||||||
return UsbServiceListenerImpl(context)
|
return UsbServiceListenerImpl(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -44,6 +44,7 @@ class LogFileManagerImpl @Inject constructor(private val context: Context) : Log
|
|||||||
|
|
||||||
file
|
file
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
|
// Log.e("LogFileManager", "Error creating log file: ${e.message}")
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,21 +38,17 @@ class ResultCalculationWithMaxImpl : TestRightResultCalculation {
|
|||||||
var wavelengthOfAbsorbanceTwo = 0.0
|
var wavelengthOfAbsorbanceTwo = 0.0
|
||||||
|
|
||||||
for (each in wavelengthToAbsorbance) {
|
for (each in wavelengthToAbsorbance) {
|
||||||
when {
|
if (each[0] >= startWavelengthOne && each[0] < endWavelengthOne) {
|
||||||
each[0] >= startWavelengthOne && each[0] < endWavelengthOne -> {
|
if (each[1] > maxAbsorbanceAtOne) {
|
||||||
if (each[1] > maxAbsorbanceAtOne) {
|
maxAbsorbanceAtOne = each[1]
|
||||||
maxAbsorbanceAtOne = each[1]
|
wavelengthOfAbsorbanceOne = each[0]
|
||||||
wavelengthOfAbsorbanceOne = each[0]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
when {
|
if (each[0] >= startWavelengthTwo && each[0] < endWavelengthTwo) {
|
||||||
each[0] >= startWavelengthTwo && each[0] < endWavelengthTwo -> {
|
// maxAbsorbanceAtTwo = max(maxAbsorbanceAtTwo, each[1])
|
||||||
// maxAbsorbanceAtTwo = max(maxAbsorbanceAtTwo, each[1])
|
if (each[1] > maxAbsorbanceAtTwo) {
|
||||||
if (each[1] > maxAbsorbanceAtTwo) {
|
maxAbsorbanceAtTwo = each[1]
|
||||||
maxAbsorbanceAtTwo = each[1]
|
wavelengthOfAbsorbanceTwo = each[0]
|
||||||
wavelengthOfAbsorbanceTwo = each[0]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,32 +70,26 @@ class ResultCalculationWithMaxImpl : TestRightResultCalculation {
|
|||||||
val value = absorbanceAtWaveTwo / absorbanceAtWaveOne
|
val value = absorbanceAtWaveTwo / absorbanceAtWaveOne
|
||||||
testRightCalculationData.ratioValue = value
|
testRightCalculationData.ratioValue = value
|
||||||
|
|
||||||
when {
|
if (value <= 0.29) {
|
||||||
value <= 0.29 -> {
|
testRightCalculationData.ratioMinRange = 0.0
|
||||||
testRightCalculationData.ratioMinRange = 0.0
|
testRightCalculationData.ratioMaxRange = 0.29
|
||||||
testRightCalculationData.ratioMaxRange = 0.29
|
return TestRightResultType.NORMAL
|
||||||
return TestRightResultType.NORMAL
|
} else if (value > 0.29 && value <= 0.32) {
|
||||||
}
|
testRightCalculationData.ratioMinRange = 0.29
|
||||||
value > 0.29 && value <= 0.32 -> {
|
testRightCalculationData.ratioMaxRange = 0.32
|
||||||
testRightCalculationData.ratioMinRange = 0.29
|
return TestRightResultType.NEGATIVEBORDERLINE
|
||||||
testRightCalculationData.ratioMaxRange = 0.32
|
} else if (value > 0.32 && value <= 0.50) {
|
||||||
return TestRightResultType.NEGATIVEBORDERLINE
|
testRightCalculationData.ratioMinRange = 0.32
|
||||||
}
|
testRightCalculationData.ratioMaxRange = 0.50
|
||||||
value > 0.32 && value <= 0.50 -> {
|
return TestRightResultType.SICKLECELLTRAIT
|
||||||
testRightCalculationData.ratioMinRange = 0.32
|
} else if (value > 0.50 && value <= 0.55) {
|
||||||
testRightCalculationData.ratioMaxRange = 0.50
|
testRightCalculationData.ratioMinRange = 0.50
|
||||||
return TestRightResultType.SICKLECELLTRAIT
|
testRightCalculationData.ratioMaxRange = 0.55
|
||||||
}
|
return TestRightResultType.POSITIVEBORDERLINE
|
||||||
value > 0.50 && value <= 0.55 -> {
|
}else if (value > 0.55) {
|
||||||
testRightCalculationData.ratioMinRange = 0.50
|
testRightCalculationData.ratioMinRange = 0.55
|
||||||
testRightCalculationData.ratioMaxRange = 0.55
|
testRightCalculationData.ratioMaxRange = 999.0
|
||||||
return TestRightResultType.POSITIVEBORDERLINE
|
return TestRightResultType.SICKLECELLDISEASE
|
||||||
}
|
|
||||||
value > 0.55 -> {
|
|
||||||
testRightCalculationData.ratioMinRange = 0.55
|
|
||||||
testRightCalculationData.ratioMaxRange = 999.0
|
|
||||||
return TestRightResultType.SICKLECELLDISEASE
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class SaveRawData(private val localFileRepository: LocalFileRepository) {
|
|||||||
fun saveCsv(folderPath: String, fileName: String, matrix: ArrayList<ArrayList<Double>>) {
|
fun saveCsv(folderPath: String, fileName: String, matrix: ArrayList<ArrayList<Double>>) {
|
||||||
// try {
|
// try {
|
||||||
val fullPath = "$folderPath/$fileName"
|
val fullPath = "$folderPath/$fileName"
|
||||||
|
// val writer = CSVWriter(FileWriter(fullPath))
|
||||||
|
|
||||||
sort(matrix) { one: ArrayList<Double>, two: ArrayList<Double> ->
|
sort(matrix) { one: ArrayList<Double>, two: ArrayList<Double> ->
|
||||||
one[0].compareTo(two[0])
|
one[0].compareTo(two[0])
|
||||||
@@ -38,6 +39,7 @@ class SaveRawData(private val localFileRepository: LocalFileRepository) {
|
|||||||
for (eachRow in matrix) {
|
for (eachRow in matrix) {
|
||||||
|
|
||||||
if (eachRow[0] >= Constants.MIN_WAVELENGTH_RANGE_TO_RECORD && eachRow[0] < Constants.MAX_WAVELENGTH_RANGE_TO_RECORD + 1) {
|
if (eachRow[0] >= Constants.MIN_WAVELENGTH_RANGE_TO_RECORD && eachRow[0] < Constants.MAX_WAVELENGTH_RANGE_TO_RECORD + 1) {
|
||||||
|
// val rowContent = arrayOf(String.format("%.3f", eachRow[0]), String.format("%.3f", eachRow[1]))
|
||||||
val rowContent =
|
val rowContent =
|
||||||
arrayOf(
|
arrayOf(
|
||||||
String.format("%.10f", eachRow[0]),
|
String.format("%.10f", eachRow[0]),
|
||||||
@@ -48,9 +50,22 @@ class SaveRawData(private val localFileRepository: LocalFileRepository) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
localFileRepository.saveCsvToDisk(fullPath, content)
|
localFileRepository.saveCsvToDisk(fullPath, content)
|
||||||
|
// writer.writeAll(content) // data is adding to csv
|
||||||
|
// writer.close()
|
||||||
|
|
||||||
|
// } catch (e: Exception) {
|
||||||
|
// Log.e(TAG, e.toString())
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveLog(folderPath: String, fileName: String, calculationData: TestRightCalculationData) {
|
fun saveLog(folderPath: String, fileName: String, calculationData: TestRightCalculationData) {
|
||||||
|
// val fileObj = File(folderPath, fileName)
|
||||||
|
// val writer = FileWriter(fileObj)
|
||||||
|
|
||||||
|
// writer.append(getLogStringFromObj(calculationData))
|
||||||
|
// writer.flush()
|
||||||
|
// writer.close()
|
||||||
|
|
||||||
val fullPath = folderPath + fileName
|
val fullPath = folderPath + fileName
|
||||||
localFileRepository.saveTextToDisk(fullPath, getLogStringFromObj(calculationData))
|
localFileRepository.saveTextToDisk(fullPath, getLogStringFromObj(calculationData))
|
||||||
}
|
}
|
||||||
@@ -98,6 +113,13 @@ class SaveRawData(private val localFileRepository: LocalFileRepository) {
|
|||||||
calculationData: TestRightCalculationData,
|
calculationData: TestRightCalculationData,
|
||||||
testDetails: UserData?,
|
testDetails: UserData?,
|
||||||
) {
|
) {
|
||||||
|
// val fileObj = File(folderPath, fileName)
|
||||||
|
// val writer = FileWriter(fileObj)
|
||||||
|
|
||||||
|
// writer.append(getLogStringFromObjWithPatientData(calculationData, patientData))
|
||||||
|
// writer.flush()
|
||||||
|
// writer.close()
|
||||||
|
|
||||||
val fullPath = folderPath + fileName
|
val fullPath = folderPath + fileName
|
||||||
localFileRepository.saveTextToDisk(
|
localFileRepository.saveTextToDisk(
|
||||||
fullPath,
|
fullPath,
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class SaveRawDataTest(private val localFileRepository: LocalFileRepository) {
|
|||||||
|
|
||||||
// try {
|
// try {
|
||||||
val fullPath = "$folderPath/$fileName"
|
val fullPath = "$folderPath/$fileName"
|
||||||
|
// val writer = CSVWriter(FileWriter(fullPath))
|
||||||
val content = ArrayList<Array<String>>()
|
val content = ArrayList<Array<String>>()
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
@@ -52,6 +53,19 @@ class SaveRawDataTest(private val localFileRepository: LocalFileRepository) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun saveLog(folderPath: String, fileName: String, isReference: Boolean, fullString: String) {
|
fun saveLog(folderPath: String, fileName: String, isReference: Boolean, fullString: String) {
|
||||||
|
// val fileObj = File(folderPath, fileName)
|
||||||
|
|
||||||
|
// Log.d(TAG, "$folderPath --- $fileName")
|
||||||
|
// val writer = FileWriter(fileObj)
|
||||||
|
|
||||||
|
// if (isReference)
|
||||||
|
// writer.append("\nREFERENCE OUTPUT\n")
|
||||||
|
// else
|
||||||
|
// writer.append("\nSAMPLE OUTPUT\n")
|
||||||
|
//
|
||||||
|
// writer.append(fullString)
|
||||||
|
// writer.flush()
|
||||||
|
// writer.close()
|
||||||
|
|
||||||
val filePath = folderPath + fileName
|
val filePath = folderPath + fileName
|
||||||
var stringToWrite = ""
|
var stringToWrite = ""
|
||||||
|
|||||||
@@ -38,21 +38,17 @@ class SickleFindResultCaluculationWithMaxImpl : TestRightResultCalculation{
|
|||||||
var wavelengthOfAbsorbanceTwo = 0.0
|
var wavelengthOfAbsorbanceTwo = 0.0
|
||||||
|
|
||||||
for (each in wavelengthToAbsorbance) {
|
for (each in wavelengthToAbsorbance) {
|
||||||
when {
|
if (each[0] >= startWavelengthOne && each[0] < endWavelengthOne) {
|
||||||
each[0] >= startWavelengthOne && each[0] < endWavelengthOne -> {
|
if (each[1] > maxAbsorbanceAtOne) {
|
||||||
if (each[1] > maxAbsorbanceAtOne) {
|
maxAbsorbanceAtOne = each[1]
|
||||||
maxAbsorbanceAtOne = each[1]
|
wavelengthOfAbsorbanceOne = each[0]
|
||||||
wavelengthOfAbsorbanceOne = each[0]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
when {
|
if (each[0] >= startWavelengthTwo && each[0] < endWavelengthTwo) {
|
||||||
each[0] >= startWavelengthTwo && each[0] < endWavelengthTwo -> {
|
// maxAbsorbanceAtTwo = max(maxAbsorbanceAtTwo, each[1])
|
||||||
// maxAbsorbanceAtTwo = max(maxAbsorbanceAtTwo, each[1])
|
if (each[1] > maxAbsorbanceAtTwo) {
|
||||||
if (each[1] > maxAbsorbanceAtTwo) {
|
maxAbsorbanceAtTwo = each[1]
|
||||||
maxAbsorbanceAtTwo = each[1]
|
wavelengthOfAbsorbanceTwo = each[0]
|
||||||
wavelengthOfAbsorbanceTwo = each[0]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,22 +70,18 @@ class SickleFindResultCaluculationWithMaxImpl : TestRightResultCalculation{
|
|||||||
val value = absorbanceAtWaveTwo / absorbanceAtWaveOne
|
val value = absorbanceAtWaveTwo / absorbanceAtWaveOne
|
||||||
testRightCalculationData.ratioValue = value
|
testRightCalculationData.ratioValue = value
|
||||||
|
|
||||||
when {
|
if (value < 0.30 || value == 0.0) {
|
||||||
value < 0.30 || value == 0.0 -> {
|
testRightCalculationData.ratioMinRange = 0.0
|
||||||
testRightCalculationData.ratioMinRange = 0.0
|
testRightCalculationData.ratioMaxRange = 0.30
|
||||||
testRightCalculationData.ratioMaxRange = 0.30
|
return TestRightResultType.NORMAL
|
||||||
return TestRightResultType.NORMAL
|
} else if (value >= 0.30 && value < 0.31) {
|
||||||
}
|
testRightCalculationData.ratioMinRange = 0.30
|
||||||
value >= 0.30 && value < 0.31 -> {
|
testRightCalculationData.ratioMaxRange = 0.31
|
||||||
testRightCalculationData.ratioMinRange = 0.30
|
return TestRightResultType.UNDEFINED
|
||||||
testRightCalculationData.ratioMaxRange = 0.31
|
} else if (value >= 0.31) {
|
||||||
return TestRightResultType.UNDEFINED
|
testRightCalculationData.ratioMinRange = 0.31
|
||||||
}
|
testRightCalculationData.ratioMaxRange = 999.0
|
||||||
value >= 0.31 -> {
|
return TestRightResultType.SICKLECELLDISEASE
|
||||||
testRightCalculationData.ratioMinRange = 0.31
|
|
||||||
testRightCalculationData.ratioMaxRange = 999.0
|
|
||||||
return TestRightResultType.SICKLECELLDISEASE
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
package com.example.hpostesting.encryption
|
package com.example.hpostesting.encryption
|
||||||
|
|
||||||
import android.util.Base64
|
import android.util.Base64
|
||||||
import java.security.SecureRandom
|
|
||||||
import javax.crypto.Cipher
|
import javax.crypto.Cipher
|
||||||
import javax.crypto.SecretKeyFactory
|
import javax.crypto.SecretKeyFactory
|
||||||
import javax.crypto.spec.IvParameterSpec
|
import javax.crypto.spec.IvParameterSpec
|
||||||
@@ -22,8 +21,7 @@ import javax.crypto.spec.PBEKeySpec
|
|||||||
import javax.crypto.spec.SecretKeySpec
|
import javax.crypto.spec.SecretKeySpec
|
||||||
|
|
||||||
object Encryption {
|
object Encryption {
|
||||||
//private const val AES_MODE = "AES/CBC/PKCS5Padding"
|
private const val AES_MODE = "AES/CBC/PKCS5Padding"
|
||||||
private const val AES_MODE= "AES/GCM/NoPadding"
|
|
||||||
private const val KEY_SPEC_ALGORITHM = "PBKDF2WithHmacSHA1"
|
private const val KEY_SPEC_ALGORITHM = "PBKDF2WithHmacSHA1"
|
||||||
private const val SALT = "Bigtec"
|
private const val SALT = "Bigtec"
|
||||||
private const val ITERATION_COUNT = 10000
|
private const val ITERATION_COUNT = 10000
|
||||||
@@ -31,8 +29,7 @@ object Encryption {
|
|||||||
private val FIXED_IV = byteArrayOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
|
private val FIXED_IV = byteArrayOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
|
||||||
|
|
||||||
fun encrypt(textToEncrypt: String, password: String): String {
|
fun encrypt(textToEncrypt: String, password: String): String {
|
||||||
val salt = ByteArray(16)
|
val salt = SALT.toByteArray()
|
||||||
SecureRandom().nextBytes(salt)
|
|
||||||
val factory = SecretKeyFactory.getInstance(KEY_SPEC_ALGORITHM)
|
val factory = SecretKeyFactory.getInstance(KEY_SPEC_ALGORITHM)
|
||||||
val spec = PBEKeySpec(password.toCharArray(), salt, ITERATION_COUNT, KEY_LENGTH)
|
val spec = PBEKeySpec(password.toCharArray(), salt, ITERATION_COUNT, KEY_LENGTH)
|
||||||
val tmp = factory.generateSecret(spec)
|
val tmp = factory.generateSecret(spec)
|
||||||
@@ -40,12 +37,12 @@ object Encryption {
|
|||||||
val cipher = Cipher.getInstance(AES_MODE)
|
val cipher = Cipher.getInstance(AES_MODE)
|
||||||
cipher.init(Cipher.ENCRYPT_MODE, key, IvParameterSpec(FIXED_IV))
|
cipher.init(Cipher.ENCRYPT_MODE, key, IvParameterSpec(FIXED_IV))
|
||||||
val encryptedBytes = cipher.doFinal(textToEncrypt.toByteArray(Charsets.UTF_8))
|
val encryptedBytes = cipher.doFinal(textToEncrypt.toByteArray(Charsets.UTF_8))
|
||||||
return Base64.encodeToString(salt + encryptedBytes, Base64.NO_WRAP)
|
return Base64.encodeToString(encryptedBytes, Base64.NO_WRAP)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun decrypt(encryptedText: String, password: String): String {
|
fun decrypt(encryptedText: String, password: String): String {
|
||||||
val salt = encryptedText.substring(0, 24).toByteArray()
|
val salt = SALT.toByteArray()
|
||||||
val encryptedBytes = Base64.decode(encryptedText.substring(24), Base64.NO_WRAP)
|
val encryptedBytes = Base64.decode(encryptedText, Base64.NO_WRAP)
|
||||||
val factory = SecretKeyFactory.getInstance(KEY_SPEC_ALGORITHM)
|
val factory = SecretKeyFactory.getInstance(KEY_SPEC_ALGORITHM)
|
||||||
val spec = PBEKeySpec(password.toCharArray(), salt, ITERATION_COUNT, KEY_LENGTH)
|
val spec = PBEKeySpec(password.toCharArray(), salt, ITERATION_COUNT, KEY_LENGTH)
|
||||||
val tmp = factory.generateSecret(spec)
|
val tmp = factory.generateSecret(spec)
|
||||||
@@ -55,29 +52,4 @@ object Encryption {
|
|||||||
val decryptedBytes = cipher.doFinal(encryptedBytes)
|
val decryptedBytes = cipher.doFinal(encryptedBytes)
|
||||||
return String(decryptedBytes, Charsets.UTF_8)
|
return String(decryptedBytes, Charsets.UTF_8)
|
||||||
}
|
}
|
||||||
// fun encrypt(textToEncrypt: String, password: String): String {
|
|
||||||
// val salt = SALT.toByteArray()
|
|
||||||
// val factory = SecretKeyFactory.getInstance(KEY_SPEC_ALGORITHM)
|
|
||||||
// val spec = PBEKeySpec(password.toCharArray(), salt, ITERATION_COUNT, KEY_LENGTH)
|
|
||||||
// val tmp = factory.generateSecret(spec)
|
|
||||||
// val key = SecretKeySpec(tmp.encoded, "AES")
|
|
||||||
// val cipher = Cipher.getInstance(AES_MODE)
|
|
||||||
// cipher.init(Cipher.ENCRYPT_MODE, key, IvParameterSpec(FIXED_IV))
|
|
||||||
// val encryptedBytes = cipher.doFinal(textToEncrypt.toByteArray(Charsets.UTF_8))
|
|
||||||
// return Base64.encodeToString(encryptedBytes, Base64.NO_WRAP)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// fun decrypt(encryptedText: String, password: String): String {
|
|
||||||
// val salt = SALT.toByteArray()
|
|
||||||
// val encryptedBytes = Base64.decode(encryptedText, Base64.NO_WRAP)
|
|
||||||
// val factory = SecretKeyFactory.getInstance(KEY_SPEC_ALGORITHM)
|
|
||||||
// val spec = PBEKeySpec(password.toCharArray(), salt, ITERATION_COUNT, KEY_LENGTH)
|
|
||||||
// val tmp = factory.generateSecret(spec)
|
|
||||||
// val key = SecretKeySpec(tmp.encoded, "AES")
|
|
||||||
// val cipher = Cipher.getInstance(AES_MODE)
|
|
||||||
// cipher.init(Cipher.DECRYPT_MODE, key, IvParameterSpec(FIXED_IV))
|
|
||||||
// val decryptedBytes = cipher.doFinal(encryptedBytes)
|
|
||||||
// return String(decryptedBytes, Charsets.UTF_8)
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,156 +0,0 @@
|
|||||||
package com.example.hpostesting.firebase
|
|
||||||
/*
|
|
||||||
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
|
||||||
* // Notice: All information contained herein is, and remains
|
|
||||||
* // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
|
||||||
* // if any. The intellectual and technical concepts contained
|
|
||||||
* // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
|
||||||
* // and its suppliers and may be covered by Indian and Foreign Patents,
|
|
||||||
* // patents in process, and are protected by trade secret or copyright law.
|
|
||||||
* // Dissemination of this information or reproduction of this material
|
|
||||||
* // is strictly forbidden unless prior written permission is obtained
|
|
||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
|
||||||
*/
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.os.Process
|
|
||||||
import com.google.firebase.FirebaseApp
|
|
||||||
import com.google.firebase.FirebaseOptions
|
|
||||||
import com.google.firebase.firestore.FirebaseFirestore
|
|
||||||
import com.google.firebase.storage.FirebaseStorage
|
|
||||||
import kotlinx.coroutines.CoroutineDispatcher
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
class FirebaseManager @Inject constructor(private val context: Context) {
|
|
||||||
|
|
||||||
private val sharedPreferences =
|
|
||||||
context.getSharedPreferences("FirebaseConfigPrefs", Context.MODE_PRIVATE)
|
|
||||||
|
|
||||||
var currentFirestore: FirebaseFirestore = FirebaseFirestore.getInstance()
|
|
||||||
var currentStorage: FirebaseStorage = FirebaseStorage.getInstance()
|
|
||||||
var updateStatus = false
|
|
||||||
|
|
||||||
private val defaultServers = listOf(
|
|
||||||
// i have it in different place look down
|
|
||||||
firebaseConfig1, firebaseConfig2, firebaseConfig3,
|
|
||||||
)
|
|
||||||
|
|
||||||
init {
|
|
||||||
val lastSelectedServer = getLastSelectedServer()
|
|
||||||
switchServer(lastSelectedServer)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getCurrentFirestoreF(): FirebaseFirestore = currentFirestore
|
|
||||||
fun getCurrentStorageF(): FirebaseStorage = currentStorage
|
|
||||||
|
|
||||||
fun switchServer(firebaseConfig: FirebaseConfig) {
|
|
||||||
saveSelectedServer(firebaseConfig)
|
|
||||||
val firebaseApp = getOrInitializeFirebaseApp(firebaseConfig)
|
|
||||||
currentFirestore = FirebaseFirestore.getInstance(firebaseApp)
|
|
||||||
currentStorage = FirebaseStorage.getInstance(firebaseApp)
|
|
||||||
updateStatus = true
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getOrInitializeFirebaseApp(firebaseConfig: FirebaseConfig): FirebaseApp {
|
|
||||||
val existingApp = FirebaseApp.getApps(context).find { it.name == firebaseConfig.serverName }
|
|
||||||
|
|
||||||
return if (existingApp != null) {
|
|
||||||
|
|
||||||
existingApp
|
|
||||||
} else {
|
|
||||||
|
|
||||||
val options = FirebaseOptions.Builder().setProjectId(firebaseConfig.projectId)
|
|
||||||
.setApplicationId(firebaseConfig.appId).setApiKey(firebaseConfig.apiKey)
|
|
||||||
.setStorageBucket(firebaseConfig.storageBucket).build()
|
|
||||||
|
|
||||||
FirebaseApp.initializeApp(context, options, firebaseConfig.serverName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun saveSelectedServer(firebaseConfig: FirebaseConfig) {
|
|
||||||
with(sharedPreferences.edit()) {
|
|
||||||
putString("selectedServerName", firebaseConfig.serverName)
|
|
||||||
putString("projectId", firebaseConfig.projectId)
|
|
||||||
putString("appId", firebaseConfig.appId)
|
|
||||||
putString("apiKey", firebaseConfig.apiKey)
|
|
||||||
putString("storageBucket", firebaseConfig.storageBucket)
|
|
||||||
apply()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
fun restartApp() {
|
|
||||||
if (updateStatus) {
|
|
||||||
updateStatus = false
|
|
||||||
delayedRestart(context)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getLastSelectedServer(): FirebaseConfig {
|
|
||||||
val selectedServerName =
|
|
||||||
sharedPreferences.getString("selectedServerName", defaultServers.first().serverName)
|
|
||||||
val projectId = sharedPreferences.getString("projectId", defaultServers.first().projectId)
|
|
||||||
val appId = sharedPreferences.getString("appId", defaultServers.first().appId)
|
|
||||||
val apiKey = sharedPreferences.getString("apiKey", defaultServers.first().apiKey)
|
|
||||||
val storageBucket =
|
|
||||||
sharedPreferences.getString("storageBucket", defaultServers.first().storageBucket)
|
|
||||||
|
|
||||||
return FirebaseConfig(
|
|
||||||
serverName = selectedServerName ?: defaultServers.first().serverName,
|
|
||||||
projectId = projectId ?: defaultServers.first().projectId,
|
|
||||||
appId = appId ?: defaultServers.first().appId,
|
|
||||||
apiKey = apiKey ?: defaultServers.first().apiKey,
|
|
||||||
storageBucket = storageBucket ?: defaultServers.first().storageBucket
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getAvailableServers(): List<FirebaseConfig> {
|
|
||||||
return defaultServers
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun restartApp(context: Context) {
|
|
||||||
val intent = context.packageManager.getLaunchIntentForPackage(context.packageName)
|
|
||||||
intent?.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
||||||
context.startActivity(intent)
|
|
||||||
Process.killProcess(Process.myPid())
|
|
||||||
}
|
|
||||||
fun delayedRestart(
|
|
||||||
context: Context,
|
|
||||||
coroutineScope: CoroutineScope = CoroutineScope(Dispatchers.Main),
|
|
||||||
dispatcher: CoroutineDispatcher = Dispatchers.Main
|
|
||||||
) {
|
|
||||||
coroutineScope.launch(dispatcher) {
|
|
||||||
delay(5000L)
|
|
||||||
restartApp(context)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val firebaseConfig1 = FirebaseConfig(
|
|
||||||
serverName = "dev",
|
|
||||||
apiKey = "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I",
|
|
||||||
appId = "1:650071678820:android:a53292637abb7c0d6c6471",
|
|
||||||
projectId = "hpos-af3cc",
|
|
||||||
storageBucket = "hpos-af3cc.appspot.com"
|
|
||||||
)
|
|
||||||
|
|
||||||
private val firebaseConfig2 = FirebaseConfig(
|
|
||||||
serverName = "qc-qa",
|
|
||||||
apiKey = "AIzaSyC4d4GhWHr_NMJAeBvnztQ_yQ3Qe9MAnLs",
|
|
||||||
appId = "1:1004619739289:android:3dbcefb10ea99654e5c808",
|
|
||||||
projectId = "hpos-qa",
|
|
||||||
storageBucket = "hpos-qa.appspot.com"
|
|
||||||
)
|
|
||||||
|
|
||||||
private val firebaseConfig3 = FirebaseConfig(
|
|
||||||
serverName = "prod",
|
|
||||||
apiKey = "AIzaSyDYySi27LioZGNisP1NfnNU5inJX_0FT38",
|
|
||||||
appId = "1:121176529204:android:a7bc0842f61e5095bbed61",
|
|
||||||
projectId = "hpos-preprod",
|
|
||||||
storageBucket = "hpos-preprod.appspot.com"
|
|
||||||
)
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package com.example.hpostesting.firebase
|
|
||||||
/*
|
|
||||||
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
|
||||||
* // Notice: All information contained herein is, and remains
|
|
||||||
* // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
|
||||||
* // if any. The intellectual and technical concepts contained
|
|
||||||
* // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
|
||||||
* // and its suppliers and may be covered by Indian and Foreign Patents,
|
|
||||||
* // patents in process, and are protected by trade secret or copyright law.
|
|
||||||
* // Dissemination of this information or reproduction of this material
|
|
||||||
* // is strictly forbidden unless prior written permission is obtained
|
|
||||||
* // from ShanMukha Innovations Pvt. Ltd.
|
|
||||||
*/
|
|
||||||
data class FirebaseConfig(
|
|
||||||
val serverName: String,
|
|
||||||
val apiKey: String,
|
|
||||||
val appId: String,
|
|
||||||
val projectId: String,
|
|
||||||
val storageBucket: String
|
|
||||||
)
|
|
||||||
|
|
||||||
@@ -19,19 +19,23 @@ import android.content.SharedPreferences
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.Editable
|
import android.text.Editable
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.view.View
|
||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.example.hpostesting.data.constant.Constants
|
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.data.model.test.TestType
|
import com.example.hpostesting.data.model.test.TestType
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import com.example.hpostesting.presentation.hb_test.HBTestActivity
|
import com.example.hpostesting.presentation.hb_test.HBTestActivity
|
||||||
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
||||||
import com.example.hpostesting.presentation.testRight.TestRightActivity
|
import com.example.hpostesting.presentation.testRight.TestRightActivity
|
||||||
|
import com.google.android.material.snackbar.Snackbar
|
||||||
|
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||||
import com.journeyapps.barcodescanner.ScanContract
|
import com.journeyapps.barcodescanner.ScanContract
|
||||||
import com.journeyapps.barcodescanner.ScanIntentResult
|
import com.journeyapps.barcodescanner.ScanIntentResult
|
||||||
|
import com.journeyapps.barcodescanner.ScanOptions
|
||||||
import com.zebra.barcode.sdk.sms.ConfigurationUpdateEvent
|
import com.zebra.barcode.sdk.sms.ConfigurationUpdateEvent
|
||||||
import com.zebra.scannercontrol.DCSSDKDefs
|
import com.zebra.scannercontrol.DCSSDKDefs
|
||||||
import com.zebra.scannercontrol.DCSSDKDefs.DCSSDK_COMMAND_OPCODE
|
import com.zebra.scannercontrol.DCSSDKDefs.DCSSDK_COMMAND_OPCODE
|
||||||
@@ -46,11 +50,10 @@ import java.text.SimpleDateFormat
|
|||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
import kotlin.math.max
|
||||||
|
|
||||||
class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
||||||
private var fromWhere = "Home"
|
private var fromWhere = "Home"
|
||||||
private val forD10 = "SMI/SC-2-D10/"
|
|
||||||
private val forD35 = "SMI/SC/"
|
|
||||||
private val TAG = "KitScanActivity"
|
private val TAG = "KitScanActivity"
|
||||||
private lateinit var binding: ActivityKitScanBinding
|
private lateinit var binding: ActivityKitScanBinding
|
||||||
|
|
||||||
@@ -72,14 +75,14 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun processScannedData(contents: String) {//edited auto selection of cuvette size
|
private fun processScannedData(contents: String) {//edited auto selection of cuvette size
|
||||||
if(contents.contains(forD35)){
|
if(contents.contains("SMI/SC/")){
|
||||||
with(sharedPreference.edit()) {
|
with(sharedPreference.edit()) {
|
||||||
putString(Constants.CUVETTE_SIZE, "2mm")
|
putString(Constants.CUVETTE_SIZE, "2mm")
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
Toast.makeText(this, "Selected cuvette size: 2mm", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, "Selected cuvette size: 2mm", Toast.LENGTH_SHORT).show()
|
||||||
binding.nameEditText.setText(contents)
|
binding.nameEditText.setText(contents)
|
||||||
}else if(contents.contains(forD10)){
|
}else if(contents.contains("SMI/SC-2-D10/")){
|
||||||
with(sharedPreference.edit()) {
|
with(sharedPreference.edit()) {
|
||||||
putString(Constants.CUVETTE_SIZE, "10mm")
|
putString(Constants.CUVETTE_SIZE, "10mm")
|
||||||
apply()
|
apply()
|
||||||
@@ -98,51 +101,33 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun dcssdkEventScannerAppeared(dcsScannerInfo: DCSScannerInfo?) {
|
override fun dcssdkEventScannerAppeared(dcsScannerInfo: DCSScannerInfo?) {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun dcssdkEventScannerDisappeared(i: Int) {
|
override fun dcssdkEventScannerDisappeared(i: Int) {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun dcssdkEventCommunicationSessionEstablished(dcsScannerInfo: DCSScannerInfo?) {
|
override fun dcssdkEventCommunicationSessionEstablished(dcsScannerInfo: DCSScannerInfo?) {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun dcssdkEventCommunicationSessionTerminated(i: Int) {
|
override fun dcssdkEventCommunicationSessionTerminated(i: Int) {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
// override fun dcssdkEventBarcode(p0: ByteArray?, p1: Int, p2: Int) {
|
// override fun dcssdkEventBarcode(p0: ByteArray?, p1: Int, p2: Int) {
|
||||||
|
// TODO("Not yet implemented")
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
override fun dcssdkEventImage(bytes: ByteArray?, i: Int) {
|
override fun dcssdkEventImage(bytes: ByteArray?, i: Int) {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun dcssdkEventVideo(bytes: ByteArray?, i: Int) {
|
override fun dcssdkEventVideo(bytes: ByteArray?, i: Int) {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun dcssdkEventBinaryData(bytes: ByteArray?, i: Int) {
|
override fun dcssdkEventBinaryData(bytes: ByteArray?, i: Int) {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun dcssdkEventFirmwareUpdate(firmwareUpdateEvent: FirmwareUpdateEvent?) {
|
override fun dcssdkEventFirmwareUpdate(firmwareUpdateEvent: FirmwareUpdateEvent?) {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun dcssdkEventAuxScannerAppeared(
|
override fun dcssdkEventAuxScannerAppeared(
|
||||||
dcsScannerInfo: DCSScannerInfo?,
|
dcsScannerInfo: DCSScannerInfo?,
|
||||||
dcsScannerInfo1: DCSScannerInfo?,
|
dcsScannerInfo1: DCSScannerInfo?,
|
||||||
) {
|
) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun dcssdkEventConfigurationUpdate(configurationUpdateEvent: ConfigurationUpdateEvent?) {
|
override fun dcssdkEventConfigurationUpdate(configurationUpdateEvent: ConfigurationUpdateEvent?) {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@@ -225,13 +210,13 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
binding.btnGo.setOnClickListener {
|
binding.btnGo.setOnClickListener {
|
||||||
val serialNumber = binding.nameEditText.text.toString().trim()
|
val serialNumber = binding.nameEditText.text.toString().trim()
|
||||||
if (serialNumber.isNotEmpty() && isSerialValid(serialNumber)) {
|
if (serialNumber.isNotEmpty() && isSerialValid(serialNumber)) {
|
||||||
if(serialNumber.contains(forD35)){
|
if(serialNumber.contains("SMI/SC/")){
|
||||||
with(sharedPreference.edit()) {
|
with(sharedPreference.edit()) {
|
||||||
putString(Constants.CUVETTE_SIZE, "2mm")
|
putString(Constants.CUVETTE_SIZE, "2mm")
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
Toast.makeText(this, "Selected cuvette size: 2mm", Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, "Selected cuvette size: 2mm", Toast.LENGTH_SHORT).show()
|
||||||
}else if(serialNumber.contains(forD10)){
|
}else if(serialNumber.contains("SMI/SC-2-D10/")){
|
||||||
with(sharedPreference.edit()) {
|
with(sharedPreference.edit()) {
|
||||||
putString(Constants.CUVETTE_SIZE, "10mm")
|
putString(Constants.CUVETTE_SIZE, "10mm")
|
||||||
apply()
|
apply()
|
||||||
@@ -304,11 +289,11 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
|
|
||||||
//deciding what kind of notifications we want to receive. Explained more in the function
|
//deciding what kind of notifications we want to receive. Explained more in the function
|
||||||
//first we use bitmapping to set these values into the notifications_mask.
|
//first we use bitmapping to set these values into the notifications_mask.
|
||||||
var notificationsMask = 0
|
var notifications_mask = 0
|
||||||
// We would like to subscribe to all barcode events
|
// We would like to subscribe to all barcode events
|
||||||
notificationsMask =
|
notifications_mask =
|
||||||
notificationsMask or DCSSDKDefs.DCSSDK_EVENT.DCSSDK_EVENT_BARCODE.value
|
notifications_mask or DCSSDKDefs.DCSSDK_EVENT.DCSSDK_EVENT_BARCODE.value
|
||||||
sdkHandler!!.dcssdkSubsribeForEvents(notificationsMask)
|
sdkHandler!!.dcssdkSubsribeForEvents(notifications_mask)
|
||||||
mScannerInfoList.addAll(sdkHandler!!.dcssdkGetAvailableScannersList())
|
mScannerInfoList.addAll(sdkHandler!!.dcssdkGetAvailableScannersList())
|
||||||
Log.e("scannersize", sdkHandler!!.dcssdkGetAvailableScannersList().size.toString())
|
Log.e("scannersize", sdkHandler!!.dcssdkGetAvailableScannersList().size.toString())
|
||||||
if (mScannerInfoList.isNotEmpty()) {
|
if (mScannerInfoList.isNotEmpty()) {
|
||||||
@@ -350,7 +335,7 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
val result = String(barcodeData!!)
|
val result = String(barcodeData!!)
|
||||||
Log.d("BARCODE", result)
|
Log.d("BARCODE", result)
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
Editable.Factory.getInstance().newEditable(result)
|
val editableResult: Editable = Editable.Factory.getInstance().newEditable(result)
|
||||||
processScannedData(result)
|
processScannedData(result)
|
||||||
// binding.nameEditText.text = editableResult
|
// binding.nameEditText.text = editableResult
|
||||||
}
|
}
|
||||||
@@ -364,12 +349,12 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
private fun isSerialValid(s: String): Boolean {
|
private fun isSerialValid(s: String): Boolean {
|
||||||
if (s.contains(forD35)) {
|
if (s.contains("SMI/SC/")) {
|
||||||
if(s.length != 17){
|
if(s.length != 17){
|
||||||
binding.nameEditText.error = "Invalid Kit Serial Number, correct example SMI/SC/000/00/000"
|
binding.nameEditText.error = "Invalid Kit Serial Number, correct example SMI/SC/000/00/000"
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}else if(s.contains(forD10)){
|
}else if(s.contains("SMI/SC-2-D10/")){
|
||||||
if(s.length != 27){
|
if(s.length != 27){
|
||||||
binding.nameEditText.error = "Invalid Kit Serial Number, correct example SMI/SC-2-D10/000000/000/000"
|
binding.nameEditText.error = "Invalid Kit Serial Number, correct example SMI/SC-2-D10/000000/000/000"
|
||||||
return false
|
return false
|
||||||
@@ -388,50 +373,56 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
}else{
|
}else{
|
||||||
DataHolder.deviceType.observe(this) { deviceType ->
|
DataHolder.deviceType.observe(this) { deviceType ->
|
||||||
when (deviceType) {
|
when (deviceType) {
|
||||||
Constants.DEVICE_TYPE_HEMOCUBE ,Constants.DEVICE_TYPE_TRUEHEME -> {
|
Constants.DEVICE_TYPE_HEMOCUBE -> {
|
||||||
val i = Intent(applicationContext, HemocubeActivity::class.java)
|
val i = Intent(applicationContext, HemocubeActivity::class.java)
|
||||||
startActivity(i)
|
startActivity(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
Constants.DEVICE_TYPE_TEST_RIGHT -> {
|
Constants.DEVICE_TYPE_TEST_RIGHT -> {
|
||||||
val i = Intent(applicationContext, TestRightActivity::class.java)
|
val i = Intent(applicationContext, TestRightActivity::class.java)
|
||||||
startActivity(i)
|
startActivity(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Constants.DEVICE_TYPE_TRUEHEME -> {
|
||||||
|
val i = Intent(applicationContext, HemocubeActivity::class.java)
|
||||||
|
startActivity(i)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private fun startScanningNow() {
|
private fun startScanningNow() {
|
||||||
// val options = ScanOptions()
|
val options = ScanOptions()
|
||||||
// options.setDesiredBarcodeFormats(ScanOptions.QR_CODE)
|
options.setDesiredBarcodeFormats(ScanOptions.QR_CODE)
|
||||||
// options.setPrompt("Scan a barcode")
|
options.setPrompt("Scan a barcode")
|
||||||
// options.setCameraId(0) // Use a specific camera of the device
|
options.setCameraId(0) // Use a specific camera of the device
|
||||||
//
|
|
||||||
// options.setBeepEnabled(true)
|
options.setBeepEnabled(true)
|
||||||
// options.setBarcodeImageEnabled(true)
|
options.setBarcodeImageEnabled(true)
|
||||||
//
|
|
||||||
// options.setPrompt("Start Scanning")
|
options.setPrompt("Start Scanning")
|
||||||
// options.setOrientationLocked(false)
|
options.setOrientationLocked(false)
|
||||||
//// options.setTimeout(10000) // in ms
|
// options.setTimeout(10000) // in ms
|
||||||
//
|
|
||||||
// barcodeLauncher.launch(options)
|
barcodeLauncher.launch(options)
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// 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, R.string.select_patient, 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)
|
||||||
// startActivity(i)
|
startActivity(i)
|
||||||
//
|
|
||||||
// false
|
false
|
||||||
// } else {
|
} else {
|
||||||
// true
|
true
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
private fun timeDifference(createdAt: String): Long {
|
private fun timeDifference(createdAt: String): Long {
|
||||||
val currentTime = Calendar.getInstance().time
|
val currentTime = Calendar.getInstance().time
|
||||||
val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import android.content.BroadcastReceiver
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
import android.content.SharedPreferences
|
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.hardware.usb.UsbManager
|
import android.hardware.usb.UsbManager
|
||||||
import android.location.Location
|
import android.location.Location
|
||||||
@@ -31,9 +30,10 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.constant.Constants
|
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
import com.example.hpostesting.data.model.test.TestType
|
import com.example.hpostesting.data.model.test.TestType
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import com.google.android.gms.location.FusedLocationProviderClient
|
import com.google.android.gms.location.FusedLocationProviderClient
|
||||||
@@ -48,12 +48,12 @@ import `in`.sminnovations.hpostesting.R
|
|||||||
import `in`.sminnovations.hpostesting.databinding.ActivityMainBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityMainBinding
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private lateinit var binding: ActivityMainBinding
|
private lateinit var binding: ActivityMainBinding
|
||||||
private var myMenu: Menu? = null
|
private var myMenu: Menu? = null
|
||||||
private val TAG = "MainActivity"
|
private val TAG = "MainActivity"
|
||||||
private lateinit var fusedLocationClient: FusedLocationProviderClient
|
private lateinit var fusedLocationClient: FusedLocationProviderClient
|
||||||
private lateinit var locationCallback: LocationCallback
|
private lateinit var locationCallback: LocationCallback
|
||||||
private lateinit var sharedPreference: SharedPreferences
|
|
||||||
|
|
||||||
private val usbReceiver = object : BroadcastReceiver() {
|
private val usbReceiver = object : BroadcastReceiver() {
|
||||||
override fun onReceive(context: Context?, intent: Intent) {
|
override fun onReceive(context: Context?, intent: Intent) {
|
||||||
@@ -73,28 +73,14 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
sharedPreference = getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
|
||||||
val action = intent?.action
|
|
||||||
if (action == UsbManager.ACTION_USB_DEVICE_ATTACHED || action == UsbManager.ACTION_USB_DEVICE_DETACHED) {
|
|
||||||
// If the activity is triggered by USB events, simply finish it
|
|
||||||
checkAndUpdateUsbConnection()
|
|
||||||
finish()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
binding = ActivityMainBinding.inflate(layoutInflater)
|
binding = ActivityMainBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
binding.myToolbar.title = "Test Type"
|
binding.myToolbar.title = "Test Type"
|
||||||
setSupportActionBar(binding.myToolbar)
|
setSupportActionBar(binding.myToolbar)
|
||||||
if ((sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN")) {
|
|
||||||
binding.cvItem3.visibility = View.VISIBLE
|
|
||||||
}else{
|
|
||||||
binding.cvItem3.visibility = View.GONE
|
|
||||||
}
|
|
||||||
setupListeners()
|
setupListeners()
|
||||||
fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)
|
fusedLocationClient = LocationServices.getFusedLocationProviderClient(this)
|
||||||
getLocation()
|
getLocation()
|
||||||
|
|
||||||
locationCallback = object : LocationCallback() {
|
locationCallback = object : LocationCallback() {
|
||||||
override fun onLocationResult(locationResult: LocationResult) {
|
override fun onLocationResult(locationResult: LocationResult) {
|
||||||
locationResult.lastLocation?.let { location ->
|
locationResult.lastLocation?.let { location ->
|
||||||
@@ -106,6 +92,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val usbFilter = IntentFilter().apply {
|
val usbFilter = IntentFilter().apply {
|
||||||
addAction(UsbManager.ACTION_USB_DEVICE_DETACHED)
|
addAction(UsbManager.ACTION_USB_DEVICE_DETACHED)
|
||||||
addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED)
|
addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED)
|
||||||
@@ -129,17 +116,10 @@ class MainActivity : AppCompatActivity() {
|
|||||||
// finish()
|
// finish()
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
private fun changeUI(){
|
|
||||||
binding.cvItem1.visibility = View.VISIBLE
|
|
||||||
binding.cvItem3.visibility = View.VISIBLE
|
|
||||||
binding.cvItem2.visibility = View.GONE
|
|
||||||
binding.cvItem4.visibility = View.GONE
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun checkAndUpdateUsbConnection() {
|
private fun checkAndUpdateUsbConnection() {
|
||||||
val availableDrivers = UsbSerialProber.getDefaultProber()
|
val availableDrivers = UsbSerialProber.getDefaultProber()
|
||||||
.findAllDrivers(getSystemService(Context.USB_SERVICE) as UsbManager)
|
.findAllDrivers(getSystemService(Context.USB_SERVICE) as UsbManager)
|
||||||
.toList()
|
|
||||||
|
|
||||||
val deviceType = when {
|
val deviceType = when {
|
||||||
availableDrivers.isNotEmpty() -> {
|
availableDrivers.isNotEmpty() -> {
|
||||||
@@ -150,18 +130,51 @@ class MainActivity : AppCompatActivity() {
|
|||||||
Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
when {
|
when {
|
||||||
(device.productId == Constants.HOMO_CUBE_ID && device.vendorId == Constants.VENDOR_ID) || (device.productId == Constants.HEMO_CUBE_V2_PRODUCT_ID && device.vendorId == Constants.HEMO_CUBE_V2_VENDOR_ID) -> {
|
device.productId == Constants.HOMO_CUBE_ID && device.vendorId == Constants.VENDOR_ID -> {
|
||||||
changeUI()
|
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_HEMOCUBE)
|
DataHolder.deviceType.postValue(Constants.DEVICE_TYPE_HEMOCUBE)
|
||||||
Constants.DEVICE_TYPE_HEMOCUBE
|
Constants.DEVICE_TYPE_HEMOCUBE
|
||||||
}
|
}
|
||||||
|
|
||||||
(device.productId == 24577 && device.vendorId == 1027) || (device.productId == 8963 && device.vendorId == 1659) || (device.productId == 4614 && device.vendorId == 7111) -> {
|
device.productId == Constants.HEMO_CUBE_V2_PRODUCT_ID && device.vendorId == Constants.HEMO_CUBE_V2_VENDOR_ID -> {
|
||||||
// changeUI()
|
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_HEMOCUBE)
|
||||||
|
Constants.DEVICE_TYPE_HEMOCUBE
|
||||||
|
}
|
||||||
|
|
||||||
|
device.productId == 24577 && device.vendorId == 1027 -> {
|
||||||
|
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_TRUEHEME)
|
DataHolder.deviceType.postValue(Constants.DEVICE_TYPE_TRUEHEME)
|
||||||
Constants.DEVICE_TYPE_TRUEHEME
|
Constants.DEVICE_TYPE_TRUEHEME
|
||||||
}
|
}
|
||||||
|
|
||||||
|
device.productId == 8963 && device.vendorId == 1659 -> {
|
||||||
|
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_HEMOCUBE)
|
||||||
|
Constants.DEVICE_TYPE_HEMOCUBE
|
||||||
|
}
|
||||||
|
|
||||||
|
device.productId == 4614 && device.vendorId == 7111 -> {
|
||||||
|
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_HEMOCUBE)
|
||||||
|
Constants.DEVICE_TYPE_HEMOCUBE
|
||||||
|
}
|
||||||
|
|
||||||
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,
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ class SplashActivity : AppCompatActivity() {
|
|||||||
handlePermissionsResult(true)
|
handlePermissionsResult(true)
|
||||||
} else {
|
} else {
|
||||||
val requestPermissionLauncher =
|
val requestPermissionLauncher =
|
||||||
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { _ ->
|
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
|
||||||
if (Environment.isExternalStorageManager()) {
|
if (Environment.isExternalStorageManager()) {
|
||||||
handlePermissionsResult(true)
|
handlePermissionsResult(true)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -15,17 +15,18 @@ package com.example.hpostesting.presentation.adapter
|
|||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.res.Resources
|
||||||
|
import android.provider.ContactsContract.Data
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.annotation.StringRes
|
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
import androidx.recyclerview.widget.AsyncListDiffer
|
import androidx.recyclerview.widget.AsyncListDiffer
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.example.hpostesting.data.constant.Constants
|
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.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 `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
@@ -71,97 +72,78 @@ class OfflineUserListAdapter(private val view: View, private val batLevel: Int,p
|
|||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onBindViewHolder(holder: OfflineUserListViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: OfflineUserListViewHolder, position: Int) {
|
||||||
val userList = differ.currentList[position]
|
val userList = differ.currentList[position]
|
||||||
updateHolderBinding(holder, userList)
|
|
||||||
}
|
|
||||||
private fun formatTime(incubationTime: String): String {
|
|
||||||
val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
|
||||||
val incubationTimeDate = formatter.parse(incubationTime)!!
|
|
||||||
val timeFormatter = SimpleDateFormat("HH:mm:ss", Locale.getDefault())
|
|
||||||
return "Time: ${isBetween15And30Minutes(incubationTime)} \n Started at: ${timeFormatter.format(incubationTimeDate)}"
|
|
||||||
}
|
|
||||||
private fun getSampleIdText(userList: HemoCubeTestData): String {
|
|
||||||
return "Sample ID: ${userList._id}"
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getBloodGroupText(userList: HemoCubeTestData): String {
|
|
||||||
return "Blood group: ${userList.bloodGroup}"
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getTestStatusText(userList: HemoCubeTestData): String {
|
|
||||||
return if (userList.testStatus!!) {
|
|
||||||
view.context.getString(R.string.test_concluded)
|
|
||||||
} else {
|
|
||||||
view.context.getString(R.string.test_pending)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private fun updateHolderBinding(holder: OfflineUserListViewHolder, userList: HemoCubeTestData) {
|
|
||||||
holder.binding.apply {
|
holder.binding.apply {
|
||||||
updateBasicUserInfo(this, userList)
|
userID.text = "Sample ID: ${userList._id}"
|
||||||
if (fromWhere == "Home") {
|
bloodGroup.text = "Blood group: ${userList.bloodGroup}"
|
||||||
setupUserCardClickListener(userCard, userList)
|
time.text = "Time: ${isBetween15And30Minutes(userList.incubationTime)} \n Started at: ${
|
||||||
|
SimpleDateFormat("HH:mm:ss").format(
|
||||||
|
SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
).parse(userList.incubationTime)!!
|
||||||
|
)
|
||||||
|
}"
|
||||||
|
|
||||||
|
if (userList.testStatus!!) {
|
||||||
|
teststatus.text = view.context.getString(R.string.test_concluded)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
teststatus.text = view.context.getString(R.string.test_pending)
|
||||||
|
}
|
||||||
|
if(fromWhere == "Home") {
|
||||||
|
userCard.setOnClickListener {
|
||||||
|
if (false) {
|
||||||
|
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(
|
||||||
|
sampleid = userList.sampleid,
|
||||||
|
_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 updateBasicUserInfo(binding: OfflineUserListViewBinding, userList: HemoCubeTestData) {
|
|
||||||
binding.apply {
|
|
||||||
userID.text = getSampleIdText(userList)
|
|
||||||
bloodGroup.text = getBloodGroupText(userList)
|
|
||||||
time.text = formatTime(userList.incubationTime)
|
|
||||||
teststatus.text = getTestStatusText(userList)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupUserCardClickListener(userCard: View, userList: HemoCubeTestData) {
|
|
||||||
userCard.setOnClickListener {
|
|
||||||
when {
|
|
||||||
isLowBattery(userList.batteryLevel) -> showToast(R.string.low_battery_warning)
|
|
||||||
isTestAlreadyCompleted(userList.testStatus) -> showToast(R.string.test_already_conducted)
|
|
||||||
else -> handleIncubationCheck(userList)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun isLowBattery(batteryLevel: String): Boolean =
|
|
||||||
batteryLevel < "20"
|
|
||||||
|
|
||||||
private fun isTestAlreadyCompleted(testStatus: Boolean?): Boolean =
|
|
||||||
testStatus == true
|
|
||||||
|
|
||||||
private fun handleIncubationCheck(userList: HemoCubeTestData) {
|
|
||||||
if (userList.incubationTime.isEmpty()) {
|
|
||||||
showToast(R.string.incubation_not_started)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val incubationMinutes = isBetween15And30Minutes(userList.incubationTime)
|
|
||||||
when {
|
|
||||||
incubationMinutes < Constants.INCUBATION_TIME_MIN ->
|
|
||||||
showToast(R.string.incubation_not_completed)
|
|
||||||
incubationMinutes > Constants.INCUBATION_TIME_MAX ->
|
|
||||||
showToast(R.string.incubation_crossed_30_minutes)
|
|
||||||
else -> navigateToMainActivity(userList)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun showToast(@StringRes messageResId: Int) {
|
|
||||||
Toast.makeText(
|
|
||||||
view.context,
|
|
||||||
view.context.getString(messageResId),
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun navigateToMainActivity(userList: HemoCubeTestData) {
|
|
||||||
DataHolder.selectedTest = UserData(
|
|
||||||
sampleid = userList.sampleid,
|
|
||||||
_id = userList._id,
|
|
||||||
bloodGroup = userList.bloodGroup,
|
|
||||||
incubationTime = userList.incubationTime
|
|
||||||
)
|
|
||||||
view.findNavController().navigate(R.id.action_nav_home_to_mainActivity)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun isBetween15And30Minutes(createdAt: String): Long {
|
private fun isBetween15And30Minutes(createdAt: String): Long {
|
||||||
val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
||||||
val createdAtDate: Date = formatter.parse(createdAt)!!
|
val createdAtDate: Date = formatter.parse(createdAt)!!
|
||||||
@@ -173,19 +155,19 @@ class OfflineUserListAdapter(private val view: View, private val batLevel: Int,p
|
|||||||
return diffMillis / (60 * 1000)
|
return diffMillis / (60 * 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
// private fun showWarningToast(resId: Int) {
|
private fun showWarningToast(resId: Int) {
|
||||||
// val contextToUse = view.context ?: return
|
val contextToUse = view.context ?: return
|
||||||
//
|
|
||||||
// val message = try {
|
val message = try {
|
||||||
// contextToUse.getString(resId)
|
contextToUse.getString(resId)
|
||||||
// } catch (e: Resources.NotFoundException) {
|
} catch (e: Resources.NotFoundException) {
|
||||||
// "Resource not found for ID: $resId"
|
"Resource not found for ID: $resId"
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// Toast.makeText(
|
Toast.makeText(
|
||||||
// contextToUse,
|
contextToUse,
|
||||||
// message,
|
message,
|
||||||
// Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
// ).show()
|
).show()
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,6 @@ import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
|||||||
import com.firebase.ui.firestore.FirestoreRecyclerAdapter
|
import com.firebase.ui.firestore.FirestoreRecyclerAdapter
|
||||||
import com.firebase.ui.firestore.FirestoreRecyclerOptions
|
import com.firebase.ui.firestore.FirestoreRecyclerOptions
|
||||||
import com.google.firebase.firestore.FirebaseFirestore
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
import com.google.firebase.firestore.QuerySnapshot
|
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.UserItemViewBinding
|
import `in`.sminnovations.hpostesting.databinding.UserItemViewBinding
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
@@ -62,274 +61,212 @@ class UserListAdapter(
|
|||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onBindViewHolder(holder: OrderItemViewHolder, position: Int, model: UserData) {
|
override fun onBindViewHolder(holder: OrderItemViewHolder, position: Int, model: UserData) {
|
||||||
holder.binding.apply {
|
holder.binding.apply {
|
||||||
setupUserInfo(this, model)
|
|
||||||
setupBloodGroupButton(this, model)
|
|
||||||
setupTestStatusAndImage(this, model)
|
|
||||||
setupStartIncubationButton(this)
|
|
||||||
setupUserCardClickListener(this, model)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupUserInfo(binding: UserItemViewBinding, model: UserData) {
|
|
||||||
binding.apply {
|
|
||||||
userName.text = "Name: ${model.name}"
|
userName.text = "Name: ${model.name}"
|
||||||
if (model.incubationTime.isEmpty()) {
|
userId.text = "User ID:${model._id}"
|
||||||
userId.text = "User ID:${model._id}"
|
if (model.incubationTime == "") {
|
||||||
btnBlood.visibility = View.VISIBLE
|
btnBlood.visibility = View.VISIBLE
|
||||||
} else {
|
} else {
|
||||||
val timeFormatted = SimpleDateFormat("HH:mm:ss").format(
|
userId.text =
|
||||||
SimpleDateFormat(context.resources.getString(R.string.DateTimeFormat), Locale.getDefault())
|
"User ID:${model._id} \n Time: ${isBetween15And30Minutes(model.incubationTime)} \n Started at: ${
|
||||||
.parse(model.incubationTime)!!
|
SimpleDateFormat("HH:mm:ss").format(
|
||||||
)
|
SimpleDateFormat(
|
||||||
userId.text = "User ID:${model._id} \n Time: ${isBetween15And30Minutes(model.incubationTime)} \n Started at: $timeFormatted"
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
).parse(model.incubationTime)!!
|
||||||
|
)
|
||||||
|
}"
|
||||||
btnBlood.visibility = View.GONE
|
btnBlood.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupTestStatusAndImage(binding: UserItemViewBinding, model: UserData) {
|
|
||||||
binding.apply {
|
|
||||||
Glide.with(view).load(model.userImageURL).into(userImage)
|
Glide.with(view).load(model.userImageURL).into(userImage)
|
||||||
teststatus.text = if (model.testStatus!!) {
|
if (model.testStatus!!) {
|
||||||
view.context.getString(R.string.test_concluded)
|
teststatus.text = view.context.getString(R.string.test_concluded)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
view.context.getString(R.string.test_pending)
|
teststatus.text = view.context.getString(R.string.test_pending)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupBloodGroupButton(binding: UserItemViewBinding, model: UserData) {
|
holder.binding.btnBlood.setOnClickListener {
|
||||||
binding.btnBlood.setOnClickListener {
|
val view: View? = requireActivity.currentFocus
|
||||||
hideKeyboard()
|
|
||||||
showBloodGroupDialog(model, binding)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun hideKeyboard() {
|
// on below line checking if view is not null.
|
||||||
val view: View? = requireActivity.currentFocus
|
if (view != null) {
|
||||||
view?.let {
|
// on below line we are creating a variable
|
||||||
val inputMethodManager =
|
// for input manager and initializing it.
|
||||||
context.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
|
val inputMethodManager =
|
||||||
inputMethodManager.hideSoftInputFromWindow(it.windowToken, 0)
|
context.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun showBloodGroupDialog(model: UserData, binding: UserItemViewBinding) {
|
// on below line hiding our keyboard.
|
||||||
val dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_custom, null)
|
inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0)
|
||||||
val builder = AlertDialog.Builder(context)
|
}
|
||||||
.setView(dialogView)
|
val inflater = LayoutInflater.from(context)
|
||||||
.setTitle(R.string.blood_group)
|
val dialogView = inflater.inflate(R.layout.dialog_custom, null)
|
||||||
|
|
||||||
val etBloodGroup = dialogView.findViewById<AutoCompleteTextView>(R.id.et_blood_group)
|
val builder = AlertDialog.Builder(context)
|
||||||
setupDialogButtons(builder, etBloodGroup, model, binding)
|
.setView(dialogView)
|
||||||
}
|
.setTitle(R.string.blood_group)
|
||||||
|
|
||||||
private fun setupDialogButtons(
|
val etBloodGroup =
|
||||||
builder: AlertDialog.Builder,
|
dialogView.findViewById<AutoCompleteTextView>(R.id.et_blood_group)
|
||||||
etBloodGroup: AutoCompleteTextView,
|
|
||||||
model: UserData,
|
|
||||||
binding: UserItemViewBinding
|
|
||||||
) {
|
|
||||||
builder.setPositiveButton(R.string.ok) { _, _ ->
|
|
||||||
handleBloodGroupSelection(etBloodGroup, model, binding)
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.setNegativeButton(R.string.cancel) { dialog, _ -> dialog.dismiss() }
|
builder.setPositiveButton(R.string.ok) { dialog, which ->
|
||||||
builder.create().show()
|
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()
|
||||||
|
|
||||||
private fun handleBloodGroupSelection(
|
db.collection("patientData")
|
||||||
etBloodGroup: AutoCompleteTextView,
|
.whereEqualTo("_id", model._id)
|
||||||
model: UserData,
|
.get()
|
||||||
binding: UserItemViewBinding
|
.addOnSuccessListener { userdata ->
|
||||||
) {
|
try {
|
||||||
val bloodGroup = etBloodGroup.text.toString()
|
val document = userdata.documents[0]
|
||||||
if (isInvalidBloodGroup(bloodGroup)) {
|
db.collection("patientData")
|
||||||
showBloodGroupError(etBloodGroup)
|
.document(document.id)
|
||||||
return
|
.update(
|
||||||
}
|
"bloodGroup", bloodGroup,
|
||||||
updateBloodGroupInFirestore(bloodGroup, model, binding)
|
"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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun isInvalidBloodGroup(bloodGroup: String): Boolean {
|
}
|
||||||
return bloodGroup == "Select Blood Group" ||
|
.addOnFailureListener { e ->
|
||||||
bloodGroup == "ರಕ್ತ ಗುಂಪು ಆಯ್ಕೆಮಾಡಿ" ||
|
Toast.makeText(
|
||||||
bloodGroup.isBlank()
|
context,
|
||||||
}
|
"Error fetching user data: ${e.message}",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Handle the selected blood group here
|
||||||
|
}
|
||||||
|
|
||||||
private fun showBloodGroupError(etBloodGroup: AutoCompleteTextView) {
|
builder.setNegativeButton(R.string.cancel) { dialog, which ->
|
||||||
etBloodGroup.error = view.context.getString(R.string.blood_group_error)
|
dialog.dismiss()
|
||||||
Toast.makeText(
|
}
|
||||||
context,
|
|
||||||
view.context.getString(R.string.blood_group_toast),
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateBloodGroupInFirestore(
|
val alertDialog = builder.create()
|
||||||
bloodGroup: String,
|
alertDialog.show()
|
||||||
model: UserData,
|
|
||||||
binding: UserItemViewBinding
|
|
||||||
) {
|
|
||||||
val db = FirebaseFirestore.getInstance()
|
|
||||||
db.collection("patientData")
|
|
||||||
.whereEqualTo("_id", model._id)
|
|
||||||
.get()
|
|
||||||
.addOnSuccessListener { userdata ->
|
|
||||||
handleFirestoreUpdate(userdata, bloodGroup, binding)
|
|
||||||
}
|
}
|
||||||
.addOnFailureListener { e ->
|
|
||||||
Toast.makeText(
|
|
||||||
context,
|
|
||||||
"Error fetching user data: ${e.message}",
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun handleFirestoreUpdate(
|
btnStartIncubation.setOnClickListener {
|
||||||
userdata: QuerySnapshot,
|
// it.visibility = View.GONE
|
||||||
bloodGroup: String,
|
// Firebase.firestore.collection("patientData").whereEqualTo("_id", model._id).get()
|
||||||
binding: UserItemViewBinding
|
// .addOnSuccessListener { data ->
|
||||||
) {
|
// if (data.documents.isNotEmpty()) {
|
||||||
try {
|
// data.documents.forEach { userData ->
|
||||||
val document = userdata.documents[0]
|
// Firebase.firestore.collection("patientData").document(userData.id)
|
||||||
updateDocument(document.id, bloodGroup, binding)
|
// .update(
|
||||||
} catch (e: IndexOutOfBoundsException) {
|
// "incubationTime", SimpleDateFormat(
|
||||||
Toast.makeText(
|
// "yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
view.context,
|
// ).format(Calendar.getInstance().time).toString()
|
||||||
context.getString(R.string.no_user_data_found),
|
// ).addOnSuccessListener {
|
||||||
Toast.LENGTH_SHORT
|
// Toast.makeText(
|
||||||
).show()
|
// view.context, "Incubation started", Toast.LENGTH_SHORT
|
||||||
}
|
// ).show()
|
||||||
}
|
// startListening()
|
||||||
|
// }
|
||||||
private fun updateDocument(
|
// }
|
||||||
documentId: String,
|
|
||||||
bloodGroup: String,
|
|
||||||
binding: UserItemViewBinding
|
|
||||||
) {
|
|
||||||
FirebaseFirestore.getInstance().collection("patientData")
|
|
||||||
.document(documentId)
|
|
||||||
.update(
|
|
||||||
"bloodGroup", bloodGroup,
|
|
||||||
"incubationTime", getCurrentTimeFormatted()
|
|
||||||
)
|
|
||||||
.addOnSuccessListener {
|
|
||||||
Toast.makeText(
|
|
||||||
view.context,
|
|
||||||
context.getString(R.string.blood_group_updated_successfully),
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
binding.btnBlood.visibility = View.GONE
|
|
||||||
}
|
|
||||||
.addOnFailureListener {
|
|
||||||
Toast.makeText(
|
|
||||||
view.context,
|
|
||||||
context.getString(R.string.failed_to_update_blood_group),
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getCurrentTimeFormatted(): String {
|
|
||||||
return SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
|
||||||
.format(Calendar.getInstance().time)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupStartIncubationButton(binding: UserItemViewBinding) {
|
|
||||||
// Commented code preserved as per requirement
|
|
||||||
binding.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 {
|
||||||
}
|
if (false) {
|
||||||
|
Toast.makeText(
|
||||||
private fun setupUserCardClickListener(binding: UserItemViewBinding, model: UserData) {
|
view.context,
|
||||||
binding.userCard.setOnClickListener {
|
context?.getString(R.string.low_battery_warning),
|
||||||
model.testStatus?.let { testStatus ->
|
Toast.LENGTH_SHORT
|
||||||
if (testStatus) {
|
).show()
|
||||||
showTestAlreadyConductedMessage()
|
return@setOnClickListener
|
||||||
} else {
|
}
|
||||||
handleIncubationTimeCheck(model)
|
if (model.testStatus != null) {
|
||||||
|
if (model.testStatus!!) {
|
||||||
|
Toast.makeText(
|
||||||
|
view.context,
|
||||||
|
context?.getString(R.string.test_already_conducted),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
} else {
|
||||||
|
if (model.incubationTime != "") {
|
||||||
|
if (isBetween15And30Minutes(model.incubationTime) < -15000) {
|
||||||
|
Toast.makeText(
|
||||||
|
view.context,
|
||||||
|
context?.getString(R.string.incubation_not_completed),
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
} else if (isBetween15And30Minutes(model.incubationTime) > 300000) {
|
||||||
|
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 showTestAlreadyConductedMessage() {
|
|
||||||
Toast.makeText(
|
|
||||||
view.context,
|
|
||||||
context.getString(R.string.test_already_conducted),
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun handleIncubationTimeCheck(model: UserData) {
|
|
||||||
if (model.incubationTime.isEmpty()) {
|
|
||||||
showIncubationNotStartedMessage()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val incubationTime = isBetween15And30Minutes(model.incubationTime)
|
|
||||||
when {
|
|
||||||
incubationTime < -15000 -> showIncubationNotCompletedMessage()
|
|
||||||
incubationTime > 300000 -> showIncubationCrossedMessage()
|
|
||||||
else -> navigateToMainActivity(model)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun showIncubationNotStartedMessage() {
|
|
||||||
Toast.makeText(
|
|
||||||
view.context,
|
|
||||||
context.getString(R.string.incubation_not_started),
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun showIncubationNotCompletedMessage() {
|
|
||||||
Toast.makeText(
|
|
||||||
view.context,
|
|
||||||
context.getString(R.string.incubation_not_completed),
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun showIncubationCrossedMessage() {
|
|
||||||
Toast.makeText(
|
|
||||||
view.context,
|
|
||||||
context.getString(R.string.incubation_crossed_30_minutes),
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun navigateToMainActivity(model: UserData) {
|
|
||||||
DataHolder.selectedTest = model
|
|
||||||
view.findNavController().navigate(R.id.action_nav_home_to_mainActivity)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun isBetween15And30Minutes(createdAt: String): Long {
|
private fun isBetween15And30Minutes(createdAt: String): Long {
|
||||||
val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
||||||
val createdAtDate: Date = formatter.parse(createdAt)!!
|
val createdAtDate: Date = formatter.parse(createdAt)!!
|
||||||
|
|
||||||
val currentTime = Calendar.getInstance().time
|
val currentTime = Calendar.getInstance().time
|
||||||
|
|
||||||
val diffMillis = currentTime.time - createdAtDate.time
|
val diffMillis = currentTime.time - createdAtDate.time
|
||||||
|
|
||||||
return diffMillis / (60 * 1000)
|
return diffMillis / (60 * 1000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,276 +36,233 @@ import `in`.sminnovations.hpostesting.databinding.FragmentAssuranceControlsBindi
|
|||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
|
||||||
class AssuranceControlsFragment : Fragment() {
|
class AssuranceControlsFragment : Fragment() {
|
||||||
private val selectConcentration = "Select concentration"
|
lateinit var binding: FragmentAssuranceControlsBinding
|
||||||
private val selectSolution = "Select solution"
|
|
||||||
private lateinit var binding: FragmentAssuranceControlsBinding
|
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
||||||
): View {
|
): View {
|
||||||
binding = FragmentAssuranceControlsBinding.inflate(inflater, container, false)
|
binding = FragmentAssuranceControlsBinding.inflate(inflater, container, false)
|
||||||
initializeSharedPreferences()
|
sharedPreferences =
|
||||||
resetTestData()
|
requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
|
|
||||||
|
DataHolder.hemoCubeTestData!!.solution = ""
|
||||||
|
DataHolder.hemoCubeTestData!!.volume = ""
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initializeSharedPreferences() {
|
|
||||||
sharedPreferences = requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun resetTestData() {
|
|
||||||
DataHolder.hemoCubeTestData?.apply {
|
|
||||||
solution = ""
|
|
||||||
volume = ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
initViews()
|
initViews()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initViews() {
|
private fun initViews() {
|
||||||
setupSolutionSpinner()
|
// binding.btnSubmit.visibility = View.GONE
|
||||||
setupConcentrationSpinner()
|
val solutionSpinner: Spinner = binding.spinnerSolutions
|
||||||
setupVolumeSpinner()
|
val solutionOptions = arrayOf("Select solution", "Tartrazine", "Acid Red","Sickle-Cert-Buffer", "1 Abs Holo Filter", "0.25 Abs Holo Filter", "Air Blank")
|
||||||
setupAdminSpinner()
|
val solutionAdapter =
|
||||||
loadSavedValues()
|
ArrayAdapter(requireContext(), R.layout.simple_spinner_item, solutionOptions)
|
||||||
setupSubmitButton()
|
solutionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||||
}
|
solutionSpinner.adapter = solutionAdapter
|
||||||
|
solutionSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
private fun setupSolutionSpinner() {
|
|
||||||
val solutionOptions = getSolutionOptions()
|
|
||||||
val solutionAdapter = createSpinnerAdapter(solutionOptions)
|
|
||||||
binding.spinnerSolutions.apply {
|
|
||||||
adapter = solutionAdapter
|
|
||||||
onItemSelectedListener = createSolutionSelectionListener(solutionOptions)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getSolutionOptions() = arrayOf(
|
|
||||||
selectSolution, "Tartrazine", "Acid Red", "Sickle-Cert-Buffer",
|
|
||||||
"1 Abs Holo Filter", "0.25 Abs Holo Filter", "Air Blank"
|
|
||||||
)
|
|
||||||
|
|
||||||
private fun createSolutionSelectionListener(solutionOptions: Array<String>) =
|
|
||||||
object : AdapterView.OnItemSelectedListener {
|
|
||||||
override fun onItemSelected(
|
override fun onItemSelected(
|
||||||
parent: AdapterView<*>?, view: View?, position: Int, id: Long
|
parent: AdapterView<*>?,
|
||||||
|
view: View?,
|
||||||
|
position: Int,
|
||||||
|
id: Long,
|
||||||
) {
|
) {
|
||||||
handleSolutionSelection(solutionOptions[position])
|
val selectedSolution: String = solutionOptions[position]
|
||||||
}
|
if (selectedSolution != "Select solution") {
|
||||||
|
DataHolder.hemoCubeTestData!!.solution = selectedSolution
|
||||||
|
|
||||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
// Update visibility and name based on selected solution
|
||||||
//Nothing
|
if(selectedSolution == "Tartrazine" || selectedSolution == "Acid Red"){
|
||||||
}
|
activity?.runOnUiThread {
|
||||||
}
|
binding.spinnerConcentration.visibility = View.VISIBLE
|
||||||
|
// Ensure the name is updated only after concentration is selected.
|
||||||
private fun handleSolutionSelection(selectedSolution: String) {
|
// You might need to adjust this logic based on how and when you want to update the name.
|
||||||
if (selectedSolution != selectSolution) {
|
// For now, it simply shows that the visibility is being handled.
|
||||||
DataHolder.hemoCubeTestData?.solution = selectedSolution
|
}
|
||||||
updateConcentrationSpinnerVisibility(selectedSolution)
|
} else {
|
||||||
} else {
|
activity?.runOnUiThread {
|
||||||
activity?.runOnUiThread {
|
binding.spinnerConcentration.visibility = View.GONE
|
||||||
binding.spinnerConcentration.visibility = View.GONE
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
}
|
activity?.runOnUiThread {
|
||||||
|
binding.spinnerConcentration.visibility = View.GONE
|
||||||
private fun updateConcentrationSpinnerVisibility(selectedSolution: String) {
|
}
|
||||||
val shouldShowConcentration = selectedSolution in listOf("Tartrazine", "Acid Red")
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
binding.spinnerConcentration.visibility =
|
|
||||||
if (shouldShowConcentration) View.VISIBLE else View.GONE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupConcentrationSpinner() {
|
|
||||||
val concentrationOptions = getConcentrationOptions()
|
|
||||||
val concentrationAdapter = createSpinnerAdapter(concentrationOptions)
|
|
||||||
binding.spinnerConcentration.apply {
|
|
||||||
adapter = concentrationAdapter
|
|
||||||
onItemSelectedListener = createConcentrationSelectionListener(concentrationOptions)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getConcentrationOptions() = arrayOf(
|
|
||||||
selectConcentration, "65umol", "45umol", "22.5umol", "12.25umol",
|
|
||||||
"6.125umol", "75umol", "50umol", "25umol", "12.5umol", "6.25umol"
|
|
||||||
)
|
|
||||||
|
|
||||||
private fun createConcentrationSelectionListener(concentrationOptions: Array<String>) =
|
|
||||||
object : AdapterView.OnItemSelectedListener {
|
|
||||||
override fun onItemSelected(
|
|
||||||
parent: AdapterView<*>?, view: View?, position: Int, id: Long
|
|
||||||
) {
|
|
||||||
val selectedValue = concentrationOptions[position]
|
|
||||||
if (selectedValue != selectConcentration) {
|
|
||||||
DataHolder.hemoCubeTestData?.concentration = selectedValue
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||||
//Nothing
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupVolumeSpinner() {
|
val concentrationSpinner: Spinner = binding.spinnerConcentration
|
||||||
val volumeOptions = getVolumeOptions()
|
val concentrationOptions = arrayOf(
|
||||||
val volumeAdapter = createSpinnerAdapter(volumeOptions)
|
"Select concentration",
|
||||||
binding.spinnerVolume.apply {
|
"65umol",
|
||||||
adapter = volumeAdapter
|
"45umol",
|
||||||
onItemSelectedListener = createVolumeSelectionListener(volumeOptions)
|
"22.5umol",
|
||||||
|
"12.25umol",
|
||||||
|
"6.125umol",
|
||||||
|
"75umol",
|
||||||
|
"50umol",
|
||||||
|
"25umol",
|
||||||
|
"12.5umol",
|
||||||
|
"6.25umol"
|
||||||
|
)
|
||||||
|
val concentrationAdapter =
|
||||||
|
ArrayAdapter(requireContext(), R.layout.simple_spinner_item, concentrationOptions)
|
||||||
|
concentrationAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||||
|
concentrationSpinner.adapter = concentrationAdapter
|
||||||
|
concentrationSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
|
override fun onItemSelected(
|
||||||
|
parent: AdapterView<*>?,
|
||||||
|
view: View?,
|
||||||
|
position: Int,
|
||||||
|
id: Long,
|
||||||
|
) {
|
||||||
|
val selectedValue: String = concentrationOptions[position]
|
||||||
|
if (!selectedValue.equals("Select concentration")) {
|
||||||
|
DataHolder.hemoCubeTestData!!.concentration = selectedValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun getVolumeOptions() =
|
val volumeSpinner: Spinner = binding.spinnerVolume
|
||||||
arrayOf("Select volume", "1uml", "2uml", "4uml", "4.5uml", "5uml")
|
val volumeOptions = arrayOf("Select volume", "1uml", "2uml", "4uml", "4.5uml", "5uml")
|
||||||
|
val volumeAdapter =
|
||||||
|
ArrayAdapter(requireContext(), R.layout.simple_spinner_item, volumeOptions)
|
||||||
|
volumeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||||
|
volumeSpinner.adapter = volumeAdapter
|
||||||
|
volumeSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
|
override fun onItemSelected(
|
||||||
|
parent: AdapterView<*>?,
|
||||||
|
view: View?,
|
||||||
|
position: Int,
|
||||||
|
id: Long,
|
||||||
|
) {
|
||||||
|
val selectedValue: String = volumeOptions[position]
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupAdminSpinner() {
|
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||||
val adminOptions = getAdminOptions()
|
}
|
||||||
val adminAdapter = createSpinnerAdapter(adminOptions)
|
|
||||||
binding.spinnerAdmin.apply {
|
|
||||||
adapter = adminAdapter
|
|
||||||
onItemSelectedListener = createAdminSelectionListener(adminOptions)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun getAdminOptions() = arrayOf(
|
|
||||||
"Select options", "Sickle-Cert-Buffer", "1 Abs Holo Filter",
|
|
||||||
"0.25 Abs Holo Filter", "Air Blank"
|
|
||||||
)
|
|
||||||
|
|
||||||
private fun createSpinnerAdapter(options: Array<String>): ArrayAdapter<String> {
|
val adminspinner: Spinner = binding.spinnerAdmin
|
||||||
return ArrayAdapter(requireContext(), R.layout.simple_spinner_item, options).apply {
|
val adminOptions = arrayOf("Select options", "Sickle-Cert-Buffer", "1 Abs Holo Filter", "0.25 Abs Holo Filter", "Air Blank")
|
||||||
setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
val adminAdapter =
|
||||||
|
ArrayAdapter(requireContext(), R.layout.simple_spinner_item, adminOptions)
|
||||||
|
adminAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||||
|
adminspinner.adapter =adminAdapter
|
||||||
|
adminspinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
|
override fun onItemSelected(
|
||||||
|
parent: AdapterView<*>?,
|
||||||
|
view: View?,
|
||||||
|
position: Int,
|
||||||
|
id: Long,
|
||||||
|
) {
|
||||||
|
val selectedValue: String = adminOptions[position]
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
// load saved values
|
||||||
|
val savedSolution =
|
||||||
|
sharedPreferences.getString(Constants.QUICK_CAPTURE_SOLUTION, "").toString()
|
||||||
|
val solutionPosition = getPositionOfValue(savedSolution, solutionOptions.toList())
|
||||||
|
solutionSpinner.setSelection(solutionPosition)
|
||||||
|
|
||||||
private fun loadSavedValues() {
|
val savedConcentration =
|
||||||
loadSpinnerValue(Constants.QUICK_CAPTURE_SOLUTION, getSolutionOptions(), binding.spinnerSolutions)
|
sharedPreferences.getString(Constants.QUICK_CAPTURE_CONCENTRATION, "").toString()
|
||||||
loadSpinnerValue(Constants.QUICK_CAPTURE_CONCENTRATION, getConcentrationOptions(), binding.spinnerConcentration)
|
val concentrationPosition =
|
||||||
loadSpinnerValue(Constants.QUICK_CAPTURE_VOLUME, getVolumeOptions(), binding.spinnerVolume)
|
getPositionOfValue(savedConcentration, concentrationOptions.toList())
|
||||||
loadSpinnerValue(Constants.QUICK_CAPTURE_FOR_ADMIN, getAdminOptions(), binding.spinnerAdmin)
|
concentrationSpinner.setSelection(concentrationPosition)
|
||||||
}
|
|
||||||
|
|
||||||
private fun loadSpinnerValue(key: String, options: Array<String>, spinner: Spinner) {
|
val savedVolume = sharedPreferences.getString(Constants.QUICK_CAPTURE_VOLUME, "").toString()
|
||||||
val savedValue = sharedPreferences.getString(key, "").toString()
|
val volumePosition = getPositionOfValue(savedVolume, volumeOptions.toList())
|
||||||
val position = getPositionOfValue(savedValue, options.toList())
|
volumeSpinner.setSelection(volumePosition)
|
||||||
spinner.setSelection(position)
|
|
||||||
}
|
|
||||||
|
val foradmin =
|
||||||
|
sharedPreferences.getString(Constants.QUICK_CAPTURE_FOR_ADMIN, "").toString()
|
||||||
|
val adminPosition = getPositionOfValue(foradmin, adminOptions.toList())
|
||||||
|
adminspinner.setSelection(adminPosition)
|
||||||
|
|
||||||
private fun setupSubmitButton() {
|
|
||||||
binding.btnSubmit.setOnClickListener {
|
binding.btnSubmit.setOnClickListener {
|
||||||
if (!validateSelections()) return@setOnClickListener
|
val selectedSolution = binding.spinnerSolutions.selectedItem.toString()
|
||||||
updateTestData()
|
val selectedConcentration = binding.spinnerConcentration.selectedItem.toString()
|
||||||
savePreferences()
|
val selectedadminOption = binding.spinnerAdmin.selectedItem.toString()
|
||||||
navigateToHemocubeActivity()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun validateSelections(): Boolean {
|
// Check if any of the selections are default values
|
||||||
val selectedSolution = binding.spinnerSolutions.selectedItem.toString()
|
if (selectedSolution == "Select solution") {
|
||||||
val selectedConcentration = binding.spinnerConcentration.selectedItem.toString()
|
Toast.makeText(requireContext(), "Please select a solution", Toast.LENGTH_LONG).show()
|
||||||
val selectedAdminOption = binding.spinnerAdmin.selectedItem.toString()
|
return@setOnClickListener // Prevent further execution
|
||||||
|
}else{
|
||||||
if (selectedSolution == selectSolution) {
|
DataHolder.hemoCubeTestData!!.name = selectedSolution
|
||||||
showToast("Please select a solution")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedConcentration == selectConcentration && binding.spinnerConcentration.isVisible) {
|
|
||||||
showToast("Please select a concentration")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedAdminOption == "Select options" && binding.spinnerAdmin.isVisible) {
|
|
||||||
showToast("Please select a option")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun showToast(message: String) {
|
|
||||||
Toast.makeText(requireContext(), message, Toast.LENGTH_LONG).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateTestData() {
|
|
||||||
DataHolder.hemoCubeTestData?.apply {
|
|
||||||
quickCapture = true
|
|
||||||
_id = generateTestId()
|
|
||||||
solution = binding.spinnerSolutions.selectedItem.toString()
|
|
||||||
concentration = binding.spinnerConcentration.selectedItem.toString()
|
|
||||||
filter = binding.spinnerAdmin.selectedItem.toString()
|
|
||||||
name = determineTestName()
|
|
||||||
}
|
|
||||||
|
|
||||||
DataHolder.selectedTest = UserData().apply {
|
|
||||||
_id = DataHolder.hemoCubeTestData?._id.toString()
|
|
||||||
name = DataHolder.hemoCubeTestData?.name.toString()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun generateTestId(): String {
|
|
||||||
val currentUnixTime = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
||||||
Instant.now().epochSecond
|
|
||||||
} else {
|
|
||||||
""
|
|
||||||
}
|
|
||||||
return "${currentUnixTime}SMI"
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun determineTestName(): String {
|
|
||||||
val solution = binding.spinnerSolutions.selectedItem.toString()
|
|
||||||
return if (binding.spinnerConcentration.isVisible) {
|
|
||||||
"$solution ${binding.spinnerConcentration.selectedItem}"
|
|
||||||
} else {
|
|
||||||
solution
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun savePreferences() {
|
|
||||||
with(sharedPreferences.edit()) {
|
|
||||||
putString(Constants.QUICK_CAPTURE_SOLUTION, DataHolder.hemoCubeTestData?.solution)
|
|
||||||
putString(Constants.QUICK_CAPTURE_CONCENTRATION, DataHolder.hemoCubeTestData?.concentration)
|
|
||||||
putString(Constants.QUICK_CAPTURE_VOLUME, DataHolder.hemoCubeTestData?.volume)
|
|
||||||
putString(Constants.QUICK_CAPTURE_FOR_ADMIN, DataHolder.hemoCubeTestData?.filter)
|
|
||||||
apply()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun navigateToHemocubeActivity() {
|
|
||||||
val intent = Intent(requireContext(), HemocubeActivity::class.java)
|
|
||||||
startActivity(intent)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun createVolumeSelectionListener(volumeOptions: Array<String>) =
|
|
||||||
object : AdapterView.OnItemSelectedListener {
|
|
||||||
override fun onItemSelected(
|
|
||||||
parent: AdapterView<*>?, view: View?, position: Int, id: Long
|
|
||||||
) {
|
|
||||||
volumeOptions[position]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
if (selectedConcentration == "Select concentration" && binding.spinnerConcentration.isVisible) {
|
||||||
//Nothing
|
Toast.makeText(requireContext(), "Please select a concentration", Toast.LENGTH_LONG).show()
|
||||||
}
|
return@setOnClickListener // Prevent further execution
|
||||||
}
|
}else if(binding.spinnerConcentration.isVisible){
|
||||||
|
DataHolder.hemoCubeTestData!!.name = "$selectedSolution $selectedConcentration"
|
||||||
private fun createAdminSelectionListener(adminOptions: Array<String>) =
|
}else{
|
||||||
object : AdapterView.OnItemSelectedListener {
|
DataHolder.hemoCubeTestData!!.name = selectedSolution
|
||||||
override fun onItemSelected(
|
|
||||||
parent: AdapterView<*>?, view: View?, position: Int, id: Long
|
|
||||||
) {
|
|
||||||
adminOptions[position]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
|
||||||
//Nothing
|
|
||||||
|
|
||||||
|
if (selectedadminOption == "Select options" && binding.spinnerAdmin.isVisible) {
|
||||||
|
Toast.makeText(requireContext(), "Please select a option", Toast.LENGTH_LONG).show()
|
||||||
|
return@setOnClickListener // Prevent further execution
|
||||||
}
|
}
|
||||||
|
DataHolder.hemoCubeTestData!!.quickCapture = true
|
||||||
|
val currentUnixTime = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
Instant.now().epochSecond
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
DataHolder.hemoCubeTestData!!._id = currentUnixTime.toString() + "SMI"
|
||||||
|
DataHolder.hemoCubeTestData!!.solution = binding.spinnerSolutions.selectedItem.toString()
|
||||||
|
DataHolder.hemoCubeTestData!!.concentration = binding.spinnerConcentration.selectedItem.toString()
|
||||||
|
DataHolder.hemoCubeTestData!!.filter = binding.spinnerAdmin.selectedItem.toString()
|
||||||
|
// if(binding.spinnerAdmin.selectedItem.toString().equals("Select options") && binding.spinnerAdmin.isVisible){
|
||||||
|
// Toast.makeText(requireContext(), "Please select a option", Toast.LENGTH_LONG).show()
|
||||||
|
// }else {
|
||||||
|
// DataHolder.hemoCubeTestData!!.name = DataHolder.hemoCubeTestData!!.filter.toString()
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DataHolder.selectedTest = UserData()
|
||||||
|
DataHolder.selectedTest?._id = DataHolder.hemoCubeTestData!!._id
|
||||||
|
DataHolder.selectedTest?.name = DataHolder.hemoCubeTestData!!.name
|
||||||
|
|
||||||
|
with(sharedPreferences.edit()) {
|
||||||
|
putString(Constants.QUICK_CAPTURE_SOLUTION, DataHolder.hemoCubeTestData!!.solution)
|
||||||
|
putString(
|
||||||
|
Constants.QUICK_CAPTURE_CONCENTRATION,
|
||||||
|
DataHolder.hemoCubeTestData!!.concentration
|
||||||
|
)
|
||||||
|
putString(Constants.QUICK_CAPTURE_VOLUME, DataHolder.hemoCubeTestData!!.volume)
|
||||||
|
putString(Constants.QUICK_CAPTURE_FOR_ADMIN, DataHolder.hemoCubeTestData!!.filter)
|
||||||
|
apply()
|
||||||
|
}
|
||||||
|
|
||||||
|
val i = Intent(requireContext(), HemocubeActivity::class.java)
|
||||||
|
startActivity(i)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun <T> getPositionOfValue(value: T, data: List<T>?): Int {
|
fun <T> getPositionOfValue(value: T, data: List<T>?): Int {
|
||||||
data?.let {
|
data?.let {
|
||||||
@@ -315,6 +272,7 @@ class AssuranceControlsFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,101 +44,74 @@ class AutoDacFragment : Fragment() {
|
|||||||
private lateinit var sharedPreferences: SharedPreferences
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
private var currentDeviceData: DeviceData? = null
|
private var currentDeviceData: DeviceData? = null
|
||||||
private var resultData: String = ""
|
private var resultData: String = ""
|
||||||
|
// private val messages = MutableLiveData<String>()
|
||||||
private var startListening = MutableLiveData(false)
|
private var startListening = MutableLiveData(false)
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
||||||
): View {
|
): View {
|
||||||
binding = FragmentAutoDacBinding.inflate(inflater, container, false)
|
binding = FragmentAutoDacBinding.inflate(inflater, container, false)
|
||||||
initSharedPreferences()
|
sharedPreferences =
|
||||||
|
requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initSharedPreferences() {
|
|
||||||
sharedPreferences = requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
initViews()
|
initViews()
|
||||||
setupObservers()
|
observeViewModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initViews() {
|
private fun initViews() {
|
||||||
setupInitialViewState()
|
binding.btnSubmit.visibility = View.GONE
|
||||||
setupClickListeners()
|
|
||||||
setupAdminControls()
|
|
||||||
listenToHemoCube()
|
listenToHemoCube()
|
||||||
getDeviceId()
|
getDeviceId()
|
||||||
}
|
binding.tvSubtitle4.movementMethod = ScrollingMovementMethod()
|
||||||
|
binding.btnSubmit.setOnClickListener {
|
||||||
private fun setupInitialViewState() {
|
resultData += "Calibrating the device...\n"
|
||||||
binding.apply {
|
autoDacViewModel.messages.postValue(resultData)
|
||||||
btnSubmit.visibility = View.GONE
|
testStatusCode = 0.5
|
||||||
tvSubtitle4.movementMethod = ScrollingMovementMethod()
|
binding.btnSubmit.visibility = View.GONE
|
||||||
|
runJCommand()
|
||||||
}
|
}
|
||||||
|
binding.btnReadDac.setOnClickListener {
|
||||||
|
readClick = true
|
||||||
|
binding.btnReadDac.visibility = View.GONE
|
||||||
|
runECommand()
|
||||||
|
}
|
||||||
|
if (sharedPreferences.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
||||||
|
binding.btnReadDac.visibility = View.VISIBLE
|
||||||
|
}else{
|
||||||
|
binding.btnReadDac.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupClickListeners() {
|
private fun observeViewModel() {
|
||||||
binding.apply {
|
|
||||||
btnSubmit.setOnClickListener {
|
autoDacViewModel.deviceData.observe(viewLifecycleOwner) {
|
||||||
resultData += "Calibrating the device...\n"
|
currentDeviceData = it
|
||||||
autoDacViewModel.messages.postValue(resultData)
|
}
|
||||||
testStatusCode = 0.5
|
|
||||||
btnSubmit.visibility = View.GONE
|
autoDacViewModel.messages.observe(viewLifecycleOwner) {
|
||||||
sendHemoCubeCommand(HemoCubeCommands.J_COMMAND)
|
binding.tvSubtitle4.text = it
|
||||||
|
}
|
||||||
|
|
||||||
|
autoDacViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
||||||
|
if (result == "Success") {
|
||||||
|
showToast("Auto Dac data uploaded successfully")
|
||||||
}
|
}
|
||||||
btnReadDac.setOnClickListener {
|
if (result == "Local") {
|
||||||
readClick = true
|
showToast("Auto Dac uploading failed, note it down manually")
|
||||||
btnReadDac.visibility = View.GONE
|
|
||||||
sendHemoCubeCommand(HemoCubeCommands.LOAD_DAC_VALUES)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupAdminControls() {
|
binding.progressBar.visibility = View.GONE
|
||||||
binding.btnReadDac.visibility =
|
|
||||||
if (isAdminUser()) View.VISIBLE else View.GONE
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun isAdminUser(): Boolean =
|
|
||||||
sharedPreferences.getString(Constants.USER_ID, "") == "ADMIN"
|
|
||||||
|
|
||||||
private fun setupObservers() {
|
|
||||||
with(autoDacViewModel) {
|
|
||||||
deviceData.observe(viewLifecycleOwner) { currentDeviceData = it }
|
|
||||||
messages.observe(viewLifecycleOwner) { binding.tvSubtitle4.text = it }
|
|
||||||
fireBaseUpload.observe(viewLifecycleOwner) { handleFirebaseUploadResult(it) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun handleFirebaseUploadResult(result: String) {
|
|
||||||
when (result) {
|
|
||||||
"Success" -> showToast("Auto Dac data uploaded successfully")
|
|
||||||
"Local" -> showToast("Auto Dac uploading failed, note it down manually")
|
|
||||||
}
|
|
||||||
binding.progressBar.visibility = View.GONE
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun sendHemoCubeCommand(
|
|
||||||
command: HemoCubeCommands,
|
|
||||||
listener: UsbServiceListener = defaultUsbListener()
|
|
||||||
) {
|
|
||||||
autoDacViewModel.progressBar.postValue(true)
|
|
||||||
(activity as AutoDacActivity).mService.sendAndListenToHemoCube(command, listener)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun defaultUsbListener() = object : UsbServiceListener {
|
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
|
||||||
//Nothing
|
|
||||||
}
|
|
||||||
override fun onUsbError(e: Exception?) {
|
|
||||||
autoDacViewModel.progressBar.postValue(false)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getDeviceId() {
|
private fun getDeviceId() {
|
||||||
sendHemoCubeCommand(
|
autoDacViewModel.progressBar.postValue(true)
|
||||||
|
(activity as AutoDacActivity).mService.sendAndListenToHemoCube(
|
||||||
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
@@ -152,143 +125,257 @@ class AutoDacFragment : Fragment() {
|
|||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
autoDacViewModel.progressBar.postValue(false)
|
autoDacViewModel.progressBar.postValue(false)
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
)
|
}
|
||||||
|
private fun runJCommand() {
|
||||||
|
autoDacViewModel.progressBar.postValue(true)
|
||||||
|
(activity as AutoDacActivity).mService.sendAndListenToHemoCube(
|
||||||
|
HemoCubeCommands.J_COMMAND,
|
||||||
|
object : UsbServiceListener {
|
||||||
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
autoDacViewModel.progressBar.postValue(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
private fun runDCommand() {
|
||||||
|
autoDacViewModel.progressBar.postValue(true)
|
||||||
|
(activity as AutoDacActivity).mService.sendAndListenToHemoCube(
|
||||||
|
HemoCubeCommands.DIAGNOSTICS_COMMAND,
|
||||||
|
object : UsbServiceListener {
|
||||||
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
autoDacViewModel.progressBar.postValue(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
private fun runCCommand() {
|
||||||
|
autoDacViewModel.progressBar.postValue(true)
|
||||||
|
(activity as AutoDacActivity).mService.sendAndListenToHemoCube(
|
||||||
|
HemoCubeCommands.AUTO_DAC_COMMAND,
|
||||||
|
object : UsbServiceListener {
|
||||||
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
autoDacViewModel.progressBar.postValue(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
private fun runGCommand() {
|
||||||
|
autoDacViewModel.progressBar.postValue(true)
|
||||||
|
(activity as AutoDacActivity).mService.sendAndListenToHemoCube(
|
||||||
|
HemoCubeCommands.SET_AUTO_DAC_TO_EPROM_COMMAND,
|
||||||
|
object : UsbServiceListener {
|
||||||
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
autoDacViewModel.progressBar.postValue(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
private fun runECommand() {
|
||||||
|
autoDacViewModel.progressBar.postValue(true)
|
||||||
|
(activity as AutoDacActivity).mService.sendAndListenToHemoCube(
|
||||||
|
HemoCubeCommands.LOAD_DAC_VALUES,
|
||||||
|
object : UsbServiceListener {
|
||||||
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
autoDacViewModel.progressBar.postValue(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun setAutoDacValuesCommand() {
|
||||||
|
autoDacViewModel.progressBar.postValue(true)
|
||||||
|
(activity as AutoDacActivity).mService.sendAndListenToHemoCube(
|
||||||
|
HemoCubeCommands.SET_AUTO_DAC_TO_EPROM_COMMAND,
|
||||||
|
object : UsbServiceListener {
|
||||||
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
autoDacViewModel.progressBar.postValue(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun readCurrentDACValuesCommand() {
|
||||||
|
autoDacViewModel.progressBar.postValue(true)
|
||||||
|
(activity as AutoDacActivity).mService.sendAndListenToHemoCube(
|
||||||
|
HemoCubeCommands.READ_DAC_COMMAND,
|
||||||
|
object : UsbServiceListener {
|
||||||
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
autoDacViewModel.progressBar.postValue(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun listenToHemoCube() {
|
private fun listenToHemoCube() {
|
||||||
|
|
||||||
|
val fullReadOutput = StringBuilder()
|
||||||
startListening.postValue(true)
|
startListening.postValue(true)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
(activity as AutoDacActivity).mService.listenToHemoCube(
|
(activity as AutoDacActivity).mService.listenToHemoCube(object :
|
||||||
object : UsbServiceListener {
|
UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
data?.let { handleHemoCubeData(String(it)) }
|
data?.let {
|
||||||
|
val stringData = String(it)
|
||||||
|
fullReadOutput.append(stringData)
|
||||||
|
resultData += stringData
|
||||||
|
if (sharedPreferences.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
||||||
|
autoDacViewModel.messages.postValue(resultData)
|
||||||
|
}
|
||||||
|
// 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("#JC") && testStatusCode < 1.0) {
|
||||||
|
testStatusCode = 1.1
|
||||||
|
runDCommand()
|
||||||
|
}
|
||||||
|
if (resultData.contains("#DC") && testStatusCode < 1.2) {
|
||||||
|
testStatusCode = 1.3
|
||||||
|
if(validateDacValues()){
|
||||||
|
if (sharedPreferences.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
||||||
|
resultData += "Calibrating the device, Please wait...\n"
|
||||||
|
}else{
|
||||||
|
resultData = "Calibrating the device, Please wait...\n"
|
||||||
|
}
|
||||||
|
autoDacViewModel.messages.postValue(resultData)
|
||||||
|
runCCommand()
|
||||||
|
}else{
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
if (sharedPreferences.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
||||||
|
resultData += "Calibration failed!\nContact us for help at support@sminnovations.in"
|
||||||
|
}else{
|
||||||
|
resultData = "Calibration failed!\nContact us for help at support@sminnovations.in"
|
||||||
|
}
|
||||||
|
autoDacViewModel.messages.postValue(resultData)
|
||||||
|
binding.btnReadDac.visibility = View.GONE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (resultData.contains("#GC") && testStatusCode < 1.6) {
|
||||||
|
testStatusCode = 1.7
|
||||||
|
runECommand()
|
||||||
|
}
|
||||||
|
if (resultData.contains("#EC") && testStatusCode < 1.8) {
|
||||||
|
testStatusCode = 1.9
|
||||||
|
if (sharedPreferences.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
||||||
|
resultData += "Calibration Completed\n"
|
||||||
|
}else{
|
||||||
|
resultData = "Calibration Completed\n"
|
||||||
|
}
|
||||||
|
autoDacViewModel.messages.postValue(resultData)
|
||||||
|
activity?.runOnUiThread {
|
||||||
|
Toast.makeText(requireActivity(), "Calibration completed", Toast.LENGTH_LONG).show()
|
||||||
|
binding.ivCheck.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (resultData.contains("#EC") && readClick && testStatusCode < 2.1) {
|
||||||
|
testStatusCode = 2.2
|
||||||
|
readCurrentDACValuesCommand()
|
||||||
|
}
|
||||||
|
if (resultData.contains("#CC") && testStatusCode < 1.4) {
|
||||||
|
testStatusCode = 1.5
|
||||||
|
setAutoDacValuesCommand()
|
||||||
|
autoDacViewModel.addAutoDacDataToDb(
|
||||||
|
DiagnosticsData(
|
||||||
|
deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "")
|
||||||
|
.toString(),
|
||||||
|
devicePassword = sharedPreferences.getString(
|
||||||
|
Constants.DEVICE_PASSWORD_API,
|
||||||
|
""
|
||||||
|
).toString(),
|
||||||
|
deviceNatsToken = sharedPreferences.getString(
|
||||||
|
Constants.NATS_TOKEN,
|
||||||
|
""
|
||||||
|
).toString(),
|
||||||
|
accessToken = sharedPreferences.getString(
|
||||||
|
Constants.ACCESS_TOKEN,
|
||||||
|
""
|
||||||
|
).toString(),
|
||||||
|
deviceData = resultData,
|
||||||
|
runTime = SimpleDateFormat(
|
||||||
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
|
).format(Calendar.getInstance().time)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
if (resultData.contains("#WC")) {
|
||||||
autoDacViewModel.progressBar.postValue(false)
|
showToast("DAC Values saved to EPROM")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
override fun onUsbError(e: Exception?) {
|
||||||
|
autoDacViewModel.progressBar.postValue(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fun extractSubstring(input: String): String {
|
||||||
private fun handleHemoCubeData(stringData: String) {
|
val regex = "#CS(.*?)#CC".toRegex()
|
||||||
resultData += stringData
|
val matchResult = regex.find(input)
|
||||||
if (isAdminUser()) {
|
return matchResult?.groups?.get(1)?.value?.trim() ?: ""
|
||||||
autoDacViewModel.messages.postValue(resultData)
|
|
||||||
}
|
|
||||||
|
|
||||||
when {
|
|
||||||
stringData.contains("SN") -> handleSerialNumber(stringData)
|
|
||||||
resultData.contains("#JC") && testStatusCode < 1.0 -> handleJCommandResponse()
|
|
||||||
resultData.contains("#DC") && testStatusCode < 1.2 -> handleDCommandResponse()
|
|
||||||
resultData.contains("#GC") && testStatusCode < 1.6 -> handleGCommandResponse()
|
|
||||||
resultData.contains("#EC") && testStatusCode < 1.8 -> handleECommandResponse()
|
|
||||||
resultData.contains("#EC") && readClick && testStatusCode < 2.1 -> handleReadClickResponse()
|
|
||||||
resultData.contains("#CC") && testStatusCode < 1.4 -> handleCCommandResponse()
|
|
||||||
resultData.contains("#WC") -> showToast("DAC Values saved to EPROM")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleSerialNumber(stringData: String) {
|
|
||||||
stringData.split(" ").getOrNull(1)?.trim()?.let { _ ->
|
|
||||||
// Commented as per original code
|
|
||||||
// saveHardwareId(hardwareId)
|
|
||||||
}
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
binding.btnSubmit.visibility = View.VISIBLE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun handleJCommandResponse() {
|
|
||||||
testStatusCode = 1.1
|
|
||||||
sendHemoCubeCommand(HemoCubeCommands.DIAGNOSTICS_COMMAND)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun handleDCommandResponse() {
|
|
||||||
testStatusCode = 1.3
|
|
||||||
if (validateDacValues()) {
|
|
||||||
val message = if (isAdminUser()) {
|
|
||||||
resultData += "Calibrating the device, Please wait...\n"
|
|
||||||
resultData
|
|
||||||
} else {
|
|
||||||
"Calibrating the device, Please wait...\n"
|
|
||||||
}
|
|
||||||
autoDacViewModel.messages.postValue(message)
|
|
||||||
sendHemoCubeCommand(HemoCubeCommands.AUTO_DAC_COMMAND)
|
|
||||||
} else {
|
|
||||||
handleCalibrationFailure()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun handleCalibrationFailure() {
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
val message = if (isAdminUser()) {
|
|
||||||
resultData += "Calibration failed!\nContact us for help at support@sminnovations.in"
|
|
||||||
resultData
|
|
||||||
} else {
|
|
||||||
"Calibration failed!\nContact us for help at support@sminnovations.in"
|
|
||||||
}
|
|
||||||
autoDacViewModel.messages.postValue(message)
|
|
||||||
binding.btnReadDac.visibility = View.GONE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun handleGCommandResponse() {
|
|
||||||
testStatusCode = 1.7
|
|
||||||
sendHemoCubeCommand(HemoCubeCommands.LOAD_DAC_VALUES)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun handleECommandResponse() {
|
|
||||||
testStatusCode = 1.9
|
|
||||||
val message = if (isAdminUser()) {
|
|
||||||
resultData += "Calibration Completed\n"
|
|
||||||
resultData
|
|
||||||
} else {
|
|
||||||
"Calibration Completed\n"
|
|
||||||
}
|
|
||||||
autoDacViewModel.messages.postValue(message)
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
showToast("Calibration completed")
|
|
||||||
binding.ivCheck.visibility = View.VISIBLE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun handleReadClickResponse() {
|
|
||||||
testStatusCode = 2.2
|
|
||||||
sendHemoCubeCommand(HemoCubeCommands.READ_DAC_COMMAND)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun handleCCommandResponse() {
|
|
||||||
testStatusCode = 1.5
|
|
||||||
sendHemoCubeCommand(HemoCubeCommands.SET_AUTO_DAC_TO_EPROM_COMMAND)
|
|
||||||
uploadAutoDacData()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun uploadAutoDacData() {
|
|
||||||
autoDacViewModel.addAutoDacDataToDb(
|
|
||||||
DiagnosticsData(
|
|
||||||
deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString(),
|
|
||||||
devicePassword = sharedPreferences.getString(Constants.DEVICE_PASSWORD_API, "").toString(),
|
|
||||||
deviceNatsToken = sharedPreferences.getString(Constants.NATS_TOKEN, "").toString(),
|
|
||||||
accessToken = sharedPreferences.getString(Constants.ACCESS_TOKEN, "").toString(),
|
|
||||||
deviceData = resultData,
|
|
||||||
runTime = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault())
|
|
||||||
.format(Calendar.getInstance().time)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun validateDacValues(): Boolean {
|
private fun validateDacValues(): Boolean {
|
||||||
val pattern = Regex("(LED:\\d+)__DAC:(\\d+)__ADC:(\\d+)")
|
val pattern = Regex("(LED:\\d+)__DAC:(\\d+)__ADC:(\\d+)")
|
||||||
return pattern.findAll(resultData).none { match ->
|
val matches = pattern.findAll(resultData)
|
||||||
|
for (match in matches) {
|
||||||
|
val ledName = match.groupValues[1]
|
||||||
val xValue = match.groupValues[2].toDouble()
|
val xValue = match.groupValues[2].toDouble()
|
||||||
val yValue = match.groupValues[3].toDouble()
|
val yValue = match.groupValues[3].toDouble()
|
||||||
xValue == 3200.0 && yValue < 500.0
|
|
||||||
|
if(xValue == 3200.0){
|
||||||
|
if(yValue < 500.0){
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
private fun showToast(message: String) {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class AutoDacViewModel @Inject constructor(
|
|||||||
fun addAutoDacDataToDb(data: DiagnosticsData) {
|
fun addAutoDacDataToDb(data: DiagnosticsData) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
when (repository.addDiagnostics(data)) {
|
when (val response = repository.addDiagnostics(data)) {
|
||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import java.util.UUID
|
|||||||
import kotlin.math.log10
|
import kotlin.math.log10
|
||||||
|
|
||||||
class HemoCubeBufferCheckFragment : Fragment() {
|
class HemoCubeBufferCheckFragment : Fragment() {
|
||||||
private val kitFailed = "Kit Failed"
|
|
||||||
private lateinit var binding: FragmentHemoCubeReferenceBinding
|
private lateinit var binding: FragmentHemoCubeReferenceBinding
|
||||||
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
@@ -178,7 +178,6 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@@ -403,27 +402,27 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private fun findResult(calculatedRatio: Double?): String {
|
private fun findResult(calculatedRatio: Double?): String {
|
||||||
// try {
|
try {
|
||||||
// hemoCubeViewModel.messages.postValue("result classification")
|
hemoCubeViewModel.messages.postValue("result classification")
|
||||||
// if (calculatedRatio != null) {
|
if (calculatedRatio != null) {
|
||||||
// if (calculatedRatio < 0.05) return "Inconclusive. Very low Absorbance - Repeat test with Higher Blood Volume"
|
if (calculatedRatio < 0.05) return "Inconclusive. Very low Absorbance - Repeat test with Higher Blood Volume"
|
||||||
// if (calculatedRatio in 0.05..0.155) return "Normal"
|
if (calculatedRatio in 0.05..0.155) return "Normal"
|
||||||
// if (calculatedRatio in 0.155..0.175) return "Negative Borderline. Repeat Test"
|
if (calculatedRatio in 0.155..0.175) return "Negative Borderline. Repeat Test"
|
||||||
// if (calculatedRatio in 0.175..0.22) return "Sickle Cell Trait"
|
if (calculatedRatio in 0.175..0.22) return "Sickle Cell Trait"
|
||||||
// if (calculatedRatio in 0.22..0.25) return "Positive for Sickle Cell. HPLC for Confirmation"
|
if (calculatedRatio in 0.22..0.25) return "Positive for Sickle Cell. HPLC for Confirmation"
|
||||||
// if (calculatedRatio in 0.25..0.35) return "Sickle Cell Disease"
|
if (calculatedRatio in 0.25..0.35) return "Sickle Cell Disease"
|
||||||
// if (calculatedRatio > 0.35) return "Inconclusive. Repeat with test with lower volume of blood"
|
if (calculatedRatio > 0.35) return "Inconclusive. Repeat with test with lower volume of blood"
|
||||||
// } else {
|
} else {
|
||||||
// return "INVALID"
|
return "INVALID"
|
||||||
// }
|
}
|
||||||
// } catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
// showToast(R.string.error_classification)
|
showToast(R.string.error_classification)
|
||||||
// Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
// return "ERROR"
|
return "ERROR"
|
||||||
// }
|
}
|
||||||
// return "INVALID"
|
return "INVALID"
|
||||||
// }
|
}
|
||||||
|
|
||||||
private fun absorbanceBasedClassification(predictedDenovixRatio: Double?): String {
|
private fun absorbanceBasedClassification(predictedDenovixRatio: Double?): String {
|
||||||
try {
|
try {
|
||||||
@@ -431,9 +430,9 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
if (predictedDenovixRatio != null) {
|
if (predictedDenovixRatio != null) {
|
||||||
if (predictedDenovixRatio in 0.0..0.16) return "Kit Passed"
|
if (predictedDenovixRatio in 0.0..0.16) return "Kit Passed"
|
||||||
if (predictedDenovixRatio in 0.16..0.165) return "Kit Passed"
|
if (predictedDenovixRatio in 0.16..0.165) return "Kit Passed"
|
||||||
if (predictedDenovixRatio in 0.165..0.235) return kitFailed
|
if (predictedDenovixRatio in 0.165..0.235) return "Kit Failed"
|
||||||
if (predictedDenovixRatio in 0.235..0.24) return kitFailed
|
if (predictedDenovixRatio in 0.235..0.24) return "Kit Failed"
|
||||||
if (predictedDenovixRatio in 0.24..1.0) return kitFailed
|
if (predictedDenovixRatio in 0.24..1.0) return "Kit Failed"
|
||||||
} else {
|
} else {
|
||||||
return "INVALID"
|
return "INVALID"
|
||||||
}
|
}
|
||||||
@@ -461,12 +460,9 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
|
|
||||||
(activity as HemocubeBufferCheckActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.START_BUFFER_COMMAND,
|
(activity as HemocubeBufferCheckActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.START_BUFFER_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -478,12 +474,9 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
|
|
||||||
(activity as HemocubeBufferCheckActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.START_SAMPLE,
|
(activity as HemocubeBufferCheckActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.START_SAMPLE,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -511,21 +504,18 @@ class HemoCubeBufferCheckFragment : Fragment() {
|
|||||||
|
|
||||||
(activity as HemocubeBufferCheckActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.PRINT_COMMAND,
|
(activity as HemocubeBufferCheckActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.PRINT_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// private fun calculateRatio(ratio: Double): Double {
|
private fun calculateRatio(ratio: Double): Double {
|
||||||
// val coefficient1 = currentDeviceData?.coefficients?.get(0) ?: 0.0
|
val coefficient1 = currentDeviceData?.coefficients?.get(0) ?: 0.0
|
||||||
// val coefficient2 = currentDeviceData?.coefficients?.get(1) ?: 1.0
|
val coefficient2 = currentDeviceData?.coefficients?.get(1) ?: 1.0
|
||||||
// return coefficient1 * ratio + coefficient2
|
return coefficient1 * ratio + coefficient2
|
||||||
// }
|
}
|
||||||
|
|
||||||
private fun isSerialValid(s: String): Boolean {
|
private fun isSerialValid(s: String): Boolean {
|
||||||
if (s.length != 17) {
|
if (s.length != 17) {
|
||||||
|
|||||||
@@ -75,11 +75,9 @@ class CalibrationFragment : Fragment() {
|
|||||||
val etLed1Slope = binding.etLed1Slope
|
val etLed1Slope = binding.etLed1Slope
|
||||||
etLed1Slope.addTextChangedListener(object : TextWatcher {
|
etLed1Slope.addTextChangedListener(object : TextWatcher {
|
||||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun afterTextChanged(s: Editable?) {
|
override fun afterTextChanged(s: Editable?) {
|
||||||
@@ -89,11 +87,9 @@ class CalibrationFragment : Fragment() {
|
|||||||
val etLed1Intercept = binding.etLed1Intercept
|
val etLed1Intercept = binding.etLed1Intercept
|
||||||
etLed1Intercept.addTextChangedListener(object : TextWatcher {
|
etLed1Intercept.addTextChangedListener(object : TextWatcher {
|
||||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun afterTextChanged(s: Editable?) {
|
override fun afterTextChanged(s: Editable?) {
|
||||||
@@ -104,11 +100,9 @@ class CalibrationFragment : Fragment() {
|
|||||||
val etLed2Slope = binding.etLed2Slope
|
val etLed2Slope = binding.etLed2Slope
|
||||||
etLed2Slope.addTextChangedListener(object : TextWatcher {
|
etLed2Slope.addTextChangedListener(object : TextWatcher {
|
||||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun afterTextChanged(s: Editable?) {
|
override fun afterTextChanged(s: Editable?) {
|
||||||
@@ -118,11 +112,9 @@ class CalibrationFragment : Fragment() {
|
|||||||
val etLed2Intercept = binding.etLed2Intercept
|
val etLed2Intercept = binding.etLed2Intercept
|
||||||
etLed2Intercept.addTextChangedListener(object : TextWatcher {
|
etLed2Intercept.addTextChangedListener(object : TextWatcher {
|
||||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun afterTextChanged(s: Editable?) {
|
override fun afterTextChanged(s: Editable?) {
|
||||||
@@ -133,11 +125,9 @@ class CalibrationFragment : Fragment() {
|
|||||||
val etLed3Slope = binding.etLed3Slope
|
val etLed3Slope = binding.etLed3Slope
|
||||||
etLed3Slope.addTextChangedListener(object : TextWatcher {
|
etLed3Slope.addTextChangedListener(object : TextWatcher {
|
||||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun afterTextChanged(s: Editable?) {
|
override fun afterTextChanged(s: Editable?) {
|
||||||
@@ -147,11 +137,9 @@ class CalibrationFragment : Fragment() {
|
|||||||
val etLed3Intercept = binding.etLed3Intercept
|
val etLed3Intercept = binding.etLed3Intercept
|
||||||
etLed3Intercept.addTextChangedListener(object : TextWatcher {
|
etLed3Intercept.addTextChangedListener(object : TextWatcher {
|
||||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun afterTextChanged(s: Editable?) {
|
override fun afterTextChanged(s: Editable?) {
|
||||||
@@ -162,11 +150,9 @@ class CalibrationFragment : Fragment() {
|
|||||||
val etLed4Slope = binding.etLed4Slope
|
val etLed4Slope = binding.etLed4Slope
|
||||||
etLed4Slope.addTextChangedListener(object : TextWatcher {
|
etLed4Slope.addTextChangedListener(object : TextWatcher {
|
||||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun afterTextChanged(s: Editable?) {
|
override fun afterTextChanged(s: Editable?) {
|
||||||
@@ -176,11 +162,9 @@ class CalibrationFragment : Fragment() {
|
|||||||
val etLed4Intercept = binding.etLed4Intercept
|
val etLed4Intercept = binding.etLed4Intercept
|
||||||
etLed4Intercept.addTextChangedListener(object : TextWatcher {
|
etLed4Intercept.addTextChangedListener(object : TextWatcher {
|
||||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun afterTextChanged(s: Editable?) {
|
override fun afterTextChanged(s: Editable?) {
|
||||||
|
|||||||
@@ -13,12 +13,27 @@
|
|||||||
|
|
||||||
package com.example.hpostesting.presentation.dashboard
|
package com.example.hpostesting.presentation.dashboard
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import android.os.BatteryManager
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.activityViewModels
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
|
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
||||||
|
import com.example.hpostesting.presentation.adapter.UserListAdapter
|
||||||
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
|
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
||||||
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentAboutBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentAboutBinding
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.FragmentActivitiesBinding
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.FragmentHomeBinding
|
||||||
|
|
||||||
class AboutFragment : Fragment() {
|
class AboutFragment : Fragment() {
|
||||||
private lateinit var binding: FragmentAboutBinding
|
private lateinit var binding: FragmentAboutBinding
|
||||||
|
|||||||
@@ -14,17 +14,25 @@
|
|||||||
package com.example.hpostesting.presentation.dashboard
|
package com.example.hpostesting.presentation.dashboard
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
import android.os.BatteryManager
|
import android.os.BatteryManager
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
||||||
|
import com.example.hpostesting.presentation.adapter.UserListAdapter
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
|
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
||||||
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentActivitiesBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentActivitiesBinding
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.FragmentHomeBinding
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
@@ -50,7 +58,7 @@ class ActivitiesFragment : Fragment() {
|
|||||||
|
|
||||||
if (userData.isNotEmpty()) {
|
if (userData.isNotEmpty()) {
|
||||||
userData.forEach { user ->
|
userData.forEach { user ->
|
||||||
if((isBetween15And30Minutes(user.incubationTime) > 30 || isBetween15And30Minutes(user.incubationTime) < 0 ) && user.testStatus == false){
|
if((isBetween15And30Minutes(user.incubationTime) > 30 || isBetween15And30Minutes(user.incubationTime) < 0) && user.testStatus == false){
|
||||||
hemoCubeViewModel.deleteByStatus()
|
hemoCubeViewModel.deleteByStatus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
package com.example.hpostesting.presentation.dashboard
|
|
||||||
|
|
||||||
class AppVersionTapManager {
|
|
||||||
|
|
||||||
private var tapCount = 0
|
|
||||||
private val maxTapCount = 5
|
|
||||||
|
|
||||||
fun registerTap(onMaxTapsReached: () -> Unit) {
|
|
||||||
tapCount++
|
|
||||||
if (tapCount >= maxTapCount) {
|
|
||||||
onMaxTapsReached()
|
|
||||||
reset()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private fun reset() {
|
|
||||||
tapCount = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -23,6 +23,7 @@ import android.os.Build
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.FileProvider
|
import androidx.core.content.FileProvider
|
||||||
@@ -32,15 +33,19 @@ import androidx.navigation.ui.AppBarConfiguration
|
|||||||
import androidx.navigation.ui.navigateUp
|
import androidx.navigation.ui.navigateUp
|
||||||
import androidx.navigation.ui.setupActionBarWithNavController
|
import androidx.navigation.ui.setupActionBarWithNavController
|
||||||
import androidx.navigation.ui.setupWithNavController
|
import androidx.navigation.ui.setupWithNavController
|
||||||
|
import com.example.hpostesting.util.Result
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
|
import com.example.hpostesting.data.model.login.LoginRequest
|
||||||
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
||||||
import com.example.hpostesting.data.repository.DatabaseRepository
|
import com.example.hpostesting.presentation.utils.NatsManager
|
||||||
import com.example.hpostesting.firebase.FirebaseManager
|
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
import com.example.hpostesting.presentation.jig.JigActivity
|
import com.example.hpostesting.presentation.jig.JigActivity
|
||||||
import com.example.hpostesting.presentation.utils.NatsManager
|
|
||||||
import com.google.android.material.navigation.NavigationView
|
import com.google.android.material.navigation.NavigationView
|
||||||
|
import com.google.firebase.appdistribution.FirebaseAppDistribution
|
||||||
|
import com.google.firebase.appdistribution.FirebaseAppDistributionException
|
||||||
|
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
|
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
|
||||||
import com.google.firebase.remoteconfig.ktx.remoteConfig
|
import com.google.firebase.remoteconfig.ktx.remoteConfig
|
||||||
@@ -51,9 +56,8 @@ import `in`.sminnovations.hpostesting.R
|
|||||||
import `in`.sminnovations.hpostesting.databinding.ActivityDashboardBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityDashboardBinding
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
fun interface NatsMessageCallback {
|
interface NatsMessageCallback {
|
||||||
fun onMessageReceived(topic: String, message: String)
|
fun onMessageReceived(topic: String, message: String)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,8 +68,6 @@ open interface IDataCollector: NatsMessageCallback {
|
|||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class DashboardActivity : AppCompatActivity(), IDataCollector {
|
class DashboardActivity : AppCompatActivity(), IDataCollector {
|
||||||
@Inject
|
|
||||||
lateinit var databaseRepository: DatabaseRepository
|
|
||||||
private val remoteConfig: FirebaseRemoteConfig = Firebase.remoteConfig
|
private val remoteConfig: FirebaseRemoteConfig = Firebase.remoteConfig
|
||||||
val TAG = "DashboardActivity"
|
val TAG = "DashboardActivity"
|
||||||
private var isRegistered = false
|
private var isRegistered = false
|
||||||
@@ -74,8 +76,8 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
lateinit var sharedPreferences: SharedPreferences
|
lateinit var sharedPreferences: SharedPreferences
|
||||||
var responses: String = ""
|
var responses: String = ""
|
||||||
lateinit var nats: NatsManager
|
lateinit var nats: NatsManager
|
||||||
|
|
||||||
private var downloadId: Long = 0
|
private var downloadId: Long = 0
|
||||||
|
// TODO: Remove hemocube viewmodel
|
||||||
private val hemocubeViewModel: HemoCubeViewModel by viewModels()
|
private val hemocubeViewModel: HemoCubeViewModel by viewModels()
|
||||||
|
|
||||||
override fun attachBaseContext(newBase: Context?) {
|
override fun attachBaseContext(newBase: Context?) {
|
||||||
@@ -84,7 +86,6 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
super.attachBaseContext(newBase)
|
super.attachBaseContext(newBase)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onMessageReceived(topic: String, message: String) {
|
override fun onMessageReceived(topic: String, message: String) {
|
||||||
// Handle incoming messages from NATS
|
// Handle incoming messages from NATS
|
||||||
|
|
||||||
@@ -94,15 +95,11 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
@SuppressLint("SetWorldReadable")
|
@SuppressLint("SetWorldReadable")
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
val firebaseManager = FirebaseManager(this)
|
|
||||||
binding = ActivityDashboardBinding.inflate(layoutInflater)
|
binding = ActivityDashboardBinding.inflate(layoutInflater)
|
||||||
sharedPreferences = this.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
sharedPreferences = this.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
setSupportActionBar(binding.appBarDashboard.toolbar)
|
setSupportActionBar(binding.appBarDashboard.toolbar)
|
||||||
nats = NatsManager(this)
|
nats = NatsManager(this)
|
||||||
|
|
||||||
val currentServer = firebaseManager.getLastSelectedServer().serverName
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
nats.connect()
|
nats.connect()
|
||||||
}
|
}
|
||||||
@@ -111,7 +108,7 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
Log.d("DashboardActivity", "Saved Kit Serial: $savedKitSerial")
|
Log.d("DashboardActivity", "Saved Kit Serial: $savedKitSerial")
|
||||||
// Toast.makeText(this, "Saved Kit Serial: $savedKitSerial", Toast.LENGTH_SHORT).show()
|
// Toast.makeText(this, "Saved Kit Serial: $savedKitSerial", Toast.LENGTH_SHORT).show()
|
||||||
|
|
||||||
val versionName = getAppVersion(this@DashboardActivity) + " [ " + getAppEnvironment(this@DashboardActivity) +"->"+currentServer+"]"
|
val versionName = getAppVersion(this@DashboardActivity) + " [ " + getAppEnvironment(this@DashboardActivity) + " ]"
|
||||||
binding.appBarDashboard.versionName.text = versionName
|
binding.appBarDashboard.versionName.text = versionName
|
||||||
|
|
||||||
|
|
||||||
@@ -209,10 +206,7 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
|
|
||||||
var apk = it
|
var apk = it
|
||||||
val file = File(getExternalFilesDir("Downloads"), "update.apk")
|
val file = File(getExternalFilesDir("Downloads"), "update.apk")
|
||||||
val isReadable = file.setReadable(true, false)
|
file.setReadable(true, false)
|
||||||
if (!isReadable) {
|
|
||||||
Log.w(TAG, "Failed to set file readable")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write APK to file
|
// Write APK to file
|
||||||
apk.byteStream().use { input ->
|
apk.byteStream().use { input ->
|
||||||
@@ -256,12 +250,6 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// fun sendData(data:String){ this was used to send the basic data for server validation
|
|
||||||
// databaseRepository.addtodb(data)
|
|
||||||
// Toast.makeText(this, "data uploaded", Toast.LENGTH_SHORT).show()
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
// Inflate the menu; this adds items to the action bar if it is present.
|
// Inflate the menu; this adds items to the action bar if it is present.
|
||||||
menuInflater.inflate(R.menu.dashboard, menu)
|
menuInflater.inflate(R.menu.dashboard, menu)
|
||||||
@@ -292,7 +280,7 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
return actualChecksum.equals(expectedChecksum, ignoreCase = true)
|
return actualChecksum.equals(expectedChecksum, ignoreCase = true)
|
||||||
}
|
}
|
||||||
private fun installApk(file: File) {
|
private fun installApk(file: File) {
|
||||||
baseContext.packageManager.getPackageInfo(baseContext.packageName, 0)
|
val pInfo = baseContext.packageManager.getPackageInfo(baseContext.packageName, 0)
|
||||||
val uri: Uri = FileProvider.getUriForFile(
|
val uri: Uri = FileProvider.getUriForFile(
|
||||||
this,
|
this,
|
||||||
"${BuildConfig.APPLICATION_ID}.fileprovider",
|
"${BuildConfig.APPLICATION_ID}.fileprovider",
|
||||||
@@ -378,16 +366,15 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// private fun createDeviceUpdateRequestData(): DeviceUpdateRequest {
|
private fun createDeviceUpdateRequestData(): DeviceUpdateRequest {
|
||||||
// return DeviceUpdateRequest(
|
return DeviceUpdateRequest(
|
||||||
// serial_no = sharedPreferences.getString(Constants.DEVICE_ID, "")
|
serial_no = sharedPreferences.getString(Constants.DEVICE_ID, "")
|
||||||
// )
|
)
|
||||||
// }
|
}
|
||||||
private fun getAppVersion(context: Context): String {
|
private fun getAppVersion(context: Context): String {
|
||||||
return try {
|
return try {
|
||||||
val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
|
val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
|
||||||
pInfo.versionName
|
pInfo.versionName
|
||||||
|
|
||||||
} catch (e: PackageManager.NameNotFoundException) {
|
} catch (e: PackageManager.NameNotFoundException) {
|
||||||
"N/A"
|
"N/A"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,7 +116,6 @@ class GalleryFragment : Fragment() {
|
|||||||
binding.btnUsbTerminal.setOnClickListener {
|
binding.btnUsbTerminal.setOnClickListener {
|
||||||
startActivity(Intent(requireContext(), UsbTerminalActivity::class.java))
|
startActivity(Intent(requireContext(), UsbTerminalActivity::class.java))
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnSubmit.setOnClickListener {
|
binding.btnSubmit.setOnClickListener {
|
||||||
startActivity(Intent(requireContext(), HemocubeBufferCheckActivity::class.java))
|
startActivity(Intent(requireContext(), HemocubeBufferCheckActivity::class.java))
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
package com.example.hpostesting.presentation.dashboard
|
package com.example.hpostesting.presentation.dashboard
|
||||||
|
|
||||||
import android.app.AlertDialog
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
@@ -24,7 +23,7 @@ import android.view.ViewGroup
|
|||||||
import android.widget.AdapterView
|
import android.widget.AdapterView
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.preference.ListPreference
|
import androidx.preference.ListPreference
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
@@ -32,231 +31,127 @@ import androidx.preference.PreferenceFragmentCompat
|
|||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.data.repository.DatabaseRepository
|
import com.example.hpostesting.data.model.TestState
|
||||||
import com.example.hpostesting.firebase.FirebaseConfig
|
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
||||||
import com.example.hpostesting.firebase.FirebaseManager
|
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.FragmentHemoCubeReferenceBinding
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentSlideshowBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentSlideshowBinding
|
||||||
|
|
||||||
private var isLanguageChanged = false
|
private var isLanguageChanged = false
|
||||||
|
|
||||||
class SlideshowFragment : Fragment() {
|
class SlideshowFragment : Fragment(){
|
||||||
private var selectedItem = "10mm"
|
private var selectedItem = "10mm"
|
||||||
private val values = arrayOf("10mm", "2mm")
|
private val values = arrayOf("10mm", "2mm")
|
||||||
private lateinit var binding: FragmentSlideshowBinding
|
private lateinit var binding: FragmentSlideshowBinding
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
||||||
): View {
|
): View {
|
||||||
binding = FragmentSlideshowBinding.inflate(inflater, container, false)
|
binding = FragmentSlideshowBinding.inflate(inflater, container, false)
|
||||||
sharedPreferences = requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
sharedPreferences =
|
||||||
|
requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
binding.nameEditText.setText(sharedPreferences.getString(Constants.LABNAME, ""))
|
binding.nameEditText.setText(sharedPreferences.getString(Constants.LABNAME,""))
|
||||||
|
|
||||||
selectedItem = sharedPreferences.getString(Constants.CUVETTE_SIZE, "10mm").toString()
|
selectedItem = sharedPreferences.getString(Constants.CUVETTE_SIZE,"10mm").toString()
|
||||||
val time = sharedPreferences.getString(Constants.LAST_UPDATED, "NA").toString()
|
val time = sharedPreferences.getString(Constants.LAST_UPDATED,"NA").toString()
|
||||||
binding.lastUpdated.text = "Last updated config: $time"
|
binding.lastUpdated.text = "Last updated config: $time"
|
||||||
binding.btnGo.setOnClickListener {
|
binding.btnGo.setOnClickListener {
|
||||||
var labname = binding.nameEditText.text.toString()
|
var labname = binding.nameEditText.text.toString()
|
||||||
DataHolder.hemoCubeTestData?.apply {
|
DataHolder.hemoCubeTestData?.apply {
|
||||||
this.labName = labname
|
this.labName = labname
|
||||||
}
|
}
|
||||||
|
|
||||||
with(sharedPreferences.edit()) {
|
with(sharedPreferences.edit()) {
|
||||||
putString(Constants.LABNAME, labname)
|
putString(Constants.LABNAME, labname)
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
requireContext(), "Lab Name is Added successfully.", Toast.LENGTH_SHORT
|
requireContext(),
|
||||||
|
"Lab Name is Added successfully.",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
val adapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, values)
|
val adapter = ArrayAdapter(requireContext(), android.R.layout.simple_spinner_item, values)
|
||||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||||
val pos: Int
|
val pos: Int
|
||||||
if (selectedItem == "10mm") {
|
if(selectedItem == "10mm"){
|
||||||
pos = 0
|
pos = 0
|
||||||
} else {
|
}else{
|
||||||
pos = 1
|
pos = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.spinnerCuvette.adapter = adapter
|
binding.spinnerCuvette.adapter = adapter
|
||||||
binding.spinnerCuvette.onItemSelectedListener =
|
binding.spinnerCuvette.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
object : AdapterView.OnItemSelectedListener {
|
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||||
override fun onItemSelected(
|
// Handle item selection here
|
||||||
parent: AdapterView<*>?, view: View?, position: Int, id: Long
|
selectedItem = values[position]
|
||||||
) {
|
|
||||||
// Handle item selection here
|
|
||||||
selectedItem = values[position]
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
|
||||||
// Do nothing here
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||||
|
// Do nothing here
|
||||||
|
}
|
||||||
|
}
|
||||||
binding.spinnerCuvette.setSelection(pos)
|
binding.spinnerCuvette.setSelection(pos)
|
||||||
binding.btnAddSize.setOnClickListener {
|
binding.btnAddSize.setOnClickListener {
|
||||||
with(sharedPreferences.edit()) {
|
with(sharedPreferences.edit()) {
|
||||||
putString(Constants.CUVETTE_SIZE, selectedItem)
|
putString(Constants.CUVETTE_SIZE, selectedItem)
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
Toast.makeText(
|
Toast.makeText(requireContext(), "Selected cuvette size: $selectedItem", Toast.LENGTH_SHORT).show()
|
||||||
requireContext(), "Selected cuvette size: $selectedItem", Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
childFragmentManager.beginTransaction().replace(binding.container.id, PrefsFragment())
|
childFragmentManager.beginTransaction().replace(binding.container.id,PrefsFragment()).commit()
|
||||||
.commit()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
class PrefsFragment: PreferenceFragmentCompat(){
|
||||||
class PrefsFragment : PreferenceFragmentCompat(){
|
|
||||||
private lateinit var tapManager: AppVersionTapManager
|
|
||||||
private var isServerSelectionVisible = false
|
|
||||||
private lateinit var serverPreference: Preference
|
|
||||||
private lateinit var currentServerPreference: Preference
|
|
||||||
lateinit var firebaseManager: FirebaseManager
|
|
||||||
lateinit var databaseRepository: DatabaseRepository
|
|
||||||
|
|
||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
firebaseManager = FirebaseManager(requireContext())
|
|
||||||
databaseRepository = (activity as DashboardActivity).databaseRepository
|
|
||||||
|
|
||||||
tapManager = AppVersionTapManager()
|
|
||||||
val sharedPreference =
|
|
||||||
requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
|
||||||
val preferenceScreen = preferenceManager.createPreferenceScreen(requireContext())
|
val preferenceScreen = preferenceManager.createPreferenceScreen(requireContext())
|
||||||
val currentServer = firebaseManager.getLastSelectedServer().serverName
|
|
||||||
|
|
||||||
// Language Preference
|
val languagePreference = ListPreference(requireContext())
|
||||||
val languagePreference = ListPreference(requireContext()).apply {
|
languagePreference.key = "language_preference"
|
||||||
key = "language_preference"
|
languagePreference.title = getString(R.string.app_language)
|
||||||
title = getString(R.string.app_language)
|
languagePreference.summary = getString(R.string.select_language)
|
||||||
summary = getString(R.string.select_language)
|
languagePreference.entries = arrayOf("English", "Kannada", "Hindi")
|
||||||
entries = arrayOf("English", "Kannada", "Hindi")
|
languagePreference.entryValues = arrayOf("en", "kn", "hi")
|
||||||
entryValues = arrayOf("en", "kn", "hi")
|
languagePreference.setDefaultValue("en")
|
||||||
setDefaultValue("en")
|
|
||||||
icon = ContextCompat.getDrawable(requireContext(), R.drawable.baseline_translate_24)
|
|
||||||
|
|
||||||
onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
languagePreference.onPreferenceChangeListener =
|
||||||
|
Preference.OnPreferenceChangeListener { _, newValue ->
|
||||||
val languageCode = newValue as String
|
val languageCode = newValue as String
|
||||||
updateLanguage(requireContext(), languageCode)
|
updateLanguage(requireContext(), languageCode)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
|
||||||
preferenceScreen.addPreference(languagePreference)
|
preferenceScreen.addPreference(languagePreference)
|
||||||
|
|
||||||
val appVersionPreference = Preference(requireContext()).apply {
|
|
||||||
title = "App Version"
|
|
||||||
summary =
|
|
||||||
getAppVersion(requireContext()) + " [ " + getAppEnvironment(requireContext()) +"->"+currentServer+"]"
|
|
||||||
icon = ContextCompat.getDrawable(requireContext(), R.drawable.baseline_info_24)
|
|
||||||
|
|
||||||
setOnPreferenceClickListener {
|
|
||||||
if ((sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN")) {
|
|
||||||
tapManager.registerTap {
|
|
||||||
if (!isServerSelectionVisible) {
|
|
||||||
showServerSelection()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
preferenceScreen.addPreference(appVersionPreference)
|
|
||||||
|
|
||||||
|
|
||||||
currentServerPreference = Preference(requireContext()).apply {
|
|
||||||
key = "current_server_preference"
|
|
||||||
title = "Current Server"
|
|
||||||
summary = "No server selected"
|
|
||||||
isVisible = false
|
|
||||||
icon = ContextCompat.getDrawable(requireContext(), R.drawable.baseline_cloud_done_24)
|
|
||||||
|
|
||||||
setOnPreferenceClickListener {
|
|
||||||
// (activity as? DashboardActivity)?.sendData("hello test data")
|
|
||||||
// Toast.makeText(context, "data sent", Toast.LENGTH_SHORT).show() this was used to send the basic data as test data
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
preferenceScreen.addPreference(currentServerPreference)
|
|
||||||
setPreferenceScreen(preferenceScreen)
|
setPreferenceScreen(preferenceScreen)
|
||||||
|
|
||||||
|
// App Version Preference
|
||||||
|
val appVersionPreference = Preference(requireContext())
|
||||||
|
appVersionPreference.title = "App Version SMI"
|
||||||
|
appVersionPreference.summary =
|
||||||
|
getAppVersion(requireContext()) + " [ " + getAppEnvironment(requireContext()) + " ]"
|
||||||
|
|
||||||
|
preferenceScreen.addPreference(languagePreference)
|
||||||
|
preferenceScreen.addPreference(appVersionPreference)
|
||||||
|
setPreferenceScreen(preferenceScreen)
|
||||||
if (isLanguageChanged) {
|
if (isLanguageChanged) {
|
||||||
Toast.makeText(requireContext(), R.string.language_update, Toast.LENGTH_SHORT).show()
|
Toast.makeText(requireContext(), R.string.language_update, Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private fun showServerSelection() {
|
|
||||||
val currentServer = firebaseManager.getLastSelectedServer().serverName
|
|
||||||
serverPreference = Preference(requireContext()).apply {
|
|
||||||
title = "Select Server"
|
|
||||||
summary = "Choose your server"
|
|
||||||
icon = ContextCompat.getDrawable(requireContext(), R.drawable.baseline_cloud_sync_24)
|
|
||||||
setOnPreferenceClickListener {
|
|
||||||
showServerSelectionDialog()
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
preferenceScreen.addPreference(serverPreference)
|
|
||||||
currentServerPreference.isVisible = true
|
|
||||||
currentServerPreference.summary = "Current Server: $currentServer"
|
|
||||||
|
|
||||||
Toast.makeText(requireContext(), "Server selection now available", Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun showServerSelectionDialog() {
|
|
||||||
val servers = firebaseManager.getAvailableServers()
|
|
||||||
|
|
||||||
val serverNames = servers.map { it.serverName }.toTypedArray()
|
|
||||||
val builder = AlertDialog.Builder(requireContext())
|
|
||||||
builder.setTitle("Select Server")
|
|
||||||
.setItems(serverNames) { _, which ->
|
|
||||||
val selectedServer = servers[which]
|
|
||||||
|
|
||||||
switchFirebaseServer(selectedServer)
|
|
||||||
}
|
|
||||||
.setNegativeButton("Cancel", null)
|
|
||||||
.show()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private fun switchFirebaseServer(firebaseConfig: FirebaseConfig) {
|
|
||||||
firebaseManager.switchServer(firebaseConfig)
|
|
||||||
Toast.makeText(requireContext(), "Switched to ${firebaseConfig.serverName}, Please wait for few seconds", Toast.LENGTH_SHORT).show()
|
|
||||||
Toast.makeText(requireContext(), "Restart needed restarting the app", Toast.LENGTH_SHORT).show()
|
|
||||||
firebaseManager.restartApp()
|
|
||||||
currentServerPreference.summary = "Current Server: ${firebaseConfig.serverName}"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// private fun switchCurrentServer(serverCode: String) {
|
|
||||||
// Toast.makeText(requireContext(), "Switched to server: $serverCode", Toast.LENGTH_SHORT)
|
|
||||||
// .show()
|
|
||||||
// currentServerPreference.summary = "Current Server: $serverCode"
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
private fun updateLanguage(context: Context, languageCode: String) {
|
private fun updateLanguage(context: Context, languageCode: String) {
|
||||||
LanguageManager.persistLanguagePreference(context, languageCode)
|
LanguageManager.persistLanguagePreference(context, languageCode)
|
||||||
LanguageManager.setLocale(context, languageCode)
|
LanguageManager.setLocale(context, languageCode)
|
||||||
requireActivity().recreate()
|
requireActivity().recreate() // Recreate activity to apply language changes
|
||||||
isLanguageChanged = true
|
isLanguageChanged = true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getAppVersion(context: Context): String {
|
private fun getAppVersion(context: Context): String {
|
||||||
return try {
|
return try {
|
||||||
val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
|
val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
|
||||||
@@ -275,5 +170,3 @@ class PrefsFragment : PreferenceFragmentCompat(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,17 @@
|
|||||||
|
|
||||||
package com.example.hpostesting.presentation.dashboard.ui
|
package com.example.hpostesting.presentation.dashboard.ui
|
||||||
|
|
||||||
|
import com.example.hpostesting.util.SecureStorage
|
||||||
import android.accounts.Account
|
import android.accounts.Account
|
||||||
import android.accounts.AccountManager
|
import android.accounts.AccountManager
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
|
import android.location.Location
|
||||||
|
import android.location.LocationListener
|
||||||
|
import android.location.LocationManager
|
||||||
|
import android.net.ConnectivityManager
|
||||||
|
import android.net.NetworkCapabilities
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
@@ -31,9 +38,14 @@ import androidx.navigation.fragment.findNavController
|
|||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.util.AppInitializer
|
import com.example.hpostesting.util.AppInitializer
|
||||||
import com.example.hpostesting.util.SecureStorage
|
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentLoginBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentLoginBinding
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.GlobalScope
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import java.net.HttpURLConnection
|
||||||
|
import java.net.URL
|
||||||
|
import java.util.Scanner
|
||||||
|
|
||||||
|
|
||||||
class LoginFragment : Fragment() {
|
class LoginFragment : Fragment() {
|
||||||
@@ -198,108 +210,106 @@ class LoginFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Check if we can get our location */
|
/** Check if we can get our location */
|
||||||
// @SuppressLint("MissingPermission")
|
@SuppressLint("MissingPermission")
|
||||||
// fun checkLocation() {
|
fun checkLocation() {
|
||||||
// // Get the location manager
|
// Get the location manager
|
||||||
// val locationManager = requireActivity().getSystemService(Context.LOCATION_SERVICE) as LocationManager
|
val locationManager = requireActivity().getSystemService(Context.LOCATION_SERVICE) as LocationManager
|
||||||
// val locationProviderWifi = LocationManager.NETWORK_PROVIDER
|
val locationProviderWifi = LocationManager.NETWORK_PROVIDER
|
||||||
// val locationProviderGPS = LocationManager.GPS_PROVIDER
|
val locationProviderGPS = LocationManager.GPS_PROVIDER
|
||||||
// val locationListenerNetwork: LocationListener
|
val locationListenerNetwork: LocationListener
|
||||||
// val locationListenerGPS: LocationListener
|
val locationListenerGPS: LocationListener
|
||||||
// var gps_enabled = false
|
var gps_enabled = false
|
||||||
// var network_enabled = false
|
var network_enabled = false
|
||||||
//
|
|
||||||
// //check wifi
|
//check wifi
|
||||||
// val connectivityManager = requireActivity().getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
val connectivityManager = requireActivity().getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||||
// val mWifi = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
|
val mWifi = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI)
|
||||||
// if (mWifi!!.isConnected) {
|
if (mWifi!!.isConnected) {
|
||||||
// Log.d(TAG, "Wifi connected")
|
Log.d(TAG, "Wifi connected")
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// //check gps and wifi availability
|
//check gps and wifi availability
|
||||||
// try {
|
try {
|
||||||
// gps_enabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)
|
gps_enabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)
|
||||||
// } catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
// //nothing
|
}
|
||||||
// }
|
try {
|
||||||
// try {
|
network_enabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)
|
||||||
// network_enabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)
|
} catch (ex: Exception) {
|
||||||
// } catch (ex: Exception) {
|
}
|
||||||
// //nothing
|
if (!gps_enabled) {
|
||||||
// }
|
Log.d(TAG, "GPS: Missing")
|
||||||
// if (!gps_enabled) {
|
}else{
|
||||||
// Log.d(TAG, "GPS: Missing")
|
// getPublicIpAddr { ipAddress ->
|
||||||
// }else{
|
// // Do something with the ipAddress
|
||||||
//// getPublicIpAddr { ipAddress ->
|
// Log.d(TAG, "GPS: PRESENT"+ipAddress)
|
||||||
//// // Do something with the ipAddress
|
|
||||||
//// Log.d(TAG, "GPS: PRESENT"+ipAddress)
|
|
||||||
//// }
|
|
||||||
// }
|
|
||||||
// if (!network_enabled) {
|
|
||||||
// Log.d(TAG, "Network: Missing")
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /* Location change listeners */try {
|
|
||||||
// Log.d(TAG, "GPS: PRESENT TRy")
|
|
||||||
// // Define a listener that responds to gps location updates
|
|
||||||
// locationListenerGPS = object : LocationListener {
|
|
||||||
// override fun onLocationChanged(location: Location) {
|
|
||||||
// Log.d(TAG, "GPS: PRESENT loc")
|
|
||||||
// Log.d(
|
|
||||||
// TAG,
|
|
||||||
// "GPS: Latitude: " + location.latitude + ", Longitude = " + location.longitude
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onStatusChanged(provider: String, status: Int, extras: Bundle) {
|
|
||||||
// Log.d(TAG, "GP location found 1")
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onProviderEnabled(provider: String) {
|
|
||||||
// Log.d(TAG, "GP location found 2")
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// override fun onProviderDisabled(provider: String) {
|
|
||||||
// Log.d(TAG, "GP location found 3")
|
|
||||||
// }
|
|
||||||
// }
|
// }
|
||||||
// locationManager.requestLocationUpdates(locationProviderGPS, 0, 0f, locationListenerGPS)
|
}
|
||||||
// Log.d(TAG, "GPS: PRESENT Req")
|
if (!network_enabled) {
|
||||||
// } catch (e: Exception) {
|
Log.d(TAG, "Network: Missing")
|
||||||
// Log.e(TAG, "Location Exception: " + e.message)
|
}
|
||||||
// }
|
|
||||||
// try {
|
/* Location change listeners */try {
|
||||||
// // Define a listener that responds to wifi location updates
|
Log.d(TAG, "GPS: PRESENT TRy")
|
||||||
// locationListenerNetwork = object : LocationListener {
|
// Define a listener that responds to gps location updates
|
||||||
// override fun onLocationChanged(location: Location) {
|
locationListenerGPS = object : LocationListener {
|
||||||
// Log.d(
|
override fun onLocationChanged(location: Location) {
|
||||||
// TAG,
|
Log.d(TAG, "GPS: PRESENT loc")
|
||||||
// "NW: Latitude: " + location.latitude + ", Longitude = " + location.longitude
|
Log.d(
|
||||||
// )
|
TAG,
|
||||||
// }
|
"GPS: Latitude: " + location.latitude + ", Longitude = " + location.longitude
|
||||||
//
|
)
|
||||||
// override fun onStatusChanged(provider: String, status: Int, extras: Bundle) {
|
}
|
||||||
// Log.d(TAG, "location found 1")
|
|
||||||
// }
|
override fun onStatusChanged(provider: String, status: Int, extras: Bundle) {
|
||||||
//
|
Log.d(TAG, "GP location found 1")
|
||||||
// override fun onProviderEnabled(provider: String) {
|
}
|
||||||
// Log.d(TAG, "location found 2")
|
|
||||||
// }
|
override fun onProviderEnabled(provider: String) {
|
||||||
//
|
Log.d(TAG, "GP location found 2")
|
||||||
// override fun onProviderDisabled(provider: String) {
|
}
|
||||||
// Log.d(TAG, "location found 3")
|
|
||||||
// }
|
override fun onProviderDisabled(provider: String) {
|
||||||
// }
|
Log.d(TAG, "GP location found 3")
|
||||||
// locationManager.requestLocationUpdates(
|
}
|
||||||
// locationProviderWifi,
|
}
|
||||||
// 0,
|
locationManager.requestLocationUpdates(locationProviderGPS, 0, 0f, locationListenerGPS)
|
||||||
// 0f,
|
Log.d(TAG, "GPS: PRESENT Req")
|
||||||
// locationListenerNetwork
|
} catch (e: Exception) {
|
||||||
// )
|
Log.e(TAG, "Location Exception: " + e.message)
|
||||||
// } catch (e: Exception) {
|
}
|
||||||
// Log.e(TAG, "NW Location Exception: " + e.message)
|
try {
|
||||||
// }
|
// Define a listener that responds to wifi location updates
|
||||||
// }
|
locationListenerNetwork = object : LocationListener {
|
||||||
|
override fun onLocationChanged(location: Location) {
|
||||||
|
Log.d(
|
||||||
|
TAG,
|
||||||
|
"NW: Latitude: " + location.latitude + ", Longitude = " + location.longitude
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onStatusChanged(provider: String, status: Int, extras: Bundle) {
|
||||||
|
Log.d(TAG, "location found 1")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onProviderEnabled(provider: String) {
|
||||||
|
Log.d(TAG, "location found 2")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onProviderDisabled(provider: String) {
|
||||||
|
Log.d(TAG, "location found 3")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
locationManager.requestLocationUpdates(
|
||||||
|
locationProviderWifi,
|
||||||
|
0,
|
||||||
|
0f,
|
||||||
|
locationListenerNetwork
|
||||||
|
)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e(TAG, "NW Location Exception: " + e.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
// fun getPublicIpAddr(callback: (String) -> Unit) {
|
// fun getPublicIpAddr(callback: (String) -> Unit) {
|
||||||
// GlobalScope.launch(Dispatchers.IO) {
|
// GlobalScope.launch(Dispatchers.IO) {
|
||||||
// val url = URL("https://api.ipify.org")
|
// val url = URL("https://api.ipify.org")
|
||||||
@@ -319,40 +329,40 @@ class LoginFragment : Fragment() {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//private fun getPublicIpAddr(callback: (String) -> Unit) {
|
private fun getPublicIpAddr(callback: (String) -> Unit) {
|
||||||
// try {
|
try {
|
||||||
// GlobalScope.launch(Dispatchers.IO) {
|
GlobalScope.launch(Dispatchers.IO) {
|
||||||
// val url = URL("https://api.ipify.org")
|
val url = URL("https://api.ipify.org")
|
||||||
// val conn = url.openConnection() as HttpURLConnection
|
val conn = url.openConnection() as HttpURLConnection
|
||||||
// try {
|
try {
|
||||||
// conn.connect()
|
conn.connect()
|
||||||
// if (conn.responseCode == HttpURLConnection.HTTP_OK) {
|
if (conn.responseCode == HttpURLConnection.HTTP_OK) {
|
||||||
// val scanner = Scanner(conn.inputStream)
|
val scanner = Scanner(conn.inputStream)
|
||||||
// scanner.useDelimiter("\\A")
|
scanner.useDelimiter("\\A")
|
||||||
// if (scanner.hasNext()) {
|
if (scanner.hasNext()) {
|
||||||
// val ipAddress = scanner.next()
|
val ipAddress = scanner.next()
|
||||||
// callback(ipAddress)
|
callback(ipAddress)
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// } finally {
|
} finally {
|
||||||
// conn.disconnect()
|
conn.disconnect()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }catch (e: Exception){
|
}catch (e: Exception){
|
||||||
// Log.e(TAG,e.toString())
|
Log.e(TAG,e.toString())
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
// @SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
// private fun isInternetAvailable(): Boolean {
|
private fun isInternetAvailable(): Boolean {
|
||||||
// val connectivityManager = requireActivity().getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
val connectivityManager = requireActivity().getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||||
// val network = connectivityManager.activeNetwork ?: return false
|
val network = connectivityManager.activeNetwork ?: return false
|
||||||
// val networkCapabilities = connectivityManager.getNetworkCapabilities(network) ?: return false
|
val networkCapabilities = connectivityManager.getNetworkCapabilities(network) ?: return false
|
||||||
// return networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
return networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// private fun checkUserName(userName: String): Boolean {
|
private fun checkUserName(userName: String): Boolean {
|
||||||
// return userName.isNotEmpty() && userName.length >= 3
|
return userName.isNotEmpty() && userName.length >= 3
|
||||||
//}
|
}
|
||||||
|
|
||||||
private fun checkCenterName(centerName: String): Boolean {
|
private fun checkCenterName(centerName: String): Boolean {
|
||||||
return centerName.isNotEmpty() && centerName.length >= 3
|
return centerName.isNotEmpty() && centerName.length >= 3
|
||||||
|
|||||||
@@ -29,13 +29,14 @@ import android.os.Bundle
|
|||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
|
import android.view.MenuItem
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.constant.Constants
|
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.utils.DeviceCommunicationHandler
|
import com.example.hpostesting.presentation.utils.DeviceCommunicationHandler
|
||||||
|
|||||||
@@ -89,7 +89,6 @@ class DeviceFragment : Fragment() {
|
|||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Environment
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
@@ -26,18 +27,20 @@ import android.widget.Toast
|
|||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import com.example.hpostesting.util.Result
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
import com.example.hpostesting.encryption.Encryption
|
import com.example.hpostesting.encryption.Encryption
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||||
import com.example.hpostesting.util.Result
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
|
import com.google.android.gms.ads.identifier.AdvertisingIdClient
|
||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentDeviceProvisionBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentDeviceProvisionBinding
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.io.FileOutputStream
|
||||||
|
|
||||||
class DeviceProvisionFragment : Fragment() {
|
class DeviceProvisionFragment : Fragment() {
|
||||||
private var resultData: String = ""
|
private var resultData: String = ""
|
||||||
@@ -172,9 +175,7 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
binding.btnSubmit.visibility = View.GONE
|
binding.btnSubmit.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {}
|
||||||
//Nothing
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
viewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
viewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
||||||
@@ -192,12 +193,8 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
(activity as DeviceProvisionActivity).mService.sendAndListenToHemoCube(
|
(activity as DeviceProvisionActivity).mService.sendAndListenToHemoCube(
|
||||||
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
//nothing
|
override fun onUsbError(e: Exception?) {}
|
||||||
}
|
|
||||||
override fun onUsbError(e: Exception?) {
|
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,9 +214,7 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Firebase.crashlytics.recordException(e)
|
Firebase.crashlytics.recordException(e)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class DeviceProvisionViewModel @Inject constructor(
|
|||||||
fun addDeviceProvisionDataToDb(data: DeviceData) {
|
fun addDeviceProvisionDataToDb(data: DeviceData) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
when (repository.getDeviceResponse(data)) {
|
when (val response = repository.getDeviceResponse(data)) {
|
||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
// Log.i("Testdb", "Data uploaded to Firestore successfully")
|
// Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||||
fireBaseUpload.postValue("Successfully device response uploaded to firebase")
|
fireBaseUpload.postValue("Successfully device response uploaded to firebase")
|
||||||
@@ -70,9 +70,7 @@ class DeviceProvisionViewModel @Inject constructor(
|
|||||||
fireBaseUpload.postValue("Error")
|
fireBaseUpload.postValue("Error")
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
// Log.e("Testdb", "Exception during data upload: ${e.message}")
|
// Log.e("Testdb", "Exception during data upload: ${e.message}")
|
||||||
|
|||||||
@@ -103,10 +103,10 @@ class DiagnosticsFragment : Fragment() {
|
|||||||
|
|
||||||
val additionalDetails = AdditionalDetails(
|
val additionalDetails = AdditionalDetails(
|
||||||
batteryLevel = batteryLevel,
|
batteryLevel = batteryLevel,
|
||||||
batteryCapacity = batteryCapacity,
|
batteryCapacity = batteryCapacity!!,
|
||||||
batteryMaxCapacity = batteryMaxCapacity,
|
batteryMaxCapacity = batteryMaxCapacity!!,
|
||||||
batteryTemperature = batteryTemperature,
|
batteryTemperature = batteryTemperature,
|
||||||
batteryVoltage = batteryVoltage
|
batteryVoltage = batteryVoltage!!
|
||||||
)
|
)
|
||||||
if(Constants.MOLBIO_INTEGRATION){
|
if(Constants.MOLBIO_INTEGRATION){
|
||||||
diagnosticsViewModel.deviceDiagnostics(
|
diagnosticsViewModel.deviceDiagnostics(
|
||||||
@@ -149,7 +149,7 @@ class DiagnosticsFragment : Fragment() {
|
|||||||
|
|
||||||
response.data.data?.let { diagnosticsData ->
|
response.data.data?.let { diagnosticsData ->
|
||||||
|
|
||||||
diagnosticsData.additionalDetails?.batteryLevel
|
val batteryLevel = diagnosticsData.additionalDetails?.batteryLevel
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -169,12 +169,9 @@ class DiagnosticsFragment : Fragment() {
|
|||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
is Result.Loading -> {
|
is Result.Loading -> {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {}
|
||||||
// nothing
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,7 +203,6 @@ class DiagnosticsFragment : Fragment() {
|
|||||||
HemoCubeCommands.DIAGNOSTICS_COMMAND,
|
HemoCubeCommands.DIAGNOSTICS_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
@@ -220,7 +216,6 @@ class DiagnosticsFragment : Fragment() {
|
|||||||
HemoCubeCommands.READ_DAC_COMMAND,
|
HemoCubeCommands.READ_DAC_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
@@ -234,7 +229,6 @@ class DiagnosticsFragment : Fragment() {
|
|||||||
HemoCubeCommands.LOAD_DAC_VALUES,
|
HemoCubeCommands.LOAD_DAC_VALUES,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
@@ -386,8 +380,10 @@ class DiagnosticsFragment : Fragment() {
|
|||||||
if (!ledDataMap.containsKey(ledName)) {
|
if (!ledDataMap.containsKey(ledName)) {
|
||||||
ledDataMap[ledName] = mutableListOf()
|
ledDataMap[ledName] = mutableListOf()
|
||||||
}
|
}
|
||||||
if ((ledDataMap[ledName]?.size ?: 0) < 7 && xValue != 0.0) {
|
if ((ledDataMap[ledName]?.size ?: 0) < 7) {
|
||||||
ledDataMap[ledName]?.add(xValue to yValue)
|
if(xValue != 0.0){
|
||||||
|
ledDataMap[ledName]?.add(xValue to yValue)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// ledDataMap[ledName]?.add(xValue to yValue)
|
// ledDataMap[ledName]?.add(xValue to yValue)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class DiagnosticsViewModel @Inject constructor(
|
|||||||
fun addDiagnosticsDataToDb(data: DiagnosticsData) {
|
fun addDiagnosticsDataToDb(data: DiagnosticsData) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
when (repository.addDiagnostics(data)) {
|
when (val response = repository.addDiagnostics(data)) {
|
||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
// Log.i("Testdb", "Data uploaded to Firestore successfully")
|
// Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
@@ -57,9 +57,7 @@ class DiagnosticsViewModel @Inject constructor(
|
|||||||
fireBaseUpload.postValue("Error")
|
fireBaseUpload.postValue("Error")
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
// Log.e("Testdb", "Exception during data upload: ${e.message}")
|
// Log.e("Testdb", "Exception during data upload: ${e.message}")
|
||||||
|
|||||||
@@ -33,24 +33,19 @@ import androidx.activity.viewModels
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.constant.Constants
|
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.data.repository.DatabaseRepository
|
|
||||||
import com.example.hpostesting.firebase.FirebaseManager
|
|
||||||
import com.example.hpostesting.util.UsbService
|
import com.example.hpostesting.util.UsbService
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.ActivityAutoDacBinding
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityHbTestBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityHbTestBinding
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class HBTestActivity : AppCompatActivity() {
|
class HBTestActivity : AppCompatActivity() {
|
||||||
|
|
||||||
@Inject
|
|
||||||
lateinit var databaseRepository: DatabaseRepository
|
|
||||||
private lateinit var binding: ActivityHbTestBinding
|
private lateinit var binding: ActivityHbTestBinding
|
||||||
val viewModel: HBTestViewModel by viewModels()
|
val viewModel: HBTestViewModel by viewModels()
|
||||||
private var myMenu: Menu? = null
|
private var myMenu: Menu? = null
|
||||||
@@ -102,10 +97,6 @@ class HBTestActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
val firebaseManager = FirebaseManager(this)
|
|
||||||
val lastSelectedServer = firebaseManager.getLastSelectedServer()
|
|
||||||
// switchFirebaseServer(lastSelectedServer)
|
|
||||||
Log.d("CURRENT SERVR......","server : ${lastSelectedServer.serverName}")
|
|
||||||
binding = ActivityHbTestBinding.inflate(layoutInflater)
|
binding = ActivityHbTestBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
// setSupportActionBar(binding.myToolbar)
|
// setSupportActionBar(binding.myToolbar)
|
||||||
@@ -114,11 +105,7 @@ class HBTestActivity : AppCompatActivity() {
|
|||||||
connectUsb(false)
|
connectUsb(false)
|
||||||
|
|
||||||
}
|
}
|
||||||
// private fun switchFirebaseServer(config: FirebaseConfig) {
|
|
||||||
// val (newFirestore, newStorage) = firebaseManager.switchFirestoreServer(config)
|
|
||||||
// databaseRepository.switchServer(newFirestore, newStorage)
|
|
||||||
//// Toast.makeText(this, "server switched", Toast.LENGTH_SHORT).show()// Update repository with new Firestore and Storage
|
|
||||||
// }
|
|
||||||
private fun setupListener() {
|
private fun setupListener() {
|
||||||
DataHolder.usbConnected.observe(this) {
|
DataHolder.usbConnected.observe(this) {
|
||||||
Log.d("USB OBSERVE", "HemoCube called -> $it")
|
Log.d("USB OBSERVE", "HemoCube called -> $it")
|
||||||
|
|||||||
@@ -27,12 +27,14 @@ import androidx.lifecycle.MutableLiveData
|
|||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
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.data.model.patient.DeviceData
|
||||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.FragmentAutoDacBinding
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentHbTestBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentHbTestBinding
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
@@ -115,6 +117,7 @@ class HBTestFragment : Fragment() {
|
|||||||
testDetails.testTime = SimpleDateFormat(
|
testDetails.testTime = SimpleDateFormat(
|
||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
).format(Calendar.getInstance().time)
|
).format(Calendar.getInstance().time)
|
||||||
|
//Toast.makeText(requireContext(), "deviceID"+deviceId, Toast.LENGTH_LONG).show()
|
||||||
hBTestViewModel.uploadFirebaseQc(testDetails)
|
hBTestViewModel.uploadFirebaseQc(testDetails)
|
||||||
}
|
}
|
||||||
binding.btnBuffer.setOnClickListener {
|
binding.btnBuffer.setOnClickListener {
|
||||||
@@ -174,7 +177,6 @@ class HBTestFragment : Fragment() {
|
|||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
data?.let {
|
data?.let {
|
||||||
val stringData = String(it)
|
val stringData = String(it)
|
||||||
//deviceId = stringData
|
|
||||||
hBTestViewModel.messages.postValue(stringData)
|
hBTestViewModel.messages.postValue(stringData)
|
||||||
binding.tvSubtitle4.text = stringData
|
binding.tvSubtitle4.text = stringData
|
||||||
}
|
}
|
||||||
@@ -191,7 +193,6 @@ class HBTestFragment : Fragment() {
|
|||||||
HemoCubeCommands.START_BUFFER_COMMAND,
|
HemoCubeCommands.START_BUFFER_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
@@ -205,7 +206,6 @@ class HBTestFragment : Fragment() {
|
|||||||
HemoCubeCommands.START_SAMPLE,
|
HemoCubeCommands.START_SAMPLE,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
@@ -219,7 +219,6 @@ class HBTestFragment : Fragment() {
|
|||||||
HemoCubeCommands.PRINT_COMMAND,
|
HemoCubeCommands.PRINT_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
@@ -233,7 +232,6 @@ class HBTestFragment : Fragment() {
|
|||||||
|
|
||||||
return matchResult?.groups?.get(1)?.value
|
return matchResult?.groups?.get(1)?.value
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun listenToHemoCube() {
|
private fun listenToHemoCube() {
|
||||||
|
|
||||||
val fullReadOutput = StringBuilder()
|
val fullReadOutput = StringBuilder()
|
||||||
@@ -252,7 +250,6 @@ class HBTestFragment : Fragment() {
|
|||||||
if (stringData.contains("SNE")) {
|
if (stringData.contains("SNE")) {
|
||||||
val slData = stringData.split(" ")
|
val slData = stringData.split(" ")
|
||||||
if (slData.size > 1) {
|
if (slData.size > 1) {
|
||||||
///val hardwareId = slData[1].trim()
|
|
||||||
deviceId = extractV2HardwareId(resultData).toString()
|
deviceId = extractV2HardwareId(resultData).toString()
|
||||||
hBTestViewModel.messages.postValue("Place buffer and click below button to start test")
|
hBTestViewModel.messages.postValue("Place buffer and click below button to start test")
|
||||||
// with(sharedPreferences.edit()) {
|
// with(sharedPreferences.edit()) {
|
||||||
|
|||||||
@@ -60,9 +60,7 @@ class HBTestViewModel @Inject constructor(
|
|||||||
hemoCubeDao.updateTest(testDetails)
|
hemoCubeDao.updateTest(testDetails)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
fireBaseUpload.postValue("Error")
|
fireBaseUpload.postValue("Error")
|
||||||
@@ -72,7 +70,7 @@ class HBTestViewModel @Inject constructor(
|
|||||||
fun addAutoDacDataToDb(data: DiagnosticsData) {
|
fun addAutoDacDataToDb(data: DiagnosticsData) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
when (repository.addDiagnostics(data)) {
|
when (val response = repository.addDiagnostics(data)) {
|
||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,11 +52,6 @@ import kotlin.random.Random
|
|||||||
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
class HemoCubeFragment : Fragment() {
|
class HemoCubeFragment : Fragment() {
|
||||||
private val sickleCellDisease = "Sickle Cell Disease"
|
|
||||||
private val regEx = "\\s+(?=LB|LS)"
|
|
||||||
private val sickleCellTrait = "Sickle Cell Trait"
|
|
||||||
private val positiveBoderLine = "Positive for Sickle Cell. HPLC for Confirmation"
|
|
||||||
private val negativeBorderLine = "Negative Borderline"
|
|
||||||
private var positiveBoderLine10mm1=Constants.positiveBoderLine10mm1
|
private var positiveBoderLine10mm1=Constants.positiveBoderLine10mm1
|
||||||
private var positiveBoderLine10mm2=Constants.positiveBoderLine10mm2
|
private var positiveBoderLine10mm2=Constants.positiveBoderLine10mm2
|
||||||
private var negativeBoderLine10mm1=Constants.negativeBoderLine10mm1
|
private var negativeBoderLine10mm1=Constants.negativeBoderLine10mm1
|
||||||
@@ -189,20 +184,6 @@ class HemoCubeFragment : Fragment() {
|
|||||||
binding.tvSubtitle4.movementMethod = ScrollingMovementMethod()
|
binding.tvSubtitle4.movementMethod = ScrollingMovementMethod()
|
||||||
binding.tvDeviceMessages.movementMethod = ScrollingMovementMethod()
|
binding.tvDeviceMessages.movementMethod = ScrollingMovementMethod()
|
||||||
binding.btnSubmit.setOnClickListener {
|
binding.btnSubmit.setOnClickListener {
|
||||||
// with(sharedPreferences.edit()) {
|
|
||||||
// putBoolean(Constants.QUICK_CAPTURE, false)
|
|
||||||
// apply()
|
|
||||||
// }
|
|
||||||
// if(DataHolder.hemoCubeTestData!!.classificationResult != "Invalid"){
|
|
||||||
// DataHolder.sampleReadCounter++
|
|
||||||
// }
|
|
||||||
// binding.btnSubmit.isEnabled = false
|
|
||||||
// binding.btnSubmit.isClickable = false
|
|
||||||
// activity?.runOnUiThread {
|
|
||||||
// Log.d("HemoCubeFragment","Test Process completed, result saved")
|
|
||||||
// binding.progressBar.visibility = View.VISIBLE
|
|
||||||
// binding.btnSubmit.visibility = View.GONE
|
|
||||||
// }
|
|
||||||
submitClick = true
|
submitClick = true
|
||||||
if(checkSubmit){
|
if(checkSubmit){
|
||||||
with(sharedPreferences.edit()) {
|
with(sharedPreferences.edit()) {
|
||||||
@@ -227,6 +208,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
binding.btnSubmit.isEnabled = true
|
binding.btnSubmit.isEnabled = true
|
||||||
binding.btnSubmit.isClickable = true
|
binding.btnSubmit.isClickable = true
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.tvTitle2.visibility = View.GONE
|
binding.tvTitle2.visibility = View.GONE
|
||||||
@@ -339,7 +321,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
hemoCubeViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
hemoCubeViewModel.fireBaseUpload.observe(viewLifecycleOwner) { result ->
|
||||||
if (result == "Success") {
|
if (result == "Success") {
|
||||||
uploadedToCloud = true
|
uploadedToCloud = true
|
||||||
//var accessToken = sharedPreferences.getString(Constants.ACCESS_TOKEN, "").toString()
|
var accessToken = sharedPreferences.getString(Constants.ACCESS_TOKEN, "").toString()
|
||||||
showToast(R.string.test_upload)
|
showToast(R.string.test_upload)
|
||||||
if (Constants.MOLBIO_INTEGRATION) {
|
if (Constants.MOLBIO_INTEGRATION) {
|
||||||
hemoCubeViewModel.resultUpload.observe(viewLifecycleOwner) {
|
hemoCubeViewModel.resultUpload.observe(viewLifecycleOwner) {
|
||||||
@@ -371,9 +353,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
handleReadingFinish()
|
handleReadingFinish()
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -401,7 +381,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
hemoCubeViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
hemoCubeViewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable ->
|
||||||
apply {
|
apply {
|
||||||
DataHolder.hemoCubeTestData?.let {
|
DataHolder.hemoCubeTestData?.let {
|
||||||
currentDeviceData?.coefficients?.let { _ ->
|
currentDeviceData?.coefficients?.let { coefficients ->
|
||||||
// val coefficient1 = coefficients[0]
|
// val coefficient1 = coefficients[0]
|
||||||
// val coefficient2 = coefficients[1]
|
// val coefficient2 = coefficients[1]
|
||||||
// val result = coefficient1 * coefficient2
|
// val result = coefficient1 * coefficient2
|
||||||
@@ -487,32 +467,32 @@ class HemoCubeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private fun showBufferAlertDialog() {
|
private fun showBufferAlertDialog() {
|
||||||
// val title = "WARNING"
|
val title = "WARNING"
|
||||||
// val message = getString(R.string.do_exist)
|
val message = getString(R.string.do_exist)
|
||||||
// val negativeText = getString(R.string.no)
|
val negativeText = getString(R.string.no)
|
||||||
// val positiveText = getString(R.string.yes)
|
val positiveText = getString(R.string.yes)
|
||||||
//
|
|
||||||
// UIUtils.createAlertDialog(requireContext(),
|
UIUtils.createAlertDialog(requireContext(),
|
||||||
// title,
|
title,
|
||||||
// message,
|
message,
|
||||||
// negativeText,
|
negativeText,
|
||||||
// positiveText,
|
positiveText,
|
||||||
// object : MyDialogListener {
|
object : MyDialogListener {
|
||||||
// override fun onClickNegativeButton() {
|
override fun onClickNegativeButton() {
|
||||||
// startBufferProcess()
|
startBufferProcess()
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// override fun onClickPositiveButton() {
|
override fun onClickPositiveButton() {
|
||||||
// activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
//// binding.btnPlacebuffer.visibility = View.GONE
|
// binding.btnPlacebuffer.visibility = View.GONE
|
||||||
// binding.btnSamplestart.visibility = View.VISIBLE
|
binding.btnSamplestart.visibility = View.VISIBLE
|
||||||
// binding.tvSubtitle4.text = getString(R.string.place_sample)
|
binding.tvSubtitle4.text = getString(R.string.place_sample)
|
||||||
// }
|
}
|
||||||
// //isUsingExistingBuffer = true
|
//isUsingExistingBuffer = true
|
||||||
// }
|
}
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
|
|
||||||
private fun listenToHemoCube() {
|
private fun listenToHemoCube() {
|
||||||
DataHolder.hemoCubeTestData = DataHolder.selectedTest?.toHemoCubeTestData()
|
DataHolder.hemoCubeTestData = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||||
@@ -566,7 +546,6 @@ class HemoCubeFragment : Fragment() {
|
|||||||
HemoCubeCommands.LOAD_DAC_VALUES,
|
HemoCubeCommands.LOAD_DAC_VALUES,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
//nothing
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
@@ -710,7 +689,6 @@ class HemoCubeFragment : Fragment() {
|
|||||||
binding.testing.visibility = View.GONE
|
binding.testing.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resultData.contains("#BS") && this.testStatusCode < TestStatus.BUFFER_STARTED.code -> {
|
resultData.contains("#BS") && this.testStatusCode < TestStatus.BUFFER_STARTED.code -> {
|
||||||
hemoCubeViewModel.messages.postValue(getString(R.string.buffer_started))
|
hemoCubeViewModel.messages.postValue(getString(R.string.buffer_started))
|
||||||
this.testStatusCode = TestStatus.BUFFER_STARTED.code
|
this.testStatusCode = TestStatus.BUFFER_STARTED.code
|
||||||
@@ -782,6 +760,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
(resultData.contains("#SC") || resultData.contains("#SC1")) && this.testStatusCode < TestStatus.SAMPLE_COMPLETED.code -> {
|
(resultData.contains("#SC") || resultData.contains("#SC1")) && this.testStatusCode < TestStatus.SAMPLE_COMPLETED.code -> {
|
||||||
this.testStatusCode = TestStatus.SAMPLE_COMPLETED.code
|
this.testStatusCode = TestStatus.SAMPLE_COMPLETED.code
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
@@ -795,6 +774,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
fetchResult()
|
fetchResult()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
resultData.contains("ovf") -> {
|
resultData.contains("ovf") -> {
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
binding.testing.visibility = View.GONE
|
binding.testing.visibility = View.GONE
|
||||||
@@ -862,7 +842,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
this.testStatusCode = TestStatus.FIRST_GAIN_PRINT_COMPLETED.code
|
this.testStatusCode = TestStatus.FIRST_GAIN_PRINT_COMPLETED.code
|
||||||
hemoCubeViewModel.messages.postValue("First air reading completed")
|
hemoCubeViewModel.messages.postValue("First air reading completed")
|
||||||
|
|
||||||
val resultLines = currentResultData.split(regEx.toRegex())
|
val resultLines = currentResultData.split("\\s+(?=LB|LS)".toRegex())
|
||||||
DataHolder.hemoCubeTestData?.apply {
|
DataHolder.hemoCubeTestData?.apply {
|
||||||
led1Air1 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
led1Air1 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led2Air1 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
led2Air1 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
@@ -880,7 +860,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
this.testStatusCode = TestStatus.SECOND_EMPTY_AIR_PRINT_COMPLETED.code
|
this.testStatusCode = TestStatus.SECOND_EMPTY_AIR_PRINT_COMPLETED.code
|
||||||
hemoCubeViewModel.messages.postValue("Second air reading completed")
|
hemoCubeViewModel.messages.postValue("Second air reading completed")
|
||||||
|
|
||||||
val resultLines = currentResultData.split(regEx.toRegex())
|
val resultLines = currentResultData.split("\\s+(?=LB|LS)".toRegex())
|
||||||
DataHolder.hemoCubeTestData?.apply {
|
DataHolder.hemoCubeTestData?.apply {
|
||||||
led1Air2 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
led1Air2 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led2Air2 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
led2Air2 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
@@ -898,7 +878,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
this.testStatusCode = TestStatus.FIRST_GAIN_PRINT_COMPLETED.code
|
this.testStatusCode = TestStatus.FIRST_GAIN_PRINT_COMPLETED.code
|
||||||
hemoCubeViewModel.messages.postValue("1.3X gain data gathered")
|
hemoCubeViewModel.messages.postValue("1.3X gain data gathered")
|
||||||
|
|
||||||
val resultLines = currentResultData.split(regEx.toRegex())
|
val resultLines = currentResultData.split("\\s+(?=LB|LS)".toRegex())
|
||||||
DataHolder.hemoCubeTestData?.apply {
|
DataHolder.hemoCubeTestData?.apply {
|
||||||
led1Gain1 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
led1Gain1 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led2Gain1 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
led2Gain1 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
@@ -917,7 +897,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
this.testStatusCode = TestStatus.SECOND_GAIN_PRINT_COMPLETED.code
|
this.testStatusCode = TestStatus.SECOND_GAIN_PRINT_COMPLETED.code
|
||||||
hemoCubeViewModel.messages.postValue("2X gain data gathered")
|
hemoCubeViewModel.messages.postValue("2X gain data gathered")
|
||||||
|
|
||||||
val resultLines = currentResultData.split(regEx.toRegex())
|
val resultLines = currentResultData.split("\\s+(?=LB|LS)".toRegex())
|
||||||
DataHolder.hemoCubeTestData?.apply {
|
DataHolder.hemoCubeTestData?.apply {
|
||||||
led1Gain2 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
led1Gain2 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led2Gain2 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
led2Gain2 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
@@ -936,7 +916,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
this.testStatusCode = TestStatus.FORTH_GAIN_PRINT_COMPLETED.code
|
this.testStatusCode = TestStatus.FORTH_GAIN_PRINT_COMPLETED.code
|
||||||
hemoCubeViewModel.messages.postValue("7.6X gain data gathered")
|
hemoCubeViewModel.messages.postValue("7.6X gain data gathered")
|
||||||
|
|
||||||
val resultLines = currentResultData.split(regEx.toRegex())
|
val resultLines = currentResultData.split("\\s+(?=LB|LS)".toRegex())
|
||||||
DataHolder.hemoCubeTestData?.apply {
|
DataHolder.hemoCubeTestData?.apply {
|
||||||
led1Gain4 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
led1Gain4 = resultLines[5].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
led2Gain4 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
led2Gain4 = resultLines[6].split(' ')[1].trim().toDoubleOrNull()!!
|
||||||
@@ -1014,7 +994,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
getString(R.string.data_collected_processing_data)
|
getString(R.string.data_collected_processing_data)
|
||||||
)
|
)
|
||||||
|
|
||||||
val resultLines = currentResultData.split(regEx.toRegex())
|
val resultLines = currentResultData.split("\\s+(?=LB|LS)".toRegex())
|
||||||
var bufferIntensity = resultLines[1].split(' ')[1].trim()
|
var bufferIntensity = resultLines[1].split(' ')[1].trim()
|
||||||
led1BufferForDevice = if (isUsingExistingBuffer) {
|
led1BufferForDevice = if (isUsingExistingBuffer) {
|
||||||
sharedPreferences.getString(Constants.BUFFER_VALUE_1, "")?.toDoubleOrNull()!!
|
sharedPreferences.getString(Constants.BUFFER_VALUE_1, "")?.toDoubleOrNull()!!
|
||||||
@@ -1296,13 +1276,13 @@ class HemoCubeFragment : Fragment() {
|
|||||||
constant = Constants.DEVICE_CONFIGURATION[deviceHardwareId]?.get(0)?.get(1)
|
constant = Constants.DEVICE_CONFIGURATION[deviceHardwareId]?.get(0)?.get(1)
|
||||||
fittedAbs4 = gradient?.times(led4Average)?.plus(constant!!)!!
|
fittedAbs4 = gradient?.times(led4Average)?.plus(constant!!)!!
|
||||||
|
|
||||||
// val slope1 = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(1)?.get(0)
|
val slope1 = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(1)?.get(0)
|
||||||
// val intercept1 = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(1)?.get(1)
|
val intercept1 = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(1)?.get(1)
|
||||||
//val calculatedHb1 = (led1Average - intercept1!!) / slope1!!
|
val calculatedHb1 = (led1Average - intercept1!!) / slope1!!
|
||||||
|
|
||||||
// val slope2 = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(3)?.get(0)
|
val slope2 = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(3)?.get(0)
|
||||||
// val intercept = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(3)?.get(1)
|
val intercept = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(3)?.get(1)
|
||||||
//val calculatedHb2 = (led2Average - intercept!!) / slope2!!
|
val calculatedHb2 = (led2Average - intercept!!) / slope2!!
|
||||||
|
|
||||||
val slope3 = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(2)?.get(0)
|
val slope3 = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(2)?.get(0)
|
||||||
val intercept3 = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(2)?.get(1)
|
val intercept3 = Constants.DEVICE_HB_PARAMETERS[deviceHardwareId]?.get(2)?.get(1)
|
||||||
@@ -1401,7 +1381,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
"%.3f".format(
|
"%.3f".format(
|
||||||
borderlineMetric
|
borderlineMetric
|
||||||
)
|
)
|
||||||
}"
|
} \n Remove Cuvette & Click Submit"
|
||||||
)
|
)
|
||||||
if (DataHolder.hemoCubeTestData?.testType == "HB")
|
if (DataHolder.hemoCubeTestData?.testType == "HB")
|
||||||
hemoCubeViewModel.messages.postValue("Hb: $calculatedHb4")
|
hemoCubeViewModel.messages.postValue("Hb: $calculatedHb4")
|
||||||
@@ -1446,13 +1426,13 @@ class HemoCubeFragment : Fragment() {
|
|||||||
fun reclassifyWithBorderlineMethod2(deviceRatio: Double?, deviceRatioClass: String?, led2Average: Double?): String {
|
fun reclassifyWithBorderlineMethod2(deviceRatio: Double?, deviceRatioClass: String?, led2Average: Double?): String {
|
||||||
try {
|
try {
|
||||||
if (deviceRatio != null && led2Average != null) {
|
if (deviceRatio != null && led2Average != null) {
|
||||||
if (deviceRatioClass == negativeBorderLine) {
|
if (deviceRatioClass == "Negative Borderline") {
|
||||||
return if (led2Average >= 0.15)
|
return if (led2Average >= 0.15)
|
||||||
"Borderline. Normal"
|
"Borderline. Normal"
|
||||||
else
|
else
|
||||||
"Borderline. Sickle Cell Trait"
|
"Borderline. Sickle Cell Trait"
|
||||||
}
|
}
|
||||||
if (deviceRatioClass == positiveBoderLine) {
|
if (deviceRatioClass == "Positive for Sickle Cell. HPLC for Confirmation") {
|
||||||
return if (led2Average >= 0.19)
|
return if (led2Average >= 0.19)
|
||||||
"Borderline. Sickle Cell Trait"
|
"Borderline. Sickle Cell Trait"
|
||||||
else
|
else
|
||||||
@@ -1475,57 +1455,59 @@ class HemoCubeFragment : Fragment() {
|
|||||||
// hemoCubeViewModel.messages.postValue("post classification checks")
|
// hemoCubeViewModel.messages.postValue("post classification checks")
|
||||||
if (deviceRatio != null && borderlineMetric != null) {
|
if (deviceRatio != null && borderlineMetric != null) {
|
||||||
if(cuvetteSize == "10mm"){
|
if(cuvetteSize == "10mm"){
|
||||||
if (deviceRatioClass == negativeBorderLine) {
|
if (deviceRatioClass == "Negative Borderline") {
|
||||||
when {
|
if (borderlineMetric < negativeBoderLine10mm1){//1.34
|
||||||
borderlineMetric < negativeBoderLine10mm1 -> {//1.34
|
return "Sickle Cell Trait"
|
||||||
return sickleCellTrait
|
}else if(borderlineMetric > negativeBoderLine10mm2){
|
||||||
}
|
return "Normal"
|
||||||
borderlineMetric > negativeBoderLine10mm2 -> {
|
}else if(borderlineMetric > negativeBoderLine10mm1 && borderlineMetric < negativeBoderLine10mm2){
|
||||||
return "Normal"
|
return "Negative borderline. Confirm with HPLC"
|
||||||
}
|
|
||||||
borderlineMetric > negativeBoderLine10mm1 && borderlineMetric < negativeBoderLine10mm2 -> {
|
|
||||||
return "Negative borderline. Confirm with HPLC"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (deviceRatioClass == positiveBoderLine) {
|
if (deviceRatioClass == "Positive for Sickle Cell. HPLC for Confirmation") {
|
||||||
when {
|
if (borderlineMetric < positiveBoderLine10mm1){//1.34
|
||||||
borderlineMetric < positiveBoderLine10mm1 -> {//1.34
|
return "Sickle Cell Disease"
|
||||||
return sickleCellDisease
|
}else if(borderlineMetric > positiveBoderLine10mm2){
|
||||||
}
|
return "Sickle Cell Trait"
|
||||||
borderlineMetric > positiveBoderLine10mm2 -> {
|
}else if(borderlineMetric > positiveBoderLine10mm1 && borderlineMetric < positiveBoderLine10mm2){
|
||||||
return sickleCellTrait
|
return "Positive for Sickle Cell. Confirm with HPLC"
|
||||||
}
|
|
||||||
borderlineMetric > positiveBoderLine10mm1 && borderlineMetric < positiveBoderLine10mm2 -> {
|
|
||||||
return "Positive for Sickle Cell. Confirm with HPLC"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// if (deviceRatioClass == "Negative Borderline") {
|
||||||
|
// if (borderlineMetric < negativeBoderLine10mm1){//1.34
|
||||||
|
// return "Sickle Cell Trait"
|
||||||
|
// }else if(borderlineMetric > negativeBoderLine10mm1){
|
||||||
|
// return "Normal"
|
||||||
|
// }else if(borderlineMetric == negativeBoderLine10mm1){
|
||||||
|
// return "Sickle Cell Trait"
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (deviceRatioClass == "Positive for Sickle Cell. HPLC for Confirmation") {
|
||||||
|
// if (borderlineMetric < positiveBoderLine10mm1){//1.34
|
||||||
|
// return "Sickle Cell Disease"
|
||||||
|
// }else if(borderlineMetric > positiveBoderLine10mm1){
|
||||||
|
// return "Sickle Cell Trait"
|
||||||
|
// }else if(borderlineMetric == positiveBoderLine10mm1){
|
||||||
|
// return "Sickle Cell Disease"
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}else if(cuvetteSize == "2mm"){
|
}else if(cuvetteSize == "2mm"){
|
||||||
if (deviceRatioClass == negativeBorderLine) {
|
if (deviceRatioClass == "Negative Borderline") {
|
||||||
when {
|
if (borderlineMetric < negativeBoderLine2mm1){//1.34
|
||||||
borderlineMetric < negativeBoderLine2mm1 -> {//1.34
|
return "Sickle Cell Trait"
|
||||||
return sickleCellTrait
|
}else if(borderlineMetric > negativeBoderLine2mm2){
|
||||||
}
|
return "Normal"
|
||||||
borderlineMetric > negativeBoderLine2mm2 -> {
|
}else if(borderlineMetric > negativeBoderLine2mm1 && borderlineMetric < negativeBoderLine2mm2){
|
||||||
return "Normal"
|
return "Negative borderline. Confirm with HPLC"
|
||||||
}
|
|
||||||
borderlineMetric > negativeBoderLine2mm1 && borderlineMetric < negativeBoderLine2mm2 -> {
|
|
||||||
return "Negative borderline. Confirm with HPLC"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (deviceRatioClass == positiveBoderLine) {
|
if (deviceRatioClass == "Positive for Sickle Cell. HPLC for Confirmation") {
|
||||||
when {
|
if (borderlineMetric < positiveBoderLine2mm1){//1.34
|
||||||
borderlineMetric < positiveBoderLine2mm1 -> {//1.34
|
return "Sickle Cell Disease"
|
||||||
return sickleCellDisease
|
}else if(borderlineMetric > positiveBoderLine2mm2){
|
||||||
}
|
return "Sickle Cell Trait"
|
||||||
borderlineMetric > positiveBoderLine2mm2 -> {
|
}else if(borderlineMetric > positiveBoderLine2mm1 && borderlineMetric < positiveBoderLine2mm2){
|
||||||
return sickleCellTrait
|
return "Positive for Sickle Cell. Confirm with HPLC"
|
||||||
}
|
|
||||||
borderlineMetric > positiveBoderLine2mm1 && borderlineMetric < positiveBoderLine2mm2 -> {
|
|
||||||
return "Positive for Sickle Cell. Confirm with HPLC"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1546,13 +1528,13 @@ class HemoCubeFragment : Fragment() {
|
|||||||
return "Normal"
|
return "Normal"
|
||||||
}
|
}
|
||||||
if (roundedRatio in 0.237..0.242)
|
if (roundedRatio in 0.237..0.242)
|
||||||
return negativeBorderLine
|
return "Negative Borderline"
|
||||||
if (roundedRatio in 0.242..0.318)
|
if (roundedRatio in 0.242..0.318)
|
||||||
return sickleCellTrait
|
return "Sickle Cell Trait"
|
||||||
if (roundedRatio >= 0.318 && roundedRatio < 0.356)
|
if (roundedRatio >= 0.318 && roundedRatio < 0.356)
|
||||||
return positiveBoderLine
|
return "Positive for Sickle Cell. HPLC for Confirmation"
|
||||||
if (roundedRatio in 0.356..0.7)
|
if (roundedRatio in 0.356..0.7)
|
||||||
return sickleCellDisease
|
return "Sickle Cell Disease"
|
||||||
} else {
|
} else {
|
||||||
return "Invalid"
|
return "Invalid"
|
||||||
}
|
}
|
||||||
@@ -1572,16 +1554,16 @@ class HemoCubeFragment : Fragment() {
|
|||||||
return "Normal"
|
return "Normal"
|
||||||
}
|
}
|
||||||
if (ratio in negativeBorderlineMin10mm..negativeBorderlineMax10mm){
|
if (ratio in negativeBorderlineMin10mm..negativeBorderlineMax10mm){
|
||||||
return negativeBorderLine
|
return "Negative Borderline"
|
||||||
}
|
}
|
||||||
if (ratio in sickleCellTraitMin10mm..sickleCellTraitMax10mm){
|
if (ratio in sickleCellTraitMin10mm..sickleCellTraitMax10mm){
|
||||||
return sickleCellTrait
|
return "Sickle Cell Trait"
|
||||||
}
|
}
|
||||||
if (ratio in positiveForSickleCellMin10mm..positiveForSickleCellMax10mm){//0.36
|
if (ratio in positiveForSickleCellMin10mm..positiveForSickleCellMax10mm){//0.36
|
||||||
return positiveBoderLine
|
return "Positive for Sickle Cell. HPLC for Confirmation"
|
||||||
}
|
}
|
||||||
if (ratio in sickleCellDiseaseMin10mm..sickleCellDiseaseMax10mm){
|
if (ratio in sickleCellDiseaseMin10mm..sickleCellDiseaseMax10mm){
|
||||||
return sickleCellDisease
|
return "Sickle Cell Disease"
|
||||||
}
|
}
|
||||||
}else if(cuvetteSize == "2mm"){
|
}else if(cuvetteSize == "2mm"){
|
||||||
if (ratio in normalMin2mm..normalMax2mm) {
|
if (ratio in normalMin2mm..normalMax2mm) {
|
||||||
@@ -1589,16 +1571,16 @@ class HemoCubeFragment : Fragment() {
|
|||||||
return "Normal"
|
return "Normal"
|
||||||
}
|
}
|
||||||
if (ratio in negativeBorderlineMin2mm..negativeBorderlineMax2mm){
|
if (ratio in negativeBorderlineMin2mm..negativeBorderlineMax2mm){
|
||||||
return negativeBorderLine
|
return "Negative Borderline"
|
||||||
}
|
}
|
||||||
if (ratio in sickleCellTraitMin2mm..sickleCellTraitMax2mm){
|
if (ratio in sickleCellTraitMin2mm..sickleCellTraitMax2mm){
|
||||||
return sickleCellTrait
|
return "Sickle Cell Trait"
|
||||||
}
|
}
|
||||||
if (ratio in positiveForSickleCellMin2mm..positiveForSickleCellMax2mm){//0.36
|
if (ratio in positiveForSickleCellMin2mm..positiveForSickleCellMax2mm){//0.36
|
||||||
return positiveBoderLine
|
return "Positive for Sickle Cell. HPLC for Confirmation"
|
||||||
}
|
}
|
||||||
if (ratio in sickleCellDiseaseMin2mm..sickleCellDiseaseMax2mm){
|
if (ratio in sickleCellDiseaseMin2mm..sickleCellDiseaseMax2mm){
|
||||||
return sickleCellDisease
|
return "Sickle Cell Disease"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1698,9 +1680,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
|
|
||||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.CHECK_CUVETTE_COMMAND,
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.CHECK_CUVETTE_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
hemoCubeViewModel.progressBar.postValue(false)
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
@@ -1714,9 +1694,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
// }
|
// }
|
||||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.START_BUFFER_COMMAND,
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.START_BUFFER_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
hemoCubeViewModel.progressBar.postValue(false)
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
@@ -1729,9 +1707,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
|
|
||||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.START_SAMPLE,
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.START_SAMPLE,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
hemoCubeViewModel.progressBar.postValue(false)
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
@@ -1745,9 +1721,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
|
|
||||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.FIRST_GAIN_COMMAND,
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.FIRST_GAIN_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
hemoCubeViewModel.progressBar.postValue(false)
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
@@ -1760,9 +1734,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
|
|
||||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.SECOND_GAIN_COMMAND,
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.SECOND_GAIN_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
hemoCubeViewModel.progressBar.postValue(false)
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
@@ -1770,29 +1742,25 @@ class HemoCubeFragment : Fragment() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// private fun sendThirdGainCommand() {
|
private fun sendThirdGainCommand() {
|
||||||
// hemoCubeViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
//
|
|
||||||
// (activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.THIRD_GAIN_COMMAND,
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.THIRD_GAIN_COMMAND,
|
||||||
// object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
// override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
// //nothing
|
|
||||||
// }
|
override fun onUsbError(e: Exception?) {
|
||||||
//
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
// override fun onUsbError(e: Exception?) {
|
}
|
||||||
// hemoCubeViewModel.progressBar.postValue(false)
|
})
|
||||||
// }
|
}
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
||||||
private fun sendForthGainCommand() {
|
private fun sendForthGainCommand() {
|
||||||
hemoCubeViewModel.progressBar.postValue(true)
|
hemoCubeViewModel.progressBar.postValue(true)
|
||||||
|
|
||||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.FORTH_GAIN_COMMAND,
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.FORTH_GAIN_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
hemoCubeViewModel.progressBar.postValue(false)
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
@@ -1804,9 +1772,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
|
|
||||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.CHECK_TEMP_COMMAND,
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.CHECK_TEMP_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
hemoCubeViewModel.progressBar.postValue(false)
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
@@ -1818,9 +1784,7 @@ class HemoCubeFragment : Fragment() {
|
|||||||
|
|
||||||
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.PRINT_COMMAND,
|
(activity as HemocubeActivity).mService.sendAndListenToHemoCube(HemoCubeCommands.PRINT_COMMAND,
|
||||||
object : UsbServiceListener {
|
object : UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
hemoCubeViewModel.progressBar.postValue(false)
|
hemoCubeViewModel.progressBar.postValue(false)
|
||||||
|
|||||||
@@ -25,8 +25,11 @@ import androidx.lifecycle.viewModelScope
|
|||||||
import androidx.work.ExistingPeriodicWorkPolicy
|
import androidx.work.ExistingPeriodicWorkPolicy
|
||||||
import androidx.work.PeriodicWorkRequestBuilder
|
import androidx.work.PeriodicWorkRequestBuilder
|
||||||
import androidx.work.WorkManager
|
import androidx.work.WorkManager
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.util.CsvWriter
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
import com.example.hpostesting.util.NetworkStatusLiveData
|
||||||
|
import com.example.hpostesting.util.Result
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
||||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||||
import com.example.hpostesting.data.datasource.LocalFileDataSource
|
import com.example.hpostesting.data.datasource.LocalFileDataSource
|
||||||
@@ -47,11 +50,7 @@ import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
|||||||
import com.example.hpostesting.data.repository.Repository
|
import com.example.hpostesting.data.repository.Repository
|
||||||
import com.example.hpostesting.domain.CheckUpdateWorker
|
import com.example.hpostesting.domain.CheckUpdateWorker
|
||||||
import com.example.hpostesting.domain.LogFileManager
|
import com.example.hpostesting.domain.LogFileManager
|
||||||
import com.example.hpostesting.util.CsvWriter
|
|
||||||
import com.example.hpostesting.util.NetworkStatusLiveData
|
|
||||||
import com.example.hpostesting.util.Result
|
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import `in`.sminnovations.hpostesting.R
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import okhttp3.Headers
|
import okhttp3.Headers
|
||||||
@@ -73,18 +72,17 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
private val repository: Repository,
|
private val repository: Repository,
|
||||||
private val logFileManager: LogFileManager,
|
private val logFileManager: LogFileManager,
|
||||||
private val localFileDataSource: LocalFileDataSource,
|
private val localFileDataSource: LocalFileDataSource,
|
||||||
private val contextV: Context
|
context: Context,
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
private val successMsg = "Data uploaded to Firestore successfully"
|
|
||||||
private var testUpload: Boolean = false
|
private var testUpload: Boolean = false
|
||||||
var isServiceConnected = false
|
var isServiceConnected = false
|
||||||
val progressBar = MutableLiveData(false)
|
val progressBar = MutableLiveData(false)
|
||||||
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||||
val messages = MutableLiveData<String>()
|
val messages = MutableLiveData<String>()
|
||||||
private val sharedPreference =
|
private val sharedPreference =
|
||||||
contextV.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
context.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
|
|
||||||
private val workManager = WorkManager.getInstance(contextV)
|
private val workManager = WorkManager.getInstance(context)
|
||||||
|
|
||||||
// init {
|
// init {
|
||||||
// startPeriodicCheckUpdate()
|
// startPeriodicCheckUpdate()
|
||||||
@@ -105,7 +103,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
|
|
||||||
// Get the device ID of the device you want to retrieve data for (e.g., the first device in the list)
|
// Get the device ID of the device you want to retrieve data for (e.g., the first device in the list)
|
||||||
|
|
||||||
private val _networkStatusLiveData = NetworkStatusLiveData(contextV)
|
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||||
val allUserData = hemoCubeDao.getAll()
|
val allUserData = hemoCubeDao.getAll()
|
||||||
val allLocalData = hemoCubeDao.getAll()
|
val allLocalData = hemoCubeDao.getAll()
|
||||||
val allPendingUserToUpload = hemoCubeDao.getPendingUser()
|
val allPendingUserToUpload = hemoCubeDao.getPendingUser()
|
||||||
@@ -121,7 +119,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
|
|
||||||
private val batteryStatus: Intent? =
|
private val batteryStatus: Intent? =
|
||||||
IntentFilter(Intent.ACTION_BATTERY_CHANGED).let { ifilter ->
|
IntentFilter(Intent.ACTION_BATTERY_CHANGED).let { ifilter ->
|
||||||
contextV.registerReceiver(null, ifilter)
|
context.registerReceiver(null, ifilter)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun uploadHemoCubeResultToDatabase(
|
fun uploadHemoCubeResultToDatabase(
|
||||||
@@ -151,7 +149,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
// addResultTestToDb(quickCapture,isOnline)
|
// addResultTestToDb(quickCapture,isOnline)
|
||||||
testDetails?.testTime = SimpleDateFormat(
|
testDetails?.testTime = SimpleDateFormat(
|
||||||
contextV.resources.getString(R.string.DateTimeFormat), Locale.getDefault()
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
).format(Calendar.getInstance().time)
|
).format(Calendar.getInstance().time)
|
||||||
testDetails?.localFlag = false
|
testDetails?.localFlag = false
|
||||||
hemoCubeDao.updateTest(testDetails!!)
|
hemoCubeDao.updateTest(testDetails!!)
|
||||||
@@ -180,7 +178,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
testDetails.reportUploadTime = SimpleDateFormat(
|
testDetails.reportUploadTime = SimpleDateFormat(
|
||||||
contextV.resources.getString(R.string.DateTimeFormat), Locale.getDefault()
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
).format(Calendar.getInstance().time)
|
).format(Calendar.getInstance().time)
|
||||||
val currentTimeFormatted = SimpleDateFormat(
|
val currentTimeFormatted = SimpleDateFormat(
|
||||||
"yyyy-MM-dd'T'HH:mm:ssZZZZZ",
|
"yyyy-MM-dd'T'HH:mm:ssZZZZZ",
|
||||||
@@ -308,12 +306,15 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sendDataToFirebase() = viewModelScope.launch (Dispatchers.IO) {
|
|
||||||
|
fun sendDataToFirebase() = viewModelScope.launch ( Dispatchers.IO ) {
|
||||||
val pendingData = hemoCubeDao.getFirebasePending()
|
val pendingData = hemoCubeDao.getFirebasePending()
|
||||||
pendingData.forEach{
|
pendingData.forEach{
|
||||||
userData ->
|
userData ->
|
||||||
if (!userData.localFlag && userData.testStatus == true) {
|
if (userData != null) {
|
||||||
bulkAddResultTestToDb(userData)
|
if (!userData.localFlag && userData.testStatus == true) {
|
||||||
|
bulkAddResultTestToDb(userData)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(testUpload){
|
if(testUpload){
|
||||||
@@ -360,7 +361,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
|
|
||||||
fun uploadLogs() = viewModelScope.launch {
|
fun uploadLogs() = viewModelScope.launch {
|
||||||
uploadLogs.postValue(Result.Loading())
|
uploadLogs.postValue(Result.Loading())
|
||||||
logFileManager.createLogFile().let { file ->
|
val logFile = logFileManager.createLogFile().let { file ->
|
||||||
val requestBody = file?.asRequestBody("multipart/form-data".toMediaTypeOrNull())
|
val requestBody = file?.asRequestBody("multipart/form-data".toMediaTypeOrNull())
|
||||||
val multipartFile =
|
val multipartFile =
|
||||||
requestBody?.let { MultipartBody.Part.createFormData("logFile", file?.name, it) }
|
requestBody?.let { MultipartBody.Part.createFormData("logFile", file?.name, it) }
|
||||||
@@ -385,7 +386,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
when (val response =
|
when (val response =
|
||||||
repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
Log.i("Testdb", successMsg)
|
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
bufferCheckData.localFlag = true
|
bufferCheckData.localFlag = true
|
||||||
hemoCubeBufferDao.insertAll(bufferCheckData)
|
hemoCubeBufferDao.insertAll(bufferCheckData)
|
||||||
@@ -397,6 +398,8 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
bufferCheckData.localFlag = true
|
bufferCheckData.localFlag = true
|
||||||
hemoCubeBufferDao.insertAll(bufferCheckData)
|
hemoCubeBufferDao.insertAll(bufferCheckData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else -> {}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("Testdb", "Exception during data upload: ${e.message}")
|
Log.e("Testdb", "Exception during data upload: ${e.message}")
|
||||||
@@ -411,7 +414,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
fun bulkAddResultKitTestToDb(bufferCheckData: BufferCheckData) {
|
fun bulkAddResultKitTestToDb(bufferCheckData: BufferCheckData) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
bufferCheckData.reportUploadTime = SimpleDateFormat(
|
bufferCheckData.reportUploadTime = SimpleDateFormat(
|
||||||
contextV.resources.getString(R.string.DateTimeFormat), Locale.getDefault()
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
).format(Calendar.getInstance().time)
|
).format(Calendar.getInstance().time)
|
||||||
when (repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
when (repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
@@ -440,7 +443,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
testDetails?.resultData = DataHolder.hemoCubeTestData?.resultData.toString()
|
testDetails?.resultData = DataHolder.hemoCubeTestData?.resultData.toString()
|
||||||
testDetails?.location = DataHolder.location
|
testDetails?.location = DataHolder.location
|
||||||
testDetails?.testTime = SimpleDateFormat(
|
testDetails?.testTime = SimpleDateFormat(
|
||||||
contextV.resources.getString(R.string.DateTimeFormat), Locale.getDefault()
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
).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
|
||||||
@@ -502,10 +505,10 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
testDetails!!.quickCapture = quickCapture
|
testDetails!!.quickCapture = quickCapture
|
||||||
testDetails.testStatus = true
|
testDetails.testStatus = true
|
||||||
testDetails.reportUploadTime = SimpleDateFormat(
|
testDetails.reportUploadTime = SimpleDateFormat(
|
||||||
contextV.resources.getString(R.string.DateTimeFormat), Locale.getDefault()
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
).format(Calendar.getInstance().time)
|
).format(Calendar.getInstance().time)
|
||||||
val currentTimeFormatted = SimpleDateFormat(
|
val currentTimeFormatted = SimpleDateFormat(
|
||||||
contextV.resources.getString(R.string.DateTimeFormat),
|
"yyyy-MM-dd'T'HH:mm:ssZZZZZ",
|
||||||
Locale.getDefault()
|
Locale.getDefault()
|
||||||
).format(Calendar.getInstance().time)
|
).format(Calendar.getInstance().time)
|
||||||
if(quickCapture){
|
if(quickCapture){
|
||||||
@@ -516,7 +519,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
putInt(Constants.KIT_COUNT, kitCount.plus(1))
|
putInt(Constants.KIT_COUNT, kitCount.plus(1))
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
Log.i("Testdb", successMsg)
|
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
testDetails.localFlag = true
|
testDetails.localFlag = true
|
||||||
hemoCubeDao.updateTest(testDetails)
|
hemoCubeDao.updateTest(testDetails)
|
||||||
@@ -528,9 +531,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
hemoCubeDao.updateTest(testDetails)
|
hemoCubeDao.updateTest(testDetails)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {}
|
||||||
//nothing
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
when (val response = repository.addTestToDatabase(testDetails)) {
|
when (val response = repository.addTestToDatabase(testDetails)) {
|
||||||
@@ -541,7 +542,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
putInt(Constants.KIT_COUNT, kitCount.plus(1))
|
putInt(Constants.KIT_COUNT, kitCount.plus(1))
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
Log.i("Testdb", successMsg)
|
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
|
|
||||||
if (Constants.MOLBIO_INTEGRATION) {
|
if (Constants.MOLBIO_INTEGRATION) {
|
||||||
@@ -576,6 +577,8 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
fireBaseUpload.postValue("Error")
|
fireBaseUpload.postValue("Error")
|
||||||
hemoCubeDao.updateTest(testDetails)
|
hemoCubeDao.updateTest(testDetails)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -642,7 +645,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
when (val response =
|
when (val response =
|
||||||
repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
Log.i("Testdb", successMsg)
|
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -650,6 +653,8 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
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 -> {}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("Testdb", "Exception during data upload: ${e.message}")
|
Log.e("Testdb", "Exception during data upload: ${e.message}")
|
||||||
|
|||||||
@@ -304,9 +304,11 @@ open class HemocubeActivity : AppCompatActivity() {
|
|||||||
// }
|
// }
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
val fragment = supportFragmentManager.findFragmentById(R.id.fghemocube)
|
val fragment = supportFragmentManager.findFragmentById(R.id.fghemocube)
|
||||||
if (fragment is HemoCubeFragment && fragment.handleBackButtonPress()) {
|
if (fragment is HemoCubeFragment) {
|
||||||
// If the fragment handled the back press, return to avoid calling super.onBackPressed
|
if (fragment.handleBackButtonPress()) {
|
||||||
return
|
// If the fragment handled the back press, return to avoid calling super.onBackPressed
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// If the fragment did not handle the back press, call the superclass method
|
// If the fragment did not handle the back press, call the superclass method
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
|
|||||||
@@ -36,7 +36,11 @@ import androidx.core.content.ContextCompat
|
|||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
|
import com.example.hpostesting.presentation.deviceinfo.DeviceFragment
|
||||||
|
import com.example.hpostesting.presentation.utils.DeviceCommunicationHandler
|
||||||
|
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||||
import com.example.hpostesting.util.UsbService
|
import com.example.hpostesting.util.UsbService
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||||
@@ -55,37 +59,25 @@ class UsbTerminalActivity : AppCompatActivity() {
|
|||||||
private var mConnection: UsbDeviceConnection? = null
|
private var mConnection: UsbDeviceConnection? = null
|
||||||
lateinit var mService: UsbService
|
lateinit var mService: UsbService
|
||||||
private var deviceId = ""
|
private var deviceId = ""
|
||||||
private var executedCommands: MutableList<String> = mutableListOf()
|
|
||||||
private var isResuming = false
|
|
||||||
private val TAG = "Calibration"
|
private val TAG = "Calibration"
|
||||||
|
|
||||||
private val broadcastReceiver = object : BroadcastReceiver() {
|
private val broadcastReceiver = object : BroadcastReceiver() {
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
|
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
val device: UsbDevice? = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE)
|
val device: UsbDevice? = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE)
|
||||||
|
|
||||||
if (UsbManager.ACTION_USB_DEVICE_DETACHED == intent.action) {
|
if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
|
||||||
// Handle USB disconnection
|
device?.apply {
|
||||||
Log.d(TAG, "USB device detached")
|
|
||||||
cleanupUsb()
|
|
||||||
DataHolder.usbConnected.postValue(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (UsbManager.ACTION_USB_DEVICE_ATTACHED == intent.action) {
|
|
||||||
// Handle USB reconnection
|
|
||||||
Log.d(TAG, "USB device attached")
|
|
||||||
connectUsb(false) // Attempt reconnection
|
|
||||||
} else if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
|
|
||||||
// Handle USB permission granted
|
|
||||||
device?.let {
|
|
||||||
connectUsb(true)
|
connectUsb(true)
|
||||||
DataHolder.usbConnected.postValue(true)
|
DataHolder.usbConnected.postValue(true)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "USB permission denied")
|
onErrorReported("permission denied for device")
|
||||||
DataHolder.usbConnected.postValue(false)
|
DataHolder.usbConnected.postValue(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,15 +96,6 @@ class UsbTerminalActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getExecutedCommands(): List<String> {
|
|
||||||
return executedCommands
|
|
||||||
}
|
|
||||||
|
|
||||||
fun addExecutedCommand(command: String) {
|
|
||||||
if (!executedCommands.contains(command)) {
|
|
||||||
executedCommands.add(command)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
override fun attachBaseContext(newBase: Context?) {
|
override fun attachBaseContext(newBase: Context?) {
|
||||||
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
val languageCode = LanguageManager.getSavedLanguage(newBase!!)
|
||||||
LanguageManager.setLocale(newBase, languageCode)
|
LanguageManager.setLocale(newBase, languageCode)
|
||||||
@@ -123,28 +106,18 @@ class UsbTerminalActivity : AppCompatActivity() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = ActivityUsbTerminalBinding.inflate(layoutInflater)
|
binding = ActivityUsbTerminalBinding.inflate(layoutInflater)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
// setSupportActionBar(binding.myToolbar)
|
||||||
val filter = IntentFilter()
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED)
|
|
||||||
filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED)
|
|
||||||
registerReceiver(broadcastReceiver, filter)
|
|
||||||
|
|
||||||
doBoth()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fun doBoth(){
|
|
||||||
setupListener()
|
setupListener()
|
||||||
connectUsb(false)
|
connectUsb(false)
|
||||||
}
|
}
|
||||||
private fun setupListener() {
|
|
||||||
|
|
||||||
|
private fun setupListener() {
|
||||||
DataHolder.usbConnected.observe(this) {
|
DataHolder.usbConnected.observe(this) {
|
||||||
Log.d("USB OBSERVE", "HemoCube called -> $it")
|
Log.d("USB OBSERVE", "HemoCube called -> $it")
|
||||||
if (it) {
|
if (it) {
|
||||||
myMenu?.get(0)?.icon =
|
myMenu?.get(0)?.icon =
|
||||||
ContextCompat.getDrawable(this, R.drawable.ic_baseline_usb_24)
|
ContextCompat.getDrawable(this, R.drawable.ic_baseline_usb_24)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
myMenu?.get(0)?.icon =
|
myMenu?.get(0)?.icon =
|
||||||
ContextCompat.getDrawable(this, R.drawable.ic_baseline_usb_off_24)
|
ContextCompat.getDrawable(this, R.drawable.ic_baseline_usb_off_24)
|
||||||
@@ -155,14 +128,11 @@ class UsbTerminalActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
open fun connectUsb(permissionGranted: Boolean) {
|
open fun connectUsb(permissionGranted: Boolean) {
|
||||||
Log.d(TAG, "connectUsb() called, permission variable = $permissionGranted")
|
Log.d(TAG, "connectUsb() called, permission variable = $permissionGranted")
|
||||||
cleanupUsb() // Clean up before reinitializing
|
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
if (availableDrivers.isEmpty()) {
|
if (availableDrivers.isEmpty()) {
|
||||||
onErrorReported("No Device Connected")
|
onErrorReported("No Device is Connected")
|
||||||
DataHolder.usbConnected.postValue(false)
|
|
||||||
} else {
|
} else {
|
||||||
mDriver = availableDrivers[0]
|
mDriver = availableDrivers[0]
|
||||||
mConnection = manager.openDevice(mDriver.device)
|
mConnection = manager.openDevice(mDriver.device)
|
||||||
@@ -170,13 +140,13 @@ class UsbTerminalActivity : AppCompatActivity() {
|
|||||||
requestUserPermission(manager, mDriver.device)
|
requestUserPermission(manager, mDriver.device)
|
||||||
} else {
|
} else {
|
||||||
setupService()
|
setupService()
|
||||||
DataHolder.usbConnected.postValue(true)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onErrorReported(msg: String) {
|
fun onErrorReported(msg: String) {
|
||||||
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
|
||||||
|
if (!isFinishing) onBackPressed()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun moveToNext() {
|
private fun moveToNext() {
|
||||||
@@ -186,9 +156,6 @@ class UsbTerminalActivity : AppCompatActivity() {
|
|||||||
.commit()
|
.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("MutableImplicitPendingIntent")
|
@SuppressLint("MutableImplicitPendingIntent")
|
||||||
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
private fun requestUserPermission(manager: UsbManager, device: UsbDevice) {
|
||||||
val mPendingIntent: PendingIntent
|
val mPendingIntent: PendingIntent
|
||||||
@@ -220,29 +187,12 @@ class UsbTerminalActivity : AppCompatActivity() {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
unregisterReceiver(broadcastReceiver)
|
|
||||||
if (usbTerminalViewModel.isServiceConnected) {
|
if (usbTerminalViewModel.isServiceConnected) {
|
||||||
mService.disconnect()
|
mService.disconnect()
|
||||||
unbindService(connection)
|
unbindService(connection)
|
||||||
usbTerminalViewModel.isServiceConnected = false
|
usbTerminalViewModel.isServiceConnected = false
|
||||||
}
|
}
|
||||||
cleanupUsb()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private fun cleanupUsb() {
|
|
||||||
try {
|
|
||||||
mService.disconnect()
|
|
||||||
unbindService(connection)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e(TAG, "Error during USB cleanup: ${e.message}")
|
|
||||||
}
|
|
||||||
mConnection?.close()
|
|
||||||
mConnection = null
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -13,8 +13,6 @@
|
|||||||
|
|
||||||
package com.example.hpostesting.presentation.usb_teminal
|
package com.example.hpostesting.presentation.usb_teminal
|
||||||
|
|
||||||
// Fragment Class
|
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@@ -25,145 +23,62 @@ import android.view.ViewGroup
|
|||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||||
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
|
import com.google.firebase.ktx.Firebase
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentUsbTerminalBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentUsbTerminalBinding
|
||||||
|
|
||||||
|
|
||||||
class UsbTerminalFragment : Fragment() {
|
class UsbTerminalFragment : Fragment() {
|
||||||
private lateinit var binding: FragmentUsbTerminalBinding
|
private lateinit var binding: FragmentUsbTerminalBinding
|
||||||
private val usbTerminalViewModel: UsbTerminalViewModel by activityViewModels()
|
private val usbTerminalViewModel: UsbTerminalViewModel by activityViewModels()
|
||||||
private lateinit var sharedPreferences: SharedPreferences
|
private lateinit var sharedPreferences: SharedPreferences
|
||||||
private var startListening = MutableLiveData(false)
|
private var startListening = MutableLiveData(false)
|
||||||
private var resultData = StringBuilder()
|
private var resultData: String = ""
|
||||||
private var commandQueue: MutableList<String> = mutableListOf()
|
|
||||||
private var currentCommand: String? = null
|
|
||||||
var executedCommands: MutableList<String> = mutableListOf()
|
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
||||||
): View {
|
): View {
|
||||||
binding = FragmentUsbTerminalBinding.inflate(inflater, container, false)
|
binding = FragmentUsbTerminalBinding.inflate(inflater, container, false)
|
||||||
sharedPreferences = requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
sharedPreferences =
|
||||||
|
requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
val pastCommands = (activity as? UsbTerminalActivity)?.getExecutedCommands() ?: emptyList()
|
|
||||||
if (pastCommands.isNotEmpty()) {
|
|
||||||
resumeCommands(pastCommands)
|
|
||||||
}
|
|
||||||
|
|
||||||
initViews()
|
initViews()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun initViews() {
|
private fun initViews() {
|
||||||
binding.messageCommand.movementMethod = ScrollingMovementMethod()
|
binding.messageCommand.movementMethod = ScrollingMovementMethod()
|
||||||
|
usbTerminalViewModel.messages.observe(viewLifecycleOwner) {
|
||||||
// Observe messages with proper formatting
|
binding.messageCommand.text = it
|
||||||
usbTerminalViewModel.messages.observe(viewLifecycleOwner) { message ->
|
|
||||||
binding.messageCommand.text = message
|
|
||||||
scrollToBottom()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.sendCommand.setOnClickListener {
|
binding.sendCommand.setOnClickListener {
|
||||||
val commands = binding.etCommands.text.toString().trim()
|
callCommand(binding.etCommands.text.trim().toString())
|
||||||
if (commands.isNotEmpty()) {
|
|
||||||
// Process entire command string
|
|
||||||
addToQueue(listOf(commands))
|
|
||||||
binding.etCommands.text.clear()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
binding.button.setOnClickListener{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
listenToHemoCube()
|
listenToHemoCube()
|
||||||
callCommand("I")
|
callCommand("I")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun scrollToBottom() {
|
|
||||||
binding.messageCommand.post {
|
|
||||||
val scrollAmount = binding.messageCommand.layout.getLineTop(binding.messageCommand.lineCount) -
|
|
||||||
binding.messageCommand.height
|
|
||||||
if (scrollAmount > 0) {
|
|
||||||
binding.messageCommand.scrollTo(0, scrollAmount)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun addToQueue(commands: List<String>) {
|
|
||||||
commandQueue.clear()
|
|
||||||
currentCommand = null
|
|
||||||
|
|
||||||
commandQueue.addAll(commands)
|
|
||||||
|
|
||||||
// Track commands in the activity
|
|
||||||
(activity as? UsbTerminalActivity)?.let { activity ->
|
|
||||||
commands.forEach { command ->
|
|
||||||
activity.addExecutedCommand(command)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
appendFormattedMessage("\nNew priority commands: ${commands.joinToString(" ")}")
|
|
||||||
processNextCommand()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private fun appendFormattedMessage(message: String) {
|
|
||||||
resultData.append("\n").append(message)
|
|
||||||
usbTerminalViewModel.messages.postValue(resultData.toString())
|
|
||||||
scrollToBottom()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun processNextCommand() {
|
|
||||||
if (currentCommand == null && commandQueue.isNotEmpty()) {
|
|
||||||
currentCommand = commandQueue.removeAt(0)
|
|
||||||
callCommand(currentCommand!!)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun callCommand(command: String) {
|
private fun callCommand(command: String) {
|
||||||
// Don't process if command was cleared
|
|
||||||
if (currentCommand == null) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
usbTerminalViewModel.progressBar.postValue(true)
|
usbTerminalViewModel.progressBar.postValue(true)
|
||||||
appendFormattedMessage("Sending command: $command \n")
|
(activity as UsbTerminalActivity).mService.sendAndListenToHemoCubeTxt(
|
||||||
|
command,
|
||||||
try {
|
object : UsbServiceListener {
|
||||||
(activity as UsbTerminalActivity).mService.sendAndListenToHemoCubeTxt(
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
command,
|
|
||||||
object : UsbServiceListener {
|
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
|
||||||
// Keep empty as per original code
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
|
|
||||||
appendFormattedMessage("Error sending command $command: ${e?.message ?: "Unknown error"}")
|
|
||||||
usbTerminalViewModel.progressBar.postValue(false)
|
|
||||||
currentCommand = null
|
|
||||||
|
|
||||||
|
|
||||||
processNextCommand()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
)
|
|
||||||
} catch (e: Exception) {
|
override fun onUsbError(e: Exception?) {
|
||||||
appendFormattedMessage("Error: ${e.localizedMessage}")
|
usbTerminalViewModel.progressBar.postValue(false)
|
||||||
usbTerminalViewModel.progressBar.postValue(false)
|
}
|
||||||
currentCommand = null
|
})
|
||||||
processNextCommand()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun listenToHemoCube() {
|
private fun listenToHemoCube() {
|
||||||
|
|
||||||
|
val fullReadOutput = StringBuilder()
|
||||||
startListening.postValue(true)
|
startListening.postValue(true)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -171,58 +86,20 @@ class UsbTerminalFragment : Fragment() {
|
|||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
data?.let {
|
data?.let {
|
||||||
val stringData = String(it)
|
val stringData = String(it)
|
||||||
resultData.append(stringData)
|
fullReadOutput.append(stringData)
|
||||||
|
resultData += stringData
|
||||||
activity?.runOnUiThread {
|
usbTerminalViewModel.messages.postValue(resultData)
|
||||||
usbTerminalViewModel.messages.postValue(resultData.toString())
|
|
||||||
scrollToBottom()
|
|
||||||
|
|
||||||
// Check for command completion
|
|
||||||
if (currentCommand != null && stringData.contains("${currentCommand}C")) {
|
|
||||||
currentCommand = null
|
|
||||||
usbTerminalViewModel.progressBar.postValue(false)
|
|
||||||
|
|
||||||
// If there are no more commands in queue, clear completion flags
|
|
||||||
if (commandQueue.isEmpty()) {
|
|
||||||
appendFormattedMessage("\nAll commands completed")
|
|
||||||
} else {
|
|
||||||
processNextCommand()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
activity?.runOnUiThread {
|
usbTerminalViewModel.messages.postValue(e!!.localizedMessage)
|
||||||
appendFormattedMessage("Error: ${e?.localizedMessage ?: "Unknown error"}")
|
usbTerminalViewModel.progressBar.postValue(false)
|
||||||
usbTerminalViewModel.progressBar.postValue(false)
|
|
||||||
currentCommand = null
|
|
||||||
processNextCommand()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
appendFormattedMessage("Error: ${e.localizedMessage}")
|
usbTerminalViewModel.messages.postValue(e.localizedMessage)
|
||||||
|
Firebase.crashlytics.recordException(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resumeCommands(pastCommands: List<String>) {
|
|
||||||
appendFormattedMessage("Resuming execution...")
|
|
||||||
pastCommands.forEach { command ->
|
|
||||||
if (!commandQueue.contains(command)) {
|
|
||||||
commandQueue.add(command)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
processNextCommand()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
override fun onDestroyView() {
|
|
||||||
super.onDestroyView()
|
|
||||||
startListening.value = false
|
|
||||||
resultData.clear()
|
|
||||||
commandQueue.clear()
|
|
||||||
currentCommand = null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -23,6 +23,8 @@ import javax.inject.Inject
|
|||||||
|
|
||||||
@HiltViewModel
|
@HiltViewModel
|
||||||
class UsbTerminalViewModel @Inject constructor(
|
class UsbTerminalViewModel @Inject constructor(
|
||||||
|
private val hemoCubeDao: HemoCubeDao,
|
||||||
|
private val repository: Repository,
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
var isServiceConnected = false
|
var isServiceConnected = false
|
||||||
val progressBar = MutableLiveData(false)
|
val progressBar = MutableLiveData(false)
|
||||||
|
|||||||
@@ -15,6 +15,6 @@ package com.example.hpostesting.presentation.utils
|
|||||||
|
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
|
|
||||||
fun interface DeviceCommunicationHandler {
|
interface DeviceCommunicationHandler {
|
||||||
fun sendAndListenToDevice(command: HemoCubeCommands, listener: UsbServiceListener)
|
fun sendAndListenToDevice(command: HemoCubeCommands, listener: UsbServiceListener)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,9 +26,16 @@ import io.nats.client.NKey
|
|||||||
import io.nats.client.Nats
|
import io.nats.client.Nats
|
||||||
import io.nats.client.Options
|
import io.nats.client.Options
|
||||||
import io.nats.client.support.SSLUtils
|
import io.nats.client.support.SSLUtils
|
||||||
|
import java.io.FileInputStream
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
import java.security.GeneralSecurityException
|
import java.security.GeneralSecurityException
|
||||||
|
import java.security.KeyStore
|
||||||
|
import java.security.SecureRandom
|
||||||
|
import java.security.cert.CertificateFactory
|
||||||
|
import javax.net.ssl.KeyManagerFactory
|
||||||
|
import javax.net.ssl.SSLContext
|
||||||
|
import javax.net.ssl.TrustManagerFactory
|
||||||
|
|
||||||
|
|
||||||
class NatsManager(datacollector: DashboardActivity) {
|
class NatsManager(datacollector: DashboardActivity) {
|
||||||
@@ -39,41 +46,41 @@ class NatsManager(datacollector: DashboardActivity) {
|
|||||||
var connect = false
|
var connect = false
|
||||||
var sharedPreferences = datacollector.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
var sharedPreferences = datacollector.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
|
|
||||||
// private fun createSSLContext(): SSLContext {
|
private fun createSSLContext(): SSLContext {
|
||||||
// val keyStorePassword = "prime24".toCharArray() // Change as necessary
|
val keyStorePassword = "prime24".toCharArray() // Change as necessary
|
||||||
// val clientCertPath = "/storage/sdcard0/Download/client.p12"
|
val clientCertPath = "/storage/sdcard0/Download/client.p12"
|
||||||
//
|
|
||||||
// // Load client certificate and key
|
// Load client certificate and key
|
||||||
// val keyStore = KeyStore.getInstance("PKCS12")
|
val keyStore = KeyStore.getInstance("PKCS12")
|
||||||
// FileInputStream(clientCertPath).use { keyStoreInputStream ->
|
FileInputStream(clientCertPath).use { keyStoreInputStream ->
|
||||||
// keyStore.load(keyStoreInputStream, keyStorePassword)
|
keyStore.load(keyStoreInputStream, keyStorePassword)
|
||||||
// }
|
}
|
||||||
// val caCertPath =
|
val caCertPath =
|
||||||
// "/storage/sdcard0/Android/data/in.sminnovations.hpostesting.quality/files/NATS/clientCertificate/client-cert.pem"
|
"/storage/sdcard0/Android/data/in.sminnovations.hpostesting.quality/files/NATS/clientCertificate/client-cert.pem"
|
||||||
// val caCert = FileInputStream(caCertPath).use { inputStream ->
|
val caCert = FileInputStream(caCertPath).use { inputStream ->
|
||||||
// val certificateFactory = CertificateFactory.getInstance("X.509")
|
val certificateFactory = CertificateFactory.getInstance("X.509")
|
||||||
// certificateFactory.generateCertificate(inputStream)
|
certificateFactory.generateCertificate(inputStream)
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// val trustStore = KeyStore.getInstance(KeyStore.getDefaultType()).apply {
|
val trustStore = KeyStore.getInstance(KeyStore.getDefaultType()).apply {
|
||||||
// load(null, null) // Initialize the keystore
|
load(null, null) // Initialize the keystore
|
||||||
// setCertificateEntry("caCert", caCert) // Add the CA certificate
|
setCertificateEntry("caCert", caCert) // Add the CA certificate
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Initialize key manager factory
|
// Initialize key manager factory
|
||||||
// val kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm())
|
val kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm())
|
||||||
// kmf.init(keyStore, keyStorePassword)
|
kmf.init(keyStore, keyStorePassword)
|
||||||
//
|
|
||||||
// // Initialize trust manager factory
|
// Initialize trust manager factory
|
||||||
// val tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm())
|
val tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm())
|
||||||
// tmf.init(trustStore)
|
tmf.init(trustStore)
|
||||||
//
|
|
||||||
// // Initialize SSLContext
|
// Initialize SSLContext
|
||||||
// val sslContext = SSLContext.getInstance("TLS")
|
val sslContext = SSLContext.getInstance("TLS")
|
||||||
// sslContext.init(kmf.keyManagers, tmf.trustManagers, SecureRandom())
|
sslContext.init(kmf.keyManagers, tmf.trustManagers, SecureRandom())
|
||||||
//
|
|
||||||
// return sslContext
|
return sslContext
|
||||||
// }
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.O)
|
@RequiresApi(Build.VERSION_CODES.O)
|
||||||
fun connect() {
|
fun connect() {
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
|
||||||
|
|
||||||
<path android:fillColor="@android:color/white" android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96z"/>
|
|
||||||
|
|
||||||
</vector>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
|
||||||
|
|
||||||
<path android:fillColor="@android:color/white" android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96zM10,17l-3.5,-3.5 1.41,-1.41L10,14.17 15.18,9l1.41,1.41L10,17z"/>
|
|
||||||
|
|
||||||
</vector>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
|
||||||
|
|
||||||
<path android:fillColor="@android:color/white" android:pathData="M21.5,14.98c-0.02,0 -0.03,0 -0.05,0.01C21.2,13.3 19.76,12 18,12c-1.4,0 -2.6,0.83 -3.16,2.02C13.26,14.1 12,15.4 12,17c0,1.66 1.34,3 3,3l6.5,-0.02c1.38,0 2.5,-1.12 2.5,-2.5S22.88,14.98 21.5,14.98zM10,4.26v2.09C7.67,7.18 6,9.39 6,12c0,1.77 0.78,3.34 2,4.44V14h2v6H4v-2h2.73C5.06,16.54 4,14.4 4,12C4,8.27 6.55,5.15 10,4.26zM20,6h-2.73c1.43,1.26 2.41,3.01 2.66,5l-2.02,0C17.68,9.64 16.98,8.45 16,7.56V10h-2V4h6V6z"/>
|
|
||||||
|
|
||||||
</vector>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
|
||||||
|
|
||||||
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z"/>
|
|
||||||
|
|
||||||
</vector>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
|
||||||
|
|
||||||
<path android:fillColor="@android:color/white" android:pathData="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z"/>
|
|
||||||
|
|
||||||
</vector>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
|
||||||
|
|
||||||
<path android:fillColor="@android:color/white" android:pathData="M12.87,15.07l-2.54,-2.51 0.03,-0.03c1.74,-1.94 2.98,-4.17 3.71,-6.53L17,6L17,4h-7L10,2L8,2v2L1,4v1.99h11.17C11.5,7.92 10.44,9.75 9,11.35 8.07,10.32 7.3,9.19 6.69,8h-2c0.73,1.63 1.73,3.17 2.98,4.56l-5.09,5.02L4,19l5,-5 3.11,3.11 0.76,-2.04zM18.5,10h-2L12,22h2l1.12,-3h4.75L21,22h2l-4.5,-12zM15.88,17l1.62,-4.33L19.12,17h-3.24z"/>
|
|
||||||
|
|
||||||
</vector>
|
|
||||||
@@ -45,7 +45,6 @@
|
|||||||
android:layout_marginHorizontal="24dp"
|
android:layout_marginHorizontal="24dp"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:text="@string/scan_qr_code_of_the_kit"
|
android:text="@string/scan_qr_code_of_the_kit"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/app_bar_layout" />
|
app:layout_constraintTop_toBottomOf="@id/app_bar_layout" />
|
||||||
|
|
||||||
@@ -59,7 +58,6 @@
|
|||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
app:backgroundTint="@color/blue_app_light"
|
app:backgroundTint="@color/blue_app_light"
|
||||||
app:cornerRadius="100dp"
|
app:cornerRadius="100dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tv_title" />
|
app:layout_constraintTop_toBottomOf="@+id/tv_title" />
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,6 @@
|
|||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
app:backgroundTint="@color/blue_app_light"
|
app:backgroundTint="@color/blue_app_light"
|
||||||
app:cornerRadius="100dp"
|
app:cornerRadius="100dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tv_title" />
|
app:layout_constraintTop_toBottomOf="@+id/tv_title" />
|
||||||
|
|
||||||
@@ -104,9 +103,9 @@
|
|||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:text="Refresh"
|
android:text="Refresh"
|
||||||
android:textColor="@color/white"
|
|
||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
android:textColor="@color/white"
|
||||||
|
app:layout_constraintEnd_toEndOf="@id/btn_scan_now"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_scan_now" />
|
app:layout_constraintTop_toBottomOf="@id/btn_scan_now" />
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,6 @@
|
|||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
app:backgroundTint="@color/blue_app_light"
|
app:backgroundTint="@color/blue_app_light"
|
||||||
app:cornerRadius="100dp"
|
app:cornerRadius="100dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/tv_title2" />
|
app:layout_constraintTop_toBottomOf="@+id/tv_title2" />
|
||||||
|
|
||||||
|
|||||||
@@ -11,51 +11,59 @@
|
|||||||
~ // from ShanMukha Innovations Pvt. Ltd.
|
~ // from ShanMukha Innovations Pvt. Ltd.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout
|
||||||
|
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_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:layout_marginStart="8dp"
|
||||||
android:padding="16dp">
|
android:layout_marginEnd="8dp"
|
||||||
|
>
|
||||||
<Button
|
|
||||||
android:id="@+id/button"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Clar All Commands" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/messageCommand"
|
android:id="@+id/message_command"
|
||||||
|
style="@style/title1_1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_marginTop="10dp"
|
||||||
android:background="@android:color/darker_gray"
|
android:gravity="start|bottom"
|
||||||
android:padding="8dp"
|
android:text="Start"
|
||||||
android:scrollbars="vertical"
|
android:scrollbars = "vertical"
|
||||||
android:textColor="@android:color/white" />
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
<LinearLayout
|
android:layout_above="@+id/ll_commands"
|
||||||
|
android:visibility="visible"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="18sp"
|
||||||
|
/>
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/ll_commands"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/etCommands"
|
android:id="@+id/et_commands"
|
||||||
android:layout_width="0dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_marginTop="10dp"
|
||||||
android:hint="Enter command"
|
android:hint="@string/commands"
|
||||||
android:inputType="text"
|
android:layout_alignParentStart="true"
|
||||||
android:maxLines="1"
|
android:imeOptions="actionDone"
|
||||||
android:minHeight="48dp" />
|
android:textSize="18sp"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
/>
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/send_command"
|
||||||
|
android:layout_width="32dp"
|
||||||
|
android:layout_height="26dp"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:src="@drawable/ic_baseline_send_24"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/sendCommand"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:text="Send" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|||||||
@@ -1,38 +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"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<!-- RadioGroup to select servers -->
|
|
||||||
<RadioGroup
|
|
||||||
android:id="@+id/radioGroupServers"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<!-- Radio Buttons for each server option -->
|
|
||||||
<RadioButton
|
|
||||||
android:id="@+id/radioButtonInternal"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Internal" />
|
|
||||||
|
|
||||||
<RadioButton
|
|
||||||
android:id="@+id/radioButtonClinical"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Clinical" />
|
|
||||||
|
|
||||||
<RadioButton
|
|
||||||
android:id="@+id/radioButtonCustomer"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Customer" />
|
|
||||||
|
|
||||||
</RadioGroup>
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
@@ -289,6 +289,8 @@
|
|||||||
<string name="check_cuvette">Checking cuvette presence</string>
|
<string name="check_cuvette">Checking cuvette presence</string>
|
||||||
<string name="cuvette_present">Cuvette present</string>
|
<string name="cuvette_present">Cuvette present</string>
|
||||||
<string name="cuvette_absent">Cuvette absent</string>
|
<string name="cuvette_absent">Cuvette absent</string>
|
||||||
|
<string name="cuvette_presentt">Cuvette Present , Please Remove Cuvette And Try Again</string>
|
||||||
|
<string name="cuvette_absentt">Cuvette Absent,Now You Can Submit</string>
|
||||||
<string name="retry">Retry</string>
|
<string name="retry">Retry</string>
|
||||||
<string name="Firefox">Firefox</string>
|
<string name="Firefox">Firefox</string>
|
||||||
<string name="Files">Files</string>
|
<string name="Files">Files</string>
|
||||||
@@ -305,8 +307,4 @@
|
|||||||
<string name="quick_capture">Quick Capture</string>
|
<string name="quick_capture">Quick Capture</string>
|
||||||
<string name="reset_password_for_this_device">Reset password for this device</string>
|
<string name="reset_password_for_this_device">Reset password for this device</string>
|
||||||
<string name="calibrate_device">Calibrate the device</string>
|
<string name="calibrate_device">Calibrate the device</string>
|
||||||
<string name="cuvette_presentt">Cuvette Present , Please Remove Cuvette And Try Again</string>
|
|
||||||
<string name="cuvette_absentt">Cuvette Absent,Now You Can Submit</string>
|
|
||||||
<string name="DateTimeFormat">yyyy-MM-dd HH:mm:ss</string>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -213,7 +213,7 @@
|
|||||||
<string name="start_incubation">ಇನ್ಕ್ಯುಬೇಷನ್ ಪ್ರಾರಂಭಿಸಿ</string>
|
<string name="start_incubation">ಇನ್ಕ್ಯುಬೇಷನ್ ಪ್ರಾರಂಭಿಸಿ</string>
|
||||||
<string name="check_buffer">ಬಫರ್ ಚೆಕ್ ಮಾಡಿ</string>
|
<string name="check_buffer">ಬಫರ್ ಚೆಕ್ ಮಾಡಿ</string>
|
||||||
<!-- Kannada Translations -->
|
<!-- Kannada Translations -->
|
||||||
<string name="low_battery_warning">ಬ್ಯಾಟರಿ ಸ್ತರ 20% ಕ್ಕಿಂತ ಕಡಿಮೆಯಾಗಿದೆ, ಟೆಸ್ಟ್ ಮುಂದುವರಿಸಲು ದಯವಿಟ್ಟು ಡಿವೈಸ ಚಾರ್ಜ್ ಮಾಡಿ</string>
|
<string name="low_battery_warning">ಬ್ಯಾಟರಿ ಸ್ತರ 40% ಕ್ಕಿಂತ ಕಡಿಮೆಯಾಗಿದೆ, ಟೆಸ್ಟ್ ಮುಂದುವರಿಸಲು ದಯವಿಟ್ಟು ಡಿವೈಸ ಚಾರ್ಜ್ ಮಾಡಿ</string>
|
||||||
<string name="test_already_conducted">ಈ ಬಳಕೆದಾರನ ಮೇಲೆ ಟೆಸ್ಟ್ ಮುಗಿದಿದೆ </string>
|
<string name="test_already_conducted">ಈ ಬಳಕೆದಾರನ ಮೇಲೆ ಟೆಸ್ಟ್ ಮುಗಿದಿದೆ </string>
|
||||||
<string name="incubation_not_completed">15 ನಿಮಿಷಗಳ ಇನ್ಕ್ಯೂಬೇಷನ್ ಇನ್ನು ಪೂರ್ತಿ ಆಗಿಲ್ಲ್ಲ</string>
|
<string name="incubation_not_completed">15 ನಿಮಿಷಗಳ ಇನ್ಕ್ಯೂಬೇಷನ್ ಇನ್ನು ಪೂರ್ತಿ ಆಗಿಲ್ಲ್ಲ</string>
|
||||||
<string name="incubation_crossed_30_minutes">ಇನ್ಕ್ಯೂಬೇಷನ್ 30 ನಿಮಿಷಗಳನ್ನು ದಾಟಿದೆ, ಇನ್ನೊಮ್ಮೆ ಇನ್ಕ್ಯೂಬೇಷನ್ ಮಾಡಬೇಕಾಗಿದೆ</string>
|
<string name="incubation_crossed_30_minutes">ಇನ್ಕ್ಯೂಬೇಷನ್ 30 ನಿಮಿಷಗಳನ್ನು ದಾಟಿದೆ, ಇನ್ನೊಮ್ಮೆ ಇನ್ಕ್ಯೂಬೇಷನ್ ಮಾಡಬೇಕಾಗಿದೆ</string>
|
||||||
@@ -288,6 +288,8 @@
|
|||||||
<string name="check_cuvette">ಕುವೆಟ್ ಇರುವಿಕೆಯನ್ನು ಪರಿಶೀಲಿಸಲಾಗುತ್ತಿದೆ</string>
|
<string name="check_cuvette">ಕುವೆಟ್ ಇರುವಿಕೆಯನ್ನು ಪರಿಶೀಲಿಸಲಾಗುತ್ತಿದೆ</string>
|
||||||
<string name="cuvette_present">ಕುವೆಟ್ಟೆ ಇರುತ್ತದೆ</string>
|
<string name="cuvette_present">ಕುವೆಟ್ಟೆ ಇರುತ್ತದೆ</string>
|
||||||
<string name="cuvette_absent">ಕುವೆಟ್ಟೆ ಇರುವುದಿಲ್ಲ </string>
|
<string name="cuvette_absent">ಕುವೆಟ್ಟೆ ಇರುವುದಿಲ್ಲ </string>
|
||||||
|
<string name="cuvette_presentt">Cuvette Present , Please Remove Cuvette And Try Again</string>
|
||||||
|
<string name="cuvette_absentt">Cuvette Absent,Now You Can Submit</string>
|
||||||
<string name="retry">ಮರುಪ್ರಯತ್ನಿಸಿ</string>
|
<string name="retry">ಮರುಪ್ರಯತ್ನಿಸಿ</string>
|
||||||
<string name="Firefox">ಫೈರ್ಫಾಕ್ಸ್</string>
|
<string name="Firefox">ಫೈರ್ಫಾಕ್ಸ್</string>
|
||||||
<string name="Files">ಫೈಲ್</string>
|
<string name="Files">ಫೈಲ್</string>
|
||||||
@@ -304,10 +306,6 @@
|
|||||||
<string name="quick_capture">ತ್ವರಿತ ಕ್ಯಾಪ್ಚರ್</string>
|
<string name="quick_capture">ತ್ವರಿತ ಕ್ಯಾಪ್ಚರ್</string>
|
||||||
<string name="reset_password_for_this_device">ಈ ಸಾಧನಕ್ಕಾಗಿ ಪಾಸ್ವರ್ಡ್ ಅನ್ನು ಮರುಹೊಂದಿಸಿ</string>
|
<string name="reset_password_for_this_device">ಈ ಸಾಧನಕ್ಕಾಗಿ ಪಾಸ್ವರ್ಡ್ ಅನ್ನು ಮರುಹೊಂದಿಸಿ</string>
|
||||||
<string name="calibrate_device">ಸಾಧನವನ್ನು ಮಾಪನಾಂಕ ಮಾಡಿ</string>
|
<string name="calibrate_device">ಸಾಧನವನ್ನು ಮಾಪನಾಂಕ ಮಾಡಿ</string>
|
||||||
<string name="cuvette_presentt">Cuvette Present , Please Remove Cuvette And Try Again</string>
|
|
||||||
<string name="cuvette_absentt">Cuvette Absent,Now You Can Submit</string>
|
|
||||||
<string name="DateTimeFormat">yyyy-MM-dd HH:mm:ss</string>
|
|
||||||
|
|
||||||
<!-- Add translations for other strings -->
|
<!-- Add translations for other strings -->
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">HPOS ALPHA Testing</string>
|
<string name="app_name">HPOS Testing</string>
|
||||||
|
|
||||||
<string-array name="instrument">
|
<string-array name="instrument">
|
||||||
<item>TestRight</item>
|
<item>TestRight</item>
|
||||||
@@ -219,7 +219,7 @@
|
|||||||
<string name="all_registered_user_are_tested_successfully">All registered user are tested successfully</string>
|
<string name="all_registered_user_are_tested_successfully">All registered user are tested successfully</string>
|
||||||
<string name="start_incubation">Incubate</string>
|
<string name="start_incubation">Incubate</string>
|
||||||
<string name="check_buffer">Check Buffer</string>
|
<string name="check_buffer">Check Buffer</string>
|
||||||
<string name="low_battery_warning">Battery level is low than 20%, please charge the device to continue testing</string>
|
<string name="low_battery_warning">Battery level is low than 40%, please charge the device to continue testing</string>
|
||||||
<string name="test_already_conducted">Test has been already conducted for this user</string>
|
<string name="test_already_conducted">Test has been already conducted for this user</string>
|
||||||
<string name="incubation_not_completed">Incubation has not completed 15 minutes</string>
|
<string name="incubation_not_completed">Incubation has not completed 15 minutes</string>
|
||||||
<string name="incubation_crossed_30_minutes">Incubation crossed 30 minutes, need to repeat the incubation</string>
|
<string name="incubation_crossed_30_minutes">Incubation crossed 30 minutes, need to repeat the incubation</string>
|
||||||
@@ -291,6 +291,8 @@
|
|||||||
<string name="check_cuvette">Checking cuvette presence</string>
|
<string name="check_cuvette">Checking cuvette presence</string>
|
||||||
<string name="cuvette_present">Cuvette present , you can start the test</string>
|
<string name="cuvette_present">Cuvette present , you can start the test</string>
|
||||||
<string name="cuvette_absent">Cuvette is absent , please place the cuvette and retry again</string>
|
<string name="cuvette_absent">Cuvette is absent , please place the cuvette and retry again</string>
|
||||||
|
<string name="cuvette_presentt">Cuvette Present , Please Remove Cuvette And Try Again</string>
|
||||||
|
<string name="cuvette_absentt">Cuvette Absent,Now You Can Submit</string>
|
||||||
<string name="retry">Retry again</string>
|
<string name="retry">Retry again</string>
|
||||||
<string name="usb_terminal">Usb Terminal</string>
|
<string name="usb_terminal">Usb Terminal</string>
|
||||||
<string name="menu_about">About</string>
|
<string name="menu_about">About</string>
|
||||||
@@ -305,8 +307,4 @@
|
|||||||
<string name="quick_capture">Quick Capture</string>
|
<string name="quick_capture">Quick Capture</string>
|
||||||
<string name="reset_password_for_this_device">Reset password for this device</string>
|
<string name="reset_password_for_this_device">Reset password for this device</string>
|
||||||
<string name="calibrate_device">Calibrate Device</string>
|
<string name="calibrate_device">Calibrate Device</string>
|
||||||
<string name="cuvette_presentt">Cuvette Present , Please Remove Cuvette And Try Again</string>
|
|
||||||
<string name="cuvette_absentt">Cuvette Absent,Now You Can Submit</string>
|
|
||||||
<string name="DateTimeFormat">yyyy-MM-dd HH:mm:ss</string>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -3,7 +3,7 @@ buildscript {
|
|||||||
kotlin_version = '1.8.21'
|
kotlin_version = '1.8.21'
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:8.5.0'
|
classpath 'com.android.tools.build:gradle:8.4.0'
|
||||||
classpath 'com.google.gms:google-services:4.4.1'
|
classpath 'com.google.gms:google-services:4.4.1'
|
||||||
classpath 'com.google.firebase:firebase-appdistribution-gradle:4.1.0'
|
classpath 'com.google.firebase:firebase-appdistribution-gradle:4.1.0'
|
||||||
}
|
}
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -14,6 +14,6 @@
|
|||||||
#Mon Mar 04 17:08:24 IST 2024
|
#Mon Mar 04 17:08:24 IST 2024
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
3768
hs_err_pid3592.log
Normal file
3768
hs_err_pid3592.log
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user