mirror of
https://github.com/Nezumi-2711/Foodify-Shipper.git
synced 2026-09-22 13:38:42 +00:00
Add sign in method and show information
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'com.google.gms.google-services'
|
||||
}
|
||||
|
||||
android {
|
||||
@@ -34,9 +35,15 @@ dependencies {
|
||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||
implementation 'com.google.android.material:material:1.9.0-beta01'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation 'com.google.firebase:firebase-auth:21.0.3'
|
||||
implementation 'com.google.firebase:firebase-storage:20.0.1'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||
|
||||
implementation 'com.makeramen:roundedimageview:2.3.0'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'
|
||||
implementation 'com.github.gabriel-TheCode:AestheticDialogs:1.3.6'
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
@@ -10,8 +12,12 @@
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:usesCleartextTraffic="true"
|
||||
android:theme="@style/Theme.FoodifyShipper"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".Activity.ChangePasswordActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".Activity.OrderDetailActivity"
|
||||
android:exported="false" />
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,78 @@
|
||||
package com.capstone.foodify.shipper.API;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
|
||||
|
||||
public interface FoodApi {
|
||||
Gson gson = new GsonBuilder().setDateFormat("HH:mm:ss dd-MM-yyyy").setLenient().create();
|
||||
|
||||
FoodApi apiService = new Retrofit.Builder()
|
||||
.baseUrl("http://192.168.1.183:8080/api/").addConverterFactory(GsonConverterFactory.create(gson))
|
||||
.build()
|
||||
.create(FoodApi.class);
|
||||
|
||||
// @GET("products/random?pageSize=10")
|
||||
// Call<Foods> recommendFood();
|
||||
//
|
||||
// @GET("products/enable?pageNo=0&pageSize=10&sortBy=createdTime&sortDir=desc")
|
||||
// Call<Foods> recentFood();
|
||||
//
|
||||
// @GET("shops/enable?pageNo=0&pageSize=10&sortBy=id&sortDir=asc")
|
||||
// Call<Shops> allShops();
|
||||
//
|
||||
// @GET("products/search/{name}")
|
||||
// Call<Foods> searchFoodByName(@Path("name") String name, @Query("pageNo") int pageNo, @Query("pageSize") int pageSize, @Query("sortBy") String sortBy, @Query("sortDir") String sortDir);
|
||||
//
|
||||
// @GET("products")
|
||||
// Call<Foods> listFood(@Query("pageNo") int pageNo, @Query("pageSize") int pageSize, @Query("sortBy") String sortBy, @Query("sortDir") String sortDir);
|
||||
//
|
||||
// @GET("categories/randoms?pageNo=0&pageSize=7")
|
||||
// Call<Categories> listCategory();
|
||||
//
|
||||
// @GET("products/categories")
|
||||
// Call<Foods> listFoodByCategory(@Query("id") List<Integer> id, @Query("pageNo") int pageNo, @Query("pageSize") int pageSize, @Query("sortBy") String sortBy, @Query("sortDir") String sortDir);
|
||||
//
|
||||
// @GET("products/categoriesAndName")
|
||||
// Call<Foods> listFoodByCategoriesAndName(@Query("id") List<Integer> id, @Query("name") String name, @Query("pageNo") int pageNo, @Query("pageSize") int pageSize, @Query("sortBy") String sortBy, @Query("sortDir") String sortDir);
|
||||
//
|
||||
// @GET("products/{id}")
|
||||
// Call<Food> detailFood(@Path("id") String id);
|
||||
//
|
||||
// @GET("shops/{id}")
|
||||
// Call<Shop> detailShop(@Path("id") int id);
|
||||
//
|
||||
// @GET("products/shops/{id}")
|
||||
// Call<Foods> listFoodByShopId(@Path("id") int id, @Query("pageNo") int pageNo, @Query("pageSize") int pageSize, @Query("sortBy") String sortBy, @Query("sortDir") String sortDir);
|
||||
//
|
||||
// @GET("districts/{districtId}/wards")
|
||||
// Call<List<DistrictWardResponse>> wardResponse(@Path("districtId") int district_id);
|
||||
//
|
||||
// @GET("districts")
|
||||
// Call<List<DistrictWardResponse>> districtResponse();
|
||||
//
|
||||
// @GET("sliders")
|
||||
// Call<List<Slider>> listSlider();
|
||||
//
|
||||
// @Headers({"accept: */*", "Content-Type: application/json"})
|
||||
// @POST("auth/signup")
|
||||
// Call<User> register(@Body User user);
|
||||
//
|
||||
// @POST("auth/check")
|
||||
// Call<CustomResponse> checkEmailOrPhoneExist (@Body User user);
|
||||
//
|
||||
// @GET("products/{productId}/comments")
|
||||
// Call<Comments> getCommentByProductId(@Path("productId") int productId, @Query("pageNo") int pageNo, @Query("pageSize") int pageSize, @Query("sortBy") String sortBy, @Query("sortDir") String sortDir);
|
||||
//
|
||||
// @GET("products/{productId}/users/{userId}")
|
||||
// Call<Comment> getUserComment(@Path("productId") int productId, @Path("userId") int userId);
|
||||
//
|
||||
// @GET("shops/{id}")
|
||||
// Call<Shop> getShopById(@Path("id") int id);
|
||||
//
|
||||
// @GET("products/{productId}/user")
|
||||
// Call<CustomResponse> checkUserBuyProduct(@Path("productId") int productId, @Query("userId") int userId);
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.capstone.foodify.shipper.API;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.capstone.foodify.shipper.Common;
|
||||
import com.capstone.foodify.shipper.Model.User;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Path;
|
||||
|
||||
public interface FoodApiToken {
|
||||
Gson gson = new GsonBuilder().setDateFormat("HH:mm:ss dd-MM-yyyy").setLenient().create();
|
||||
|
||||
OkHttpClient client = new OkHttpClient.Builder().addInterceptor(new Interceptor() {
|
||||
@NonNull
|
||||
@Override
|
||||
public Response intercept(@NonNull Chain chain) throws IOException {
|
||||
Request newRequest = chain.request().newBuilder().addHeader("Authorization", "Bearer " + Common.TOKEN).build();
|
||||
return chain.proceed(newRequest);
|
||||
}
|
||||
}).build();
|
||||
|
||||
|
||||
FoodApiToken apiService = new Retrofit.Builder()
|
||||
.client(client)
|
||||
.baseUrl("http://192.168.1.183:8080/api/").addConverterFactory(GsonConverterFactory.create(gson))
|
||||
.build()
|
||||
.create(FoodApiToken.class);
|
||||
|
||||
|
||||
// @POST("users/{userId}/loves/{productId}")
|
||||
// Call<Food> addFoodToFavorite(@Path("userId") int userId, @Path("productId") int productId);
|
||||
//
|
||||
// @DELETE("users/{userId}/loves/{productId}")
|
||||
// Call<Food> removeFoodFromFavorite(@Path("userId") int userId, @Path("productId") int productId);
|
||||
|
||||
@GET("users/email/{userEmail}")
|
||||
Call<User> getUserFromEmail(@Path("userEmail") String userEmail);
|
||||
|
||||
// @GET("users/{userId}/loves")
|
||||
// Call<Foods> getListFavoriteFood(@Path("userId") int userId, @Query("pageNo") int pageNo, @Query("pageSize") int pageSize, @Query("sortBy") String sortBy, @Query("sortDir") String sortDir);
|
||||
//
|
||||
// @PUT("users/{userId}")
|
||||
// Call<User> updateUser(@Path("userId") int userId, @Body User user);
|
||||
//
|
||||
// @GET("users/{userId}/loves/{productId}")
|
||||
// Call<CustomResponse> checkFoodIsFavorite(@Path("userId") int userId, @Path("productId") int productId);
|
||||
//
|
||||
// @POST("users/{userId}/addresses")
|
||||
// Call<CustomResponse> createAddressUser(@Path("userId") int userId, @Body Address address);
|
||||
//
|
||||
// @PUT("users/{userId}/addresses/{addressId}")
|
||||
// Call<CustomResponse> editAddressUser(@Path("userId") int userId, @Path("addressId") int addressId, @Body Address address);
|
||||
//
|
||||
// @DELETE("users/{userId}/addresses/{addressId}")
|
||||
// Call<CustomResponse> deleteAddressUser(@Path("userId") int userId, @Path("addressId") int addressId);
|
||||
//
|
||||
// @POST("users/{userId}/orders")
|
||||
// Call<Order> createOrder(@Path("userId") int userId, @Body Order order);
|
||||
//
|
||||
// @POST("products/{productId}/comments")
|
||||
// Call<Comment> createComment(@Path("productId") int productId, @Body Comment comment);
|
||||
//
|
||||
// @DELETE("products/{productId}/comments/{commentId}")
|
||||
// Call<CustomResponse> deleteComment(@Path("productId") int productId, @Path("commentId") int commentId);
|
||||
//
|
||||
// @PUT("products/{productId}/comments/{commentId}")
|
||||
// Call<CustomResponse> updateComment(@Path("productId") int productId, @Path("commentId") int commentId, @Body Comment comment);
|
||||
//
|
||||
// @GET("users/{userId}/orders/status/{status}")
|
||||
// Call<Orders> getOrderUser(@Path("userId") int userId, @Path("status") String status, @Query("pageNo") int pageNo, @Query("pageSize") int pageSize, @Query("sortBy") String sortBy, @Query("sortDir") String sortDir);
|
||||
//
|
||||
// @DELETE("users/{userId}/orders/{orderId}")
|
||||
// Call<CustomResponse> deleteOrder(@Path("userId") int userId, @Path("orderId") int orderId);
|
||||
//
|
||||
// @PUT("users/{userId}/orders/{orderId}/status")
|
||||
// Call<CustomResponse> updateOrderStatus(@Path("userId") int userId, @Path("orderId") int orderId, @Query("status") String status);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.capstone.foodify.shipper.API;
|
||||
|
||||
import com.capstone.foodify.shipper.Model.GoogleMap.GoogleMapResponse;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.Query;
|
||||
|
||||
public interface GoogleMapApi {
|
||||
|
||||
Gson gson = new GsonBuilder().setDateFormat("HH:mm:ss dd-MM-yyyy").setLenient().create();
|
||||
|
||||
GoogleMapApi apiService = new Retrofit.Builder()
|
||||
.baseUrl("https://maps.googleapis.com/").addConverterFactory(GsonConverterFactory.create(gson))
|
||||
.build()
|
||||
.create(GoogleMapApi.class);
|
||||
|
||||
@GET("maps/api/geocode/json")
|
||||
Call<GoogleMapResponse> getGeoCode(@Query("address") String address, @Query("key") String key);
|
||||
|
||||
@GET("maps/api/geocode/json")
|
||||
Call<GoogleMapResponse> getAddress(@Query("latlng") String LatLng, @Query("key") String key);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.capstone.foodify.shipper.Activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.capstone.foodify.shipper.R;
|
||||
|
||||
public class ChangePasswordActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_change_password);
|
||||
}
|
||||
}
|
||||
@@ -45,10 +45,10 @@ public class MainActivity extends AppCompatActivity {
|
||||
int id = item.getItemId();
|
||||
switch (id) {
|
||||
case R.id.activity_order:
|
||||
viewPager2.setCurrentItem(0);
|
||||
viewPager2.setCurrentItem(0, false);
|
||||
break;
|
||||
case R.id.activity_profile:
|
||||
viewPager2.setCurrentItem(1);
|
||||
viewPager2.setCurrentItem(1, false);
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -2,15 +2,35 @@ package com.capstone.foodify.shipper.Activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.capstone.foodify.shipper.R;
|
||||
|
||||
public class OrderDetailActivity extends AppCompatActivity {
|
||||
|
||||
Button btn_shipping;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_order_detail);
|
||||
|
||||
btn_shipping = findViewById(R.id.btn_shipping);
|
||||
|
||||
btn_shipping.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW,
|
||||
Uri.parse("google.navigation:q=16.0230,108.2498&mode=l"));
|
||||
intent.setPackage("com.google.android.apps.maps");
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,35 +1,303 @@
|
||||
package com.capstone.foodify.shipper.Activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.core.splashscreen.SplashScreen;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.splashscreen.SplashScreen;
|
||||
|
||||
import com.capstone.foodify.shipper.API.FoodApiToken;
|
||||
import com.capstone.foodify.shipper.Common;
|
||||
import com.capstone.foodify.shipper.Model.User;
|
||||
import com.capstone.foodify.shipper.R;
|
||||
import com.google.android.gms.tasks.OnCompleteListener;
|
||||
import com.google.android.gms.tasks.Task;
|
||||
import com.google.android.material.button.MaterialButton;
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
import com.google.firebase.FirebaseApp;
|
||||
import com.google.firebase.auth.AuthResult;
|
||||
import com.google.firebase.auth.FirebaseAuth;
|
||||
import com.google.firebase.auth.FirebaseUser;
|
||||
import com.google.firebase.auth.GetTokenResult;
|
||||
import com.google.firebase.auth.SignInMethodQueryResult;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class SignInActivity extends AppCompatActivity {
|
||||
|
||||
Button btn_sign_in;
|
||||
private FirebaseAuth mAuth;
|
||||
TextInputLayout textInput_email, textInput_password;
|
||||
TextInputEditText edt_email, edt_password;
|
||||
ConstraintLayout progressLayout;
|
||||
String email, password = null;
|
||||
MaterialButton btn_sign_in;
|
||||
private FirebaseUser user;
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
//Get user from Paper
|
||||
// user = Paper.book().read("user");
|
||||
|
||||
// Check if user is signed in (non-null) and update UI accordingly.
|
||||
user = mAuth.getCurrentUser();
|
||||
|
||||
if (user != null && Common.CURRENT_USER == null) {
|
||||
progressLayout.setVisibility(View.VISIBLE);
|
||||
user.getIdToken(true)
|
||||
.addOnCompleteListener(new OnCompleteListener<GetTokenResult>() {
|
||||
@Override
|
||||
public void onComplete(@NonNull Task<GetTokenResult> task) {
|
||||
if (task.isSuccessful()) {
|
||||
Common.TOKEN = task.getResult().getToken();
|
||||
|
||||
//Get user from database
|
||||
FoodApiToken.apiService.getUserFromEmail(user.getEmail()).enqueue(new Callback<User>() {
|
||||
@Override
|
||||
public void onResponse(Call<User> call, Response<User> response) {
|
||||
User userData = response.body();
|
||||
if (userData != null) {
|
||||
Common.CURRENT_USER = userData;
|
||||
startActivity(new Intent(SignInActivity.this, MainActivity.class));
|
||||
|
||||
progressLayout.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<User> call, Throwable t) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Toast.makeText(SignInActivity.this, "Error when taking token!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
SplashScreen.installSplashScreen(this);
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
||||
|
||||
//Init firebase app
|
||||
FirebaseApp.initializeApp(SignInActivity.this);
|
||||
setContentView(R.layout.activity_sign_in);
|
||||
|
||||
// Initialize Firebase Auth
|
||||
mAuth = FirebaseAuth.getInstance();
|
||||
|
||||
//Init Component
|
||||
btn_sign_in = findViewById(R.id.btn_sign_in);
|
||||
initComponent();
|
||||
setFontUI();
|
||||
|
||||
if(Common.CURRENT_USER != null)
|
||||
startActivity(new Intent(this, MainActivity.class));
|
||||
|
||||
btn_sign_in.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(SignInActivity.this, MainActivity.class));
|
||||
initData();
|
||||
|
||||
if(validData()){
|
||||
signIn();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
edt_password.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
textInput_password.setErrorEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void signIn(){
|
||||
progressLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
mAuth.setLanguageCode("vi");
|
||||
|
||||
mAuth.fetchSignInMethodsForEmail(email)
|
||||
.addOnCompleteListener(new OnCompleteListener<SignInMethodQueryResult>() {
|
||||
@Override
|
||||
public void onComplete(@NonNull Task<SignInMethodQueryResult> task) {
|
||||
|
||||
boolean isNewUser = task.getResult().getSignInMethods().isEmpty();
|
||||
|
||||
if (isNewUser) {
|
||||
Toast.makeText(SignInActivity.this, "Tài khoản chưa được đăng ký! Vui lòng đăng ký để tiếp tục sử dụng!", Toast.LENGTH_SHORT).show();
|
||||
progressLayout.setVisibility(View.GONE);
|
||||
} else {
|
||||
signInMethod();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void signInMethod(){
|
||||
mAuth.signInWithEmailAndPassword(email, password)
|
||||
.addOnCompleteListener(SignInActivity.this, new OnCompleteListener<AuthResult>() {
|
||||
@Override
|
||||
public void onComplete(@NonNull Task<AuthResult> task) {
|
||||
if (task.isSuccessful()) {
|
||||
// Sign in success, update UI with the signed-in user's information
|
||||
FirebaseUser user = mAuth.getCurrentUser();
|
||||
|
||||
//Save user
|
||||
// Paper.book().write("user", user);
|
||||
|
||||
user.getIdToken(true)
|
||||
.addOnCompleteListener(new OnCompleteListener<GetTokenResult>() {
|
||||
@Override
|
||||
public void onComplete(@NonNull Task<GetTokenResult> task) {
|
||||
if(task.isSuccessful()){
|
||||
Common.TOKEN = task.getResult().getToken();
|
||||
|
||||
//Get user from database
|
||||
FoodApiToken.apiService.getUserFromEmail(user.getEmail()).enqueue(new Callback<User>() {
|
||||
@Override
|
||||
public void onResponse(Call<User> call, Response<User> response) {
|
||||
if(response.code() == 200){
|
||||
|
||||
User userData = response.body();
|
||||
if(userData != null){
|
||||
|
||||
//Check user is lock or not
|
||||
if(!userData.isLocked()){
|
||||
|
||||
//Check role account
|
||||
if(userData.getRole().getRoleName().equals("ROLE_USER")){
|
||||
Common.CURRENT_USER = userData;
|
||||
|
||||
//Dismiss progress bar
|
||||
progressLayout.setVisibility(View.GONE);
|
||||
|
||||
startActivity(new Intent(SignInActivity.this, MainActivity.class));
|
||||
finish();
|
||||
} else {
|
||||
Toast.makeText(SignInActivity.this, "Tài khoản không hợp lệ! Vui lòng kiểm tra lại!", Toast.LENGTH_SHORT).show();
|
||||
FirebaseAuth.getInstance().signOut();
|
||||
|
||||
//Dismiss progress bar
|
||||
progressLayout.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(SignInActivity.this, "Tài khoản của bạn đã bị khoá!", Toast.LENGTH_SHORT).show();
|
||||
FirebaseAuth.getInstance().signOut();
|
||||
|
||||
//Dismiss progress bar
|
||||
progressLayout.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<User> call, Throwable t) {
|
||||
System.out.println("ERROR: " + t);
|
||||
Common.showErrorServerNotification(SignInActivity.this, "Không thể đăng nhập tài khoản! Vui lòng thử lại sau!");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Toast.makeText(SignInActivity.this, "Error when taking token!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// If sign in fails, display a message to the user.
|
||||
Toast.makeText(SignInActivity.this, "Thông tin đăng nhập không đúng! Vui lòng kiểm tra và thử lại!",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
|
||||
//Dismiss progress bar
|
||||
progressLayout.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initData(){
|
||||
email = edt_email.getText().toString();
|
||||
password = edt_password.getText().toString();
|
||||
}
|
||||
|
||||
private void initComponent(){
|
||||
btn_sign_in = findViewById(R.id.sign_in_button);
|
||||
textInput_email = findViewById(R.id.textInput_email);
|
||||
textInput_password = findViewById(R.id.textInput_password);
|
||||
|
||||
edt_email = findViewById(R.id.edt_email);
|
||||
edt_password = findViewById(R.id.edt_password);
|
||||
|
||||
progressLayout = findViewById(R.id.progress_layout);
|
||||
|
||||
}
|
||||
|
||||
private void setFontUI() {
|
||||
textInput_email.setTypeface(Common.setFontBebas(getAssets()));
|
||||
textInput_password.setTypeface(Common.setFontBebas(getAssets()));
|
||||
}
|
||||
|
||||
private boolean validData(){
|
||||
boolean dataHasValidate = true;
|
||||
|
||||
//Check phone number
|
||||
if(email.isEmpty()){
|
||||
textInput_email.setError("Email không được bỏ trống!");
|
||||
dataHasValidate = false;
|
||||
} else {
|
||||
|
||||
//Check email valid
|
||||
Pattern patternEmail = Pattern.compile(Common.VALID_EMAIL_ADDRESS_REGEX, Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcherEmail = patternEmail.matcher(email);
|
||||
if(!matcherEmail.matches()){
|
||||
textInput_email.setError("Địa chỉ email không đúng định dạng. Xin vui lòng kiểm tra lại!");
|
||||
dataHasValidate = false;
|
||||
} else {
|
||||
textInput_email.setErrorEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
//Check password
|
||||
Pattern patternPassword = Pattern.compile(Common.PASSWORD_PATTERN);
|
||||
Matcher matcherPassword = patternPassword.matcher(edt_password.getText().toString());
|
||||
|
||||
if(!matcherPassword.matches() || edt_password.getText().toString().length() < 8) {
|
||||
textInput_password.setError("Mật khẩu của bạn cần tối thiểu có 8 ký tự, 1 ký tự viết hoa, 1 số và 1 ký tự đặc biệt!");
|
||||
dataHasValidate = false;
|
||||
} else {
|
||||
textInput_password.setErrorEnabled(false);
|
||||
}
|
||||
|
||||
return dataHasValidate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.capstone.foodify.shipper;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.res.AssetManager;
|
||||
import android.graphics.Typeface;
|
||||
import android.location.Location;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.capstone.foodify.shipper.Model.User;
|
||||
import com.thecode.aestheticdialogs.AestheticDialog;
|
||||
import com.thecode.aestheticdialogs.DialogStyle;
|
||||
import com.thecode.aestheticdialogs.DialogType;
|
||||
import com.thecode.aestheticdialogs.OnDialogClickListener;
|
||||
|
||||
public class Common {
|
||||
public static User CURRENT_USER = null;
|
||||
public static String TOKEN = null;
|
||||
public static Location CURRENT_LOCATION = null;
|
||||
public static final String MAP_API = "AIzaSyAY14Ic32UP26Hg6GILznOfbBihiY5BUxw";
|
||||
public static final String IS_FORGOT_PASSWORD = "isForgotPassword";
|
||||
public static final String FORMAT_DATE="dd-MM-yyyy";
|
||||
public static final String VALID_EMAIL_ADDRESS_REGEX = "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$";
|
||||
public static final String PHONE_CODE = "+84";
|
||||
public static final String PASSWORD_PATTERN = "^(?=.*[0-9])(?=.*[A-Z])(?=.*[@#$%^&+=!_])(?=\\S+$).{4,}$";
|
||||
public static final String PHONE_PATTERN = "^0[98753]{1}\\d{8}$";
|
||||
|
||||
public static Typeface setFontBebas(AssetManager assetManager){
|
||||
return Typeface.createFromAsset(assetManager, "font/bebas.ttf");
|
||||
}
|
||||
|
||||
public static Typeface setFontOpenSans(AssetManager assetManager){
|
||||
return Typeface.createFromAsset(assetManager, "font/opensans.ttf");
|
||||
}
|
||||
|
||||
public static void showErrorServerNotification(Activity activity, String message){
|
||||
new AestheticDialog.Builder(activity, DialogStyle.RAINBOW, DialogType.ERROR)
|
||||
.setTitle("LỖI!")
|
||||
.setMessage(message)
|
||||
.setCancelable(false)
|
||||
.setOnClickListener(new OnDialogClickListener() {
|
||||
@Override
|
||||
public void onClick(@NonNull AestheticDialog.Builder builder) {
|
||||
|
||||
activity.finishAffinity();
|
||||
System.exit(0);
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +1,75 @@
|
||||
package com.capstone.foodify.shipper.Fragment;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import android.os.CountDownTimer;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.capstone.foodify.shipper.Activity.ChangePasswordActivity;
|
||||
import com.capstone.foodify.shipper.Common;
|
||||
import com.capstone.foodify.shipper.R;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
import com.google.firebase.auth.FirebaseAuth;
|
||||
import com.google.firebase.auth.FirebaseUser;
|
||||
import com.google.firebase.storage.FirebaseStorage;
|
||||
import com.google.firebase.storage.StorageReference;
|
||||
import com.makeramen.roundedimageview.RoundedImageView;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
public class ProfileFragment extends Fragment {
|
||||
private static final String FOLDER_DIRECTORY = "UserImages/";
|
||||
TextView txt_countdown, txt_resend_code, txt_verify_email;
|
||||
EditText edt_birthday, edt_phone, edt_fullName;
|
||||
Button update_image_button;
|
||||
RoundedImageView profile_avatar;
|
||||
private Uri imageUri;
|
||||
final private StorageReference storageReference = FirebaseStorage.getInstance().getReference();
|
||||
ConstraintLayout progressLayout;
|
||||
|
||||
LinearLayout changePasswordLayout;
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_profile, container, false);
|
||||
View view = inflater.inflate(R.layout.fragment_profile, container, false);
|
||||
|
||||
//Init component
|
||||
initComponent(view);
|
||||
initData();
|
||||
|
||||
//Set event for change password layout
|
||||
changePasswordLayout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(getContext(), ChangePasswordActivity.class));
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void initData(){
|
||||
edt_phone.setText(Common.CURRENT_USER.getPhoneNumber());
|
||||
edt_birthday.setText(Common.CURRENT_USER.getDateOfBirth());
|
||||
edt_fullName.setText(Common.CURRENT_USER.getFullName());
|
||||
}
|
||||
private void initComponent(View view){
|
||||
changePasswordLayout = view.findViewById(R.id.change_password);
|
||||
edt_phone = view.findViewById(R.id.edt_phone);
|
||||
edt_birthday = view.findViewById(R.id.edt_birthDay);
|
||||
edt_fullName = view.findViewById(R.id.edt_fullName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.capstone.foodify.shipper.Model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Address implements Serializable{
|
||||
private int id;
|
||||
private String address;
|
||||
private String ward;
|
||||
private String district;
|
||||
|
||||
public Address(String address, String ward, String district) {
|
||||
this.address = address;
|
||||
this.ward = ward;
|
||||
this.district = district;
|
||||
}
|
||||
|
||||
public Address(){}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getWard() {
|
||||
return ward;
|
||||
}
|
||||
|
||||
public void setWard(String ward) {
|
||||
this.ward = ward;
|
||||
}
|
||||
|
||||
public String getDistrict() {
|
||||
return district;
|
||||
}
|
||||
|
||||
public void setDistrict(String district) {
|
||||
this.district = district;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
|
||||
package com.capstone.foodify.shipper.Model.GoogleMap;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AddressComponent {
|
||||
|
||||
@SerializedName("long_name")
|
||||
@Expose
|
||||
private String longName;
|
||||
@SerializedName("short_name")
|
||||
@Expose
|
||||
private String shortName;
|
||||
@SerializedName("types")
|
||||
@Expose
|
||||
private List<String> types;
|
||||
|
||||
public String getLongName() {
|
||||
return longName;
|
||||
}
|
||||
|
||||
public void setLongName(String longName) {
|
||||
this.longName = longName;
|
||||
}
|
||||
|
||||
public String getShortName() {
|
||||
return shortName;
|
||||
}
|
||||
|
||||
public void setShortName(String shortName) {
|
||||
this.shortName = shortName;
|
||||
}
|
||||
|
||||
public List<String> getTypes() {
|
||||
return types;
|
||||
}
|
||||
|
||||
public void setTypes(List<String> types) {
|
||||
this.types = types;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
|
||||
package com.capstone.foodify.shipper.Model.GoogleMap;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class Geometry {
|
||||
|
||||
@SerializedName("location")
|
||||
@Expose
|
||||
private Location location;
|
||||
@SerializedName("location_type")
|
||||
@Expose
|
||||
private String locationType;
|
||||
@SerializedName("viewport")
|
||||
@Expose
|
||||
private Viewport viewport;
|
||||
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(Location location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public String getLocationType() {
|
||||
return locationType;
|
||||
}
|
||||
|
||||
public void setLocationType(String locationType) {
|
||||
this.locationType = locationType;
|
||||
}
|
||||
|
||||
public Viewport getViewport() {
|
||||
return viewport;
|
||||
}
|
||||
|
||||
public void setViewport(Viewport viewport) {
|
||||
this.viewport = viewport;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
|
||||
package com.capstone.foodify.shipper.Model.GoogleMap;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GoogleMapResponse {
|
||||
|
||||
@SerializedName("results")
|
||||
@Expose
|
||||
private List<Result> results;
|
||||
@SerializedName("status")
|
||||
@Expose
|
||||
private String status;
|
||||
|
||||
public List<Result> getResults() {
|
||||
return results;
|
||||
}
|
||||
|
||||
public void setResults(List<Result> results) {
|
||||
this.results = results;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
|
||||
package com.capstone.foodify.shipper.Model.GoogleMap;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class Location {
|
||||
|
||||
@SerializedName("lat")
|
||||
@Expose
|
||||
private Double lat;
|
||||
@SerializedName("lng")
|
||||
@Expose
|
||||
private Double lng;
|
||||
|
||||
public Double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(Double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public Double getLng() {
|
||||
return lng;
|
||||
}
|
||||
|
||||
public void setLng(Double lng) {
|
||||
this.lng = lng;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
|
||||
package com.capstone.foodify.shipper.Model.GoogleMap;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class Northeast {
|
||||
|
||||
@SerializedName("lat")
|
||||
@Expose
|
||||
private Double lat;
|
||||
@SerializedName("lng")
|
||||
@Expose
|
||||
private Double lng;
|
||||
|
||||
public Double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(Double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public Double getLng() {
|
||||
return lng;
|
||||
}
|
||||
|
||||
public void setLng(Double lng) {
|
||||
this.lng = lng;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
|
||||
package com.capstone.foodify.shipper.Model.GoogleMap;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Result {
|
||||
|
||||
@SerializedName("address_components")
|
||||
@Expose
|
||||
private List<AddressComponent> addressComponents;
|
||||
@SerializedName("formatted_address")
|
||||
@Expose
|
||||
private String formattedAddress;
|
||||
@SerializedName("geometry")
|
||||
@Expose
|
||||
private Geometry geometry;
|
||||
@SerializedName("place_id")
|
||||
@Expose
|
||||
private String placeId;
|
||||
@SerializedName("types")
|
||||
@Expose
|
||||
private List<String> types;
|
||||
|
||||
public List<AddressComponent> getAddressComponents() {
|
||||
return addressComponents;
|
||||
}
|
||||
|
||||
public void setAddressComponents(List<AddressComponent> addressComponents) {
|
||||
this.addressComponents = addressComponents;
|
||||
}
|
||||
|
||||
public String getFormattedAddress() {
|
||||
return formattedAddress;
|
||||
}
|
||||
|
||||
public void setFormattedAddress(String formattedAddress) {
|
||||
this.formattedAddress = formattedAddress;
|
||||
}
|
||||
|
||||
public Geometry getGeometry() {
|
||||
return geometry;
|
||||
}
|
||||
|
||||
public void setGeometry(Geometry geometry) {
|
||||
this.geometry = geometry;
|
||||
}
|
||||
|
||||
public String getPlaceId() {
|
||||
return placeId;
|
||||
}
|
||||
|
||||
public void setPlaceId(String placeId) {
|
||||
this.placeId = placeId;
|
||||
}
|
||||
|
||||
public List<String> getTypes() {
|
||||
return types;
|
||||
}
|
||||
|
||||
public void setTypes(List<String> types) {
|
||||
this.types = types;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
|
||||
package com.capstone.foodify.shipper.Model.GoogleMap;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class Southwest {
|
||||
|
||||
@SerializedName("lat")
|
||||
@Expose
|
||||
private Double lat;
|
||||
@SerializedName("lng")
|
||||
@Expose
|
||||
private Double lng;
|
||||
|
||||
public Double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(Double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public Double getLng() {
|
||||
return lng;
|
||||
}
|
||||
|
||||
public void setLng(Double lng) {
|
||||
this.lng = lng;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
|
||||
package com.capstone.foodify.shipper.Model.GoogleMap;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class Viewport {
|
||||
|
||||
@SerializedName("northeast")
|
||||
@Expose
|
||||
private Northeast northeast;
|
||||
@SerializedName("southwest")
|
||||
@Expose
|
||||
private Southwest southwest;
|
||||
|
||||
public Northeast getNortheast() {
|
||||
return northeast;
|
||||
}
|
||||
|
||||
public void setNortheast(Northeast northeast) {
|
||||
this.northeast = northeast;
|
||||
}
|
||||
|
||||
public Southwest getSouthwest() {
|
||||
return southwest;
|
||||
}
|
||||
|
||||
public void setSouthwest(Southwest southwest) {
|
||||
this.southwest = southwest;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.capstone.foodify.shipper.Model;
|
||||
|
||||
public class Role {
|
||||
private int id;
|
||||
private String roleName;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.capstone.foodify.shipper.Model;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class User implements Serializable {
|
||||
private int id;
|
||||
@SerializedName("addressDto")
|
||||
private Address address;
|
||||
private String dateOfBirth;
|
||||
private String email;
|
||||
private String fullName;
|
||||
private String identifiedCode;
|
||||
private String imageUrl;
|
||||
private boolean isLocked;
|
||||
private String phoneNumber;
|
||||
private String roleName;
|
||||
private Role role;
|
||||
private int defaultAddress;
|
||||
private List<Address> addresses;
|
||||
|
||||
public User(Address address, String dateOfBirth, String email, String fullName, String identifiedCode, String phoneNumber) {
|
||||
this.address = address;
|
||||
this.dateOfBirth = dateOfBirth;
|
||||
this.email = email;
|
||||
this.fullName = fullName;
|
||||
this.identifiedCode = identifiedCode;
|
||||
this.imageUrl = "";
|
||||
this.phoneNumber = phoneNumber;
|
||||
this.roleName = "ROLE_USER";
|
||||
this.isLocked = false;
|
||||
}
|
||||
|
||||
public User(){}
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Address getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(Address address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public boolean isLocked() {
|
||||
return isLocked;
|
||||
}
|
||||
|
||||
public void setLocked(boolean locked) {
|
||||
isLocked = locked;
|
||||
}
|
||||
|
||||
public String getDateOfBirth() {
|
||||
return dateOfBirth;
|
||||
}
|
||||
|
||||
public void setDateOfBirth(String dateOfBirth) {
|
||||
this.dateOfBirth = dateOfBirth;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public String getIdentifiedCode() {
|
||||
return identifiedCode;
|
||||
}
|
||||
|
||||
public void setIdentifiedCode(String identifiedCode) {
|
||||
this.identifiedCode = identifiedCode;
|
||||
}
|
||||
|
||||
public String getImageUrl() {
|
||||
return imageUrl;
|
||||
}
|
||||
|
||||
public void setImageUrl(String imageUrl) {
|
||||
this.imageUrl = imageUrl;
|
||||
}
|
||||
|
||||
public String getPhoneNumber() {
|
||||
return phoneNumber;
|
||||
}
|
||||
|
||||
public void setPhoneNumber(String phoneNumber) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
public List<Address> getAddresses() {
|
||||
return addresses;
|
||||
}
|
||||
|
||||
public int getDefaultAddress() {
|
||||
return defaultAddress;
|
||||
}
|
||||
|
||||
public void setDefaultAddress(int defaultAddress) {
|
||||
this.defaultAddress = defaultAddress;
|
||||
}
|
||||
|
||||
public void setAddresses(List<Address> addresses) {
|
||||
this.addresses = addresses;
|
||||
}
|
||||
|
||||
public Role getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(Role role) {
|
||||
this.role = role;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
<?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=".Activity.ChangePasswordActivity">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clickable="false"
|
||||
>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back_image"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="5dp"
|
||||
android:padding="8dp"
|
||||
android:src="@drawable/back_button"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginTop="40dp"
|
||||
android:fontFamily="@font/bebas"
|
||||
android:text="Thay đổi mật khẩu"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="40sp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/back_image" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:id="@+id/layout_change_password"
|
||||
>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/textInput_old_password"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:hint="Mật khẩu cũ"
|
||||
app:boxBackgroundColor="@color/white"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/textInput_password"
|
||||
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_old_password"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:inputType="textPassword" />
|
||||
|
||||
</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="wrap_content"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:hint="Mật khẩu mới"
|
||||
app:boxBackgroundColor="@color/white"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/textInput_password_confirm"
|
||||
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>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/textInput_password_confirm"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:hint="Xác nhận mật khẩu"
|
||||
app:boxBackgroundColor="@color/white"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
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_confirmPassword"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:inputType="textPassword" />
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/change_password_button"
|
||||
style="@style/DefaultSolid"
|
||||
android:fontFamily="@font/bebas"
|
||||
android:text="Thay đổi mật khẩu"
|
||||
android:textSize="20sp"
|
||||
android:padding="10dp"
|
||||
android:layout_marginTop="80dp"
|
||||
android:layout_marginStart="40dp"
|
||||
android:layout_marginEnd="40dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@+id/layout_change_password"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#80000000"
|
||||
android:id="@+id/progress_layout"
|
||||
android:visibility="gone"
|
||||
android:clickable="true"
|
||||
>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBarLoadData"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:indeterminateTint="@color/primaryColor"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -119,7 +119,7 @@
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/btn_sign_in"
|
||||
android:id="@+id/sign_in_button"
|
||||
android:text="Đăng nhập"
|
||||
android:textSize="20sp"
|
||||
android:fontFamily="@font/bebas"
|
||||
@@ -138,4 +138,26 @@
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#80000000"
|
||||
android:id="@+id/progress_layout"
|
||||
android:visibility="gone"
|
||||
android:clickable="true"
|
||||
>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBarLoadData"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:indeterminateTint="@color/primaryColor"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -52,29 +52,6 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
/>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/textInput_email"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="20dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:hint="Email"
|
||||
app:boxBackgroundColor="@color/white"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/textInput_phone"
|
||||
app:startIconDrawable="@drawable/baseline_email_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="textEmailAddress"
|
||||
android:enabled="false"
|
||||
/>
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/textInput_phone"
|
||||
@@ -119,6 +96,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:inputType="text"
|
||||
android:enabled="false"
|
||||
/>
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
@@ -142,7 +120,7 @@
|
||||
android:id="@+id/edt_birthDay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clickable="false"
|
||||
android:enabled="false"
|
||||
android:cursorVisible="false"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"
|
||||
@@ -157,9 +135,9 @@
|
||||
android:layout_marginBottom="30dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/updated_button"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
|
||||
@@ -194,22 +172,6 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/updated_button"
|
||||
style="@style/DefaultSolid"
|
||||
android:fontFamily="@font/bebas"
|
||||
android:text="Cập nhật"
|
||||
android:textSize="20sp"
|
||||
android:padding="10dp"
|
||||
android:layout_marginStart="40dp"
|
||||
android:layout_marginEnd="40dp"
|
||||
android:layout_marginBottom="17dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
||||
@@ -10,6 +10,8 @@ dependencyResolutionManagement {
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
mavenCentral()
|
||||
maven { url 'https://jitpack.io' }
|
||||
}
|
||||
}
|
||||
rootProject.name = "Foodify Shipper"
|
||||
|
||||
Reference in New Issue
Block a user