diff --git a/.idea/codestream.xml b/.idea/codestream.xml new file mode 100644 index 0000000..a4e0c03 --- /dev/null +++ b/.idea/codestream.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b66ec6b..9801de3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -11,8 +11,7 @@ android:theme="@style/Theme.Samarpan"> - + android:exported="false" /> + + diff --git a/app/src/main/ic_launcher-playstore.png b/app/src/main/ic_launcher-playstore.png new file mode 100644 index 0000000..b8480e2 Binary files /dev/null and b/app/src/main/ic_launcher-playstore.png differ 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 1b536bd..abac635 100644 --- a/app/src/main/java/com/hazard/samarpan/user/UserDashboardFragment.kt +++ b/app/src/main/java/com/hazard/samarpan/user/UserDashboardFragment.kt @@ -45,10 +45,8 @@ class UserDashboardFragment : Fragment() { clothRecycler.adapter = ClothAdapter(clothList) btnLogout?.setOnClickListener{ - Firebase.auth.signOut() - val intent= Intent(context, MainActivity::class.java) + val intent = Intent(context,UserProfileActivity::class.java) startActivity(intent) - activity?.finish() } donate?.setOnClickListener { diff --git a/app/src/main/java/com/hazard/samarpan/user/UserProfileActivity.kt b/app/src/main/java/com/hazard/samarpan/user/UserProfileActivity.kt new file mode 100644 index 0000000..76d8fdf --- /dev/null +++ b/app/src/main/java/com/hazard/samarpan/user/UserProfileActivity.kt @@ -0,0 +1,74 @@ +package com.hazard.samarpan.user + +import android.content.Intent +import android.os.Bundle +import android.util.Log +import android.widget.Button +import android.widget.TextView +import android.widget.Toast +import androidx.appcompat.app.AppCompatActivity +import com.google.firebase.auth.FirebaseAuth +import com.google.firebase.auth.FirebaseUser +import com.google.firebase.firestore.ktx.firestore +import com.google.firebase.ktx.Firebase +import com.hazard.samarpan.R +import com.hazard.samarpan.common.MainActivity + +class UserProfileActivity : AppCompatActivity() { + private lateinit var registerAuth: FirebaseAuth + private var TAG : String = "UserProfileActivity" + private var userName: TextView? = null + private var userPhone: TextView? = null + private var userAddress: TextView? = null + private var userEmail: TextView? = null + private var userPin: TextView? = null + private var logOutBtn: Button? = null + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_user_profile) + registerAuth = FirebaseAuth.getInstance() + userName = findViewById(R.id.user_profile_name) + userPhone = findViewById(R.id.user_profile_phone) + userAddress = findViewById(R.id.user_profile_address) + userEmail = findViewById(R.id.user_profile_emailid) + userPin = findViewById(R.id.user_profile_pin) + logOutBtn = findViewById(R.id.userLogout) + logOutBtn?.setOnClickListener{ + registerAuth.signOut() + Toast.makeText(this,"Logged out successfully!",Toast.LENGTH_SHORT).show() + val intent = Intent(this,MainActivity::class.java) + startActivity(intent) + finish() + } + } + + override fun onResume() { + (super.onResume()) + readUserData() + } + + private fun readUserData() + { + val dbInstance = Firebase.firestore + val user: FirebaseUser? = registerAuth.currentUser + val docRef = dbInstance.collection("users").document( + user?.uid ?: "" + ) + docRef.get() + .addOnSuccessListener { document -> + if (document != null) { + userName?.text = document.data?.get("Full Name").toString() + userPhone?.text = document.data?.get("PhoneNumber").toString() + userAddress?.text = document.data?.get("Address").toString() + userPin?.text = document.data?.get("Pin Code").toString() + userEmail?.text = document.data?.get("Email").toString() + } else { + Log.d(TAG, "No such document") + } + } + .addOnFailureListener { exception -> + Log.d(TAG, "get failed with ", exception) + } + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml index 07d5da9..ca3826a 100644 --- a/app/src/main/res/drawable/ic_launcher_background.xml +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -1,170 +1,74 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + xmlns:android="http://schemas.android.com/apk/res/android"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_baseline_account_circle_24.xml b/app/src/main/res/drawable/profile_ico.xml similarity index 100% rename from app/src/main/res/drawable/ic_baseline_account_circle_24.xml rename to app/src/main/res/drawable/profile_ico.xml diff --git a/app/src/main/res/layout/activity_user_profile.xml b/app/src/main/res/layout/activity_user_profile.xml new file mode 100644 index 0000000..185edcd --- /dev/null +++ b/app/src/main/res/layout/activity_user_profile.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + +