Compare commits
2 Commits
dev-molbio
...
dev-check-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a31d26bc1 | ||
|
|
3199caae5c |
@@ -19,8 +19,8 @@ android {
|
|||||||
applicationId "in.sminnovations.hpostesting.dev"
|
applicationId "in.sminnovations.hpostesting.dev"
|
||||||
minSdk 21
|
minSdk 21
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 120
|
versionCode 114
|
||||||
versionName "2.1.120"
|
versionName "2.1.114"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.example.hpostesting.util
|
package com.example.hpostesting.data
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Environment
|
import android.os.Environment
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.example.hpostesting.data.constant
|
package com.example.hpostesting.data
|
||||||
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.example.hpostesting.util
|
package com.example.hpostesting.data
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.example.hpostesting.util
|
package com.example.hpostesting.data
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.example.hpostesting.util
|
package com.example.hpostesting.data
|
||||||
|
|
||||||
sealed class Result<out T : Any> {
|
sealed class Result<out T : Any> {
|
||||||
data class Success<out T : Any>(val data: T) : Result<T>()
|
data class Success<out T : Any>(val data: T) : Result<T>()
|
||||||
@@ -1,6 +1,12 @@
|
|||||||
package com.example.hpostesting.presentation.utils
|
package com.example.hpostesting.data.api
|
||||||
|
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
|
import com.example.hpostesting.presentation.UsbServiceListener
|
||||||
|
|
||||||
|
interface PropertyProvider {
|
||||||
|
|
||||||
|
fun getProperty(key: String): String
|
||||||
|
}
|
||||||
|
|
||||||
interface DeviceCommunicationHandler {
|
interface DeviceCommunicationHandler {
|
||||||
fun sendAndListenToDevice(command: HemoCubeCommands, listener: UsbServiceListener)
|
fun sendAndListenToDevice(command: HemoCubeCommands, listener: UsbServiceListener)
|
||||||
@@ -5,7 +5,6 @@ import androidx.room.Dao
|
|||||||
import androidx.room.Insert
|
import androidx.room.Insert
|
||||||
import androidx.room.OnConflictStrategy
|
import androidx.room.OnConflictStrategy
|
||||||
import androidx.room.Query
|
import androidx.room.Query
|
||||||
import androidx.room.Update
|
|
||||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
@Dao
|
@Dao
|
||||||
@@ -13,12 +12,6 @@ interface HemoCubeDao {
|
|||||||
@Query("SELECT * from hemo_cube_test_table")
|
@Query("SELECT * from hemo_cube_test_table")
|
||||||
fun getAll(): LiveData<List<HemoCubeTestData>>
|
fun getAll(): LiveData<List<HemoCubeTestData>>
|
||||||
|
|
||||||
@Query("SELECT * from hemo_cube_test_table WHERE molbioFlag=false")
|
|
||||||
fun getMolbioPending(): List<HemoCubeTestData>
|
|
||||||
|
|
||||||
@Query("SELECT * from hemo_cube_test_table WHERE localFlag=false")
|
|
||||||
fun getFirebasePending():List<HemoCubeTestData>
|
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
suspend fun insertAll(hemoCubeTestData: HemoCubeTestData)
|
suspend fun insertAll(hemoCubeTestData: HemoCubeTestData)
|
||||||
|
|
||||||
@@ -37,7 +30,7 @@ interface HemoCubeDao {
|
|||||||
@Query("UPDATE hemo_cube_test_table SET isCSVCreated = :newValue WHERE _id = :id")
|
@Query("UPDATE hemo_cube_test_table SET isCSVCreated = :newValue WHERE _id = :id")
|
||||||
suspend fun updateCSVFieldById(id: String, newValue: Boolean)
|
suspend fun updateCSVFieldById(id: String, newValue: Boolean)
|
||||||
|
|
||||||
@Query("SELECT * from hemo_cube_test_table WHERE localFlag = 0")
|
@Query("SELECT * from hemo_cube_test_table WHERE molbioFlag = :status")
|
||||||
fun getPendingUser(): LiveData<List<HemoCubeTestData>>
|
suspend fun getPendingUser(status: Boolean): List<HemoCubeTestData>
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ import com.example.hpostesting.data.model.patient.UserData
|
|||||||
|
|
||||||
@Database(
|
@Database(
|
||||||
entities = [UserData::class, HemoCubeTestData::class, DeviceData::class, BufferCheckData::class],
|
entities = [UserData::class, HemoCubeTestData::class, DeviceData::class, BufferCheckData::class],
|
||||||
version = 29,
|
version = 28,
|
||||||
exportSchema = false
|
exportSchema = false
|
||||||
)
|
)
|
||||||
@TypeConverters(Converters::class)
|
@TypeConverters(Converters::class)
|
||||||
|
|||||||
@@ -89,9 +89,8 @@ class LocalFileDataSourceImpl @Inject constructor() : LocalFileDataSource {
|
|||||||
)
|
)
|
||||||
csvWriter.writeNext(header)
|
csvWriter.writeNext(header)
|
||||||
|
|
||||||
// Filter and write data rows where testStatus is true
|
// Write data rows
|
||||||
val filteredDataList = dataList.filter { it.testStatus == true }
|
for (data in dataList) {
|
||||||
for (data in filteredDataList) {
|
|
||||||
val row = arrayOf(
|
val row = arrayOf(
|
||||||
data._id,
|
data._id,
|
||||||
data.name,
|
data.name,
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ import androidx.room.PrimaryKey
|
|||||||
|
|
||||||
@Entity(tableName = "hemo_cube_test_table")
|
@Entity(tableName = "hemo_cube_test_table")
|
||||||
data class HemoCubeTestData(
|
data class HemoCubeTestData(
|
||||||
@PrimaryKey(autoGenerate = true)
|
@PrimaryKey
|
||||||
var sampleid: Int = 0,
|
|
||||||
var _id: String = "",
|
var _id: String = "",
|
||||||
var name: String = "",
|
var name: String = "",
|
||||||
var incubationTime: String = "",
|
var incubationTime: String = "",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.example.hpostesting.data.repository
|
package com.example.hpostesting.data.repository
|
||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import com.example.hpostesting.util.Result
|
import com.example.hpostesting.data.Result
|
||||||
import com.example.hpostesting.data.api.MolbioAuthApi
|
import com.example.hpostesting.data.api.MolbioAuthApi
|
||||||
import com.example.hpostesting.data.api.MolbioResultApi
|
import com.example.hpostesting.data.api.MolbioResultApi
|
||||||
import com.example.hpostesting.data.model.PendingUploads
|
import com.example.hpostesting.data.model.PendingUploads
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.example.hpostesting.data.repository
|
package com.example.hpostesting.data.repository
|
||||||
|
|
||||||
import com.example.hpostesting.util.Result
|
import com.example.hpostesting.data.Result
|
||||||
import com.example.hpostesting.data.model.Response
|
import com.example.hpostesting.data.model.Response
|
||||||
import com.example.hpostesting.data.model.devicediagnostics.DeviceDiagnosticsRequest
|
import com.example.hpostesting.data.model.devicediagnostics.DeviceDiagnosticsRequest
|
||||||
import com.example.hpostesting.data.model.devicediagnostics.DeviceDiagnosticsResponse
|
import com.example.hpostesting.data.model.devicediagnostics.DeviceDiagnosticsResponse
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.example.hpostesting.di
|
package com.example.hpostesting.domain.di
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
@@ -7,7 +7,7 @@ import android.content.res.AssetManager
|
|||||||
import androidx.room.Room
|
import androidx.room.Room
|
||||||
import com.example.hpostesting.data.api.MolbioAuthApi
|
import com.example.hpostesting.data.api.MolbioAuthApi
|
||||||
import com.example.hpostesting.data.api.MolbioResultApi
|
import com.example.hpostesting.data.api.MolbioResultApi
|
||||||
import com.example.hpostesting.util.PropertyProvider
|
import com.example.hpostesting.data.api.PropertyProvider
|
||||||
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
||||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||||
import com.example.hpostesting.data.dao.MyDatabase
|
import com.example.hpostesting.data.dao.MyDatabase
|
||||||
@@ -22,8 +22,8 @@ import com.example.hpostesting.domain.LogFileManager
|
|||||||
import com.example.hpostesting.domain.LogFileManagerImpl
|
import com.example.hpostesting.domain.LogFileManagerImpl
|
||||||
import com.example.hpostesting.domain.SaveRawData
|
import com.example.hpostesting.domain.SaveRawData
|
||||||
import com.example.hpostesting.domain.SaveRawDataTest
|
import com.example.hpostesting.domain.SaveRawDataTest
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListenerImpl
|
import com.example.hpostesting.presentation.UsbServiceListenerImpl
|
||||||
import com.example.hpostesting.util.PropertyProviderImpl
|
import com.example.hpostesting.util.PropertyProviderImpl
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
import dagger.Provides
|
import dagger.Provides
|
||||||
@@ -147,7 +147,7 @@ object AppModule {
|
|||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun provideRetrofit(
|
fun provideRetrofit(
|
||||||
propertyProvider: PropertyProvider, @Named("Auth") client: OkHttpClient
|
propertyProvider: PropertyProvider,@Named("Auth") client: OkHttpClient
|
||||||
): Retrofit {
|
): Retrofit {
|
||||||
return Retrofit.Builder().baseUrl(propertyProvider.getProperty("BASE_URL")).client(client)
|
return Retrofit.Builder().baseUrl(propertyProvider.getProperty("BASE_URL")).client(client)
|
||||||
.addConverterFactory(GsonConverterFactory.create()).build()
|
.addConverterFactory(GsonConverterFactory.create()).build()
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package com.example.hpostesting.encryption
|
|
||||||
|
|
||||||
import android.util.Base64
|
|
||||||
import javax.crypto.Cipher
|
|
||||||
import javax.crypto.SecretKeyFactory
|
|
||||||
import javax.crypto.spec.IvParameterSpec
|
|
||||||
import javax.crypto.spec.PBEKeySpec
|
|
||||||
import javax.crypto.spec.SecretKeySpec
|
|
||||||
|
|
||||||
object Encryption {
|
|
||||||
private const val AES_MODE = "AES/CBC/PKCS5Padding"
|
|
||||||
private const val KEY_SPEC_ALGORITHM = "PBKDF2WithHmacSHA1"
|
|
||||||
private const val SALT = "Bigtec"
|
|
||||||
private const val ITERATION_COUNT = 10000
|
|
||||||
private const val KEY_LENGTH = 256
|
|
||||||
private val FIXED_IV = byteArrayOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
|
|
||||||
|
|
||||||
fun encrypt(textToEncrypt: String, password: String): String {
|
|
||||||
val salt = SALT.toByteArray()
|
|
||||||
val factory = SecretKeyFactory.getInstance(KEY_SPEC_ALGORITHM)
|
|
||||||
val spec = PBEKeySpec(password.toCharArray(), salt, ITERATION_COUNT, KEY_LENGTH)
|
|
||||||
val tmp = factory.generateSecret(spec)
|
|
||||||
val key = SecretKeySpec(tmp.encoded, "AES")
|
|
||||||
val cipher = Cipher.getInstance(AES_MODE)
|
|
||||||
cipher.init(Cipher.ENCRYPT_MODE, key, IvParameterSpec(FIXED_IV))
|
|
||||||
val encryptedBytes = cipher.doFinal(textToEncrypt.toByteArray(Charsets.UTF_8))
|
|
||||||
return Base64.encodeToString(encryptedBytes, Base64.NO_WRAP)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun decrypt(encryptedText: String, password: String): String {
|
|
||||||
val salt = SALT.toByteArray()
|
|
||||||
val encryptedBytes = Base64.decode(encryptedText, Base64.NO_WRAP)
|
|
||||||
val factory = SecretKeyFactory.getInstance(KEY_SPEC_ALGORITHM)
|
|
||||||
val spec = PBEKeySpec(password.toCharArray(), salt, ITERATION_COUNT, KEY_LENGTH)
|
|
||||||
val tmp = factory.generateSecret(spec)
|
|
||||||
val key = SecretKeySpec(tmp.encoded, "AES")
|
|
||||||
val cipher = Cipher.getInstance(AES_MODE)
|
|
||||||
cipher.init(Cipher.DECRYPT_MODE, key, IvParameterSpec(FIXED_IV))
|
|
||||||
val decryptedBytes = cipher.doFinal(encryptedBytes)
|
|
||||||
return String(decryptedBytes, Charsets.UTF_8)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,7 @@ import android.view.View
|
|||||||
import android.widget.EditText
|
import android.widget.EditText
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.example.hpostesting.presentation
|
||||||
|
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
|
||||||
|
class MainViewModel : ViewModel() {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.example.hpostesting.presentation.utils
|
package com.example.hpostesting.presentation
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
@@ -13,7 +13,7 @@ import androidx.activity.result.contract.ActivityResultContracts
|
|||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import com.example.hpostesting.util.MyUtils
|
import com.example.hpostesting.util.MyUtils
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.example.hpostesting.presentation.utils
|
package com.example.hpostesting.presentation
|
||||||
|
|
||||||
interface UsbServiceListener {
|
interface UsbServiceListener {
|
||||||
fun onUsbRead(data: ByteArray?)
|
fun onUsbRead(data: ByteArray?)
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
package com.example.hpostesting.presentation.utils
|
package com.example.hpostesting.presentation
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
|
||||||
|
|
||||||
class UsbServiceListenerImpl(private val context: Context): UsbServiceListener {
|
class UsbServiceListenerImpl(private val context: Context): UsbServiceListener {
|
||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
@@ -11,7 +11,7 @@ import androidx.navigation.findNavController
|
|||||||
import androidx.recyclerview.widget.AsyncListDiffer
|
import androidx.recyclerview.widget.AsyncListDiffer
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import androidx.fragment.app.FragmentActivity
|
|||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
import com.firebase.ui.firestore.FirestoreRecyclerAdapter
|
import com.firebase.ui.firestore.FirestoreRecyclerAdapter
|
||||||
|
|||||||
@@ -13,8 +13,9 @@ import android.widget.AdapterView
|
|||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
import android.widget.Spinner
|
import android.widget.Spinner
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.model.patient.UserData
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import androidx.activity.viewModels
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.testRight.UsbService
|
import com.example.hpostesting.presentation.testRight.UsbService
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import com.example.hpostesting.data.constant.Constants
|
|||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.UsbServiceListener
|
||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentAutoDacBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentAutoDacBinding
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package com.example.hpostesting.presentation.blank
|
||||||
|
|
||||||
|
class BlankActivity {
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package com.example.hpostesting.presentation.blank
|
||||||
|
|
||||||
|
class BlankFragment {
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package com.example.hpostesting.presentation.blank
|
||||||
|
|
||||||
|
class BlankViewModel {
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@ import com.example.hpostesting.data.constant.Constants
|
|||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
import com.example.hpostesting.data.model.patient.BufferCheckData
|
import com.example.hpostesting.data.model.patient.BufferCheckData
|
||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import androidx.activity.viewModels
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import androidx.activity.viewModels
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.testRight.UsbService
|
import com.example.hpostesting.presentation.testRight.UsbService
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import com.example.hpostesting.data.constant.Constants
|
|||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
import com.example.hpostesting.data.model.calibration.CalibrationData
|
import com.example.hpostesting.data.model.calibration.CalibrationData
|
||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
package com.example.hpostesting.presentation.dashboard
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.SharedPreferences
|
|
||||||
import android.os.BatteryManager
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.util.Log
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.fragment.app.activityViewModels
|
|
||||||
import com.example.hpostesting.data.constant.Constants
|
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
|
||||||
import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
|
||||||
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
|
||||||
import com.example.hpostesting.presentation.adapter.UserListAdapter
|
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
|
||||||
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
|
||||||
import `in`.sminnovations.hpostesting.R
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentActivitiesBinding
|
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentHomeBinding
|
|
||||||
|
|
||||||
class ActivitiesFragment : Fragment() {
|
|
||||||
private lateinit var binding: FragmentActivitiesBinding
|
|
||||||
private val hemoCubeViewModel: HemoCubeViewModel by activityViewModels()
|
|
||||||
private lateinit var adapter: OfflineUserListAdapter
|
|
||||||
|
|
||||||
override fun onCreateView(
|
|
||||||
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?,
|
|
||||||
): View {
|
|
||||||
binding = FragmentActivitiesBinding.inflate(inflater, container, false)
|
|
||||||
|
|
||||||
return binding.root
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
||||||
super.onViewCreated(view, savedInstanceState)
|
|
||||||
|
|
||||||
hemoCubeViewModel.allPendingUserToUpload.observe(viewLifecycleOwner) { userData ->
|
|
||||||
|
|
||||||
if (userData.isNotEmpty()) {
|
|
||||||
binding.rvOrderOffline.visibility = View.VISIBLE
|
|
||||||
binding.noDataText.visibility = View.GONE
|
|
||||||
val bm =
|
|
||||||
requireContext().getSystemService(Context.BATTERY_SERVICE) as BatteryManager
|
|
||||||
val batLevel: Int = bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY)
|
|
||||||
adapter = OfflineUserListAdapter(binding.root, batLevel)
|
|
||||||
adapter.differ.submitList(userData)
|
|
||||||
binding.rvOrderOffline.adapter = adapter
|
|
||||||
}else{
|
|
||||||
binding.rvOrderOffline.visibility = View.GONE
|
|
||||||
binding.noDataText.visibility = View.VISIBLE
|
|
||||||
Log.d("Activities","Nothing to show")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -3,8 +3,8 @@ package com.example.hpostesting.presentation.dashboard
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.IntentFilter
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.content.pm.PackageManager
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@@ -20,22 +20,30 @@ import androidx.navigation.ui.AppBarConfiguration
|
|||||||
import androidx.navigation.ui.navigateUp
|
import androidx.navigation.ui.navigateUp
|
||||||
import androidx.navigation.ui.setupActionBarWithNavController
|
import androidx.navigation.ui.setupActionBarWithNavController
|
||||||
import androidx.navigation.ui.setupWithNavController
|
import androidx.navigation.ui.setupWithNavController
|
||||||
import com.example.hpostesting.util.Result
|
import com.example.hpostesting.data.Result
|
||||||
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.updates.DeviceUpdateRequest
|
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
||||||
import com.example.hpostesting.presentation.utils.NatsManager
|
import com.example.hpostesting.presentation.NatsManager
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
import com.example.hpostesting.presentation.jig.JigActivity
|
import com.example.hpostesting.presentation.jig.JigActivity
|
||||||
import com.google.android.material.navigation.NavigationView
|
import com.google.android.material.navigation.NavigationView
|
||||||
import com.google.firebase.appdistribution.FirebaseAppDistribution
|
import com.google.firebase.appdistribution.FirebaseAppDistribution
|
||||||
import com.google.firebase.appdistribution.FirebaseAppDistributionException
|
import com.google.firebase.appdistribution.FirebaseAppDistributionException
|
||||||
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
import com.google.firebase.crashlytics.FirebaseCrashlytics
|
||||||
|
import com.google.firebase.firestore.ktx.firestore
|
||||||
|
import com.google.firebase.ktx.Firebase
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
import `in`.sminnovations.hpostesting.BuildConfig
|
import `in`.sminnovations.hpostesting.BuildConfig
|
||||||
import `in`.sminnovations.hpostesting.R
|
import `in`.sminnovations.hpostesting.R
|
||||||
import `in`.sminnovations.hpostesting.databinding.ActivityDashboardBinding
|
import `in`.sminnovations.hpostesting.databinding.ActivityDashboardBinding
|
||||||
|
import okhttp3.ResponseBody
|
||||||
|
import java.io.BufferedInputStream
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.io.FileInputStream
|
||||||
|
import java.io.FileOutputStream
|
||||||
|
import java.io.InputStream
|
||||||
|
import java.util.zip.ZipInputStream
|
||||||
|
|
||||||
interface NatsMessageCallback {
|
interface NatsMessageCallback {
|
||||||
fun onMessageReceived(topic: String, message: String)
|
fun onMessageReceived(topic: String, message: String)
|
||||||
@@ -84,9 +92,6 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
nats.connect()
|
nats.connect()
|
||||||
}
|
}
|
||||||
val versionName = getAppVersion(this@DashboardActivity) + " [ " + getAppEnvironment(this@DashboardActivity) + " ]"
|
|
||||||
binding.appBarDashboard.versionName.text = versionName
|
|
||||||
|
|
||||||
|
|
||||||
val deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "")
|
val deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "")
|
||||||
|
|
||||||
@@ -137,7 +142,7 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
|
|
||||||
appBarConfiguration = AppBarConfiguration(
|
appBarConfiguration = AppBarConfiguration(
|
||||||
setOf(
|
setOf(
|
||||||
R.id.nav_home, R.id.nav_profile, R.id.nav_activity,R.id.nav_settings
|
R.id.nav_home, R.id.nav_profile, R.id.nav_settings
|
||||||
), drawerLayout
|
), drawerLayout
|
||||||
)
|
)
|
||||||
setupActionBarWithNavController(navController, appBarConfiguration)
|
setupActionBarWithNavController(navController, appBarConfiguration)
|
||||||
@@ -188,7 +193,7 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
if(isRegistered) {
|
if(isRegistered) {
|
||||||
try {
|
try {
|
||||||
// unregisterReceiver(downloadReceiver)
|
unregisterReceiver(downloadReceiver)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.d("HomeFragment", e.toString())
|
Log.d("HomeFragment", e.toString())
|
||||||
}
|
}
|
||||||
@@ -255,20 +260,4 @@ class DashboardActivity : AppCompatActivity(), IDataCollector {
|
|||||||
serial_no = sharedPreference.getString(Constants.DEVICE_ID, "")
|
serial_no = sharedPreference.getString(Constants.DEVICE_ID, "")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
private fun getAppVersion(context: Context): String {
|
|
||||||
return try {
|
|
||||||
val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
|
|
||||||
pInfo.versionName
|
|
||||||
} catch (e: PackageManager.NameNotFoundException) {
|
|
||||||
"N/A"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private fun getAppEnvironment(context: Context): String {
|
|
||||||
return try {
|
|
||||||
val pInfo = context.packageManager.getPackageInfo(context.packageName, 0)
|
|
||||||
pInfo.packageName.substringAfterLast('.')
|
|
||||||
} catch (e: PackageManager.NameNotFoundException) {
|
|
||||||
"N/A"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -15,8 +15,6 @@ import android.net.Uri
|
|||||||
import android.os.BatteryManager
|
import android.os.BatteryManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Environment
|
|
||||||
import android.provider.Settings
|
|
||||||
import android.util.Base64
|
import android.util.Base64
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
@@ -24,13 +22,12 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.core.content.FileProvider
|
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.util.Result
|
import com.example.hpostesting.data.Result
|
||||||
import com.example.hpostesting.presentation.utils.DeviceCommunicationHandler
|
import com.example.hpostesting.data.api.DeviceCommunicationHandler
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
import com.example.hpostesting.data.model.login.LoginRequest
|
import com.example.hpostesting.data.model.login.LoginRequest
|
||||||
@@ -42,9 +39,8 @@ import com.example.hpostesting.data.model.patient.HemoCubeTestData
|
|||||||
import com.example.hpostesting.data.model.patient.UserData
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
import com.example.hpostesting.data.model.updates.CheckUpdateRequest
|
||||||
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
import com.example.hpostesting.data.model.updates.DeviceUpdateRequest
|
||||||
import com.example.hpostesting.encryption.Encryption
|
|
||||||
import com.example.hpostesting.presentation.KitScanActivity
|
import com.example.hpostesting.presentation.KitScanActivity
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
import com.example.hpostesting.presentation.adapter.OfflineUserListAdapter
|
||||||
import com.example.hpostesting.presentation.adapter.UserListAdapter
|
import com.example.hpostesting.presentation.adapter.UserListAdapter
|
||||||
import com.example.hpostesting.presentation.assurance.AssuranceControlsActivity
|
import com.example.hpostesting.presentation.assurance.AssuranceControlsActivity
|
||||||
@@ -154,7 +150,7 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now re-subscribe to allUserData
|
// Now re-subscribe to allUserData
|
||||||
/* hemoCubeViewModel.allLocalData.observe(viewLifecycleOwner) { originalUserDataList ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { originalUserDataList ->
|
||||||
|
|
||||||
Log.d("LOCAL_DB OBSERVE", "OBSERVE CALLED")
|
Log.d("LOCAL_DB OBSERVE", "OBSERVE CALLED")
|
||||||
|
|
||||||
@@ -210,15 +206,13 @@ class HomeFragment : Fragment() {
|
|||||||
result.rawData?.let { sanitizeDoubleValues(it) }
|
result.rawData?.let { sanitizeDoubleValues(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then, check if there are any results to upload.
|
// Then, check if there are any results to upload.
|
||||||
if (resultList.results?.isNotEmpty() == true) {
|
if (resultList.results?.isNotEmpty() == true) {
|
||||||
hemoCubeViewModel.uploadResult(resultList)
|
hemoCubeViewModel.uploadResult(resultList)
|
||||||
Log.d("resultcount1", "Uploading sanitized results")
|
Log.d("resultcount1", "Uploading sanitized results")
|
||||||
}
|
}
|
||||||
|
|
||||||
}*/
|
}
|
||||||
hemoCubeViewModel.sendDataToMolbio()
|
|
||||||
hemoCubeViewModel.sendDataToFirebase()
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
binding.internetAvailableCL.visibility = View.GONE
|
binding.internetAvailableCL.visibility = View.GONE
|
||||||
@@ -242,34 +236,30 @@ class HomeFragment : Fragment() {
|
|||||||
logoutUser(requireContext())
|
logoutUser(requireContext())
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.btnLogout1.setOnClickListener {
|
|
||||||
logoutUser(requireContext())
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.uploadData.setOnClickListener {
|
binding.uploadData.setOnClickListener {
|
||||||
// showUploadDialog(requireContext())
|
// showUploadDialog(requireContext())
|
||||||
}
|
}
|
||||||
// hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userData ->
|
||||||
//
|
|
||||||
// val btnSaveLocalVisibility =
|
val btnSaveLocalVisibility =
|
||||||
// if (userData.any { it.testStatus == true }) View.GONE else View.GONE
|
if (userData.any { it.testStatus == true }) View.GONE else View.GONE
|
||||||
//
|
|
||||||
// binding.downloadCSV.visibility = btnSaveLocalVisibility
|
binding.downloadCSV.visibility = btnSaveLocalVisibility
|
||||||
//
|
|
||||||
// binding.downloadCSV.setOnClickListener {
|
binding.downloadCSV.setOnClickListener {
|
||||||
// if (btnSaveLocalVisibility == View.VISIBLE) {
|
if (btnSaveLocalVisibility == View.VISIBLE) {
|
||||||
// // Execute the action when the button is visible (testStatus is true for at least one user)
|
// Execute the action when the button is visible (testStatus is true for at least one user)
|
||||||
// showDownloadDialog(requireContext())
|
showDownloadDialog(requireContext())
|
||||||
// } else {
|
} else {
|
||||||
// // Handle the case when the button is not visible
|
// Handle the case when the button is not visible
|
||||||
// Toast.makeText(
|
Toast.makeText(
|
||||||
// requireContext(),
|
requireContext(),
|
||||||
// "No test details stored locally",
|
"No test details stored locally",
|
||||||
// Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
// ).show()
|
).show()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
binding.btnNewKit.setOnClickListener {
|
binding.btnNewKit.setOnClickListener {
|
||||||
@@ -281,17 +271,6 @@ class HomeFragment : Fragment() {
|
|||||||
startActivity(Intent(requireContext(), KitScanActivity::class.java))
|
startActivity(Intent(requireContext(), KitScanActivity::class.java))
|
||||||
requireActivity().finish()
|
requireActivity().finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
binding.btnNewKitoffline.setOnClickListener {
|
|
||||||
with(sharedPreference.edit()) {
|
|
||||||
putString(Constants.KIT_NUMBER, "")
|
|
||||||
putInt(Constants.KIT_COUNT, 0)
|
|
||||||
apply()
|
|
||||||
}
|
|
||||||
startActivity(Intent(requireContext(), KitScanActivity::class.java))
|
|
||||||
requireActivity().finish()
|
|
||||||
}
|
|
||||||
binding.btnQuickCapture.setOnClickListener {
|
binding.btnQuickCapture.setOnClickListener {
|
||||||
DataHolder.hemoCubeTestData = HemoCubeTestData()
|
DataHolder.hemoCubeTestData = HemoCubeTestData()
|
||||||
|
|
||||||
@@ -313,52 +292,26 @@ class HomeFragment : Fragment() {
|
|||||||
var password = sharedPreference.getString(Constants.DEVICE_PASSWORD_API, "").toString()
|
var password = sharedPreference.getString(Constants.DEVICE_PASSWORD_API, "").toString()
|
||||||
var userID = sharedPreference.getString(Constants.DEVICE_ID_API, "").toString()
|
var userID = sharedPreference.getString(Constants.DEVICE_ID_API, "").toString()
|
||||||
deviceId = sharedPreference.getString(Constants.DEVICE_ID, "").toString()
|
deviceId = sharedPreference.getString(Constants.DEVICE_ID, "").toString()
|
||||||
|
if(userID.isNotEmpty() && password.isNotEmpty()) {
|
||||||
val target = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
|
Log.d("istoken",isTokenAvailable.toString())
|
||||||
val file = File(target, "credentials.txt") //this file contains userID and password to communicate with API.
|
|
||||||
|
|
||||||
if (userID.isNotEmpty() && password.isNotEmpty()) {
|
|
||||||
Log.d("istoken", isTokenAvailable.toString())
|
|
||||||
if (!isTokenAvailable) {
|
if (!isTokenAvailable) {
|
||||||
Log.d("istoken1", isTokenAvailable.toString())
|
Log.d("istoken1",isTokenAvailable.toString())
|
||||||
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||||
isTokenAvailable = true
|
isTokenAvailable = true
|
||||||
|
|
||||||
} else if (isTokenAvailable) {
|
}else if(isTokenAvailable){
|
||||||
Log.d("istoken7", isTokenAvailable.toString())
|
Log.d("istoken7",isTokenAvailable.toString())
|
||||||
isTokenAvailable = true
|
isTokenAvailable = true
|
||||||
hemoCubeViewModel.startPeriodicCheckUpdate()
|
hemoCubeViewModel.startPeriodicCheckUpdate()
|
||||||
hemoCubeViewModel.checkUpdate(createCheckUpdateRequestData())
|
hemoCubeViewModel.checkUpdate(createCheckUpdateRequestData())
|
||||||
} else {
|
}else{
|
||||||
if (isTokenExpired(accessToken)) {
|
if(isTokenExpired(accessToken)) {
|
||||||
Log.d("istoken8", isTokenAvailable.toString())
|
Log.d("istoken8",isTokenAvailable.toString())
|
||||||
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (userID == "deviceIDAPI" && password == "devicePasswordAPI" && deviceId.isNotEmpty()) {
|
} else if (userID.isEmpty() && password.isEmpty() && deviceId.isNotEmpty()) {
|
||||||
fetchDeviceCredentials()
|
fetchDeviceCredentials()
|
||||||
} else if (file.exists()) {
|
|
||||||
val encryptedString = file.readText()
|
|
||||||
val encryptionKey =
|
|
||||||
Settings.Secure.getString(context?.contentResolver, Settings.Secure.ANDROID_ID)
|
|
||||||
val decryptedMessage: String = Encryption.decrypt(encryptedString, encryptionKey)
|
|
||||||
val credentials = decryptedMessage.split("\n")
|
|
||||||
userID = credentials[0]
|
|
||||||
password = credentials[1]
|
|
||||||
Toast.makeText(context, "DECRYPTED: $credentials", Toast.LENGTH_SHORT).show()
|
|
||||||
if (!isTokenAvailable) {
|
|
||||||
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
|
||||||
isTokenAvailable = true
|
|
||||||
|
|
||||||
} else if (isTokenAvailable) {
|
|
||||||
isTokenAvailable = true
|
|
||||||
hemoCubeViewModel.startPeriodicCheckUpdate()
|
|
||||||
hemoCubeViewModel.checkUpdate(createCheckUpdateRequestData())
|
|
||||||
} else {
|
|
||||||
if (isTokenExpired(accessToken)) {
|
|
||||||
hemoCubeViewModel.login(createLoginRequestData(userID, password))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
@@ -373,7 +326,7 @@ class HomeFragment : Fragment() {
|
|||||||
updateTokens(response)
|
updateTokens(response)
|
||||||
response.data.data?.accessToken
|
response.data.data?.accessToken
|
||||||
isTokenAvailable = true
|
isTokenAvailable = true
|
||||||
Log.d("istoken2", isTokenAvailable.toString())
|
Log.d("istoken2",isTokenAvailable.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
is Result.Error -> {
|
is Result.Error -> {
|
||||||
@@ -399,7 +352,7 @@ class HomeFragment : Fragment() {
|
|||||||
when (it) {
|
when (it) {
|
||||||
is Result.Success -> {
|
is Result.Success -> {
|
||||||
|
|
||||||
Log.d("success,", "uploded")
|
Log.d("success,","uploded")
|
||||||
it.data.data?.forEach { id ->
|
it.data.data?.forEach { id ->
|
||||||
id.rawData?.let { it1 ->
|
id.rawData?.let { it1 ->
|
||||||
hemoCubeViewModel.updateMolbioFlag(
|
hemoCubeViewModel.updateMolbioFlag(
|
||||||
@@ -407,11 +360,7 @@ class HomeFragment : Fragment() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Toast.makeText(
|
Toast.makeText(activity, "Molbio Result is successfully uploaded", Toast.LENGTH_LONG)
|
||||||
activity,
|
|
||||||
"Molbio Result is successfully uploaded",
|
|
||||||
Toast.LENGTH_LONG
|
|
||||||
)
|
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,8 +416,7 @@ class HomeFragment : Fragment() {
|
|||||||
context?.let { ctx ->
|
context?.let { ctx ->
|
||||||
val packageInfo = ctx.packageManager.getPackageInfo(ctx.packageName, 0)
|
val packageInfo = ctx.packageManager.getPackageInfo(ctx.packageName, 0)
|
||||||
val versionName = packageInfo.versionName
|
val versionName = packageInfo.versionName
|
||||||
val versionCode: Long =
|
val versionCode: Long = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
||||||
// From Android P (API level 28), versionCode is deprecated and you should use longVersionCode instead.
|
// From Android P (API level 28), versionCode is deprecated and you should use longVersionCode instead.
|
||||||
packageInfo.longVersionCode
|
packageInfo.longVersionCode
|
||||||
} else {
|
} else {
|
||||||
@@ -477,14 +425,11 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use versionName and versionCode as needed
|
// Use versionName and versionCode as needed
|
||||||
Log.d(
|
Log.d("AppInfo", "Version Name: $versionName, Version Code: $versionCode")
|
||||||
"AppInfo",
|
|
||||||
"Version Name: $versionName, Version Code: $versionCode"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
Log.d("versionnow", currentversion.toString())
|
Log.d("versionnow",currentversion.toString())
|
||||||
Log.d("versionnow", updatedversion.toString())
|
Log.d("versionnow",updatedversion.toString())
|
||||||
if (updatedversion > currentversion.toString()) {
|
if(updatedversion > currentversion.toString()){
|
||||||
hemoCubeViewModel.deviceUpdate(createDeviceUpdateRequestData())
|
hemoCubeViewModel.deviceUpdate(createDeviceUpdateRequestData())
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
activity,
|
activity,
|
||||||
@@ -492,7 +437,7 @@ class HomeFragment : Fragment() {
|
|||||||
Toast.LENGTH_LONG
|
Toast.LENGTH_LONG
|
||||||
)
|
)
|
||||||
.show()
|
.show()
|
||||||
} else {
|
}else{
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
activity,
|
activity,
|
||||||
"App is Up to date",
|
"App is Up to date",
|
||||||
@@ -528,19 +473,14 @@ class HomeFragment : Fragment() {
|
|||||||
|
|
||||||
val downloadDirectory = "NATS"
|
val downloadDirectory = "NATS"
|
||||||
val fileName = "nats_certificate.zip"
|
val fileName = "nats_certificate.zip"
|
||||||
val unzipDirectoryPath =
|
val unzipDirectoryPath = requireContext().getExternalFilesDir(null)?.absolutePath + "/$downloadDirectory"
|
||||||
requireContext().getExternalFilesDir(null)?.absolutePath + "/$downloadDirectory"
|
|
||||||
|
|
||||||
// Check if the directory with extracted files exists.
|
// Check if the directory with extracted files exists.
|
||||||
val directory = File(unzipDirectoryPath)
|
val directory = File(unzipDirectoryPath)
|
||||||
if (directory.exists() && directory.isDirectory) {
|
if (directory.exists() && directory.isDirectory) {
|
||||||
// Assuming if the directory exists, the certificate has been downloaded and extracted.
|
// Assuming if the directory exists, the certificate has been downloaded and extracted.
|
||||||
// You can add more specific checks here, e.g., checking for specific files within the directory.
|
// You can add more specific checks here, e.g., checking for specific files within the directory.
|
||||||
Toast.makeText(
|
Toast.makeText(requireContext(), "NATS certificate already downloaded and extracted.", Toast.LENGTH_SHORT).show()
|
||||||
requireContext(),
|
|
||||||
"NATS certificate already downloaded and extracted.",
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
return@observe
|
return@observe
|
||||||
}
|
}
|
||||||
val file = downloadFile(url, requireContext(), fileName, downloadDirectory)
|
val file = downloadFile(url, requireContext(), fileName, downloadDirectory)
|
||||||
@@ -572,7 +512,7 @@ class HomeFragment : Fragment() {
|
|||||||
|
|
||||||
|
|
||||||
private fun isTokenExpired(token: String): Boolean {
|
private fun isTokenExpired(token: String): Boolean {
|
||||||
if (token.isNotEmpty()) {
|
if(token.isNotEmpty()) {
|
||||||
val parts = token.split("\\.".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
val parts = token.split("\\.".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
|
||||||
val decodedPayload = String(Base64.decode(parts[1], Base64.DEFAULT))
|
val decodedPayload = String(Base64.decode(parts[1], Base64.DEFAULT))
|
||||||
val jsonPayload = JSONObject(decodedPayload)
|
val jsonPayload = JSONObject(decodedPayload)
|
||||||
@@ -581,7 +521,7 @@ class HomeFragment : Fragment() {
|
|||||||
val currentTimeSeconds = System.currentTimeMillis() / 1000
|
val currentTimeSeconds = System.currentTimeMillis() / 1000
|
||||||
|
|
||||||
return exp <= currentTimeSeconds
|
return exp <= currentTimeSeconds
|
||||||
} else {
|
}else{
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -596,7 +536,7 @@ class HomeFragment : Fragment() {
|
|||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
isTokenAvailable = true
|
isTokenAvailable = true
|
||||||
Log.d("istoken3", isTokenAvailable.toString())
|
Log.d("istoken3",isTokenAvailable.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createLoginRequestData(userID: String, password: String): LoginRequest {
|
private fun createLoginRequestData(userID: String, password: String): LoginRequest {
|
||||||
@@ -739,7 +679,7 @@ class HomeFragment : Fragment() {
|
|||||||
putString(Constants.NATS_TOKEN, natsToken)
|
putString(Constants.NATS_TOKEN, natsToken)
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
if (!isTokenAvailable) {
|
if (!isTokenAvailable ) {
|
||||||
Log.d("istoken0", isTokenAvailable.toString())
|
Log.d("istoken0", isTokenAvailable.toString())
|
||||||
hemoCubeViewModel.login(createLoginRequestData(username, password))
|
hemoCubeViewModel.login(createLoginRequestData(username, password))
|
||||||
}
|
}
|
||||||
@@ -906,16 +846,16 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun checkForLocalDBData() {
|
private fun checkForLocalDBData() {
|
||||||
// viewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
viewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
// val uploadDataVisibility = if (userDataList.isEmpty()) View.GONE else View.VISIBLE
|
val uploadDataVisibility = if (userDataList.isEmpty()) View.GONE else View.VISIBLE
|
||||||
// binding.uploadData.visibility = uploadDataVisibility
|
binding.uploadData.visibility = uploadDataVisibility
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
// val uploadDataVisibility =
|
val uploadDataVisibility =
|
||||||
// if (userDataList.any { !it.localFlag && !it.molbioFlag && it.testStatus == true }) View.VISIBLE else View.GONE
|
if (userDataList.any { !it.localFlag && !it.molbioFlag && it.testStatus == true }) View.VISIBLE else View.GONE
|
||||||
// binding.uploadData.visibility = uploadDataVisibility
|
binding.uploadData.visibility = uploadDataVisibility
|
||||||
// }
|
}
|
||||||
|
|
||||||
hemoCubeViewModel.allKitTestData.observe(viewLifecycleOwner) { bufferData ->
|
hemoCubeViewModel.allKitTestData.observe(viewLifecycleOwner) { bufferData ->
|
||||||
val uploadDataVisibility =
|
val uploadDataVisibility =
|
||||||
@@ -925,11 +865,11 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun checkUnprocessedCSVData() {
|
private fun checkUnprocessedCSVData() {
|
||||||
// hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
// val downloadDataVisibility =
|
val downloadDataVisibility =
|
||||||
// if (userDataList.any { !it.isCSVCreated && it.testStatus == true }) View.GONE else View.GONE
|
if (userDataList.any { !it.isCSVCreated && it.testStatus == true }) View.GONE else View.GONE
|
||||||
// binding.downloadCSV.visibility = downloadDataVisibility
|
binding.downloadCSV.visibility = downloadDataVisibility
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sanitizeDoubleValues(hemoCubeTestData: HemoCubeTestData): HemoCubeTestData {
|
private fun sanitizeDoubleValues(hemoCubeTestData: HemoCubeTestData): HemoCubeTestData {
|
||||||
@@ -946,6 +886,7 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private fun showUploadDialog(context: Context) {
|
private fun showUploadDialog(context: Context) {
|
||||||
val builder = AlertDialog.Builder(context)
|
val builder = AlertDialog.Builder(context)
|
||||||
builder.setTitle(R.string.upload_db_registration_title)
|
builder.setTitle(R.string.upload_db_registration_title)
|
||||||
@@ -981,23 +922,23 @@ class HomeFragment : Fragment() {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
private fun uploadLocalDBData(dialog: DialogInterface) {
|
private fun uploadLocalDBData(dialog: DialogInterface) {
|
||||||
// viewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
viewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
// if (userDataList.isEmpty()) {
|
if (userDataList.isEmpty()) {
|
||||||
// dialog.dismiss()
|
dialog.dismiss()
|
||||||
// } else {
|
} else {
|
||||||
// userDataList.forEach { userData ->
|
userDataList.forEach { userData ->
|
||||||
// viewModel.bulkUploadResultToDatabase(userData)
|
viewModel.bulkUploadResultToDatabase(userData)
|
||||||
// viewModel.deleteById(userData._id)
|
viewModel.deleteById(userData._id)
|
||||||
// }
|
}
|
||||||
// dialog.dismiss()
|
dialog.dismiss()
|
||||||
// Toast.makeText(
|
Toast.makeText(
|
||||||
// requireContext(), R.string.upload_success_message, Toast.LENGTH_SHORT
|
requireContext(), R.string.upload_success_message, Toast.LENGTH_SHORT
|
||||||
// ).show()
|
).show()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
// val resultList = MolbioV2ResultRequest(mutableListOf(MolbioV2Result()))
|
val resultList = MolbioV2ResultRequest(mutableListOf(MolbioV2Result()))
|
||||||
// userDataList.forEach { userData ->
|
// userDataList.forEach { userData ->
|
||||||
// if (!userData.molbioFlag && isTokenAvailable) {
|
// if (!userData.molbioFlag && isTokenAvailable) {
|
||||||
// resultList.results?.add(
|
// resultList.results?.add(
|
||||||
@@ -1026,8 +967,8 @@ class HomeFragment : Fragment() {
|
|||||||
// hemoCubeViewModel.uploadResult(resultList)
|
// hemoCubeViewModel.uploadResult(resultList)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// dialog.dismiss()
|
dialog.dismiss()
|
||||||
// }
|
}
|
||||||
|
|
||||||
hemoCubeViewModel.allKitTestData.observe(viewLifecycleOwner) { kitDataList ->
|
hemoCubeViewModel.allKitTestData.observe(viewLifecycleOwner) { kitDataList ->
|
||||||
kitDataList.forEach { userData ->
|
kitDataList.forEach { userData ->
|
||||||
@@ -1102,7 +1043,7 @@ class HomeFragment : Fragment() {
|
|||||||
builder.setMessage(R.string.download_db_registration_message)
|
builder.setMessage(R.string.download_db_registration_message)
|
||||||
|
|
||||||
builder.setPositiveButton(R.string.downloadcsv) { dialog, _ ->
|
builder.setPositiveButton(R.string.downloadcsv) { dialog, _ ->
|
||||||
// downloadLocalDBData(dialog)
|
downloadLocalDBData(dialog)
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.setNegativeButton(R.string.cancel) { dialog, _ ->
|
builder.setNegativeButton(R.string.cancel) { dialog, _ ->
|
||||||
@@ -1113,52 +1054,52 @@ class HomeFragment : Fragment() {
|
|||||||
dialog.show()
|
dialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
// private fun downloadLocalDBData(dialog: DialogInterface) {
|
private fun downloadLocalDBData(dialog: DialogInterface) {
|
||||||
// var csvDownloaded = false
|
var csvDownloaded = false
|
||||||
// hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
hemoCubeViewModel.allUserData.observe(viewLifecycleOwner) { userDataList ->
|
||||||
// try {
|
try {
|
||||||
// if (!csvDownloaded) {
|
if (!csvDownloaded) {
|
||||||
// val downloadList = mutableListOf<HemoCubeTestData>()
|
val downloadList = mutableListOf<HemoCubeTestData>()
|
||||||
//
|
|
||||||
// userDataList.forEach { userData ->
|
userDataList.forEach { userData ->
|
||||||
// if (userData.testStatus == true) {
|
if (userData.testStatus == true) {
|
||||||
//// if (!userData.isCSVCreated) {
|
// if (!userData.isCSVCreated) {
|
||||||
// downloadList.add(userData) // Add the userData to downloadList
|
downloadList.add(userData) // Add the userData to downloadList
|
||||||
// }
|
}
|
||||||
//// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (downloadList.isNotEmpty()) {
|
|
||||||
// // Call ViewModel function to create CSV with filtered data
|
|
||||||
// hemoCubeViewModel.createCSV(downloadList, requireContext())
|
|
||||||
// csvDownloaded = true
|
|
||||||
// Toast.makeText(
|
|
||||||
// requireContext(),
|
|
||||||
// "CSV file downloaded successfully",
|
|
||||||
// Toast.LENGTH_SHORT
|
|
||||||
// ).show()
|
|
||||||
// } else {
|
|
||||||
// Toast.makeText(
|
|
||||||
// requireContext(),
|
|
||||||
// "No data to download",
|
|
||||||
// Toast.LENGTH_SHORT
|
|
||||||
// )
|
|
||||||
// .show()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// } catch (e: Exception) {
|
|
||||||
// e.printStackTrace()
|
|
||||||
// Toast.makeText(requireContext(), "Error downloading CSV file", Toast.LENGTH_SHORT)
|
|
||||||
// .show()
|
|
||||||
// } finally {
|
|
||||||
// dialog.dismiss()
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (downloadList.isNotEmpty()) {
|
||||||
|
// Call ViewModel function to create CSV with filtered data
|
||||||
|
hemoCubeViewModel.createCSV(downloadList, requireContext())
|
||||||
|
csvDownloaded = true
|
||||||
|
Toast.makeText(
|
||||||
|
requireContext(),
|
||||||
|
"CSV file downloaded successfully",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show()
|
||||||
|
} else {
|
||||||
|
Toast.makeText(
|
||||||
|
requireContext(),
|
||||||
|
"No data to download",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
Toast.makeText(requireContext(), "Error downloading CSV file", Toast.LENGTH_SHORT)
|
||||||
|
.show()
|
||||||
|
} finally {
|
||||||
|
dialog.dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun getDeviceId() {
|
private fun getDeviceId() {
|
||||||
Log.d("HomeFragmentUSb", "getDeviceId")
|
Log.d("HomeFragmentUSb","getDeviceId")
|
||||||
val handler = activity as? DeviceCommunicationHandler
|
val handler = activity as? DeviceCommunicationHandler
|
||||||
handler?.sendAndListenToDevice(
|
handler?.sendAndListenToDevice(
|
||||||
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
HemoCubeCommands.DEVICE_CONFIGURATION_COMMAND,
|
||||||
@@ -1166,10 +1107,9 @@ class HomeFragment : Fragment() {
|
|||||||
override fun onUsbRead(data: ByteArray?) {
|
override fun onUsbRead(data: ByteArray?) {
|
||||||
data?.let {
|
data?.let {
|
||||||
val receivedData = String(it, Charset.forName("UTF-8"))
|
val receivedData = String(it, Charset.forName("UTF-8"))
|
||||||
Log.d("HomeFragment", "USB data" + receivedData)
|
Log.d("HomeFragment","USB data"+receivedData)
|
||||||
// Assuming the device ID is the full content of the received data. Adjust if needed.
|
// Assuming the device ID is the full content of the received data. Adjust if needed.
|
||||||
deviceId =
|
deviceId = extractDeviceId(receivedData) // Implement this method based on your data format.
|
||||||
extractDeviceId(receivedData) // Implement this method based on your data format.
|
|
||||||
if (deviceId.isNotEmpty()) {
|
if (deviceId.isNotEmpty()) {
|
||||||
// Store the deviceId in SharedPreferences
|
// Store the deviceId in SharedPreferences
|
||||||
with(sharedPreference.edit()) {
|
with(sharedPreference.edit()) {
|
||||||
@@ -1186,7 +1126,7 @@ class HomeFragment : Fragment() {
|
|||||||
|
|
||||||
override fun onUsbError(e: Exception?) {
|
override fun onUsbError(e: Exception?) {
|
||||||
// Handle USB communication error
|
// Handle USB communication error
|
||||||
Log.d("HomeFragment", "USB read error" + e.toString())
|
Log.d("HomeFragment","USB read error"+e.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -1198,7 +1138,6 @@ class HomeFragment : Fragment() {
|
|||||||
val matchResult = regex.find(receivedData)
|
val matchResult = regex.find(receivedData)
|
||||||
return matchResult?.groups?.get(1)?.value ?: ""
|
return matchResult?.groups?.get(1)?.value ?: ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SuspiciousIndentation")
|
@SuppressLint("SuspiciousIndentation")
|
||||||
private fun checkForUpdate() {
|
private fun checkForUpdate() {
|
||||||
try {
|
try {
|
||||||
@@ -1216,59 +1155,41 @@ class HomeFragment : Fragment() {
|
|||||||
// deviceData?.let { data ->
|
// deviceData?.let { data ->
|
||||||
|
|
||||||
val deviceVersion = deviceData!!.deviceVersion
|
val deviceVersion = deviceData!!.deviceVersion
|
||||||
val deviceUpdateAvailableGlobal = deviceData.deviceUpdateAvailable
|
val deviceUpdateAvailableGlobal= deviceData.deviceUpdateAvailable
|
||||||
val updatePathGlobal = deviceData.updatePath
|
val updatePathGlobal= deviceData.updatePath
|
||||||
|
|
||||||
|
// if(deviceUpdateAvailableGlobal){
|
||||||
db.collection("devices").whereEqualTo("deviceId", deviceId).get()
|
db.collection("devices").whereEqualTo("deviceId", deviceId).get().addOnSuccessListener { documentSnapshotNew ->
|
||||||
.addOnSuccessListener { documentSnapshotNew ->
|
|
||||||
if (documentSnapshotNew.documents.isNotEmpty()) {
|
if (documentSnapshotNew.documents.isNotEmpty()) {
|
||||||
documentSnapshotNew.documents.forEach {
|
documentSnapshotNew.documents.forEach{
|
||||||
val documentIn = it.toObject(DeviceData::class.java)
|
val documentIn = it.toObject(DeviceData::class.java)
|
||||||
|
|
||||||
val globalUpdateIgnore = documentIn!!.globalUpdateIgnore
|
val globalUpdateIgnore = documentIn!!.globalUpdateIgnore
|
||||||
val deviceUpdateAvailable = documentIn.deviceUpdateAvailable
|
val deviceUpdateAvailable = documentIn.deviceUpdateAvailable
|
||||||
val globalUpdateDone = documentIn.globalUpdateDone
|
val globalUpdateDone = documentIn.globalUpdateDone
|
||||||
val updatePath = documentIn.updatePath
|
val updatePath = documentIn.updatePath
|
||||||
if (globalUpdateIgnore) {
|
if(globalUpdateIgnore){
|
||||||
if (deviceUpdateAvailable) {
|
if(deviceUpdateAvailable){
|
||||||
val update = db.collection("devices").document(it.id)
|
val update = db.collection("devices").document(it.id).update("deviceUpdateAvailable",false)
|
||||||
.update("deviceUpdateAvailable", false)
|
|
||||||
update.addOnSuccessListener {
|
update.addOnSuccessListener {
|
||||||
Log.d(
|
Log.d("HomeFragmentUpdate","Device local update done")
|
||||||
"HomeFragmentUpdate",
|
|
||||||
"Device local update done"
|
|
||||||
)
|
|
||||||
|
|
||||||
initiateUpdate(updatePath)
|
initiateUpdate(updatePath)
|
||||||
}.addOnFailureListener {
|
}.addOnFailureListener{
|
||||||
Log.e("fetchDeviceUpdate", "update fail.")
|
Log.e("fetchDeviceUpdate", "update fail.")
|
||||||
}
|
}
|
||||||
} else {
|
}else{
|
||||||
Log.d(
|
Log.d("HomeFragmentUpdate","Device update not available")
|
||||||
"HomeFragmentUpdate",
|
|
||||||
"Device update not available"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
} else {
|
}else{
|
||||||
if (deviceUpdateAvailableGlobal) {
|
if(!globalUpdateDone){
|
||||||
if (!globalUpdateDone) {
|
val update = db.collection("devices").document(it.id).update("globalUpdateDone",true)
|
||||||
val update =
|
|
||||||
db.collection("devices").document(it.id)
|
|
||||||
.update("globalUpdateDone", true)
|
|
||||||
update.addOnSuccessListener {
|
update.addOnSuccessListener {
|
||||||
Log.d(
|
Log.d("HomeFragmentUpdate","Device global update done")
|
||||||
"HomeFragmentUpdate",
|
|
||||||
"Device global update done"
|
|
||||||
)
|
|
||||||
|
|
||||||
initiateUpdate(updatePathGlobal)
|
initiateUpdate(updatePathGlobal)
|
||||||
}.addOnFailureListener {
|
}.addOnFailureListener{
|
||||||
Log.e(
|
Log.e("fetchDeviceUpdate", "update fail.")
|
||||||
"fetchDeviceUpdate",
|
|
||||||
"update fail."
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1290,7 +1211,8 @@ class HomeFragment : Fragment() {
|
|||||||
"fetchDeviceCredentials",
|
"fetchDeviceCredentials",
|
||||||
"deviceVersion: $deviceVersion, Password: $deviceUpdateAvailableGlobal, updatePath: $updatePathGlobal"
|
"deviceVersion: $deviceVersion, Password: $deviceUpdateAvailableGlobal, updatePath: $updatePathGlobal"
|
||||||
)
|
)
|
||||||
// ?: Log.e("fetchDeviceUpdate", "Failed to parse device data.")
|
|
||||||
|
// } ?: Log.e("fetchDeviceUpdate", "Failed to parse device data.")
|
||||||
} else {
|
} else {
|
||||||
Log.e("fetchDeviceUpdate", "Document does not exist.")
|
Log.e("fetchDeviceUpdate", "Document does not exist.")
|
||||||
}
|
}
|
||||||
@@ -1316,8 +1238,7 @@ class HomeFragment : Fragment() {
|
|||||||
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
||||||
request.setDestinationInExternalFilesDir(requireActivity(), "Updates", "update.apk")
|
request.setDestinationInExternalFilesDir(requireActivity(), "Updates", "update.apk")
|
||||||
|
|
||||||
val downloadManager =
|
val downloadManager = requireActivity().getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
|
||||||
requireActivity().getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
|
|
||||||
downloadId = downloadManager.enqueue(request)
|
downloadId = downloadManager.enqueue(request)
|
||||||
|
|
||||||
// Register a BroadcastReceiver to receive the download complete event
|
// Register a BroadcastReceiver to receive the download complete event
|
||||||
@@ -1327,15 +1248,12 @@ class HomeFragment : Fragment() {
|
|||||||
requireActivity().registerReceiver(downloadReceiver, filter, RECEIVER_EXPORTED)
|
requireActivity().registerReceiver(downloadReceiver, filter, RECEIVER_EXPORTED)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun extractApkUrl(responseBody: ResponseBody): String {
|
private fun extractApkUrl(responseBody: ResponseBody): String {
|
||||||
return responseBody.string()
|
return responseBody.string()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isValidHttpUrl(url: String): Boolean {
|
private fun isValidHttpUrl(url: String): Boolean {
|
||||||
return url.startsWith("http://") || url.startsWith("https://")
|
return url.startsWith("http://") || url.startsWith("https://")
|
||||||
}
|
}
|
||||||
|
|
||||||
private val downloadReceiver = object : BroadcastReceiver() {
|
private val downloadReceiver = object : BroadcastReceiver() {
|
||||||
override fun onReceive(context: Context?, intent: Intent?) {
|
override fun onReceive(context: Context?, intent: Intent?) {
|
||||||
val id = intent?.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1)
|
val id = intent?.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1)
|
||||||
@@ -1349,11 +1267,8 @@ class HomeFragment : Fragment() {
|
|||||||
val file = File(requireActivity().getExternalFilesDir("Updates"), "update.apk")
|
val file = File(requireActivity().getExternalFilesDir("Updates"), "update.apk")
|
||||||
file.setReadable(true, false) // Ensure the file is readable
|
file.setReadable(true, false) // Ensure the file is readable
|
||||||
|
|
||||||
val pInfo = requireActivity().baseContext.packageManager.getPackageInfo(
|
val pInfo = requireActivity().baseContext.packageManager.getPackageInfo(requireActivity().baseContext.packageName, 0)
|
||||||
requireActivity().baseContext.packageName,
|
Log.d("HomeFragmentShowInfo",pInfo.packageName.toString())
|
||||||
0
|
|
||||||
)
|
|
||||||
Log.d("HomeFragmentShowInfo", pInfo.packageName.toString())
|
|
||||||
val uri: Uri = FileProvider.getUriForFile(
|
val uri: Uri = FileProvider.getUriForFile(
|
||||||
requireActivity(),
|
requireActivity(),
|
||||||
"${pInfo.packageName}.fileprovider",
|
"${pInfo.packageName}.fileprovider",
|
||||||
@@ -1376,7 +1291,7 @@ class HomeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
if (isRegistered) {
|
if(isRegistered) {
|
||||||
try {
|
try {
|
||||||
requireActivity().unregisterReceiver(downloadReceiver)
|
requireActivity().unregisterReceiver(downloadReceiver)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ import androidx.activity.viewModels
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
|
import com.example.hpostesting.data.api.DeviceCommunicationHandler
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.utils.DeviceCommunicationHandler
|
import com.example.hpostesting.presentation.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
|
||||||
import com.example.hpostesting.presentation.testRight.UsbService
|
import com.example.hpostesting.presentation.testRight.UsbService
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import androidx.fragment.app.activityViewModels
|
|||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ import androidx.activity.viewModels
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
|
import com.example.hpostesting.data.api.DeviceCommunicationHandler
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.utils.DeviceCommunicationHandler
|
import com.example.hpostesting.presentation.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
|
||||||
import com.example.hpostesting.presentation.testRight.UsbService
|
import com.example.hpostesting.presentation.testRight.UsbService
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Environment
|
|
||||||
import android.provider.Settings
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@@ -14,20 +12,16 @@ import android.widget.Toast
|
|||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import com.example.hpostesting.util.Result
|
import com.example.hpostesting.data.Result
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
import com.example.hpostesting.encryption.Encryption
|
import com.example.hpostesting.presentation.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import com.google.android.gms.ads.identifier.AdvertisingIdClient
|
|
||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentDeviceProvisionBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentDeviceProvisionBinding
|
||||||
import java.io.File
|
|
||||||
import java.io.FileOutputStream
|
|
||||||
|
|
||||||
class DeviceProvisionFragment : Fragment() {
|
class DeviceProvisionFragment : Fragment() {
|
||||||
private var resultData: String = ""
|
private var resultData: String = ""
|
||||||
@@ -128,10 +122,6 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
deviceUpdateAvailable = false
|
deviceUpdateAvailable = false
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
encryptAndSaveToFile(
|
|
||||||
response.data.data?.credentials?.username.toString(),
|
|
||||||
response.data.data?.credentials?.password.toString()
|
|
||||||
)
|
|
||||||
// viewModel.addDeviceId(DeviceData(deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString()))
|
// viewModel.addDeviceId(DeviceData(deviceId = sharedPreferences.getString(Constants.DEVICE_ID, "").toString()))
|
||||||
Log.e("idpass", response.toString())
|
Log.e("idpass", response.toString())
|
||||||
Log.e("idpass", response.data.data?.credentials?.username.toString())
|
Log.e("idpass", response.data.data?.credentials?.username.toString())
|
||||||
@@ -231,25 +221,4 @@ class DeviceProvisionFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun encryptAndSaveToFile(username: String, password: String) {
|
|
||||||
val messageToEncrypt = "$username\n$password"
|
|
||||||
val encryptionKey =
|
|
||||||
Settings.Secure.getString(context?.contentResolver, Settings.Secure.ANDROID_ID)
|
|
||||||
val encryptedString = Encryption.encrypt(messageToEncrypt, encryptionKey)
|
|
||||||
Log.d("DEVICE ID/encryptionKey", encryptionKey)
|
|
||||||
val target = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)
|
|
||||||
val file = File(target, "credentials.txt")
|
|
||||||
|
|
||||||
if (!file.exists()) {
|
|
||||||
file.createNewFile()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
file.writeText(encryptedString)
|
|
||||||
|
|
||||||
Log.d("Encrypted Message", encryptedString)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.example.hpostesting.presentation.deviceprovision
|
|||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.example.hpostesting.util.Result
|
import com.example.hpostesting.data.Result
|
||||||
import com.example.hpostesting.data.model.Response
|
import com.example.hpostesting.data.model.Response
|
||||||
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
||||||
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionResponse
|
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionResponse
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import androidx.activity.viewModels
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.testRight.UsbService
|
import com.example.hpostesting.presentation.testRight.UsbService
|
||||||
|
|||||||
@@ -13,15 +13,15 @@ import android.widget.Toast
|
|||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import com.example.hpostesting.util.Result
|
import com.example.hpostesting.data.Result
|
||||||
import com.example.hpostesting.util.Result.Success
|
import com.example.hpostesting.data.Result.Success
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
import com.example.hpostesting.data.model.devicediagnostics.AdditionalDetails
|
import com.example.hpostesting.data.model.devicediagnostics.AdditionalDetails
|
||||||
import com.example.hpostesting.data.model.devicediagnostics.DeviceDiagnosticsRequest
|
import com.example.hpostesting.data.model.devicediagnostics.DeviceDiagnosticsRequest
|
||||||
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
import com.example.hpostesting.data.model.diagnostics.DiagnosticsData
|
||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.UsbServiceListener
|
||||||
import com.google.firebase.crashlytics.ktx.crashlytics
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
import com.google.firebase.ktx.Firebase
|
import com.google.firebase.ktx.Firebase
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentDiagnosticsBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentDiagnosticsBinding
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.example.hpostesting.presentation.diagnostics
|
|||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.example.hpostesting.util.Result
|
import com.example.hpostesting.data.Result
|
||||||
import com.example.hpostesting.data.model.Response
|
import com.example.hpostesting.data.model.Response
|
||||||
import com.example.hpostesting.data.model.devicediagnostics.DeviceDiagnosticsRequest
|
import com.example.hpostesting.data.model.devicediagnostics.DeviceDiagnosticsRequest
|
||||||
import com.example.hpostesting.data.model.devicediagnostics.DeviceDiagnosticsResponse
|
import com.example.hpostesting.data.model.devicediagnostics.DeviceDiagnosticsResponse
|
||||||
@@ -25,7 +25,7 @@ class DiagnosticsViewModel @Inject constructor(
|
|||||||
|
|
||||||
val deviceData = MutableLiveData<DeviceData?>()
|
val deviceData = MutableLiveData<DeviceData?>()
|
||||||
val fireBaseUpload = MutableLiveData<String>()
|
val fireBaseUpload = MutableLiveData<String>()
|
||||||
val deviceDiagnosticsResponse = MutableLiveData<Result<DeviceDiagnosticsResponse>>()
|
val deviceDiagnosticsResponse = MutableLiveData<com.example.hpostesting.data.Result<DeviceDiagnosticsResponse>>()
|
||||||
// private val batteryStatus: Intent? =
|
// private val batteryStatus: Intent? =
|
||||||
// IntentFilter(Intent.ACTION_BATTERY_CHANGED).let { ifilter ->
|
// IntentFilter(Intent.ACTION_BATTERY_CHANGED).let { ifilter ->
|
||||||
// context.registerReceiver(null, ifilter)
|
// context.registerReceiver(null, ifilter)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
||||||
import `in`.sminnovations.hpostesting.databinding.FragmentDigitalCardBinding
|
import `in`.sminnovations.hpostesting.databinding.FragmentDigitalCardBinding
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@@ -14,15 +13,15 @@ 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 com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.util.Result
|
import com.example.hpostesting.data.Result
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
import com.example.hpostesting.data.constant.TestStatus
|
import com.example.hpostesting.data.constant.TestStatus
|
||||||
import com.example.hpostesting.data.model.TestState
|
import com.example.hpostesting.data.model.TestState
|
||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import com.example.hpostesting.presentation.utils.MyDialogListener
|
import com.example.hpostesting.presentation.utils.MyDialogListener
|
||||||
import com.example.hpostesting.presentation.utils.UIUtils
|
import com.example.hpostesting.presentation.utils.UIUtils
|
||||||
@@ -173,11 +172,10 @@ class HemoCubeFragment : Fragment() {
|
|||||||
it.exception.let { message ->
|
it.exception.let { message ->
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
activity,
|
activity,
|
||||||
"$message",
|
"An error occurred: $message",
|
||||||
Toast.LENGTH_LONG
|
Toast.LENGTH_LONG
|
||||||
)
|
)
|
||||||
.show()
|
.show()
|
||||||
Log.d("resultuploadfail1", message.toString())
|
|
||||||
}
|
}
|
||||||
handleReadingFinish()
|
handleReadingFinish()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ 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.util.CsvWriter
|
import com.example.hpostesting.data.CsvWriter
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.util.NetworkStatusLiveData
|
import com.example.hpostesting.data.NetworkStatusLiveData
|
||||||
import com.example.hpostesting.util.Result
|
import com.example.hpostesting.data.Result
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
||||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||||
@@ -38,7 +38,6 @@ 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 dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||||
import okhttp3.MultipartBody
|
import okhttp3.MultipartBody
|
||||||
@@ -89,8 +88,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
|
|
||||||
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
private val _networkStatusLiveData = NetworkStatusLiveData(context)
|
||||||
val allUserData = hemoCubeDao.getAll()
|
val allUserData = hemoCubeDao.getAll()
|
||||||
val allLocalData = hemoCubeDao.getAll()
|
val allPendingUserToUpload = MutableLiveData<List<HemoCubeTestData>>()
|
||||||
val allPendingUserToUpload = hemoCubeDao.getPendingUser()
|
|
||||||
val allKitTestData = hemoCubeBufferDao.getAll()
|
val allKitTestData = hemoCubeBufferDao.getAll()
|
||||||
val deviceData = MutableLiveData<DeviceData?>()
|
val deviceData = MutableLiveData<DeviceData?>()
|
||||||
|
|
||||||
@@ -153,89 +151,6 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun sendDataToMolbio() = viewModelScope.launch(Dispatchers.IO) {
|
|
||||||
|
|
||||||
Log.d("molbio","getting in sendMolbio")
|
|
||||||
val resultList = MolbioV2ResultRequest(mutableListOf())
|
|
||||||
val pendingData = hemoCubeDao.getMolbioPending()
|
|
||||||
Log.d("molbio","pending size"+pendingData.size)
|
|
||||||
pendingData.forEach{
|
|
||||||
userData ->
|
|
||||||
val currentTimeFormatted = SimpleDateFormat(
|
|
||||||
"yyyy-MM-dd'T'HH:mm:ssZZZZZ",
|
|
||||||
Locale.getDefault()
|
|
||||||
).format(Calendar.getInstance().time)
|
|
||||||
val bufferIntensityThreshold =
|
|
||||||
Constants.BUFFER_INTENSITY_THRESHOLDS[userData.deviceId]?.toString()
|
|
||||||
?: "defaultThreshold" // Handle possible nulls safely
|
|
||||||
resultList.results?.add(
|
|
||||||
MolbioV2Result(
|
|
||||||
rawData = userData,
|
|
||||||
analysisId = userData._id,
|
|
||||||
analysisDate = currentTimeFormatted,
|
|
||||||
analysisStatus = userData.classificationResult
|
|
||||||
?: "defaultStatus", // Handle possible nulls
|
|
||||||
thresholds = bufferIntensityThreshold,
|
|
||||||
interpretation = userData.classificationResult
|
|
||||||
?: "defaultInterpretation", // Handle possible nulls
|
|
||||||
testId = userData._id,
|
|
||||||
testTime = currentTimeFormatted,
|
|
||||||
collectionTime = currentTimeFormatted,
|
|
||||||
expiryTime = currentTimeFormatted
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
resultList.results?.forEach { result ->
|
|
||||||
result.rawData?.let { sanitizeDoubleValues(it) }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (resultList.results?.isNotEmpty() == true) {
|
|
||||||
uploadMoblioBulkResults(resultList)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fun uploadMoblioBulkResults(molbioV2ResultRequest: MolbioV2ResultRequest) = viewModelScope.launch {
|
|
||||||
Log.d("molbio","upload called")
|
|
||||||
repository.uploadResults(molbioV2ResultRequest).let {
|
|
||||||
when (it) {
|
|
||||||
is Result.Success -> {
|
|
||||||
it.data.data?.forEach { id ->
|
|
||||||
id.rawData?.let { it1 ->
|
|
||||||
updateMolbioFlag(
|
|
||||||
it1._id
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
is Result.Error -> {
|
|
||||||
Log.d("result","result upload error")
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
Log.d("result","result upload else")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fun sendDataToFirebase() = viewModelScope.launch ( Dispatchers.IO ) {
|
|
||||||
val pendingData = hemoCubeDao.getFirebasePending()
|
|
||||||
pendingData.forEach{
|
|
||||||
userData ->
|
|
||||||
if (userData != null) {
|
|
||||||
if (!userData.localFlag) {
|
|
||||||
bulkAddResultTestToDb(userData)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fun checkUpdate(checkUpdateRequest: CheckUpdateRequest) = viewModelScope.launch {
|
fun checkUpdate(checkUpdateRequest: CheckUpdateRequest) = viewModelScope.launch {
|
||||||
checkUpdate.postValue(Result.Loading())
|
checkUpdate.postValue(Result.Loading())
|
||||||
repository.checkUpdate(checkUpdateRequest).let {
|
repository.checkUpdate(checkUpdateRequest).let {
|
||||||
@@ -280,9 +195,9 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fun getPendingUser() = viewModelScope.launch {
|
fun uploadPendingUser() = viewModelScope.launch {
|
||||||
// allPendingUserToUpload.postValue(hemoCubeDao.getPendingUser(true))
|
allPendingUserToUpload.postValue(hemoCubeDao.getPendingUser(false))
|
||||||
// }
|
}
|
||||||
|
|
||||||
fun uploadHemoCubeResultToDatabaseForBufferCheck(
|
fun uploadHemoCubeResultToDatabaseForBufferCheck(
|
||||||
isOnline: Boolean,
|
isOnline: Boolean,
|
||||||
@@ -418,24 +333,20 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
fireBaseUpload.postValue("Success")
|
fireBaseUpload.postValue("Success")
|
||||||
testDetails.localFlag = true
|
testDetails.localFlag = true
|
||||||
if (Constants.MOLBIO_INTEGRATION) {
|
if (Constants.MOLBIO_INTEGRATION) {
|
||||||
// Sanitize testDetails before using it in the API call
|
|
||||||
val sanitizedTestDetails = sanitizeDoubleValues(testDetails)
|
|
||||||
|
|
||||||
// Now, use sanitizedTestDetails for the API call
|
|
||||||
uploadResult(
|
uploadResult(
|
||||||
MolbioV2ResultRequest(
|
MolbioV2ResultRequest(
|
||||||
mutableListOf(
|
mutableListOf(
|
||||||
MolbioV2Result(
|
MolbioV2Result(
|
||||||
rawData = sanitizedTestDetails,
|
rawData = testDetails,
|
||||||
analysisId = sanitizedTestDetails._id,
|
analysisId = testDetails._id,
|
||||||
analysisDate = sanitizedTestDetails.testTime,
|
analysisDate = testDetails.testTime,
|
||||||
analysisStatus = sanitizedTestDetails.classificationResult,
|
analysisStatus = testDetails.classificationResult,
|
||||||
thresholds = Constants.BUFFER_INTENSITY_THRESHOLDS[sanitizedTestDetails.deviceId]?.toString(),
|
thresholds = Constants.BUFFER_INTENSITY_THRESHOLDS[testDetails.deviceId].toString(),
|
||||||
interpretation = sanitizedTestDetails.classificationResult,
|
interpretation = testDetails.classificationResult,
|
||||||
testId = sanitizedTestDetails._id,
|
testId = testDetails._id,
|
||||||
testTime = sanitizedTestDetails.testTime,
|
testTime = testDetails.testTime,
|
||||||
collectionTime = sanitizedTestDetails.testTime,
|
collectionTime = testDetails.testTime,
|
||||||
expiryTime = sanitizedTestDetails.testTime,
|
expiryTime = testDetails.testTime,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -464,7 +375,7 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
userData.reportUploadTime = SimpleDateFormat(
|
userData.reportUploadTime = SimpleDateFormat(
|
||||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||||
).format(Calendar.getInstance().time)
|
).format(Calendar.getInstance().time)
|
||||||
when (repository.addTestToDatabase(userData)) {
|
when (repository.addTestToDatabasefornew(userData)) {
|
||||||
is Response.Success -> {
|
is Response.Success -> {
|
||||||
fireBaseBulkUpload.postValue("Success")
|
fireBaseBulkUpload.postValue("Success")
|
||||||
updateLocalFlag(userData._id)
|
updateLocalFlag(userData._id)
|
||||||
@@ -477,19 +388,6 @@ class HemoCubeViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sanitizeDoubleValues(hemoCubeTestData: HemoCubeTestData): HemoCubeTestData {
|
|
||||||
hemoCubeTestData::class.java.declaredFields.forEach { field ->
|
|
||||||
if (field.type == Double::class.javaObjectType || field.type == Double::class.javaPrimitiveType) {
|
|
||||||
field.isAccessible = true
|
|
||||||
val value = field.get(hemoCubeTestData) as Double?
|
|
||||||
if (value != null && (value.isInfinite() || value.isNaN())) {
|
|
||||||
field.set(hemoCubeTestData, 0.0) // Replace with a suitable default value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return hemoCubeTestData
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateLocalFlag(userId: String) = viewModelScope.launch {
|
private fun updateLocalFlag(userId: String) = viewModelScope.launch {
|
||||||
hemoCubeDao.updateFieldById(id = userId, true)
|
hemoCubeDao.updateFieldById(id = userId, true)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import androidx.annotation.RequiresApi
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.testRight.UsbService
|
import com.example.hpostesting.presentation.testRight.UsbService
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import androidx.activity.viewModels
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.testRight.UsbService
|
import com.example.hpostesting.presentation.testRight.UsbService
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import androidx.activity.viewModels
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialProber
|
import com.hoho.android.usbserial.driver.UsbSerialProber
|
||||||
@@ -132,7 +132,7 @@ class TestRightActivity : AppCompatActivity() {
|
|||||||
this,
|
this,
|
||||||
0,
|
0,
|
||||||
Intent(Constants.ACTION_USB_PERMISSION),
|
Intent(Constants.ACTION_USB_PERMISSION),
|
||||||
PendingIntent.FLAG_IMMUTABLE
|
PendingIntent.FLAG_MUTABLE
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
mPendingIntent = PendingIntent.getBroadcast(
|
mPendingIntent = PendingIntent.getBroadcast(
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ import android.view.ViewGroup
|
|||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.TestRightCommands
|
import com.example.hpostesting.data.constant.TestRightCommands
|
||||||
import com.example.hpostesting.data.model.ErrorMessage
|
import com.example.hpostesting.data.model.ErrorMessage
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.utils.MyDialogListener
|
import com.example.hpostesting.presentation.utils.MyDialogListener
|
||||||
import com.example.hpostesting.presentation.utils.UIUtils
|
import com.example.hpostesting.presentation.utils.UIUtils
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
|||||||
@@ -10,13 +10,13 @@ import android.view.View
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.TestRightCommands
|
import com.example.hpostesting.data.constant.TestRightCommands
|
||||||
import com.example.hpostesting.data.model.ErrorMessage
|
import com.example.hpostesting.data.model.ErrorMessage
|
||||||
import com.example.hpostesting.data.model.test.TestType
|
import com.example.hpostesting.data.model.test.TestType
|
||||||
import com.example.hpostesting.presentation.MainActivity
|
import com.example.hpostesting.presentation.MainActivity
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.utils.MyDialogListener
|
import com.example.hpostesting.presentation.utils.MyDialogListener
|
||||||
import com.example.hpostesting.presentation.utils.UIUtils
|
import com.example.hpostesting.presentation.utils.UIUtils
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import android.view.ViewGroup
|
|||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.model.test.TestRightResultType
|
import com.example.hpostesting.data.model.test.TestRightResultType
|
||||||
import com.example.hpostesting.data.model.test.TestType
|
import com.example.hpostesting.data.model.test.TestType
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import android.net.Uri
|
|||||||
import androidx.lifecycle.MutableLiveData
|
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.DataHolder
|
||||||
import com.example.hpostesting.util.NetworkStatusLiveData
|
import com.example.hpostesting.data.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
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import android.util.Log
|
|||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
import com.example.hpostesting.data.constant.TestRightCommands
|
import com.example.hpostesting.data.constant.TestRightCommands
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.UsbServiceListener
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
import com.hoho.android.usbserial.driver.UsbSerialDriver
|
||||||
import com.hoho.android.usbserial.driver.UsbSerialPort
|
import com.hoho.android.usbserial.driver.UsbSerialPort
|
||||||
import com.hoho.android.usbserial.util.SerialInputOutputManager
|
import com.hoho.android.usbserial.util.SerialInputOutputManager
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import androidx.activity.viewModels
|
|||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.view.get
|
import androidx.core.view.get
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.presentation.hemocube.HemoCubeFragment
|
import com.example.hpostesting.presentation.hemocube.HemoCubeFragment
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import android.annotation.SuppressLint
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Build
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@@ -14,15 +13,15 @@ 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 com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.util.Result
|
import com.example.hpostesting.data.Result
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.HemoCubeCommands
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
import com.example.hpostesting.data.constant.TestStatus
|
import com.example.hpostesting.data.constant.TestStatus
|
||||||
import com.example.hpostesting.data.model.TestState
|
import com.example.hpostesting.data.model.TestState
|
||||||
import com.example.hpostesting.data.model.patient.DeviceData
|
import com.example.hpostesting.data.model.patient.DeviceData
|
||||||
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
import com.example.hpostesting.data.model.patient.toHemoCubeTestData
|
||||||
import com.example.hpostesting.presentation.utils.UsbServiceListener
|
import com.example.hpostesting.presentation.UsbServiceListener
|
||||||
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
import com.example.hpostesting.presentation.dashboard.DashboardActivity
|
||||||
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
import com.example.hpostesting.presentation.hemocube.HemocubeActivity
|
||||||
import com.example.hpostesting.presentation.utils.MyDialogListener
|
import com.example.hpostesting.presentation.utils.MyDialogListener
|
||||||
@@ -1156,8 +1155,6 @@ class TrueHemeFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun reconnect() {
|
private fun reconnect() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
||||||
(activity as HemocubeActivity).reconnectDevice()
|
(activity as HemocubeActivity).reconnectDevice()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -12,10 +12,10 @@ 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.util.CsvWriter
|
import com.example.hpostesting.data.CsvWriter
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.DataHolder
|
||||||
import com.example.hpostesting.util.NetworkStatusLiveData
|
import com.example.hpostesting.data.NetworkStatusLiveData
|
||||||
import com.example.hpostesting.util.Result
|
import com.example.hpostesting.data.Result
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
import com.example.hpostesting.data.dao.HemoCubeBufferDao
|
||||||
import com.example.hpostesting.data.dao.HemoCubeDao
|
import com.example.hpostesting.data.dao.HemoCubeDao
|
||||||
|
|||||||
11
app/src/main/java/com/example/hpostesting/test.kt
Normal file
11
app/src/main/java/com/example/hpostesting/test.kt
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package com.example.hpostesting
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Date
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
|
fun main(){
|
||||||
|
val dateFormat = SimpleDateFormat("MM:HHddMMyyyy", Locale.getDefault())
|
||||||
|
val currentDate = Date()
|
||||||
|
print(dateFormat.format(currentDate))
|
||||||
|
}
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package com.example.hpostesting.util
|
|
||||||
|
|
||||||
interface PropertyProvider {
|
|
||||||
|
|
||||||
fun getProperty(key: String): String
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.example.hpostesting.util
|
package com.example.hpostesting.util
|
||||||
|
|
||||||
import android.content.res.AssetManager
|
import android.content.res.AssetManager
|
||||||
|
import com.example.hpostesting.data.api.PropertyProvider
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.util.Properties
|
import java.util.Properties
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
|
||||||
|
|
||||||
<path android:fillColor="@android:color/white" android:pathData="M19,3L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM14,17L7,17v-2h7v2zM17,13L7,13v-2h10v2zM17,9L7,9L7,7h10v2z"/>
|
|
||||||
|
|
||||||
</vector>
|
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
>
|
tools:context=".presentation.dashboard.DashboardActivity">
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -16,17 +16,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?attr/actionBarSize"
|
||||||
android:background="?attr/colorPrimary"
|
android:background="?attr/colorPrimary"
|
||||||
app:popupTheme="@style/Theme.HPOS.PopupOverlay" >
|
app:popupTheme="@style/Theme.HPOS.PopupOverlay" />
|
||||||
<TextView
|
|
||||||
android:id="@+id/version_name"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="--"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:layout_gravity="end"
|
|
||||||
android:textSize="18sp"
|
|
||||||
android:layout_marginEnd="15dp"/>
|
|
||||||
</androidx.appcompat.widget.Toolbar>
|
|
||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<RelativeLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/titleText"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:gravity="center"
|
|
||||||
android:text="Upload Pending List(Local data)"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:textSize="21sp"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
/>
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/rv_order_offline"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_below="@+id/titleText"
|
|
||||||
android:layout_alignParentStart="true"
|
|
||||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
|
||||||
tools:listitem="@layout/offline_user_list_view" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/noDataText"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_centerInParent="true"
|
|
||||||
android:text="All up-to-date"
|
|
||||||
android:textSize="22sp"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
@@ -38,20 +38,10 @@
|
|||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
android:padding="24dp">
|
android:padding="24dp">
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/btnLogout1"
|
|
||||||
android:layout_width="30dp"
|
|
||||||
android:layout_height="30dp"
|
|
||||||
android:layout_marginEnd="10dp"
|
|
||||||
android:src="@drawable/baseline_logout_24"
|
|
||||||
app:layout_constraintTop_toTopOf="@+id/internetNotAvailableCL"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_title_no_internet"
|
android:id="@+id/tv_title_no_internet"
|
||||||
style="@style/title1"
|
style="@style/title1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
@@ -135,27 +125,6 @@
|
|||||||
<!-- app:layout_constraintBottom_toBottomOf="@+id/rv_order_offline"-->
|
<!-- app:layout_constraintBottom_toBottomOf="@+id/rv_order_offline"-->
|
||||||
<!-- app:layout_constraintStart_toStartOf="parent" />-->
|
<!-- app:layout_constraintStart_toStartOf="parent" />-->
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/label1"
|
|
||||||
style="@style/title1_1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/new_kit"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/btnNewKitoffline"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent" />
|
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
|
||||||
android:id="@+id/btnNewKitoffline"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="8dp"
|
|
||||||
android:backgroundTint="@color/primary"
|
|
||||||
android:contentDescription="@string/new_kit"
|
|
||||||
android:src="@drawable/ic_add"
|
|
||||||
app:elevation="1dp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
|||||||
@@ -12,10 +12,6 @@
|
|||||||
android:id="@+id/nav_profile"
|
android:id="@+id/nav_profile"
|
||||||
android:icon="@drawable/control_panel"
|
android:icon="@drawable/control_panel"
|
||||||
android:title="@string/profile" />
|
android:title="@string/profile" />
|
||||||
<item
|
|
||||||
android:id="@+id/nav_activity"
|
|
||||||
android:icon="@drawable/shows_activity_24"
|
|
||||||
android:title="@string/action_activity" />
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/nav_settings"
|
android:id="@+id/nav_settings"
|
||||||
android:icon="@drawable/baseline_settings_24"
|
android:icon="@drawable/baseline_settings_24"
|
||||||
|
|||||||
@@ -32,11 +32,6 @@
|
|||||||
android:name="com.example.hpostesting.presentation.dashboard.SlideshowFragment"
|
android:name="com.example.hpostesting.presentation.dashboard.SlideshowFragment"
|
||||||
android:label="@string/action_settings"
|
android:label="@string/action_settings"
|
||||||
tools:layout="@layout/fragment_slideshow" />
|
tools:layout="@layout/fragment_slideshow" />
|
||||||
<fragment
|
|
||||||
android:id="@+id/nav_activity"
|
|
||||||
android:name="com.example.hpostesting.presentation.dashboard.ActivitiesFragment"
|
|
||||||
android:label="@string/action_activity"
|
|
||||||
tools:layout="@layout/fragment_activities" />
|
|
||||||
<activity
|
<activity
|
||||||
android:id="@+id/mainActivity"
|
android:id="@+id/mainActivity"
|
||||||
android:name="com.example.hpostesting.presentation.MainActivity"
|
android:name="com.example.hpostesting.presentation.MainActivity"
|
||||||
|
|||||||
@@ -271,5 +271,4 @@
|
|||||||
<string name="deviceinfo">डिवाइस जानकारी</string>
|
<string name="deviceinfo">डिवाइस जानकारी</string>
|
||||||
|
|
||||||
<string name="downloadcsv">सीएसवी डाउनलोड करें</string>
|
<string name="downloadcsv">सीएसवी डाउनलोड करें</string>
|
||||||
<string name="action_activity">Activities</string>
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -270,7 +270,6 @@
|
|||||||
<string name="add_blood_group">ರಕ್ತ ಗುಂಡನ್ನು ಸೇರಿಸಿ</string>
|
<string name="add_blood_group">ರಕ್ತ ಗುಂಡನ್ನು ಸೇರಿಸಿ</string>
|
||||||
<string name="ok">ಸರಿ</string>
|
<string name="ok">ಸರಿ</string>
|
||||||
<string name="downloadcsv">CSV ಡೌನ್ಲೋಡ್ ಮಾಡಿ</string>
|
<string name="downloadcsv">CSV ಡೌನ್ಲೋಡ್ ಮಾಡಿ</string>
|
||||||
<string name="action_activity">Activities</string>
|
|
||||||
<!-- Add translations for other strings -->
|
<!-- Add translations for other strings -->
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -273,5 +273,4 @@
|
|||||||
<string name="select_language">Select your preferred language</string>
|
<string name="select_language">Select your preferred language</string>
|
||||||
<string name="app_language">App Language</string>
|
<string name="app_language">App Language</string>
|
||||||
<string name="ok">OK</string>
|
<string name="ok">OK</string>
|
||||||
<string name="action_activity">Activities</string>
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<external-files-path name="Updates" path="." />
|
<external-files-path name="downloaded_file" path="." />
|
||||||
</paths>
|
</paths>
|
||||||
|
|||||||
@@ -3,15 +3,18 @@ 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 androidx.lifecycle.Observer
|
||||||
|
import com.example.hpostesting.data.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.model.patient.DeviceData
|
||||||
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 io.mockk.*
|
import io.mockk.*
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import kotlinx.coroutines.test.TestCoroutineDispatcher
|
import kotlinx.coroutines.test.TestCoroutineDispatcher
|
||||||
import kotlinx.coroutines.test.setMain
|
import kotlinx.coroutines.test.setMain
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.example.hpostesting
|
package com.example.hpostesting
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.example.hpostesting.util.CsvWriter
|
import com.example.hpostesting.data.CsvWriter
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|||||||
@@ -1,5 +1,26 @@
|
|||||||
package com.example.hpostesting
|
package com.example.hpostesting
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import androidx.fragment.app.testing.FragmentScenario
|
||||||
|
import androidx.fragment.app.testing.launchFragmentInContainer
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import androidx.test.core.app.ApplicationProvider
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.constant.HemoCubeCommands
|
||||||
|
import com.example.hpostesting.presentation.deviceinfo.DeviceActivity
|
||||||
|
import com.example.hpostesting.presentation.UsbServiceListener
|
||||||
|
import com.example.hpostesting.presentation.hemocube.HemoCubeViewModel
|
||||||
|
import com.google.firebase.crashlytics.ktx.crashlytics
|
||||||
|
import com.google.firebase.ktx.Firebase
|
||||||
|
import `in`.sminnovations.hpostesting.databinding.FragmentDeviceBinding
|
||||||
|
import org.junit.After
|
||||||
|
import org.junit.Before
|
||||||
|
import org.junit.Test
|
||||||
|
import org.mockito.Mock
|
||||||
|
import org.mockito.Mockito.*
|
||||||
|
import org.mockito.MockitoAnnotations
|
||||||
|
|
||||||
class DeviceFragmentTest {
|
class DeviceFragmentTest {
|
||||||
//
|
//
|
||||||
// @Mock
|
// @Mock
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package com.example.hpostesting
|
|||||||
|
|
||||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import com.example.hpostesting.util.Result
|
import com.example.hpostesting.data.Result
|
||||||
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionRequest
|
||||||
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionResponse
|
import com.example.hpostesting.data.model.deviceprovision.DeviceProvisionResponse
|
||||||
import com.example.hpostesting.data.repository.Repository
|
import com.example.hpostesting.data.repository.Repository
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.example.hpostesting
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import com.example.hpostesting.util.Result
|
import com.example.hpostesting.data.Result
|
||||||
import com.example.hpostesting.data.model.login.LoginResponse
|
import com.example.hpostesting.data.model.login.LoginResponse
|
||||||
import com.example.hpostesting.data.repository.Repository
|
import com.example.hpostesting.data.repository.Repository
|
||||||
import com.example.hpostesting.domain.LogFileManager
|
import com.example.hpostesting.domain.LogFileManager
|
||||||
|
|||||||
@@ -1,5 +1,22 @@
|
|||||||
package com.example.hpostesting
|
package com.example.hpostesting
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import com.example.hpostesting.data.DataHolder
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
|
import com.example.hpostesting.data.dao.UserDao
|
||||||
|
import com.example.hpostesting.data.model.patient.UserData
|
||||||
|
import com.example.hpostesting.data.repository.DatabaseRepository
|
||||||
|
import com.example.hpostesting.domain.SaveRawData
|
||||||
|
import com.example.hpostesting.domain.SaveRawDataTest
|
||||||
|
import com.example.hpostesting.presentation.testRight.TestRightViewModel
|
||||||
|
import junit.framework.Assert.assertEquals
|
||||||
|
import org.junit.Before
|
||||||
|
import org.junit.Test
|
||||||
|
import org.mockito.Mock
|
||||||
|
import org.mockito.MockitoAnnotations
|
||||||
|
import java.math.RoundingMode
|
||||||
|
import java.text.DecimalFormat
|
||||||
|
|
||||||
class TestRightViewModelTest {
|
class TestRightViewModelTest {
|
||||||
// private val viewModel = TestRightViewModel()
|
// private val viewModel = TestRightViewModel()
|
||||||
// private val data = InputData()
|
// private val data = InputData()
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ buildscript {
|
|||||||
kotlin_version = '1.8.21'
|
kotlin_version = '1.8.21'
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:8.2.2'
|
classpath 'com.android.tools.build:gradle:8.3.0'
|
||||||
classpath 'com.google.gms:google-services:4.4.1'
|
classpath 'com.google.gms:google-services:4.4.0'
|
||||||
classpath 'com.google.firebase:firebase-appdistribution-gradle:4.1.0'
|
classpath 'com.google.firebase:firebase-appdistribution-gradle:4.0.1'
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,4 +1,4 @@
|
|||||||
#Mon Mar 04 17:08:24 IST 2024
|
#Tue Feb 27 16:09:58 IST 2024
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
||||||
|
|||||||
Reference in New Issue
Block a user