mirror of
https://github.com/Nezumi-2711/Foodify.git
synced 2026-09-22 13:38:41 +00:00
Add Sign In Activity
This commit is contained in:
@@ -11,6 +11,9 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Foodify"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".SignInActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".SignUpActivity"
|
||||
android:exported="false" />
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.capstone.foodify;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class SignInActivity extends AppCompatActivity {
|
||||
|
||||
TextView signUp_textView;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_sign_in);
|
||||
|
||||
signUp_textView = (TextView) findViewById(R.id.sign_up_textView);
|
||||
signUp_textView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
startActivity(new Intent(SignInActivity.this, SignUpActivity.class));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.app.DatePickerDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
@@ -21,6 +22,7 @@ import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
public class SignUpActivity extends AppCompatActivity {
|
||||
|
||||
@@ -29,6 +31,7 @@ public class SignUpActivity extends AppCompatActivity {
|
||||
final Calendar myCalendar= Calendar.getInstance();
|
||||
EditText editText, edt_birthday;
|
||||
|
||||
TextView signIn_textView;
|
||||
Spinner wardSpinner, districtSpinner;
|
||||
|
||||
|
||||
@@ -38,25 +41,25 @@ public class SignUpActivity extends AppCompatActivity {
|
||||
setContentView(R.layout.activity_sign_up);
|
||||
|
||||
setFontUI();
|
||||
chooseDateOfBirth();
|
||||
listWardAndDistrict();
|
||||
|
||||
//Calendar date of birth
|
||||
editText=(EditText) findViewById(R.id.edt_birthDay);
|
||||
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();
|
||||
}
|
||||
};
|
||||
editText.setOnClickListener(new View.OnClickListener() {
|
||||
signIn_textView = (TextView) findViewById(R.id.signIn_textView);
|
||||
signIn_textView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
new DatePickerDialog(SignUpActivity.this,date,myCalendar.get(Calendar.YEAR),myCalendar.get(Calendar.MONTH),myCalendar.get(Calendar.DAY_OF_MONTH)).show();
|
||||
startActivity(new Intent(SignUpActivity.this, SignInActivity.class));
|
||||
}
|
||||
});
|
||||
|
||||
// enabling action bar app icon and behaving it as toggle button
|
||||
Objects.requireNonNull(getSupportActionBar()).setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void listWardAndDistrict() {
|
||||
wardSpinner = (Spinner) findViewById(R.id.ward);
|
||||
districtSpinner = (Spinner) findViewById(R.id.district);
|
||||
|
||||
@@ -82,7 +85,6 @@ public class SignUpActivity extends AppCompatActivity {
|
||||
wardSpinner.setSelection(ward.indexOf("---Phường"));//set selected value in spinner
|
||||
districtSpinner.setSelection(district.indexOf("---Quận"));
|
||||
}
|
||||
|
||||
private static class MySpinnerAdapter extends ArrayAdapter<String> {
|
||||
// Initialise custom font, for example:
|
||||
Typeface font = Typeface.createFromAsset(getContext().getAssets(),
|
||||
@@ -112,6 +114,26 @@ public class SignUpActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private void chooseDateOfBirth() {
|
||||
//Calendar date of birth
|
||||
editText=(EditText) findViewById(R.id.edt_birthDay);
|
||||
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();
|
||||
}
|
||||
};
|
||||
editText.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
new DatePickerDialog(SignUpActivity.this,date,myCalendar.get(Calendar.YEAR),myCalendar.get(Calendar.MONTH),myCalendar.get(Calendar.DAY_OF_MONTH)).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateLabel(){
|
||||
String myFormat="MM/dd/yy";
|
||||
SimpleDateFormat dateFormat=new SimpleDateFormat(myFormat, Locale.US);
|
||||
|
||||
@@ -7,6 +7,8 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class SplashScreenActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M12,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM12,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,138 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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"
|
||||
tools:context=".SignInActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginTop="50dp"
|
||||
android:fontFamily="@font/bebas"
|
||||
android:text="@string/sign_in_text"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="50sp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/logo_image"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_marginTop="32dp"
|
||||
android:src="@drawable/logo"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView" />
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/textInput_account"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:hint="@string/phone_or_email"
|
||||
app:boxBackgroundColor="@color/white"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/logo_image"
|
||||
app:startIconDrawable="@drawable/baseline_person_24"
|
||||
app:startIconTint="@color/primaryColor">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/edt_email"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:inputType="text" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/textInput_password"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:hint="@string/password_text"
|
||||
app:boxBackgroundColor="@color/white"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textInput_account"
|
||||
app:passwordToggleEnabled="true"
|
||||
app:passwordToggleTint="@color/primaryColor"
|
||||
app:startIconDrawable="@drawable/baseline_vpn_key_24"
|
||||
app:startIconTint="@color/primaryColor">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/edt_password"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:inputType="textPassword" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/forgotPassword_textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:fontFamily="@font/bebas"
|
||||
android:text="@string/forgot_password"
|
||||
android:textColor="@color/graylight"
|
||||
android:textSize="15sp"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textInput_password" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/sign_up_button"
|
||||
style="@style/DefaultSolid"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="40dp"
|
||||
android:layout_marginEnd="40dp"
|
||||
android:layout_marginTop="80dp"
|
||||
android:fontFamily="@font/bebas"
|
||||
android:padding="10dp"
|
||||
android:text="@string/sign_in_text"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textInput_password" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/dont_have_an_account"
|
||||
android:textColor="@color/gray"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/sign_up_textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:text="@string/sign_up_text"
|
||||
android:textColor="@color/secondary"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -276,6 +276,7 @@
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/signIn_textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
@@ -287,4 +288,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -6,6 +6,6 @@
|
||||
<color name="primaryColor">#2FDBBC</color>
|
||||
<color name="gray">#A3A3A3</color>
|
||||
<color name="secondary">#F99928</color>
|
||||
<color name="graylight">#F1F0F0</color>
|
||||
<color name="graylight">#ACA5A5</color>
|
||||
|
||||
</resources>
|
||||
@@ -1,5 +1,5 @@
|
||||
<resources>
|
||||
<string name="app_name">UI App</string>
|
||||
<string name="app_name">Foodify</string>
|
||||
<string name="activity_home">Trang chủ</string>
|
||||
<string name="activity_search">Tìm kiếm</string>
|
||||
<string name="activity_basket">Giỏ hàng</string>
|
||||
@@ -18,4 +18,7 @@
|
||||
<string name="last_name_text">Tên</string>
|
||||
<string name="birthday_text">ngày sinh nhật (mm/dd/yyyy)</string>
|
||||
<string name="address_text">địa chỉ</string>
|
||||
<string name="phone_or_email">phone or email</string>
|
||||
<string name="forgot_password">Forgot Password?</string>
|
||||
<string name="dont_have_an_account">Don\'t have an account?</string>
|
||||
</resources>
|
||||
@@ -10,8 +10,6 @@
|
||||
<!-- Status bar color. -->
|
||||
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="DefaultSolid" parent="Widget.MaterialComponents.Button">
|
||||
|
||||
Reference in New Issue
Block a user