diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml deleted file mode 100644 index abd4805..0000000 --- a/.idea/deploymentTargetDropDown.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index e7cb5a9..04700b8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4e94c9a..bd7a072 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,6 +2,8 @@ + + + // 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) + }) - Toast.makeText(this, email + " added to database", Toast.LENGTH_LONG).show() + } + 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() + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/attendance/UserInfo.kt b/app/src/main/java/com/example/attendance/UserInfo.kt new file mode 100644 index 0000000..256074d --- /dev/null +++ b/app/src/main/java/com/example/attendance/UserInfo.kt @@ -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){ + +} diff --git a/app/src/main/res/layout/activity_register.xml b/app/src/main/res/layout/activity_register.xml index 4af4e37..a979066 100644 --- a/app/src/main/res/layout/activity_register.xml +++ b/app/src/main/res/layout/activity_register.xml @@ -10,17 +10,7 @@ android:padding="10dp" > - + + + + @@ -53,6 +63,37 @@ android:layout_width="match_parent" android:layout_height="wrap_content" /> + + + + + + + + + + + app:endIconTint="@color/white"> + android:layout_height="wrap_content" + android:inputType="textPassword"/> + app:endIconTint="@color/white"> + android:layout_height="wrap_content" + android:inputType="textPassword"/> @@ -115,27 +158,41 @@ android:layout_gravity="center_horizontal" android:layout_marginBottom="40dp"/> -