Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/src/main/AndroidManifest.xml
  • Loading branch information
janhaviiii committed Sep 27, 2021
2 parents c5a5b95 + ddbc53e commit 8a81252
Show file tree
Hide file tree
Showing 12 changed files with 228 additions and 55 deletions.
26 changes: 6 additions & 20 deletions .idea/misc.xml

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

1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ dependencies {
implementation platform('com.google.firebase:firebase-bom:28.4.1')
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.android.gms:play-services-auth:19.2.0'
implementation 'com.jaeger.statusbarutil:library:1.4.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
Expand Down
23 changes: 12 additions & 11 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.effe_21ca">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

<application
android:allowBackup="true"
Expand All @@ -10,12 +9,6 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Effe21CA">
<activity
android:name=".App_issues"
android:exported="true" />
<activity
android:name=".upload"
android:exported="true" />
<activity
android:name=".SignInActivity"
android:exported="true">
Expand All @@ -24,16 +17,23 @@

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</activity>
<activity
android:name=".SignUpActivity"
android:exported="true" />
android:exported="true">


</activity>

<activity
android:name=".NotificationActivity"
android:exported="true" />
<activity
android:name=".Bottom_Navigation_Activity"
android:exported="true" />
android:exported="true">

</activity>
<activity
android:name=".About_Us"
android:exported="true" />
Expand All @@ -51,8 +51,9 @@
android:exported="true" />
<activity
android:name=".login"
android:exported="true" />
android:exported="true">

</activity>
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
Expand Down
102 changes: 102 additions & 0 deletions app/src/main/java/com/example/effe_21ca/SignUpActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,38 @@
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import com.example.effe_21ca.databinding.ActivitySignUpBinding;
import com.example.effe_21ca.models.Users;
import com.google.android.gms.auth.api.signin.GoogleSignIn;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.auth.api.signin.GoogleSignInClient;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import com.google.android.gms.common.api.ApiException;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthCredential;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.auth.GoogleAuthProvider;
import com.google.firebase.database.FirebaseDatabase;

public class SignUpActivity extends AppCompatActivity {

ActivitySignUpBinding binding;
GoogleSignInClient mGoogleSignInClient;
private FirebaseAuth Auth;
FirebaseDatabase database;
ProgressDialog progressDialog;
FirebaseAuth firebaseAuth;
private FirebaseAuth.AuthStateListener authStateListener;

private static final int RC_SIGN_IN = 234;
private static final String TAG = "example";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -32,9 +47,31 @@ protected void onCreate(Bundle savedInstanceState) {

Auth = FirebaseAuth.getInstance();
database=FirebaseDatabase.getInstance();
firebaseAuth = FirebaseAuth.getInstance();
progressDialog=new ProgressDialog(SignUpActivity.this);
progressDialog.setTitle("Creating Account");
progressDialog.setMessage("We are creating your account");
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken("358743908709-bm0lkn9hjv1ueogqk2ggpjlj5ribgua9.apps.googleusercontent.com")
.requestEmail()
.build();

mGoogleSignInClient = GoogleSignIn.getClient(this, gso);

findViewById(R.id.sign_in_button).setOnClickListener(view -> {
signIn();
});
authStateListener = firebaseAuth -> {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
Toast.makeText(SignUpActivity.this, "User logged in ", Toast.LENGTH_SHORT).show();
Intent I = new Intent(SignUpActivity.this, Bottom_Navigation_Activity.class);
startActivity(I);
}


};

binding.btnSignUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand All @@ -61,6 +98,8 @@ public void onComplete(@NonNull Task<AuthResult> task) {
});
}
});


binding.tvSignUpToLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand All @@ -70,4 +109,67 @@ public void onClick(View view) {
});

}


@Override
protected void onStart() {
super.onStart();
if (firebaseAuth.getCurrentUser() != null) {
finish();
startActivity(new Intent(this, Bottom_Navigation_Activity.class));
}
firebaseAuth.addAuthStateListener(authStateListener);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);


if (requestCode == RC_SIGN_IN) {


Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
try {

GoogleSignInAccount account = task.getResult(ApiException.class);


assert account != null;
firebaseAuthWithGoogle(account);
} catch (ApiException e) {
Toast.makeText(SignUpActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
}
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId());


AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);


firebaseAuth.signInWithCredential(credential)
.addOnCompleteListener(this, task -> {
if (task.isSuccessful()) {
Log.d(TAG, "signInWithCredential:success");
FirebaseUser user = firebaseAuth.getCurrentUser();

Toast.makeText(SignUpActivity.this, "User Signed In", Toast.LENGTH_SHORT).show();
} else {

Log.w(TAG, "signInWithCredential:failure", task.getException());
Toast.makeText(SignUpActivity.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();

}

});
}
private void signIn() {
Intent signInIntent = mGoogleSignInClient.getSignInIntent();
startActivityForResult(signInIntent, RC_SIGN_IN);
}



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.example.effe_21ca;

import androidx.appcompat.app.AppCompatActivity;

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

import com.jaeger.library.StatusBarUtil;

public class Splash_Screen_Activity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.activity_splash_screen);


StatusBarUtil.setTransparent(this);
Handler handler = new Handler();
Runnable runnable = () -> {
Intent intent = new Intent(Splash_Screen_Activity.this, SignUpActivity.class);
startActivity(intent);
};
handler.postDelayed(runnable, 500);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
import androidx.lifecycle.ViewModelProvider;

import com.example.effe_21ca.databinding.FragmentNotificationsBinding;
import com.google.firebase.database.FirebaseDatabase;

public class NotificationsFragment extends Fragment {
//FirebaseDatabase database;

private NotificationsViewModel notificationsViewModel;
private FragmentNotificationsBinding binding;
Expand All @@ -21,6 +23,9 @@ public View onCreateView(@NonNull LayoutInflater inflater,
notificationsViewModel =
new ViewModelProvider(this).get(NotificationsViewModel.class);

// database = FirebaseDatabase.getInstance();\
// String name = getIntent().getStringExtra("name");

binding = FragmentNotificationsBinding.inflate(inflater, container, false);
View root = binding.getRoot();

Expand Down
Binary file added app/src/main/res/drawable-v24/logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@


<com.google.android.gms.common.SignInButton
android:id="@+id/sign_in_button"
android:id="@+id/sign_in_button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/button2"
Expand Down
27 changes: 16 additions & 11 deletions app/src/main/res/layout/activity_sign_in.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,27 +114,32 @@



<TextView
<com.google.android.gms.common.SignInButton
android:id="@+id/GoogleLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_width="136dp"
android:layout_height="64dp"

android:layout_margin="50dp"

android:layout_marginStart="50dp"
android:layout_marginLeft="50dp"


android:layout_marginTop="50dp"
android:layout_marginEnd="60dp"
android:layout_marginRight="60dp"
android:layout_marginBottom="50dp"
android:layout_weight="1"
android:background="@drawable/googlegr"
android:drawableLeft="@drawable/google"
android:gravity="center"
android:padding="10dp"
android:text="Google"
android:textColor="#FAF6F6"
android:layout_marginLeft="5dp" />
android:padding="10dp" />
</LinearLayout>

<TextView
android:id="@+id/tvLoginToSignUp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Want to creat new account" />
android:text="Want to create new account" />

</LinearLayout>

Expand Down
26 changes: 15 additions & 11 deletions app/src/main/res/layout/activity_sign_up.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,24 @@
android:orientation="horizontal">


<com.google.android.gms.common.SignInButton
android:id="@+id/sign_in_button"
android:layout_width="136dp"
android:layout_height="64dp"

<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_margin="50dp"

android:layout_marginStart="50dp"
android:layout_marginLeft="50dp"


android:layout_marginTop="50dp"
android:layout_marginEnd="60dp"
android:layout_marginRight="60dp"
android:layout_marginBottom="50dp"
android:layout_weight="1"
android:background="@drawable/googlegr"
android:drawableLeft="@drawable/google"
android:gravity="center"
android:padding="10dp"
android:text="Google"
android:textColor="#FAF6F6"
android:layout_marginLeft="5dp" />
android:padding="10dp" />
</LinearLayout>

<TextView
Expand Down
Loading

0 comments on commit 8a81252

Please sign in to comment.