2 Commits

15 changed files with 284 additions and 268 deletions

3
app/.gitignore vendored
View File

@@ -1,2 +1 @@
/build
/google-services*
/build

View File

@@ -16,8 +16,8 @@ android {
applicationId "in.sminnovations.hposregistration"
minSdk 26
targetSdk 34
versionCode 6
versionName "1.0.6"
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@@ -42,9 +42,9 @@ android {
dependencies {
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.core:core-ktx:1.10.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.10.0'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
@@ -58,26 +58,24 @@ 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.7.0'
implementation 'com.google.firebase:firebase-appdistribution:16.0.0-beta11'
implementation("com.google.firebase:firebase-appdistribution-api-ktx:16.0.0-beta11")
implementation 'com.google.android.gms:play-services-auth:20.6.0'
// Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1'
// Coroutine Lifecycle Scopes
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.2"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.1"
//Dagger - Hilt
implementation "com.google.dagger:hilt-android:2.46"
kapt "com.google.dagger:hilt-android-compiler:2.46"
kapt "androidx.hilt:hilt-compiler:1.1.0"
kapt "androidx.hilt:hilt-compiler:1.0.0"
// Navigation Component
implementation "androidx.navigation:navigation-fragment-ktx:2.7.5"
implementation "androidx.navigation:navigation-ui-ktx:2.7.5"
implementation "androidx.navigation:navigation-fragment-ktx:2.7.0"
implementation "androidx.navigation:navigation-ui-ktx:2.7.0"
// Retrofit + GSON
implementation "com.squareup.retrofit2:retrofit:2.9.0"
@@ -87,16 +85,16 @@ dependencies {
implementation 'com.jakewharton.timber:timber:4.7.1'
// Activity KTX for viewModels()
implementation "androidx.activity:activity-ktx:1.8.1"
implementation "androidx.activity:activity-ktx:1.7.2"
//image
implementation 'com.github.bumptech.glide:glide:4.13.2'
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.2'
//Room
implementation "androidx.room:room-ktx:2.6.1"
implementation "androidx.room:room-runtime:2.6.1"
kapt ("androidx.room:room-compiler:2.6.1")
implementation "androidx.room:room-ktx:2.6.0-alpha03"
implementation "androidx.room:room-runtime:2.6.0-alpha03"
kapt ("androidx.room:room-compiler:2.6.0-alpha03")
// Barcode scanner
implementation 'com.journeyapps:zxing-android-embedded:4.3.0'

113
app/google-services.json Normal file
View File

@@ -0,0 +1,113 @@
{
"project_info": {
"project_number": "650071678820",
"project_id": "hpos-af3cc",
"storage_bucket": "hpos-af3cc.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:650071678820:android:f1435a1c07f710036c6471",
"android_client_info": {
"package_name": "com.example.hposconsentform"
}
},
"oauth_client": [
{
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:650071678820:android:7569c1cad4fc99916c6471",
"android_client_info": {
"package_name": "in.sminnovations.hposregistration"
}
},
"oauth_client": [
{
"client_id": "650071678820-70kp5jvjda4r5diqch2kn4lc40p4f42g.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "in.sminnovations.hposregistration",
"certificate_hash": "7714b9268a81d0cf0fb178b0af8dbb630f8fc70a"
}
},
{
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:650071678820:android:f96be19e5d43102b6c6471",
"android_client_info": {
"package_name": "in.sminnovations.hpostesting"
}
},
"oauth_client": [
{
"client_id": "650071678820-l87dnr0bdj95get0khgnvfv2an1k6ogq.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "in.sminnovations.hpostesting",
"certificate_hash": "7714b9268a81d0cf0fb178b0af8dbb630f8fc70a"
}
},
{
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyAVdNGCev_AFX0qmuZJF6kxzRzXUTeAW5I"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "650071678820-to41afi9f0gi5r3k6v7pe1e5p96nupcs.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}

View File

@@ -1,36 +1,11 @@
package com.example.hposregistration.dao
import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import androidx.room.TypeConverters
import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase
import com.example.hposregistration.data.user.UserData
@Database(entities = [UserData::class], version = 3, exportSchema = false)
@Database(entities = [UserData::class], version = 1, exportSchema = false)
abstract class MyDatabase : RoomDatabase() {
abstract fun userDao(): UserDao
companion object {
val MIGRATION_2_3: Migration = object : Migration(2, 3) {
override fun migrate(database: SupportSQLiteDatabase) {
// Define the necessary SQL statements for migration from version 2 to 3
// For example, you can alter tables or create new ones
database.execSQL("ALTER TABLE user_table ADD COLUMN aadharIdSearch TEXT")
}
}
fun getInstance(context: Context): MyDatabase {
return Room.databaseBuilder(
context.applicationContext,
MyDatabase::class.java,
"my_database"
)
.addMigrations(MIGRATION_2_3)
.build()
}
}
}
}

View File

@@ -7,11 +7,8 @@ import androidx.room.PrimaryKey
data class UserData(
@PrimaryKey
var _id: String = "",
var _idSearch: String = "",
var abhaId: String = "",
var abhaIdSearch: String = "",
var aadharId: String = "",
var aadharIdSearch: String = "",
var name: String = "",
var birthYear: String = "",
var gender: String = "",
@@ -34,10 +31,7 @@ data class UserData(
var registeredBy: String? = "",
var createdAt: String? = "",
var registrationCenterName: String? = "",
var testStatus: Boolean = false,
var userAbhaRegistrationLog:String = "",
var userDetailsLog: String = "",
var appVersion: String = "",
var testStatus: Boolean = false
){
enum class Gender {
MALE,

View File

@@ -27,7 +27,4 @@ class UserDao {
// suspend fun getPatientList(): List<UserData> {
// return patientCollection.get().await().toObjects(UserData::class.java)
// }
}

View File

@@ -2,10 +2,6 @@ package com.example.hposregistration.ui.activities
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import com.google.firebase.appdistribution.FirebaseAppDistribution
import com.google.firebase.appdistribution.FirebaseAppDistributionException
import com.google.firebase.crashlytics.FirebaseCrashlytics
import dagger.hilt.android.AndroidEntryPoint
import `in`.sminnovations.hposregistration.databinding.ActivityMainBinding
@@ -20,44 +16,4 @@ class MainActivity : AppCompatActivity() {
setContentView(binding.root)
}
override fun onResume() {
super.onResume()
val firebaseAppDistribution = FirebaseAppDistribution.getInstance()
firebaseAppDistribution.updateIfNewReleaseAvailable()
.addOnProgressListener { updateProgress ->
if (updateProgress.apkBytesDownloaded > 0) {
Toast.makeText(
this,
"${updateProgress.updateStatus}. ${updateProgress.apkBytesDownloaded / 1048576} /${updateProgress.apkFileTotalBytes / 1048576} MB",
Toast.LENGTH_SHORT
).show()
}
}
.addOnFailureListener { e ->
// (Optional) Handle errors.
if (e is FirebaseAppDistributionException) {
when (e.errorCode) {
FirebaseAppDistributionException.Status.NOT_IMPLEMENTED -> {
// SDK did nothing. This is expected when building for Play.
}
else -> {
// Handle other errors.
Toast.makeText(
this,
"AppDistribution error, status: ${e.errorCode}",
Toast.LENGTH_SHORT
).show()
}
}
FirebaseCrashlytics.getInstance().recordException(e)
}
}
.addOnSuccessListener {
// Toast.makeText(this, "App Update: Success!", Toast.LENGTH_SHORT).show()
}
}
}

View File

@@ -8,6 +8,7 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.Toast
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
@@ -17,14 +18,11 @@ import com.example.hposregistration.data.Constant
import com.example.hposregistration.data.user.UserData
import com.example.hposregistration.ui.viewmodels.RegistrationViewModel
import com.firebase.ui.firestore.FirestoreRecyclerOptions
import com.google.firebase.firestore.Query
import com.google.firebase.firestore.ktx.firestore
import com.google.firebase.ktx.Firebase
import dagger.hilt.android.AndroidEntryPoint
import `in`.sminnovations.hposregistration.R
import `in`.sminnovations.hposregistration.databinding.FragmentUserListBinding
import java.text.SimpleDateFormat
import java.util.Date
@AndroidEntryPoint
class UserListFragment : BaseFragment() {
@@ -58,11 +56,6 @@ class UserListFragment : BaseFragment() {
}
private fun setupViews() {
val pInfo = requireActivity().packageManager.getPackageInfo(
requireActivity().packageName, 0
)
val version = pInfo.versionName
binding.appVersion.text = version
binding.btnRegisterUser.setOnClickListener {
findNavController().navigate(R.id.action_userListFragment_to_registrationFragment)
}
@@ -167,17 +160,7 @@ class UserListFragment : BaseFragment() {
private fun fetchFromServer() {
binding.noList.visibility = View.GONE
binding.rvOrder.visibility = View.VISIBLE
val dateFormat = SimpleDateFormat("yyyy-MM-dd")
val currentDate = Date()
val today = dateFormat.format(currentDate)
val query = Firebase.firestore.collection("patientData")
.whereGreaterThanOrEqualTo("createdAt", today)
.orderBy("createdAt", Query.Direction.DESCENDING)
query.get().addOnSuccessListener {
if (it.documents.isEmpty() && isOnline) {
binding.emptyRegistrations.visibility = View.VISIBLE
}
}
val recyclerViewOptions =
FirestoreRecyclerOptions.Builder<UserData>().setQuery(query, UserData::class.java)
.build()
@@ -193,7 +176,6 @@ class UserListFragment : BaseFragment() {
binding.noList.visibility = View.GONE
binding.rvOrder.visibility = View.VISIBLE
} else {
binding.emptyRegistrations.visibility = View.GONE
if (userDataList.isEmpty()) {
binding.noList.visibility = View.VISIBLE
binding.rvOrder.visibility = View.GONE

View File

@@ -1,15 +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
import android.widget.Toast
import androidx.core.content.edit
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
@@ -34,7 +29,6 @@ class AbhaRegistrationFragment : BaseFragment() {
private val viewModel by viewModels<RegistrationViewModel>()
private val args: AbhaRegistrationFragmentArgs by navArgs()
private var userData = UserData()
private lateinit var sharedPreference:SharedPreferences
private val barcodeLauncher =
registerForActivityResult(ScanContract()) { result: ScanIntentResult ->
@@ -51,11 +45,7 @@ class AbhaRegistrationFragment : BaseFragment() {
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
): View {
_binding = FragmentAbhaRegistrationBinding.inflate(inflater, container, false)
sharedPreference =
requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
return binding.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@@ -63,7 +53,6 @@ class AbhaRegistrationFragment : BaseFragment() {
init()
}
@SuppressLint("LogNotTimber", "CommitPrefEdits")
private fun init() {
binding.btnScanNow.setOnClickListener {
barcodeLauncher.launch(scanQR("Please Scan the Abha ID/Aadhar ID"))
@@ -89,28 +78,17 @@ class AbhaRegistrationFragment : BaseFragment() {
val userName = binding.etName.text.toString()
val aadharIdInput = binding.aadharID.text.toString()
val centerName = binding.centerName.text.toString()
if (validateInputs(abhaIdInput, aadharIdInput, userName, centerName)) {
userData.apply {
name = userName
aadharId = aadharIdInput
abhaId = abhaIdInput
registrationCenterName = 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())
_id = aadharId + userName.substring(0, 3).uppercase() + centerName.substring(0, 3).uppercase()
}
viewModel.insert(userData)
// Make sure this provides a meaningful string representation of userData
viewModel.insert(userData)
navigateToUserDetailsFragment(userData._id)
}
@@ -131,7 +109,6 @@ 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()) {

View File

@@ -4,7 +4,6 @@ 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
@@ -48,15 +47,12 @@ class ReviewDetailsRegistrationFragment : BaseFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
init()
}
private fun init() {
viewModel.getUserByID(args.userId)
viewModel.userData.observe(viewLifecycleOwner) { user ->
userData = user
userData.userAbhaRegistrationLog = sharedPreference.getString("userAbhaRegistrationLog", "").toString()
userData.userDetailsLog = sharedPreference.getString("userDetailslog", "").toString()
setUserData(user)
}
@@ -174,18 +170,6 @@ class ReviewDetailsRegistrationFragment : BaseFragment() {
R.string.sickle_cell_family_history, userData.sickleCellHistory
)
}
val pInfo = requireActivity().packageManager.getPackageInfo(
requireActivity().packageName, 0
)
val version = pInfo.versionName
userData.appVersion = version
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)
}
}

View File

@@ -1,14 +1,11 @@
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.view.isVisible
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
@@ -28,7 +25,6 @@ class UserDetailsRegistrationFragment : Fragment() {
private val viewModel by viewModels<RegistrationViewModel>()
private lateinit var userData: UserData
private lateinit var sharedPreference: SharedPreferences
private val args: UserDetailsRegistrationFragmentArgs by navArgs()
@@ -36,9 +32,6 @@ class UserDetailsRegistrationFragment : Fragment() {
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
): View {
_binding = FragmentUserDetailsRegistrationBinding.inflate(inflater, container, false)
sharedPreference =
requireContext().getSharedPreferences("PREFERENCE_NAME", Context.MODE_PRIVATE)
return binding.root
}
@@ -50,6 +43,25 @@ class UserDetailsRegistrationFragment : Fragment() {
private fun init() {
setupViewModel()
setupSubmitButton()
binding.etCategory.setOnItemClickListener { parent, view, position, id ->
if (parent.getItemAtPosition(position).toString().equals("OTHER", ignoreCase = true)) {
binding.tilOther.visibility = View.VISIBLE
} else {
binding.tilOther.visibility = View.GONE
}
}
binding.etCaste.setOnItemClickListener { parent, view, position, id ->
if (parent.getItemAtPosition(position).toString().equals("OTHER", ignoreCase = true)) {
binding.tilOthercaste.visibility = View.VISIBLE
} else {
binding.tilOthercaste.visibility = View.GONE
}
}
}
private fun setupViewModel() {
@@ -67,20 +79,21 @@ class UserDetailsRegistrationFragment : Fragment() {
when (it) {
"Male" -> {
male.isChecked = true
binding.tilOthergender.visibility = View.GONE
}
"Female" -> {
female.isChecked = true
binding.tilOthergender.visibility = View.GONE
}
else -> {
other.isChecked = true
binding.tilOthergender.visibility = View.VISIBLE
}
}
}
user.phoneNumber.let { etMobile.setText(it) }
user.careOf.let { etCareof.setText(it) }
user.maritalStatus.let { etIsMarried.setText(it, false) }
user.caste.let { etCaste.setText(it, false) }
user.category.let { etCategory.setText(it, false) }
user.subCaste.let { etSubCaste.setText(it) }
user.house.let { etHouse.setText(it) }
user.city.let { etCity.setText(it) }
@@ -102,6 +115,12 @@ class UserDetailsRegistrationFragment : Fragment() {
yes1history.isChecked = true
}
}
user.category.let {
etCategory.setText(it, false)
}
user.caste.let {
etCaste.setText(it, false)
}
if (yes1history.isChecked) {
if (binding.yes1history.isChecked) View.VISIBLE else View.GONE
@@ -119,43 +138,45 @@ class UserDetailsRegistrationFragment : Fragment() {
binding.tilFamilyHistory.visibility =
if (binding.no1history.isChecked) View.GONE else View.VISIBLE
}
if(other.isChecked){
user.gender.let { etOthergender.setText(it) }
}
binding.male.setOnClickListener {
binding.tilOthergender.visibility = View.GONE
}
binding.female.setOnClickListener {
binding.tilOthergender.visibility = View.GONE
}
binding.other.setOnClickListener {
binding.tilOthergender.visibility = View.VISIBLE
}
if (binding.etCategory.text.toString().equals("OTHER", ignoreCase = true)) {
binding.tilOther.visibility = View.VISIBLE
binding.etOther.visibility = View.VISIBLE
} else {
binding.tilOther.visibility = View.GONE
}
if (binding.etCaste.text.toString().equals("OTHER", ignoreCase = true)) {
binding.tilOthercaste.visibility = View.VISIBLE
binding.etOthercaste.visibility = View.VISIBLE
} else {
binding.tilOthercaste.visibility = View.GONE
}
}
}
@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")
@@ -180,11 +201,19 @@ class UserDetailsRegistrationFragment : Fragment() {
}
if (male.isChecked) {
binding.tilOthergender.visibility = View.GONE
userData.gender = "Male"
} else if (female.isChecked) {
binding.tilOthergender.visibility = View.GONE
userData.gender = "Female"
} else {
userData.gender = "Other"
} else if(other.isChecked) {
binding.tilOthergender.visibility = View.VISIBLE
val genderother= binding.etOthergender.text.toString()
userData.gender = genderother
if (genderother.isEmpty()) {
etOthergender.error = "Please fill the field"
return false
}
}
val mobile = etMobile.text.toString()
@@ -212,21 +241,28 @@ class UserDetailsRegistrationFragment : Fragment() {
}
val category = etCategory.text.toString()
val other = etOther.text.toString()
if (category.isEmpty()) {
etCategory.error = "Please enter your category"
return false
} else if (category == "OTHER" && tilOther.isVisible) {
userData.category = other
} else {
userData.category = category
}
val caste = etCaste.text.toString()
val othercaste = etOthercaste.text.toString()
if (caste.isEmpty()) {
etCaste.error = "Please enter your caste"
return false
} else if (caste == "OTHER" && tilOthercaste.isVisible) {
userData.caste = othercaste
} else {
userData.caste = caste
}
val subCaste = etSubCaste.text.toString()
if (subCaste.isNotEmpty()) {
userData.subCaste = subCaste
@@ -292,6 +328,8 @@ class UserDetailsRegistrationFragment : Fragment() {
return true
}
}

View File

@@ -1,9 +1,7 @@
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
@@ -15,10 +13,6 @@ import com.example.hposregistration.data.user.UserData
import com.google.firebase.storage.FirebaseStorage
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Date
import java.util.Locale
import javax.inject.Inject
@HiltViewModel
@@ -32,11 +26,8 @@ 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}")
@@ -71,28 +62,7 @@ class RegistrationViewModel @Inject constructor(
val networkStatusLiveData: LiveData<Boolean>
get() = _networkStatusLiveData
fun insert(userData: UserData) = viewModelScope.launch {
val currentDate = Date()
val dateFormat = SimpleDateFormat("yyyyMMdd")
val partition = dateFormat.format(currentDate)
userData._idSearch = partition + userData._id
userData.abhaIdSearch = partition + userData.abhaId
userData.aadharIdSearch = partition + userData.aadharId
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)
}

View File

@@ -63,7 +63,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:checked="true"
android:text="@string/male"
android:textSize="16sp" />
@@ -83,7 +82,8 @@
</RadioGroup>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_mobile"
android:visibility="gone"
android:id="@+id/til_othergender"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
@@ -93,6 +93,28 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/gender">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_othergender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Other"
android:inputType="text"
android:maxLength="10" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_mobile"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="24dp"
android:layout_marginTop="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/til_othergender">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_mobile"
android:layout_width="match_parent"
@@ -160,12 +182,32 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/category"
android:inputType="none"
android:inputType="text"
android:labelFor="@id/til_is_married"
app:simpleItems="@array/category" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:visibility="gone"
android:id="@+id/til_other"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="24dp"
android:layout_marginTop="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/til_category">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_other"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Other Category"
android:inputType="text"
android:maxLength="10" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_caste"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
@@ -175,19 +217,39 @@
android:layout_marginTop="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/til_category">
app:layout_constraintTop_toBottomOf="@id/til_other">
<AutoCompleteTextView
android:id="@+id/et_Caste"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/caste"
android:inputType="none"
android:inputType="text"
android:labelFor="@id/til_is_married"
app:simpleItems="@array/caste" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:visibility="gone"
android:id="@+id/til_othercaste"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="24dp"
android:layout_marginTop="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/til_caste">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_othercaste"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Other Caste"
android:inputType="text"
android:maxLength="10" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/til_subCaste"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
@@ -197,7 +259,7 @@
android:layout_marginTop="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/til_caste">
app:layout_constraintTop_toBottomOf="@id/til_othercaste">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/et_subCaste"

View File

@@ -16,20 +16,6 @@
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
<TextView
android:id="@+id/app_version"
style="@style/title2"
android:layout_width="57dp"
android:layout_height="15dp"
android:layout_marginTop="4dp"
android:gravity="center"
android:text="1.0.4"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.017"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_title"
style="@style/title1"
@@ -40,20 +26,6 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/emptyRegistrations"
style="@style/title1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/empty_registrations"
android:textColor="@color/black"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/noList"
style="@style/title1"

View File

@@ -55,7 +55,6 @@
<string name="edit">Edit</string>
<string name="user_details">User Details</string>
<string name="internet_is_not_available_and_there_is_no_data_available_in_local_db">Internet is not available and there is no Data available in Local DB</string>
<string name="empty_registrations">No registrations are available for display</string>
<string name="user_id">User ID: %1$s</string>
<string name="abha_number">Abha Number: %1$s</string>
<string name="aadhar_number_details">Aadhar Number: %1$s</string>