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

tambahkan qrcode

parent 700f1ea0
...@@ -80,9 +80,9 @@ public class BottomSheets extends BottomSheetDialogFragment { ...@@ -80,9 +80,9 @@ public class BottomSheets extends BottomSheetDialogFragment {
totalHarga = v.findViewById(R.id.totalHarga); totalHarga = v.findViewById(R.id.totalHarga);
utils = new Utils(); utils = new Utils();
bottomSheetBehavior = BottomSheetBehavior.from(layoutFormCash); // bottomSheetBehavior = BottomSheetBehavior.from(layoutFormCash);
sharedPreferences = getActivity().getSharedPreferences(MainActivity.MY_SHARED_PREFERENCES, Context.MODE_PRIVATE); sharedPreferences = getActivity().getSharedPreferences(MainActivity.MY_SHARED_PREFERENCES, Context.MODE_PRIVATE);
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); // bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
long ga = paymentsModels.getGrossAmount(); long ga = paymentsModels.getGrossAmount();
String setCurrency = utils.convertPrice("Rp.", ga); String setCurrency = utils.convertPrice("Rp.", ga);
......
...@@ -64,6 +64,7 @@ public class PaymentActivity extends AppCompatActivity { ...@@ -64,6 +64,7 @@ public class PaymentActivity extends AppCompatActivity {
private CheckoutAdapter checkoutAdapter; private CheckoutAdapter checkoutAdapter;
private TextView grandTotal; private TextView grandTotal;
public static BottomSheets bottomSheet; public static BottomSheets bottomSheet;
public static QRCode qrCode;
public static SharedPreferences sharedPreferences; public static SharedPreferences sharedPreferences;
Button cashBtn; Button cashBtn;
ProgressDialog progressDialog; ProgressDialog progressDialog;
...@@ -180,51 +181,56 @@ public class PaymentActivity extends AppCompatActivity { ...@@ -180,51 +181,56 @@ public class PaymentActivity extends AppCompatActivity {
Log.i("CASH", "onClick: "+utils.convertGson(paymentsModels)); Log.i("CASH", "onClick: "+utils.convertGson(paymentsModels));
bottomSheet = new BottomSheets(paymentsModels); bottomSheet = new BottomSheets(paymentsModels);
bottomSheet.setCancelable(false); bottomSheet.setCancelable(true);
bottomSheet.show(getSupportFragmentManager(), bottomSheet.show(getSupportFragmentManager(),
"ModalBottomSheet"); "ModalBottomSheet");
}else{ }else{
progressDialog.show();
// bottomSheetBank.setState(BottomSheetBehavior.STATE_EXPANDED); // bottomSheetBank.setState(BottomSheetBehavior.STATE_EXPANDED);
// progressDialog.show(); // progressDialog.show();
// Client client = new Client(); Client client = new Client();
// paymentsModels.setPaymentType("bank_transfer"); paymentsModels.setPaymentType("bank_transfer");
// paymentsModels.setBank(methodPay); paymentsModels.setBank(methodPay);
// paymentsModels.setOrderId(orderId); paymentsModels.setOrderId(orderId);
// Log.i("BANK", "onClick: "+utils.convertGson(paymentsModels)); Log.i("BANK", "onClick: "+utils.convertGson(paymentsModels));
// PaymentService paymentService = client.Client(PaymentService.class); PaymentService paymentService = client.Client(PaymentService.class);
// paymentService.postFromCart(paymentsModels).enqueue(new Callback<DataResponse<PaymentsModels>>() { paymentService.postFromCart(paymentsModels).enqueue(new Callback<DataResponse<PaymentsModels>>() {
// @Override @Override
// public void onResponse(Call<DataResponse<PaymentsModels>> call, Response<DataResponse<PaymentsModels>> response) { public void onResponse(Call<DataResponse<PaymentsModels>> call, Response<DataResponse<PaymentsModels>> response) {
// Log.i("Paymen_bank", "onResponse: "+utils.convertGson(response.body())); Log.i("Paymen_bank", "onResponse: "+utils.convertGson(response.body()));
// if (response.body() != null){
// SharedPreferences.Editor editor = sharedPreferences.edit(); if (response.body() != null){
// editor.putString(ORDER_ID, ""); SharedPreferences.Editor editor = sharedPreferences.edit();
// editor.putBoolean(CHECKOUT, false); editor.putString(ORDER_ID, "");
// progressDialog.dismiss(); editor.putBoolean(CHECKOUT, false);
// if (editor.commit()){ progressDialog.dismiss();
// startActivity(new Intent(PaymentActivity.this, MainActivity.class)); if (editor.commit()){
// finish(); qrCode = new QRCode(response.body());
// } qrCode.show(
// }else{ getSupportFragmentManager(),
// progressDialog.dismiss(); "QRCode"
// 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();
// }
// });
}
}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; package com.yono.messeripos;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Point; import android.graphics.Point;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.Display; import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import com.google.android.material.textview.MaterialTextView; import com.google.android.material.textview.MaterialTextView;
import com.google.zxing.WriterException; 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.QRGContents;
import androidmads.library.qrgenearator.QRGEncoder; import androidmads.library.qrgenearator.QRGEncoder;
public class QRCode extends AppCompatActivity { public class QRCode extends BottomSheetDialogFragment {
ImageView qrCode; ImageView qrCode;
MaterialTextView vaText; MaterialTextView vaText;
QRGEncoder qrgEncoder; QRGEncoder qrgEncoder;
String inputValue; String inputValue;
Bitmap bitmap; Bitmap bitmap;
DataResponse<PaymentsModels> paymentsModels;
public QRCode(DataResponse<PaymentsModels> paymentsModels) {
this.paymentsModels = paymentsModels;
Log.d("TAG", "QRCode: "+paymentsModels);
}
@Nullable
@Override @Override
protected void onCreate(Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); View v = inflater.inflate(
setContentView(R.layout.activity_q_r_code); R.layout.activity_q_r_code,
container,
false
);
qrCode = findViewById(R.id.qr_image); qrCode = v.findViewById(R.id.qr_image);
vaText = findViewById(R.id.etVA); vaText = v.findViewById(R.id.etVA);
generateQrCode();
} WindowManager manager = (WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE);
private void generateQrCode() {
WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);
Display display = manager.getDefaultDisplay(); Display display = manager.getDefaultDisplay();
Point point = new Point(); Point point = new Point();
display.getSize(point); display.getSize(point);
...@@ -57,5 +74,9 @@ public class QRCode extends AppCompatActivity { ...@@ -57,5 +74,9 @@ public class QRCode extends AppCompatActivity {
}catch (Exception e) { }catch (Exception e) {
Log.d("onCreate: ", e.toString()); 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"?> <?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 <RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/form_cash" android:id="@+id/form_cash"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="vertical" android:orientation="vertical"
app:behavior_hideable="true" app:behavior_hideable="true"
app:behavior_peekHeight="56dp" android:backgroundTint="#333"
app:behavior_peekHeight="60dp"
style="@style/Widget.Rounded.BottomSheet" style="@style/Widget.Rounded.BottomSheet"
android:padding="16dp"> android:padding="16dp"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
<TextView <TextView
android:id="@+id/totalText" android:id="@+id/totalText"
...@@ -28,23 +25,28 @@ ...@@ -28,23 +25,28 @@
android:layout_alignParentStart="true" /> android:layout_alignParentStart="true" />
<TextView <TextView
android:id="@+id/changeText" android:id="@+id/totalHarga"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Change" android:text="Rp. 600.000"
android:textSize="20sp" android:textSize="30dp"
android:textFontWeight="600" android:textFontWeight="600"
android:layout_below="@id/totalText" android:layout_alignParentEnd="true" />
android:layout_alignParentStart="true" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="@id/totalHarga">
<TextView <TextView
android:id="@+id/totalHarga" android:id="@+id/changeText"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Rp. 600.000" android:text="Change"
android:textSize="30dp" android:textSize="20sp"
android:textFontWeight="600" android:textFontWeight="600"
android:layout_alignParentEnd="true" /> android:layout_alignParentStart="true" />
<TextView <TextView
android:id="@+id/hargaChange" android:id="@+id/hargaChange"
...@@ -53,7 +55,6 @@ ...@@ -53,7 +55,6 @@
android:text="Rp. 600.000" android:text="Rp. 600.000"
android:textSize="20sp" android:textSize="20sp"
android:textFontWeight="600" android:textFontWeight="600"
android:layout_below="@id/totalHarga"
android:layout_alignParentEnd="true" /> android:layout_alignParentEnd="true" />
<TextView <TextView
...@@ -61,6 +62,7 @@ ...@@ -61,6 +62,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Bayar" android:text="Bayar"
android:layout_marginTop="10dp"
android:textFontWeight="600" android:textFontWeight="600"
android:layout_below="@id/changeText" /> android:layout_below="@id/changeText" />
...@@ -81,8 +83,8 @@ ...@@ -81,8 +83,8 @@
android:hint="Insert Money" android:hint="Insert Money"
android:layout_below="@id/etBayar" /> android:layout_below="@id/etBayar" />
</RelativeLayout> </RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</RelativeLayout>
...@@ -85,6 +85,7 @@ ...@@ -85,6 +85,7 @@
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
/> />
</RelativeLayout> </RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout> </androidx.coordinatorlayout.widget.CoordinatorLayout>
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/qrCodeForm" <androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_parent"
android:layout_width="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" style="@style/Widget.Rounded.BottomSheet"
android:layout_height="wrap_content"
app:behavior_hideable="true"
app:behavior_peekHeight="56dp"
android:background="#efefef"
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior" app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"
tools:context=".QRCode"> xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView <ImageView
android:id="@+id/qr_image" android:id="@+id/qr_image"
android:layout_width="200dp" android:layout_width="300dp"
android:layout_height="200dp" android:layout_height="300dp"
android:backgroundTint="#333" android:backgroundTint="#333"
android:src="@mipmap/ic_launcher" 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 <com.google.android.material.textview.MaterialTextView
...@@ -28,10 +27,10 @@ ...@@ -28,10 +27,10 @@
android:text="Va_Text" android:text="Va_Text"
android:textSize="20sp" android:textSize="20sp"
android:textStyle="bold" android:textStyle="bold"
android:layout_below="@id/qr_image" app:layout_constraintTop_toBottomOf="@id/qr_image"
android:layout_centerInParent="true" app:layout_constraintEnd_toEndOf="parent"
/> app:layout_constraintStart_toStartOf="parent"
/>
</RelativeLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file \ No newline at end of file
...@@ -76,8 +76,8 @@ ...@@ -76,8 +76,8 @@
</style> </style>
<style name="ShapeAppearanceOverlay.Rounded.top" parent=""> <style name="ShapeAppearanceOverlay.Rounded.top" parent="">
<item name="cornerSizeTopLeft">30dp</item> <item name="cornerSizeTopLeft">10dp</item>
<item name="cornerSizeTopRight">30dp</item> <item name="cornerSizeTopRight">10dp</item>
<item name="cornerFamily">rounded</item> <item name="cornerFamily">rounded</item>
</style> </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