Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
meser
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Muhammad Suryono
meser
Commits
41dab5ea
Commit
41dab5ea
authored
Aug 31, 2020
by
iman Fauzi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
tambahkan qrcode
parent
700f1ea0
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
149 additions
and
196 deletions
+149
-196
BottomSheets.java
app/src/main/java/com/yono/messeripos/BottomSheets.java
+2
-2
PaymentActivity.java
app/src/main/java/com/yono/messeripos/PaymentActivity.java
+44
-38
QRCode.java
app/src/main/java/com/yono/messeripos/QRCode.java
+31
-10
activity_bottom_sheets.xml
app/src/main/res/layout-v28/activity_bottom_sheets.xml
+0
-76
activity_bottom_sheets.xml
app/src/main/res/layout/activity_bottom_sheets.xml
+53
-51
activity_payment.xml
app/src/main/res/layout/activity_payment.xml
+1
-0
activity_q_r_code.xml
app/src/main/res/layout/activity_q_r_code.xml
+16
-17
styles.xml
app/src/main/res/values/styles.xml
+2
-2
No files found.
app/src/main/java/com/yono/messeripos/BottomSheets.java
View file @
41dab5ea
...
...
@@ -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_COLLAPS
ED
);
// bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPAND
ED);
long
ga
=
paymentsModels
.
getGrossAmount
();
String
setCurrency
=
utils
.
convertPrice
(
"Rp."
,
ga
);
...
...
app/src/main/java/com/yono/messeripos/PaymentActivity.java
View file @
41dab5ea
...
...
@@ -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
(
fals
e
);
bottomSheet
.
setCancelable
(
tru
e
);
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
();
}
});
}
}
});
...
...
app/src/main/java/com/yono/messeripos/QRCode.java
View file @
41dab5ea
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
app/src/main/res/layout-v28/activity_bottom_sheets.xml
deleted
100644 → 0
View file @
700f1ea0
<?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>
app/src/main/res/layout/activity_bottom_sheets.xml
View file @
41dab5ea
<?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_par
ent"
android:layout_height=
"
wrap_cont
ent"
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=
"
20s
p"
android:text=
"
Rp. 600.000
"
android:textSize=
"
30d
p"
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=
"30d
p"
android:text=
"Change
"
android:textSize=
"20s
p"
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>
app/src/main/res/layout/activity_payment.xml
View file @
41dab5ea
...
...
@@ -85,6 +85,7 @@
android:layout_alignParentStart=
"true"
/>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
app/src/main/res/layout/activity_q_r_code.xml
View file @
41dab5ea
<?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=
"
2
00dp"
android:layout_height=
"
2
00dp"
android:layout_width=
"
3
00dp"
android:layout_height=
"
3
00dp"
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
app/src/main/res/values/styles.xml
View file @
41dab5ea
...
...
@@ -76,8 +76,8 @@
</style>
<style
name=
"ShapeAppearanceOverlay.Rounded.top"
parent=
""
>
<item
name=
"cornerSizeTopLeft"
>
3
0dp
</item>
<item
name=
"cornerSizeTopRight"
>
3
0dp
</item>
<item
name=
"cornerSizeTopLeft"
>
1
0dp
</item>
<item
name=
"cornerSizeTopRight"
>
1
0dp
</item>
<item
name=
"cornerFamily"
>
rounded
</item>
</style>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment