11package com .example .hongjo .myfinancialmanager ;
22
33import android .content .ContentValues ;
4+ import android .content .DialogInterface ;
45import android .content .Intent ;
56import android .support .v7 .app .AlertDialog ;
67import android .support .v7 .app .AppCompatActivity ;
910import android .view .View ;
1011import android .widget .Button ;
1112import android .widget .EditText ;
13+ import android .widget .TextView ;
14+ import android .net .Uri ;
15+ import android .widget .Toast ;
1216
1317import com .example .hongjo .myfinancialmanager .database .DataProvider ;
1418import com .example .hongjo .myfinancialmanager .database .DataSource ;
@@ -29,6 +33,8 @@ public class LoginActivity extends AppCompatActivity{
2933
3034 private String email , password ;
3135
36+ private TextView forgotPassword ;
37+
3238 @ Override
3339 protected void onCreate (Bundle savedInstanceState ) {
3440 super .onCreate (savedInstanceState );
@@ -39,11 +45,14 @@ protected void onCreate(Bundle savedInstanceState) {
3945 emailEdt = findViewById (R .id .email );
4046 passwordEdt = findViewById (R .id .password );
4147
48+ forgotPassword = findViewById (R .id .forgot_password );
49+
4250 Button signIn = findViewById (R .id .sign_in_button );
4351 Button createAccount = findViewById (R .id .create_account_button );
4452
4553 signIn .setOnClickListener (listener );
4654 createAccount .setOnClickListener (listener );
55+ forgotPassword .setOnClickListener (listener );
4756
4857 }
4958
@@ -59,6 +68,10 @@ public void onClick(View view){
5968 case R .id .create_account_button :
6069 register ();
6170 break ;
71+ //if the user forgets the password, send it to the user's email
72+ case R .id .forgot_password :
73+
74+ break ;
6275 }
6376 }
6477 };
@@ -73,6 +86,12 @@ private void checkValidity(){
7386
7487 AlertDialog .Builder builder = new AlertDialog .Builder (this );
7588 builder .setTitle ("Sign In Error" );
89+
90+ if (email .isEmpty ()||password .isEmpty ()){
91+ builder .setMessage ("Both email and password are required" );
92+ builder .setCancelable (false ).setPositiveButton ("OK" , null ).create ().show ();
93+ return ;
94+ }
7695 //if there is no user in the database
7796 if (user ==null ){
7897 builder .setMessage ("There is no user In database" );
@@ -92,7 +111,7 @@ private void checkValidity(){
92111 builder .setCancelable (false ).setPositiveButton ("OK" , null ).create ().show ();
93112 }
94113 }else {
95- //if there is no user by the email in the database
114+ //if there is no user who has the same email in the database
96115 builder .setMessage ("No Email found in the Database" );
97116 builder .setCancelable (false ).setPositiveButton ("OK" , null ).create ().show ();
98117 }
0 commit comments