-
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
Samuelford24
authored and
Samuelford24
committed
Jan 28, 2021
0 parents
commit 5499e3a
Showing
63 changed files
with
2,254 additions
and
0 deletions.
There are no files selected for viewing
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,15 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/caches | ||
/.idea/libraries | ||
/.idea/modules.xml | ||
/.idea/workspace.xml | ||
/.idea/navEditor.xml | ||
/.idea/assetWizardSettings.xml | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.cxx | ||
local.properties |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
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,46 @@ | ||
plugins { | ||
id 'com.android.application' | ||
} | ||
|
||
android { | ||
compileSdkVersion 30 | ||
buildToolsVersion "29.0.3" | ||
|
||
defaultConfig { | ||
applicationId "com.sf.stormwaterutilityandroid" | ||
minSdkVersion 26 | ||
targetSdkVersion 30 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'androidx.appcompat:appcompat:1.2.0' | ||
implementation 'com.google.android.material:material:1.2.1' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.0.1' | ||
implementation 'androidx.navigation:navigation-fragment:2.3.0' | ||
implementation 'androidx.navigation:navigation-ui:2.3.0' | ||
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' | ||
implementation 'me.riddhimanadib.form-master:form-master:1.1.0' | ||
implementation 'androidx.annotation:annotation:1.1.0' | ||
implementation 'com.google.firebase:firebase-auth:19.4.0' | ||
implementation 'com.google.firebase:firebase-firestore:21.6.0' | ||
testImplementation 'junit:junit:4.+' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.2' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' | ||
} |
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,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
26 changes: 26 additions & 0 deletions
26
app/src/androidTest/java/com/sf/stormwaterutilityandroid/ExampleInstrumentedTest.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,26 @@ | ||
package com.sf.stormwaterutilityandroid; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
assertEquals("com.sf.stormwaterutilityandroid", appContext.getPackageName()); | ||
} | ||
} |
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,27 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.sf.stormwaterutilityandroid"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.StormWaterUtilityAndroid"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:label="@string/app_name"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
<activity android:name=".Reset_password"/> | ||
<activity android:name=".SampleFordm"/> | ||
<activity android:name=".Login"/> | ||
<activity android:name=".SignUp"/> | ||
</application> | ||
|
||
</manifest> |
148 changes: 148 additions & 0 deletions
148
app/src/main/java/com/sf/stormwaterutilityandroid/Login.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,148 @@ | ||
package com.sf.stormwaterutilityandroid; | ||
|
||
import android.content.DialogInterface; | ||
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.ProgressBar; | ||
import android.widget.Toast; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.appcompat.app.AlertDialog; | ||
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; | ||
|
||
public class Login extends AppCompatActivity { | ||
|
||
private EditText inputEmail, inputPassword; | ||
private FirebaseAuth auth; | ||
FirebaseAuth.AuthStateListener mAuthListener; | ||
|
||
private ProgressBar progressBar; | ||
private Button btnSignup, btnLogin, btnReset; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_login); | ||
//Get Firebase auth instance | ||
|
||
auth = FirebaseAuth.getInstance(); | ||
mAuthListener = new FirebaseAuth.AuthStateListener() { | ||
@Override | ||
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { | ||
if (firebaseAuth.getCurrentUser() != null && auth.getCurrentUser().isEmailVerified()) { | ||
startActivity(new Intent(Login.this, MainActivity.class)); | ||
finish(); | ||
} | ||
if (firebaseAuth.getCurrentUser() == null) { | ||
|
||
} | ||
|
||
|
||
} | ||
}; | ||
|
||
|
||
setContentView(R.layout.activity_login); | ||
inputEmail = findViewById(R.id.email); | ||
inputPassword = findViewById(R.id.password); | ||
progressBar = findViewById(R.id.progressBar); | ||
btnSignup = findViewById(R.id.btn_signup); | ||
btnLogin = findViewById(R.id.btn_login); | ||
btnReset = findViewById(R.id.btn_reset_password); | ||
|
||
//Get Firebase auth instance | ||
auth = FirebaseAuth.getInstance(); | ||
|
||
btnSignup.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
startActivity(new Intent(Login.this, SignUp.class)); | ||
} | ||
}); | ||
|
||
btnReset.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
startActivity(new Intent(Login.this, Reset_password.class)); | ||
} | ||
}); | ||
|
||
btnLogin.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
String email = inputEmail.getText().toString(); | ||
final String password = inputPassword.getText().toString(); | ||
|
||
if (TextUtils.isEmpty(email)) { | ||
Toast.makeText(getApplicationContext(), "Enter email address!", Toast.LENGTH_SHORT).show(); | ||
return; | ||
} | ||
|
||
if (TextUtils.isEmpty(password)) { | ||
Toast.makeText(getApplicationContext(), "Enter password!", Toast.LENGTH_SHORT).show(); | ||
return; | ||
} | ||
|
||
progressBar.setVisibility(View.VISIBLE); | ||
|
||
//authenticate user | ||
auth.signInWithEmailAndPassword(email, password) | ||
.addOnCompleteListener(Login.this, new OnCompleteListener<AuthResult>() { | ||
@Override | ||
public void onComplete(@NonNull Task<AuthResult> task) { | ||
// If sign in fails, display a message to the user. If sign in succeeds | ||
// the auth state listener will be notified and logic to handle the | ||
// signed in user can be handled in the listener. | ||
progressBar.setVisibility(View.GONE); | ||
if (!task.isSuccessful()) { | ||
// there was an error | ||
if (password.length() < 6) { | ||
inputPassword.setError("Your password must be at least 6 characters"); | ||
} else { | ||
Toast.makeText(Login.this, "Error, couldn't login. Please try again", Toast.LENGTH_LONG).show(); | ||
} | ||
} else { | ||
if (auth.getCurrentUser().isEmailVerified()) { | ||
Intent intent = new Intent(Login.this, MainActivity.class); | ||
startActivity(intent); | ||
progressBar.setVisibility(View.INVISIBLE); | ||
finish(); | ||
} else { | ||
AlertDialog.Builder builder; | ||
builder = new AlertDialog.Builder(Login.this); | ||
//builder.setIcon(R.drawable.open_browser); | ||
builder.setTitle("Verify Email"); | ||
builder.setMessage("You need to verify your email before logging in! Would you like to resend the verification email?"); | ||
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() { | ||
public void onClick(DialogInterface dialog, int id) { | ||
auth.getCurrentUser().sendEmailVerification(); | ||
} | ||
}); | ||
builder.setNegativeButton("No", new DialogInterface.OnClickListener() { | ||
public void onClick(DialogInterface dialog, int id) { | ||
dialog.dismiss(); | ||
} | ||
}); | ||
builder.setCancelable(true); | ||
builder.show(); | ||
|
||
|
||
} | ||
} | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.