This repository has been archived by the owner on Mar 16, 2021. It is now read-only.
-
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.
Adding support for user sing in/up with Email & Password, with Fireba…
…seUI
- Loading branch information
Showing
20 changed files
with
1,353 additions
and
16 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
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,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" | ||
} |
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
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,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(); | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -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); | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.