Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

Commit

Permalink
Adding support for user sing in/up with Email & Password, with Fireba…
Browse files Browse the repository at this point in the history
…seUI
  • Loading branch information
migbash committed Feb 25, 2020
1 parent 6f4bba9 commit e37ed6c
Show file tree
Hide file tree
Showing 20 changed files with 1,353 additions and 16 deletions.
21 changes: 20 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.example.mad_cw"
minSdkVersion 28
targetSdkVersion 29
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -23,6 +24,24 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

// Firebase for Google Analytics:
implementation 'com.google.firebase:firebase-analytics:17.2.2'

// Firebase Authentication:
implementation 'com.google.firebase:firebase-auth:19.2.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'

// Firebase Dynamic Links:
implementation 'com.google.firebase:firebase-dynamic-links:19.1.0'

// Glide Dependency (Image Handling):
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'

// Firebase Storage:
implementation 'com.google.firebase:firebase-storage:19.1.1'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
Expand Down
77 changes: 77 additions & 0 deletions app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"project_info": {
"project_number": "825859146304",
"firebase_url": "https://practical-android.firebaseio.com",
"project_id": "practical-android",
"storage_bucket": "practical-android.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:825859146304:android:7c67dac5123f089eb6d5a5",
"android_client_info": {
"package_name": "com.example.firebase_con"
}
},
"oauth_client": [
{
"client_id": "825859146304-v1qs3nlardt1i6o3kqf54i2k85sdv71g.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyAJSknN_NCrv8gZJUsxwOj9FiKIoz9-wXk"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "825859146304-v1qs3nlardt1i6o3kqf54i2k85sdv71g.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:825859146304:android:9be0832efb4e3c57b6d5a5",
"android_client_info": {
"package_name": "com.example.mad_cw"
}
},
"oauth_client": [
{
"client_id": "825859146304-85ruq4kj1vecoj38hb5fjgiga3ldak25.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.example.mad_cw",
"certificate_hash": "dd4b00285896b9ecfb467a2c48fe905a58eece5b"
}
},
{
"client_id": "825859146304-v1qs3nlardt1i6o3kqf54i2k85sdv71g.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyAJSknN_NCrv8gZJUsxwOj9FiKIoz9-wXk"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "825859146304-v1qs3nlardt1i6o3kqf54i2k85sdv71g.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}
25 changes: 23 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,41 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mad_cw">

<!-- Enable Permissions In-App -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>


<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/AppTheme">
<activity android:name=".MainActivity">
<activity android:name=".User_Sign_In">

<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

<!-- Handling User DeepLinks -->

<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="madcw.page.link" android:scheme="http"/>
<data android:host="madcw.page.link" android:scheme="https"/>
</intent-filter>

</activity>

<!-- <activity android:name=".User_Sign_In" /> -->
<activity android:name=".User_Sign_Up"/>
<activity android:name=".User_Profile"/>

</application>

</manifest>
47 changes: 47 additions & 0 deletions app/src/main/java/com/example/mad_cw/BaseActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.example.mad_cw;

import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.ProgressBar;

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

public class BaseActivity extends AppCompatActivity {

@VisibleForTesting
public ProgressBar mProgressBar;

public void setProgressBar(int resId) {
mProgressBar = findViewById(resId);
}

public void showProgressBar() {
if (mProgressBar != null) {
mProgressBar.setVisibility(View.VISIBLE);
}
}

public void hideProgressBar() {

if (mProgressBar != null) {
mProgressBar.setVisibility(View.INVISIBLE);
}

}

public void hideKeyboard(View view) {
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
}

@Override
public void onStop() {
super.onStop();
hideProgressBar();
}

}
113 changes: 108 additions & 5 deletions app/src/main/java/com/example/mad_cw/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,125 @@
package com.example.mad_cw;

import androidx.appcompat.app.AppCompatActivity;
// Other Imports
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

// Firebase Imports
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
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;
import com.google.firebase.auth.UserProfileChangeRequest;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.UploadTask;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

/**
* Main Activity Class
* _________
* Usage: Currently handles the user login onto the app and records them in Firebase App
* We will be using a password-less login here for the user authentication using the
* users email address.
*
* _________
* @author migbash
* @date 22/02/2020
*
*/

public class MainActivity extends AppCompatActivity {
public class MainActivity extends BaseActivity {

private static final String TAG = "MainActivity";

private FirebaseAuth mAuth;

public static final int PICK_IMAGE = 1;

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

// Sign-Up Layout
setContentView(R.layout.activity_main);

// On load show the Main App Welcome Screen / Loading Screen
// Views

// Buttons

// Initialize Firebase Auth
mAuth = FirebaseAuth.getInstance();
}

@Override
public void onStart() {
super.onStart();
// Check if user is signed in (non-null) and update UI accordingly.
FirebaseUser currentUser = mAuth.getCurrentUser();
// updateUI(currentUser);
}

// private void sendEmailVerification() {
// // Disable button
// findViewById(R.id.verifyEmailButton).setEnabled(false);
//
// // Send verification email
// // [START send_email_verification]
// final FirebaseUser user = mAuth.getCurrentUser();
// user.sendEmailVerification()
// .addOnCompleteListener(this, new OnCompleteListener<Void>() {
// @Override
// public void onComplete(@NonNull Task<Void> task) {
// // [START_EXCLUDE]
// // Re-enable button
// findViewById(R.id.verifyEmailButton).setEnabled(true);
//
// if (task.isSuccessful()) {
// Toast.makeText(MainActivity.this,
// "Verification email sent to " + user.getEmail(),
// Toast.LENGTH_SHORT).show();
// } else {
// Log.e(TAG, "sendEmailVerification", task.getException());
// Toast.makeText(MainActivity.this,
// "Failed to send verification email.",
// Toast.LENGTH_SHORT).show();
// }
// // [END_EXCLUDE]
// }
// });
// // [END send_email_verification]
// }

public void pickManyImage() {
Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT);
getIntent.setType("image/*");

Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
pickIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
pickIntent.setType("image/*");

Intent chooserIntent = Intent.createChooser(getIntent, "Select Image");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] {pickIntent});

startActivityForResult(chooserIntent, PICK_IMAGE);
}

}
}
Loading

0 comments on commit e37ed6c

Please sign in to comment.