Skip to content
Snippets Groups Projects
Commit c2a11f7e authored by Shubham Maheshwari's avatar Shubham Maheshwari
Browse files

Added Sign up, Login and Logout funcionality

parent 385a4f8a
No related branches found
No related tags found
No related merge requests found
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
<component name="ProjectModuleManager"> <component name="ProjectModuleManager">
<modules> <modules>
<module fileurl="file://$PROJECT_DIR$/TaskBoxx.iml" filepath="$PROJECT_DIR$/TaskBoxx.iml" /> <module fileurl="file://$PROJECT_DIR$/TaskBoxx.iml" filepath="$PROJECT_DIR$/TaskBoxx.iml" />
<module fileurl="file://$PROJECT_DIR$/TaskBoxx1.iml" filepath="$PROJECT_DIR$/TaskBoxx1.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" /> <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
</modules> </modules>
</component> </component>
......
{ {
"project_info": { "project_info": {
"project_number": "629462529132", "project_number": "23719170467",
"firebase_url": "https://browsy-bc721.firebaseio.com", "firebase_url": "https://my-app-e5bdb.firebaseio.com",
"project_id": "browsy-bc721", "project_id": "my-app-e5bdb",
"storage_bucket": "browsy-bc721.appspot.com" "storage_bucket": "my-app-e5bdb.appspot.com"
}, },
"client": [ "client": [
{ {
"client_info": { "client_info": {
"mobilesdk_app_id": "1:629462529132:android:50e3b5ef2ef861e3", "mobilesdk_app_id": "1:23719170467:android:50e3b5ef2ef861e3",
"android_client_info": { "android_client_info": {
"package_name": "com.example.taskboxx" "package_name": "com.example.taskboxx"
} }
}, },
"oauth_client": [ "oauth_client": [
{ {
"client_id": "629462529132-b6vra23omvdfhos88osa7bvv0p1g8lrv.apps.googleusercontent.com", "client_id": "23719170467-9gbikc8ea63o0cc95d8re0stigfc68vh.apps.googleusercontent.com",
"client_type": 3 "client_type": 3
} }
], ],
"api_key": [ "api_key": [
{ {
"current_key": "AIzaSyBsz9xV3HCn9UXJ6TOP2mlRNeTGVSDw9gE" "current_key": "AIzaSyDAFDTRB19anG9_AYRSQT9CX7RVU0oUt2Q"
} }
], ],
"services": { "services": {
......
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
android:name=".Dashboard" android:name=".Dashboard"
android:label="DashBoard" android:label="DashBoard"
android:theme="@style/AppTheme.NoActionBar" /> android:theme="@style/AppTheme.NoActionBar" />
<activity android:name=".LoginActivity"> <activity android:name=".LoginActivity"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
......
package com.example.taskboxx; package com.example.taskboxx;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar; import android.support.design.widget.Snackbar;
...@@ -13,9 +14,13 @@ import android.support.v7.widget.Toolbar; ...@@ -13,9 +14,13 @@ import android.support.v7.widget.Toolbar;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import com.google.firebase.auth.FirebaseAuth;
public class Dashboard extends AppCompatActivity public class Dashboard extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener { implements NavigationView.OnNavigationItemSelectedListener {
FirebaseAuth mAuth;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -23,6 +28,8 @@ public class Dashboard extends AppCompatActivity ...@@ -23,6 +28,8 @@ public class Dashboard extends AppCompatActivity
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
mAuth = FirebaseAuth.getInstance();
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() { fab.setOnClickListener(new View.OnClickListener() {
@Override @Override
...@@ -81,15 +88,16 @@ public class Dashboard extends AppCompatActivity ...@@ -81,15 +88,16 @@ public class Dashboard extends AppCompatActivity
int id = item.getItemId(); int id = item.getItemId();
if (id == R.id.nav_camera) { if (id == R.id.nav_camera) {
// Handle the camera action
} else if (id == R.id.nav_slideshow) { } else if (id == R.id.nav_slideshow) {
} else if (id == R.id.nav_manage) { } else if (id == R.id.nav_manage) {
} else if (id == R.id.nav_share) { } else if (id == R.id.nav_logout) {
mAuth.getInstance().signOut();
} else if (id == R.id.nav_send) { Intent intent = new Intent(this,LoginActivity.class);
startActivity(intent);
finish();
} }
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
......
package com.example.taskboxx; package com.example.taskboxx;
import android.app.ProgressDialog;
import android.content.Intent; import android.content.Intent;
import android.graphics.Paint; import android.graphics.Paint;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.EditText;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
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;
import com.google.firebase.auth.FirebaseUser;
public class LoginActivity extends AppCompatActivity { public class LoginActivity extends AppCompatActivity {
TextView textView; TextView textView;
private EditText Email;
private EditText pass;
private FirebaseAuth mAuth;
private FirebaseAuth.AuthStateListener mAuthListener;
ProgressDialog pd;
public static final String TAG = "TAG";
@Override
public void onStart() {
super.onStart();
mAuth.addAuthStateListener(mAuthListener);
}
@Override
public void onStop() {
super.onStop();
if (mAuthListener != null) {
mAuth.removeAuthStateListener(mAuthListener);
}
}
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login); setContentView(R.layout.activity_login);
Email = (EditText) findViewById(R.id.input_uname_login);
pass = (EditText) findViewById(R.id.input_password_login);
textView = (TextView) findViewById(R.id.launch_forgotpass); textView = (TextView) findViewById(R.id.launch_forgotpass);
textView.setPaintFlags(textView.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); textView.setPaintFlags(textView.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
pd = new ProgressDialog(this);
mAuth = FirebaseAuth.getInstance();
mAuthListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
// User is signed in
Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid());
} else {
// User is signed out
Log.d(TAG, "onAuthStateChanged:signed_out");
}
}
};
} }
public void Login(View view) { public void Login(View view) {
Toast.makeText(this, "Login Successful", Toast.LENGTH_SHORT).show(); String email = Email.getText().toString();
Intent dashboardintent = new Intent(this,Dashboard.class); String password = pass.getText().toString();
if (email.isEmpty() || password.isEmpty()) {
Toast.makeText(this, "Please enter the Email and Password!", Toast.LENGTH_SHORT).show();
} else {
pd.setMessage("Logging in. Please Wait...");
pd.show();
mAuth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
Log.d(TAG, "signInWithEmail:onComplete:" + task.isSuccessful());
if (!task.isSuccessful()) {
pd.dismiss();
Log.w(TAG, "signInWithEmail:failed", task.getException());
Toast.makeText(LoginActivity.this, task.getException().getMessage().toString(),
Toast.LENGTH_SHORT).show();
} else {
pd.dismiss();
Toast.makeText(LoginActivity.this, "Login Successful", Toast.LENGTH_SHORT).show();
Intent dashboardintent = new Intent(LoginActivity.this, Dashboard.class);
startActivity(dashboardintent); startActivity(dashboardintent);
} }
}
});
}
}
public void gotoSignUp(View view){ public void gotoSignUp(View view){
Toast.makeText(this, "Great Idea!", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Great Idea!", Toast.LENGTH_SHORT).show();
......
...@@ -23,6 +23,7 @@ import com.google.android.gms.tasks.Task; ...@@ -23,6 +23,7 @@ import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult; import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseAuthException; import com.google.firebase.auth.FirebaseAuthException;
import com.google.firebase.auth.FirebaseUser;
public class SignUpActivity extends AppCompatActivity { public class SignUpActivity extends AppCompatActivity {
...@@ -34,9 +35,6 @@ public class SignUpActivity extends AppCompatActivity { ...@@ -34,9 +35,6 @@ public class SignUpActivity extends AppCompatActivity {
public EditText confirm_pwd; public EditText confirm_pwd;
public ProgressDialog pd; public ProgressDialog pd;
private FirebaseAuth mAuth; private FirebaseAuth mAuth;
private FirebaseAuth.AuthStateListener mAuthListener;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -52,17 +50,10 @@ public class SignUpActivity extends AppCompatActivity { ...@@ -52,17 +50,10 @@ public class SignUpActivity extends AppCompatActivity {
confirm_pwd = (EditText) findViewById(R.id.input_RePass_SignUp); confirm_pwd = (EditText) findViewById(R.id.input_RePass_SignUp);
pd = new ProgressDialog(this); pd = new ProgressDialog(this);
signup_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
StartRigister();
}
});
} }
private void StartRigister() { public void SignUp(View view) {
String u_name = name.getText().toString(); String u_name = name.getText().toString();
...@@ -74,13 +65,11 @@ public class SignUpActivity extends AppCompatActivity { ...@@ -74,13 +65,11 @@ public class SignUpActivity extends AppCompatActivity {
if (TextUtils.isEmpty(u_name) || TextUtils.isEmpty(u_username) || TextUtils.isEmpty(u_email) || TextUtils.isEmpty(u_pwd) || TextUtils.isEmpty(u_c_pwd)) { if (TextUtils.isEmpty(u_name) || TextUtils.isEmpty(u_username) || TextUtils.isEmpty(u_email) || TextUtils.isEmpty(u_pwd) || TextUtils.isEmpty(u_c_pwd)) {
Toast.makeText(this, "Please Enter All the fields to proceed!", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Please Enter All the fields to proceed!", Toast.LENGTH_SHORT).show();
return; return;
} } else {
if (u_pwd.equals(u_c_pwd)) { if (u_pwd.equals(u_c_pwd)) {
pd.setMessage("Browsy is Registering You!"); pd.setMessage("Registering...");
pd.show(); pd.show();
...@@ -92,13 +81,13 @@ public class SignUpActivity extends AppCompatActivity { ...@@ -92,13 +81,13 @@ public class SignUpActivity extends AppCompatActivity {
public void onComplete(@NonNull Task<AuthResult> task) { public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) if (task.isSuccessful()) {
{
pd.hide(); pd.hide();
Toast.makeText(SignUpActivity.this, "Registered Successfully!", Toast.LENGTH_SHORT).show(); Toast.makeText(SignUpActivity.this, "Registered Successfully!", Toast.LENGTH_SHORT).show();
} Toast.makeText(SignUpActivity.this, "Please Log in to proceed", Toast.LENGTH_SHORT).show();
Intent loginintent = new Intent(SignUpActivity.this,LoginActivity.class);
else { startActivity(loginintent);
} else {
pd.hide(); pd.hide();
Toast.makeText(SignUpActivity.this, "Failed To Register!", Toast.LENGTH_SHORT).show(); Toast.makeText(SignUpActivity.this, "Failed To Register!", Toast.LENGTH_SHORT).show();
} }
...@@ -108,7 +97,6 @@ public class SignUpActivity extends AppCompatActivity { ...@@ -108,7 +97,6 @@ public class SignUpActivity extends AppCompatActivity {
}); });
} else { } else {
Toast.makeText(this, "The Entered Password doesn't Match!", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "The Entered Password doesn't Match!", Toast.LENGTH_SHORT).show();
...@@ -121,3 +109,4 @@ public class SignUpActivity extends AppCompatActivity { ...@@ -121,3 +109,4 @@ public class SignUpActivity extends AppCompatActivity {
} }
}
\ No newline at end of file
...@@ -38,8 +38,8 @@ ...@@ -38,8 +38,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="30dp" android:layout_marginRight="30dp"
android:layout_marginLeft="30dp" android:layout_marginLeft="30dp"
android:inputType="text" android:inputType="textEmailAddress"
android:hint="Username or Email" /> android:hint="Registered Email" />
</android.support.design.widget.TextInputLayout> </android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout <android.support.design.widget.TextInputLayout
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
android:layout_below="@+id/LoginUname_textLayout" android:layout_below="@+id/LoginUname_textLayout"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"> android:layout_alignParentStart="true">
<EditText android:id="@+id/input_password" <EditText android:id="@+id/input_password_login"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="30dp" android:layout_marginRight="30dp"
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/colorPrimary"
tools:context="com.example.taskboxx.SignUpActivity"> tools:context="com.example.taskboxx.SignUpActivity">
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -12,7 +11,7 @@ ...@@ -12,7 +11,7 @@
<TextView <TextView
android:id="@+id/Explanation" android:id="@+id/Explanation"
android:textColor="@color/colorAccent" android:textColor="#AA000000"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
...@@ -31,7 +30,8 @@ ...@@ -31,7 +30,8 @@
android:layout_below="@+id/Explanation" android:layout_below="@+id/Explanation"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"> android:layout_alignParentStart="true"
app:hintTextAppearance="@style/TextAppearance.TextInputLayout">
<EditText android:id="@+id/input_Name_SignUp" <EditText android:id="@+id/input_Name_SignUp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
...@@ -130,6 +130,7 @@ ...@@ -130,6 +130,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="#EEEEEE" android:background="#EEEEEE"
android:onClick="SignUp"
android:text="Sign Up" /> android:text="Sign Up" />
</LinearLayout> </LinearLayout>
......
...@@ -19,13 +19,9 @@ ...@@ -19,13 +19,9 @@
<item android:title="Communicate"> <item android:title="Communicate">
<menu> <menu>
<item <item
android:id="@+id/nav_share" android:id="@+id/nav_logout"
android:icon="@drawable/ic_menu_share" android:icon="@drawable/ic_menu_share"
android:title="Share" /> android:title="Logout" />
<item
android:id="@+id/nav_send"
android:icon="@drawable/ic_menu_send"
android:title="Send" />
</menu> </menu>
</item> </item>
......
...@@ -17,5 +17,9 @@ ...@@ -17,5 +17,9 @@
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="TextAppearance.TextInputLayout" parent="@android:style/TextAppearance">
<item name="android:textColor">#000000</item>
<item name="android:textSize">10dp</item>
</style>
</resources> </resources>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment