Commit 5b656e25 authored by Muhammad Suryono's avatar Muhammad Suryono

update

parents 40a816d9 41dab5ea
......@@ -18,19 +18,16 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProvider;
import androidx.fragment.app.DialogFragment;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import com.yono.messeripos.adapter.ProductAdapter;
import com.yono.messeripos.api.client.Client;
import com.yono.messeripos.api.service.PaymentService;
import com.yono.messeripos.models.PaymentsModels;
import com.yono.messeripos.models.ProductModels;
import com.yono.messeripos.response.DataResponse;
import com.yono.messeripos.utils.Utils;
import okhttp3.internal.Util;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
......@@ -53,6 +50,7 @@ public class BottomSheets extends BottomSheetDialogFragment {
RelativeLayout layoutFormCash;
PaymentsModels paymentsModels;
public BottomSheets(PaymentsModels paymentsModels) {
this.paymentsModels = paymentsModels;
}
......@@ -71,6 +69,7 @@ public class BottomSheets extends BottomSheetDialogFragment {
public View onCreateView(LayoutInflater inflater, @Nullable
ViewGroup container, @Nullable Bundle savedInstanceState)
{
View v = inflater.inflate(R.layout.activity_bottom_sheets,
container, false);
......@@ -83,6 +82,7 @@ public class BottomSheets extends BottomSheetDialogFragment {
// bottomSheetBehavior = BottomSheetBehavior.from(layoutFormCash);
sharedPreferences = getActivity().getSharedPreferences(MainActivity.MY_SHARED_PREFERENCES, Context.MODE_PRIVATE);
// bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
long ga = paymentsModels.getGrossAmount();
String setCurrency = utils.convertPrice("Rp.", ga);
......@@ -105,7 +105,7 @@ public class BottomSheets extends BottomSheetDialogFragment {
// break;
// }
// }
//
// @Override
// public void onSlide(@NonNull View bottomSheet, float slideOffset) {
// if (bottomSheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED) {
......@@ -124,7 +124,7 @@ public class BottomSheets extends BottomSheetDialogFragment {
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
if (TextUtils.isEmpty(charSequence)) inputAmount.setText("0");
if (TextUtils.isEmpty(charSequence)) inputAmount.setText("");
grossAmount = paymentsModels.getGrossAmount();
long input = Long.parseLong(inputAmount.getText().toString());
......@@ -146,6 +146,7 @@ public class BottomSheets extends BottomSheetDialogFragment {
}
private void bayar(View view) {
// String orderId, String paymentType, String bank, long grossAmount
PaymentsModels paymentsModels = new PaymentsModels(
sharedPreferences.getString(ORDER_ID, ""),
......
......@@ -3,7 +3,6 @@ package com.yono.messeripos;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
......@@ -12,11 +11,8 @@ import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
......@@ -34,7 +30,6 @@ import com.yono.messeripos.adapter.CartAdapter;
import com.yono.messeripos.api.client.Client;
import com.yono.messeripos.api.service.OrdersService;
import com.yono.messeripos.api.service.PaymentService;
import com.yono.messeripos.api.service.ProductService;
import com.yono.messeripos.models.MainViewModelsCart;
import com.yono.messeripos.models.PaymentsModels;
import com.yono.messeripos.models.ProductCartModels;
......@@ -50,7 +45,6 @@ import retrofit2.Call;
import retrofit2.Callback;
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;
......
......@@ -64,6 +64,7 @@ public class PaymentActivity extends AppCompatActivity {
private CheckoutAdapter checkoutAdapter;
private TextView grandTotal;
public static BottomSheets bottomSheet;
public static QRCode qrCode;
public static SharedPreferences sharedPreferences;
Button cashBtn;
ProgressDialog progressDialog;
......@@ -72,11 +73,11 @@ public class PaymentActivity extends AppCompatActivity {
PaymentsModels paymentsModelsIntent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_payment);
Log.i("Status Checkout payment", "onCreate: "+checkout);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow();
......@@ -172,7 +173,6 @@ public class PaymentActivity extends AppCompatActivity {
btnPay.setEnabled(true);
});
btnPay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
......@@ -181,50 +181,56 @@ public class PaymentActivity extends AppCompatActivity {
Log.i("CASH", "onClick: "+utils.convertGson(paymentsModels));
bottomSheet = new BottomSheets(paymentsModels);
bottomSheet.setCancelable(false);
bottomSheet.setCancelable(true);
bottomSheet.show(getSupportFragmentManager(),
"ModalBottomSheet");
}else{
progressDialog.show();
// bottomSheetBank.setState(BottomSheetBehavior.STATE_EXPANDED);
// progressDialog.show();
// Client client = new Client();
// paymentsModels.setPaymentType("bank_transfer");
// paymentsModels.setBank(methodPay);
// paymentsModels.setOrderId(orderId);
// Log.i("BANK", "onClick: "+utils.convertGson(paymentsModels));
// PaymentService paymentService = client.Client(PaymentService.class);
// paymentService.postFromCart(paymentsModels).enqueue(new Callback<DataResponse<PaymentsModels>>() {
// @Override
// public void onResponse(Call<DataResponse<PaymentsModels>> call, Response<DataResponse<PaymentsModels>> response) {
// Log.i("Paymen_bank", "onResponse: "+utils.convertGson(response.body()));
// if (response.body() != null){
// SharedPreferences.Editor editor = sharedPreferences.edit();
// editor.putString(ORDER_ID, "");
// editor.putBoolean(CHECKOUT, false);
// progressDialog.dismiss();
// if (editor.commit()){
// startActivity(new Intent(PaymentActivity.this, MainActivity.class));
// finish();
// }
// }else{
// progressDialog.dismiss();
// new AlertDialog.Builder(PaymentActivity.this)
// .setTitle("Payment Order")
// .setMessage("Erorr save!").show();
// }
// }
//
// @Override
// public void onFailure(Call<DataResponse<PaymentsModels>> call, Throwable t) {
// progressDialog.dismiss();
// new AlertDialog.Builder(PaymentActivity.this)
// .setCancelable(false)
// .setTitle("Payment Order")
// .setMessage("Add new payment failed, try again!").show();
// }
// });
Client client = new Client();
paymentsModels.setPaymentType("bank_transfer");
paymentsModels.setBank(methodPay);
paymentsModels.setOrderId(orderId);
Log.i("BANK", "onClick: "+utils.convertGson(paymentsModels));
PaymentService paymentService = client.Client(PaymentService.class);
paymentService.postFromCart(paymentsModels).enqueue(new Callback<DataResponse<PaymentsModels>>() {
@Override
public void onResponse(Call<DataResponse<PaymentsModels>> call, Response<DataResponse<PaymentsModels>> response) {
Log.i("Paymen_bank", "onResponse: "+utils.convertGson(response.body()));
if (response.body() != null){
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(ORDER_ID, "");
editor.putBoolean(CHECKOUT, false);
progressDialog.dismiss();
if (editor.commit()){
qrCode = new QRCode(response.body());
qrCode.show(
getSupportFragmentManager(),
"QRCode"
);
}
}else{
progressDialog.dismiss();
new AlertDialog.Builder(PaymentActivity.this)
.setTitle("Payment Order")
.setMessage("Erorr save!").show();
}
}
@Override
public void onFailure(Call<DataResponse<PaymentsModels>> call, Throwable t) {
progressDialog.dismiss();
new AlertDialog.Builder(PaymentActivity.this)
.setCancelable(false)
.setTitle("Payment Order")
.setMessage("Add new payment failed, try again!").show();
}
});
}
}
});
......
package com.yono.messeripos;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Point;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.ImageView;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import com.google.android.material.textview.MaterialTextView;
import com.google.zxing.WriterException;
import com.yono.messeripos.models.PaymentsModels;
import com.yono.messeripos.response.DataResponse;
import androidmads.library.qrgenearator.QRGContents;
import androidmads.library.qrgenearator.QRGEncoder;
public class QRCode extends AppCompatActivity {
public class QRCode extends BottomSheetDialogFragment {
ImageView qrCode;
MaterialTextView vaText;
QRGEncoder qrgEncoder;
String inputValue;
Bitmap bitmap;
DataResponse<PaymentsModels> paymentsModels;
public QRCode(DataResponse<PaymentsModels> paymentsModels) {
this.paymentsModels = paymentsModels;
Log.d("TAG", "QRCode: "+paymentsModels);
}
@Nullable
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_q_r_code);
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(
R.layout.activity_q_r_code,
container,
false
);
qrCode = findViewById(R.id.qr_image);
vaText = findViewById(R.id.etVA);
generateQrCode();
qrCode = v.findViewById(R.id.qr_image);
vaText = v.findViewById(R.id.etVA);
}
WindowManager manager = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE);
private void generateQrCode() {
WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);
Display display = manager.getDefaultDisplay();
Point point = new Point();
display.getSize(point);
......@@ -57,5 +74,9 @@ public class QRCode extends AppCompatActivity {
}catch (Exception e) {
Log.d("onCreate: ", e.toString());
}
return v;
}
}
\ No newline at end of file
package com.yono.messeripos;
import android.content.Context;
import com.google.android.material.appbar.MaterialToolbar;
public class ToolbarApp {
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/form_cash"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
style="@style/AppModalStyle"
android:padding="16dp">
app:behavior_hideable="true"
android:backgroundTint="#333"
app:behavior_peekHeight="60dp"
style="@style/Widget.Rounded.BottomSheet"
android:padding="16dp"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
<TextView
android:id="@+id/totalText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Total"
android:textSize="30dp"
android:textSize="30sp"
android:textFontWeight="600"
android:layout_alignParentStart="true" />
<TextView
android:id="@+id/changeText"
android:id="@+id/totalHarga"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Change"
android:textSize="20sp"
android:text="Rp. 600.000"
android:textSize="30dp"
android:textFontWeight="600"
android:layout_below="@id/totalText"
android:layout_alignParentStart="true" />
android:layout_alignParentEnd="true" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="@id/totalHarga">
<TextView
android:id="@+id/totalHarga"
android:id="@+id/changeText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rp. 600.000"
android:textSize="30dp"
android:text="Change"
android:textSize="20sp"
android:textFontWeight="600"
android:layout_alignParentEnd="true" />
android:layout_alignParentStart="true" />
<TextView
android:id="@+id/hargaChange"
......@@ -49,7 +55,6 @@
android:text="Rp. 600.000"
android:textSize="20sp"
android:textFontWeight="600"
android:layout_below="@id/totalHarga"
android:layout_alignParentEnd="true" />
<TextView
......@@ -57,6 +62,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bayar"
android:layout_marginTop="10dp"
android:textFontWeight="600"
android:layout_below="@id/changeText" />
......@@ -77,8 +83,8 @@
android:hint="Insert Money"
android:layout_below="@id/etBayar" />
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</RelativeLayout>
</RelativeLayout>
<?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="match_parent"
android:background="@color/colorPrimaryDark">
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -85,6 +85,7 @@
android:layout_alignParentStart="true"
/>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/qrCodeForm"
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:behavior_hideable="true"
app:behavior_peekHeight="56dp"
android:background="#efefef"
style="@style/Widget.Rounded.BottomSheet"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
tools:context=".QRCode">
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:id="@+id/qr_image"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_width="300dp"
android:layout_height="300dp"
android:backgroundTint="#333"
android:src="@mipmap/ic_launcher"
android:layout_centerInParent="true"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
/>
<com.google.android.material.textview.MaterialTextView
......@@ -28,10 +27,10 @@
android:text="Va_Text"
android:textSize="20sp"
android:textStyle="bold"
android:layout_below="@id/qr_image"
android:layout_centerInParent="true"
/>
app:layout_constraintTop_toBottomOf="@id/qr_image"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
/>
</RelativeLayout>
\ No newline at end of file
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -102,6 +102,7 @@
android:layout_marginTop="20dp"
android:background="@drawable/ic_rounded_circle"
android:padding="10dp"
android:tint="@color/colorWhite"
android:src="@drawable/ic_baseline_minus_24"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvPrice" />
......@@ -130,6 +131,7 @@
android:layout_height="wrap_content"
android:background="@drawable/ic_rounded_circle"
android:padding="10dp"
android:tint="@color/colorWhite"
android:src="@drawable/ic_baseline_plus_24"
app:layout_constraintBottom_toBottomOf="@id/tiQty"
app:layout_constraintStart_toEndOf="@id/tiQty" />
......
......@@ -24,6 +24,8 @@
<item name="windowActionBarOverlay">true</item>
<item name="android:fontFamily">@font/roboto</item>
<item name="actionBarStyle">@style/ThemeActionBar</item>
<item name="bottomSheetDialogTheme">@style/ThemeOverlay.Rounded.BottomSheetDialog</item>
</style>
<style name="AppTheme.my.a" parent="Theme.MaterialComponents.Light.NoActionBar">
......@@ -73,6 +75,22 @@
<item name="android:hint">Select kategori</item>
</style>
<style name="ShapeAppearanceOverlay.Rounded.top" parent="">
<item name="cornerSizeTopLeft">10dp</item>
<item name="cornerSizeTopRight">10dp</item>
<item name="cornerFamily">rounded</item>
</style>
<style
name="ThemeOverlay.Rounded.BottomSheetDialog"
parent="@style/ThemeOverlay.MaterialComponents.BottomSheetDialog">
<item name="bottomSheetStyle">@style/Widget.Rounded.BottomSheet</item>
</style>
<style name="Widget.Rounded.BottomSheet" parent="Widget.MaterialComponents.BottomSheet">
<item name="shapeAppearanceOverlay">@style/ShapeAppearanceOverlay.Rounded.top</item>
</style>
<style name="AppModalStyle" parent="Widget.Design.BottomSheet.Modal">
<item name="android:background">@drawable/round_corner_sheet</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