1. Registration page (Add username ,contact number and profile pic) (Done)
2. For unsuccessful registration throw an alert message . (Done) 3. Incorrect password exception to be handled. (Done) 4. Password length should be min 8 and should have special characters. (Done) 5. Firebase saving done . (Done)
This commit is contained in:
parent
5134d78789
commit
76840c4993
17
.idea/deploymentTargetDropDown.xml
generated
17
.idea/deploymentTargetDropDown.xml
generated
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<runningDeviceTargetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="RUNNING_DEVICE_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="SERIAL_NUMBER" />
|
||||
<value value="RW9DYX45K7I7OZ7H" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</runningDeviceTargetSelectedWithDropDown>
|
||||
<timeTargetWasSelectedWithDropDown value="2023-03-11T13:10:44.558803800Z" />
|
||||
</component>
|
||||
</project>
|
@ -40,6 +40,7 @@ dependencies {
|
||||
implementation 'com.google.android.material:material:1.8.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'com.google.firebase:firebase-auth-ktx:21.0.3'
|
||||
implementation 'com.google.firebase:firebase-database-ktx:20.1.0'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||
|
@ -2,6 +2,8 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
|
@ -16,6 +16,8 @@ class DBHelper(context: Context, factory: SQLiteDatabase.CursorFactory?) :
|
||||
val query = ("CREATE TABLE " + TABLE_NAME + " ("
|
||||
+ ID_COL + " INTEGER PRIMARY KEY, " +
|
||||
EMAIL_COl + " TEXT," +
|
||||
USERNAME_COl + " TEXT," +
|
||||
PHONE_COl + " TEXT," +
|
||||
PASSWORD_COL + " TEXT," +
|
||||
CONPASSWORD_COL + " TEXT" + ")")
|
||||
|
||||
@ -31,7 +33,7 @@ class DBHelper(context: Context, factory: SQLiteDatabase.CursorFactory?) :
|
||||
}
|
||||
|
||||
// This method is for adding data in our database
|
||||
fun addUser(email : String, password : String, conpassword : String ){
|
||||
fun addUser(email : String,username :String,phone :String, password : String, conpassword : String ){
|
||||
|
||||
// below we are creating
|
||||
// a content values variable
|
||||
@ -40,6 +42,8 @@ class DBHelper(context: Context, factory: SQLiteDatabase.CursorFactory?) :
|
||||
// we are inserting our values
|
||||
// in the form of key-value pair
|
||||
values.put(EMAIL_COl, email)
|
||||
values.put(USERNAME_COl, username)
|
||||
values.put(PHONE_COl, phone)
|
||||
values.put(PASSWORD_COL, password)
|
||||
values.put(CONPASSWORD_COL, conpassword)
|
||||
|
||||
@ -90,6 +94,11 @@ class DBHelper(context: Context, factory: SQLiteDatabase.CursorFactory?) :
|
||||
// below is the variable for email column
|
||||
val EMAIL_COl = "email"
|
||||
|
||||
val USERNAME_COl = "username"
|
||||
|
||||
val PHONE_COl = "phone"
|
||||
|
||||
|
||||
// below is the variable for password column
|
||||
val PASSWORD_COL = "password"
|
||||
|
||||
|
@ -1,27 +1,41 @@
|
||||
package com.example.attendance
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.provider.MediaStore
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import android.widget.ImageView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import com.google.android.material.textfield.TextInputEditText
|
||||
import com.google.firebase.auth.FirebaseAuth
|
||||
import com.google.firebase.auth.ktx.auth
|
||||
import com.google.firebase.database.DatabaseReference
|
||||
import com.google.firebase.database.FirebaseDatabase
|
||||
import com.google.firebase.ktx.Firebase
|
||||
|
||||
class RegisterActivity : AppCompatActivity() {
|
||||
private lateinit var edt_email: TextInputEditText
|
||||
private lateinit var edt_pass: TextInputEditText
|
||||
private lateinit var edt_usrname: TextInputEditText
|
||||
private lateinit var edt_phone: TextInputEditText
|
||||
private lateinit var edt_conPass: TextInputEditText
|
||||
private lateinit var btn_register: Button
|
||||
private lateinit var profile_image: ImageView
|
||||
|
||||
lateinit var email: String
|
||||
lateinit var usrname: String
|
||||
lateinit var phone: String
|
||||
lateinit var pass: String
|
||||
lateinit var conpass: String
|
||||
|
||||
// For firebase implementation
|
||||
private lateinit var auth: FirebaseAuth
|
||||
private lateinit var database: DatabaseReference
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -29,8 +43,11 @@ class RegisterActivity : AppCompatActivity() {
|
||||
|
||||
edt_email = findViewById(R.id.edt_email)
|
||||
edt_pass = findViewById(R.id.edt_pass)
|
||||
edt_usrname = findViewById(R.id.edt_usrname)
|
||||
edt_phone = findViewById(R.id.edt_phone)
|
||||
edt_conPass = findViewById(R.id.edt_conPass)
|
||||
btn_register = findViewById(R.id.btn_register)
|
||||
profile_image = findViewById(R.id.profile_image)
|
||||
|
||||
auth = FirebaseAuth.getInstance()
|
||||
|
||||
@ -39,17 +56,50 @@ class RegisterActivity : AppCompatActivity() {
|
||||
email = edt_email.text.toString()
|
||||
pass = edt_pass.text.toString()
|
||||
conpass = edt_conPass.text.toString()
|
||||
usrname = edt_usrname.text.toString()
|
||||
phone = edt_phone.text.toString()
|
||||
|
||||
signUpUser()
|
||||
|
||||
db.addUser(email, pass, conpass)
|
||||
|
||||
|
||||
database = FirebaseDatabase.getInstance().getReference("UserInfo")
|
||||
val userInfo = UserInfo(email,usrname,phone, pass)
|
||||
database.child(usrname).setValue(userInfo).addOnSuccessListener {
|
||||
edt_email.text?.clear()
|
||||
edt_usrname.text?.clear()
|
||||
edt_phone.text?.clear()
|
||||
edt_pass.text?.clear()
|
||||
edt_conPass.text?.clear()
|
||||
}.addOnFailureListener{
|
||||
Toast.makeText(this, "Failed", Toast.LENGTH_LONG).show()
|
||||
}
|
||||
db.addUser(email,usrname,phone,pass,conpass)
|
||||
Toast.makeText(this, email + " added to database", Toast.LENGTH_LONG).show()
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
profile_image.setOnClickListener(View.OnClickListener { v: View? ->
|
||||
// Create the camera_intent ACTION_IMAGE_CAPTURE it will open the camera for capture the image
|
||||
val cameraIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
|
||||
// Start the activity with camera_intent, and request pic id
|
||||
startActivityForResult(cameraIntent, pic_id)
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
// Match the request 'pic id with requestCode
|
||||
if (requestCode == pic_id) {
|
||||
// BitMap is data structure of image file which store the image in memory
|
||||
val photo = data!!.extras!!["data"] as Bitmap?
|
||||
// Set the image in imageview for display
|
||||
profile_image.setImageBitmap(photo)
|
||||
}
|
||||
}
|
||||
companion object {
|
||||
// Define the pic id
|
||||
private const val pic_id = 123
|
||||
}
|
||||
|
||||
private fun signUpUser() {
|
||||
@ -67,6 +117,16 @@ class RegisterActivity : AppCompatActivity() {
|
||||
.show()
|
||||
return
|
||||
}
|
||||
if(pass.length<8){
|
||||
Toast.makeText(this, "Password should atleast have 8 characters", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
return
|
||||
}
|
||||
if(!pass.contains("#") || !pass.contains("&") || !pass.contains("@")){
|
||||
Toast.makeText(this, "Password should special characters", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// If all credential are correct
|
||||
@ -76,9 +136,10 @@ class RegisterActivity : AppCompatActivity() {
|
||||
auth.createUserWithEmailAndPassword(email, pass).addOnCompleteListener(this) {
|
||||
if (it.isSuccessful) {
|
||||
moveToLogin()
|
||||
Toast.makeText(this, "Successfully signed Up", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(this, "Successfully signed Up", Toast.LENGTH_SHORT).show()
|
||||
finish()
|
||||
} else {
|
||||
showAlert()
|
||||
Toast.makeText(this, it.exception.toString(), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
System.out.println("error: " + it.exception.toString())
|
||||
@ -90,4 +151,23 @@ class RegisterActivity : AppCompatActivity() {
|
||||
val intent = Intent(this, LoginActivity::class.java)
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
private fun showAlert(){
|
||||
val builder = AlertDialog.Builder(this)
|
||||
//set title for alert dialog
|
||||
builder.setTitle("Warning")
|
||||
//set message for alert dialog
|
||||
builder.setMessage("Unsuccessfull attempt")
|
||||
builder.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
|
||||
//performing positive action
|
||||
builder.setPositiveButton("Try again"){dialogInterface, which ->
|
||||
|
||||
}
|
||||
// Create the AlertDialog
|
||||
val alertDialog: AlertDialog = builder.create()
|
||||
// Set other dialog properties
|
||||
alertDialog.setCancelable(false)
|
||||
alertDialog.show()
|
||||
}
|
||||
}
|
5
app/src/main/java/com/example/attendance/UserInfo.kt
Normal file
5
app/src/main/java/com/example/attendance/UserInfo.kt
Normal file
@ -0,0 +1,5 @@
|
||||
package com.example.attendance
|
||||
|
||||
data class UserInfo(val email : String? = null,val userName : String? = null,val phone : String? = null,val password : String? = null){
|
||||
|
||||
}
|
@ -10,17 +10,7 @@
|
||||
android:padding="10dp"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
android:text="Sentient Geeks!!"
|
||||
android:textColor="@color/white"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginBottom="20dp"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
@ -31,6 +21,26 @@
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
<de.hdodenhof.circleimageview.CircleImageView
|
||||
android:id="@+id/profile_image"
|
||||
app:civ_border_width="4dp"
|
||||
android:layout_centerInParent="true"
|
||||
android:src="@drawable/login"
|
||||
app:civ_border_color="#FF000000"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="70dp"
|
||||
android:layout_gravity="center_horizontal"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Click here for profile pic"
|
||||
android:textSize="10sp"
|
||||
android:textColor="@color/white"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_gravity="center_horizontal" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@ -44,7 +54,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:hint="Username/Email"
|
||||
android:hint="Email"
|
||||
app:endIconMode="clear_text"
|
||||
app:endIconTint="@color/black">
|
||||
|
||||
@ -59,15 +69,47 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:hint="Enter password"
|
||||
app:endIconMode="password_toggle"
|
||||
android:hint="Username"
|
||||
app:endIconMode="clear_text"
|
||||
app:endIconTint="@color/black">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/edt_pass"
|
||||
android:id="@+id/edt_usrname"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:hint="Phone"
|
||||
app:endIconMode="clear_text"
|
||||
app:endIconTint="@color/black">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/edt_phone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="number"/>
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:hint="Enter password"
|
||||
app:endIconMode="password_toggle"
|
||||
app:endIconTint="@color/white">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/edt_pass"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textPassword"/>
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
|
||||
@ -76,12 +118,13 @@
|
||||
android:layout_marginBottom="12dp"
|
||||
android:hint="Confirm password"
|
||||
app:endIconMode="password_toggle"
|
||||
app:endIconTint="@color/black">
|
||||
app:endIconTint="@color/white">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/edt_conPass"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textPassword"/>
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
@ -115,27 +158,41 @@
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginBottom="40dp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_finger"
|
||||
android:layout_width="match_parent"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Use finger pattern"
|
||||
android:background="@drawable/login_button_bg"
|
||||
android:textColor="@color/white"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"/>
|
||||
android:orientation="horizontal"
|
||||
android:layout_weight="1.0">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_finger"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Use finger pattern"
|
||||
android:background="@drawable/login_button_bg"
|
||||
android:textColor="@color/white"
|
||||
android:textStyle="bold"
|
||||
android:layout_weight="0.5"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_face"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Use face recognition"
|
||||
android:background="@drawable/login_button_bg"
|
||||
android:textColor="@color/white"
|
||||
android:textStyle="bold"
|
||||
android:layout_weight="0.5"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_face"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Use face recognition"
|
||||
android:background="@drawable/login_button_bg"
|
||||
android:textColor="@color/white"
|
||||
android:textStyle="bold"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"/>
|
||||
|
||||
</LinearLayout>
|
Loading…
x
Reference in New Issue
Block a user