Compare commits
3 Commits
dev-server
...
dev-server
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7785f24441 | ||
|
|
5f2d5fed85 | ||
|
|
c312bf0f39 |
@@ -1,13 +1,5 @@
|
|||||||
# Latest hpos app version
|
|
||||||
## current version : 2.1.132
|
|
||||||
|
|
||||||
### Release key
|
### Release key
|
||||||
|
|
||||||
key0: prime24
|
key0: prime24
|
||||||
|
|
||||||
### Version 133.3
|
|
||||||
|
|
||||||
Printer not added yet
|
|
||||||
|
|
||||||
//update it when it is completed
|
|
||||||
|
|
||||||
@@ -18,16 +18,11 @@ android {
|
|||||||
// server -> for server switching for internal test
|
// server -> for server switching for internal test
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "in.sminnovations.hpostesting.server"
|
applicationId "in.sminnovations.hpostesting.server"
|
||||||
minSdk 30
|
minSdk 21
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 138
|
versionCode 133
|
||||||
versionName "2.1.133.3"
|
versionName "2.1.131"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
externalNativeBuild {
|
|
||||||
cmake {
|
|
||||||
cppFlags ''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -35,7 +30,6 @@ android {
|
|||||||
release {
|
release {
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
signingConfig signingConfigs.debug
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
@@ -59,12 +53,6 @@ android {
|
|||||||
packagingOptions {
|
packagingOptions {
|
||||||
exclude 'mockito-extensions/org.mockito.plugins.MockMaker'
|
exclude 'mockito-extensions/org.mockito.plugins.MockMaker'
|
||||||
}
|
}
|
||||||
externalNativeBuild {
|
|
||||||
cmake {
|
|
||||||
path file('src/main/cpp/CMakeLists.txt')
|
|
||||||
version '3.22.1'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// testOptions {
|
// testOptions {
|
||||||
// unitTests {
|
// unitTests {
|
||||||
// includeAndroidResources = true
|
// includeAndroidResources = true
|
||||||
|
|||||||
@@ -1,33 +1,33 @@
|
|||||||
{
|
{
|
||||||
"project_info": {
|
"project_info": {
|
||||||
"project_number": "1012719870714",
|
"project_number": "650071678820",
|
||||||
"project_id": "hpos-prod",
|
"project_id": "hpos-af3cc",
|
||||||
"storage_bucket": "hpos-prod.appspot.com"
|
"storage_bucket": "hpos-af3cc.appspot.com"
|
||||||
},
|
},
|
||||||
"client": [
|
"client": [
|
||||||
{
|
{
|
||||||
"client_info": {
|
"client_info": {
|
||||||
"mobilesdk_app_id": "1:1012719870714:android:d8d7c962d96f4097de5f43",
|
"mobilesdk_app_id": "1:650071678820:android:f6fd45e2f6a63aef6c6471",
|
||||||
"android_client_info": {
|
"android_client_info": {
|
||||||
"package_name": "in.sminnovations.hpostesting.server"
|
"package_name": "in.sminnovations.hpostesting.server"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"oauth_client": [
|
"oauth_client": [
|
||||||
{
|
{
|
||||||
"client_id": "1012719870714-uli6cdjea3lfnnueh6e4r15i10ei1vlj.apps.googleusercontent.com",
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
"client_type": 3
|
"client_type": 3
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"api_key": [
|
"api_key": [
|
||||||
{
|
{
|
||||||
"current_key": "AIzaSyA_O0oZGzy3Kiw9fiLQ3OFPME-xQJP88vs"
|
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"services": {
|
"services": {
|
||||||
"appinvite_service": {
|
"appinvite_service": {
|
||||||
"other_platform_oauth_client": [
|
"other_platform_oauth_client": [
|
||||||
{
|
{
|
||||||
"client_id": "1012719870714-uli6cdjea3lfnnueh6e4r15i10ei1vlj.apps.googleusercontent.com",
|
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
|
||||||
"client_type": 3
|
"client_type": 3
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
37
app/release/output-metadata.json
Normal file
37
app/release/output-metadata.json
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"version": 3,
|
||||||
|
"artifactType": {
|
||||||
|
"type": "APK",
|
||||||
|
"kind": "Directory"
|
||||||
|
},
|
||||||
|
"applicationId": "in.sminnovations.hpostesting.server",
|
||||||
|
"variantName": "release",
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"type": "SINGLE",
|
||||||
|
"filters": [],
|
||||||
|
"attributes": [],
|
||||||
|
"versionCode": 133,
|
||||||
|
"versionName": "2.1.131",
|
||||||
|
"outputFile": "app-release.apk"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"elementType": "File",
|
||||||
|
"baselineProfiles": [
|
||||||
|
{
|
||||||
|
"minApi": 28,
|
||||||
|
"maxApi": 30,
|
||||||
|
"baselineProfiles": [
|
||||||
|
"baselineProfiles/1/app-release.dm"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minApi": 31,
|
||||||
|
"maxApi": 2147483647,
|
||||||
|
"baselineProfiles": [
|
||||||
|
"baselineProfiles/0/app-release.dm"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"minSdkVersionForDexing": 21
|
||||||
|
}
|
||||||
@@ -24,12 +24,13 @@
|
|||||||
<uses-feature android:name="android.hardware.usb.host" />
|
<uses-feature android:name="android.hardware.usb.host" />
|
||||||
|
|
||||||
<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.GET_ACCOUNTS" />
|
||||||
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
|
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
|
||||||
<uses-permission
|
<uses-permission android:name="android.permission.ACCOUNT_MANAGER"
|
||||||
android:name="android.permission.ACCOUNT_MANAGER"
|
|
||||||
tools:ignore="ProtectedPermissions" />
|
tools:ignore="ProtectedPermissions" />
|
||||||
|
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name="com.example.hpostesting.HPOSTestingApplication"
|
android:name="com.example.hpostesting.HPOSTestingApplication"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
@@ -218,4 +219,5 @@
|
|||||||
android:resource="@xml/file_paths" />
|
android:resource="@xml/file_paths" />
|
||||||
</provider>
|
</provider>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
|
|
||||||
cmake_minimum_required(VERSION 3.18.1)
|
|
||||||
|
|
||||||
project("native-server")
|
|
||||||
|
|
||||||
# Create the shared library from server.cpp
|
|
||||||
add_library(
|
|
||||||
native-server
|
|
||||||
SHARED
|
|
||||||
server.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
# Find Android logging library
|
|
||||||
find_library(
|
|
||||||
log-lib
|
|
||||||
log
|
|
||||||
)
|
|
||||||
|
|
||||||
# Link logging library to our native lib
|
|
||||||
target_link_libraries(
|
|
||||||
native-server
|
|
||||||
${log-lib}
|
|
||||||
)
|
|
||||||
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
#include <jni.h>
|
|
||||||
#include <string>
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
std::vector<std::pair<int, std::pair<std::string, std::unordered_map<std::string, std::string>>>> firebaseDataOrdered = {
|
|
||||||
{0, {"dev", {{"apiKey", "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"}, {"appId", "1:650071678820:android:a53292637abb7c0d6c6471"}, {"projectId", "hpos-af3cc"}, {"storageBucket", "hpos-af3cc.appspot.com"}}}},
|
|
||||||
{1, {"qc-qa", {{"apiKey", "AIzaSyC4d4GhWHr_NMJAeBvnztQ_yQ3Qe9MAnLs"}, {"appId", "1:1004619739289:android:3dbcefb10ea99654e5c808"}, {"projectId", "hpos-qa"}, {"storageBucket", "hpos-qa.appspot.com"}}}},
|
|
||||||
{2, {"prod", {{"apiKey", "AIzaSyA_O0oZGzy3Kiw9fiLQ3OFPME-xQJP88vs"}, {"appId", "1:1012719870714:android:d8d7c962d96f4097de5f43"}, {"projectId", "hpos-prod"}, {"storageBucket", "hpos-prod.appspot.com"}}}},
|
|
||||||
{3, {"pre prod", {{"apiKey", "AIzaSyDYySi27LioZGNisP1NfnNU5inJX_0FT38"}, {"appId", "1:121176529204:android:e6841fdac57bdc95bbed61"}, {"projectId", "hpos-preprod"}, {"storageBucket", "hpos-preprod.appspot.com"}}}},
|
|
||||||
{4, {"SMI R&D", {{"apiKey", "AIzaSyAVxpilbB804iRCCpMBDjjmdZhQguctGHM"}, {"appId", "1:327771387914:android:a3b4ed2e42ea6e38dc87f3"}, {"projectId", "hposrandd"}, {"storageBucket", "hposrandd.firebasestorage.app"}}}},
|
|
||||||
{5, {"molbio", {{"apiKey", "molbio"}, {"appId", "molbio"}, {"projectId", "molbio"}, {"storageBucket", "molbio"}}}}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
JNIEXPORT jobject JNICALL
|
|
||||||
Java_com_example_hpostesting_firebase_FirebaseManager_getFirebaseDataMap(JNIEnv *env,jobject thiz) {
|
|
||||||
jclass mapClass = env->FindClass("java/util/LinkedHashMap");
|
|
||||||
jmethodID init = env->GetMethodID(mapClass, "<init>", "()V");
|
|
||||||
jmethodID put = env->GetMethodID(mapClass, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
|
|
||||||
jobject outerMap = env->NewObject(mapClass, init);
|
|
||||||
|
|
||||||
for (const auto &entry : firebaseDataOrdered) {
|
|
||||||
int order = entry.first;
|
|
||||||
const std::string &outerKeyStr = entry.second.first;
|
|
||||||
const auto &innerMapData = entry.second.second;
|
|
||||||
|
|
||||||
jobject innerMap = env->NewObject(mapClass, init);
|
|
||||||
// "int" field for order
|
|
||||||
|
|
||||||
jstring intKey = env->NewStringUTF("int");
|
|
||||||
jstring intValue = env->NewStringUTF(std::to_string(order).c_str());
|
|
||||||
env->CallObjectMethod(innerMap, put, intKey, intValue);
|
|
||||||
env->DeleteLocalRef(intKey);
|
|
||||||
env->DeleteLocalRef(intValue);
|
|
||||||
|
|
||||||
// actual firebase config keys
|
|
||||||
for (const auto &innerPair : innerMapData) {
|
|
||||||
jstring key = env->NewStringUTF(innerPair.first.c_str());
|
|
||||||
jstring value = env->NewStringUTF(innerPair.second.c_str());
|
|
||||||
env->CallObjectMethod(innerMap, put, key, value);
|
|
||||||
env->DeleteLocalRef(key);
|
|
||||||
env->DeleteLocalRef(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
jstring outerKey = env->NewStringUTF(outerKeyStr.c_str());
|
|
||||||
env->CallObjectMethod(outerMap, put, outerKey, innerMap);
|
|
||||||
env->DeleteLocalRef(outerKey);
|
|
||||||
env->DeleteLocalRef(innerMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
return outerMap;
|
|
||||||
}
|
|
||||||
@@ -15,6 +15,7 @@ package com.example.hpostesting
|
|||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import com.example.hpostesting.firebase.FirebaseManager
|
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
|
||||||
@@ -22,16 +23,8 @@ import kotlinx.coroutines.Dispatchers
|
|||||||
import kotlinx.coroutines.SupervisorJob
|
import kotlinx.coroutines.SupervisorJob
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
|
||||||
@HiltAndroidApp
|
@HiltAndroidApp
|
||||||
class HPOSTestingApplication : Application() {
|
class HPOSTestingApplication : Application() {
|
||||||
companion object {
|
|
||||||
init {
|
|
||||||
System.loadLibrary("native-server")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var firebaseManager: FirebaseManager
|
lateinit var firebaseManager: FirebaseManager
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
@@ -46,5 +39,4 @@ class HPOSTestingApplication : Application() {
|
|||||||
val firestore = firebaseManager.getCurrentFirestore()
|
val firestore = firebaseManager.getCurrentFirestore()
|
||||||
firestore.firestoreSettings = firestoreSettings
|
firestore.firestoreSettings = firestoreSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -32,6 +32,7 @@ import retrofit2.http.PUT
|
|||||||
import retrofit2.http.Part
|
import retrofit2.http.Part
|
||||||
|
|
||||||
interface MolbioResultApi {
|
interface MolbioResultApi {
|
||||||
|
|
||||||
@PUT("deviceService/results/HPOS")
|
@PUT("deviceService/results/HPOS")
|
||||||
suspend fun uploadResults(
|
suspend fun uploadResults(
|
||||||
@Body molbioV2ResultRequest: MolbioV2ResultRequest,
|
@Body molbioV2ResultRequest: MolbioV2ResultRequest,
|
||||||
@@ -46,7 +47,6 @@ interface MolbioResultApi {
|
|||||||
// suspend fun deviceUpdate(
|
// suspend fun deviceUpdate(
|
||||||
// @Body deviceUpdateRequest: DeviceUpdateRequest,
|
// @Body deviceUpdateRequest: DeviceUpdateRequest,
|
||||||
// ): ResponseBody
|
// ): ResponseBody
|
||||||
|
|
||||||
@POST("deviceService/device/getUpdate")
|
@POST("deviceService/device/getUpdate")
|
||||||
suspend fun deviceUpdate(
|
suspend fun deviceUpdate(
|
||||||
@Body deviceUpdateRequest: DeviceUpdateRequest,
|
@Body deviceUpdateRequest: DeviceUpdateRequest,
|
||||||
@@ -62,6 +62,7 @@ interface MolbioResultApi {
|
|||||||
@Part logFile: MultipartBody.Part,
|
@Part logFile: MultipartBody.Part,
|
||||||
): UploadLogsResponse
|
): UploadLogsResponse
|
||||||
|
|
||||||
|
|
||||||
@PUT("deviceService/device/uploadDeviceDiagnostics")
|
@PUT("deviceService/device/uploadDeviceDiagnostics")
|
||||||
suspend fun deviceDiagnostics(
|
suspend fun deviceDiagnostics(
|
||||||
@Body deviceDiagnosticsRequest: DeviceDiagnosticsRequest
|
@Body deviceDiagnosticsRequest: DeviceDiagnosticsRequest
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ object Constants {
|
|||||||
const val DOCUMENT_ID_FOR_UPDATE ="2o71vBKLqdgEKYtFG8Lb"
|
const val DOCUMENT_ID_FOR_UPDATE ="2o71vBKLqdgEKYtFG8Lb"
|
||||||
const val ABHA_APP_PACKAGE = "in.ndhm.phr"
|
const val ABHA_APP_PACKAGE = "in.ndhm.phr"
|
||||||
|
|
||||||
var MOLBIO_INTEGRATION = true
|
const val MOLBIO_INTEGRATION = false
|
||||||
var FIREBASE_INTEGRATION = false
|
const val FIREBASE_INTEGRATION = true
|
||||||
const val deviceProvisionEmail = "HPOS_provisioner@bigtec.co.in"
|
const val deviceProvisionEmail = "HPOS_provisioner@bigtec.co.in"
|
||||||
const val deviceProvisionPassword = "f2ab0e7f9d69"
|
const val deviceProvisionPassword = "f2ab0e7f9d69"
|
||||||
const val DEVICE_ID_API = "deviceIDAPI"
|
const val DEVICE_ID_API = "deviceIDAPI"
|
||||||
@@ -44,9 +44,9 @@ object Constants {
|
|||||||
const val DELAY_BETWEEN_COMMANDS: Long = 1000
|
const val DELAY_BETWEEN_COMMANDS: Long = 1000
|
||||||
|
|
||||||
const val TEST_RIGHT_TOTAL_PIXEL = 3694
|
const val TEST_RIGHT_TOTAL_PIXEL = 3694
|
||||||
|
|
||||||
const val MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE = 34
|
const val MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE = 34
|
||||||
const val MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE10MM = 9
|
const val MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE10MM = 9
|
||||||
const val MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE10MM_RANDD= 129
|
|
||||||
|
|
||||||
const val RANGE_IN_RESULT_CALCULATIONS = 10
|
const val RANGE_IN_RESULT_CALCULATIONS = 10
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ import com.example.hpostesting.domain.SaveRawDataTest
|
|||||||
import com.example.hpostesting.firebase.FirebaseManager
|
import com.example.hpostesting.firebase.FirebaseManager
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListenerImpl
|
import com.example.hpostesting.presentation.utils.UsbServiceListenerImpl
|
||||||
import com.example.hpostesting.util.NetworkMonitor
|
|
||||||
import com.example.hpostesting.util.PropertyProvider
|
import com.example.hpostesting.util.PropertyProvider
|
||||||
import com.example.hpostesting.util.PropertyProviderImpl
|
import com.example.hpostesting.util.PropertyProviderImpl
|
||||||
import com.google.firebase.firestore.FirebaseFirestore
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
@@ -241,12 +240,8 @@ object AppModule {
|
|||||||
return UsbServiceListenerImpl(context)
|
return UsbServiceListenerImpl(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
fun provideNetworkMonitor(
|
|
||||||
@ApplicationContext context: Context
|
|
||||||
): NetworkMonitor {
|
|
||||||
return NetworkMonitor(context).apply { startMonitoring() }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -14,9 +14,6 @@ package com.example.hpostesting.firebase
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Process
|
import android.os.Process
|
||||||
import android.util.Log
|
|
||||||
import androidx.core.content.edit
|
|
||||||
import com.example.hpostesting.data.constant.Constants
|
|
||||||
import com.google.firebase.FirebaseApp
|
import com.google.firebase.FirebaseApp
|
||||||
import com.google.firebase.FirebaseOptions
|
import com.google.firebase.FirebaseOptions
|
||||||
import com.google.firebase.firestore.FirebaseFirestore
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
@@ -29,83 +26,33 @@ import kotlinx.coroutines.launch
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class FirebaseManager @Inject constructor(private val context: Context) {
|
class FirebaseManager @Inject constructor(private val context: Context) {
|
||||||
private var defaultServers = mutableListOf<FirebaseConfig>()
|
|
||||||
external fun getFirebaseDataMap(): Map<String, Map<String, String>>
|
private val sharedPreferences =
|
||||||
private val map: Map<String, Map<String, String>> = getFirebaseDataMap()
|
context.getSharedPreferences("FirebaseConfigPrefs", Context.MODE_PRIVATE)
|
||||||
companion object {
|
|
||||||
init {
|
|
||||||
System.loadLibrary("native-server") //use NDK ro secure somethings
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private val sharedPreferencesServerConfig = context.getSharedPreferences("FirebaseConfigPrefs", Context.MODE_PRIVATE)
|
|
||||||
private val sharedPreferencesDev = context.getSharedPreferences("DevMode",Context.MODE_PRIVATE)
|
|
||||||
|
|
||||||
private var currentFirestore: FirebaseFirestore = FirebaseFirestore.getInstance()
|
private var currentFirestore: FirebaseFirestore = FirebaseFirestore.getInstance()
|
||||||
private var currentStorage: FirebaseStorage = FirebaseStorage.getInstance()
|
private var currentStorage: FirebaseStorage = FirebaseStorage.getInstance()
|
||||||
private var updateStatus = false
|
var updateStatus = false
|
||||||
|
|
||||||
|
private val defaultServers = listOf(
|
||||||
private fun Map<String, String>.toFirebaseConfig(server: String): FirebaseConfig? {
|
// i have it in different place look down
|
||||||
val apiKey = this["apiKey"] ?: return null
|
firebaseConfig1, firebaseConfig2, firebaseConfig3,
|
||||||
val appId = this["appId"] ?: return null
|
|
||||||
val projectId = this["projectId"] ?: return null
|
|
||||||
val storageBucket = this["storageBucket"] ?: return null
|
|
||||||
return FirebaseConfig(
|
|
||||||
serverName = server,
|
|
||||||
projectId = projectId,
|
|
||||||
appId = appId,
|
|
||||||
apiKey = apiKey,
|
|
||||||
storageBucket = storageBucket
|
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fun populate() {
|
|
||||||
defaultServers.clear()
|
|
||||||
map.forEach { (server, config) ->
|
|
||||||
config.toFirebaseConfig(server)?.let {
|
|
||||||
defaultServers.add(it)
|
|
||||||
} ?: Log.w("Firebase", "Skipping $server due to missing keys")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
populate()
|
|
||||||
val lastSelectedServer = getLastSelectedServer()
|
val lastSelectedServer = getLastSelectedServer()
|
||||||
switchServer(lastSelectedServer)
|
switchServer(lastSelectedServer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun setDevModeOn(state : Boolean){
|
|
||||||
sharedPreferencesDev.edit {
|
|
||||||
putBoolean( "isDevModeOn",state )
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getDevMode(): Boolean {
|
|
||||||
return sharedPreferencesDev.getBoolean("isDevModeOn",false)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fun getCurrentFirestore(): FirebaseFirestore = currentFirestore
|
fun getCurrentFirestore(): FirebaseFirestore = currentFirestore
|
||||||
fun getCurrentStorage(): FirebaseStorage = currentStorage
|
fun getCurrentStorage(): FirebaseStorage = currentStorage
|
||||||
|
|
||||||
fun switchServer(firebaseConfig: FirebaseConfig) {
|
fun switchServer(firebaseConfig: FirebaseConfig) {
|
||||||
if (firebaseConfig.serverName =="molbio" ||firebaseConfig.apiKey == "molbio"){
|
|
||||||
saveSelectedServer(firebaseConfig)
|
|
||||||
makeMolbioAsBackEnd()
|
|
||||||
}else {
|
|
||||||
makeSMIBackEnd()
|
|
||||||
saveSelectedServer(firebaseConfig)
|
saveSelectedServer(firebaseConfig)
|
||||||
val firebaseApp = getOrInitializeFirebaseApp(firebaseConfig)
|
val firebaseApp = getOrInitializeFirebaseApp(firebaseConfig)
|
||||||
currentFirestore = FirebaseFirestore.getInstance(firebaseApp)
|
currentFirestore = FirebaseFirestore.getInstance(firebaseApp)
|
||||||
currentStorage = FirebaseStorage.getInstance(firebaseApp)
|
currentStorage = FirebaseStorage.getInstance(firebaseApp)
|
||||||
updateStatus = true
|
updateStatus = true
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,6 +60,7 @@ class FirebaseManager @Inject constructor(private val context: Context) {
|
|||||||
val existingApp = FirebaseApp.getApps(context).find { it.name == firebaseConfig.serverName }
|
val existingApp = FirebaseApp.getApps(context).find { it.name == firebaseConfig.serverName }
|
||||||
|
|
||||||
return if (existingApp != null) {
|
return if (existingApp != null) {
|
||||||
|
|
||||||
existingApp
|
existingApp
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@@ -125,7 +73,7 @@ class FirebaseManager @Inject constructor(private val context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun saveSelectedServer(firebaseConfig: FirebaseConfig) {
|
private fun saveSelectedServer(firebaseConfig: FirebaseConfig) {
|
||||||
with(sharedPreferencesServerConfig.edit()) {
|
with(sharedPreferences.edit()) {
|
||||||
putString("selectedServerName", firebaseConfig.serverName)
|
putString("selectedServerName", firebaseConfig.serverName)
|
||||||
putString("projectId", firebaseConfig.projectId)
|
putString("projectId", firebaseConfig.projectId)
|
||||||
putString("appId", firebaseConfig.appId)
|
putString("appId", firebaseConfig.appId)
|
||||||
@@ -145,12 +93,12 @@ class FirebaseManager @Inject constructor(private val context: Context) {
|
|||||||
|
|
||||||
fun getLastSelectedServer(): FirebaseConfig {
|
fun getLastSelectedServer(): FirebaseConfig {
|
||||||
val selectedServerName =
|
val selectedServerName =
|
||||||
sharedPreferencesServerConfig.getString("selectedServerName", defaultServers.first().serverName)
|
sharedPreferences.getString("selectedServerName", defaultServers.first().serverName)
|
||||||
val projectId = sharedPreferencesServerConfig.getString("projectId", defaultServers.first().projectId)
|
val projectId = sharedPreferences.getString("projectId", defaultServers.first().projectId)
|
||||||
val appId = sharedPreferencesServerConfig.getString("appId", defaultServers.first().appId)
|
val appId = sharedPreferences.getString("appId", defaultServers.first().appId)
|
||||||
val apiKey = sharedPreferencesServerConfig.getString("apiKey", defaultServers.first().apiKey)
|
val apiKey = sharedPreferences.getString("apiKey", defaultServers.first().apiKey)
|
||||||
val storageBucket =
|
val storageBucket =
|
||||||
sharedPreferencesServerConfig.getString("storageBucket", defaultServers.first().storageBucket)
|
sharedPreferences.getString("storageBucket", defaultServers.first().storageBucket)
|
||||||
|
|
||||||
return FirebaseConfig(
|
return FirebaseConfig(
|
||||||
serverName = selectedServerName ?: defaultServers.first().serverName,
|
serverName = selectedServerName ?: defaultServers.first().serverName,
|
||||||
@@ -164,16 +112,6 @@ class FirebaseManager @Inject constructor(private val context: Context) {
|
|||||||
fun getAvailableServers(): List<FirebaseConfig> {
|
fun getAvailableServers(): List<FirebaseConfig> {
|
||||||
return defaultServers
|
return defaultServers
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun makeMolbioAsBackEnd(){
|
|
||||||
Constants.FIREBASE_INTEGRATION = false
|
|
||||||
Constants.MOLBIO_INTEGRATION = true
|
|
||||||
restartApp()
|
|
||||||
}
|
|
||||||
private fun makeSMIBackEnd(){
|
|
||||||
Constants.FIREBASE_INTEGRATION = true
|
|
||||||
Constants.MOLBIO_INTEGRATION = false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun restartApp(context: Context) {
|
fun restartApp(context: Context) {
|
||||||
@@ -190,51 +128,26 @@ fun delayedRestart(context: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
private val firebaseConfig1 = FirebaseConfig(
|
||||||
//
|
serverName = "dev",
|
||||||
//private val firebaseConfigDev = FirebaseConfig(
|
apiKey = "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I",
|
||||||
// serverName = "dev",
|
appId = "1:650071678820:android:a53292637abb7c0d6c6471",
|
||||||
// apiKey = "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I",
|
projectId = "hpos-af3cc",
|
||||||
// appId = "1:650071678820:android:a53292637abb7c0d6c6471",
|
storageBucket = "hpos-af3cc.appspot.com"
|
||||||
// projectId = "hpos-af3cc",
|
)
|
||||||
// storageBucket = "hpos-af3cc.appspot.com"
|
|
||||||
//)
|
private val firebaseConfig2 = FirebaseConfig(
|
||||||
//private val firebaseConfigQaQc = FirebaseConfig(
|
serverName = "qc-qa",
|
||||||
// serverName = "qc-qa",
|
apiKey = "AIzaSyC4d4GhWHr_NMJAeBvnztQ_yQ3Qe9MAnLs",
|
||||||
// apiKey = "AIzaSyC4d4GhWHr_NMJAeBvnztQ_yQ3Qe9MAnLs",
|
appId = "1:1004619739289:android:3dbcefb10ea99654e5c808",
|
||||||
// appId = "1:1004619739289:android:3dbcefb10ea99654e5c808",
|
projectId = "hpos-qa",
|
||||||
// projectId = "hpos-qa",
|
storageBucket = "hpos-qa.appspot.com"
|
||||||
// storageBucket = "hpos-qa.appspot.com"
|
)
|
||||||
//)
|
|
||||||
//
|
private val firebaseConfig3 = FirebaseConfig(
|
||||||
//private val firebaseConfigProd = FirebaseConfig(
|
serverName = " pre prod",
|
||||||
// serverName = "prod",
|
apiKey = "AIzaSyDYySi27LioZGNisP1NfnNU5inJX_0FT38",
|
||||||
// apiKey = "AIzaSyA_O0oZGzy3Kiw9fiLQ3OFPME-xQJP88vs",
|
appId = "1:121176529204:android:a7bc0842f61e5095bbed61",
|
||||||
// appId = "1:1012719870714:android:d8d7c962d96f4097de5f43",
|
projectId = "hpos-preprod",
|
||||||
// projectId = "hpos-prod",
|
storageBucket = "hpos-preprod.appspot.com"
|
||||||
// storageBucket = "hpos-prod.appspot.com"
|
)
|
||||||
//)
|
|
||||||
//
|
|
||||||
//private val firebaseConfigPreProd = FirebaseConfig(
|
|
||||||
// serverName = "pre prod",
|
|
||||||
// apiKey = "AIzaSyDYySi27LioZGNisP1NfnNU5inJX_0FT38",
|
|
||||||
// appId = "1:121176529204:android:e6841fdac57bdc95bbed61",
|
|
||||||
// projectId = "hpos-preprod",
|
|
||||||
// storageBucket = "hpos-preprod.appspot.com"
|
|
||||||
//)
|
|
||||||
//
|
|
||||||
//private val firebaseConfigSmiRandD= FirebaseConfig(
|
|
||||||
// serverName = "SMI R&D",
|
|
||||||
// apiKey = "AIzaSyAVxpilbB804iRCCpMBDjjmdZhQguctGHM",
|
|
||||||
// appId = "1:327771387914:android:a3b4ed2e42ea6e38dc87f3",
|
|
||||||
// projectId = "hposrandd",
|
|
||||||
// storageBucket = "hposrandd.firebasestorage.app"
|
|
||||||
//)
|
|
||||||
//
|
|
||||||
//private val configMolbio = FirebaseConfig(
|
|
||||||
// serverName = "molbio",
|
|
||||||
// apiKey = "molbio",
|
|
||||||
// appId = "molbio",
|
|
||||||
// projectId = "molbio",
|
|
||||||
// storageBucket = "molbio"
|
|
||||||
//)
|
|
||||||
|
|||||||
@@ -22,12 +22,10 @@ import android.util.Log
|
|||||||
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 androidx.core.content.ContentProviderCompat.requireContext
|
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.data.model.test.TestType
|
import com.example.hpostesting.data.model.test.TestType
|
||||||
import com.example.hpostesting.firebase.FirebaseManager
|
|
||||||
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
import com.example.hpostesting.presentation.main_base.DashboardActivity
|
||||||
import com.example.hpostesting.presentation.hb_test.HBTestActivity
|
import com.example.hpostesting.presentation.hb_test.HBTestActivity
|
||||||
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestActivity
|
import com.example.hpostesting.presentation.trueheme_test.TrueHemeTestActivity
|
||||||
@@ -54,7 +52,7 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
private var fromWhere = "Home"
|
private var fromWhere = "Home"
|
||||||
private val TAG = "KitScanActivity"
|
private val TAG = "KitScanActivity"
|
||||||
private lateinit var binding: ActivityKitScanBinding
|
private lateinit var binding: ActivityKitScanBinding
|
||||||
private lateinit var firebaseManager: FirebaseManager
|
|
||||||
private lateinit var sharedPreference: SharedPreferences
|
private lateinit var sharedPreference: SharedPreferences
|
||||||
|
|
||||||
var sdkHandler: SDKHandler? = null
|
var sdkHandler: SDKHandler? = null
|
||||||
@@ -129,42 +127,27 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
firebaseManager = FirebaseManager(this)
|
|
||||||
val currentServer = firebaseManager.getLastSelectedServer().serverName
|
|
||||||
binding = ActivityKitScanBinding.inflate(layoutInflater)
|
binding = ActivityKitScanBinding.inflate(layoutInflater)
|
||||||
sharedPreference = this.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
sharedPreference = this.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
binding.toolbar.title = "Kit Serial Number"
|
binding.toolbar.title = "Kit Serial Number"
|
||||||
fromWhere = intent.getStringExtra("fromWhere").toString()
|
fromWhere = intent.getStringExtra("fromWhere").toString()
|
||||||
|
val maxTest = if(sharedPreference.getString(Constants.CUVETTE_SIZE, "10mm").toString() == "2mm"){
|
||||||
val maxTest = if (currentServer == "SMI R&D"){
|
|
||||||
Constants.MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE10MM_RANDD
|
|
||||||
|
|
||||||
Log.d(TAG, "onCreate RandD mode")
|
|
||||||
}else {
|
|
||||||
if (sharedPreference.getString(Constants.CUVETTE_SIZE, "10mm").toString() == "2mm") {
|
|
||||||
Constants.MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE
|
Constants.MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE
|
||||||
}else{
|
}else{
|
||||||
Constants.MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE10MM
|
Constants.MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE10MM
|
||||||
}
|
}
|
||||||
}
|
|
||||||
val time = timeDifference(sharedPreference.getString(Constants.KIT_TIME, "").toString())
|
val time = timeDifference(sharedPreference.getString(Constants.KIT_TIME, "").toString())
|
||||||
val kitNum = sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
val kitNum = sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
|
||||||
// Toast.makeText(this@KitScanActivity,"Test MAx time"+ time+"-Test count-"+kitNum,Toast.LENGTH_SHORT).show()
|
// Toast.makeText(this@KitScanActivity,"Test MAx time"+ time+"-Test count-"+kitNum,Toast.LENGTH_SHORT).show()
|
||||||
// if (sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
|
||||||
// moveToNext()
|
|
||||||
// }else{
|
|
||||||
if (sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
if (sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN") {
|
||||||
moveToNext()
|
moveToNext()
|
||||||
}else{
|
}else{
|
||||||
if (DataHolder.sampleReadCounter <= maxTest && kitNum != "" && time < Constants.MAX_KIT_TIME) {
|
if (DataHolder.sampleReadCounter <= maxTest && kitNum != "" && time < Constants.MAX_KIT_TIME) {
|
||||||
moveToNext()
|
moveToNext()
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(
|
Toast.makeText(this@KitScanActivity, "Limit Reached, Use New KIT for testing", Toast.LENGTH_SHORT).show()
|
||||||
this@KitScanActivity,
|
|
||||||
"Limit Reached, Use New KIT for testing",
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
DataHolder.sampleReadCounter = 0
|
DataHolder.sampleReadCounter = 0
|
||||||
DataHolder.kitSerial = ""
|
DataHolder.kitSerial = ""
|
||||||
|
|
||||||
@@ -315,8 +298,7 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
if (mScannerInfoList.isNotEmpty()) {
|
if (mScannerInfoList.isNotEmpty()) {
|
||||||
sdkHandler!!.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
|
sdkHandler!!.dcssdkEstablishCommunicationSession(mScannerInfoList[0].scannerID)
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(this, "Scanner Is not available In this device", Toast.LENGTH_LONG)
|
Toast.makeText(this,"Scanner Is not available In this device", Toast.LENGTH_LONG).show()
|
||||||
.show()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -368,14 +350,12 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
private fun isSerialValid(s: String): Boolean {
|
private fun isSerialValid(s: String): Boolean {
|
||||||
if (s.contains("SMI/SC/")) {
|
if (s.contains("SMI/SC/")) {
|
||||||
if(s.length != 17){
|
if(s.length != 17){
|
||||||
binding.nameEditText.error =
|
binding.nameEditText.error = "Invalid Kit Serial Number, correct example SMI/SC/000/00/000"
|
||||||
"Invalid Kit Serial Number, correct example SMI/SC/000/00/000"
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}else if(s.contains("SMI/SC-2-D10/")){
|
}else if(s.contains("SMI/SC-2-D10/")){
|
||||||
if(s.length != 27){
|
if(s.length != 27){
|
||||||
binding.nameEditText.error =
|
binding.nameEditText.error = "Invalid Kit Serial Number, correct example SMI/SC-2-D10/000000/000/000"
|
||||||
"Invalid Kit Serial Number, correct example SMI/SC-2-D10/000000/000/000"
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@@ -442,7 +422,6 @@ class KitScanActivity : AppCompatActivity(), IDcsSdkApiDelegate {
|
|||||||
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())
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
package com.example.hpostesting.presentation
|
package com.example.hpostesting.presentation
|
||||||
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
@@ -34,7 +33,6 @@ import com.example.hpostesting.util.MyUtils
|
|||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivitySplashBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivitySplashBinding
|
||||||
|
|
||||||
@SuppressLint("CustomSplashScreen")
|
|
||||||
class SplashActivity : AppCompatActivity() {
|
class SplashActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private lateinit var binding: ActivitySplashBinding
|
private lateinit var binding: ActivitySplashBinding
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import com.example.hpostesting.presentation.main_base.DashboardActivity
|
|||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentDeviceProvisionBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentDeviceProvisionBinding
|
||||||
import okio.ByteString.Companion.decodeBase64
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class DeviceProvisionFragment : Fragment() {
|
class DeviceProvisionFragment : Fragment() {
|
||||||
@@ -148,18 +147,17 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
DashboardActivity::class.java
|
DashboardActivity::class.java
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
activity,
|
activity,
|
||||||
"An error in device provision: ${response.data.message}",
|
"An error in device provision: ${response.data.message}",
|
||||||
Toast.LENGTH_LONG
|
Toast.LENGTH_LONG
|
||||||
).show()
|
).show()
|
||||||
Log.d("Error in hpos network", "observeViewModel:${response.data.message} ")
|
|
||||||
binding.btnSubmit.visibility = View.VISIBLE
|
binding.btnSubmit.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is Result.Error -> {
|
is Result.Error -> {
|
||||||
response.exception.let { message ->
|
response.exception.let { message ->
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
@@ -167,9 +165,7 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
"An error occurred in device provision: $message",
|
"An error occurred in device provision: $message",
|
||||||
Toast.LENGTH_LONG
|
Toast.LENGTH_LONG
|
||||||
).show()
|
).show()
|
||||||
Log.d("Error in hpos network 2", "observeViewModel:$message} ")
|
|
||||||
}
|
}
|
||||||
Log.d("Error in hpos network 3", "observeViewModel: $response} ")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is Result.Loading -> {
|
is Result.Loading -> {
|
||||||
|
|||||||
@@ -1,18 +1,13 @@
|
|||||||
package com.example.hpostesting.presentation.main_base
|
package com.example.hpostesting.presentation.main_base
|
||||||
|
|
||||||
import com.example.hpostesting.data.constant.Constants.FIREBASE_INTEGRATION
|
|
||||||
import com.example.hpostesting.data.constant.Constants.MOLBIO_INTEGRATION
|
|
||||||
|
|
||||||
class AppVersionTapManager {
|
class AppVersionTapManager {
|
||||||
|
|
||||||
private var tapCount = 0
|
private var tapCount = 0
|
||||||
private val maxTapCount = 5
|
private val maxTapCount = 5
|
||||||
val shouldEnable = FIREBASE_INTEGRATION && !MOLBIO_INTEGRATION
|
|
||||||
val notEnable = MOLBIO_INTEGRATION && !FIREBASE_INTEGRATION
|
|
||||||
|
|
||||||
fun registerTap(onMaxTapsReached: () -> Unit) {
|
fun registerTap(onMaxTapsReached: () -> Unit) {
|
||||||
tapCount++
|
tapCount++
|
||||||
if (tapCount >= maxTapCount && shouldEnable) {
|
if (tapCount >= maxTapCount) {
|
||||||
onMaxTapsReached()
|
onMaxTapsReached()
|
||||||
reset()
|
reset()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,7 +89,6 @@ class PanelFragment : Fragment() {
|
|||||||
binding.btnDeviceInfo.visibility = View.VISIBLE
|
binding.btnDeviceInfo.visibility = View.VISIBLE
|
||||||
binding.btnResetPassword.visibility = View.VISIBLE
|
binding.btnResetPassword.visibility = View.VISIBLE
|
||||||
binding.btnUpdateValues.visibility = View.VISIBLE
|
binding.btnUpdateValues.visibility = View.VISIBLE
|
||||||
binding.btnRnd.visibility = View.GONE
|
|
||||||
}else{
|
}else{
|
||||||
binding.btnResetPassword.visibility = View.GONE
|
binding.btnResetPassword.visibility = View.GONE
|
||||||
binding.btnDeviceProvision.visibility = View.GONE
|
binding.btnDeviceProvision.visibility = View.GONE
|
||||||
@@ -103,7 +102,6 @@ class PanelFragment : Fragment() {
|
|||||||
binding.btnSubmit.visibility = View.GONE
|
binding.btnSubmit.visibility = View.GONE
|
||||||
binding.btnDeviceInfo.visibility = View.VISIBLE
|
binding.btnDeviceInfo.visibility = View.VISIBLE
|
||||||
binding.btnUpdateValues.visibility = View.GONE
|
binding.btnUpdateValues.visibility = View.GONE
|
||||||
binding.btnRnd.visibility = View.GONE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnResetPassword.setOnClickListener{
|
binding.btnResetPassword.setOnClickListener{
|
||||||
@@ -144,7 +142,6 @@ class PanelFragment : Fragment() {
|
|||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
binding.btnFiles.setOnClickListener {
|
binding.btnFiles.setOnClickListener {
|
||||||
val intent = Intent(Intent.ACTION_GET_CONTENT)
|
val intent = Intent(Intent.ACTION_GET_CONTENT)
|
||||||
intent.type = "file/*"
|
intent.type = "file/*"
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
package com.example.hpostesting.presentation.main_base
|
package com.example.hpostesting.presentation.main_base
|
||||||
|
|
||||||
|
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
|
||||||
@@ -28,18 +29,15 @@ import androidx.fragment.app.Fragment
|
|||||||
import androidx.preference.ListPreference
|
import androidx.preference.ListPreference
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
import androidx.preference.SwitchPreferenceCompat
|
|
||||||
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.repository.DatabaseRepository
|
||||||
import com.example.hpostesting.firebase.FirebaseConfig
|
import com.example.hpostesting.firebase.FirebaseConfig
|
||||||
import com.example.hpostesting.firebase.FirebaseManager
|
import com.example.hpostesting.firebase.FirebaseManager
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
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() {
|
||||||
@@ -60,6 +58,7 @@ class SlideshowFragment : Fragment() {
|
|||||||
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()
|
||||||
binding.btnGo.setOnClickListener {
|
binding.btnGo.setOnClickListener {
|
||||||
var labname = binding.nameEditText.text.toString()
|
var labname = binding.nameEditText.text.toString()
|
||||||
@@ -98,7 +97,6 @@ class SlideshowFragment : Fragment() {
|
|||||||
// Do nothing here
|
// Do nothing here
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.spinnerCuvette.setSelection(pos)
|
binding.spinnerCuvette.setSelection(pos)
|
||||||
binding.btnAddSize.setOnClickListener {
|
binding.btnAddSize.setOnClickListener {
|
||||||
with(sharedPreferences.edit()) {
|
with(sharedPreferences.edit()) {
|
||||||
@@ -117,23 +115,22 @@ class SlideshowFragment : Fragment() {
|
|||||||
|
|
||||||
class PrefsFragment : PreferenceFragmentCompat(){
|
class PrefsFragment : PreferenceFragmentCompat(){
|
||||||
private lateinit var tapManager: AppVersionTapManager
|
private lateinit var tapManager: AppVersionTapManager
|
||||||
|
private var isServerSelectionVisible = false
|
||||||
private lateinit var serverPreference: Preference
|
private lateinit var serverPreference: Preference
|
||||||
private lateinit var currentServerPreference: Preference
|
private lateinit var currentServerPreference: Preference
|
||||||
lateinit var firebaseManager: FirebaseManager
|
lateinit var firebaseManager: FirebaseManager
|
||||||
private var topDevMode = false
|
|
||||||
lateinit var databaseRepository: DatabaseRepository
|
lateinit var databaseRepository: DatabaseRepository
|
||||||
|
|
||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
firebaseManager = FirebaseManager(requireContext())
|
firebaseManager = FirebaseManager(requireContext())
|
||||||
databaseRepository = (activity as DashboardActivity).databaseRepository
|
databaseRepository = (activity as DashboardActivity).databaseRepository
|
||||||
|
|
||||||
tapManager = AppVersionTapManager()
|
tapManager = AppVersionTapManager()
|
||||||
topDevMode = firebaseManager.getDevMode()
|
|
||||||
val sharedPreference =
|
val sharedPreference =
|
||||||
requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
requireContext().getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
val preferenceScreen = preferenceManager.createPreferenceScreen(requireContext())
|
val preferenceScreen = preferenceManager.createPreferenceScreen(requireContext())
|
||||||
val currentServer = firebaseManager.getLastSelectedServer().serverName
|
val currentServer = firebaseManager.getLastSelectedServer().serverName
|
||||||
|
|
||||||
|
|
||||||
// Language Preference
|
// Language Preference
|
||||||
val languagePreference = ListPreference(requireContext()).apply {
|
val languagePreference = ListPreference(requireContext()).apply {
|
||||||
key = "language_preference"
|
key = "language_preference"
|
||||||
@@ -143,62 +140,14 @@ class PrefsFragment : PreferenceFragmentCompat() {
|
|||||||
entryValues = arrayOf("en", "kn", "hi")
|
entryValues = arrayOf("en", "kn", "hi")
|
||||||
setDefaultValue("en")
|
setDefaultValue("en")
|
||||||
icon = ContextCompat.getDrawable(requireContext(), R.drawable.baseline_translate_24)
|
icon = ContextCompat.getDrawable(requireContext(), R.drawable.baseline_translate_24)
|
||||||
|
|
||||||
onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue ->
|
||||||
val languageCode = newValue as String
|
val languageCode = newValue as String
|
||||||
updateLanguage(requireContext(), languageCode)
|
updateLanguage(requireContext(), languageCode)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val servers = firebaseManager.getAvailableServers()
|
|
||||||
val serverNames = servers.map { it.serverName }.toTypedArray()
|
|
||||||
|
|
||||||
val serverSelectorPreference = CustomDialogPreference(requireContext()).apply {
|
|
||||||
key = "server_preference"
|
|
||||||
title = "Select the Server"
|
|
||||||
summary = "Current server: $currentServer"
|
|
||||||
setEntries(serverNames)
|
|
||||||
setEntryValues(serverNames)
|
|
||||||
setValue(currentServer)
|
|
||||||
icon = ContextCompat.getDrawable(requireContext(), R.drawable.baseline_cloud_sync_24)
|
|
||||||
setOnPreferenceChangeListener { newValue ->
|
|
||||||
val preferenceConfig = servers.find { it.serverName == newValue }
|
|
||||||
switchFirebaseServer(preferenceConfig!!)
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add preferences to screen
|
|
||||||
preferenceScreen.addPreference(languagePreference)
|
preferenceScreen.addPreference(languagePreference)
|
||||||
preferenceScreen.addPreference(languagePreference)
|
|
||||||
|
|
||||||
|
|
||||||
val developerToggle = SwitchPreferenceCompat(requireContext()).apply {
|
|
||||||
title = "Developer Options"
|
|
||||||
summary = "Enable or disable developer options"
|
|
||||||
icon =
|
|
||||||
ContextCompat.getDrawable(requireContext(), R.drawable.baseline_developer_mode_24)
|
|
||||||
key = "developer_options" // Unique key for SharedPreferences
|
|
||||||
|
|
||||||
// Load toggle state from SharedPreferences
|
|
||||||
isChecked = firebaseManager.getDevMode()
|
|
||||||
|
|
||||||
setOnPreferenceChangeListener { _, newValue ->
|
|
||||||
val isEnabled = newValue as Boolean
|
|
||||||
firebaseManager.setDevModeOn(isEnabled)
|
|
||||||
|
|
||||||
if (!isEnabled) {
|
|
||||||
preferenceScreen.removePreference(this)
|
|
||||||
preferenceScreen.removePreference(serverSelectorPreference)
|
|
||||||
}
|
|
||||||
if (!firebaseManager.getDevMode() && currentServer != "prod"){
|
|
||||||
val prodConfig = servers.find { it.serverName == "prod" }
|
|
||||||
switchFirebaseServer(prodConfig!!)
|
|
||||||
}
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val appVersionPreference = Preference(requireContext()).apply {
|
val appVersionPreference = Preference(requireContext()).apply {
|
||||||
title = "App Version"
|
title = "App Version"
|
||||||
@@ -207,36 +156,36 @@ class PrefsFragment : PreferenceFragmentCompat() {
|
|||||||
icon = ContextCompat.getDrawable(requireContext(), R.drawable.baseline_info_24)
|
icon = ContextCompat.getDrawable(requireContext(), R.drawable.baseline_info_24)
|
||||||
|
|
||||||
setOnPreferenceClickListener {
|
setOnPreferenceClickListener {
|
||||||
|
if ((sharedPreference.getString(Constants.USER_ID, "").toString() == "ADMIN")) {
|
||||||
tapManager.registerTap {
|
tapManager.registerTap {
|
||||||
firebaseManager.setDevModeOn(true)
|
if (!isServerSelectionVisible) {
|
||||||
|
showServerSelection()
|
||||||
|
|
||||||
if (firebaseManager.getDevMode() && currentServer != "dev") {
|
|
||||||
Toast.makeText(requireContext(), "Now you are a Developer", Toast.LENGTH_SHORT).show()
|
|
||||||
Toast.makeText(requireContext(), "Setting Up developer Environmnet", Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preferenceScreen.findPreference<SwitchPreferenceCompat>("developer_options") == null) {
|
|
||||||
preferenceScreen.addPreference(developerToggle)
|
|
||||||
}
|
|
||||||
if (preferenceScreen.findPreference<ListPreference>("server_preference") == null) {
|
|
||||||
preferenceScreen.addPreference(serverSelectorPreference)
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
developerToggle.isChecked = true
|
|
||||||
updateServerPreference(currentServer)
|
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
preferenceScreen.addPreference(appVersionPreference)
|
preferenceScreen.addPreference(appVersionPreference)
|
||||||
if (firebaseManager.getDevMode()) {
|
|
||||||
developerToggle.isChecked = true // Ensure it's checked
|
|
||||||
preferenceScreen.addPreference(developerToggle)
|
|
||||||
preferenceScreen.addPreference(serverSelectorPreference)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
if (isLanguageChanged) {
|
if (isLanguageChanged) {
|
||||||
@@ -245,23 +194,58 @@ class PrefsFragment : PreferenceFragmentCompat() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun updateServerPreference(newServer: String) {
|
private fun showServerSelection() {
|
||||||
(findPreference<CustomDialogPreference>("server_preference"))?.let { pref ->
|
val currentServer = firebaseManager.getLastSelectedServer().serverName
|
||||||
pref.setValue(newServer)
|
serverPreference = Preference(requireContext()).apply {
|
||||||
pref.summary = "Current server: $newServer"
|
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) {
|
private fun switchFirebaseServer(firebaseConfig: FirebaseConfig) {
|
||||||
firebaseManager.switchServer(firebaseConfig)
|
firebaseManager.switchServer(firebaseConfig)
|
||||||
Toast.makeText(
|
Toast.makeText(requireContext(), "Switched to ${firebaseConfig.serverName}, Please wait for few seconds", Toast.LENGTH_SHORT).show()
|
||||||
requireContext(),
|
Toast.makeText(requireContext(), "Restart needed restarting the app", Toast.LENGTH_SHORT).show()
|
||||||
"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()
|
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) {
|
||||||
@@ -291,47 +275,3 @@ class PrefsFragment : PreferenceFragmentCompat() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// CustomDialogPreference.kt
|
|
||||||
class CustomDialogPreference(context: Context) : Preference(context) {
|
|
||||||
private var entries: Array<String> = arrayOf()
|
|
||||||
private var entryValues: Array<String> = arrayOf()
|
|
||||||
private var currentValue: String = ""
|
|
||||||
private var onValueChangeListener: ((String) -> Boolean)? = null
|
|
||||||
|
|
||||||
fun setEntries(entries: Array<String>) {
|
|
||||||
this.entries = entries
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setEntryValues(values: Array<String>) {
|
|
||||||
this.entryValues = values
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setValue(value: String) {
|
|
||||||
currentValue = value
|
|
||||||
persistString(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setOnPreferenceChangeListener(listener: (String) -> Boolean) {
|
|
||||||
onValueChangeListener = listener
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onClick() {
|
|
||||||
val builder = MaterialAlertDialogBuilder(context)
|
|
||||||
builder.setTitle(title)
|
|
||||||
|
|
||||||
builder.setSingleChoiceItems(entries, entries.indexOf(currentValue)) { dialog, which ->
|
|
||||||
val newValue = entryValues[which]
|
|
||||||
if (onValueChangeListener?.invoke(newValue) == true) {
|
|
||||||
setValue(newValue)
|
|
||||||
dialog.dismiss()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.setNegativeButton("Cancel") { dialog, _ ->
|
|
||||||
dialog.dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import androidx.lifecycle.MutableLiveData
|
|||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
import com.example.hpostesting.util.NetworkStatusLiveData
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.dao.UserDao
|
import com.example.hpostesting.data.dao.UserDao
|
||||||
import com.example.hpostesting.data.model.CalculationVariableForTest
|
import com.example.hpostesting.data.model.CalculationVariableForTest
|
||||||
@@ -35,7 +36,6 @@ import com.example.hpostesting.domain.SaveRawDataTest
|
|||||||
import com.example.hpostesting.domain.SickleFindResultCaluculationWithMaxImpl
|
import com.example.hpostesting.domain.SickleFindResultCaluculationWithMaxImpl
|
||||||
import com.example.hpostesting.domain.TestRightResultCalculation
|
import com.example.hpostesting.domain.TestRightResultCalculation
|
||||||
import com.example.hpostesting.util.MyUtils
|
import com.example.hpostesting.util.MyUtils
|
||||||
import com.example.hpostesting.util.NetworkMonitor
|
|
||||||
import com.google.firebase.storage.FirebaseStorage
|
import com.google.firebase.storage.FirebaseStorage
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -55,10 +55,10 @@ class TestRightViewModel @Inject constructor(
|
|||||||
private val saveRawDataTest: SaveRawDataTest,
|
private val saveRawDataTest: SaveRawDataTest,
|
||||||
private val repository: DatabaseRepository,
|
private val repository: DatabaseRepository,
|
||||||
private val userDao: UserDao,
|
private val userDao: UserDao,
|
||||||
networkMonitor: NetworkMonitor,
|
|
||||||
context: Context?
|
context: Context?
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
|
|
||||||
|
|
||||||
var isServiceConnected = false
|
var isServiceConnected = false
|
||||||
val progressBar = MutableLiveData(false)
|
val progressBar = MutableLiveData(false)
|
||||||
|
|
||||||
@@ -69,8 +69,9 @@ class TestRightViewModel @Inject constructor(
|
|||||||
|
|
||||||
var testDetails = DataHolder.selectedTest
|
var testDetails = DataHolder.selectedTest
|
||||||
|
|
||||||
private var _networkStatusLiveData = networkMonitor.isConnected
|
private val _networkStatusLiveData = context?.let { NetworkStatusLiveData(it) }
|
||||||
val networkStatusLiveData = _networkStatusLiveData
|
val networkStatusLiveData: NetworkStatusLiveData?
|
||||||
|
get() = _networkStatusLiveData
|
||||||
|
|
||||||
val allUserData = userDao.getAll()
|
val allUserData = userDao.getAll()
|
||||||
|
|
||||||
@@ -81,11 +82,6 @@ class TestRightViewModel @Inject constructor(
|
|||||||
|
|
||||||
val calculationVariableList = ArrayList<CalculationVariableForTest>()
|
val calculationVariableList = ArrayList<CalculationVariableForTest>()
|
||||||
|
|
||||||
init {
|
|
||||||
networkMonitor.startMonitoring()
|
|
||||||
_networkStatusLiveData = networkMonitor.isConnected
|
|
||||||
}
|
|
||||||
|
|
||||||
fun mapDeviceConstants(string: String) {
|
fun mapDeviceConstants(string: String) {
|
||||||
if (string.isNotEmpty()) {
|
if (string.isNotEmpty()) {
|
||||||
val listOfStrings = string.split(",")
|
val listOfStrings = string.split(",")
|
||||||
|
|||||||
@@ -25,8 +25,11 @@ import androidx.lifecycle.viewModelScope
|
|||||||
import androidx.work.ExistingPeriodicWorkPolicy
|
import androidx.work.ExistingPeriodicWorkPolicy
|
||||||
import androidx.work.PeriodicWorkRequestBuilder
|
import androidx.work.PeriodicWorkRequestBuilder
|
||||||
import androidx.work.WorkManager
|
import androidx.work.WorkManager
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.util.CsvWriter
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
import com.example.hpostesting.util.NetworkStatusLiveData
|
||||||
|
import com.example.hpostesting.util.Result
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
||||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||||
import com.example.hpostesting.data.datasource.LocalFileDataSource
|
import com.example.hpostesting.data.datasource.LocalFileDataSource
|
||||||
@@ -43,12 +46,10 @@ import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
|||||||
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
||||||
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
||||||
import com.example.hpostesting.data.model.updates.CheckUpdateResponse
|
import com.example.hpostesting.data.model.updates.CheckUpdateResponse
|
||||||
|
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
||||||
import com.example.hpostesting.data.repository.Repository
|
import com.example.hpostesting.data.repository.Repository
|
||||||
import com.example.hpostesting.domain.CheckUpdateWorker
|
import com.example.hpostesting.domain.CheckUpdateWorker
|
||||||
import com.example.hpostesting.domain.LogFileManager
|
import com.example.hpostesting.domain.LogFileManager
|
||||||
import com.example.hpostesting.util.CsvWriter
|
|
||||||
import com.example.hpostesting.util.NetworkMonitor
|
|
||||||
import com.example.hpostesting.util.Result
|
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||||
@@ -69,22 +70,20 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
private val repository: Repository,
|
private val repository: Repository,
|
||||||
private val logFileManager: LogFileManager,
|
private val logFileManager: LogFileManager,
|
||||||
private val localFileDataSource: LocalFileDataSource,
|
private val localFileDataSource: LocalFileDataSource,
|
||||||
networkMonitor: NetworkMonitor,
|
|
||||||
context: Context,
|
context: Context,
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
var isServiceConnected = false
|
var isServiceConnected = false
|
||||||
val progressBar = MutableLiveData(false)
|
val progressBar = MutableLiveData(false)
|
||||||
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
private val testDetails = DataHolder.selectedTest?.toHemoCubeTestData()
|
||||||
val messages = MutableLiveData<String>()
|
val messages = MutableLiveData<String>()
|
||||||
private val sharedPreference = context.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
private val sharedPreference =
|
||||||
|
context.getSharedPreferences("HEMOCUBE", Context.MODE_PRIVATE)
|
||||||
|
|
||||||
private val workManager = WorkManager.getInstance(context)
|
private val workManager = WorkManager.getInstance(context)
|
||||||
|
|
||||||
// init {
|
// init {
|
||||||
// startPeriodicCheckUpdate()
|
// startPeriodicCheckUpdate()
|
||||||
// }
|
// }
|
||||||
init {
|
|
||||||
networkMonitor.startMonitoring()
|
|
||||||
}
|
|
||||||
|
|
||||||
val loginResponse = MutableLiveData<Result<LoginResponse>>()
|
val loginResponse = MutableLiveData<Result<LoginResponse>>()
|
||||||
|
|
||||||
@@ -98,7 +97,7 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
|
|
||||||
// Get the device ID of the device you want to retrieve data for (e.g., the first device in the list)
|
// Get the device ID of the device you want to retrieve data for (e.g., the first device in the list)
|
||||||
|
|
||||||
private val _networkStatusLiveData = networkMonitor.isConnected
|
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||||
val allUserData = hemoCubeDao.getAll()
|
val allUserData = hemoCubeDao.getAll()
|
||||||
val allKitTestData = hemoCubeBufferDao.getAll()
|
val allKitTestData = hemoCubeBufferDao.getAll()
|
||||||
val deviceData = MutableLiveData<DeviceData?>()
|
val deviceData = MutableLiveData<DeviceData?>()
|
||||||
@@ -182,7 +181,7 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
val logFile = logFileManager.createLogFile().let { file ->
|
val logFile = logFileManager.createLogFile().let { file ->
|
||||||
val requestBody = file?.asRequestBody("multipart/form-data".toMediaTypeOrNull())
|
val requestBody = file?.asRequestBody("multipart/form-data".toMediaTypeOrNull())
|
||||||
val multipartFile =
|
val multipartFile =
|
||||||
requestBody?.let { MultipartBody.Part.createFormData("logFile", file.name, it) }
|
requestBody?.let { MultipartBody.Part.createFormData("logFile", file?.name, it) }
|
||||||
multipartFile?.let { partFile ->
|
multipartFile?.let { partFile ->
|
||||||
repository.uploadLogs(partFile).let { result ->
|
repository.uploadLogs(partFile).let { result ->
|
||||||
uploadLogs.postValue(result)
|
uploadLogs.postValue(result)
|
||||||
@@ -194,10 +193,12 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
fun uploadHemoCubeResultToDatabaseForBufferCheck(
|
fun uploadHemoCubeResultToDatabaseForBufferCheck(
|
||||||
isOnline: Boolean,
|
isOnline: Boolean,
|
||||||
bufferCheckData: BufferCheckData,
|
bufferCheckData: BufferCheckData,
|
||||||
) = viewModelScope.launch {
|
) =
|
||||||
|
viewModelScope.launch {
|
||||||
if (isOnline) {
|
if (isOnline) {
|
||||||
try {
|
try {
|
||||||
when (val response = repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
when (val response =
|
||||||
|
repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
@@ -395,7 +396,8 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
when (val response = repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
when (val response =
|
||||||
|
repository.addTestToDatabaseforBufferCheck(bufferCheckData)) {
|
||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
Log.i("Testdb", "Data uploaded to Firestore successfully")
|
||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
@@ -413,7 +415,8 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateBufferLocalFlag(bufferId: String) = viewModelScope.launch {
|
private fun updateBufferLocalFlag(bufferId: String) =
|
||||||
|
viewModelScope.launch {
|
||||||
hemoCubeBufferDao.updateFieldById(id = bufferId, true)
|
hemoCubeBufferDao.updateFieldById(id = bufferId, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -452,11 +455,15 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
|
|
||||||
fun getBatteryLevel(): Float? {
|
fun getBatteryLevel(): Float? {
|
||||||
val batteryPct: Float? = batteryStatus?.let { intent ->
|
val batteryPct: Float? = batteryStatus?.let { intent ->
|
||||||
val level: Int = intent.getIntExtra(
|
val level: Int =
|
||||||
BatteryManager.EXTRA_LEVEL, -1
|
intent.getIntExtra(
|
||||||
|
BatteryManager.EXTRA_LEVEL,
|
||||||
|
-1
|
||||||
)
|
)
|
||||||
val scale: Int = intent.getIntExtra(
|
val scale: Int =
|
||||||
BatteryManager.EXTRA_SCALE, -1
|
intent.getIntExtra(
|
||||||
|
BatteryManager.EXTRA_SCALE,
|
||||||
|
-1
|
||||||
)
|
)
|
||||||
level * 100 / scale.toFloat()
|
level * 100 / scale.toFloat()
|
||||||
}
|
}
|
||||||
@@ -467,7 +474,8 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
fun getBatteryTemperature(): Float? {
|
fun getBatteryTemperature(): Float? {
|
||||||
val batteryTemp: Float? = batteryStatus?.let { intent ->
|
val batteryTemp: Float? = batteryStatus?.let { intent ->
|
||||||
val temperature = intent.getIntExtra(
|
val temperature = intent.getIntExtra(
|
||||||
BatteryManager.EXTRA_TEMPERATURE, 0
|
BatteryManager.EXTRA_TEMPERATURE,
|
||||||
|
0
|
||||||
)
|
)
|
||||||
temperature.toFloat() / 10
|
temperature.toFloat() / 10
|
||||||
}
|
}
|
||||||
@@ -476,11 +484,14 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getBatteryVoltage(context: Context): Float {
|
fun getBatteryVoltage(context: Context): Float {
|
||||||
val batteryIntent = context.registerReceiver(
|
val batteryIntent =
|
||||||
null, IntentFilter(Intent.ACTION_BATTERY_CHANGED)
|
context.registerReceiver(
|
||||||
|
null,
|
||||||
|
IntentFilter(Intent.ACTION_BATTERY_CHANGED)
|
||||||
)
|
)
|
||||||
val voltage = batteryIntent?.getIntExtra(
|
val voltage = batteryIntent?.getIntExtra(
|
||||||
BatteryManager.EXTRA_VOLTAGE, 0
|
BatteryManager.EXTRA_VOLTAGE,
|
||||||
|
0
|
||||||
) ?: 0
|
) ?: 0
|
||||||
|
|
||||||
// milli-volts to volts
|
// milli-volts to volts
|
||||||
@@ -489,7 +500,8 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
|
|
||||||
|
|
||||||
fun getBatteryCapacity(context: Context): Int {
|
fun getBatteryCapacity(context: Context): Int {
|
||||||
val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
val batteryManager =
|
||||||
|
context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
||||||
val currentCapacity =
|
val currentCapacity =
|
||||||
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
|
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
|
||||||
|
|
||||||
@@ -498,7 +510,8 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
|
|
||||||
fun getBatteryMaxCapacity(context: Context): Float {
|
fun getBatteryMaxCapacity(context: Context): Float {
|
||||||
val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
val batteryManager = context.getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
||||||
val designCapacity = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
|
val designCapacity =
|
||||||
|
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
|
||||||
val currentCapacity =
|
val currentCapacity =
|
||||||
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
|
batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER)
|
||||||
|
|
||||||
@@ -515,7 +528,8 @@ class TrueHemeViewModel @Inject constructor(
|
|||||||
hemoCubeTestData.forEach { data ->
|
hemoCubeTestData.forEach { data ->
|
||||||
data.localFlag = true
|
data.localFlag = true
|
||||||
hemoCubeDao.updateCSVFieldById(
|
hemoCubeDao.updateCSVFieldById(
|
||||||
data._id, true
|
data._id,
|
||||||
|
true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ import androidx.core.content.ContextCompat
|
|||||||
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 androidx.lifecycle.lifecycleScope
|
|
||||||
import androidx.transition.Visibility
|
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.util.Result
|
import com.example.hpostesting.util.Result
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
@@ -47,9 +45,6 @@ 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.FragmentHemoCubeReferenceBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentHemoCubeReferenceBinding
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import kotlin.math.log10
|
import kotlin.math.log10
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
@@ -147,7 +142,6 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
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)
|
||||||
initViews()
|
initViews()
|
||||||
@@ -156,52 +150,10 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
observeViewModel()
|
observeViewModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun autoSmbt(ignoreCuvette : Boolean = true){
|
|
||||||
submitClick = true
|
|
||||||
checkSubmit = true
|
|
||||||
lifecycleScope.launch {
|
|
||||||
delay(100)
|
|
||||||
}
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
|
|
||||||
if (checkSubmit) {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
trueHemeTestViewModel.uploadHemoCubeResultToDatabase(
|
|
||||||
isOnline,
|
|
||||||
true,
|
|
||||||
sharedPreferences.getString(Constants.KIT_NUMBER, ""),
|
|
||||||
quickCapture
|
|
||||||
)
|
|
||||||
Toast.makeText(requireContext(), "Auto Sumbitted", Toast.LENGTH_SHORT).show()
|
|
||||||
} else {
|
|
||||||
checkCuvettePresence()
|
|
||||||
binding.btnSubmit.isEnabled = true
|
|
||||||
binding.btnSubmit.isClickable = true
|
|
||||||
Toast.makeText(requireContext(), "Auto Sumbit Failed ", Toast.LENGTH_SHORT).show()
|
|
||||||
binding.btnSubmit.visibility = View.VISIBLE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
private fun initViews() {
|
private fun initViews() {
|
||||||
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()) {
|
// with(sharedPreferences.edit()) {
|
||||||
// putBoolean(Constants.QUICK_CAPTURE, false)
|
// putBoolean(Constants.QUICK_CAPTURE, false)
|
||||||
@@ -706,8 +658,6 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
showRetryButtonForCuvette()
|
showRetryButtonForCuvette()
|
||||||
}
|
}
|
||||||
|
|
||||||
//need to change where check submit
|
|
||||||
resultData.contains("#CIN") && this.submitClick && this.testStatusCode < TestStatus.CUVETTE_PRESENTT.code -> {
|
resultData.contains("#CIN") && this.submitClick && this.testStatusCode < TestStatus.CUVETTE_PRESENTT.code -> {
|
||||||
trueHemeTestViewModel.messages.postValue(getString(R.string.cuvette_presentt))
|
trueHemeTestViewModel.messages.postValue(getString(R.string.cuvette_presentt))
|
||||||
this.testStatusCode = TestStatus.CUVETTE_PRESENTT.code
|
this.testStatusCode = TestStatus.CUVETTE_PRESENTT.code
|
||||||
@@ -715,8 +665,6 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
binding.testing.visibility = View.GONE
|
binding.testing.visibility = View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
resultData.contains("#AIN") && this.submitClick && this.testStatusCode <= TestStatus.CUVETTE_ABSENTT.code -> {
|
resultData.contains("#AIN") && this.submitClick && this.testStatusCode <= TestStatus.CUVETTE_ABSENTT.code -> {
|
||||||
trueHemeTestViewModel.messages.postValue(getString(R.string.cuvette_absentt))
|
trueHemeTestViewModel.messages.postValue(getString(R.string.cuvette_absentt))
|
||||||
this.testStatusCode = TestStatus.CUVETTE_ABSENTT.code
|
this.testStatusCode = TestStatus.CUVETTE_ABSENTT.code
|
||||||
@@ -1009,15 +957,11 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
|
|
||||||
if (readingsPerSample == 1) {
|
if (readingsPerSample == 1) {
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
|
binding.btnSubmit.visibility = View.VISIBLE
|
||||||
//changing to invisible
|
binding.btnSubmit.isEnabled = true
|
||||||
binding.btnSubmit.visibility = View.GONE
|
binding.btnSubmit.isClickable = true
|
||||||
// binding.btnSubmit.isEnabled = true
|
|
||||||
// binding.btnSubmit.isClickable = true
|
|
||||||
// binding.clParent.setBackgroundColor(Color.parseColor("#edfffd"))
|
// binding.clParent.setBackgroundColor(Color.parseColor("#edfffd"))
|
||||||
autoSmbt(true)
|
|
||||||
binding.ivCheck.visibility = View.VISIBLE
|
binding.ivCheck.visibility = View.VISIBLE
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
trueHemeTestViewModel.uploadHemoCubeResultToDatabase(
|
trueHemeTestViewModel.uploadHemoCubeResultToDatabase(
|
||||||
@@ -1825,7 +1769,4 @@ class TrueHemeTestFragment : Fragment() {
|
|||||||
private fun generateTwoDigitRandomNumber(): Int {
|
private fun generateTwoDigitRandomNumber(): Int {
|
||||||
return Random.nextInt(10, 100)
|
return Random.nextInt(10, 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import androidx.work.PeriodicWorkRequestBuilder
|
|||||||
import androidx.work.WorkManager
|
import androidx.work.WorkManager
|
||||||
import com.example.hpostesting.util.CsvWriter
|
import com.example.hpostesting.util.CsvWriter
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
|
import com.example.hpostesting.util.NetworkStatusLiveData
|
||||||
import com.example.hpostesting.util.Result
|
import com.example.hpostesting.util.Result
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
||||||
@@ -49,7 +50,6 @@ import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
|||||||
import com.example.hpostesting.data.repository.Repository
|
import com.example.hpostesting.data.repository.Repository
|
||||||
import com.example.hpostesting.domain.CheckUpdateWorker
|
import com.example.hpostesting.domain.CheckUpdateWorker
|
||||||
import com.example.hpostesting.domain.LogFileManager
|
import com.example.hpostesting.domain.LogFileManager
|
||||||
import com.example.hpostesting.util.NetworkMonitor
|
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -72,7 +72,6 @@ class TrueHemeTestViewModel @Inject constructor(
|
|||||||
private val repository: Repository,
|
private val repository: Repository,
|
||||||
private val logFileManager: LogFileManager,
|
private val logFileManager: LogFileManager,
|
||||||
private val localFileDataSource: LocalFileDataSource,
|
private val localFileDataSource: LocalFileDataSource,
|
||||||
networkMonitor: NetworkMonitor,
|
|
||||||
context: Context,
|
context: Context,
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
private var testUpload: Boolean = false
|
private var testUpload: Boolean = false
|
||||||
@@ -88,9 +87,6 @@ class TrueHemeTestViewModel @Inject constructor(
|
|||||||
// init {
|
// init {
|
||||||
// startPeriodicCheckUpdate()
|
// startPeriodicCheckUpdate()
|
||||||
// }
|
// }
|
||||||
init {
|
|
||||||
networkMonitor.startMonitoring()
|
|
||||||
}
|
|
||||||
|
|
||||||
val loginResponse = MutableLiveData<Result<LoginResponse>>()
|
val loginResponse = MutableLiveData<Result<LoginResponse>>()
|
||||||
|
|
||||||
@@ -107,7 +103,7 @@ class TrueHemeTestViewModel @Inject constructor(
|
|||||||
|
|
||||||
// Get the device ID of the device you want to retrieve data for (e.g., the first device in the list)
|
// Get the device ID of the device you want to retrieve data for (e.g., the first device in the list)
|
||||||
|
|
||||||
private val _networkStatusLiveData =networkMonitor.isConnected
|
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||||
val allUserData = hemoCubeDao.getAll()
|
val allUserData = hemoCubeDao.getAll()
|
||||||
val allLocalData = hemoCubeDao.getAll()
|
val allLocalData = hemoCubeDao.getAll()
|
||||||
val allPendingUserToUpload = hemoCubeDao.getPendingUser()
|
val allPendingUserToUpload = hemoCubeDao.getPendingUser()
|
||||||
@@ -801,5 +797,4 @@ class TrueHemeTestViewModel @Inject constructor(
|
|||||||
hemoCubeDao.updateTest(testDetails!!)
|
hemoCubeDao.updateTest(testDetails!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,117 +0,0 @@
|
|||||||
package com.example.hpostesting.util
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.content.Context
|
|
||||||
import android.net.ConnectivityManager
|
|
||||||
import android.net.Network
|
|
||||||
import android.net.NetworkCapabilities
|
|
||||||
import android.net.NetworkRequest
|
|
||||||
import androidx.lifecycle.LiveData
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.SupervisorJob
|
|
||||||
import kotlinx.coroutines.cancel
|
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import kotlinx.coroutines.isActive
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import java.net.HttpURLConnection
|
|
||||||
import java.net.URL
|
|
||||||
import javax.inject.Inject
|
|
||||||
import javax.inject.Singleton
|
|
||||||
|
|
||||||
|
|
||||||
@Singleton
|
|
||||||
class NetworkMonitor @Inject constructor(
|
|
||||||
@ApplicationContext private val context: Context
|
|
||||||
) {
|
|
||||||
private var isMonitoringStarted = false
|
|
||||||
private val connectivityManager =
|
|
||||||
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
|
||||||
|
|
||||||
private val _isConnected = MutableLiveData(false)
|
|
||||||
val isConnected: LiveData<Boolean> get() = _isConnected
|
|
||||||
|
|
||||||
private val networkScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
|
||||||
|
|
||||||
private val networkCallback = object : ConnectivityManager.NetworkCallback() {
|
|
||||||
override fun onAvailable(network: Network) {
|
|
||||||
performPingCheck()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onLost(network: Network) {
|
|
||||||
_isConnected.postValue(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCapabilitiesChanged(
|
|
||||||
network: Network, networkCapabilities: NetworkCapabilities
|
|
||||||
) {
|
|
||||||
// Recheck connectivity when capabilities change (e.g., network becomes validated)
|
|
||||||
performPingCheck()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
|
||||||
fun startMonitoring() {
|
|
||||||
if (isMonitoringStarted) return // Already started, do nothing.
|
|
||||||
isMonitoringStarted = true
|
|
||||||
// Check initial connectivity status
|
|
||||||
val network = connectivityManager.activeNetwork
|
|
||||||
val capabilities = connectivityManager.getNetworkCapabilities(network)
|
|
||||||
val isInitiallyConnected = capabilities?.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) == true
|
|
||||||
|
|
||||||
if (isInitiallyConnected) {
|
|
||||||
performPingCheck()
|
|
||||||
} else {
|
|
||||||
_isConnected.postValue(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
val networkRequest =
|
|
||||||
NetworkRequest.Builder().addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
|
|
||||||
.build()
|
|
||||||
|
|
||||||
connectivityManager.registerNetworkCallback(networkRequest, networkCallback)
|
|
||||||
// Start periodic checks:
|
|
||||||
startPeriodicPingCheck()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun stopMonitoring() { // never needed to call
|
|
||||||
try {
|
|
||||||
connectivityManager.unregisterNetworkCallback(networkCallback)
|
|
||||||
} catch (_: IllegalArgumentException) {
|
|
||||||
// Ignore if callback was not registered
|
|
||||||
}
|
|
||||||
networkScope.cancel()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun performPingCheck() {
|
|
||||||
networkScope.launch {
|
|
||||||
try {
|
|
||||||
val url = URL("https://www.google.com")
|
|
||||||
val connection = url.openConnection() as HttpURLConnection
|
|
||||||
connection.connectTimeout = 2000
|
|
||||||
connection.readTimeout = 2000
|
|
||||||
connection.setRequestProperty("Connection", "close")
|
|
||||||
connection.connect()
|
|
||||||
|
|
||||||
// Consider any 2xx response as successful
|
|
||||||
val isReachable = connection.responseCode in 200..299
|
|
||||||
_isConnected.postValue(isReachable)
|
|
||||||
connection.disconnect()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
_isConnected.postValue(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun startPeriodicPingCheck(intervalMillis: Long = 1 * 60_000L) {
|
|
||||||
networkScope.launch {
|
|
||||||
while (isActive) {
|
|
||||||
performPingCheck()
|
|
||||||
delay(intervalMillis)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* // Copyright (c) 2024 ShanMukha Innovations Pvt. Ltd. All rights reserved.
|
||||||
|
* // Notice: All information contained herein is, and remains
|
||||||
|
* // the property of ShanMukha Innovations Pvt. Ltd. and its suppliers,
|
||||||
|
* // if any. The intellectual and technical concepts contained
|
||||||
|
* // herein are proprietary to ShanMukha Innovations Pvt. Ltd.
|
||||||
|
* // and its suppliers and may be covered by Indian and Foreign Patents,
|
||||||
|
* // patents in process, and are protected by trade secret or copyright law.
|
||||||
|
* // Dissemination of this information or reproduction of this material
|
||||||
|
* // is strictly forbidden unless prior written permission is obtained
|
||||||
|
* // from ShanMukha Innovations Pvt. Ltd.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.example.hpostesting.util
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.net.ConnectivityManager
|
||||||
|
import android.net.Network
|
||||||
|
import android.net.NetworkCapabilities
|
||||||
|
import android.net.NetworkRequest
|
||||||
|
import android.os.Build
|
||||||
|
import androidx.annotation.RequiresApi
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
|
||||||
|
class NetworkStatusLiveData(context: Context) : LiveData<Boolean>() {
|
||||||
|
|
||||||
|
private val connectivityManager: ConnectivityManager =
|
||||||
|
context.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||||
|
|
||||||
|
private val networkCallback = object : ConnectivityManager.NetworkCallback() {
|
||||||
|
override fun onAvailable(network: Network) {
|
||||||
|
postValue(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onLost(network: Network) {
|
||||||
|
postValue(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.M)
|
||||||
|
override fun onActive() {
|
||||||
|
super.onActive()
|
||||||
|
postValue(isNetworkAvailable())
|
||||||
|
registerNetworkCallback()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onInactive() {
|
||||||
|
super.onInactive()
|
||||||
|
unregisterNetworkCallback()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun registerNetworkCallback() {
|
||||||
|
val networkRequest = NetworkRequest.Builder()
|
||||||
|
.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
|
||||||
|
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
|
||||||
|
.addTransportType(NetworkCapabilities.TRANSPORT_ETHERNET)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
connectivityManager.registerNetworkCallback(networkRequest, networkCallback)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun unregisterNetworkCallback() {
|
||||||
|
connectivityManager.unregisterNetworkCallback(networkCallback)
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.M)
|
||||||
|
private fun isNetworkAvailable(): Boolean {
|
||||||
|
val network = connectivityManager.activeNetwork
|
||||||
|
val networkCapabilities = connectivityManager.getNetworkCapabilities(network)
|
||||||
|
return networkCapabilities != null &&
|
||||||
|
networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) &&
|
||||||
|
networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
|
||||||
|
|
||||||
<path android:fillColor="@android:color/white" android:pathData="M7,5h10v2h2L19,3c0,-1.1 -0.9,-1.99 -2,-1.99L7,1c-1.1,0 -2,0.9 -2,2v4h2L7,5zM15.41,16.59L20,12l-4.59,-4.59L14,8.83 17.17,12 14,15.17l1.41,1.42zM10,15.17L6.83,12 10,8.83 8.59,7.41 4,12l4.59,4.59L10,15.17zM17,19L7,19v-2L5,17v4c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2v-4h-2v2z"/>
|
|
||||||
|
|
||||||
</vector>
|
|
||||||
@@ -55,20 +55,6 @@
|
|||||||
app:layout_constraintTop_toBottomOf="@id/tv_subtitle4" />
|
app:layout_constraintTop_toBottomOf="@id/tv_subtitle4" />
|
||||||
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/btn_rnd"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginHorizontal="16dp"
|
|
||||||
android:layout_marginTop="24dp"
|
|
||||||
android:clickable="false"
|
|
||||||
android:text="R and D"
|
|
||||||
android:textColor="@color/white"
|
|
||||||
app:cornerRadius="16dp"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_submit" />
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn_diagnostics"
|
android:id="@+id/btn_diagnostics"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -81,7 +67,7 @@
|
|||||||
app:cornerRadius="16dp"
|
app:cornerRadius="16dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_rnd" />
|
app:layout_constraintTop_toBottomOf="@id/btn_submit" />
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/btn_auto_dac"
|
android:id="@+id/btn_auto_dac"
|
||||||
@@ -167,7 +153,6 @@
|
|||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_deviceProvision" />
|
app:layout_constraintTop_toBottomOf="@id/btn_deviceProvision" />
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/btn_update_values"
|
android:id="@+id/btn_update_values"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -175,13 +160,12 @@
|
|||||||
android:layout_marginHorizontal="16dp"
|
android:layout_marginHorizontal="16dp"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
android:clickable="false"
|
android:clickable="false"
|
||||||
android:text="Update valueLs"
|
android:text="Update values"
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
app:cornerRadius="16dp"
|
app:cornerRadius="16dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/btn_reset_password" />
|
app:layout_constraintTop_toBottomOf="@id/btn_reset_password" />
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/btn_firefox"
|
android:id="@+id/btn_firefox"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
38
app/src/main/res/layout/server_selector_drop_down.xml
Normal file
38
app/src/main/res/layout/server_selector_drop_down.xml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?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>
|
||||||
@@ -25,7 +25,6 @@
|
|||||||
<item>ka</item>
|
<item>ka</item>
|
||||||
<!-- Use language codes (e.g., en, kn) as values -->
|
<!-- Use language codes (e.g., en, kn) as values -->
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="district">
|
<string-array name="district">
|
||||||
<item>Mysuru</item>
|
<item>Mysuru</item>
|
||||||
<item>Kodagu</item>
|
<item>Kodagu</item>
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ package com.example.hpostesting
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
|
import com.example.hpostesting.util.NetworkStatusLiveData
|
||||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||||
import com.example.hpostesting.data.model.Response
|
import com.example.hpostesting.data.model.Response
|
||||||
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
||||||
import com.example.hpostesting.data.repository.Repository
|
import com.example.hpostesting.data.repository.Repository
|
||||||
import com.example.hpostesting.presentation.autodac.AutoDacViewModel
|
import com.example.hpostesting.presentation.autodac.AutoDacViewModel
|
||||||
import com.example.hpostesting.util.NetworkMonitor
|
|
||||||
import io.mockk.*
|
import io.mockk.*
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
@@ -43,7 +43,7 @@ class AutoDacViewModelTest {
|
|||||||
private val repository = mockk<Repository>()
|
private val repository = mockk<Repository>()
|
||||||
private val context = mockk<Context>()
|
private val context = mockk<Context>()
|
||||||
private val sharedPreferences = mockk<SharedPreferences>()
|
private val sharedPreferences = mockk<SharedPreferences>()
|
||||||
private val networkStatusLiveData = mockk<NetworkMonitor>()
|
private val networkStatusLiveData = mockk<NetworkStatusLiveData>()
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
@@ -54,7 +54,7 @@ class AutoDacViewModelTest {
|
|||||||
every { context.getSystemService(any()) } returns networkStatusLiveData
|
every { context.getSystemService(any()) } returns networkStatusLiveData
|
||||||
|
|
||||||
// Mocking the NetworkStatusLiveData
|
// Mocking the NetworkStatusLiveData
|
||||||
every { networkStatusLiveData.startMonitoring() } just Runs
|
every { networkStatusLiveData.observe(any(), any()) } just Runs
|
||||||
|
|
||||||
every { hemoCubeDao.getAll() } returns mockk()
|
every { hemoCubeDao.getAll() } returns mockk()
|
||||||
// every { repository.addDiagnostics(any()) } returns Response.Success(Unit)
|
// every { repository.addDiagnostics(any()) } returns Response.Success(Unit)
|
||||||
|
|||||||
@@ -25,3 +25,4 @@ plugins {
|
|||||||
task clean(type: Delete) {
|
task clean(type: Delete) {
|
||||||
delete rootProject.buildDir
|
delete rootProject.buildDir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user