Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.firebase:firebase-auth:17.0.0'
implementation 'com.google.firebase:firebase-auth:19.1.0'
implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
Expand Down
20 changes: 10 additions & 10 deletions app/google-services.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
{
"project_info": {
"project_number": "441201864216",
"firebase_url": "https://invenapp-f8264.firebaseio.com",
"project_id": "invenapp-f8264",
"storage_bucket": "invenapp-f8264.appspot.com"
"project_number": "457897063191",
"firebase_url": "https://inventory-f3c06.firebaseio.com",
"project_id": "inventory-f3c06",
"storage_bucket": "inventory-f3c06.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:441201864216:android:b76b311dc543976733dd6d",
"mobilesdk_app_id": "1:457897063191:android:91e121ab61b37fdf9c3d52",
"android_client_info": {
"package_name": "com.example.tablayout"
}
},
"oauth_client": [
{
"client_id": "441201864216-k672vcv14riolc2vl622etkce613tdqp.apps.googleusercontent.com",
"client_id": "457897063191-alejo8f0psmm8r3f4l55fr7hfmd8ibd5.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.example.tablayout",
"certificate_hash": "6d0edd4fb84cd8516074053e7f73361a13385a81"
"certificate_hash": "bdf6c94e9b3565c0417d70d717426a46effdab03"
}
},
{
"client_id": "441201864216-ttgujha0qg7u1tm35qqhd96cl3du0jnr.apps.googleusercontent.com",
"client_id": "457897063191-fhd3j1gl3me9o2fkj47o9hqu5imsmvel.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyCeZws5AxIAyuvR2oVoQ82usRbz4zC8RJ4"
"current_key": "AIzaSyDb5lp3Z_VaGjo5BBXjrAsLk8DP4j-oni8"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "441201864216-ttgujha0qg7u1tm35qqhd96cl3du0jnr.apps.googleusercontent.com",
"client_id": "457897063191-fhd3j1gl3me9o2fkj47o9hqu5imsmvel.apps.googleusercontent.com",
"client_type": 3
}
]
Expand Down
99 changes: 91 additions & 8 deletions app/src/main/java/com/example/tablayout/Login.java
Original file line number Diff line number Diff line change
@@ -1,39 +1,122 @@
package com.example.tablayout;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

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;


public class Login extends AppCompatActivity {

private FirebaseAuth mAuth;

private EditText EmailField;
private EditText PasswordField;

Button b,r;
Context context;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);

b=findViewById(R.id.logbtn);
r=findViewById(R.id.regbtn);
mAuth = FirebaseAuth.getInstance();
onStart();
EmailField = findViewById(R.id.email);
PasswordField = findViewById(R.id.pass);
b = findViewById(R.id.logbtn);
r = findViewById(R.id.regbtn);
r.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(getApplicationContext() ,Register.class);
Intent i = new Intent(getApplicationContext(), Register.class);
startActivity(i);
}
});

b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(getApplicationContext() ,MainActivity.class);
startActivity(i);
signIn(EmailField.getText().toString(), PasswordField.getText().toString());

}
});
}
}

@Override
public void onStart() {
super.onStart();
// Check if user is signed in (non-null) and update UI accordingly.
FirebaseUser currentUser = mAuth.getCurrentUser();
if(currentUser!=null) {
Intent i = new Intent(getApplicationContext(), MainActivity.class);
startActivity(i);
}
}

private void signIn(String email, String password) {
if (!validateForm()) {
return;
}


// [START sign_in_with_email]
mAuth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
Intent i = new Intent(getApplicationContext(), MainActivity.class);
startActivity(i);
} else {
// If sign in fails, display a message to the user.

Toast.makeText(Login.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();


}

// [START_EXCLUDE]

}
});
// [END sign_in_with_email]
}
private boolean validateForm() {
boolean valid = true;

String email = EmailField.getText().toString();
if (TextUtils.isEmpty(email)) {
EmailField.setError("Required.");
valid = false;
} else {
EmailField.setError(null);
}

String password = PasswordField.getText().toString();
if (TextUtils.isEmpty(password)) {
PasswordField.setError("Required.");
valid = false;
} else {
PasswordField.setError(null);
}

return valid;
}
}

Loading