BackLog file added for nagpur consignment for Online Registration code added, fixed all issues
This commit is contained in:
4
.idea/shelf/Changes3.xml
generated
4
.idea/shelf/Changes3.xml
generated
@@ -1,4 +0,0 @@
|
||||
<changelist name="Changes3" date="1701681803133" recycled="false">
|
||||
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/Changes3/shelved.patch" />
|
||||
<option name="DESCRIPTION" value="Changes" />
|
||||
</changelist>
|
||||
@@ -1,12 +1,15 @@
|
||||
package com.example.hposregistration.ui.fragments.registration
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.edit
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
@@ -49,7 +52,7 @@ class AbhaRegistrationFragment : BaseFragment() {
|
||||
): View {
|
||||
_binding = FragmentAbhaRegistrationBinding.inflate(inflater, container, false)
|
||||
sharedPreference =
|
||||
requireContext().getSharedPreferences("userAbhaRegistrationLog", Context.MODE_PRIVATE)
|
||||
requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||
return binding.root
|
||||
|
||||
|
||||
@@ -60,6 +63,7 @@ class AbhaRegistrationFragment : BaseFragment() {
|
||||
init()
|
||||
}
|
||||
|
||||
@SuppressLint("LogNotTimber", "CommitPrefEdits")
|
||||
private fun init() {
|
||||
binding.btnScanNow.setOnClickListener {
|
||||
barcodeLauncher.launch(scanQR("Please Scan the Abha ID/Aadhar ID"))
|
||||
@@ -91,15 +95,23 @@ class AbhaRegistrationFragment : BaseFragment() {
|
||||
aadharId = aadharIdInput
|
||||
abhaId = abhaIdInput
|
||||
registrationCenterName = centerName
|
||||
_id = aadharId + userName.substring(0, 3).uppercase() + centerName.substring(0, 3).uppercase()
|
||||
userAbhaRegistrationLog = "$abhaIdInput,$userName,$aadharIdInput,$centerName"
|
||||
}
|
||||
_id = aadharId + userName.substring(0, 3).uppercase() + centerName.substring(0, 3)
|
||||
.uppercase()
|
||||
userData.userAbhaRegistrationLog = "${userData.abhaId}," + "${userData.name}," +"${userData.aadharId}," + "${userData.registrationCenterName}"
|
||||
Log.e(
|
||||
"userAbhaRegistrationLog",
|
||||
"Assigned userAbhaRegistrationLog: ${userData.userAbhaRegistrationLog}"
|
||||
)
|
||||
|
||||
sharedPreference.edit()
|
||||
.putString("userAbhaRegistrationLog", userData.userAbhaRegistrationLog)
|
||||
.apply()
|
||||
|
||||
Log.e("userAbhaRegistrationLog", sharedPreference.getString("userAbhaRegistrationLog","").toString())
|
||||
}
|
||||
viewModel.insert(userData)
|
||||
// Make sure this provides a meaningful string representation of userData
|
||||
|
||||
viewModel.insert(userData)
|
||||
val userDataString = userData.userAbhaRegistrationLog// Make sure this provides a meaningful string representation of userData
|
||||
sharedPreference.edit()
|
||||
.putString("userAbhaRegistrationLog", userDataString)
|
||||
.apply()
|
||||
navigateToUserDetailsFragment(userData._id)
|
||||
}
|
||||
}
|
||||
@@ -119,6 +131,7 @@ class AbhaRegistrationFragment : BaseFragment() {
|
||||
state = obj.getString("state name")
|
||||
district = obj.getString("district_name")
|
||||
house = obj.getString("address")
|
||||
userAbhaRegistrationLog = obj.getString("userAbhaRegistrationLog")
|
||||
}
|
||||
|
||||
if (userData.abhaId.isNotEmpty()) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@@ -54,9 +55,8 @@ class ReviewDetailsRegistrationFragment : BaseFragment() {
|
||||
viewModel.getUserByID(args.userId)
|
||||
viewModel.userData.observe(viewLifecycleOwner) { user ->
|
||||
userData = user
|
||||
userData.userAbhaRegistrationLog =
|
||||
sharedPreference.getString("userAbhaRegistrationLog", "").toString()
|
||||
userData.userDetailsLog = sharedPreference.getString("userDetailsLOg", "").toString()
|
||||
userData.userAbhaRegistrationLog = sharedPreference.getString("userAbhaRegistrationLog", "").toString()
|
||||
userData.userDetailsLog = sharedPreference.getString("userDetailslog", "").toString()
|
||||
setUserData(user)
|
||||
}
|
||||
|
||||
@@ -181,11 +181,11 @@ class ReviewDetailsRegistrationFragment : BaseFragment() {
|
||||
)
|
||||
val version = pInfo.versionName
|
||||
userData.appVersion = version
|
||||
|
||||
val useAbhaRegistrationLog = sharedPreference.getString("userAbhaRegistrationLog", "").toString()
|
||||
val userDetailsLog = sharedPreference.getString("userDetailsLOg", "").toString()
|
||||
userData.userAbhaRegistrationLog= useAbhaRegistrationLog
|
||||
userData.userDetailsLog = userDetailsLog
|
||||
userData.userAbhaRegistrationLog = "${userData.abhaId}," + "${userData.name}," +"${userData.aadharId}," + "${userData.registrationCenterName}"
|
||||
userData.userAbhaRegistrationLog = sharedPreference.getString("userAbhaRegistrationLog", "").toString()
|
||||
userData.userDetailsLog = sharedPreference.getString("userDetailslog", "").toString()
|
||||
Log.e("userAbhaRegistrationLog",userData.userAbhaRegistrationLog)
|
||||
Log.e("userAbhaRegistrationLog",userData.userDetailsLog)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.example.hposregistration.ui.fragments.registration
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@@ -35,7 +37,7 @@ class UserDetailsRegistrationFragment : Fragment() {
|
||||
): View {
|
||||
_binding = FragmentUserDetailsRegistrationBinding.inflate(inflater, container, false)
|
||||
sharedPreference =
|
||||
requireContext().getSharedPreferences("userDetailsLOg", Context.MODE_PRIVATE)
|
||||
requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||
|
||||
return binding.root
|
||||
}
|
||||
@@ -117,44 +119,43 @@ class UserDetailsRegistrationFragment : Fragment() {
|
||||
binding.tilFamilyHistory.visibility =
|
||||
if (binding.no1history.isChecked) View.GONE else View.VISIBLE
|
||||
}
|
||||
|
||||
userData.userDetailsLog = "${userData.birthYear}," +
|
||||
"${userData.gender}," +
|
||||
"${userData.phoneNumber}," +
|
||||
"${userData.careOf}," +
|
||||
"${userData.maritalStatus}," +
|
||||
"${userData.category}," +
|
||||
"${userData.caste}," +
|
||||
"${userData.subCaste ?: ""}," + // Using Elvis operator for nullable fields
|
||||
"${userData.appVersion}," +
|
||||
"${userData.house}," +
|
||||
"${userData.city}," +
|
||||
"${userData.district}," +
|
||||
"${userData.state}," +
|
||||
"${userData.pinCode}," +
|
||||
"${userData.bloodGroup}," +
|
||||
"${userData.isUnderMedication ?: false}," + // Converting null to false
|
||||
"${userData.isUnderTransfusion ?: false}," +
|
||||
"${userData.sickleCellHistory ?: ""}," +
|
||||
"${userData.userImageURL}," +
|
||||
"${userData.registeredBy ?: ""}," +
|
||||
"${userData.createdAt ?: ""}," +
|
||||
"${userData.registrationCenterName ?: ""}," +
|
||||
"${userData.testStatus},"
|
||||
|
||||
|
||||
val userDataString = userData.userDetailsLog// Make sure this provides a meaningful string representation of userData
|
||||
sharedPreference.edit()
|
||||
.putString("userDetailsLOg", userDataString)
|
||||
.apply()
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("LogNotTimber")
|
||||
private fun setupSubmitButton() {
|
||||
binding.btnSubmit.setOnClickListener {
|
||||
if (verifyUserDetails()) {
|
||||
userData._id = args.userId
|
||||
viewModel.insert(userData)
|
||||
userData.userDetailsLog = "${userData.birthYear}," +
|
||||
"${userData.gender}," +
|
||||
"${userData.phoneNumber}," +
|
||||
"${userData.careOf}," +
|
||||
"${userData.maritalStatus}," +
|
||||
"${userData.category}," +
|
||||
"${userData.caste}," +
|
||||
"${userData.subCaste ?: ""}," + // Using Elvis operator for nullable fields
|
||||
"${userData.appVersion}," +
|
||||
"${userData.house}," +
|
||||
"${userData.city}," +
|
||||
"${userData.district}," +
|
||||
"${userData.state}," +
|
||||
"${userData.pinCode}," +
|
||||
"${userData.bloodGroup}," +
|
||||
"${userData.isUnderMedication ?: false}," + // Converting null to false
|
||||
"${userData.isUnderTransfusion ?: false}," +
|
||||
"${userData.sickleCellHistory ?: ""}," +
|
||||
"${userData.userImageURL}," +
|
||||
"${userData.registeredBy ?: ""}," +
|
||||
"${userData.createdAt ?: ""}," +
|
||||
"${userData.registrationCenterName ?: ""}," +
|
||||
"${userData.testStatus},"
|
||||
val userDataString = userData.userDetailsLog// Make sure this provides a meaningful string representation of userData
|
||||
sharedPreference.edit()
|
||||
.putString("userDetailslog", userData.userDetailsLog)
|
||||
.apply()
|
||||
Log.e("userAbhaRegistrationLog",userData.userDetailsLog)
|
||||
navigateToCaptureUserImageFragment()
|
||||
} else {
|
||||
showToast("Please enter all the details properly")
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.example.hposregistration.ui.viewmodels
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.net.Uri
|
||||
import androidx.core.content.ContentProviderCompat.requireContext
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
@@ -30,8 +32,11 @@ class RegistrationViewModel @Inject constructor(
|
||||
val allUserData = mainRepository.allUsers
|
||||
|
||||
val fireBaseUpload = MutableLiveData<String>()
|
||||
|
||||
private val sharedPreference =
|
||||
context.getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
|
||||
fun addUserToDatabase(userData: UserData) = viewModelScope.launch {
|
||||
userData.userAbhaRegistrationLog = sharedPreference.getString("userAbhaRegistrationLog", "").toString()
|
||||
userData.userDetailsLog = sharedPreference.getString("userDetailslog", "").toString()
|
||||
val file = Uri.parse(userData.userImageURL)
|
||||
val storageRef = FirebaseStorage.getInstance().reference
|
||||
val imageRef = storageRef.child("${userData._id}/${file.lastPathSegment}")
|
||||
@@ -66,6 +71,8 @@ class RegistrationViewModel @Inject constructor(
|
||||
val networkStatusLiveData: LiveData<Boolean>
|
||||
get() = _networkStatusLiveData
|
||||
|
||||
|
||||
|
||||
fun insert(userData: UserData) = viewModelScope.launch {
|
||||
val currentDate = Date()
|
||||
val dateFormat = SimpleDateFormat("yyyyMMdd")
|
||||
@@ -76,6 +83,16 @@ class RegistrationViewModel @Inject constructor(
|
||||
userData.createdAt = SimpleDateFormat(
|
||||
"yyyy-MM-dd HH:mm:ss", Locale.getDefault()
|
||||
).format(Calendar.getInstance().time)
|
||||
|
||||
|
||||
val useAbhaRegistrationLog = sharedPreference.getString("userAbhaRegistrationLog", "").toString()
|
||||
val userDetailsLog = sharedPreference.getString("userDetailslog", "").toString()
|
||||
userData.userAbhaRegistrationLog = sharedPreference.getString("userAbhaRegistrationLog", "").toString()
|
||||
userData.userDetailsLog = sharedPreference.getString("userDetailslog", "").toString()
|
||||
|
||||
|
||||
userData.userAbhaRegistrationLog= useAbhaRegistrationLog
|
||||
userData.userDetailsLog = userDetailsLog
|
||||
mainRepository.insert(userData)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user