Commit ba19218c authored by iman Fauzi's avatar iman Fauzi

fix conflict

parents 9519a180 269aa124
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
......
......@@ -21,6 +21,7 @@
android:roundIcon="@mipmap/ic_launcher_new_icon"
android:supportsRtl="true"
android:theme="@style/AppTheme.appbar">
<activity android:name=".RegisterActivity"></activity>
<activity
android:name=".BottomSheets"
tools:ignore="Instantiatable" />
......@@ -37,9 +38,6 @@
<activity
android:name=".CartActivity"
android:theme="@style/AppTheme.appbar" />
<activity
android:name=".ProductActivity"
android:theme="@style/AppTheme.appbar" />
<activity android:name=".SplashScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......
......@@ -183,11 +183,11 @@ public class BottomSheets extends BottomSheetDialogFragment {
}
}
@Override
public void onFailure(Call<DataResponse<PaymentsModels<List<VaNumberModels>>>> call, Throwable t) {
@Override
public void onFailure(Call<DataResponse<PaymentsModels<List<VaNumberModels>>>> call, Throwable t) {
}
});
}
});
}else{
paymentsModels.setTransactionStatus("success");
paymentsModels.setPaymentType("cash");
......
......@@ -188,7 +188,8 @@ public class FormProductActivity extends AppCompatActivity {
HashSet<String> set = new HashSet<>();
List<String> str = new ArrayList<>();
categoryModels = new ArrayList<>();
if (productModelsIntent == null){
Log.i("GET_CATEGORY", "setSpinner: "+utils.convertGson(productModelsIntent));
if (productModelsIntent.getCategoryProduct() == 0){
str.add("SELECT CATEGORY");
}else{
str.add(getCategoryById(productModelsIntent.getIdProduct()));
......@@ -337,11 +338,11 @@ public class FormProductActivity extends AppCompatActivity {
}
private String getCategoryById(int s) {
CategoryServise categoryServise = client.Client(CategoryServise.class);
categoryServise.getCategoryId(s).enqueue(new Callback<DataResponse<CategoryModels>>() {
@Override
public void onResponse(Call<DataResponse<CategoryModels>> call, Response<DataResponse<CategoryModels>> response) {
Log.i("ER", "onResponse: "+utils.convertGson(response.body()));
categoryName = response.body().getData().getNameCategory();
}
......
......@@ -31,11 +31,20 @@ import com.yono.messeripos.utils.Utils;
public class LoginActivity extends AppCompatActivity {
TextInputEditText username, password;
MainViewModels mainViewModels;
SharedPreferences sharedPreferences;
Utils utils = new Utils();
//State
LoginState loginState;
RegisterState registerState;
MaterialButton btnSignin;
MaterialButton btnSignup, btnSignIn;
ConstraintLayout loginSheetLayout, registerSheetLayout;
int height, width;
ImageButton closeBtn;
private String TAG = "MainActivity";
......@@ -44,27 +53,67 @@ public class LoginActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.payment_method);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// Window w = getWindow();
// w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
// }
//
// mainViewModels = ViewModelProviders.of(this).get(MainViewModels.class);
//
//// bindUI
// btnSignin = findViewById(R.id.signInButtonDashboardLogin);
//
//// session login
// sharedPreferences = getSharedPreferences(SplashScreen.MY_SHARED_PREFERENCES, Context.MODE_PRIVATE);
//
//// button login on click
// btnSignin.setOnClickListener(new View.OnClickListener() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
mainViewModels = ViewModelProviders.of(this).get(MainViewModels.class);
// registerSheetLayout = findViewById(R.id.ConstraintRegisterLayout);
// sheetBehavior2 = BottomSheetBehavior.from(registerSheetLayout);
//button on click to form register
// btnSignup.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
// if (sheetBehavior2.getState() != BottomSheetBehavior.STATE_EXPANDED) {
// sheetBehavior2.setState(BottomSheetBehavior.STATE_EXPANDED);
// registerSheetLayout.setMaxHeight(height - 100);
// } else {
// sheetBehavior2.setState(BottomSheetBehavior.STATE_COLLAPSED);
// }
// }
// });
// bindUI
btnSignIn = findViewById(R.id.signInButtonDashboardLogin);
btnSignup = findViewById(R.id.signUpButtonDashboardLogin);
// //button on click to form register
// btnSignup.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// loginState = new LoginState(LoginActivity.this, mainViewModels);
// loginState.setCancelable(false);
// loginState.show(getSupportFragmentManager(), loginState.getTag());
// public void onClick(View view) {
// if (sheetBehavior2.getState() != BottomSheetBehavior.STATE_EXPANDED) {
// sheetBehavior2.setState(BottomSheetBehavior.STATE_EXPANDED);
// registerSheetLayout.setMaxHeight(height - 100);
// } else {
// sheetBehavior2.setState(BottomSheetBehavior.STATE_COLLAPSED);
// }
// }
// });
// session login
sharedPreferences = getSharedPreferences(SplashScreen.MY_SHARED_PREFERENCES, Context.MODE_PRIVATE);
// button login on click
btnSignIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
loginState = new LoginState(LoginActivity.this, mainViewModels);
loginState.show(getSupportFragmentManager(), loginState.getTag());
}
});
btnSignup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
registerState = new RegisterState(LoginActivity.this,mainViewModels);
registerState.setCancelable(false);
registerState.show(getSupportFragmentManager(),registerState.getTag());
}
});
}
}
\ No newline at end of file
}
package com.yono.messeripos;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
......@@ -11,10 +13,12 @@ import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.Observer;
......@@ -23,6 +27,7 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.textfield.TextInputEditText;
import com.yono.messeripos.models.MainViewModels;
......@@ -33,6 +38,7 @@ import com.yono.messeripos.utils.Utils;
public class LoginState extends BottomSheetDialogFragment {
private static final String TAG = "LoginState";
private static String DEFAULT_LOGIN_NAME = "sign in";
BottomSheetBehavior sheetBehavior;
BottomSheetDialog sheetDialog;
RelativeLayout loginLayout;
......@@ -43,6 +49,10 @@ public class LoginState extends BottomSheetDialogFragment {
MainViewModels mainViewModels;
SharedPreferences sharedPreferences;
Utils utils;
ProgressBar bar;
AlertDialog alertDialog;
ProgressDialog dialog;
public LoginState(Context context, MainViewModels mainViewModels) {
this.context = context;
......@@ -56,6 +66,8 @@ public class LoginState extends BottomSheetDialogFragment {
sheetDialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState);
dialog = new ProgressDialog(context);
// inflating layout
View view = View.inflate(getContext(), R.layout.login_form, null);
......@@ -65,6 +77,10 @@ public class LoginState extends BottomSheetDialogFragment {
password = view.findViewById(R.id.ETPasswordLogin);
loginButton = view.findViewById(R.id.SignInButtonInLogin);
closeBtn = view.findViewById(R.id.closeBtnLogin);
bar = view.findViewById(R.id.progressLogin);
// set progress bar gone
bar.setVisibility(View.GONE);
// create session
sharedPreferences = context.getSharedPreferences(SplashScreen.MY_SHARED_PREFERENCES, Context.MODE_PRIVATE);
......@@ -78,16 +94,28 @@ public class LoginState extends BottomSheetDialogFragment {
// get Window size
int getHeight = Resources.getSystem().getDisplayMetrics().heightPixels;
int setHeight = getHeight - (getHeight * 10) / 100;
int setHeight = getHeight - (getHeight * 5) / 100;
// set max height
sheetBehavior.setPeekHeight(setHeight);
loginLayout.setMinimumHeight(setHeight);
Log.d(TAG, "onCreateDialog: "+sheetBehavior.getState());
// alert dialog buat nampilin error
alertDialog = new AlertDialog.Builder(context)
.setTitle("Username dan Password Salah")
.setMessage("Oppss! Username dan Password yang kamu masukan salah!")
.setPositiveButton("Coba Lagi", null)
.setCancelable(false)
.create();
loginButton.setOnClickListener(view1 -> {
if (sheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED) loginAuth(view1);
if (sheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED) {
bar.setVisibility(View.VISIBLE);
loginButton.setText("");
sheetDialog.setCancelable(false);
loginAuth(view1);
}
});
// close btn is clicked
......@@ -100,7 +128,6 @@ public class LoginState extends BottomSheetDialogFragment {
}
private void loginAuth(View v) {
Snackbar snackbar = Snackbar.make(v, "Oppss! Wrong Username Or Password!", Snackbar.LENGTH_LONG);
if (TextUtils.isEmpty(username.getText().toString()) &&
TextUtils.isEmpty(password.getText().toString())){
......@@ -111,37 +138,73 @@ public class LoginState extends BottomSheetDialogFragment {
}else if (TextUtils.isEmpty(password.getText().toString())){
password.setError("This field can't empty");
}else{
/**
* Jika tombol sign in ditekan
*/
// aktifkan progress bar
bar.setVisibility(View.VISIBLE);
// hilangkan tulisan di button
loginButton.setText("");
// nonaktifkan semua form
username.setEnabled(false);
password.setEnabled(false);
loginButton.setEnabled(false);
closeBtn.setEnabled(false);
// buat checking login
mainViewModels.checkLogin(new UsersModels(username.getText().toString(),
password.getText().toString())).observe((LifecycleOwner) context, new Observer<DataResponse<UsersModels>>() {
password.getText().toString()))
.observe((LifecycleOwner) context, new Observer<DataResponse<UsersModels>>() {
@Override
public void onChanged(DataResponse<UsersModels> usersModelsDataResponse) {
Log.d("Status", usersModelsDataResponse.getMessageData());
if (usersModelsDataResponse != null) {
/**
* Jika response atau data ada dan cocok
*/
if (usersModelsDataResponse.getStatusData()) {
// SharedPreferences.Editor editor = sharedPreferences.edit();
// editor.putBoolean(SplashScreen.SESSION, true);
// editor.commit();
// redirect ke home
startActivity(new Intent(context, MainActivity.class));
// set progress bar jadi nonaktif
bar.setVisibility(View.GONE);
// munculkan tulisan default di button sign in
loginButton.setText(DEFAULT_LOGIN_NAME);
// ubah sheet dialog jadi tidak bisa di slide atau cancel
sheetDialog.setCancelable(true);
// set form jadi enable
username.setEnabled(true);
password.setEnabled(true);
loginButton.setEnabled(true);
closeBtn.setEnabled(true);
} else {
utils.snackBar(v, "Oppss! Wrong Username Or Password!").show();
/**
* Jika response atau data tidak cocok
*/
bar.setVisibility(View.GONE);
loginButton.setText(DEFAULT_LOGIN_NAME);
sheetDialog.setCancelable(true);
utils.snackBar(v, "Oppss! Wrong Username or Password!").show();
username.setEnabled(true);
password.setEnabled(true);
loginButton.setEnabled(true);
closeBtn.setEnabled(true);
}
} else {
bar.setVisibility(View.VISIBLE);
utils.snackBar(v, "Oppss! ログイン中にエラーが発生しました。しばらくしてからもう一度お試しください").show();
}
......
......@@ -101,7 +101,6 @@ public class MainActivity extends AppCompatActivity {
showLoading(true);
btnAddCart = findViewById(R.id.materialBtnAddCart);
binding.tvCategory.setVisibility(View.GONE);
binding.tvProduct.setVisibility(View.GONE);
formCategory = new FormCategory();
......@@ -200,7 +199,6 @@ public class MainActivity extends AppCompatActivity {
categoryModels.add(0,caModels);
categoryModelsArrayList.addAll(categoryModels);
binding.tvCategory.setVisibility(View.VISIBLE);
binding.tvProduct.setVisibility(View.VISIBLE);
categoryAdapter.setCategoriAdapter(MainActivity.this, categoryModelsArrayList);
binding.rvCategory.setLayoutManager(new LinearLayoutManager(
......
......@@ -204,14 +204,14 @@ public class PaymentActivity extends AppCompatActivity {
// bottomSheetBank.setState(BottomSheetBehavior.STATE_EXPANDED);
// progressDialog.show();
Client client = new Client();
paymentsModels.setPaymentType("bank_transfer");
paymentsModels.setBank(methodPay);
paymentsModels.setOrderIdUpdate(sharedPreferences.getString(ORDER_ID,""));
paymentsModels.setOrderId(sharedPreferences.getString(ORDER_ID, ""));
paymentsModels.setTransactionStatus("success");
paymentsModels.setTransaction_id(utils.timeStamp()+"-MES");
paymentsModels.setTransaction_time(utils.timeStamp());
Log.i("BANK", "onClick: "+utils.convertGson(paymentsModels));
paymentsModels.setPaymentType("bank_transfer");
paymentsModels.setBank(methodPay);
paymentsModels.setOrderIdUpdate(sharedPreferences.getString(ORDER_ID,""));
paymentsModels.setOrderId(sharedPreferences.getString(ORDER_ID, ""));
paymentsModels.setTransactionStatus("success");
paymentsModels.setTransaction_id(utils.timeStamp()+"-MES");
paymentsModels.setTransaction_time(utils.timeStamp());
Log.i("BANK", "onClick: "+utils.convertGson(paymentsModels));
PaymentService paymentService = client.Client(PaymentService.class);
if (paymentsModelsIntent == null){
......
package com.yono.messeripos;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class RegisterActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
}
}
\ No newline at end of file
package com.yono.messeripos;
import android.app.Dialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import com.google.android.material.button.MaterialButton;
import com.google.android.material.textfield.TextInputEditText;
import com.yono.messeripos.models.MainViewModels;
import com.yono.messeripos.utils.Utils;
public class RegisterState extends BottomSheetDialogFragment {
private static final String TAG = "RegisterState";
BottomSheetBehavior sheetBehavior2;
BottomSheetDialog sheetDialog2;
RelativeLayout registerLayout;
TextInputEditText username, email, password, repassword;
MaterialButton registerButton;
ImageView closeBtn;
Context context;
MainViewModels mainViewModels;
SharedPreferences sharedPreferences;
Utils utils;
public RegisterState(Context context, MainViewModels mainViewModels) {
this.context = context;
this.mainViewModels = mainViewModels;
}
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
sheetDialog2 = (BottomSheetDialog) super.onCreateDialog(savedInstanceState);
// inflating layout
View view = View.inflate(getContext(), R.layout.register_form, null);
// bindUI
registerLayout = view.findViewById(R.id.RegisterLayout);
username = view.findViewById(R.id.ETUsernameReg);
email = view.findViewById(R.id.ETEmailReg);
password = view.findViewById(R.id.ETPasswordReg);
repassword = view.findViewById(R.id.ETRePasswordReg);
registerButton = view.findViewById(R.id.MBRegister);
closeBtn = view.findViewById(R.id.ivclose);
// create session
sharedPreferences = context.getSharedPreferences(SplashScreen.MY_SHARED_PREFERENCES, Context.MODE_PRIVATE);
// utils
utils = new Utils();
sheetDialog2.setContentView(view);
sheetBehavior2 = BottomSheetBehavior.from((View) (view.getParent()));
// get Window size
int getHeight = Resources.getSystem().getDisplayMetrics().heightPixels;
int setHeight = getHeight - (getHeight * 5) / 100;
// set max height
sheetBehavior2.setPeekHeight(setHeight);
registerLayout.setMinimumHeight(setHeight);
Log.d(TAG, "onCreateDialog: " + sheetBehavior2.getState());
// loginButton.setOnClickListener(view1 -> {
// if (sheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED) loginAuth(view1);
// });
// close btn is clicked
closeBtn.setOnClickListener(view12 -> {
Log.d(TAG, "onCreateDialog: " + sheetBehavior2.getState());
sheetDialog2.dismiss();
});
return sheetDialog2;
}
}
......@@ -11,4 +11,7 @@ import retrofit2.http.POST;
public interface UsersService {
@POST(ApiHelper.VERSI_API_1+"login")
Call<DataResponse<UsersModels>> checkLogin(@Body UsersModels usersModels);
@POST(ApiHelper.VERSI_API_1+"register")
Call<DataResponse<UsersModels>> postRegister(@Body UsersModels usersModels);
}
......@@ -29,6 +29,8 @@ public class MainViewModels extends ViewModel {
MutableLiveData<DataResponse<List<ProductModels>>> productByCategory;
MutableLiveData<DataResponse<List<CategoryModels>>> categoryList;
MutableLiveData<DataResponse<UsersModels>> usersLogin;
MutableLiveData<DataResponse<UsersModels>> usersRegister;
MutableLiveData<DataResponse<List<PaymentsModels<String>>>> transactions;
private MainViewModels mainViewModels;
......@@ -36,7 +38,7 @@ public class MainViewModels extends ViewModel {
Client client = new Client();
Utils utils = new Utils();
public MainViewModels(){
public MainViewModels() {
productList = new MutableLiveData<>();
categoryList = new MutableLiveData<>();
productByCategory = new MutableLiveData<>();
......@@ -44,26 +46,26 @@ public class MainViewModels extends ViewModel {
}
public LiveData<DataResponse<List<ProductModels<CategoryModels>>>> getProduct(){
public LiveData<DataResponse<List<ProductModels<CategoryModels>>>> getProduct() {
getProductList();
return productList;
}
public LiveData<DataResponse<List<CategoryModels>>> getCategory(){
public LiveData<DataResponse<List<CategoryModels>>> getCategory() {
getCategoryList();
return categoryList;
}
public void postCategory(CategoryModels categoryModels){
public void postCategory(CategoryModels categoryModels) {
saveCategory(categoryModels);
}
public LiveData<DataResponse<List<ProductModels>>> getProductByCategory(int id){
public LiveData<DataResponse<List<ProductModels>>> getProductByCategory(int id) {
getDataProductByCategory(id);
return productByCategory;
}
public LiveData<DataResponse<List<PaymentsModels<String>>>> getAllTransactions(){
public LiveData<DataResponse<List<PaymentsModels<String>>>> getAllTransactions() {
getDataTransaction();
return transactions;
}
......@@ -74,27 +76,27 @@ public class MainViewModels extends ViewModel {
categoryServise.addCategory(categoryModels).enqueue(new Callback<DataResponse<CategoryModels>>() {
@Override
public void onResponse(Call<DataResponse<CategoryModels>> call, Response<DataResponse<CategoryModels>> response) {
Log.i("Add Categiry", "onResponse: "+utils.convertGson(response.body()));
Log.i("Add Categiry", "onResponse: " + utils.convertGson(response.body()));
}
@Override
public void onFailure(Call<DataResponse<CategoryModels>> call, Throwable t) {
Log.e("error add", "onFailure: ",t );
Log.e("error add", "onFailure: ", t);
}
});
}
public void deleteProducts(int id){
public void deleteProducts(int id) {
ProductService productService = client.Client(ProductService.class);
productService.deleteProducts(id).enqueue(new Callback<DataResponse<ProductModels>>() {
@Override
public void onResponse(Call<DataResponse<ProductModels>> call, Response<DataResponse<ProductModels>> response) {
Log.i("Delete", "onResponse: "+utils.convertGson(response.body()));
Log.i("Delete", "onResponse: " + utils.convertGson(response.body()));
}
@Override
public void onFailure(Call<DataResponse<ProductModels>> call, Throwable t) {
Log.e("error delete", "onFailure: ",t );
Log.e("error delete", "onFailure: ", t);
}
});
}
......@@ -106,17 +108,17 @@ public class MainViewModels extends ViewModel {
@Override
public void onResponse(Call<DataResponse<List<PaymentsModels<String>>>> call,
Response<DataResponse<List<PaymentsModels<String>>>> response) {
Log.i("Get all transaction", "onResponse: "+utils.convertGson(response.body()));
if (response.body() != null){
Log.i("Get all transaction", "onResponse: " + utils.convertGson(response.body()));
if (response.body() != null) {
transactions.setValue(response.body());
}else{
} else {
transactions = null;
}
}
@Override
public void onFailure(Call<DataResponse<List<PaymentsModels<String>>>> call, Throwable t) {
Log.e("Error get transaction", "onFailure: ",t );
Log.e("Error get transaction", "onFailure: ", t);
transactions = null;
}
});
......@@ -130,8 +132,8 @@ public class MainViewModels extends ViewModel {
public void onResponse(Call<DataResponse<List<ProductModels>>> call,
Response<DataResponse<List<ProductModels>>> response) {
String js = new Gson().toJson(response.body());
Log.i("Get data by category", "onResponse: "+js);
if (response != null){
Log.i("Get data by category", "onResponse: " + js);
if (response != null) {
productByCategory.setValue(response.body());
}
}
......@@ -143,28 +145,53 @@ public class MainViewModels extends ViewModel {
});
}
public MutableLiveData<DataResponse<UsersModels>> checkLogin(UsersModels usersModels){
public MutableLiveData<DataResponse<UsersModels>> checkLogin(UsersModels usersModels) {
usersLogin = new MutableLiveData<>();
PeriksaLogin(usersModels);
return usersLogin;
}
public MutableLiveData<DataResponse<UsersModels>> checkRegis(UsersModels usersModels){
usersRegister = new MutableLiveData<>();
CreateRegister(usersModels);
return usersRegister;
}
private void PeriksaLogin(UsersModels usersModels) {
UsersService usersService = client.Client(UsersService.class);
//cek login
usersService.checkLogin(usersModels).enqueue(new Callback<DataResponse<UsersModels>>() {
@Override
public void onResponse(Call<DataResponse<UsersModels>> call, Response<DataResponse<UsersModels>> response) {
if (response.body() != null){
if (response.body() != null) {
usersLogin.setValue(response.body());
}
String js = new Gson().toJson(response.body());
Log.d("Periksa login", "Response "+js);
Log.d("Periksa login", "Response " + js);
}
@Override
public void onFailure(Call<DataResponse<UsersModels>> call, Throwable t) {
Log.e("Error Login", "Response " + t.getMessage());
}
});
}
private void CreateRegister(UsersModels usersModels){
UsersService usersService = client.Client(UsersService.class);
//post register
usersService.postRegister(usersModels).enqueue(new Callback<DataResponse<UsersModels>>() {
@Override
public void onResponse(Call<DataResponse<UsersModels>> call, Response<DataResponse<UsersModels>> response) {
}
@Override
public void onFailure(Call<DataResponse<UsersModels>> call, Throwable t) {
Log.e("Error Login", "Response "+t.getMessage());
Log.e("Error Register","Response"+t.getMessage());
}
});
}
......@@ -176,40 +203,40 @@ public class MainViewModels extends ViewModel {
productService.getProducts().enqueue(new Callback<DataResponse<List<ProductModels<CategoryModels>>>>() {
@Override
public void onResponse(Call<DataResponse<List<ProductModels<CategoryModels>>>> call, Response<DataResponse<List<ProductModels<CategoryModels>>>> response) {
Log.i("Get products", "onResponse: "+utils.convertGson(response.body()));
if (response.body() != null){
Log.i("Get products", "onResponse: " + utils.convertGson(response.body()));
if (response.body() != null) {
productList.setValue(response.body());
}else{
} else {
productList.setValue(null);
}
}
@Override
public void onFailure(Call<DataResponse<List<ProductModels<CategoryModels>>>> call, Throwable t) {
Log.e("Error get product", "Response "+t.getMessage());
Log.e("Error get product", "Response " + t.getMessage());
}
});
}
private void getCategoryList(){
private void getCategoryList() {
CategoryServise categoryServise = client.Client(CategoryServise.class);
categoryServise.getCategory().enqueue(new Callback<DataResponse<List<CategoryModels>>>() {
@Override
public void onResponse(Call<DataResponse<List<CategoryModels>>> call, Response<DataResponse<List<CategoryModels>>> response) {
String js = new Gson().toJson(response.body());
Log.d("Get Data Category", "Response "+js);
if (response.body() != null){
Log.d("Get Data Category", "Response " + js);
if (response.body() != null) {
categoryList.setValue(response.body());
}else {
} else {
categoryList.setValue(null);
}
}
@Override
public void onFailure(Call<DataResponse<List<CategoryModels>>> call, Throwable t) {
Log.e("Error get product", "Response "+t.getMessage());
Log.e("Error get product", "Response " + t.getMessage());
}
});
}
......
......@@ -6,14 +6,31 @@ public class UsersModels {
@SerializedName("username")
private String usernameUsers;
@SerializedName("email")
private String emailUsers;
@SerializedName("password")
private String passwordUsers;
public UsersModels(String usernameUsers, String passwordUsers) {
public UsersModels(String usernameUsers,String passwordUsers) {
this.usernameUsers = usernameUsers;
this.passwordUsers = passwordUsers;
}
public UsersModels(String usernameUsers, String emailUsers, String passwordUsers) {
this.usernameUsers = usernameUsers;
this.emailUsers = emailUsers;
this.passwordUsers = passwordUsers;
}
public String getEmailUsers() {
return emailUsers;
}
public void setEmailUsers(String emailUsers) {
this.emailUsers = emailUsers;
}
public String getUsernameUsers() {
return usernameUsers;
}
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@color/colorPrimary"
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
</vector>
......@@ -122,6 +122,16 @@
app:layout_constraintVertical_bias="0.01999998" />
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="forgot your password ?"
android:layout_marginLeft="100sp"
android:textColor="@color/colorWhite"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/btnLogin" />
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyle"
......
......@@ -50,22 +50,15 @@
</com.google.android.material.appbar.AppBarLayout>
<TextView
android:id="@+id/tvCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/topBar"
android:textColor="@android:color/black"
android:textSize="18sp"
android:textAllCaps="true"
android:layout_margin="5dp"
android:text="Category"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tvCategory"/>
android:layout_below="@+id/topBar"
android:layout_alignParentEnd="true"
android:paddingTop="10dp"
android:layout_marginEnd="0dp" />
<ImageView
android:id="@+id/imgEmpty"
......@@ -95,8 +88,7 @@
android:textColor="@android:color/black"
android:textSize="18sp"
android:textAllCaps="true"
android:layout_margin="5dp"
android:text="Product"/>
android:layout_margin="5dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvProduct"
......
<?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=".RegisterActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -20,6 +20,7 @@
android:layout_height="wrap_content"
android:drawableStart="@drawable/ic_baseline_search_24"
android:hint="Search"
android:textStyle="normal"
android:outlineSpotShadowColor="#fff"
android:paddingStart="10dp"
android:textColor="#fff"
......
<?xml version="1.0" encoding="utf-8"?>
<!--<androidx.coordinatorlayout.widget.CoordinatorLayout android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- xmlns:app="http://schemas.android.com/apk/res-auto"-->
<!-- xmlns:tools="http://schemas.android.com/tools"-->
<!-- android:background="@drawable/gradient"-->
<!-- xmlns:android="http://schemas.android.com/apk/res/android"-->
<!-- tools:context=".LoginActivity">-->
<layout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
......@@ -70,4 +62,3 @@
</layout>
<!--</androidx.coordinatorlayout.widget.CoordinatorLayout>-->
\ No newline at end of file
......@@ -59,26 +59,28 @@
<com.google.android.material.button.MaterialButton
android:id="@+id/categoryDelete"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="40dp"
android:backgroundTint="@android:color/holo_red_dark"
android:text="DELETE"
android:textSize="10sp"
android:textAlignment="textStart"
app:layout_constraintTop_toBottomOf="@id/cvCategory"
android:backgroundTint="@android:color/holo_red_dark"
android:textSize="10sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cvCategory"
app:layout_constraintVertical_bias="0.0" />
<com.google.android.material.button.MaterialButton
android:id="@+id/categoryUpdate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="40dp"
android:backgroundTint="@color/colorGreen"
android:text="UPDATE"
android:textSize="10sp"
android:textAlignment="textEnd"
app:layout_constraintTop_toBottomOf="@id/cvCategory"
android:backgroundTint="@color/colorGreen"
android:textSize="10sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/cvCategory"
app:layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
......
<?xml version="1.0" encoding="utf-8"?>
<!--<androidx.constraintlayout.widget.ConstraintLayout-->
<!-- android:id="@+id/ConstraintLoginLayout"-->
<!-- xmlns:android="http://schemas.android.com/apk/res/android"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- xmlns:app="http://schemas.android.com/apk/res-auto"-->
<!-- android:orientation="vertical"-->
<!-- android:layout_gravity="bottom"-->
<!-- app:behavior_hideable="false"-->
<!-- android:padding="20dp"-->
<!-- style="@style/Widget.Rounded.BottomSheet"-->
<!-- app:behavior_peekHeight="0dp"-->
<!-- android:background="@color/colorWhite"-->
<!-- app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">-->
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
......@@ -21,104 +6,134 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/LoginLayout"
android:padding="20dp"
style="@style/Widget.Rounded.BottomSheet"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/LoginLayout"
style="@style/Widget.Rounded.BottomSheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp">
<ImageButton
android:id="@+id/closeBtnLogin"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_baseline_plus_24"
android:scaleType="centerInside"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:adjustViewBounds="true"
android:padding="20dp"
android:backgroundTint="@android:color/transparent"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
/>
<ImageView
android:id="@+id/messerLogoInLogin"
android:layout_width="150dp"
android:layout_height="150dp"
android:src="@drawable/ic_messer_primary"
android:layout_below="@id/closeBtnLogin"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"/>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/formUsernameLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/username"
android:layout_below="@id/messerLogoInLogin"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ETUsernameLogin"
android:layout_width="match_parent"
android:inputType="text"
android:imeOptions="actionNext"
android:layout_height="wrap_content"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/FormPasswordLogin"
android:padding="20dp"
android:scaleType="centerInside"
android:src="@drawable/ic_close" />
<ImageView
android:id="@+id/messerLogoInLogin"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_below="@id/closeBtnLogin"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:src="@drawable/ic_messer_primary" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tvLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/messerLogoInLogin"
android:paddingLeft="12dp"
android:text="Login Your Account"
android:textColor="@color/colorPrimary"
android:textFontWeight="600"
android:textSize="16sp" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/formUsernameLogin"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tvLogin"
android:hint="@string/username">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ETUsernameLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/password"
android:layout_below="@id/formUsernameLogin"
android:layout_marginTop="20dp"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ETPasswordLogin"
android:layout_width="match_parent"
android:inputType="textPassword"
android:imeOptions="actionDone|actionGo"
android:layout_height="wrap_content"
/>
</com.google.android.material.textfield.TextInputLayout>
<CheckBox
android:id="@+id/CBRememberMe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remember Me"
android:textColor="@color/colorPrimary"
android:layout_below="@id/FormPasswordLogin"
android:layout_marginVertical="10dp"
app:useMaterialThemeColors="true"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/SignInButtonInLogin"
android:imeOptions="actionNext"
android:inputType="text" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/FormPasswordLogin"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/formUsernameLogin"
android:layout_marginTop="20dp"
android:hint="@string/password">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ETPasswordLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/CBRememberMe"
android:text="Sign In"
android:layout_below="@id/CBRememberMe"
android:padding="20dp"/>
android:imeOptions="actionDone|actionGo"
android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>
<CheckBox
android:id="@+id/CBRememberMe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/FormPasswordLogin"
android:layout_marginVertical="10dp"
android:text="Remember Me"
android:textColor="@color/colorPrimary"
app:useMaterialThemeColors="true" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintBtn"
android:layout_below="@id/CBRememberMe"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.button.MaterialButton
android:id="@+id/SignInButtonInLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sign in"
android:padding="20dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
<ProgressBar
android:id="@+id/progressLogin"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="2dp"
app:layout_constraintBottom_toBottomOf="@id/SignInButtonInLogin"
app:layout_constraintTop_toTopOf="@id/SignInButtonInLogin"
app:layout_constraintStart_toStartOf="@id/SignInButtonInLogin"
app:layout_constraintEnd_toEndOf="@id/SignInButtonInLogin"
/>
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Forgot Password?"
android:layout_below="@id/SignInButtonInLogin"
android:layout_marginTop="10dp"
android:layout_alignParentEnd="true"
android:textColor="@color/colorPrimary"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</RelativeLayout>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/forgotPwd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Forgot Password?"
android:layout_below="@id/constraintBtn"
android:layout_marginTop="10dp"
android:layout_alignParentEnd="true"
android:textColor="@color/colorPrimary"/>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
<!--</androidx.constraintlayout.widget.ConstraintLayout>-->
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/RegisterLayout"
android:padding="20dp"
style="@style/Widget.Rounded.BottomSheet"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton
android:id="@+id/ivclose"
android:layout_width="50dp"
android:layout_height="50dp"
android:adjustViewBounds="true"
android:backgroundTint="@android:color/transparent"
android:padding="10dp"
android:src="@drawable/ic_close"
app:layout_constraintStart_toStartOf="parent"
/>
<ImageView
android:id="@+id/ivMeserRegister"
android:layout_width="150dp"
android:layout_height="150dp"
android:src="@drawable/ic_messer_primary"
android:layout_below="@+id/ivclose"
android:layout_centerHorizontal="true" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/tvCreate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Create Your Account"
android:textColor="@color/colorPrimary"
android:textFontWeight="600"
android:textSize="16sp"
android:layout_below="@id/ivMeserRegister"
android:paddingLeft="12dp"
/>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/formUsernameReg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/username"
android:layout_below="@id/tvCreate"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ETUsernameReg"
android:layout_width="match_parent"
android:inputType="text"
android:imeOptions="actionNext"
android:layout_height="wrap_content"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/formEmailReg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/email"
android:layout_marginTop="5dp"
android:layout_below="@id/formUsernameReg"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ETEmailReg"
android:layout_width="match_parent"
android:inputType="textEmailAddress"
android:imeOptions="actionNext"
android:layout_height="wrap_content"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/FormPasswordReg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/password"
android:layout_below="@id/formEmailReg"
android:layout_marginTop="5dp"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ETPasswordReg"
android:layout_width="match_parent"
android:inputType="textPassword"
android:imeOptions="actionDone|actionGo"
android:layout_height="wrap_content"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/FormRePasswordReg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/password_Confirmation"
android:layout_below="@id/FormPasswordReg"
android:layout_marginTop="5dp"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/ETRePasswordReg"
android:layout_width="match_parent"
android:inputType="textPassword"
android:imeOptions="actionDone|actionGo"
android:layout_height="wrap_content"
/>
</com.google.android.material.textfield.TextInputLayout>
<CheckBox
android:id="@+id/cbAgree"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I Agree of terms of use"
android:textColor="@color/colorPrimary"
android:layout_below="@id/FormRePasswordReg"
android:layout_marginVertical="10dp"
app:useMaterialThemeColors="true"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/MBRegister"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/cbAgree"
android:text="Create Account"
android:layout_below="@id/cbAgree"
android:padding="20dp"/>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
\ No newline at end of file
......@@ -28,6 +28,8 @@
<string name="title_next">next</string>
<string name="open_cart">Open Cart</string>
<string name="text_new_category">Add New Category</string>
<string name="email">Email</string>
<string name="password_Confirmation">Password Confirmation</string>
<string-array name="planets_array">
<item>Mercury</item>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment