mirror of
https://github.com/Nezumi-2711/Foodify.git
synced 2026-09-22 20:00:50 +00:00
Add profile account and change password screen
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
package com.capstone.foodify.Activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.app.DatePickerDialog;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.capstone.foodify.R;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
|
||||
public class AccountAndProfileActivity extends AppCompatActivity {
|
||||
|
||||
TextInputLayout textInput_email, textInput_phone, textInput_firstName, textInput_lastName, textInput_birthDay, textInput_username;
|
||||
|
||||
EditText edt_birthday;
|
||||
final Calendar myCalendar= Calendar.getInstance();
|
||||
LinearLayout change_password;
|
||||
|
||||
ImageView back_image;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_account_and_profile);
|
||||
|
||||
initComponent();
|
||||
setFontUI();
|
||||
chooseDateOfBirth();
|
||||
|
||||
change_password.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
startActivity(new Intent(AccountAndProfileActivity.this, ChangePasswordActivity.class));
|
||||
}
|
||||
});
|
||||
|
||||
back_image.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
onBackPressed();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void initComponent() {
|
||||
textInput_email= (TextInputLayout) findViewById(R.id.textInput_email);
|
||||
textInput_phone = (TextInputLayout) findViewById(R.id.textInput_phone);
|
||||
textInput_firstName = (TextInputLayout) findViewById(R.id.textInput_firstName);
|
||||
textInput_lastName = (TextInputLayout) findViewById(R.id.textInput_lastName);
|
||||
textInput_birthDay = (TextInputLayout) findViewById(R.id.textInput_birthDay);
|
||||
textInput_username = (TextInputLayout) findViewById(R.id.textInput_username);
|
||||
change_password = (LinearLayout) findViewById(R.id.change_password);
|
||||
|
||||
back_image = (ImageView) findViewById(R.id.back_image);
|
||||
|
||||
edt_birthday = (EditText) findViewById(R.id.edt_birthDay);
|
||||
}
|
||||
|
||||
private void setFontUI() {
|
||||
Typeface bebas= Typeface.createFromAsset(getAssets(), "font/bebas.ttf");
|
||||
|
||||
//Set Type face
|
||||
textInput_email.setTypeface(bebas);
|
||||
textInput_phone.setTypeface(bebas);
|
||||
textInput_firstName.setTypeface(bebas);
|
||||
textInput_lastName.setTypeface(bebas);
|
||||
textInput_birthDay.setTypeface(bebas);
|
||||
textInput_username.setTypeface(bebas);
|
||||
|
||||
edt_birthday.setTypeface(bebas);
|
||||
}
|
||||
|
||||
private void chooseDateOfBirth() {
|
||||
//Calendar date of birth
|
||||
|
||||
DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
|
||||
@Override
|
||||
public void onDateSet(DatePicker view, int year, int month, int day) {
|
||||
myCalendar.set(Calendar.YEAR, year);
|
||||
myCalendar.set(Calendar.MONTH,month);
|
||||
myCalendar.set(Calendar.DAY_OF_MONTH,day);
|
||||
updateLabel();
|
||||
}
|
||||
};
|
||||
edt_birthday.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
new DatePickerDialog(AccountAndProfileActivity.this,date,myCalendar.get(Calendar.YEAR),myCalendar.get(Calendar.MONTH),myCalendar.get(Calendar.DAY_OF_MONTH)).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateLabel(){
|
||||
String myFormat="dd/MM/yyyy";
|
||||
SimpleDateFormat dateFormat=new SimpleDateFormat(myFormat, Locale.US);
|
||||
edt_birthday.setText(dateFormat.format(myCalendar.getTime()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.capstone.foodify.Activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.capstone.foodify.R;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
public class ChangePasswordActivity extends AppCompatActivity {
|
||||
|
||||
TextInputLayout textInput_old_password, textInput_password, textInput_password_confirm;
|
||||
|
||||
ImageView back_image;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_change_password);
|
||||
|
||||
initComponent();
|
||||
setFontUI();
|
||||
|
||||
//Handle event when back image on click
|
||||
back_image.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
onBackPressed();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initComponent() {
|
||||
textInput_old_password = findViewById(R.id.textInput_old_password);
|
||||
textInput_password = findViewById(R.id.textInput_password);
|
||||
textInput_password_confirm = findViewById(R.id.textInput_password_confirm);
|
||||
|
||||
back_image = findViewById(R.id.back_image);
|
||||
}
|
||||
|
||||
private void setFontUI() {
|
||||
Typeface bebas= Typeface.createFromAsset(getAssets(), "font/bebas.ttf");
|
||||
|
||||
textInput_password.setTypeface(bebas);
|
||||
textInput_old_password.setTypeface(bebas);
|
||||
textInput_password_confirm.setTypeface(bebas);
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,8 @@ import retrofit2.Response;
|
||||
public class SignUpActivity extends AppCompatActivity {
|
||||
|
||||
TextInputLayout textInput_email, textInput_password, textInput_phone,
|
||||
textInput_address, textInput_repeatPassword, textInput_firstName, textInput_lastName, textInput_birthDay;
|
||||
textInput_address, textInput_repeatPassword, textInput_firstName, textInput_lastName, textInput_birthDay,
|
||||
textInput_username;
|
||||
final Calendar myCalendar= Calendar.getInstance();
|
||||
EditText edt_birthday;
|
||||
TextView signIn_textView;
|
||||
@@ -101,6 +102,7 @@ public class SignUpActivity extends AppCompatActivity {
|
||||
textInput_firstName = (TextInputLayout) findViewById(R.id.textInput_firstName);
|
||||
textInput_lastName = (TextInputLayout) findViewById(R.id.textInput_lastName);
|
||||
textInput_birthDay = (TextInputLayout) findViewById(R.id.textInput_birthDay);
|
||||
textInput_username = (TextInputLayout) findViewById(R.id.textInput_username);
|
||||
|
||||
edt_birthday = (EditText) findViewById(R.id.edt_birthDay);
|
||||
|
||||
@@ -251,6 +253,7 @@ public class SignUpActivity extends AppCompatActivity {
|
||||
textInput_firstName.setTypeface(bebas);
|
||||
textInput_lastName.setTypeface(bebas);
|
||||
textInput_birthDay.setTypeface(bebas);
|
||||
textInput_username.setTypeface(bebas);
|
||||
|
||||
edt_birthday.setTypeface(bebas);
|
||||
}
|
||||
|
||||
@@ -6,9 +6,11 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.capstone.foodify.Activity.AccountAndProfileActivity;
|
||||
import com.capstone.foodify.Activity.SignUpActivity;
|
||||
import com.capstone.foodify.R;
|
||||
|
||||
@@ -16,17 +18,25 @@ public class ProfileFragment extends Fragment {
|
||||
|
||||
Button btnSignUp;
|
||||
|
||||
LinearLayout account_and_profile;
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
View rootView = inflater.inflate(R.layout.fragment_profile, container, false);
|
||||
btnSignUp = (Button) rootView.findViewById(R.id.sign_up_button);
|
||||
account_and_profile = (LinearLayout) rootView.findViewById(R.id.account_and_profile);
|
||||
btnSignUp.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent i =new Intent(getActivity(), SignUpActivity.class);
|
||||
startActivity(i);
|
||||
startActivity(new Intent(getActivity(), SignUpActivity.class));
|
||||
}
|
||||
});
|
||||
|
||||
account_and_profile.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
startActivity(new Intent(getActivity(), AccountAndProfileActivity.class));
|
||||
}
|
||||
});
|
||||
return rootView;
|
||||
|
||||
Reference in New Issue
Block a user