Skip to content

Commit e5aab10

Browse files
committed
Open checkout bar for customization
1 parent a7f9ab8 commit e5aab10

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [0.48.4]
5+
6+
### Changes
7+
- Open checkout bar for customization
8+
49
## [0.48.3]
510

611
### Changes

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ allprojects {
3131
}
3232

3333
project.ext {
34-
sdkVersion='0.48.3'
34+
sdkVersion='0.48.4'
3535
versionCode=1
3636

3737
compileSdkVersion=31

ui/src/main/java/io/snabble/sdk/ui/cart/CheckoutBar.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import io.snabble.sdk.ui.telemetry.Telemetry
3232
import io.snabble.sdk.ui.utils.*
3333

3434

35-
class CheckoutBar @JvmOverloads constructor(
35+
open class CheckoutBar @JvmOverloads constructor(
3636
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
3737
) : LinearLayout(context, attrs, defStyleAttr), Checkout.OnCheckoutStateChangedListener {
3838
private lateinit var progressDialog: DelayedProgressDialog
@@ -75,15 +75,15 @@ class CheckoutBar @JvmOverloads constructor(
7575

7676
binding.pay.setOneShotClickListener {
7777
cart.taxation = ShoppingCart.Taxation.UNDECIDED
78-
payClick()
78+
handleButtonClick()
7979
}
8080

8181
binding.googlePayButtonLayout.googlePayButton.setOneShotClickListener {
8282
val packageName = "com.google.android.apps.walletnfcrel"
8383
val pm = context.packageManager
8484
try {
8585
pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES)
86-
payClick()
86+
handleButtonClick()
8787
} catch (e: PackageManager.NameNotFoundException) {
8888
try {
8989
context.startActivity(Intent(Intent.ACTION_VIEW,
@@ -127,15 +127,19 @@ class CheckoutBar @JvmOverloads constructor(
127127
})
128128
}
129129

130-
private fun payClick() {
130+
private fun handleButtonClick() {
131131
if (cart.isRestorable) {
132132
cart.restore()
133133
update()
134134
} else {
135-
pay()
135+
onPayClick()
136136
}
137137
}
138138

139+
protected open fun onPayClick() {
140+
pay()
141+
}
142+
139143
private fun update() {
140144
updatePaymentSelector()
141145
updatePayAndText()
@@ -197,7 +201,7 @@ class CheckoutBar @JvmOverloads constructor(
197201
}
198202
}
199203

200-
private fun pay() {
204+
protected fun pay() {
201205
if (cart.hasReachedMaxCheckoutLimit()) {
202206
val message = resources.getString(R.string.Snabble_limitsAlert_checkoutNotAvailable,
203207
project.priceFormatter.format(project.maxCheckoutLimit))

0 commit comments

Comments
 (0)