Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video Calling App #955

Merged
merged 1 commit into from
Oct 17, 2021
Merged
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
62 changes: 62 additions & 0 deletions LoginActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.example.connect;

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

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
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;

public class LoginActivity extends AppCompatActivity {
FirebaseAuth auth;
TextView email , password;
Button login, signup;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);

auth=FirebaseAuth.getInstance();

email = findViewById(R.id.email);
password = findViewById(R.id.password);
login = findViewById(R.id.button);
signup = findViewById(R.id.button2);

login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String Email,Password;
Email = email.getText().toString();
Password = password.getText().toString();

auth.signInWithEmailAndPassword(Email,Password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if(task.isSuccessful()){
Toast.makeText(LoginActivity.this, "logged in", Toast.LENGTH_SHORT).show();
}
else{
Toast.makeText(LoginActivity.this,task.getException().getLocalizedMessage(), Toast.LENGTH_SHORT).show();
}
}
});
}
});

signup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(LoginActivity.this , SignupActivity.class));
}
});
}
}
24 changes: 24 additions & 0 deletions MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.connect;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

public class MainActivity extends AppCompatActivity {

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

new Handler().postDelayed(new Runnable() {
@Override
public void run() {
startActivity(new Intent(MainActivity.this, LoginActivity.class));
}

}, 2000);
}
}
75 changes: 75 additions & 0 deletions SignupActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.example.connect;

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

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.FirebaseApp;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.firestore.FirebaseFirestore;

public class SignupActivity extends AppCompatActivity {
FirebaseAuth auth;

TextView email , password , name;
Button login, signup;
FirebaseFirestore database;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signup);
database = FirebaseFirestore.getInstance();
auth = FirebaseAuth.getInstance();

email = findViewById(R.id.email);
password = findViewById(R.id.password);
login = findViewById(R.id.button);
signup = findViewById(R.id.button2);
name = findViewById(R.id.Name);

signup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String Email,Password,Name;
Email = email.getText().toString();
Password = password.getText().toString();
Name = name.getText().toString();

User user = new User();

user.setEmail(Email);
user.setName(Name);
user.setPassword(Password);

auth.createUserWithEmailAndPassword(Email,Password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if(task.isSuccessful()){
database.collection("Users").document().set(user).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
startActivity(new Intent(SignupActivity.this,LoginActivity.class));
}
});
Toast.makeText(SignupActivity.this, "Account is Created", Toast.LENGTH_SHORT).show();
}
else{
Toast.makeText(SignupActivity.this,task.getException().getLocalizedMessage(), Toast.LENGTH_SHORT).show();
}
}
});
}
});
}
}
32 changes: 32 additions & 0 deletions User.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.example.connect;

public class User {
private String Email,Password,Name;

public User(){

}
public String getEmail() {
return Email;
}

public void setEmail(String email) {
Email = email;
}

public String getPassword() {
return Password;
}

public void setPassword(String password) {
Password = password;
}

public String getName() {
return Name;
}

public void setName(String name) {
Name = name;
}
}