diff --git a/app/src/main/java/com/example/hpostesting/data/constant/Constants.kt b/app/src/main/java/com/example/hpostesting/data/constant/Constants.kt index 89c621a..3d5308f 100644 --- a/app/src/main/java/com/example/hpostesting/data/constant/Constants.kt +++ b/app/src/main/java/com/example/hpostesting/data/constant/Constants.kt @@ -32,21 +32,26 @@ object Constants { const val USER_ID = "usernameId" val STATICID = listOf( - "SMIREG1", - "SMIREG2", - "SMIREG3", - "SMIREG4", - "SMIREG5", - "SMIREG6", - "SMIREG7", - "SMIREG8", - "SMIREG9", - "SMIREG10", - "SMIREG11", - "SMIREG12", - "SMIREG13", - "SMIREG14", - "SMIREG15" + "VIZ-1000-0001", + "VIZ-1000-0002", + "VIZ-1000-0003", + "VIZ-1000-0004", + "VIZ-1000-0005", + "VIZ-1000-0006", + "VIZ-1000-0007", + "VIZ-1000-0008", + "VIZ-1000-0009", + "VIZ-1000-0010", + "VIZ-1000-0011", + "VIZ-1000-0012", + "VIZ-1000-0013", + "VIZ-1000-0014", + "VIZ-1000-0015", + "VIZ-1000-0016", + "VIZ-1000-0017", + "VIZ-1000-0018", + "VIZ-1000-0019" + ) const val password = "SMI@12345" diff --git a/app/src/main/java/com/example/hpostesting/presentation/adapter/UserListAdapter.kt b/app/src/main/java/com/example/hpostesting/presentation/adapter/UserListAdapter.kt index b6e2bc3..653b623 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/adapter/UserListAdapter.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/adapter/UserListAdapter.kt @@ -34,7 +34,10 @@ class UserListAdapter(options: FirestoreRecyclerOptions, private val v userId.text = model._id Glide.with(view).load(model.userImageURL).into(userImage) if (model.testStatus!!) { - userCard.setCardBackgroundColor(view.resources.getColor(R.color.gray)) + teststatus.text = "Test concluded" + + } else { + teststatus.text = "Test is Pending" } userCard.setOnClickListener { if (model.testStatus != null) { 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 5335c54..1bfa6f2 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 @@ -109,7 +109,7 @@ class HomeFragment : Fragment() { // Positive button builder.setPositiveButton("Yes") { dialog, _ -> saveUserId("") - findNavController().navigate(R.id.action_userListFragment_to_loginFragment) + findNavController().navigate(R.id.action_nav_home_to_loginFragment) dialog.dismiss() } diff --git a/app/src/main/java/com/example/hpostesting/presentation/dashboard/ui/LoginFragment.kt b/app/src/main/java/com/example/hpostesting/presentation/dashboard/ui/LoginFragment.kt index f6ddfd1..39fecbe 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/dashboard/ui/LoginFragment.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/dashboard/ui/LoginFragment.kt @@ -27,11 +27,15 @@ class LoginFragment : Fragment() { return binding.root } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + init() + } private fun init() { if (isUserLoggedIn()) { - navigateToUserListFragment() + navigateToHomeFragment() return } @@ -56,8 +60,8 @@ class LoginFragment : Fragment() { return sharedPreference.getString(Constants.USER_ID, "")?.isNotBlank() == true } - private fun navigateToUserListFragment() { - findNavController().navigate(R.id.action_loginFragment_to_userListFragment) + private fun navigateToHomeFragment() { + findNavController().navigate(R.id.action_loginFragment_to_homeFragment) } private fun performLogin(loginId: String, password: String) { @@ -65,7 +69,7 @@ class LoginFragment : Fragment() { if (matchingId != null) { if (password == Constants.password) { saveUserId(loginId) - navigateToUserListFragment() + navigateToHomeFragment() return } else { Toast.makeText(requireContext(), "Wrong Password", Toast.LENGTH_SHORT).show() diff --git a/app/src/main/java/com/example/hpostesting/presentation/dashboard/ui/gallery/GalleryViewModel.kt b/app/src/main/java/com/example/hpostesting/presentation/dashboard/ui/gallery/GalleryViewModel.kt index 7906635..68df077 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/dashboard/ui/gallery/GalleryViewModel.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/dashboard/ui/gallery/GalleryViewModel.kt @@ -4,7 +4,7 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel -class GalleryViewModel : ViewModel() { +class mGalleryViewModel : ViewModel() { private val _text = MutableLiveData().apply { value = "This is gallery Fragment" diff --git a/app/src/main/java/com/example/hpostesting/presentation/testRight/TestRightResults.kt b/app/src/main/java/com/example/hpostesting/presentation/testRight/TestRightResults.kt index 6587257..24cbc32 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/testRight/TestRightResults.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/testRight/TestRightResults.kt @@ -1,8 +1,9 @@ package com.example.hpostesting.presentation.testRight +import android.content.Context import android.content.Intent +import android.content.SharedPreferences import android.os.Bundle -import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -18,24 +19,21 @@ import com.example.hpostesting.util.MyUtils.calculateAgeFromYOB import dagger.hilt.android.AndroidEntryPoint import `in`.sminnovations.hpostesting.R import `in`.sminnovations.hpostesting.databinding.FragmentTestRightResultsBinding -import java.text.SimpleDateFormat -import java.util.Date @AndroidEntryPoint class TestRightResults : Fragment() { private lateinit var binding: FragmentTestRightResultsBinding private val viewModel: TestRightViewModel by activityViewModels() - - private val TAG = "TestRightResults" - private var isOnline = false + private lateinit var sharedPreference: SharedPreferences override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { // Inflate the layout for this fragment binding = FragmentTestRightResultsBinding.inflate(inflater, container, false) - + sharedPreference = + requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE) return binding.root } @@ -135,11 +133,12 @@ class TestRightResults : Fragment() { } } viewModel.networkStatusLiveData.observe(viewLifecycleOwner) { isNetworkAvailable -> + val deviceStaticId = sharedPreference.getString(Constants.USER_ID, "") if (isNetworkAvailable) { - viewModel.uploadResultToDatabase(requireContext(), true) + viewModel.uploadResultToDatabase(requireContext(), true, deviceStaticId!!) binding.progressBar.visibility = View.VISIBLE } else { - viewModel.uploadResultToDatabase(requireContext(), false) + viewModel.uploadResultToDatabase(requireContext(), false, deviceStaticId!!) Toast.makeText( requireContext(), "Internet not available, Test Data added to Local DB", @@ -150,7 +149,7 @@ class TestRightResults : Fragment() { } - fun moveToSamplePage() { + private fun moveToSamplePage() { if (DataHolder.sampleReadCounter > Constants.MAXIMUM_TEST_ALLOWED_BEFORE_REFERENCE) { DataHolder.sampleReadCounter = 0 DataHolder.isReferenceTaken = false @@ -162,14 +161,5 @@ class TestRightResults : Fragment() { } } - private fun saveLog() { - Log.d(TAG, "saveLog() called") - val sdfDate = SimpleDateFormat("ddMMyyyy HHmmss") - val fileName: String = "log_" + sdfDate.format(Date()) + ".txt" - - viewModel.saveLog(requireContext().applicationContext, fileName) - - - } } \ No newline at end of file diff --git a/app/src/main/java/com/example/hpostesting/presentation/testRight/TestRightViewModel.kt b/app/src/main/java/com/example/hpostesting/presentation/testRight/TestRightViewModel.kt index 59cf5e4..06b96b1 100644 --- a/app/src/main/java/com/example/hpostesting/presentation/testRight/TestRightViewModel.kt +++ b/app/src/main/java/com/example/hpostesting/presentation/testRight/TestRightViewModel.kt @@ -455,11 +455,12 @@ class TestRightViewModel @Inject constructor( } } - fun uploadResultToDatabase(context: Context, isOnline: Boolean) = viewModelScope.launch { + fun uploadResultToDatabase(context: Context, isOnline: Boolean,deviceSerialNumber: String) = viewModelScope.launch { val csvFilePath = MyUtils.getAppFolderPath(context) + getCSVFileName() val logTxtFilePath = MyUtils.getAppFolderPath(context) + getLogFileName() testDetails?.csvPath = csvFilePath testDetails?.reportPath = logTxtFilePath + testDetails?.deviceSerialNumber = deviceSerialNumber if (isOnline) { val storageRef = FirebaseStorage.getInstance().reference val storageTestDetailsRef = storageRef.child("${testDetails?._id}/") @@ -476,7 +477,7 @@ class TestRightViewModel @Inject constructor( val csvUri = csvUploadTask.storage.downloadUrl.await().toString() val logUri = logUploadTask.storage.downloadUrl.await().toString() - + val serialNumber = Constants.STATICID.firstOrNull { it == deviceSerialNumber } testDetails?.csvPath = csvUri testDetails?.reportPath = logUri @@ -512,6 +513,7 @@ class TestRightViewModel @Inject constructor( userData.csvPath = csvUri userData.reportPath = logUri + bulkAddResultTestToDb(userData) } catch (exception: Exception) { // Handle the exception appropriately (e.g., log the error, display an error message) diff --git a/app/src/main/res/drawable/sickle_cell_gov_logo.png b/app/src/main/res/drawable/sickle_cell_gov_logo.png new file mode 100644 index 0000000..20d0952 Binary files /dev/null and b/app/src/main/res/drawable/sickle_cell_gov_logo.png differ diff --git a/app/src/main/res/layout/fragment_login.xml b/app/src/main/res/layout/fragment_login.xml index f2c44df..220ea5b 100644 --- a/app/src/main/res/layout/fragment_login.xml +++ b/app/src/main/res/layout/fragment_login.xml @@ -62,7 +62,7 @@ android:layout_height="wrap_content" android:hint="@string/login_id" android:inputType="textCapCharacters" - android:maxLength="12" /> + android:maxLength="13" /> + + + diff --git a/app/src/main/res/navigation/dashboard_navigation.xml b/app/src/main/res/navigation/dashboard_navigation.xml index 7c6aa0f..e7cae43 100644 --- a/app/src/main/res/navigation/dashboard_navigation.xml +++ b/app/src/main/res/navigation/dashboard_navigation.xml @@ -3,7 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/mobile_navigation" - app:startDestination="@+id/nav_home"> + app:startDestination="@+id/loginFragment"> +