diff --git a/app/src/main/java/com/hazard/samarpan/ngo/NgoSignup1Fragment.kt b/app/src/main/java/com/hazard/samarpan/ngo/NgoSignup1Fragment.kt index ce77efb..6d9affe 100644 --- a/app/src/main/java/com/hazard/samarpan/ngo/NgoSignup1Fragment.kt +++ b/app/src/main/java/com/hazard/samarpan/ngo/NgoSignup1Fragment.kt @@ -52,7 +52,7 @@ class NgoSignup1Fragment : Fragment() { val orgPhone = phone?.text.toString().trim() val officeAdd = add?.text.toString().trim() val orgPinCode = pinCode?.text.toString().trim() - val pass = password?.text.toString().trim() + val orgPass = password?.text.toString().trim() val confirmPass=confirmPassword?.text.toString().trim() @@ -76,7 +76,7 @@ class NgoSignup1Fragment : Fragment() { name?.error = "Name cannot be empty" markButtonDisable(nextBtn) } - if (pass.isEmpty()){ + if (orgPass.isEmpty()){ password?.error = "Password cannot be empty" markButtonDisable(nextBtn) } @@ -84,15 +84,15 @@ class NgoSignup1Fragment : Fragment() { mail?.error = "Invalid email" markButtonDisable(nextBtn) } - if (!(isValidPassword(pass))) { + if (!(isValidPassword(orgPass))) { password?.error = "Password format is invalid" markButtonDisable(nextBtn) } - if(pass != confirmPass){ + if(orgPass != confirmPass){ confirmPassword?.error = "Passwords doesn't match" markButtonDisable(nextBtn) }else{ - communicator.passDataCom(orgName,orgMail,orgPhone,officeAdd,orgPinCode,pass) + communicator.passDataCom(orgName,orgMail,orgPhone,officeAdd,orgPinCode,orgPass) activity?.supportFragmentManager?.beginTransaction() ?.replace( R.id.fragment_container1, diff --git a/app/src/main/java/com/hazard/samarpan/ngo/NgoSignup2Fragment.kt b/app/src/main/java/com/hazard/samarpan/ngo/NgoSignup2Fragment.kt index d3e0092..1dff27a 100644 --- a/app/src/main/java/com/hazard/samarpan/ngo/NgoSignup2Fragment.kt +++ b/app/src/main/java/com/hazard/samarpan/ngo/NgoSignup2Fragment.kt @@ -8,6 +8,8 @@ import android.view.View import android.view.ViewGroup import android.widget.* import androidx.fragment.app.Fragment +import com.google.android.material.textfield.TextInputEditText +import com.google.android.material.textfield.TextInputLayout import com.google.firebase.auth.FirebaseAuth import com.google.firebase.auth.FirebaseUser import com.google.firebase.auth.ktx.auth @@ -20,14 +22,18 @@ class NgoSignup2Fragment : Fragment(){ private var v : View?=null private var btnNgoRegister: Button?=null - private var tvSample :TextView?=null + private var tilCategoryOthers:TextInputLayout?=null + private var etCategoryOthers:TextInputEditText?=null + private var orgName:String ="" private var orgMail:String ="" private var orgPhone:String ="" private var officeAdd:String ="" private var orgPin:String ="" - private var pass:String ="" + private var orgPass:String ="" + private var category:String="" + private lateinit var registerAuth: FirebaseAuth @@ -39,31 +45,39 @@ class NgoSignup2Fragment : Fragment(){ v = layoutInflater.inflate(R.layout.ngo_signup2_fragment,container,false) btnNgoRegister=v?.findViewById(R.id.btnNgoRegister) - tvSample=v?.findViewById(R.id.tv_Sample) + tilCategoryOthers=v?.findViewById(R.id.til_category_others) + etCategoryOthers=v?.findViewById(R.id.et_category_others) val organisationTypes = resources.getStringArray(R.array.organisation_type) val arrayAdapter = ArrayAdapter(requireContext(),R.layout.dropdown_item,organisationTypes) val autoCompleteTV= v?.findViewById(R.id.ngosignup_select_orgtype_items) autoCompleteTV?.setAdapter(arrayAdapter) - + category=autoCompleteTV?.text.toString().trim() registerAuth= Firebase.auth - orgName=arguments?.getString("Name").toString() - orgMail= arguments?.getString("Mail").toString() - orgPhone=arguments?.getString("Phone").toString() - officeAdd=arguments?.getString("Address").toString() - orgPin=arguments?.getString("PinCode").toString() - pass=arguments?.getString("Password").toString() + orgName=arguments?.getString("Name").toString().trim() + orgMail= arguments?.getString("Mail").toString().trim() + orgPhone=arguments?.getString("Phone").toString().trim() + officeAdd=arguments?.getString("Address").toString().trim() + orgPin=arguments?.getString("PinCode").toString().trim() + orgPass=arguments?.getString("Password").toString().trim() btnNgoRegister?.setOnClickListener { + if(category == "Others"){ + //get the category from the user of the type he is from other than the list + btnNgoRegister?.isEnabled=false + tilCategoryOthers?.visibility=View.VISIBLE + category=etCategoryOthers?.text.toString() + btnNgoRegister?.isEnabled=true + } val db = FirebaseFirestore.getInstance() try{ - registerAuth.createUserWithEmailAndPassword(orgMail,pass) + registerAuth.createUserWithEmailAndPassword(orgMail,orgPass) .addOnCompleteListener{ task-> if(task.isSuccessful){ - val ngo: FirebaseUser? =registerAuth.currentUser + val ngo: FirebaseUser? =registerAuth.currentUser Toast.makeText( activity, "Thank You! for choosing us", @@ -73,12 +87,12 @@ class NgoSignup2Fragment : Fragment(){ ngo?.uid ?: "" ) val ngoInfo :MutableMap = HashMap() - ngoInfo["OrgName"]= orgName - ngoInfo["OrgMail"]= orgMail - ngoInfo["OrgPhone"]=orgPhone - ngoInfo["OfficeAdd"]=officeAdd - ngoInfo["OrgPinCode"]=orgPin - ngoInfo["isDonor"]=0 + ngoInfo["Full Name"]= orgName + ngoInfo["Email"]= orgMail + ngoInfo["PhoneNumber"]=orgPhone + ngoInfo["Address"]=officeAdd + ngoInfo["Pin Code"]=orgPin + ngoInfo["isDonor"]="0" // add the value of the org type from the dropdown and upload document work documentReference.set(ngoInfo).addOnSuccessListener { Log.d(ContentValues.TAG, "User data for $orgName was collected successfully ") diff --git a/app/src/main/java/com/hazard/samarpan/user/UserDashboardFragment.kt b/app/src/main/java/com/hazard/samarpan/user/UserDashboardFragment.kt index e88b3b5..1b536bd 100644 --- a/app/src/main/java/com/hazard/samarpan/user/UserDashboardFragment.kt +++ b/app/src/main/java/com/hazard/samarpan/user/UserDashboardFragment.kt @@ -1,20 +1,27 @@ package com.hazard.samarpan.user +import android.content.Intent import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.ImageButton import androidx.fragment.app.Fragment import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.google.android.material.floatingactionbutton.FloatingActionButton +import com.google.firebase.auth.ktx.auth +import com.google.firebase.ktx.Firebase import com.hazard.samarpan.adapters.ClothAdapter import com.hazard.samarpan.R +import com.hazard.samarpan.common.MainActivity + class UserDashboardFragment : Fragment() { private lateinit var clothRecycler: RecyclerView private var donate: FloatingActionButton?= null + private var btnLogout : ImageButton?=null override fun onCreateView( inflater: LayoutInflater, @@ -26,7 +33,9 @@ class UserDashboardFragment : Fragment() { donate = v.findViewById(R.id.btnDonate) - var clothList: ArrayList = ArrayList() + btnLogout=v.findViewById(R.id.profile_button) + + val clothList: ArrayList = ArrayList() for (i in 1..15) { clothList.add(R.drawable.ic_uploadimage) } @@ -35,6 +44,12 @@ class UserDashboardFragment : Fragment() { LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL, false) clothRecycler.adapter = ClothAdapter(clothList) + btnLogout?.setOnClickListener{ + Firebase.auth.signOut() + val intent= Intent(context, MainActivity::class.java) + startActivity(intent) + activity?.finish() + } donate?.setOnClickListener { val donationInfo= DonationInfoFragment() diff --git a/app/src/main/java/com/hazard/samarpan/user/UserRegisterFragment.kt b/app/src/main/java/com/hazard/samarpan/user/UserRegisterFragment.kt index e0d15a9..4a84120 100644 --- a/app/src/main/java/com/hazard/samarpan/user/UserRegisterFragment.kt +++ b/app/src/main/java/com/hazard/samarpan/user/UserRegisterFragment.kt @@ -128,7 +128,7 @@ class UserRegisterFragment : Fragment() { donorInfo["Address"] = donorAddress donorInfo["Pin Code"] = donorPinCode //specify if the user is donor - donorInfo["isDonor"] = 1 // in case of NGO give this value 0 + donorInfo["isDonor"] = "1" // in case of NGO give this value 0 documentReference.set(donorInfo).addOnSuccessListener { Log.d(TAG, "User data for $donorName was collected successfully ") diff --git a/app/src/main/res/layout/ngo_signup2_fragment.xml b/app/src/main/res/layout/ngo_signup2_fragment.xml index c2e38b0..00e63a9 100644 --- a/app/src/main/res/layout/ngo_signup2_fragment.xml +++ b/app/src/main/res/layout/ngo_signup2_fragment.xml @@ -41,6 +41,24 @@ + + + + + -