// Path: app/src/main/java/com/tryouts/courierapplication/items/User.java
// public class User {
// 
//     private String mEmail;
//     private String mUid;
//     private String mName;
//     private String mPhone;
//     private String mRole;
//     private String mInstanceId;
// 
//     public User() {
//     }
// 
//     public User(String email) {
//         this.mEmail = email;
//     }
// 
//     public User(String email, String role) {
//         this.mEmail = email;
//         this.mRole = role;
//     }
// 
//     public String getEmail() {
//         return mEmail;
//     }
// 
//      public String getRole() {
//        return mRole;
//      }
// 
//     public void setEmail(String email) {
//         mEmail = email;
//     }
// 
//       public void setRole(String role) {
//           mRole = role;
//       }
// 
//     public String getName() {
//         return mName;
//     }
// 
//     public void setName(String name) {
//         mName = name;
//     }
// 
//     public String getPhone() {
//         return mPhone;
//     }
// 
//     public void setPhone(String phone) {
//         mPhone = phone;
//     }
// 
//     public String getUid() {
//         return mUid;
//     }
// 
//     public void setUid(String uid) {
//         mUid = uid;
//     }
// 
//     public String getInstanceId() {
//         return mInstanceId;
//     }
// 
//     public void setInstanceId(String instanceId) {
//         mInstanceId = instanceId;
//     }
// }


import android.app.ProgressDialog;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
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.TextView;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseAuthInvalidCredentialsException;
import com.google.firebase.auth.FirebaseAuthUserCollisionException;
import com.google.firebase.auth.FirebaseAuthWeakPasswordException;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.tryouts.courierapplication.items.User;
            Toast.makeText(this,getString(R.string.login_hint_email), Toast.LENGTH_LONG).show();
            return;
        }
        if(TextUtils.isEmpty(mPass)){
            Toast.makeText(this,getString(R.string.login_hint_password),Toast.LENGTH_LONG).show();
            return;
        }
        if(TextUtils.isEmpty(mPhone) || mPhone.length()<9){
            Toast.makeText(this,getString(R.string.hint_phone),Toast.LENGTH_SHORT).show();
            return;
        }
        if(TextUtils.isEmpty(mName)){
            Toast.makeText(this,getString(R.string.hint_name),Toast.LENGTH_SHORT).show();
            return;
        }
        // If the email and password are not empty
        // display progress dialog
        mProgressDialog.setMessage(getString(R.string.login_progressbar_register));
        mProgressDialog.show();
        // Create a new User
        mAuth.createUserWithEmailAndPassword(mEmail, mPass)
                .addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        if(task.isSuccessful()) {
                            final DatabaseReference mDatabaseReference = FirebaseDatabase.getInstance().getReference();
                            mDatabaseReference.child("users").child(mAuth.getCurrentUser().getUid())
                                    .addListenerForSingleValueEvent(new ValueEventListener() {
                                        @Override
                                        public void onDataChange(DataSnapshot dataSnapshot) {
// Path: app/src/main/java/com/tryouts/courierapplication/items/User.java
// public class User {
// 
//     private String mEmail;
//     private String mUid;
//     private String mName;
//     private String mPhone;
//     private String mRole;
//     private String mInstanceId;
// 
//     public User() {
//     }
// 
//     public User(String email) {
//         this.mEmail = email;
//     }
// 
//     public User(String email, String role) {
//         this.mEmail = email;
//         this.mRole = role;
//     }
// 
//     public String getEmail() {
//         return mEmail;
//     }
// 
//      public String getRole() {
//        return mRole;
//      }
// 
//     public void setEmail(String email) {
//         mEmail = email;
//     }
// 
//       public void setRole(String role) {
//           mRole = role;
//       }
// 
//     public String getName() {
//         return mName;
//     }
// 
//     public void setName(String name) {
//         mName = name;
//     }
// 
//     public String getPhone() {
//         return mPhone;
//     }
// 
//     public void setPhone(String phone) {
//         mPhone = phone;
//     }
// 
//     public String getUid() {
//         return mUid;
//     }
// 
//     public void setUid(String uid) {
//         mUid = uid;
//     }
// 
//     public String getInstanceId() {
//         return mInstanceId;
//     }
// 
//     public void setInstanceId(String instanceId) {
//         mInstanceId = instanceId;
//     }
// }


// Path: app/src/main/java/com/tryouts/courierapplication/RegisterActivity.java
import android.app.ProgressDialog;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
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.TextView;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseAuthInvalidCredentialsException;
import com.google.firebase.auth.FirebaseAuthUserCollisionException;
import com.google.firebase.auth.FirebaseAuthWeakPasswordException;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.tryouts.courierapplication.items.User;

            Toast.makeText(this,getString(R.string.login_hint_email), Toast.LENGTH_LONG).show();
            return;
        }
        if(TextUtils.isEmpty(mPass)){
            Toast.makeText(this,getString(R.string.login_hint_password),Toast.LENGTH_LONG).show();
            return;
        }
        if(TextUtils.isEmpty(mPhone) || mPhone.length()<9){
            Toast.makeText(this,getString(R.string.hint_phone),Toast.LENGTH_SHORT).show();
            return;
        }
        if(TextUtils.isEmpty(mName)){
            Toast.makeText(this,getString(R.string.hint_name),Toast.LENGTH_SHORT).show();
            return;
        }
        // If the email and password are not empty
        // display progress dialog
        mProgressDialog.setMessage(getString(R.string.login_progressbar_register));
        mProgressDialog.show();
        // Create a new User
        mAuth.createUserWithEmailAndPassword(mEmail, mPass)
                .addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        if(task.isSuccessful()) {
                            final DatabaseReference mDatabaseReference = FirebaseDatabase.getInstance().getReference();
                            mDatabaseReference.child("users").child(mAuth.getCurrentUser().getUid())
                                    .addListenerForSingleValueEvent(new ValueEventListener() {
                                        @Override
                                        public void onDataChange(DataSnapshot dataSnapshot) {
                                            User mUser = new User();