mirror of
https://github.com/Nezumi-2711/Foodify.git
synced 2026-09-22 13:38:41 +00:00
Add detect location from device
This commit is contained in:
@@ -51,6 +51,7 @@ dependencies {
|
|||||||
implementation 'com.google.android.gms:play-services-auth:20.4.1'
|
implementation 'com.google.android.gms:play-services-auth:20.4.1'
|
||||||
implementation 'com.google.android.gms:play-services-auth-api-phone:18.0.1'
|
implementation 'com.google.android.gms:play-services-auth-api-phone:18.0.1'
|
||||||
implementation 'com.google.android.gms:play-services-maps:18.1.0'
|
implementation 'com.google.android.gms:play-services-maps:18.1.0'
|
||||||
|
implementation 'com.google.android.gms:play-services-location:21.0.1'
|
||||||
implementation files('libs/zpdk-release-v3.1.aar')
|
implementation files('libs/zpdk-release-v3.1.aar')
|
||||||
|
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
|
|||||||
@@ -34,10 +34,10 @@ public interface FoodApi {
|
|||||||
.build()
|
.build()
|
||||||
.create(FoodApi.class);
|
.create(FoodApi.class);
|
||||||
|
|
||||||
@GET("products?pageNo=0&pageSize=10&sortBy=id&sortDir=asc")
|
@GET("products/enable?pageNo=0&pageSize=10&sortBy=id&sortDir=asc")
|
||||||
Call<Foods> recommendFood();
|
Call<Foods> recommendFood();
|
||||||
|
|
||||||
@GET("products?pageNo=0&pageSize=10&sortBy=createdTime&sortDir=desc")
|
@GET("products/enable?pageNo=0&pageSize=10&sortBy=createdTime&sortDir=desc")
|
||||||
Call<Foods> recentFood();
|
Call<Foods> recentFood();
|
||||||
|
|
||||||
@GET("shops?pageNo=0&pageSize=10&sortBy=id&sortDir=asc")
|
@GET("shops?pageNo=0&pageSize=10&sortBy=id&sortDir=asc")
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import static com.capstone.foodify.Common.TOKEN;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.capstone.foodify.Model.Address;
|
import com.capstone.foodify.Model.Address;
|
||||||
|
import com.capstone.foodify.Model.Comment;
|
||||||
import com.capstone.foodify.Model.Food;
|
import com.capstone.foodify.Model.Food;
|
||||||
import com.capstone.foodify.Model.Order;
|
import com.capstone.foodify.Model.Order;
|
||||||
import com.capstone.foodify.Model.Response.Addresses;
|
import com.capstone.foodify.Model.Response.Addresses;
|
||||||
@@ -82,4 +83,10 @@ public interface FoodApiToken {
|
|||||||
|
|
||||||
@POST("user/{userId}/orders")
|
@POST("user/{userId}/orders")
|
||||||
Call<Order> createOrder(@Path("userId") int userId, @Body Order order);
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,13 @@ public class ChangePasswordActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
textInput_password.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onFocusChange(View v, boolean hasFocus) {
|
||||||
|
textInput_password.setErrorEnabled(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean validateData(){
|
private boolean validateData(){
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ import retrofit2.Callback;
|
|||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
|
|
||||||
public class FoodDetailActivity extends AppCompatActivity {
|
public class FoodDetailActivity extends AppCompatActivity {
|
||||||
|
private static final int ACTION_CODE = 0;
|
||||||
|
private static final int CREATE_COMMENT = 1;
|
||||||
|
private static final int EDIT_COMMENT = 2;
|
||||||
private static int CURRENT_PAGE = 0;
|
private static int CURRENT_PAGE = 0;
|
||||||
private static final int PAGE_SIZE = 8;
|
private static final int PAGE_SIZE = 8;
|
||||||
private static final String SORT_BY = "id";
|
private static final String SORT_BY = "id";
|
||||||
@@ -59,17 +62,18 @@ public class FoodDetailActivity extends AppCompatActivity {
|
|||||||
private static boolean LAST_PAGE;
|
private static boolean LAST_PAGE;
|
||||||
private HorizontalQuantitizer horizontalQuantitizer;
|
private HorizontalQuantitizer horizontalQuantitizer;
|
||||||
private ImageSlider imageSlider;
|
private ImageSlider imageSlider;
|
||||||
private ImageView back_image, not_favorite, is_favorite;
|
private ImageView back_image, not_favorite, is_favorite, delete_button;
|
||||||
private String foodId = "";
|
private String foodId = "";
|
||||||
private Food food;
|
private Food food;
|
||||||
private TextView foodName_txt, shopName_txt, discount_txt, price_txt, countRating_txt, description_content_txt, endOfListText;
|
private TextView foodName_txt, shopName_txt, discount_txt, price_txt, countRating_txt, description_content_txt, endOfListText,
|
||||||
|
userNameComment, contentComment;
|
||||||
private ConstraintLayout content_view;
|
private ConstraintLayout content_view;
|
||||||
private Button add_to_basket_button;
|
private Button add_to_basket_button;
|
||||||
private float totalPrice, price;
|
private float totalPrice, price;
|
||||||
private RecyclerView recyclerView_comment;
|
private RecyclerView recyclerView_comment;
|
||||||
private CommentAdapter commentAdapter;
|
private CommentAdapter commentAdapter;
|
||||||
private Button rating_button;
|
private Button rating_button;
|
||||||
private ScaleRatingBar ratingBar;
|
private ScaleRatingBar ratingBar, ratingBarComment;
|
||||||
private ConstraintLayout progressLayout;
|
private ConstraintLayout progressLayout;
|
||||||
private NestedScrollView nestedScrollView;
|
private NestedScrollView nestedScrollView;
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
@@ -101,6 +105,11 @@ public class FoodDetailActivity extends AppCompatActivity {
|
|||||||
endOfListText = findViewById(R.id.end_of_list_text);
|
endOfListText = findViewById(R.id.end_of_list_text);
|
||||||
progressBar = findViewById(R.id.progress_bar);
|
progressBar = findViewById(R.id.progress_bar);
|
||||||
ratingBar = findViewById(R.id.rating_bar);
|
ratingBar = findViewById(R.id.rating_bar);
|
||||||
|
userNameComment = findViewById(R.id.user_name_text_view);
|
||||||
|
contentComment = findViewById(R.id.comment_user);
|
||||||
|
ratingBarComment = findViewById(R.id.rating_bar_comment);
|
||||||
|
delete_button = findViewById(R.id.delete_button);
|
||||||
|
|
||||||
|
|
||||||
commentAdapter = new CommentAdapter(this);
|
commentAdapter = new CommentAdapter(this);
|
||||||
|
|
||||||
@@ -161,7 +170,7 @@ public class FoodDetailActivity extends AppCompatActivity {
|
|||||||
rating_button.setOnClickListener(new View.OnClickListener() {
|
rating_button.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
openCommentDialog(Gravity.CENTER);
|
openCommentDialog(Gravity.CENTER, CREATE_COMMENT);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -209,6 +218,14 @@ public class FoodDetailActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Delete comment
|
||||||
|
delete_button.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void isFavoriteIcon(){
|
private void isFavoriteIcon(){
|
||||||
@@ -308,6 +325,23 @@ public class FoodDetailActivity extends AppCompatActivity {
|
|||||||
endOfListText.setVisibility(View.VISIBLE);
|
endOfListText.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Get user's comment
|
||||||
|
for(Comment tempComment: listComment){
|
||||||
|
if(tempComment.getUser().getEmail().equals(Common.CURRENT_USER.getEmail())){
|
||||||
|
//Init data comment
|
||||||
|
userNameComment.setText(Common.CURRENT_USER.getFullName());
|
||||||
|
ratingBarComment.setRating(tempComment.getRating());
|
||||||
|
contentComment.setText(tempComment.getContent());
|
||||||
|
|
||||||
|
//Remove comment from list
|
||||||
|
listComment.remove(tempComment);
|
||||||
|
|
||||||
|
//Remove button comment
|
||||||
|
rating_button.setVisibility(View.GONE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(listComment.size() == 0)
|
if(listComment.size() == 0)
|
||||||
endOfListText.setVisibility(View.GONE);
|
endOfListText.setVisibility(View.GONE);
|
||||||
|
|
||||||
@@ -431,10 +465,14 @@ public class FoodDetailActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openCommentDialog(int gravity){
|
private void openCommentDialog(int gravity, int actionCode){
|
||||||
final Dialog dialog = new Dialog(this);
|
final Dialog dialog = new Dialog(this);
|
||||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
dialog.setContentView(R.layout.dialog_comment);
|
if(actionCode == CREATE_COMMENT){
|
||||||
|
dialog.setContentView(R.layout.dialog_comment);
|
||||||
|
} else if(actionCode == EDIT_COMMENT) {
|
||||||
|
dialog.setContentView(R.layout.dialog_comment_edit_delete);
|
||||||
|
}
|
||||||
|
|
||||||
Window window = dialog.getWindow();
|
Window window = dialog.getWindow();
|
||||||
if(window == null)
|
if(window == null)
|
||||||
@@ -458,6 +496,13 @@ public class FoodDetailActivity extends AppCompatActivity {
|
|||||||
Button confirm = dialog.findViewById(R.id.confirm_button);
|
Button confirm = dialog.findViewById(R.id.confirm_button);
|
||||||
Button cancel = dialog.findViewById(R.id.cancel_button);
|
Button cancel = dialog.findViewById(R.id.cancel_button);
|
||||||
|
|
||||||
|
if(actionCode == EDIT_COMMENT){
|
||||||
|
//TODO Edit comment
|
||||||
|
//Init data
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
cancel.setOnClickListener(new View.OnClickListener() {
|
cancel.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
@@ -465,11 +510,42 @@ public class FoodDetailActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//TODO: Update comment dialog
|
|
||||||
|
|
||||||
|
confirm.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
if(actionCode == CREATE_COMMENT){
|
||||||
|
//Create comment
|
||||||
|
Comment comment = new Comment(comment_content.getText().toString(), ratingBar.getRating(), Common.CURRENT_USER.getId());
|
||||||
|
FoodApiToken.apiService.createComment(Integer.parseInt(foodId), comment).enqueue(new Callback<Comment>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<Comment> call, Response<Comment> response) {
|
||||||
|
if(response.code() == 201){
|
||||||
|
Toast.makeText(FoodDetailActivity.this, "Đã thêm bình luận thành công!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<Comment> call, Throwable t) {
|
||||||
|
Toast.makeText(FoodDetailActivity.this, "Đã xuất hiện lỗi hệ thống!", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if(actionCode == EDIT_COMMENT){
|
||||||
|
//Edit comment
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void deleteComment(){
|
||||||
|
//TODO Delete comment
|
||||||
|
}
|
||||||
private void dataLoadMore() {
|
private void dataLoadMore() {
|
||||||
if(!LAST_PAGE){
|
if(!LAST_PAGE){
|
||||||
getListComment(++CURRENT_PAGE);
|
getListComment(++CURRENT_PAGE);
|
||||||
|
|||||||
@@ -1,12 +1,25 @@
|
|||||||
package com.capstone.foodify.Activity;
|
package com.capstone.foodify.Activity;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.IntentSender;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.location.Location;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.provider.Settings;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatDelegate;
|
import androidx.appcompat.app.AppCompatDelegate;
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.core.splashscreen.SplashScreen;
|
import androidx.core.splashscreen.SplashScreen;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@@ -14,12 +27,28 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||||||
import androidx.viewpager2.widget.ViewPager2;
|
import androidx.viewpager2.widget.ViewPager2;
|
||||||
|
|
||||||
import com.capstone.foodify.API.FoodApiToken;
|
import com.capstone.foodify.API.FoodApiToken;
|
||||||
|
import com.capstone.foodify.BuildConfig;
|
||||||
import com.capstone.foodify.Common;
|
import com.capstone.foodify.Common;
|
||||||
import com.capstone.foodify.Fragment.HomeFragment;
|
import com.capstone.foodify.Fragment.HomeFragment;
|
||||||
import com.capstone.foodify.Model.User;
|
import com.capstone.foodify.Model.User;
|
||||||
import com.capstone.foodify.R;
|
import com.capstone.foodify.R;
|
||||||
import com.capstone.foodify.ViewPagerAdapter;
|
import com.capstone.foodify.ViewPagerAdapter;
|
||||||
|
import com.google.android.gms.common.api.ApiException;
|
||||||
|
import com.google.android.gms.common.api.ResolvableApiException;
|
||||||
|
import com.google.android.gms.location.FusedLocationProviderClient;
|
||||||
|
import com.google.android.gms.location.LocationCallback;
|
||||||
|
import com.google.android.gms.location.LocationRequest;
|
||||||
|
import com.google.android.gms.location.LocationResult;
|
||||||
|
import com.google.android.gms.location.LocationServices;
|
||||||
|
import com.google.android.gms.location.LocationSettingsRequest;
|
||||||
|
import com.google.android.gms.location.LocationSettingsResponse;
|
||||||
|
import com.google.android.gms.location.LocationSettingsStatusCodes;
|
||||||
|
import com.google.android.gms.location.Priority;
|
||||||
|
import com.google.android.gms.location.SettingsClient;
|
||||||
|
import com.google.android.gms.maps.model.LatLng;
|
||||||
import com.google.android.gms.tasks.OnCompleteListener;
|
import com.google.android.gms.tasks.OnCompleteListener;
|
||||||
|
import com.google.android.gms.tasks.OnFailureListener;
|
||||||
|
import com.google.android.gms.tasks.OnSuccessListener;
|
||||||
import com.google.android.gms.tasks.Task;
|
import com.google.android.gms.tasks.Task;
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||||
import com.google.android.material.navigation.NavigationBarView;
|
import com.google.android.material.navigation.NavigationBarView;
|
||||||
@@ -27,6 +56,8 @@ import com.google.firebase.auth.FirebaseAuth;
|
|||||||
import com.google.firebase.auth.FirebaseUser;
|
import com.google.firebase.auth.FirebaseUser;
|
||||||
import com.google.firebase.auth.GetTokenResult;
|
import com.google.firebase.auth.GetTokenResult;
|
||||||
|
|
||||||
|
import org.objectweb.asm.Handle;
|
||||||
|
|
||||||
import io.paperdb.Paper;
|
import io.paperdb.Paper;
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
@@ -39,6 +70,23 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
BottomNavigationView bottomNavigationView;
|
BottomNavigationView bottomNavigationView;
|
||||||
private FirebaseAuth mAuth;
|
private FirebaseAuth mAuth;
|
||||||
private FirebaseUser user;
|
private FirebaseUser user;
|
||||||
|
|
||||||
|
//Location
|
||||||
|
private static final int REQUEST_CHECK_SETTINGS = 100;
|
||||||
|
private static final long UPDATE_INTERVAL_IN_MILLISECONDS = 1000;
|
||||||
|
private static final long FASTEST_UPDATE_IN_MILLISECONDS = 3000;
|
||||||
|
private static final long MAX_WAIT_TIME_IN_MILLISECONDS = 1000;
|
||||||
|
private static final int LOCATION_REQUEST_CODE = 100;
|
||||||
|
private static final String TAG = MainActivity.class.getSimpleName();
|
||||||
|
|
||||||
|
private FusedLocationProviderClient mFusedLocationClient;
|
||||||
|
private SettingsClient mSettingsClient;
|
||||||
|
private LocationRequest mLocationRequest;
|
||||||
|
private LocationSettingsRequest mLocationSettingsRequest;
|
||||||
|
private LocationCallback mLocationCallBack;
|
||||||
|
private Location mCurrentLocation;
|
||||||
|
private boolean mRequestingLocationUpdates = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
@@ -49,12 +97,12 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
// Check if user is signed in (non-null) and update UI accordingly.
|
// Check if user is signed in (non-null) and update UI accordingly.
|
||||||
user = mAuth.getCurrentUser();
|
user = mAuth.getCurrentUser();
|
||||||
|
|
||||||
if(user != null && Common.CURRENT_USER == null){
|
if (user != null && Common.CURRENT_USER == null) {
|
||||||
user.getIdToken(true)
|
user.getIdToken(true)
|
||||||
.addOnCompleteListener(new OnCompleteListener<GetTokenResult>() {
|
.addOnCompleteListener(new OnCompleteListener<GetTokenResult>() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(@NonNull Task<GetTokenResult> task) {
|
public void onComplete(@NonNull Task<GetTokenResult> task) {
|
||||||
if(task.isSuccessful()){
|
if (task.isSuccessful()) {
|
||||||
Common.TOKEN = task.getResult().getToken();
|
Common.TOKEN = task.getResult().getToken();
|
||||||
|
|
||||||
//Get user from database
|
//Get user from database
|
||||||
@@ -62,7 +110,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<User> call, Response<User> response) {
|
public void onResponse(Call<User> call, Response<User> response) {
|
||||||
User userData = response.body();
|
User userData = response.body();
|
||||||
if(userData != null){
|
if (userData != null) {
|
||||||
Common.CURRENT_USER = userData;
|
Common.CURRENT_USER = userData;
|
||||||
HomeFragment.setNameUser();
|
HomeFragment.setNameUser();
|
||||||
}
|
}
|
||||||
@@ -79,6 +127,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -95,8 +144,52 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
initComponent();
|
initComponent();
|
||||||
|
|
||||||
bottomNavigation();
|
bottomNavigation();
|
||||||
|
|
||||||
|
|
||||||
|
if (Common.CURRENT_LOCATION == null) {
|
||||||
|
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
|
||||||
|
mSettingsClient = LocationServices.getSettingsClient(this);
|
||||||
|
|
||||||
|
mLocationCallBack = new LocationCallback() {
|
||||||
|
@Override
|
||||||
|
public void onLocationResult(@NonNull LocationResult locationResult) {
|
||||||
|
super.onLocationResult(locationResult);
|
||||||
|
mCurrentLocation = locationResult.getLastLocation();
|
||||||
|
Common.CURRENT_LOCATION = mCurrentLocation;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
mLocationRequest = new LocationRequest.Builder(Priority.PRIORITY_HIGH_ACCURACY, UPDATE_INTERVAL_IN_MILLISECONDS)
|
||||||
|
.setWaitForAccurateLocation(false)
|
||||||
|
.setMinUpdateDistanceMeters(FASTEST_UPDATE_IN_MILLISECONDS)
|
||||||
|
.setMaxUpdateDelayMillis(MAX_WAIT_TIME_IN_MILLISECONDS)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder();
|
||||||
|
builder.addLocationRequest(mLocationRequest);
|
||||||
|
mLocationSettingsRequest = builder.build();
|
||||||
|
|
||||||
|
checkLocationPermission();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Init location user
|
||||||
|
final Handler handler = new Handler();
|
||||||
|
handler.postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if(mCurrentLocation != null){
|
||||||
|
Common.CURRENT_LOCATION = mCurrentLocation;
|
||||||
|
stopLocationUpdates();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void initComponent() {
|
private void initComponent() {
|
||||||
bottomNavigationView = findViewById(R.id.bottom_nav);
|
bottomNavigationView = findViewById(R.id.bottom_nav);
|
||||||
viewPager2 = findViewById(R.id.viewPager);
|
viewPager2 = findViewById(R.id.viewPager);
|
||||||
@@ -160,4 +253,127 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Location
|
||||||
|
private void checkLocationPermission(){
|
||||||
|
if(ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
|
||||||
|
ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED){
|
||||||
|
|
||||||
|
requestForPermission();
|
||||||
|
|
||||||
|
}else {
|
||||||
|
//Get location
|
||||||
|
mRequestingLocationUpdates = true;
|
||||||
|
startLocationUpdates();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void requestForPermission() {
|
||||||
|
ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}, LOCATION_REQUEST_CODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||||
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
|
||||||
|
if(requestCode == LOCATION_REQUEST_CODE){
|
||||||
|
if(grantResults[0] == PackageManager.PERMISSION_GRANTED){
|
||||||
|
Toast.makeText(this, "Đã cấp quyền thành công!", Toast.LENGTH_SHORT).show();
|
||||||
|
} else {
|
||||||
|
showDialogPermission();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showDialogPermission() {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
|
|
||||||
|
builder.setMessage("Hãy cho ứng dụng truy cập vào vị trí của bạn để trải nghiệm tốt hơn!")
|
||||||
|
.setCancelable(false)
|
||||||
|
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
openSettings();
|
||||||
|
dialog.cancel();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton("Để sau", new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
dialog.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AlertDialog alertDialog = builder.create();
|
||||||
|
alertDialog.setTitle("Thông báo!");
|
||||||
|
alertDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openSettings() {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
||||||
|
Uri uri = Uri.fromParts("package", BuildConfig.APPLICATION_ID, null);
|
||||||
|
intent.setData(uri);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startLocationUpdates() {
|
||||||
|
mSettingsClient.checkLocationSettings(mLocationSettingsRequest).addOnSuccessListener(this, new OnSuccessListener<LocationSettingsResponse>() {
|
||||||
|
@SuppressLint("MissingPermission")
|
||||||
|
@Override
|
||||||
|
public void onSuccess(LocationSettingsResponse locationSettingsResponse) {
|
||||||
|
mFusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallBack, Looper.myLooper());
|
||||||
|
|
||||||
|
}
|
||||||
|
}).addOnFailureListener(this, new OnFailureListener() {
|
||||||
|
@Override
|
||||||
|
public void onFailure(@NonNull Exception e) {
|
||||||
|
int statusCode = ((ApiException) e).getStatusCode();
|
||||||
|
switch (statusCode) {
|
||||||
|
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
|
||||||
|
Log.i(TAG, "Location settings are not satisfied. Attempting to upgrade location settings");
|
||||||
|
|
||||||
|
try {
|
||||||
|
ResolvableApiException rae = (ResolvableApiException) e;
|
||||||
|
rae.startResolutionForResult(MainActivity.this, REQUEST_CHECK_SETTINGS);
|
||||||
|
} catch (IntentSender.SendIntentException sie) {
|
||||||
|
Log.i(TAG, "PendingIntent unable to execute request");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
|
||||||
|
String errorMessage = "Location settings are inadequate, and cannot be fixed here. Fix in Settings";
|
||||||
|
Log.e(TAG, errorMessage);
|
||||||
|
|
||||||
|
Toast.makeText(MainActivity.this, errorMessage, Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopLocationUpdates() {
|
||||||
|
mFusedLocationClient.removeLocationUpdates(mLocationCallBack).addOnCompleteListener(this, task -> Log.d(TAG, "Location updates stopped!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkPermission() {
|
||||||
|
int permissionState = ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION);
|
||||||
|
return permissionState == PackageManager.PERMISSION_GRANTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
if (mRequestingLocationUpdates && checkPermission() && Common.CURRENT_LOCATION == null) {
|
||||||
|
startLocationUpdates();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
if (mRequestingLocationUpdates) {
|
||||||
|
stopLocationUpdates();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,13 @@
|
|||||||
package com.capstone.foodify.Activity;
|
package com.capstone.foodify.Activity;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
|
import android.location.Geocoder;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.StrictMode;
|
import android.os.StrictMode;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
@@ -27,19 +25,17 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
import androidx.core.widget.NestedScrollView;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.capstone.foodify.API.FoodApi;
|
import com.capstone.foodify.API.FoodApi;
|
||||||
import com.capstone.foodify.API.FoodApiToken;
|
|
||||||
import com.capstone.foodify.API.GoogleMapApi;
|
import com.capstone.foodify.API.GoogleMapApi;
|
||||||
import com.capstone.foodify.Adapter.OrderDetailAdapter;
|
import com.capstone.foodify.Adapter.OrderDetailAdapter;
|
||||||
import com.capstone.foodify.Common;
|
import com.capstone.foodify.Common;
|
||||||
import com.capstone.foodify.Model.Address;
|
import com.capstone.foodify.Model.Address;
|
||||||
import com.capstone.foodify.Model.DistrictWardResponse;
|
import com.capstone.foodify.Model.DistrictWardResponse;
|
||||||
import com.capstone.foodify.Model.GoogleMap.GoogleMapResponse;
|
import com.capstone.foodify.Model.GoogleMap.GoogleMapResponse;
|
||||||
import com.capstone.foodify.Model.Order;
|
import com.capstone.foodify.Model.GoogleMap.Location;
|
||||||
import com.capstone.foodify.R;
|
import com.capstone.foodify.R;
|
||||||
import com.capstone.foodify.ZaloPay.Api.CreateOrder;
|
import com.capstone.foodify.ZaloPay.Api.CreateOrder;
|
||||||
import com.google.android.gms.maps.model.LatLng;
|
import com.google.android.gms.maps.model.LatLng;
|
||||||
@@ -52,9 +48,11 @@ import com.thecode.aestheticdialogs.OnDialogClickListener;
|
|||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
@@ -179,7 +177,8 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
if(radio_button_selected == auto_detect_location){
|
if(radio_button_selected == auto_detect_location){
|
||||||
//Action 2
|
//Action 2
|
||||||
|
if(Common.CURRENT_LOCATION != null)
|
||||||
|
finalAddress = getAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(radio_button_selected == manual_input_address){
|
if(radio_button_selected == manual_input_address){
|
||||||
@@ -223,6 +222,23 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
|||||||
initZaloPaymentMethod();
|
initZaloPaymentMethod();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getAddress() {
|
||||||
|
Geocoder geocoder = new Geocoder(OrderCheckOutActivity.this, Locale.getDefault());
|
||||||
|
android.location.Address tempAddress;
|
||||||
|
|
||||||
|
try {
|
||||||
|
List<android.location.Address> addresses = geocoder.getFromLocation(Common.CURRENT_LOCATION.getLatitude(), Common.CURRENT_LOCATION.getLongitude(), 1);
|
||||||
|
tempAddress = addresses.get(0);
|
||||||
|
edt_address_detect.setText(tempAddress.getAddressLine(0));
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tempAddress.getAddressLine(0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void initZaloPaymentMethod(){
|
private void initZaloPaymentMethod(){
|
||||||
// handle CreateOrder
|
// handle CreateOrder
|
||||||
btn_ZaloPay.setOnClickListener(new View.OnClickListener() {
|
btn_ZaloPay.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
@@ -159,6 +161,40 @@ public class SignUpActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
edt_confirmPassword.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_confirmPassword.setErrorEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkEmailOrPhoneExist(){
|
private void checkEmailOrPhoneExist(){
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
|
import android.location.Location;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkCapabilities;
|
import android.net.NetworkCapabilities;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
@@ -38,6 +39,7 @@ import retrofit2.Callback;
|
|||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
|
|
||||||
public class Common {
|
public class Common {
|
||||||
|
public static Location CURRENT_LOCATION = null;
|
||||||
public static final String MAP_API = "AIzaSyCR46ZE1kbE7zkTehhflB9jZgDjDT_2944";
|
public static final String MAP_API = "AIzaSyCR46ZE1kbE7zkTehhflB9jZgDjDT_2944";
|
||||||
public static final String IS_FORGOT_PASSWORD = "isForgotPassword";
|
public static final String IS_FORGOT_PASSWORD = "isForgotPassword";
|
||||||
public static final String FORMAT_DATE="dd-MM-yyyy";
|
public static final String FORMAT_DATE="dd-MM-yyyy";
|
||||||
|
|||||||
@@ -4,8 +4,15 @@ public class Comment {
|
|||||||
private int id;
|
private int id;
|
||||||
private String content;
|
private String content;
|
||||||
private float rating;
|
private float rating;
|
||||||
|
private int userId;
|
||||||
private User user;
|
private User user;
|
||||||
|
|
||||||
|
public Comment(String content, float rating, int userId) {
|
||||||
|
this.content = content;
|
||||||
|
this.rating = rating;
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -37,4 +44,12 @@ public class Comment {
|
|||||||
public void setUser(User user) {
|
public void setUser(User user) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(int userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public class Food implements Comparable<Food>{
|
|||||||
private Shop shop;
|
private Shop shop;
|
||||||
private List<Category> categories;
|
private List<Category> categories;
|
||||||
private List<Image> images;
|
private List<Image> images;
|
||||||
|
private List<Comment> comments;
|
||||||
public Food() {
|
public Food() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,6 +106,14 @@ public class Food implements Comparable<Food>{
|
|||||||
this.images = images;
|
this.images = images;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Comment> getComments() {
|
||||||
|
return comments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComments(List<Comment> comments) {
|
||||||
|
this.comments = comments;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Food food) {
|
public int compareTo(Food food) {
|
||||||
if(getName().isEmpty() || food.getName().isEmpty()){
|
if(getName().isEmpty() || food.getName().isEmpty()){
|
||||||
|
|||||||
@@ -177,12 +177,21 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:srb_starPadding="5dp"
|
app:srb_starPadding="5dp"
|
||||||
app:srb_clickable="false"
|
app:srb_clickable="false"
|
||||||
|
android:layout_marginEnd="10dp"
|
||||||
app:srb_starWidth="22dp"
|
app:srb_starWidth="22dp"
|
||||||
app:srb_starHeight="22dp"
|
app:srb_starHeight="22dp"
|
||||||
app:srb_numStars="5"
|
app:srb_numStars="5"
|
||||||
app:srb_scrollable="false"
|
app:srb_scrollable="false"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/count_rating_text_view"
|
||||||
|
android:textSize="13sp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:text="235 đánh giá" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
@@ -299,23 +308,115 @@
|
|||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="20dp"
|
||||||
android:drawableLeft="@drawable/pencil"
|
android:drawableLeft="@drawable/pencil"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/count_rating_text_view"
|
|
||||||
android:text="235 rating"
|
|
||||||
android:layout_marginStart="10dp"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:cardElevation="5dp"
|
||||||
|
app:cardUseCompatPadding="true"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/linear_layout_2"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
android:id="@+id/user_comment_layout"
|
||||||
|
>
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/user_name_text_view"
|
||||||
|
android:text="User A"
|
||||||
|
android:fontFamily="@font/opensans"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<com.willy.ratingbar.ScaleRatingBar
|
||||||
|
android:id="@+id/rating_bar_comment"
|
||||||
|
android:layout_width="110dp"
|
||||||
|
android:layout_height="26dp"
|
||||||
|
app:srb_starPadding="5dp"
|
||||||
|
app:srb_clickable="false"
|
||||||
|
app:srb_starWidth="12dp"
|
||||||
|
app:srb_starHeight="12dp"
|
||||||
|
app:srb_numStars="5"
|
||||||
|
app:srb_scrollable="false"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/user_name_text_view"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
android:layout_marginStart="-5dp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/comment_user"
|
||||||
|
android:text="Food is good!"
|
||||||
|
android:fontFamily="@font/opensans"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/rating_bar_comment"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="30dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:src="@drawable/baseline_edit_24"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:id="@+id/edit_button"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/delete_button"
|
||||||
|
android:src="@drawable/baseline_delete_24"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/line2"
|
||||||
|
android:layout_width="200dp"
|
||||||
|
android:layout_height="2dp"
|
||||||
|
android:background="#c0c0c0"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/user_comment_layout"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
/>
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/recycler_view_comment"
|
android:id="@+id/recycler_view_comment"
|
||||||
tools:listitem="@layout/item_comment"
|
tools:listitem="@layout/item_comment"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintTop_toBottomOf="@id/linear_layout_2"
|
app:layout_constraintTop_toBottomOf="@id/line2"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -352,6 +453,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#80000000"
|
android:background="#80000000"
|
||||||
android:id="@+id/progress_layout"
|
android:id="@+id/progress_layout"
|
||||||
|
android:visibility="gone"
|
||||||
>
|
>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="5dp"
|
android:layout_marginTop="5dp"
|
||||||
|
app:srb_minimumStars="1"
|
||||||
app:layout_constraintTop_toBottomOf="@id/text_view_2"
|
app:layout_constraintTop_toBottomOf="@id/text_view_2"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="310dp"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:background="@drawable/bg_white_corner_16">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_view_1"
|
||||||
|
android:text="Đánh giá"
|
||||||
|
android:textSize="22sp"
|
||||||
|
android:fontFamily="@font/opensans"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/bg_color_corner_16"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
android:padding="7dp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_view_2"
|
||||||
|
android:text="Bạn vui lòng đánh giá tại đây!"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:fontFamily="@font/opensans"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/text_view_1"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<com.willy.ratingbar.RotationRatingBar
|
||||||
|
android:id="@+id/rating_bar"
|
||||||
|
app:srb_numStars="5"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/text_view_2"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/edit_text_comment"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="Đánh giá về món ăn..."
|
||||||
|
android:gravity="top"
|
||||||
|
android:lines="5"
|
||||||
|
android:inputType="textMultiLine"
|
||||||
|
android:background="@drawable/bg_white_corner_border_gray"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/rating_bar"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
android:layout_marginStart="20dp"
|
||||||
|
android:layout_marginEnd="20dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:padding="10dp"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatButton
|
||||||
|
android:id="@+id/confirm_button"
|
||||||
|
android:text="Chỉnh sửa"
|
||||||
|
android:textAllCaps="false"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:layout_width="120dp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:fontFamily="@font/opensans"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/bg_primary_color_dark_corner"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/edit_text_comment"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toStartOf="@id/cancel_button"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatButton
|
||||||
|
android:id="@+id/cancel_button"
|
||||||
|
android:text="Thoát"
|
||||||
|
android:textAllCaps="false"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:fontFamily="@font/opensans"
|
||||||
|
android:layout_width="120dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/bg_grey_color_corner"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/edit_text_comment"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/confirm_button"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
Reference in New Issue
Block a user