diff --git a/app/build.gradle b/app/build.gradle
index fae216e..9276ae0 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -52,11 +52,11 @@ android {
dependencies {
- implementation 'androidx.core:core-ktx:1.10.1'
+ implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
- implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.1'
+ implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2'
//firebase
implementation platform('com.google.firebase:firebase-bom:32.1.0')
@@ -66,7 +66,7 @@ dependencies {
implementation 'com.google.firebase:firebase-auth-ktx'
implementation 'com.google.firebase:firebase-storage-ktx'
implementation 'com.firebaseui:firebase-ui-firestore:8.0.2'
- implementation 'com.google.android.gms:play-services-auth:20.6.0'
+ implementation 'com.google.android.gms:play-services-auth:20.7.0'
implementation 'com.google.android.gms:play-services-location:21.0.1'
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
implementation 'com.google.android.things:androidthings:1.0'
@@ -77,7 +77,7 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
- implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1"
+ implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2"
implementation 'com.opencsv:opencsv:4.6'
implementation 'com.github.mik3y:usb-serial-for-android:3.5.1'
@@ -102,8 +102,8 @@ dependencies {
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.2'
// Navigation Component
- implementation "androidx.navigation:navigation-fragment-ktx:2.7.1"
- implementation "androidx.navigation:navigation-ui-ktx:2.7.1"
+ implementation "androidx.navigation:navigation-fragment-ktx:2.7.2"
+ implementation "androidx.navigation:navigation-ui-ktx:2.7.2"
//Dagger - Hilt
implementation "com.google.dagger:hilt-android:2.46"
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index e23cb28..b6897d1 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -99,7 +99,7 @@
diff --git a/app/src/main/java/com/example/hpostesting/HPOSTestingApplication.kt b/app/src/main/java/com/example/hpostesting/HPOSTestingApplication.kt
index 7dd5c98..7936299 100644
--- a/app/src/main/java/com/example/hpostesting/HPOSTestingApplication.kt
+++ b/app/src/main/java/com/example/hpostesting/HPOSTestingApplication.kt
@@ -5,6 +5,8 @@ import android.content.Context
import androidx.room.Room
import com.example.hpostesting.data.dao.MyDatabase
import com.google.android.datatransport.runtime.dagger.Provides
+import com.google.firebase.firestore.FirebaseFirestore
+import com.google.firebase.firestore.FirebaseFirestoreSettings
import dagger.hilt.android.HiltAndroidApp
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -13,7 +15,14 @@ import javax.inject.Singleton
@HiltAndroidApp
class HPOSTestingApplication: Application() {
- val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
-
+ override fun onCreate() {
+ super.onCreate()
+ val applicationScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
+ val firestoreSettings = FirebaseFirestoreSettings.Builder()
+ .setPersistenceEnabled(true) // Enable offline persistence if needed
+ .build()
+ val firestore = FirebaseFirestore.getInstance()
+ firestore.firestoreSettings = firestoreSettings
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/hpostesting/presentation/KitScanActivity.kt b/app/src/main/java/com/example/hpostesting/presentation/KitScanActivity.kt
index 1e150fb..deaa92e 100644
--- a/app/src/main/java/com/example/hpostesting/presentation/KitScanActivity.kt
+++ b/app/src/main/java/com/example/hpostesting/presentation/KitScanActivity.kt
@@ -5,11 +5,14 @@ import android.content.Intent
import android.content.SharedPreferences
import android.os.Bundle
import android.util.Log
+import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.example.hpostesting.data.DataHolder
import com.example.hpostesting.data.constant.Constants
import com.example.hpostesting.presentation.dashboard.DashboardActivity
+import com.google.android.material.snackbar.Snackbar
+import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.journeyapps.barcodescanner.ScanContract
import com.journeyapps.barcodescanner.ScanIntentResult
import com.journeyapps.barcodescanner.ScanOptions
@@ -50,10 +53,35 @@ class KitScanActivity : AppCompatActivity() {
moveToNext()
}
+// if (checkHemoCubeKitData()) {
+// DataHolder.selectedTest!!.kitSerial =
+// sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
+// moveToNext()
+// } else {
+// with(sharedPreference.edit()) {
+// putString(Constants.KIT_NUMBER, "")
+// putInt(Constants.KIT_COUNT, 0)
+// putString(Constants.BUFFER_VALUE_1, "")
+// putString(Constants.BUFFER_VALUE_2, "")
+// apply()
+// }
+
+
if (checkHemoCubeKitData()) {
- DataHolder.selectedTest!!.kitSerial =
- sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
- moveToNext()
+ try {
+ DataHolder.selectedTest!!.kitSerial =
+ sharedPreference.getString(Constants.KIT_NUMBER, "").toString()
+ moveToNext()
+ } catch (e: NullPointerException) {
+ // Handle the NullPointerException here
+ e.printStackTrace() // You can log the exception for debugging
+ FirebaseCrashlytics.getInstance().recordException(e)
+ val errorMessage = "An error occurred: ${e.message}"
+ val rootView = findViewById(android.R.id.content)
+ Snackbar.make(rootView, errorMessage, Snackbar.LENGTH_LONG).show()
+ // Optionally, show a user-friendly error message to the user
+ // For example, Toast.makeText(applicationContext, "An error occurred", Toast.LENGTH_SHORT).show()
+ }
} else {
with(sharedPreference.edit()) {
putString(Constants.KIT_NUMBER, "")
@@ -62,7 +90,9 @@ class KitScanActivity : AppCompatActivity() {
putString(Constants.BUFFER_VALUE_2, "")
apply()
}
- }
+
+
+ }
binding.nameEditText.setText("SMI/SC/")
diff --git a/app/src/main/java/com/example/hpostesting/presentation/MainActivity.kt b/app/src/main/java/com/example/hpostesting/presentation/MainActivity.kt
index ee7e544..854bb02 100644
--- a/app/src/main/java/com/example/hpostesting/presentation/MainActivity.kt
+++ b/app/src/main/java/com/example/hpostesting/presentation/MainActivity.kt
@@ -21,6 +21,8 @@ import com.example.hpostesting.data.constant.Constants
import com.example.hpostesting.data.model.patient.UserData
import com.example.hpostesting.data.model.test.TestType
import com.google.android.gms.location.*
+import com.google.android.material.snackbar.Snackbar
+import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.hoho.android.usbserial.driver.UsbSerialProber
import `in`.sminnovations.hpostesting.R
import `in`.sminnovations.hpostesting.databinding.ActivityMainBinding
@@ -234,18 +236,53 @@ class MainActivity : AppCompatActivity() {
return
}
- fusedLocationClient.lastLocation.addOnSuccessListener { location: Location? ->
- location?.let {
- DataHolder.selectedTest!!.location =
- UserData.Location(location.latitude, location.longitude)
- DataHolder.location =
- UserData.Location(location.latitude, location.longitude)
- } ?: run {
- requestLocationUpdates()
+// fusedLocationClient.lastLocation.addOnSuccessListener { location: Location? ->
+// location?.let {
+// DataHolder.selectedTest!!.location =
+// UserData.Location(location.latitude, location.longitude)
+// DataHolder.location =
+// UserData.Location(location.latitude, location.longitude)
+// } ?: run {
+// requestLocationUpdates()
+// }
+// }.addOnFailureListener { exception: Exception ->
+// exception.printStackTrace()
+// }
+
+
+
+ try {
+ fusedLocationClient.lastLocation.addOnSuccessListener { location: Location? ->
+ location?.let {
+ DataHolder.selectedTest!!.location =
+ UserData.Location(location.latitude, location.longitude)
+ DataHolder.location =
+ UserData.Location(location.latitude, location.longitude)
+ } ?: run {
+ requestLocationUpdates()
+ }
+ }.addOnFailureListener { exception: Exception ->
+ // Handle the exception here
+ exception.printStackTrace()
+ FirebaseCrashlytics.getInstance().recordException(exception)
+ // Display an error message to the user using a Snackbar
+ val errorMessage = "An error occurred: ${exception.message}"
+ val rootView = findViewById(android.R.id.content)
+ Snackbar.make(rootView, errorMessage, Snackbar.LENGTH_LONG).show()
}
- }.addOnFailureListener { exception: Exception ->
- exception.printStackTrace()
+ } catch (e: Exception) {
+ // Handle the exception here
+ e.printStackTrace()
+ FirebaseCrashlytics.getInstance().recordException(e)
+ // Display an error message to the user using a Snackbar
+ val errorMessage = "An error occurred: ${e.message}"
+ val rootView = findViewById(android.R.id.content)
+ Snackbar.make(rootView, errorMessage, Snackbar.LENGTH_LONG).show()
}
+
+
+
+
}
private fun requestLocationUpdates() {
diff --git a/app/src/main/java/com/example/hpostesting/presentation/SplashActivity.kt b/app/src/main/java/com/example/hpostesting/presentation/SplashActivity.kt
index a32c1fb..3623888 100644
--- a/app/src/main/java/com/example/hpostesting/presentation/SplashActivity.kt
+++ b/app/src/main/java/com/example/hpostesting/presentation/SplashActivity.kt
@@ -39,7 +39,7 @@ class SplashActivity : AppCompatActivity() {
binding = ActivitySplashBinding.inflate(layoutInflater)
setContentView(binding.root)
- setupFirestoreCache()
+// setupFirestoreCache()
setupStaticConstants()
requestPermissions()
@@ -50,12 +50,12 @@ class SplashActivity : AppCompatActivity() {
Settings.Secure.getString(applicationContext.contentResolver, Settings.Secure.ANDROID_ID)
}
- private fun setupFirestoreCache() {
- val settings = FirebaseFirestoreSettings.Builder()
- .setCacheSizeBytes(FirebaseFirestoreSettings.CACHE_SIZE_UNLIMITED)
- .build()
- Firebase.firestore.firestoreSettings = settings
- }
+// private fun setupFirestoreCache() {
+// val settings = FirebaseFirestoreSettings.Builder()
+// .setCacheSizeBytes(FirebaseFirestoreSettings.CACHE_SIZE_UNLIMITED)
+// .build()
+// Firebase.firestore.firestoreSettings = settings
+// }
private fun requestPermissions() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
diff --git a/app/src/main/java/com/example/hpostesting/presentation/dashboard/GalleryFragment.kt b/app/src/main/java/com/example/hpostesting/presentation/dashboard/GalleryFragment.kt
index 772ee88..1911ca0 100644
--- a/app/src/main/java/com/example/hpostesting/presentation/dashboard/GalleryFragment.kt
+++ b/app/src/main/java/com/example/hpostesting/presentation/dashboard/GalleryFragment.kt
@@ -25,7 +25,7 @@ class GalleryFragment : Fragment() {
// val galleryViewModel =
// ViewModelProvider(this).get(GalleryViewModel::class.java)
-// _binding = FragmentGalleryBinding.inflate(inflater, container, false)
+ _binding = FragmentGalleryBinding.inflate(inflater, container, false)
val root: View = binding.root
// val textView: TextView = binding.textGallery
diff --git a/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt b/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt
index bbc15c9..3bd989a 100644
--- a/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt
+++ b/app/src/main/java/com/example/hpostesting/presentation/dashboard/HomeFragment.kt
@@ -37,8 +37,16 @@ class HomeFragment : Fragment() {
private lateinit var sharedPreference: SharedPreferences
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
- ): View {
+ ): View? {
_binding = FragmentHomeBinding.inflate(inflater, container, false)
+
+ // Check if _binding is null
+ if (_binding == null) {
+ // Handle the case where binding could not be initialized
+ // You may want to log an error or return a default view in this case
+ return super.onCreateView(inflater, container, savedInstanceState)
+ }
+
sharedPreference = requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
DataHolder.selectedTest = null