diff --git a/app/src/main/java/com/example/refactoredapp/presentation/testRight/TestRightExpSample.kt b/app/src/main/java/com/example/refactoredapp/presentation/testRight/TestRightExpSample.kt
index bc165db..ee72f03 100644
--- a/app/src/main/java/com/example/refactoredapp/presentation/testRight/TestRightExpSample.kt
+++ b/app/src/main/java/com/example/refactoredapp/presentation/testRight/TestRightExpSample.kt
@@ -1,16 +1,26 @@
package com.example.refactoredapp.presentation.testRight
+import android.R.attr.button
+import android.content.res.ColorStateList
+import android.content.res.Resources
+import android.graphics.Color
+import android.graphics.LightingColorFilter
+import android.graphics.PorterDuff
import android.os.Bundle
-import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.widget.Button
+import androidx.core.content.ContextCompat
+import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
-import com.example.refactoredapp.databinding.FragmentTestRightExpReferenceBinding
+import com.example.refactoredapp.R
+import com.example.refactoredapp.data.model.PatientDetails
+import com.example.refactoredapp.databinding.FragmentTestRightExpSampleBinding
class TestRightExpSample : Fragment() {
- private lateinit var binding: FragmentTestRightExpReferenceBinding
+ private lateinit var binding: FragmentTestRightExpSampleBinding
private val viewModel: TestRightViewModel by activityViewModels()
override fun onCreateView(
@@ -18,7 +28,62 @@ class TestRightExpSample : Fragment() {
savedInstanceState: Bundle?
): View {
// Inflate the layout for this fragment
- binding = FragmentTestRightExpReferenceBinding.inflate(inflater, container, false)
+ binding = FragmentTestRightExpSampleBinding.inflate(inflater, container, false)
+ binding.btnUpdateReference.disable()
return binding.root
}
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ setupListeners()
+ }
+
+ private fun setupListeners() {
+ binding.btnAcquire.setOnClickListener {
+ val details = isValidInput()
+ if (details != null) {
+ viewModel.patientDetails = details
+ startAcquiring()
+ }
+ }
+ binding.etNameBlock.setOnClickListener { binding.etName.error = "" }
+ binding.etAgeBlock.setOnClickListener { binding.etAge.error = "" }
+ binding.etGenderBlock.setOnClickListener { binding.ddGender.error = "" }
+ }
+
+ private fun startAcquiring() {
+
+ }
+
+ private fun isValidInput() : PatientDetails? {
+ val name = binding.etName.editText?.text?.trim()
+ if (name.isNullOrEmpty()){
+ binding.etName.error = getString(R.string.name_error)
+ return null
+ }
+ val age = binding.etAge.editText?.text?.trim()
+ if (age.isNullOrEmpty()){
+ binding.etAge.error = getString(R.string.age_error)
+ return null
+ } else if (age.toString().toInt() < 0 || age.toString().toInt() > 199) {
+ binding.etAge.error = getString(R.string.age_error_out_of_bound)
+ return null
+ }
+ val gender = binding.ddGender.editText?.text
+ if (gender.isNullOrEmpty()){
+ binding.ddGender.error = getString(R.string.gender_error)
+ return null
+ }
+ return PatientDetails(name.toString(), age.toString().toInt(), gender.toString())
+ }
+
+ private fun Button.disable() {
+ backgroundTintList = ContextCompat.getColorStateList(requireActivity(), R.color.gray)
+ isClickable = false
+ }
+
+ fun Button.enable() {
+ backgroundTintList = ContextCompat.getColorStateList(requireActivity(), R.color.purple_500)
+// background.setColorFilter(Color.BLUE, PorterDuff.Mode.MULTIPLY)
+ isClickable = true
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/refactoredapp/presentation/testRight/TestRightViewModel.kt b/app/src/main/java/com/example/refactoredapp/presentation/testRight/TestRightViewModel.kt
index 8d27209..a844c78 100644
--- a/app/src/main/java/com/example/refactoredapp/presentation/testRight/TestRightViewModel.kt
+++ b/app/src/main/java/com/example/refactoredapp/presentation/testRight/TestRightViewModel.kt
@@ -1,10 +1,13 @@
package com.example.refactoredapp.presentation.testRight
import android.util.Log
+import android.util.Patterns
+import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.refactoredapp.data.Constants
+import com.example.refactoredapp.data.model.PatientDetails
import com.example.refactoredapp.data.model.TestRightDeviceConstants
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@@ -12,12 +15,15 @@ import kotlin.math.pow
class TestRightViewModel : ViewModel() {
- var isReferenceDone = false
- var isServiceConnected = false
private val TAG = "TestRightViewModel"
+ var isReferenceDone = false
+ var isServiceConnected = false
+
val isUsbConnected = MutableLiveData(false)
+ lateinit var patientDetails: PatientDetails
+
var deviceConstant: TestRightDeviceConstants? = null
/* Contains wavelength -> pixel no.*/
@@ -92,16 +98,28 @@ class TestRightViewModel : ViewModel() {
// }
}
-
-// val dispatcher = TestCoroutineDispatcher()
-//
-// @Before
-// fun setup() {
-// Dispatchers.setMain(dispatcher)
-// }
-//
-// @After
-// fun tearDown() {
-// Dispatchers.resetMain()
+// fun isValidInput() : Boolean{
+// name = email.trim()
+// return when {
+// email.isEmpty() -> {
+// Log.d(TAG, "email is empty")
+// _emailError.value = context.getString(R.string.malformed_email_empty_error)
+// false
+// }
+// !Patterns.EMAIL_ADDRESS.matcher(email).matches() -> {
+// Log.d(TAG, "email pattern mismatched")
+// _emailError.value = context.getString(R.string.malformed_email_error)
+// false
+// }
+// password.length < 6 -> {
+// Log.d(TAG, "password is empty")
+// _passwordError.value = context.getString(R.string.malformed_password_error)
+// false
+// }
+// else -> {
+// Log.d(TAG, "isValidInput: returning true")
+// true
+// }
+// }
// }
}
\ No newline at end of file
diff --git a/app/src/main/res/drawable/ic_baseline_create_24.xml b/app/src/main/res/drawable/ic_baseline_create_24.xml
new file mode 100644
index 0000000..1c9bd3e
--- /dev/null
+++ b/app/src/main/res/drawable/ic_baseline_create_24.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/app/src/main/res/layout/fragment_test_right_exp_sample.xml b/app/src/main/res/layout/fragment_test_right_exp_sample.xml
index 63f8707..bc33147 100644
--- a/app/src/main/res/layout/fragment_test_right_exp_sample.xml
+++ b/app/src/main/res/layout/fragment_test_right_exp_sample.xml
@@ -1,12 +1,222 @@
-
-
+ android:layout_height="match_parent">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index ff21ebe..17d3e88 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -6,6 +6,12 @@
- Denovix
+
+ - Male
+ - Female
+ - Other
+
+
Hello blank fragment
Select the Test
Set Reference
@@ -15,10 +21,31 @@
Please place the cuvette containing sample for reference before moving forward
Yes
No
+
Connect
Connected
Read
+ Update Reference
+
+
+
Instructions
Step 1 : Place the cuvette containing reference/baseline sample for referencing.
Step 2 : Press the button below to start the device reading values.
+
+ Step 1 : Enter the sample details to start.
+ Step 2 : Place the cuvette containing sample for experiment.
+ Step 3 : Press the button below to start the device reading values.
+
+
+ Acquire
+ Enter Sample Details
+ Sample Name
+ Age
+ Gender
+ Name can\'t be empty
+ Age can\'t be empty
+ Gender can\'t be empty
+ Age should be valid
+
\ No newline at end of file