Commit 41dab5ea authored by iman Fauzi's avatar iman Fauzi

tambahkan qrcode

parent 700f1ea0
......@@ -80,9 +80,9 @@ public class BottomSheets extends BottomSheetDialogFragment {
totalHarga = v.findViewById(R.id.totalHarga);
utils = new Utils();
bottomSheetBehavior = BottomSheetBehavior.from(layoutFormCash);
// bottomSheetBehavior = BottomSheetBehavior.from(layoutFormCash);
sharedPreferences = getActivity().getSharedPreferences(MainActivity.MY_SHARED_PREFERENCES, Context.MODE_PRIVATE);
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
// bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
long ga = paymentsModels.getGrossAmount();
String setCurrency = utils.convertPrice("Rp.", ga);
......
......@@ -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;
......@@ -180,51 +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
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="16dp">
<TextView
android:id="@+id/totalText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Total"
android:textSize="30sp"
android:textFontWeight="600"
android:layout_alignParentStart="true" />
<TextView
android:id="@+id/changeText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Change"
android:textSize="20sp"
android:textFontWeight="600"
android:layout_below="@id/totalText"
android:layout_alignParentStart="true" />
<TextView
android:id="@+id/totalHarga"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rp. 600.000"
android:textSize="30dp"
android:textFontWeight="600"
android:layout_alignParentEnd="true" />
<TextView
android:id="@+id/hargaChange"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rp. 600.000"
android:textSize="20sp"
android:textFontWeight="600"
android:layout_below="@id/totalHarga"
android:layout_alignParentEnd="true" />
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bayar"
android:textFontWeight="600"
android:layout_below="@id/changeText" />
<EditText
android:id="@+id/etBayar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/label"
android:hint="Rp."
android:inputType="number"
android:imeOptions="actionDone"/>
<Button
android:id="@+id/btnCash"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/hint_pay"
android:hint="Insert Money"
android:layout_below="@id/etBayar" />
</RelativeLayout>
<?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"
app:behavior_hideable="true"
app:behavior_peekHeight="56dp"
android:backgroundTint="#333"
app:behavior_peekHeight="60dp"
style="@style/Widget.Rounded.BottomSheet"
android:padding="16dp">
android:padding="16dp"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
<TextView
android:id="@+id/totalText"
......@@ -28,23 +25,28 @@
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"
......@@ -53,7 +55,6 @@
android:text="Rp. 600.000"
android:textSize="20sp"
android:textFontWeight="600"
android:layout_below="@id/totalHarga"
android:layout_alignParentEnd="true" />
<TextView
......@@ -61,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" />
......@@ -81,8 +83,8 @@
android:hint="Insert Money"
android:layout_below="@id/etBayar" />
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</RelativeLayout>
</RelativeLayout>
......@@ -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
......@@ -76,8 +76,8 @@
</style>
<style name="ShapeAppearanceOverlay.Rounded.top" parent="">
<item name="cornerSizeTopLeft">30dp</item>
<item name="cornerSizeTopRight">30dp</item>
<item name="cornerSizeTopLeft">10dp</item>
<item name="cornerSizeTopRight">10dp</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