Commit 2bf11c00 authored by Paded's avatar Paded

add resetPassword

parent 77baf646
......@@ -13,8 +13,8 @@
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:windowSoftInputMode="adjustResize"></activity>
<activity android:name=".CreateAccountActivity"></activity>
android:windowSoftInputMode="adjustResize" />
<activity android:name=".CreateAccountActivity" />
<activity
android:name=".SplashActivity"
android:theme="@style/SplashTheme">
......@@ -24,7 +24,10 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".LoginActivity"></activity>
<activity
android:name=".LoginActivity"
android:windowSoftInputMode="adjustResize" />
<activity android:name=".ResetPasswordActivity"></activity>
</application>
</manifest>
\ No newline at end of file
package ubontransitdriver.paded.com.ubontransitdriver;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
......@@ -7,9 +8,11 @@ import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.ScrollView;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
......@@ -26,6 +29,7 @@ public class CreateAccountActivity extends AppCompatActivity {
private Button btnCreateAccount, btnLogin, btnResetPassword;
private ProgressBar progressBar;
private FirebaseAuth auth;
ScrollView mainLayout;
private String TAG = "TEST22";
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -35,6 +39,8 @@ public class CreateAccountActivity extends AppCompatActivity {
//Get Firebase auth instance
auth = FirebaseAuth.getInstance();
mainLayout = (ScrollView) findViewById(R.id.mainlayout);
inputEmail = (EditText)findViewById(R.id.input_email);
inputPassword = (EditText)findViewById(R.id.input_password);
inputName = (EditText)findViewById(R.id.input_name);
......@@ -48,6 +54,10 @@ public class CreateAccountActivity extends AppCompatActivity {
btnCreateAccount.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mainLayout.getWindowToken(), 0);
String email = inputEmail.getText().toString().trim();
String password = inputPassword.getText().toString().trim();
final String userName = inputName.getText().toString().trim();
......@@ -107,6 +117,15 @@ public class CreateAccountActivity extends AppCompatActivity {
}
});
btnResetPassword.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(CreateAccountActivity.this, ResetPasswordActivity.class);
startActivity(intent);
finish();
}
});
}
public void insertData(String uid, String name){
......
package ubontransitdriver.paded.com.ubontransitdriver;
import android.content.Context;
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.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.ScrollView;
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;
public class LoginActivity extends AppCompatActivity {
private Button createPage;
private Button btn_joinus, btn_login,btnResetPassword;
private EditText input_email, input_password;
private FirebaseAuth auth;
private ProgressBar progressBar;
private String TAG = "LOGIN22";
ScrollView mainLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_layout);
createPage = (Button)findViewById(R.id.create_button);
auth = FirebaseAuth.getInstance();
mainLayout = (ScrollView) findViewById(R.id.mainlayout);
btnResetPassword = (Button) findViewById(R.id.btn_reset_password);
btn_joinus = (Button) findViewById(R.id.btn_joinus);
btn_login = (Button) findViewById(R.id.btn_login);
input_email = (EditText) findViewById(R.id.input_email);
input_password = (EditText) findViewById(R.id.input_password);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
createPage.setOnClickListener(new View.OnClickListener() {
btn_login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mainLayout.getWindowToken(), 0);
String email = input_email.getText().toString();
final String password = input_password.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);
auth.signInWithEmailAndPassword(email, password).addOnCompleteListener(LoginActivity.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
progressBar.setVisibility(View.GONE);
if (!task.isSuccessful()) {
// there was an error
if (password.length() < 6) {
input_password.setError(getString(R.string.minimum_password));
} else {
Toast.makeText(LoginActivity.this, getString(R.string.auth_failed), Toast.LENGTH_LONG).show();
}
} else {
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
}
});
}
});
btn_joinus.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(LoginActivity.this, CreateAccountActivity.class);
......@@ -24,5 +102,15 @@ public class LoginActivity extends AppCompatActivity {
finish();
}
});
btnResetPassword.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(LoginActivity.this, ResetPasswordActivity.class);
startActivity(intent);
}
});
}
}
package ubontransitdriver.paded.com.ubontransitdriver;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.ScrollView;
import com.google.firebase.auth.FirebaseAuth;
import java.util.Objects;
public class ResetPasswordActivity extends AppCompatActivity {
private Button btn_resetPassword, btn_back;
private EditText input_email;
private FirebaseAuth auth;
private ProgressBar progressBar;
private String TAG = "LOGIN22";
ScrollView mainLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.reset_password_layout);
auth = FirebaseAuth.getInstance();
mainLayout = (ScrollView) findViewById(R.id.mainlayout);
btn_resetPassword = (Button) findViewById(R.id.btn_reset_password);
btn_back = (Button) findViewById(R.id.btn_back);
input_email = (EditText) findViewById(R.id.input_email);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
btn_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
}
}
......@@ -22,9 +22,9 @@ public class SplashActivity extends AppCompatActivity {
}
private void updateUI(FirebaseUser user) {
if (user != null) {
// Intent intent = new Intent(this, MainActivity.class);
// startActivity(intent);
// finish();
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
} else {
Intent intent = new Intent(this, LoginActivity.class);
startActivity(intent);
......
......@@ -6,10 +6,7 @@
android:color="@color/gray" >
</solid>
<!--<stroke-->
<!--android:width="2dp"-->
<!--android:color="#C4CDE0" >-->
<!--</stroke>-->
<padding
android:left="5dp"
......
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid
android:color="@color/off_white" >
</solid>
<padding
android:left="5dp"
android:top="5dp"
android:right="5dp"
android:bottom="5dp" >
</padding>
<corners
android:radius="360dp" >
</corners>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="@color/off_white" />
<solid android:color="@color/white" />
<corners android:radius="8dp" />
<padding
android:bottom="7dip"
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="#FFFFFF" />
<solid android:color="@color/off_white" />
<corners android:radius="8dp" />
<stroke
android:width="1dp"
android:color="#e7e8ea" >
</stroke>
<padding
android:bottom="7dip"
android:left="7dip"
......
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="false" android:color="@color/blue" />
<item android:state_focused="true" android:state_pressed="true" android:color="@color/off_blue" />
<item android:state_focused="false" android:state_pressed="true" android:color="@color/off_blue" />
<item android:color="@color/blue" />
</selector>
\ No newline at end of file
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="false" android:color="@color/green" />
<item android:state_focused="true" android:state_pressed="true" android:color="@color/off_green" />
<item android:state_focused="false" android:state_pressed="true" android:color="@color/off_green" />
<item android:color="@color/green" />
</selector>
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="@color/blue"
android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
</vector>
......@@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mainlayout"
tools:context=".CreateAccountActivity">
......@@ -24,20 +25,6 @@
android:textColor="@color/blue"
android:layout_marginBottom="15dp"
/>
<com.h6ah4i.android.materialshadowninepatch.MaterialShadowContainerView
android:id="@+id/shadow_item_container"
style="@style/ms9_DefaultShadowStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:ms9_shadowElevation="4dp"
app:ms9_shadowTranslationZ="2dp">
<RelativeLayout
android:id="@+id/input_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<EditText
android:id="@+id/input_name"
......@@ -89,14 +76,11 @@
android:padding="15dp"
android:gravity="left|center_vertical"
style="?android:attr/borderlessButtonStyle"
android:text="@string/create_account_btn_txt_ENG"
android:text="@string/add_bus_label"
android:textColor="@color/blue" />
</RelativeLayout>
</com.h6ah4i.android.materialshadowninepatch.MaterialShadowContainerView>
<Button
android:id="@+id/btn_create_account"
android:layout_width="match_parent"
......@@ -117,7 +101,7 @@
android:background="@null"
android:text="@string/btn_forgot_password"
android:textAllCaps="false"
android:textColor="@color/blue" />
android:textColor="@drawable/button_text_color_blue" />
<!-- Link to Login Screen -->
......@@ -125,11 +109,10 @@
android:id="@+id/btnLogin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/btn_reset_password"
android:background="@null"
android:text="@string/btn_login"
android:textAllCaps="false"
android:textColor="@color/green"
android:textColor="@drawable/button_text_color_green"
android:textSize="15dp" />
......
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/mainlayout"
tools:context=".LoginActivity">
<Button
android:id="@+id/create_button"
android:layout_width="fill_parent"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:text="@string/btn_login"
android:textAllCaps="false"
android:textColor="@color/green"
android:textSize="15dp" />
android:layout_gravity="center"
android:orientation="vertical"
android:padding="25dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/login_label"
android:layout_above="@+id/input_name"
android:textSize="40dp"
android:textStyle="bold"
android:textColor="@color/blue"
android:layout_marginBottom="15dp"
/>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
<EditText
android:id="@+id/input_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/input_name"
android:drawableLeft="@drawable/ic_email"
android:drawablePadding="10dp"
android:padding="15dp"
android:layout_marginTop="10dp"
android:hint="Your Email"
android:background="@drawable/bg_edittext"
android:ems="10"
android:inputType="textEmailAddress" />
<EditText
android:id="@+id/input_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/input_email"
android:drawableLeft="@drawable/ic_pass_key"
android:drawablePadding="10dp"
android:padding="15dp"
android:layout_marginTop="10dp"
android:hint="Your Password"
android:background="@drawable/bg_edittext"
android:ems="10"
android:inputType="textPassword" />
<Button
android:id="@+id/btn_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/shadow_item_container"
android:layout_marginTop="20dp"
android:background="@drawable/create_account_btn_color"
android:padding="10dp"
android:text="@string/btn_login_main"
android:textColor="#ffffffff" />
<Button
android:id="@+id/btn_reset_password"
android:layout_width="fill_parent"
android:layout_below="@+id/btn_create_account"
android:layout_height="wrap_content"
android:layout_marginTop="20dip"
android:background="@null"
android:text="@string/btn_forgot_password"
android:textAllCaps="false"
android:textColor="@drawable/button_text_color_blue" />
<!-- Link to Login Screen -->
<Button
android:id="@+id/btn_joinus"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@null"
android:text="@string/btn_joinus"
android:textAllCaps="false"
android:textColor="@drawable/button_text_color_green"
android:textSize="15dp" />
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="158dp"
android:layout_height="30dp"
android:layout_gravity="center|bottom"
android:layout_marginBottom="20dp"
android:visibility="gone" />
</LinearLayout>
</ScrollView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
tools:context=".ResetPasswordActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/btn_back"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_margin="25dp"
style="?android:attr/borderlessButtonStyle"
android:background="@drawable/bg_back_btn"
android:drawableLeft="@drawable/ic_arrow_back_24dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical"
android:padding="25dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="15dp"
android:text="@string/forgot_password_label"
android:textColor="@color/blue"
android:textSize="40dp"
android:textStyle="bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="15dp"
android:text="@string/forgot_password_msg"
android:textColor="@color/blue"
android:textSize="18dp" />
<EditText
android:id="@+id/input_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/bg_edittext"
android:drawableLeft="@drawable/ic_email"
android:drawablePadding="10dp"
android:ems="10"
android:hint="Your Email"
android:inputType="textEmailAddress"
android:padding="15dp" />
<Button
android:id="@+id/btn_reset_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/shadow_item_container"
android:layout_marginTop="20dp"
android:background="@drawable/create_account_btn_color"
android:padding="10dp"
android:text="@string/btn_resetPassword"
android:textColor="#ffffffff" />
<!-- Link to Login Screen -->
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="158dp"
android:layout_height="30dp"
android:layout_gravity="center|bottom"
android:layout_marginBottom="20dp"
android:visibility="gone" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
\ No newline at end of file
......@@ -10,6 +10,7 @@
<color name="blue">#007aff</color>
<color name="off_blue">#006ee7</color>
<color name="green">#4cd964</color>
<color name="off_green">#47c75d</color>
<color name="red">#ff2d55</color>
<color name="black">#000000</color>
<color name="gray">#ececec</color>
......
......@@ -2,10 +2,27 @@
<string name="app_name">Ubon Transit Driver</string>
<string name="create_account_btn_txt_ENG">Create Account</string>
<!--Button-->
<string name="create_account_btn_txt_ENG">CREATE ACCOUNT</string>
<string name="btn_forgot_password">Forgot Your Password?</string>
<string name="btn_joinus">Not a member? Join us now!</string>
<string name="btn_login">Already registered. Login Me!</string>
<string name="btn_login_main">LOGIN</string>
<string name="btn_resetPassword">RESET PASSWORD</string>
<!--Label-->
<string name="create_account_label">Create your account</string>
<string name="add_bus_label">Pick your bus</string>
<string name="login_label">Login</string>
<string name="forgot_password_label">Forgot password?</string>
<string name="forgot_password_msg">We just need your registered Email Id to sent you password reset instructions.</string>
<!--Toast-->
<string name="minimum_password">Password too short, enter minimum 6 characters!</string>
<string name="auth_failed">Authentication failed, check your email and password or sign up</string>
<string name="send_password_reset_email">Send Password reset email</string>
</resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment