Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 91e18f6

Browse files
Initial Commit
0 parents commit 91e18f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1506
-0
lines changed

‎.gitignore‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
/app/build
16+
/google-services.json

‎app/.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/build
2+
*.json

‎app/build.gradle‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: 'com.google.gms.google-services'
3+
4+
android {
5+
compileSdkVersion 29
6+
buildToolsVersion "29.0.2"
7+
defaultConfig {
8+
applicationId "com.bala.firebaselogin"
9+
minSdkVersion 16
10+
targetSdkVersion 29
11+
versionCode 1
12+
versionName "1.0"
13+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
14+
}
15+
buildTypes {
16+
release {
17+
minifyEnabled false
18+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
19+
}
20+
}
21+
}
22+
23+
dependencies {
24+
implementation fileTree(dir: 'libs', include: ['*.jar'])
25+
implementation 'androidx.appcompat:appcompat:1.0.2'
26+
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
27+
implementation 'com.google.firebase:firebase-auth:19.0.0'
28+
testImplementation 'junit:junit:4.12'
29+
androidTestImplementation 'androidx.test:runner:1.2.0'
30+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
31+
}

‎app/proguard-rules.pro‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.bala.firebaselogin;
2+
3+
import android.content.Context;
4+
5+
import androidx.test.platform.app.InstrumentationRegistry;
6+
7+
import androidx.test.runner.AndroidJUnit4;
8+
9+
import org.junit.Test;
10+
import org.junit.runner.RunWith;
11+
12+
import static org.junit.Assert.*;
13+
14+
/**
15+
* Instrumented test, which will execute on an Android device.
16+
*
17+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
18+
*/
19+
20+
public class ExampleInstrumentedTest {
21+
@Test
22+
public void useAppContext() {
23+
// Context of the app under test.
24+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
25+
26+
assertEquals("com.bala.firebaselogin", appContext.getPackageName());
27+
}
28+
}

‎app/src/main/AndroidManifest.xml‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:dist="http://schemas.android.com/apk/distribution"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
package="com.bala.firebaselogin">
6+
7+
<application
8+
android:allowBackup="true"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:supportsRtl="true"
13+
android:fullBackupContent="true"
14+
android:theme="@style/AppTheme"
15+
tools:ignore="GoogleAppIndexingWarning">
16+
<activity android:name=".ForgotPasswordActivity" />
17+
<activity android:name=".SignInActivity" />
18+
<activity android:name=".SignUpActivity" />
19+
<activity android:name=".WelcomeActivity">
20+
<intent-filter>
21+
<action android:name="android.intent.action.MAIN" />
22+
23+
<category android:name="android.intent.category.LAUNCHER" />
24+
</intent-filter>
25+
</activity>
26+
<activity android:name=".MainActivity">
27+
<intent-filter>
28+
<action android:name="android.intent.action.MAIN" />
29+
</intent-filter>
30+
</activity>
31+
</application>
32+
33+
<uses-permission
34+
android:name="android.permission.INTERNET"
35+
tools:ignore="ManifestOrder" />
36+
37+
38+
<dist:module dist:instant="true" />
39+
40+
</manifest>
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package com.bala.firebaselogin;
2+
3+
import androidx.annotation.NonNull;
4+
import androidx.appcompat.app.AlertDialog;
5+
import androidx.appcompat.app.AppCompatActivity;
6+
7+
import android.content.DialogInterface;
8+
import android.content.Intent;
9+
import android.os.Bundle;
10+
import android.util.Log;
11+
import android.view.View;
12+
import android.widget.Button;
13+
import android.widget.EditText;
14+
15+
import com.google.android.gms.tasks.OnCompleteListener;
16+
import com.google.android.gms.tasks.Task;
17+
import com.google.firebase.auth.FirebaseAuth;
18+
19+
public class ForgotPasswordActivity extends AppCompatActivity {
20+
21+
22+
private static final String TAG = "ForgotPasswordActivity";
23+
public FirebaseAuth mAuth;
24+
Button resetPasswordButton;
25+
EditText emailTextInput;
26+
27+
@Override
28+
protected void onCreate(Bundle savedInstanceState) {
29+
super.onCreate(savedInstanceState);
30+
setContentView(R.layout.activity_forgot_password);
31+
32+
33+
emailTextInput = findViewById(R.id.fpEmailTextInput);
34+
resetPasswordButton = findViewById(R.id.resetPasswordButton);
35+
mAuth = FirebaseAuth.getInstance();
36+
37+
38+
resetPasswordButton.setOnClickListener(new View.OnClickListener() {
39+
@Override
40+
public void onClick(View view) {
41+
42+
43+
mAuth.sendPasswordResetEmail(emailTextInput.getText().toString())
44+
.addOnCompleteListener(new OnCompleteListener<Void>() {
45+
@Override
46+
public void onComplete(@NonNull Task<Void> task) {
47+
if (task.isSuccessful()) Log.d(TAG, "Email sent.");
48+
49+
50+
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
51+
ForgotPasswordActivity.this);
52+
53+
// set title
54+
alertDialogBuilder.setTitle("Reset Password");
55+
56+
// set dialog message
57+
alertDialogBuilder
58+
.setMessage("A Reset Password Link Is Sent To Your Registered EmailID")
59+
.setCancelable(false)
60+
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
61+
public void onClick(DialogInterface dialog, int id) {
62+
63+
ForgotPasswordActivity.this.finish();
64+
}
65+
});
66+
67+
AlertDialog alertDialog = alertDialogBuilder.create();
68+
alertDialog.show();
69+
70+
71+
}
72+
});
73+
74+
75+
}
76+
});
77+
78+
79+
}
80+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.bala.firebaselogin;
2+
3+
import androidx.appcompat.app.AppCompatActivity;
4+
5+
import android.os.Bundle;
6+
7+
public class MainActivity extends AppCompatActivity {
8+
9+
@Override
10+
protected void onCreate(Bundle savedInstanceState) {
11+
super.onCreate(savedInstanceState);
12+
setContentView(R.layout.activity_main);
13+
14+
15+
}
16+
}
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
package com.bala.firebaselogin;
2+
3+
import androidx.annotation.NonNull;
4+
import androidx.appcompat.app.AppCompatActivity;
5+
6+
import android.content.Intent;
7+
import android.os.Bundle;
8+
import android.util.Log;
9+
import android.view.View;
10+
import android.widget.Button;
11+
import android.widget.EditText;
12+
import android.widget.TextView;
13+
import android.widget.Toast;
14+
15+
import com.google.android.gms.tasks.OnCompleteListener;
16+
import com.google.android.gms.tasks.Task;
17+
import com.google.firebase.auth.AuthResult;
18+
import com.google.firebase.auth.FirebaseAuth;
19+
import com.google.firebase.auth.FirebaseUser;
20+
21+
public class SignInActivity extends AppCompatActivity {
22+
23+
private static final String TAG = "SignInActivity";
24+
public FirebaseAuth mAuth;
25+
EditText emailTextInput;
26+
EditText passwordTextInput;
27+
Button signInButton;
28+
Button forgotPasswordButton;
29+
Button sendVerifyMailAgainButton;
30+
TextView errorView;
31+
32+
@Override
33+
protected void onCreate(Bundle savedInstanceState) {
34+
super.onCreate(savedInstanceState);
35+
setContentView(R.layout.activity_sign_in);
36+
37+
emailTextInput = findViewById(R.id.signInEmailTextInput);
38+
passwordTextInput = findViewById(R.id.signInPasswordTextInput);
39+
signInButton = findViewById(R.id.signInButton);
40+
forgotPasswordButton = findViewById(R.id.forgotPasswordButton);
41+
sendVerifyMailAgainButton = findViewById(R.id.verifyEmailAgainButton);
42+
errorView = findViewById(R.id.signInErrorView);
43+
44+
sendVerifyMailAgainButton.setVisibility(View.INVISIBLE);
45+
46+
mAuth = FirebaseAuth.getInstance();
47+
48+
signInButton.setOnClickListener(new View.OnClickListener() {
49+
@Override
50+
public void onClick(View view) {
51+
52+
if (emailTextInput.getText().toString().contentEquals("")) {
53+
54+
55+
errorView.setText("Email cant be empty");
56+
57+
58+
} else if (passwordTextInput.getText().toString().contentEquals("")) {
59+
60+
errorView.setText("Password cant be empty");
61+
62+
} else {
63+
64+
65+
mAuth.signInWithEmailAndPassword(emailTextInput.getText().toString(), passwordTextInput.getText().toString())
66+
.addOnCompleteListener(SignInActivity.this, new OnCompleteListener<AuthResult>() {
67+
@Override
68+
public void onComplete(@NonNull Task<AuthResult> task) {
69+
if (task.isSuccessful()) {
70+
// Sign in success, update UI with the signed-in user's information
71+
Log.d(TAG, "signInWithEmail:success");
72+
73+
FirebaseUser user = mAuth.getCurrentUser();
74+
75+
if (user != null) {
76+
if (user.isEmailVerified()) {
77+
78+
System.out.println("Email Verified : " + user.isEmailVerified());
79+
Intent HomeActivity = new Intent(SignInActivity.this, MainActivity.class);
80+
setResult(RESULT_OK, null);
81+
startActivity(HomeActivity);
82+
SignInActivity.this.finish();
83+
84+
85+
} else {
86+
87+
sendVerifyMailAgainButton.setVisibility(View.VISIBLE);
88+
errorView.setText("Please Verify your EmailID and SignIn");
89+
90+
}
91+
}
92+
93+
} else {
94+
// If sign in fails, display a message to the user.
95+
Log.w(TAG, "signInWithEmail:failure", task.getException());
96+
Toast.makeText(SignInActivity.this, "Authentication failed.",
97+
Toast.LENGTH_SHORT).show();
98+
if (task.getException() != null) {
99+
errorView.setText(task.getException().getMessage());
100+
}
101+
102+
}
103+
104+
}
105+
});
106+
107+
108+
}
109+
110+
111+
}
112+
});
113+
114+
115+
forgotPasswordButton.setOnClickListener(new View.OnClickListener() {
116+
@Override
117+
public void onClick(View view) {
118+
119+
Intent forgotPasswordActivity = new Intent(SignInActivity.this, ForgotPasswordActivity.class);
120+
startActivity(forgotPasswordActivity);
121+
SignInActivity.this.finish();
122+
123+
}
124+
});
125+
126+
127+
}
128+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /