Commit 53410090 authored by Alfansyah Fadlian's avatar Alfansyah Fadlian

fix error

parents d2542572 a847797c
......@@ -47,6 +47,8 @@ dependencies {
implementation 'com.github.bumptech.glide:glide:4.3.1'
implementation 'com.squareup.okhttp3:logging-interceptor:4.2.1'
implementation 'com.ethanhua:skeleton:1.1.2'
implementation 'com.github.florent37:expansionpanel:1.2.4'
implementation 'com.google.guava:guava:29.0-jre'
implementation 'io.supercharge:shimmerlayout:2.1.0'
implementation project(':library')
......
......@@ -6,6 +6,9 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!--NFC PERMISSION AND FEATURE-->
<uses-permission android:name="android.permission.NFC"/>
<uses-feature android:name="android.hardware.nfc" />
<uses-feature
android:name="android.hardware.camera"
......
......@@ -16,9 +16,7 @@ import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
......@@ -37,7 +35,6 @@ import retrofit2.Response;
import static com.yono.messeripos.MainActivity.CHECKOUT;
import static com.yono.messeripos.MainActivity.ORDER_ID;
import static com.yono.messeripos.MainActivity.orderId;
public class BottomSheets extends BottomSheetDialogFragment {
......
......@@ -66,6 +66,7 @@ public class FormProductActivity extends AppCompatActivity {
String locationPath = null;
int idCategorySelected = 0;
public int id = 0;
public String categoryName = "";
private String[] permissions = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE};
......@@ -76,6 +77,7 @@ public class FormProductActivity extends AppCompatActivity {
List<String> categorySelect = new ArrayList<>();
FormCategory formCategory;
@RequiresApi(api = Build.VERSION_CODES.N)
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -139,6 +141,7 @@ public class FormProductActivity extends AppCompatActivity {
progressDialog.show();
CategoryServise categoryServise = client.Client(CategoryServise.class);
categoryServise.addCategory(categoryModels).enqueue(new Callback<DataResponse<CategoryModels>>() {
@RequiresApi(api = Build.VERSION_CODES.N)
@Override
public void onResponse(Call<DataResponse<CategoryModels>> call, Response<DataResponse<CategoryModels>> response) {
if (response.body().getStatusData()){
......@@ -185,7 +188,11 @@ public class FormProductActivity extends AppCompatActivity {
HashSet<String> set = new HashSet<>();
List<String> str = new ArrayList<>();
categoryModels = new ArrayList<>();
str.add("SELECT CATEGORY");
if (productModelsIntent == null){
str.add("SELECT CATEGORY");
}else{
str.add(getCategoryById(productModelsIntent.getIdProduct()));
}
mainViewModels.getCategory().observe(this, listDataResponse -> {
progressDialog.dismiss();
for (CategoryModels cd: listDataResponse.getData()){
......@@ -329,6 +336,23 @@ public class FormProductActivity extends AppCompatActivity {
return id;
}
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) {
categoryName = response.body().getData().getNameCategory();
}
@Override
public void onFailure(Call<DataResponse<CategoryModels>> call, Throwable t) {
}
});
return categoryName;
}
private void openFile(){
requestPermissions(permissions, REQUEST_PERMISSIONS);
Intent i = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
......
package com.yono.messeripos;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.Observer;
import com.bumptech.glide.load.engine.Resource;
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.snackbar.Snackbar;
import com.google.android.material.textfield.TextInputEditText;
import com.yono.messeripos.models.MainViewModels;
import com.yono.messeripos.models.UsersModels;
import com.yono.messeripos.response.DataResponse;
import com.yono.messeripos.utils.Utils;
public class LoginState extends BottomSheetDialogFragment {
private static final String TAG = "LoginState";
BottomSheetBehavior sheetBehavior;
BottomSheetDialog sheetDialog;
RelativeLayout loginLayout;
TextInputEditText username, password;
MaterialButton loginButton;
ImageView closeBtn;
Context context;
MainViewModels mainViewModels;
SharedPreferences sharedPreferences;
Utils utils;
public LoginState(Context context, MainViewModels mainViewModels) {
this.context = context;
this.mainViewModels = mainViewModels;
}
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
sheetDialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState);
// inflating layout
View view = View.inflate(getContext(), R.layout.login_form, null);
// bindUI
loginLayout = view.findViewById(R.id.LoginLayout);
username = view.findViewById(R.id.ETUsernameLogin);
password = view.findViewById(R.id.ETPasswordLogin);
loginButton = view.findViewById(R.id.SignInButtonInLogin);
closeBtn = view.findViewById(R.id.closeBtnLogin);
// create session
sharedPreferences = context.getSharedPreferences(SplashScreen.MY_SHARED_PREFERENCES, Context.MODE_PRIVATE);
// utils
utils = new Utils();
sheetDialog.setContentView(view);
sheetBehavior = BottomSheetBehavior.from((View) (view.getParent()));
// get Window size
int getHeight = Resources.getSystem().getDisplayMetrics().heightPixels;
int setHeight = getHeight - (getHeight * 10) / 100;
// set max height
sheetBehavior.setPeekHeight(setHeight);
loginLayout.setMinimumHeight(setHeight);
Log.d(TAG, "onCreateDialog: "+sheetBehavior.getState());
loginButton.setOnClickListener(view1 -> {
if (sheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED) loginAuth(view1);
});
// close btn is clicked
closeBtn.setOnClickListener(view12 -> {
Log.d(TAG, "onCreateDialog: "+sheetBehavior.getState());
sheetDialog.dismiss();
});
return sheetDialog;
}
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())){
username.setError("This field can't empty");
password.setError("This field can't empty");
}else if (TextUtils.isEmpty(username.getText().toString())){
username.setError("This field can't empty");
}else if (TextUtils.isEmpty(password.getText().toString())){
password.setError("This field can't empty");
}else{
username.setEnabled(false);
password.setEnabled(false);
loginButton.setEnabled(false);
closeBtn.setEnabled(false);
mainViewModels.checkLogin(new UsersModels(username.getText().toString(),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) {
if (usersModelsDataResponse.getStatusData()) {
// SharedPreferences.Editor editor = sharedPreferences.edit();
// editor.putBoolean(SplashScreen.SESSION, true);
// editor.commit();
startActivity(new Intent(context, MainActivity.class));
username.setEnabled(true);
password.setEnabled(true);
loginButton.setEnabled(true);
closeBtn.setEnabled(true);
} else {
utils.snackBar(v, "Oppss! Wrong Username Or Password!").show();
username.setEnabled(true);
password.setEnabled(true);
loginButton.setEnabled(true);
closeBtn.setEnabled(true);
}
} else {
utils.snackBar(v, "Oppss! ログイン中にエラーが発生しました。しばらくしてからもう一度お試しください").show();
}
}
});
}
}
}
......@@ -163,6 +163,7 @@ public class PaymentActivity extends AppCompatActivity {
paymentResponses.add(new PaymentResponse("https://i.ibb.co/XCsdmmT/Bank-Mandiri-logo.png", "mandiri"));
paymentResponses.add(new PaymentResponse("https://i.ibb.co/2n65nCT/bca-bank-central-asia.png", "bca"));
paymentResponses.add(new PaymentResponse("https://i.ibb.co/RjJQT9K/BNI-logo.png", "bni"));
paymentResponses.add(new PaymentResponse("https://i.ibb.co/n1V3ZCf/Whats-App-Image-2020-09-01-at-14-50-13.jpg", "nfc"));
PaymentAdapter adapter = new PaymentAdapter(paymentResponses, this);
rvPayment.setAdapter(adapter);
......
......@@ -26,6 +26,9 @@ public interface CategoryServise {
@GET(ApiHelper.VERSI_API_1+"category-name/{id}")
Call<DataResponse<List<CategoryModels>>> getCategoryByName(@Path("id") String name);
@GET(ApiHelper.VERSI_API_1+"category/{id}")
Call<DataResponse<CategoryModels>> getCategoryId(@Path("id") int id);
@POST(ApiHelper.VERSI_API_1+"category")
Call<DataResponse<CategoryModels>> addCategory(@Body CategoryModels categoryModels);
......
......@@ -40,7 +40,6 @@
android:nestedScrollingEnabled="false"
android:layout_marginTop="20dp"
tools:layout_editor_absoluteX="10dp"
tools:listitem="@layout/item_checkout"
/>
<com.google.android.material.textview.MaterialTextView
......@@ -59,15 +58,21 @@
/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvPayment"
android:layout_width="match_parent"
<ExpandableListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:nestedScrollingEnabled="false"
tools:layout_editor_absoluteX="10dp"
tools:listitem="@layout/payment_list"
android:layout_below="@id/tvLabel"/>
android:layout_below="@+id/tvLabel">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvPayment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:nestedScrollingEnabled="false"
tools:layout_editor_absoluteX="10dp"
tools:listitem="@layout/payment_list"/>
</ExpandableListView>
</RelativeLayout>
</ScrollView>
......
<?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"
<!--<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"
tools:context=".LoginActivity">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/gradient"
android:paddingHorizontal="20dp"
android:paddingVertical="25dp">
......@@ -40,12 +46,11 @@
app:strokeColor="#fff"
android:text="sign up"
android:textStyle="bold"
android:textColor="@color/colorWhite"
android:textColor="#fff"
app:strokeWidth="2dp"
app:rippleColor="@color/colorWhite"
android:padding="20dp"
app:cornerRadius="5dp"
android:background="@color/colorPrimaryCenter"
android:layout_above="@id/signInButtonDashboardLogin"
android:layout_marginBottom="10dp"/>
......@@ -63,11 +68,6 @@
android:textColor="@color/colorPrimary"/>
</RelativeLayout>
</layout>
<include
layout="@layout/login_form"/>
<include
layout="@layout/register_form"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file
<!--</androidx.coordinatorlayout.widget.CoordinatorLayout>-->
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:tools="http://schemas.android.com/tools"
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">
<androidx.constraintlayout.widget.ConstraintLayout
<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"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageButton
android:id="@+id/ivclose"
android:layout_width="50dp"
android:layout_height="50dp"
android:adjustViewBounds="true"
android:backgroundTint="@android:color/transparent"
android:padding="50dp"
android:scaleType="centerInside"
android:src="@drawable/ic_close"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/messerLogoInLogin"
android:layout_width="215dp"
android:layout_height="215dp"
android:src="@drawable/ic_messer_primary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/ivclose" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/formUsernameLogin"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
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="wrap_content"
android:hint="@string/username"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/messerLogoInLogin">
android:layout_height="match_parent">
<com.google.android.material.textfield.TextInputEditText
<ImageButton
android:id="@+id/closeBtnLogin"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_baseline_plus_24"
android:scaleType="centerInside"
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:layout_height="wrap_content"
android:hint="@string/username"
android:layout_below="@id/messerLogoInLogin"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
</com.google.android.material.textfield.TextInputLayout>
<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
android:id="@+id/FormPasswordLogin"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/password"
app:layout_constraintTop_toBottomOf="@id/formUsernameLogin">
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputEditText
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/FormPasswordLogin"
android:layout_width="match_parent"
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"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/FormPasswordLogin"
app:useMaterialThemeColors="true" />
<com.google.android.material.button.MaterialButton
android:id="@+id/SignInButtonInLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="20dp"
android:text="Sign In"
app:layout_constraintTop_toBottomOf="@id/CBRememberMe" />
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: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"/>
<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"/>
</RelativeLayout>
<com.google.android.material.textview.MaterialTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Forgot Password?"
android:textColor="@color/colorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/SignInButtonInLogin" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -76,8 +76,8 @@
</style>
<style name="ShapeAppearanceOverlay.Rounded.top" parent="">
<item name="cornerSizeTopLeft">10dp</item>
<item name="cornerSizeTopRight">10dp</item>
<item name="cornerSizeTopLeft">30dp</item>
<item name="cornerSizeTopRight">30dp</item>
<item name="cornerFamily">rounded</item>
</style>
......
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