forked from Kartikey15dem/QR_Code_scanner
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
738a921
commit e79a281
Showing
26 changed files
with
510 additions
and
56 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.example.camerax; | ||
|
||
import android.os.Bundle; | ||
|
||
import androidx.activity.EdgeToEdge; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.core.graphics.Insets; | ||
import androidx.core.view.ViewCompat; | ||
import androidx.core.view.WindowInsetsCompat; | ||
|
||
public class AdminActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
setContentView(R.layout.activity_admin); | ||
|
||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
app/src/main/java/com/example/camerax/GateKeeperActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.example.camerax; | ||
|
||
import android.os.Bundle; | ||
|
||
import androidx.activity.EdgeToEdge; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
import androidx.core.graphics.Insets; | ||
import androidx.core.view.ViewCompat; | ||
import androidx.core.view.WindowInsetsCompat; | ||
|
||
public class GateKeeperActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
EdgeToEdge.enable(this); | ||
setContentView(R.layout.activity_gate_keeper); | ||
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> { | ||
Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()); | ||
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom); | ||
return insets; | ||
}); | ||
} | ||
} |
120 changes: 120 additions & 0 deletions
120
app/src/main/java/com/example/camerax/LoginActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
package com.example.camerax; | ||
|
||
import static android.content.ContentValues.TAG; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.Toast; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import com.google.android.gms.tasks.OnCompleteListener; | ||
import com.google.android.gms.tasks.Task; | ||
import com.google.firebase.auth.AuthResult; | ||
import com.google.firebase.auth.FirebaseAuth; | ||
import com.google.firebase.auth.FirebaseUser; | ||
|
||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
public class LoginActivity extends AppCompatActivity { | ||
|
||
private EditText emailEditText, passwordEditText; | ||
private Button loginButton; | ||
private FirebaseAuth mAuth; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_login); | ||
|
||
|
||
mAuth = FirebaseAuth.getInstance(); | ||
|
||
|
||
emailEditText = findViewById(R.id.userName_edit_text); | ||
passwordEditText = findViewById(R.id.password_edit_text); | ||
loginButton = findViewById(R.id.button); | ||
|
||
loginButton.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
loginUser(); | ||
} | ||
}); | ||
} | ||
|
||
private void loginUser() { | ||
String email = emailEditText.getText().toString().trim(); | ||
String password = passwordEditText.getText().toString().trim(); | ||
|
||
if (email.isEmpty() || password.isEmpty()) { | ||
Toast.makeText(LoginActivity.this, "Please fill all fields", Toast.LENGTH_SHORT).show(); | ||
return; | ||
} | ||
|
||
|
||
mAuth.signInWithEmailAndPassword(email, password) | ||
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() { | ||
@Override | ||
public void onComplete(@NonNull Task<AuthResult> task) { | ||
if (task.isSuccessful()) { | ||
|
||
FirebaseUser user = mAuth.getCurrentUser(); | ||
|
||
|
||
String rollno = user.getEmail().substring(0, 8); | ||
|
||
// Check student login format | ||
String checkStudent = "^\\d{2}[A-Za-z]{2}\\d{4}$"; | ||
Pattern patternStudent = Pattern.compile(checkStudent); | ||
Matcher matcherStudent = patternStudent.matcher(rollno); | ||
|
||
// Check guard login format | ||
String checkGuard = "^[A-Za-z]{3}\\d{4}[A-Za-z]{1}$"; | ||
Pattern patternGuard = Pattern.compile(checkGuard); | ||
Matcher matcherGuard = patternGuard.matcher(rollno); | ||
|
||
// check for admin format | ||
String checkAdmin="^[A-Za-z]{5}\\d{2}[a-z]{1}$"; | ||
Pattern patternAdmin=Pattern.compile(checkAdmin); | ||
Matcher matcherAdmin=patternAdmin.matcher(rollno); | ||
|
||
|
||
if (matcherStudent.matches()) { | ||
Toast.makeText(LoginActivity.this, "Student login", Toast.LENGTH_SHORT).show(); | ||
Intent studentIntent = new Intent(LoginActivity.this, MainActivity.class); | ||
startActivity(studentIntent); | ||
finish(); | ||
} | ||
|
||
else if (matcherGuard.matches()) { | ||
Toast.makeText(LoginActivity.this, "Admin login", Toast.LENGTH_SHORT).show(); | ||
Intent adminIntent = new Intent(LoginActivity.this, GateKeeperActivity.class); | ||
startActivity(adminIntent); | ||
finish(); | ||
} | ||
|
||
else if(matcherAdmin.matches()) { | ||
|
||
Toast.makeText(LoginActivity.this, "Admin login", Toast.LENGTH_SHORT).show(); | ||
Intent adminIntent = new Intent(LoginActivity.this, AdminActivity.class); | ||
startActivity(adminIntent); | ||
finish(); | ||
} | ||
} | ||
|
||
else { | ||
Log.w(TAG, "signInWithEmail:failure", task.getException()); | ||
Toast.makeText(LoginActivity.this, "Authentication failed.", | ||
Toast.LENGTH_SHORT).show(); | ||
} | ||
} | ||
}); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<corners android:radius="8dp"/> | ||
<stroke android:color="@color/blue" | ||
android:width="2dp"/> | ||
|
||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="44dp" | ||
android:height="44dp" | ||
android:viewportWidth="44" | ||
android:viewportHeight="44"> | ||
<path | ||
android:pathData="M2,37C2,34.348 3.054,31.804 4.929,29.929C6.804,28.054 9.348,27 12,27H32C34.652,27 37.196,28.054 39.071,29.929C40.946,31.804 42,34.348 42,37C42,38.326 41.473,39.598 40.535,40.535C39.598,41.473 38.326,42 37,42H7C5.674,42 4.402,41.473 3.464,40.535C2.527,39.598 2,38.326 2,37Z" | ||
android:strokeLineJoin="round" | ||
android:strokeWidth="2.5" | ||
android:fillColor="#00000000" | ||
android:strokeColor="#699BF7"/> | ||
<path | ||
android:pathData="M22,17C26.142,17 29.5,13.642 29.5,9.5C29.5,5.358 26.142,2 22,2C17.858,2 14.5,5.358 14.5,9.5C14.5,13.642 17.858,17 22,17Z" | ||
android:strokeWidth="2.5" | ||
android:fillColor="#00000000" | ||
android:strokeColor="#699BF7"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="40dp" | ||
android:height="24dp" | ||
android:viewportWidth="40" | ||
android:viewportHeight="24"> | ||
<path | ||
android:pathData="M1.818,20H38.182V24H1.818V20ZM3.909,11.9L5.455,8.94L7,11.9L9.364,10.4L7.818,7.44H10.909V4.44H7.818L9.364,1.5L7,0L5.455,2.94L3.909,0L1.545,1.5L3.091,4.44H0V7.44H3.091L1.545,10.4L3.909,11.9ZM16.091,10.4L18.455,11.9L20,8.94L21.545,11.9L23.909,10.4L22.364,7.44H25.455V4.44H22.364L23.909,1.5L21.545,0L20,2.94L18.455,0L16.091,1.5L17.636,4.44H14.545V7.44H17.636L16.091,10.4ZM40,4.44H36.909L38.454,1.5L36.091,0L34.546,2.94L33,0L30.636,1.5L32.182,4.44H29.091V7.44H32.182L30.636,10.4L33,11.9L34.546,8.94L36.091,11.9L38.454,10.4L36.909,7.44H40V4.44Z" | ||
android:fillColor="#699BF7"/> | ||
</vector> |
Binary file added
BIN
+70.3 KB
app/src/main/res/drawable/rajiv_gandhi_institute_of_petroleum_technology_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/main" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".AdminActivity"> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/main" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".GateKeeperActivity"> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
Oops, something went wrong.