diff --git a/.editorconfig b/.editorconfig
index e855d433..4c697b24 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -8,6 +8,10 @@ indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
+[*.{kt,kts}]
+ij_kotlin_allow_trailing_comma=true
+ij_kotlin_allow_trailing_comma_on_call_site=true
+
[*.md]
trim_trailing_whitespace = false
diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml
index 72fbd336..3dd04860 100644
--- a/.github/workflows/build-and-test.yml
+++ b/.github/workflows/build-and-test.yml
@@ -12,12 +12,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone Repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- name: Set up JDK 11
- uses: actions/setup-java@v1
+ uses: actions/setup-java@v2
with:
- java-version: '11'
+ java-version: 11
+ distribution: 'zulu'
- name: Lint
run: ./gradlew afterpay:lintDebug afterpay:ktlint
@@ -30,12 +31,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone Repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- name: Set up JDK 11
- uses: actions/setup-java@v1
+ uses: actions/setup-java@v2
with:
- java-version: '11'
+ java-version: 11
+ distribution: 'zulu'
- name: Build and Lint
run: ./gradlew example:buildDebug example:lintDebug example:ktlint
diff --git a/.github/workflows/release-snapshot.yml b/.github/workflows/release-snapshot.yml
index 447c0648..8a954d11 100644
--- a/.github/workflows/release-snapshot.yml
+++ b/.github/workflows/release-snapshot.yml
@@ -9,12 +9,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone Repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- name: Set up JDK 11
- uses: actions/setup-java@v1
+ uses: actions/setup-java@v2
with:
- java-version: '11'
+ java-version: 11
+ distribution: 'zulu'
- name: Clean repository before building SDK
run: ./gradlew clean
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 330bea41..a9f59809 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -9,12 +9,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone Repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v3
- name: Set up JDK 11
- uses: actions/setup-java@v1
+ uses: actions/setup-java@v2
with:
- java-version: '11'
+ java-version: 11
+ distribution: 'zulu'
- name: Remove SNAPSHOT from version
run: sed -i 's/-SNAPSHOT//g' gradle.properties
diff --git a/.idea/androidTestResultsUserPreferences.xml b/.idea/androidTestResultsUserPreferences.xml
new file mode 100644
index 00000000..01cf8f7d
--- /dev/null
+++ b/.idea/androidTestResultsUserPreferences.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 4e2fe53d..7829f3cf 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -6,15 +6,6 @@
-
diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml
new file mode 100644
index 00000000..566ad480
--- /dev/null
+++ b/.idea/deploymentTargetDropDown.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/afterpay/consumer-rules.pro b/afterpay/consumer-rules.pro
index 68cf0603..4641d8ca 100644
--- a/afterpay/consumer-rules.pro
+++ b/afterpay/consumer-rules.pro
@@ -1,5 +1,4 @@
-keepattributes *Annotation*, InnerClasses
--dontnote kotlinx.serialization.AnnotationsKt # core serialization annotations
# kotlinx-serialization-json specific. Add this if you have java.lang.NoClassDefFoundError kotlinx.serialization.json.JsonObjectSerializer
-keepclassmembers class kotlinx.serialization.json.** {
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/Afterpay.kt b/afterpay/src/main/kotlin/com/afterpay/android/Afterpay.kt
index 98e1e5f3..851e3e17 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/Afterpay.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/Afterpay.kt
@@ -71,7 +71,7 @@ object Afterpay {
@JvmStatic
fun createCheckoutV2Intent(
context: Context,
- options: AfterpayCheckoutV2Options = AfterpayCheckoutV2Options()
+ options: AfterpayCheckoutV2Options = AfterpayCheckoutV2Options(),
): Intent = Intent(context, AfterpayCheckoutV2Activity::class.java)
.putCheckoutV2OptionsExtra(options)
@@ -107,14 +107,14 @@ object Afterpay {
maximumAmount: String,
currencyCode: String,
locale: Locale,
- environment: AfterpayEnvironment
+ environment: AfterpayEnvironment,
) {
configuration = Configuration(
minimumAmount = minimumAmount?.toBigDecimal(),
maximumAmount = maximumAmount.toBigDecimal(),
currency = Currency.getInstance(currencyCode),
locale = locale.clone() as Locale,
- environment = environment
+ environment = environment,
).also { configuration ->
if (configuration.maximumAmount < BigDecimal.ZERO) {
throw IllegalArgumentException("Maximum order amount is invalid")
@@ -128,7 +128,7 @@ object Afterpay {
val validCountries = Locales.validSet.map { it.country }
throw IllegalArgumentException(
"Locale contains an unsupported country: ${configuration.locale.country}. " +
- "Supported countries include: ${validCountries.joinToString(",")}"
+ "Supported countries include: ${validCountries.joinToString(",")}",
)
}
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/AfterpayCheckoutV2Handler.kt b/afterpay/src/main/kotlin/com/afterpay/android/AfterpayCheckoutV2Handler.kt
index 0df2d135..cada9685 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/AfterpayCheckoutV2Handler.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/AfterpayCheckoutV2Handler.kt
@@ -10,11 +10,11 @@ interface AfterpayCheckoutV2Handler {
fun shippingAddressDidChange(
address: ShippingAddress,
- onProvideShippingOptions: (ShippingOptionsResult) -> Unit
+ onProvideShippingOptions: (ShippingOptionsResult) -> Unit,
)
fun shippingOptionDidChange(
shippingOption: ShippingOption,
- onProvideShippingOption: (ShippingOptionUpdateResult?) -> Unit
+ onProvideShippingOption: (ShippingOptionUpdateResult?) -> Unit,
)
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/AfterpayCheckoutV2Options.kt b/afterpay/src/main/kotlin/com/afterpay/android/AfterpayCheckoutV2Options.kt
index f41e6a8a..8b9ac3de 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/AfterpayCheckoutV2Options.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/AfterpayCheckoutV2Options.kt
@@ -7,13 +7,13 @@ data class AfterpayCheckoutV2Options(
val pickup: Boolean? = null,
val buyNow: Boolean? = null,
val shippingOptionRequired: Boolean? = null,
- val enableSingleShippingOptionUpdate: Boolean? = null
+ val enableSingleShippingOptionUpdate: Boolean? = null,
) : Parcelable {
constructor(parcel: Parcel) : this(
parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
- parcel.readValue(Boolean::class.java.classLoader) as? Boolean
+ parcel.readValue(Boolean::class.java.classLoader) as? Boolean,
)
override fun writeToParcel(parcel: Parcel, flags: Int) {
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/AfterpayEnvironment.kt b/afterpay/src/main/kotlin/com/afterpay/android/AfterpayEnvironment.kt
index 3d667e1b..a660cbc5 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/AfterpayEnvironment.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/AfterpayEnvironment.kt
@@ -5,5 +5,5 @@ import java.util.Locale
enum class AfterpayEnvironment {
SANDBOX, PRODUCTION;
- override fun toString(): String = name.toLowerCase(Locale.ROOT)
+ override fun toString(): String = name.lowercase(Locale.ROOT)
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutCompletion.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutCompletion.kt
index 8e1e6018..59aae95e 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutCompletion.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutCompletion.kt
@@ -5,13 +5,13 @@ import kotlinx.serialization.Serializable
@Serializable
internal data class AfterpayCheckoutCompletion(
val status: Status,
- val orderToken: String
+ val orderToken: String,
) {
@Suppress("UNUSED_PARAMETER")
@Serializable
internal enum class Status(statusString: String) {
SUCCESS("SUCCESS"),
- CANCELLED("CANCELLED")
+ CANCELLED("CANCELLED"),
}
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutMessage.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutMessage.kt
index f0eefab0..7b13f84b 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutMessage.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutMessage.kt
@@ -24,7 +24,7 @@ internal sealed class AfterpayCheckoutMessage {
fun fromShippingOptionsResult(
result: ShippingOptionsResult,
- meta: AfterpayCheckoutMessageMeta
+ meta: AfterpayCheckoutMessageMeta,
): AfterpayCheckoutMessage = when (result) {
is ShippingOptionsErrorResult -> CheckoutErrorMessage(meta, result.error.name)
is ShippingOptionsSuccessResult -> ShippingOptionsMessage(meta, result.shippingOptions)
@@ -32,12 +32,12 @@ internal sealed class AfterpayCheckoutMessage {
fun fromShippingOptionUpdateResult(
result: ShippingOptionUpdateResult?,
- meta: AfterpayCheckoutMessageMeta
+ meta: AfterpayCheckoutMessageMeta,
): AfterpayCheckoutMessage = when (result) {
is ShippingOptionUpdateErrorResult -> CheckoutErrorMessage(meta, result.error.name)
is ShippingOptionUpdateSuccessResult -> ShippingOptionUpdateMessage(
meta,
- result.shippingOptionUpdate
+ result.shippingOptionUpdate,
)
null -> EmptyPayloadMessage(meta)
}
@@ -48,13 +48,13 @@ internal sealed class AfterpayCheckoutMessage {
@SerialName("onMessage")
internal data class CheckoutLogMessage(
override val meta: AfterpayCheckoutMessageMeta,
- val payload: CheckoutLog
+ val payload: CheckoutLog,
) : AfterpayCheckoutMessage() {
@Serializable
internal data class CheckoutLog(
val severity: String,
- val message: String
+ val message: String,
)
}
@@ -62,39 +62,39 @@ internal data class CheckoutLogMessage(
@SerialName("onError")
internal data class CheckoutErrorMessage(
override val meta: AfterpayCheckoutMessageMeta,
- val error: String
+ val error: String,
) : AfterpayCheckoutMessage()
@Serializable
@SerialName("onShippingAddressChange")
internal data class ShippingAddressMessage(
override val meta: AfterpayCheckoutMessageMeta,
- val payload: ShippingAddress
+ val payload: ShippingAddress,
) : AfterpayCheckoutMessage()
@Serializable
@SerialName("onShippingOptionChange")
internal data class ShippingOptionMessage(
override val meta: AfterpayCheckoutMessageMeta,
- val payload: ShippingOption
+ val payload: ShippingOption,
) : AfterpayCheckoutMessage()
@Serializable
@SerialName("onShippingOptionUpdateChange")
internal data class ShippingOptionUpdateMessage(
override val meta: AfterpayCheckoutMessageMeta,
- val payload: ShippingOptionUpdate?
+ val payload: ShippingOptionUpdate?,
) : AfterpayCheckoutMessage()
@Serializable
@SerialName("onShippingOptionsChange")
internal data class ShippingOptionsMessage(
override val meta: AfterpayCheckoutMessageMeta,
- val payload: List
+ val payload: List,
) : AfterpayCheckoutMessage()
@Serializable
@SerialName("onEmptyPayload")
internal data class EmptyPayloadMessage(
- override val meta: AfterpayCheckoutMessageMeta
+ override val meta: AfterpayCheckoutMessageMeta,
) : AfterpayCheckoutMessage()
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutV2.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutV2.kt
index dddff164..3ba20012 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutV2.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayCheckoutV2.kt
@@ -20,7 +20,7 @@ internal data class AfterpayCheckoutV2(
constructor(
token: String,
configuration: Configuration,
- options: AfterpayCheckoutV2Options
+ options: AfterpayCheckoutV2Options,
) : this(
token = token,
locale = configuration.locale.toString(),
@@ -30,6 +30,6 @@ internal data class AfterpayCheckoutV2(
buyNow = options.buyNow,
shippingOptionRequired = options.shippingOptionRequired,
checkoutRedesignForced = options.enableSingleShippingOptionUpdate,
- consumerLocale = Afterpay.language.toString()
+ consumerLocale = Afterpay.language.toString(),
)
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayDrawable.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayDrawable.kt
index 7ae7d2b2..0597b40b 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayDrawable.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayDrawable.kt
@@ -66,7 +66,8 @@ internal enum class AfterpayDrawable(
buttonCheckoutForeground = R.drawable.clearpay_button_checkout_fg_es,
buttonPayNowForeground = R.drawable.clearpay_button_pay_now_fg_es,
buttonPlaceOrderForeground = R.drawable.clearpay_button_place_order_fg_es,
- );
+ ),
+ ;
companion object {
fun forLocale(): AfterpayDrawable {
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayInstalment.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayInstalment.kt
index 83cd26c4..ad8162ee 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayInstalment.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayInstalment.kt
@@ -9,12 +9,12 @@ import java.util.Locale
internal sealed class AfterpayInstalment {
data class Available(
- val instalmentAmount: String
+ val instalmentAmount: String,
) : AfterpayInstalment()
data class NotAvailable(
val minimumAmount: String?,
- val maximumAmount: String
+ val maximumAmount: String,
) : AfterpayInstalment()
object NoConfiguration : AfterpayInstalment()
@@ -83,7 +83,7 @@ internal sealed class AfterpayInstalment {
return NotAvailable(
minimumAmount = configuration.minimumAmount?.let(currencyFormatterNoDecimals::format),
- maximumAmount = currencyFormatterNoDecimals.format(configuration.maximumAmount)
+ maximumAmount = currencyFormatterNoDecimals.format(configuration.maximumAmount),
)
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayString.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayString.kt
index 46f89b60..cb0f0da4 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayString.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/AfterpayString.kt
@@ -53,7 +53,7 @@ internal enum class AfterpayString(
val priceBreakdownWith: String,
val priceBreakdownInterestFree: String,
val priceBreakdownLinkLearnMore: String,
- val priceBreakdownLinkMoreInfo: String
+ val priceBreakdownLinkMoreInfo: String,
) {
EN(
breakdownLimit = "available for orders between %1\$s – %2\$s",
@@ -80,7 +80,7 @@ internal enum class AfterpayString(
priceBreakdownWith = "with ",
priceBreakdownInterestFree = "interest-free ",
priceBreakdownLinkLearnMore = "Learn More",
- priceBreakdownLinkMoreInfo = "More Info"
+ priceBreakdownLinkMoreInfo = "More Info",
),
FR_CA(
breakdownLimit = "disponible pour les montants entre %1\$s – %2\$s",
@@ -189,7 +189,8 @@ internal enum class AfterpayString(
priceBreakdownInterestFree = "sin coste ",
priceBreakdownLinkLearnMore = "Saber más",
priceBreakdownLinkMoreInfo = "Más infos",
- );
+ ),
+ ;
companion object {
fun forLocale(): AfterpayString {
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/Brand.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/Brand.kt
index c62440fb..3b956eeb 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/Brand.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/Brand.kt
@@ -38,7 +38,8 @@ internal enum class Brand(
description = R.string.clearpay_service_name_description,
badgeForeground = R.drawable.clearpay_badge_fg,
lockup = R.drawable.clearpay_lockup,
- );
+ ),
+ ;
companion object {
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/Configuration.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/Configuration.kt
index e13f2708..95541ec6 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/Configuration.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/Configuration.kt
@@ -10,5 +10,5 @@ internal data class Configuration(
val maximumAmount: BigDecimal,
val currency: Currency,
val locale: Locale,
- val environment: AfterpayEnvironment
+ val environment: AfterpayEnvironment,
)
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/Locales.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/Locales.kt
index b10a5bd2..19effbb2 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/Locales.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/Locales.kt
@@ -33,7 +33,7 @@ internal object Locales {
EN_US,
IT_IT,
FR_FR,
- ES_ES
+ ES_ES,
)
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/Resources.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/Resources.kt
index 1a39739d..f8ef1e10 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/Resources.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/Resources.kt
@@ -18,7 +18,7 @@ internal val Float.dp: Float
get() = TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP,
this,
- Resources.getSystem().displayMetrics
+ Resources.getSystem().displayMetrics,
)
internal val Int.dp: Int
@@ -40,7 +40,7 @@ internal fun Context.color(@ColorRes colorResId: Int): Int {
internal fun Context.coloredDrawable(
@DrawableRes drawableResId: Int,
- @ColorRes colorResId: Int
+ @ColorRes colorResId: Int,
): Drawable = ContextCompat.getDrawable(this, drawableResId).let {
checkNotNull(it) { "Drawable resource not found" }
val wrappedDrawable = DrawableCompat.wrap(it)
@@ -50,9 +50,9 @@ internal fun Context.coloredDrawable(
internal fun Context.rippleDrawable(
@ColorRes rippleColorResId: Int,
- drawable: Drawable
+ drawable: Drawable,
): Drawable = RippleDrawable(
ColorStateList.valueOf(color(rippleColorResId)),
drawable,
- null
+ null,
)
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/internal/Serializers.kt b/afterpay/src/main/kotlin/com/afterpay/android/internal/Serializers.kt
index 11195e26..0634950f 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/internal/Serializers.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/internal/Serializers.kt
@@ -12,7 +12,7 @@ internal object BigDecimalSerializer : KSerializer {
override val descriptor = PrimitiveSerialDescriptor(
serialName = "BigDecimal",
- kind = PrimitiveKind.STRING
+ kind = PrimitiveKind.STRING,
)
override fun deserialize(decoder: Decoder) = decoder.decodeString().toBigDecimal()
@@ -25,7 +25,7 @@ internal object CurrencySerializer : KSerializer {
override val descriptor = PrimitiveSerialDescriptor(
serialName = "Currency",
- kind = PrimitiveKind.STRING
+ kind = PrimitiveKind.STRING,
)
override fun deserialize(decoder: Decoder): Currency =
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/Money.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/Money.kt
index 37b8f129..9fab0144 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/Money.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/Money.kt
@@ -9,5 +9,5 @@ import java.util.Currency
@Serializable
data class Money(
@Serializable(with = BigDecimalSerializer::class) val amount: BigDecimal,
- @Serializable(with = CurrencySerializer::class) val currency: Currency
+ @Serializable(with = CurrencySerializer::class) val currency: Currency,
)
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingAddress.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingAddress.kt
index 216f3762..0b54be71 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingAddress.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingAddress.kt
@@ -11,5 +11,5 @@ data class ShippingAddress(
val postcode: String?,
val phoneNumber: String? = null,
val state: String? = null,
- val suburb: String? = null
+ val suburb: String? = null,
)
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOption.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOption.kt
index 5476fcd4..7f07f333 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOption.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOption.kt
@@ -9,5 +9,5 @@ data class ShippingOption(
val description: String,
var shippingAmount: Money,
var orderAmount: Money,
- var taxAmount: Money?
+ var taxAmount: Money?,
)
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionUpdate.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionUpdate.kt
index 2f988e0e..57378c24 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionUpdate.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionUpdate.kt
@@ -7,5 +7,5 @@ data class ShippingOptionUpdate(
val id: String,
var shippingAmount: Money,
var orderAmount: Money,
- var taxAmount: Money?
+ var taxAmount: Money?,
)
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionUpdateResult.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionUpdateResult.kt
index cf7b044b..67aa1fa8 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionUpdateResult.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionUpdateResult.kt
@@ -3,14 +3,14 @@ package com.afterpay.android.model
sealed class ShippingOptionUpdateResult
data class ShippingOptionUpdateSuccessResult(
- val shippingOptionUpdate: ShippingOptionUpdate
+ val shippingOptionUpdate: ShippingOptionUpdate,
) : ShippingOptionUpdateResult()
data class ShippingOptionUpdateErrorResult(
- val error: ShippingOptionUpdateError
+ val error: ShippingOptionUpdateError,
) : ShippingOptionUpdateResult()
enum class ShippingOptionUpdateError {
SERVICE_UNAVAILABLE,
- BAD_RESPONSE
+ BAD_RESPONSE,
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionsResult.kt b/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionsResult.kt
index 4e7e0877..3e50bb33 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionsResult.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/model/ShippingOptionsResult.kt
@@ -3,16 +3,16 @@ package com.afterpay.android.model
sealed class ShippingOptionsResult
data class ShippingOptionsSuccessResult(
- val shippingOptions: List
+ val shippingOptions: List,
) : ShippingOptionsResult()
data class ShippingOptionsErrorResult(
- val error: ShippingOptionsError
+ val error: ShippingOptionsError,
) : ShippingOptionsResult()
enum class ShippingOptionsError {
SHIPPING_ADDRESS_UNRECOGNIZED,
SHIPPING_ADDRESS_UNSUPPORTED,
SERVICE_UNAVAILABLE,
- BAD_RESPONSE
+ BAD_RESPONSE,
}
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayBadge.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayBadge.kt
index b504315d..824f25f4 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayBadge.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayBadge.kt
@@ -14,7 +14,7 @@ private const val MIN_WIDTH: Int = 64
class AfterpayBadge @JvmOverloads constructor(
context: Context,
- attrs: AttributeSet? = null
+ attrs: AttributeSet? = null,
) : AppCompatImageView(context, attrs) {
var colorScheme: AfterpayColorScheme = AfterpayColorScheme.DEFAULT
@@ -35,8 +35,8 @@ class AfterpayBadge @JvmOverloads constructor(
colorScheme = AfterpayColorScheme.values()[
attributes.getInteger(
R.styleable.Afterpay_afterpayColorScheme,
- AfterpayColorScheme.DEFAULT.ordinal
- )
+ AfterpayColorScheme.DEFAULT.ordinal,
+ ),
]
}
}
@@ -45,13 +45,13 @@ class AfterpayBadge @JvmOverloads constructor(
setImageDrawable(
context.coloredDrawable(
drawableResId = Afterpay.brand.badgeForeground,
- colorResId = colorScheme.foregroundColorResId
- )
+ colorResId = colorScheme.foregroundColorResId,
+ ),
)
background = context.coloredDrawable(
R.drawable.afterpay_badge_bg,
- colorScheme.backgroundColorResId
+ colorScheme.backgroundColorResId,
)
invalidate()
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayCheckoutActivity.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayCheckoutActivity.kt
index b6d5e679..2fe23ade 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayCheckoutActivity.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayCheckoutActivity.kt
@@ -35,7 +35,7 @@ internal class AfterpayCheckoutActivity : AppCompatActivity() {
"portal.clearpay.co.uk",
"portal.sandbox.clearpay.co.uk",
"checkout.clearpay.com",
- "checkout.sandbox.clearpay.com"
+ "checkout.sandbox.clearpay.com",
)
}
@@ -56,7 +56,7 @@ internal class AfterpayCheckoutActivity : AppCompatActivity() {
webViewClient = AfterpayWebViewClient(
receivedError = ::handleError,
completed = ::finish,
- shouldLoadRedirectUrls = intent.getCheckoutShouldLoadRedirectUrls()
+ shouldLoadRedirectUrls = intent.getCheckoutShouldLoadRedirectUrls(),
)
webChromeClient = AfterpayWebChromeClient(openExternalLink = ::open)
}
@@ -111,8 +111,8 @@ internal class AfterpayCheckoutActivity : AppCompatActivity() {
.setMessage(
String.format(
Afterpay.strings.loadErrorMessage,
- resources.getString(Afterpay.brand.title)
- )
+ resources.getString(Afterpay.brand.title),
+ ),
)
.setPositiveButton(Afterpay.strings.loadErrorRetry) { dialog, _ ->
loadCheckoutUrl()
@@ -190,7 +190,7 @@ private class AfterpayWebViewClient(
override fun onReceivedError(
view: WebView?,
request: WebResourceRequest?,
- error: WebResourceError?
+ error: WebResourceError?,
) {
if (request?.isForMainFrame == true) {
receivedError()
@@ -199,7 +199,7 @@ private class AfterpayWebViewClient(
}
private class AfterpayWebChromeClient(
- private val openExternalLink: (Uri) -> Unit
+ private val openExternalLink: (Uri) -> Unit,
) : WebChromeClient() {
companion object {
const val URL_KEY = "url"
@@ -209,7 +209,7 @@ private class AfterpayWebChromeClient(
view: WebView?,
isDialog: Boolean,
isUserGesture: Boolean,
- resultMsg: Message?
+ resultMsg: Message?,
): Boolean {
val hrefMessage = view?.handler?.obtainMessage()
view?.requestFocusNodeHref(hrefMessage)
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayCheckoutV2Activity.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayCheckoutV2Activity.kt
index 3d25f107..3a2ea2a5 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayCheckoutV2Activity.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayCheckoutV2Activity.kt
@@ -92,14 +92,14 @@ internal class AfterpayCheckoutV2Activity : AppCompatActivity() {
onOpenWebView = { checkoutWebView = it },
onPageFinished = { frameLayout.removeView(loadingWebView) },
receivedError = ::handleCheckoutError,
- openExternalLink = ::open
+ openExternalLink = ::open,
)
val javascriptInterface = BootstrapJavascriptInterface(
activity = activity,
webView = this,
complete = ::finish,
- cancel = ::finish
+ cancel = ::finish,
)
addJavascriptInterface(javascriptInterface, "Android")
@@ -156,8 +156,8 @@ internal class AfterpayCheckoutV2Activity : AppCompatActivity() {
.setMessage(
String.format(
Afterpay.strings.loadErrorMessage,
- resources.getString(Afterpay.brand.title)
- )
+ resources.getString(Afterpay.brand.title),
+ ),
)
.setPositiveButton(Afterpay.strings.loadErrorRetry) { dialog, _ ->
retryAction()
@@ -201,7 +201,7 @@ internal class AfterpayCheckoutV2Activity : AppCompatActivity() {
private class BootstrapWebViewClient(
private val onPageFinished: () -> Unit,
- private val receivedError: () -> Unit
+ private val receivedError: () -> Unit,
) : WebViewClient() {
override fun onPageFinished(view: WebView?, url: String?) {
onPageFinished()
@@ -210,7 +210,7 @@ private class BootstrapWebViewClient(
override fun onReceivedError(
view: WebView?,
request: WebResourceRequest?,
- error: WebResourceError?
+ error: WebResourceError?,
) {
if (request?.isForMainFrame == true) {
receivedError()
@@ -224,7 +224,7 @@ private class BootstrapWebChromeClient(
private val onOpenWebView: (WebView) -> Unit,
private val onPageFinished: () -> Unit,
private val receivedError: () -> Unit,
- private val openExternalLink: (Uri) -> Unit
+ private val openExternalLink: (Uri) -> Unit,
) : WebChromeClient() {
companion object {
const val URL_KEY = "url"
@@ -235,7 +235,7 @@ private class BootstrapWebChromeClient(
view: WebView?,
isDialog: Boolean,
isUserGesture: Boolean,
- resultMsg: Message?
+ resultMsg: Message?,
): Boolean {
val webView = WebView(context)
webView.setAfterpayUserAgentString()
@@ -253,7 +253,7 @@ private class BootstrapWebChromeClient(
override fun onReceivedError(
view: WebView?,
request: WebResourceRequest?,
- error: WebResourceError?
+ error: WebResourceError?,
) {
if (request?.isForMainFrame == true) {
receivedError()
@@ -266,7 +266,7 @@ private class BootstrapWebChromeClient(
view: WebView?,
isDialog: Boolean,
isUserGesture: Boolean,
- resultMsg: Message?
+ resultMsg: Message?,
): Boolean {
val hrefMessage = view?.handler?.obtainMessage()
view?.requestFocusNodeHref(hrefMessage)
@@ -294,7 +294,7 @@ private class BootstrapJavascriptInterface(
private val activity: Activity,
private val webView: WebView,
private val complete: (AfterpayCheckoutCompletion) -> Unit,
- private val cancel: (CancellationStatus) -> Unit
+ private val cancel: (CancellationStatus) -> Unit,
) {
private val json = Json { ignoreUnknownKeys = true }
@@ -310,7 +310,7 @@ private class BootstrapJavascriptInterface(
when (message) {
is CheckoutLogMessage -> Log.d(
javaClass.simpleName,
- message.payload.run { "${severity.replaceFirstChar { it.uppercase(Locale.ROOT) }}: $message" }
+ message.payload.run { "${severity.replaceFirstChar { it.uppercase(Locale.ROOT) }}: $message" },
)
is ShippingAddressMessage -> handler.shippingAddressDidChange(message.payload) {
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayColorScheme.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayColorScheme.kt
index 92d1d91f..26d2a8f7 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayColorScheme.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayColorScheme.kt
@@ -5,24 +5,25 @@ import com.afterpay.android.R
enum class AfterpayColorScheme(
@ColorRes val foregroundColorResId: Int,
- @ColorRes val backgroundColorResId: Int
+ @ColorRes val backgroundColorResId: Int,
) {
BLACK_ON_MINT(
foregroundColorResId = R.color.afterpay_black,
- backgroundColorResId = R.color.afterpay_mint
+ backgroundColorResId = R.color.afterpay_mint,
),
MINT_ON_BLACK(
foregroundColorResId = R.color.afterpay_mint,
- backgroundColorResId = R.color.afterpay_black
+ backgroundColorResId = R.color.afterpay_black,
),
WHITE_ON_BLACK(
foregroundColorResId = R.color.afterpay_white,
- backgroundColorResId = R.color.afterpay_black
+ backgroundColorResId = R.color.afterpay_black,
),
BLACK_ON_WHITE(
foregroundColorResId = R.color.afterpay_black,
- backgroundColorResId = R.color.afterpay_white
- );
+ backgroundColorResId = R.color.afterpay_white,
+ ),
+ ;
internal companion object {
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayIntroText.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayIntroText.kt
index 5ca6e3af..34ec90e5 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayIntroText.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayIntroText.kt
@@ -14,7 +14,8 @@ enum class AfterpayIntroText(val id: Int) {
OR_TITLE(8),
OR(9),
PAY_IN_TITLE(10),
- PAY_IN(11);
+ PAY_IN(11),
+ ;
internal companion object {
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayLockup.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayLockup.kt
index 46be6ee0..57897b35 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayLockup.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayLockup.kt
@@ -15,7 +15,7 @@ private const val MIN_WIDTH: Int = 64
class AfterpayLockup @JvmOverloads constructor(
context: Context,
- attrs: AttributeSet? = null
+ attrs: AttributeSet? = null,
) : AppCompatImageView(context, attrs) {
var colorScheme: AfterpayColorScheme = AfterpayColorScheme.DEFAULT
@@ -36,8 +36,8 @@ class AfterpayLockup @JvmOverloads constructor(
colorScheme = AfterpayColorScheme.values()[
attributes.getInteger(
R.styleable.Afterpay_afterpayColorScheme,
- AfterpayColorScheme.DEFAULT.ordinal
- )
+ AfterpayColorScheme.DEFAULT.ordinal,
+ ),
]
}
}
@@ -52,8 +52,8 @@ class AfterpayLockup @JvmOverloads constructor(
setImageDrawable(
context.coloredDrawable(
drawableResId = Afterpay.brand.lockup,
- colorResId = colorScheme.foregroundColorResId
- )
+ colorResId = colorScheme.foregroundColorResId,
+ ),
)
invalidate()
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayLogoType.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayLogoType.kt
index 63874bd4..794d13da 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayLogoType.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayLogoType.kt
@@ -2,7 +2,8 @@ package com.afterpay.android.view
enum class AfterpayLogoType(val fontHeightMultiplier: Double) {
BADGE(2.5),
- LOCKUP(1.0);
+ LOCKUP(1.0),
+ ;
internal companion object {
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayModalLinkStyle.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayModalLinkStyle.kt
index a0f93354..4aa9496c 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayModalLinkStyle.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayModalLinkStyle.kt
@@ -3,36 +3,34 @@ package com.afterpay.android.view
import com.afterpay.android.Afterpay
import com.afterpay.android.R
-sealed class AfterpayModalLinkStyle(val config: ModalLinkConfig) {
- constructor(string: String, config: ModalLinkConfig) : this(config)
-
+sealed class AfterpayModalLinkStyle(internal val config: ModalLinkConfig) {
object CircledInfoIcon : AfterpayModalLinkStyle(
ModalLinkConfig(
text = "\u24D8",
- underlined = false
- )
+ underlined = false,
+ ),
)
object MoreInfoText : AfterpayModalLinkStyle(
ModalLinkConfig(
- text = Afterpay.strings.priceBreakdownLinkMoreInfo
- )
+ text = Afterpay.strings.priceBreakdownLinkMoreInfo,
+ ),
)
object LearnMoreText : AfterpayModalLinkStyle(
ModalLinkConfig(
- text = Afterpay.strings.priceBreakdownLinkLearnMore
- )
+ text = Afterpay.strings.priceBreakdownLinkLearnMore,
+ ),
)
object CircledQuestionIcon : AfterpayModalLinkStyle(
ModalLinkConfig(
image = R.drawable.icon_circled_question,
- imageRenderingMode = AfterpayImageRenderingMode.TEMPLATE
- )
+ imageRenderingMode = AfterpayImageRenderingMode.TEMPLATE,
+ ),
)
object CircledLogo : AfterpayModalLinkStyle(
ModalLinkConfig(
image = R.drawable.afterpay_logo_small,
- imageRenderingMode = AfterpayImageRenderingMode.ORIGINAL
- )
+ imageRenderingMode = AfterpayImageRenderingMode.ORIGINAL,
+ ),
)
object Custom : AfterpayModalLinkStyle(ModalLinkConfig()) {
public fun setContent(content: CharSequence) {
@@ -50,7 +48,7 @@ sealed class AfterpayModalLinkStyle(val config: ModalLinkConfig) {
internal enum class AfterpayImageRenderingMode {
ORIGINAL,
- TEMPLATE
+ TEMPLATE,
}
internal data class ModalLinkConfig(
@@ -58,5 +56,5 @@ internal data class ModalLinkConfig(
val image: Int? = null,
val imageRenderingMode: AfterpayImageRenderingMode? = null,
var customContent: CharSequence? = null,
- val underlined: Boolean = true
+ val underlined: Boolean = true,
)
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayModalTheme.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayModalTheme.kt
index 784104a3..371d0743 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayModalTheme.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayModalTheme.kt
@@ -2,7 +2,8 @@ package com.afterpay.android.view
enum class AfterpayModalTheme(val slug: String) {
MINT(""),
- WHITE("-theme-white");
+ WHITE("-theme-white"),
+ ;
internal companion object {
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt
index daaa5bfb..c6e9d362 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayMoreInfoOptions.kt
@@ -16,7 +16,7 @@ class AfterpayMoreInfoOptions {
*/
constructor(
modalId: String,
- modalLinkStyle: AfterpayModalLinkStyle = AfterpayModalLinkStyle.DEFAULT
+ modalLinkStyle: AfterpayModalLinkStyle = AfterpayModalLinkStyle.DEFAULT,
) {
this.modalId = modalId
this.modalLinkStyle = modalLinkStyle
@@ -34,7 +34,7 @@ class AfterpayMoreInfoOptions {
constructor(
modalTheme: AfterpayModalTheme = AfterpayModalTheme.MINT,
isCbtEnabled: Boolean = false,
- modalLinkStyle: AfterpayModalLinkStyle = AfterpayModalLinkStyle.DEFAULT
+ modalLinkStyle: AfterpayModalLinkStyle = AfterpayModalLinkStyle.DEFAULT,
) {
this.modalTheme = modalTheme
this.isCbtEnabled = isCbtEnabled
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPaymentButton.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPaymentButton.kt
index 735b04f0..aa25cbd4 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPaymentButton.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPaymentButton.kt
@@ -25,7 +25,7 @@ private const val PADDING: Int = 0
class AfterpayPaymentButton @JvmOverloads constructor(
context: Context,
- attrs: AttributeSet? = null
+ attrs: AttributeSet? = null,
) : AppCompatImageButton(context, attrs) {
var buttonText: ButtonText = ButtonText.DEFAULT
@@ -57,7 +57,7 @@ class AfterpayPaymentButton @JvmOverloads constructor(
init {
contentDescription = String.format(
Afterpay.strings.paymentButtonContentDescription,
- resources.getString(Afterpay.brand.description)
+ resources.getString(Afterpay.brand.description),
)
scaleType = FIT_CENTER
adjustViewBounds = true
@@ -67,15 +67,15 @@ class AfterpayPaymentButton @JvmOverloads constructor(
buttonText = ButtonText.values()[
attributes.getInteger(
R.styleable.Afterpay_afterpayButtonText,
- ButtonText.DEFAULT.ordinal
- )
+ ButtonText.DEFAULT.ordinal,
+ ),
]
colorScheme = values()[
attributes.getInteger(
R.styleable.Afterpay_afterpayColorScheme,
- AfterpayColorScheme.DEFAULT.ordinal
- )
+ AfterpayColorScheme.DEFAULT.ordinal,
+ ),
]
}
@@ -92,8 +92,8 @@ class AfterpayPaymentButton @JvmOverloads constructor(
setImageDrawable(
context.coloredDrawable(
drawableResId = buttonText.drawableResId,
- colorResId = colorScheme.foregroundColorResId
- )
+ colorResId = colorScheme.foregroundColorResId,
+ ),
)
val rippleColorResId = when (colorScheme) {
@@ -105,8 +105,8 @@ class AfterpayPaymentButton @JvmOverloads constructor(
rippleColorResId = rippleColorResId,
drawable = context.coloredDrawable(
drawableResId = R.drawable.afterpay_button_bg,
- colorResId = colorScheme.backgroundColorResId
- )
+ colorResId = colorScheme.backgroundColorResId,
+ ),
)
invalidate()
@@ -118,7 +118,8 @@ class AfterpayPaymentButton @JvmOverloads constructor(
PAY_NOW(drawableResId = Afterpay.drawables.buttonPayNowForeground),
BUY_NOW(drawableResId = Afterpay.drawables.buttonBuyNowForeground),
CHECKOUT(drawableResId = Afterpay.drawables.buttonCheckoutForeground),
- PLACE_ORDER(drawableResId = Afterpay.drawables.buttonPlaceOrderForeground);
+ PLACE_ORDER(drawableResId = Afterpay.drawables.buttonPlaceOrderForeground),
+ ;
companion object {
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPriceBreakdown.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPriceBreakdown.kt
index 30319e41..a8c612cd 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPriceBreakdown.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayPriceBreakdown.kt
@@ -31,12 +31,12 @@ import java.util.Observer
class AfterpayPriceBreakdown @JvmOverloads constructor(
context: Context,
- attrs: AttributeSet? = null
+ attrs: AttributeSet? = null,
) : FrameLayout(context, attrs) {
private data class Content(
val text: String,
- val description: String
+ val description: String,
)
var totalAmount: BigDecimal = BigDecimal.ZERO
@@ -108,8 +108,8 @@ class AfterpayPriceBreakdown @JvmOverloads constructor(
colorScheme = AfterpayColorScheme.values()[
attributes.getInteger(
R.styleable.Afterpay_afterpayColorScheme,
- AfterpayColorScheme.DEFAULT.ordinal
- )
+ AfterpayColorScheme.DEFAULT.ordinal,
+ ),
]
}
@@ -147,7 +147,7 @@ class AfterpayPriceBreakdown @JvmOverloads constructor(
append(
context.getString(Afterpay.brand.title),
CenteredImageSpan(drawable),
- Spannable.SPAN_INCLUSIVE_EXCLUSIVE
+ Spannable.SPAN_INCLUSIVE_EXCLUSIVE,
)
append(" ")
append(content.text)
@@ -157,7 +157,7 @@ class AfterpayPriceBreakdown @JvmOverloads constructor(
append(
context.getString(Afterpay.brand.title),
CenteredImageSpan(drawable),
- Spannable.SPAN_INCLUSIVE_EXCLUSIVE
+ Spannable.SPAN_INCLUSIVE_EXCLUSIVE,
)
}
@@ -168,14 +168,14 @@ class AfterpayPriceBreakdown @JvmOverloads constructor(
append(
linkStyle.customContent,
AfterpayInfoSpan(infoUrl, false),
- Spannable.SPAN_INCLUSIVE_EXCLUSIVE
+ Spannable.SPAN_INCLUSIVE_EXCLUSIVE,
)
} else if (linkStyle.text != null) {
append(" ")
append(
linkStyle.text,
AfterpayInfoSpan(infoUrl, linkStyle.underlined),
- Spannable.SPAN_INCLUSIVE_EXCLUSIVE
+ Spannable.SPAN_INCLUSIVE_EXCLUSIVE,
)
} else if (linkStyle.image != null && linkStyle.imageRenderingMode != null) {
append(" ")
@@ -185,12 +185,12 @@ class AfterpayPriceBreakdown @JvmOverloads constructor(
context.theme.resolveAttribute(
android.R.attr.textColorSecondary,
typedValue,
- true
+ true,
)
context.coloredDrawable(
drawableResId = linkStyle.image,
- colorResId = typedValue.resourceId
+ colorResId = typedValue.resourceId,
)
} else {
ResourcesCompat.getDrawable(resources, linkStyle.image, null)
@@ -208,14 +208,14 @@ class AfterpayPriceBreakdown @JvmOverloads constructor(
append(
accessibleLinkString,
CenteredImageSpan(imageDrawable),
- Spannable.SPAN_INCLUSIVE_EXCLUSIVE
+ Spannable.SPAN_INCLUSIVE_EXCLUSIVE,
)
setSpan(
AfterpayInfoSpan(infoUrl),
this.length - accessibleLinkString.length,
this.length,
- Spannable.SPAN_INCLUSIVE_EXCLUSIVE
+ Spannable.SPAN_INCLUSIVE_EXCLUSIVE,
)
}
}
@@ -228,21 +228,21 @@ class AfterpayPriceBreakdown @JvmOverloads constructor(
val drawable = if (logoType === AfterpayLogoType.LOCKUP) {
context.coloredDrawable(
drawableResId = Afterpay.brand.lockup,
- colorResId = colorScheme.foregroundColorResId
+ colorResId = colorScheme.foregroundColorResId,
)
} else {
LayerDrawable(
arrayOf(
context.coloredDrawable(
drawableResId = R.drawable.afterpay_badge_bg,
- colorResId = colorScheme.backgroundColorResId
+ colorResId = colorScheme.backgroundColorResId,
),
context.coloredDrawable(
drawableResId = Afterpay.brand.badgeForeground,
- colorResId = colorScheme.foregroundColorResId
- )
- )
+ colorResId = colorScheme.foregroundColorResId,
+ ),
+ ),
)
}
@@ -284,7 +284,7 @@ class AfterpayPriceBreakdown @JvmOverloads constructor(
numberOfInstalments.toString(),
interestFreeText,
afterpay.instalmentAmount,
- withText
+ withText,
).trim(),
description = String.format(
Afterpay.strings.priceBreakdownAvailableDescription,
@@ -293,46 +293,47 @@ class AfterpayPriceBreakdown @JvmOverloads constructor(
interestFreeText,
afterpay.instalmentAmount,
withText,
- resources.getString(Afterpay.brand.description)
- ).trim()
+ resources.getString(Afterpay.brand.description),
+ ).trim(),
)
}
is AfterpayInstalment.NotAvailable ->
- if (afterpay.minimumAmount != null)
+ if (afterpay.minimumAmount != null) {
Content(
text = String.format(
Afterpay.strings.breakdownLimit,
afterpay.minimumAmount,
- afterpay.maximumAmount
+ afterpay.maximumAmount,
),
description = String.format(
Afterpay.strings.breakdownLimitDescription,
resources.getString(Afterpay.brand.description),
afterpay.minimumAmount,
- afterpay.maximumAmount
- )
+ afterpay.maximumAmount,
+ ),
)
- else
+ } else {
Content(
text = String.format(
Afterpay.strings.breakdownLimit,
"1",
- afterpay.maximumAmount
+ afterpay.maximumAmount,
),
description = String.format(
Afterpay.strings.breakdownLimitDescription,
resources.getString(Afterpay.brand.description),
"1",
- afterpay.maximumAmount
- )
+ afterpay.maximumAmount,
+ ),
)
+ }
AfterpayInstalment.NoConfiguration ->
Content(
text = Afterpay.strings.noConfiguration,
description = String.format(
Afterpay.strings.noConfigurationDescription,
- resources.getString(Afterpay.brand.description)
- )
+ resources.getString(Afterpay.brand.description),
+ ),
)
}
}
@@ -346,7 +347,7 @@ private class CenteredImageSpan(drawable: Drawable) : ImageSpan(drawable) {
text: CharSequence,
start: Int,
end: Int,
- fontMetricsInt: Paint.FontMetricsInt?
+ fontMetricsInt: Paint.FontMetricsInt?,
): Int {
val drawable = drawable
val bounds = drawable.bounds
@@ -373,7 +374,7 @@ private class CenteredImageSpan(drawable: Drawable) : ImageSpan(drawable) {
top: Int,
y: Int,
bottom: Int,
- paint: Paint
+ paint: Paint,
) {
val drawable = drawable
canvas.save()
diff --git a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayWidgetView.kt b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayWidgetView.kt
index 2daf0c9a..d5b99f77 100644
--- a/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayWidgetView.kt
+++ b/afterpay/src/main/kotlin/com/afterpay/android/view/AfterpayWidgetView.kt
@@ -32,7 +32,7 @@ import java.math.BigDecimal
class AfterpayWidgetView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
- defStyleAttr: Int = 0
+ defStyleAttr: Int = 0,
) : WebView(context, attrs, defStyleAttr) {
private val configuration: Configuration
@@ -62,7 +62,7 @@ class AfterpayWidgetView @JvmOverloads constructor(
onUpdate: (dueToday: Money, checksum: String?) -> Unit,
onError: (error: String) -> Unit,
showLogo: Boolean = true,
- showHeading: Boolean = true
+ showHeading: Boolean = true,
) {
if (!Afterpay.enabled) {
visibility = View.GONE
@@ -97,7 +97,7 @@ class AfterpayWidgetView @JvmOverloads constructor(
onUpdate: (dueToday: Money, checksum: String?) -> Unit,
onError: (error: String) -> Unit,
showLogo: Boolean = true,
- showHeading: Boolean = true
+ showHeading: Boolean = true,
) {
if (!Afterpay.enabled) {
visibility = View.GONE
@@ -119,7 +119,7 @@ class AfterpayWidgetView @JvmOverloads constructor(
private fun configureWebView(
onExternalRequest: (Uri) -> Unit,
onError: (String) -> Unit,
- onPageFinished: () -> Unit
+ onPageFinished: () -> Unit,
) {
setAfterpayUserAgentString()
@SuppressLint("SetJavaScriptEnabled")
@@ -135,14 +135,14 @@ class AfterpayWidgetView @JvmOverloads constructor(
webView: WebView?,
isDialog: Boolean,
isUserGesture: Boolean,
- resultMsg: Message?
+ resultMsg: Message?,
): Boolean {
val message = webView?.handler?.obtainMessage()
webView?.requestFocusNodeHref(message)
message?.data?.getString("url")?.let { onExternalRequest(Uri.parse(it)) }
return false
}
- }
+ },
)
super.setWebViewClient(
@@ -157,7 +157,7 @@ class AfterpayWidgetView @JvmOverloads constructor(
override fun onReceivedError(
webView: WebView?,
request: WebResourceRequest?,
- error: WebResourceError?
+ error: WebResourceError?,
) {
checkNotNull(webView) { "A WebView was expected but not received" }
if (request?.isForMainFrame == true) {
@@ -169,14 +169,14 @@ class AfterpayWidgetView @JvmOverloads constructor(
webView: WebView?,
errorCode: Int,
description: String?,
- failingUrl: String?
+ failingUrl: String?,
) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
checkNotNull(webView) { "A WebView was expected but not received" }
onError(description.orDefaultError())
}
}
- }
+ },
)
val widgetScriptUrl = context.resources.getString(R.string.afterpay_url_widget)
@@ -202,12 +202,12 @@ class AfterpayWidgetView @JvmOverloads constructor(
token: String?,
totalCost: String?,
showLogo: Boolean,
- showHeading: Boolean
+ showHeading: Boolean,
) {
val style = "{ \"logo\": $showLogo, \"heading\": $showHeading }"
evaluateJavascript(
"createAfterpayWidget($token, $totalCost, \"${configuration.locale}\", $style);",
- null
+ null,
)
}
@@ -225,7 +225,7 @@ class AfterpayWidgetView @JvmOverloads constructor(
evaluateJavascript(
"updateAmount(${totalCost.toAmount()});",
- null
+ null,
)
}
@@ -263,7 +263,7 @@ class AfterpayWidgetView @JvmOverloads constructor(
val isValid: Boolean,
val amountDueToday: Money? = null,
val paymentScheduleChecksum: String? = null,
- val error: Error? = null
+ val error: Error? = null,
) {
@Serializable
@@ -271,7 +271,7 @@ class AfterpayWidgetView @JvmOverloads constructor(
val errorCode: String? = null,
val errorId: String? = null,
val message: String? = null,
- val httpStatusCode: Int? = null
+ val httpStatusCode: Int? = null,
)
}
}
diff --git a/afterpay/src/test/kotlin/com/afterpay/android/AfterpayInstalmentLocaleTest.kt b/afterpay/src/test/kotlin/com/afterpay/android/AfterpayInstalmentLocaleTest.kt
index 1447637a..7fe0008b 100644
--- a/afterpay/src/test/kotlin/com/afterpay/android/AfterpayInstalmentLocaleTest.kt
+++ b/afterpay/src/test/kotlin/com/afterpay/android/AfterpayInstalmentLocaleTest.kt
@@ -241,7 +241,7 @@ class AfterpayInstalmentLocaleTest {
val gbp: AfterpayInstalment.Available,
val nzd: AfterpayInstalment.Available,
val usd: AfterpayInstalment.Available,
- val eur: AfterpayInstalment.Available
+ val eur: AfterpayInstalment.Available,
)
private data class AllUnavailableInstallments(
@@ -250,7 +250,7 @@ class AfterpayInstalmentLocaleTest {
val gbp: AfterpayInstalment.NotAvailable,
val nzd: AfterpayInstalment.NotAvailable,
val usd: AfterpayInstalment.NotAvailable,
- val eur: AfterpayInstalment.NotAvailable
+ val eur: AfterpayInstalment.NotAvailable,
)
private fun createAllAvailableInstalments(amount: BigDecimal, locale: Locale): AllAvailableInstallments {
@@ -260,7 +260,7 @@ class AfterpayInstalmentLocaleTest {
gbp = availableInstalment(amount, poundSterling, locale),
nzd = availableInstalment(amount, newZealandDollar, locale),
usd = availableInstalment(amount, unitedStatesDollar, locale),
- eur = availableInstalment(amount, euro, locale)
+ eur = availableInstalment(amount, euro, locale),
)
}
@@ -271,21 +271,21 @@ class AfterpayInstalmentLocaleTest {
gbp = unavailableInstalment(amount, poundSterling, locale),
nzd = unavailableInstalment(amount, newZealandDollar, locale),
usd = unavailableInstalment(amount, unitedStatesDollar, locale),
- eur = unavailableInstalment(amount, euro, locale)
+ eur = unavailableInstalment(amount, euro, locale),
)
}
private fun availableInstalment(
amount: BigDecimal,
currency: Currency,
- locale: Locale
+ locale: Locale,
): AfterpayInstalment.Available {
val configuration = Configuration(
50.toBigDecimal(),
1000.toBigDecimal(),
currency,
locale,
- AfterpayEnvironment.SANDBOX
+ AfterpayEnvironment.SANDBOX,
)
return AfterpayInstalment.of(amount, configuration, locale) as AfterpayInstalment.Available
}
@@ -293,14 +293,14 @@ class AfterpayInstalmentLocaleTest {
private fun unavailableInstalment(
amount: BigDecimal,
currency: Currency,
- locale: Locale
+ locale: Locale,
): AfterpayInstalment.NotAvailable {
val configuration = Configuration(
10.toBigDecimal(),
20.toBigDecimal(),
currency,
locale,
- AfterpayEnvironment.SANDBOX
+ AfterpayEnvironment.SANDBOX,
)
return AfterpayInstalment.of(amount, configuration, locale) as AfterpayInstalment.NotAvailable
}
diff --git a/afterpay/src/test/kotlin/com/afterpay/android/AfterpayInstalmentPriceTest.kt b/afterpay/src/test/kotlin/com/afterpay/android/AfterpayInstalmentPriceTest.kt
index 1372888f..f67887fe 100644
--- a/afterpay/src/test/kotlin/com/afterpay/android/AfterpayInstalmentPriceTest.kt
+++ b/afterpay/src/test/kotlin/com/afterpay/android/AfterpayInstalmentPriceTest.kt
@@ -22,14 +22,14 @@ class AfterpayInstalmentPriceTest {
40.04 to "$10.01",
40.009 to "$10.00",
40.019 to "$10.00",
- 40.3934567 to "$10.10"
+ 40.3934567 to "$10.10",
)
private val priceCasesInt = mapOf(
40 to "$10.00",
41 to "$10.25",
100 to "$25.00",
- 103 to "$25.75"
+ 103 to "$25.75",
)
@Test
@@ -38,7 +38,7 @@ class AfterpayInstalmentPriceTest {
val instalments = availableInstalment(
amount.toBigDecimal(),
Currency.getInstance("AUD"),
- Locales.EN_AU
+ Locales.EN_AU,
)
Assert.assertEquals(instalmentAmount, instalments.instalmentAmount)
}
@@ -50,7 +50,7 @@ class AfterpayInstalmentPriceTest {
val instalments = availableInstalment(
amount.toBigDecimal(),
Currency.getInstance("AUD"),
- Locales.EN_AU
+ Locales.EN_AU,
)
Assert.assertEquals(instalmentAmount, instalments.instalmentAmount)
}
@@ -69,7 +69,7 @@ class AfterpayInstalmentPriceTest {
val instalments = availableInstalment(
oneHundredAndTwentyOne,
Currency.getInstance("AUD"),
- Locales.EN_AU
+ Locales.EN_AU,
)
Assert.assertEquals("$30.25", instalments.instalmentAmount)
@@ -78,14 +78,14 @@ class AfterpayInstalmentPriceTest {
private fun availableInstalment(
amount: BigDecimal,
currency: Currency,
- locale: Locale
+ locale: Locale,
): AfterpayInstalment.Available {
val configuration = Configuration(
2.toBigDecimal(),
1000.toBigDecimal(),
currency,
locale,
- AfterpayEnvironment.SANDBOX
+ AfterpayEnvironment.SANDBOX,
)
return AfterpayInstalment.of(amount, configuration, locale) as AfterpayInstalment.Available
}
diff --git a/afterpay/src/test/kotlin/com/afterpay/android/AfterpayTest.kt b/afterpay/src/test/kotlin/com/afterpay/android/AfterpayTest.kt
index 2c0d7a93..40ab0ed3 100644
--- a/afterpay/src/test/kotlin/com/afterpay/android/AfterpayTest.kt
+++ b/afterpay/src/test/kotlin/com/afterpay/android/AfterpayTest.kt
@@ -15,7 +15,7 @@ class AfterpayTest {
maximumAmount = "100.00",
currencyCode = "AUD",
locale = Locale.US,
- environment = environment
+ environment = environment,
)
}
@@ -26,7 +26,7 @@ class AfterpayTest {
maximumAmount = "100.00",
currencyCode = "AUD",
locale = Locale.US,
- environment = environment
+ environment = environment,
)
}
@@ -38,7 +38,7 @@ class AfterpayTest {
maximumAmount = "100.00",
currencyCode = "foo",
locale = Locale.US,
- environment = environment
+ environment = environment,
)
}
}
@@ -51,7 +51,7 @@ class AfterpayTest {
maximumAmount = "100.00",
currencyCode = "AUD",
locale = Locale.US,
- environment = environment
+ environment = environment,
)
}
}
@@ -64,7 +64,7 @@ class AfterpayTest {
maximumAmount = "foo",
currencyCode = "AUD",
locale = Locale.US,
- environment = environment
+ environment = environment,
)
}
}
@@ -77,7 +77,7 @@ class AfterpayTest {
maximumAmount = "100.00",
currencyCode = "AUD",
locale = Locale.US,
- environment = environment
+ environment = environment,
)
}
}
@@ -90,7 +90,7 @@ class AfterpayTest {
maximumAmount = "100.00",
currencyCode = "AUD",
locale = Locale.US,
- environment = environment
+ environment = environment,
)
}
}
@@ -103,7 +103,7 @@ class AfterpayTest {
maximumAmount = "-2.00",
currencyCode = "AUD",
locale = Locale.US,
- environment = environment
+ environment = environment,
)
}
}
@@ -116,7 +116,7 @@ class AfterpayTest {
maximumAmount = "100.00",
currencyCode = "AUD",
locale = Locale.JAPAN,
- environment = environment
+ environment = environment,
)
}
}
diff --git a/build.gradle b/build.gradle
index 6bd589bf..79411740 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,35 +1,36 @@
buildscript {
ext.versions = [
'compile_sdk' : 31,
+ 'example_compile_sdk' : 33,
'min_sdk' : 24,
'java' : '1.8',
'build_tools' : '30.0.3',
- 'android_gradle_plugin' : '7.0.4',
- 'kotlin' : '1.6.0',
- 'kotlinx_coroutines' : '1.5.1',
- 'kotlinx_serialization' : '1.3.1',
+ 'android_gradle_plugin' : '7.3.1',
+ 'kotlin' : '1.7.20',
+ 'kotlinx_coroutines' : '1.6.4',
+ 'kotlinx_serialization' : '1.4.1',
'maven_publish_plugin' : '0.17.0',
- 'androidx_activity' : '1.4.0',
- 'androidx_constraint_layout': '2.1.2',
- 'androidx_fragment' : '1.4.0',
- 'androidx_lifecycle' : '2.4.0',
- 'androidx_navigation' : '2.3.5',
+ 'androidx_activity' : '1.6.0',
+ 'androidx_constraint_layout': '2.1.4',
+ 'androidx_fragment' : '1.5.3',
+ 'androidx_lifecycle' : '2.5.1',
+ 'androidx_navigation' : '2.5.2',
'androidx_recycler_view' : '1.2.1',
- 'android_three_ten' : '1.3.1',
- 'app_compat' : '1.4.0',
- 'core_ktx' : '1.7.0',
- 'material_design_components': '1.4.0',
- 'moshi' : '1.13.0',
- 'okhttp' : '4.9.1',
+ 'android_three_ten' : '1.4.2',
+ 'app_compat' : '1.5.1',
+ 'core_ktx' : '1.9.0',
+ 'material_design_components': '1.7.0',
+ 'moshi' : '1.14.0',
+ 'okhttp' : '5.0.0-alpha.10',
'retrofit' : '2.9.0',
'junit' : '4.13.2',
- 'androidx_test_orchestrator': '1.4.0',
+ 'androidx_test_orchestrator': '1.4.1',
'androidx_test_core' : '1.4.0',
'androidx_test_junit' : '1.1.3',
'androidx_test_runner' : '1.4.0',
'espresso' : '3.4.0',
'uiautomator' : '2.2.0',
- 'ktlint' : '0.43.2'
+ 'ktlint' : '0.47.1'
]
repositories {
@@ -65,14 +66,14 @@ subprojects {
task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
classpath = configurations.ktlint
- main = "com.pinterest.ktlint.Main"
+ mainClass = "com.pinterest.ktlint.Main"
args "src/**/*.kt"
}
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
classpath = configurations.ktlint
- main = "com.pinterest.ktlint.Main"
+ mainClass = "com.pinterest.ktlint.Main"
args "-F", "src/**/*.kt"
}
}
diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock
index 7b01b259..9c735591 100644
--- a/docs/Gemfile.lock
+++ b/docs/Gemfile.lock
@@ -1,20 +1,20 @@
GEM
remote: https://rubygems.org/
specs:
- activesupport (6.0.5.1)
+ activesupport (6.0.6)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
- addressable (2.8.0)
- public_suffix (>= 2.0.2, < 5.0)
+ addressable (2.8.1)
+ public_suffix (>= 2.0.2, < 6.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.11.1)
colorator (1.1.0)
- commonmarker (0.23.5)
+ commonmarker (0.23.6)
concurrent-ruby (1.1.10)
dnsruby (1.61.9)
simpleidn (~> 0.1)
@@ -25,10 +25,10 @@ GEM
ffi (>= 1.15.0)
eventmachine (1.2.7)
execjs (2.8.1)
- faraday (2.5.2)
+ faraday (2.6.0)
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
- faraday-net_http (3.0.0)
+ faraday-net_http (3.0.1)
ffi (1.15.5)
forwardable-extended (2.6.0)
gemoji (3.0.1)
@@ -83,7 +83,7 @@ GEM
octokit (~> 4.0)
public_suffix (>= 3.0, < 5.0)
typhoeus (~> 1.3)
- html-pipeline (2.14.2)
+ html-pipeline (2.14.3)
activesupport (>= 2)
nokogiri (>= 1.4)
http_parser.rb (0.8.0)
@@ -211,8 +211,8 @@ GEM
jekyll (>= 3.5, < 5.0)
jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1)
- minitest (5.16.2)
- nokogiri (1.13.8)
+ minitest (5.16.3)
+ nokogiri (1.13.9)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
octokit (4.25.1)
@@ -222,7 +222,7 @@ GEM
forwardable-extended (~> 2.6)
public_suffix (4.0.7)
racc (1.6.0)
- rb-fsevent (0.11.1)
+ rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.2.5)
@@ -251,7 +251,7 @@ GEM
unf_ext
unf_ext (0.0.8.2)
unicode-display_width (1.8.0)
- zeitwerk (2.6.0)
+ zeitwerk (2.6.1)
PLATFORMS
ruby
diff --git a/example/build.gradle b/example/build.gradle
index eb44f06a..93f70369 100644
--- a/example/build.gradle
+++ b/example/build.gradle
@@ -4,13 +4,13 @@ plugins {
}
android {
- compileSdkVersion versions.compile_sdk
+ compileSdkVersion versions.example_compile_sdk
buildToolsVersion versions.build_tools
defaultConfig {
applicationId "com.example.afterpay"
minSdkVersion versions.min_sdk
- targetSdkVersion versions.compile_sdk
+ targetSdkVersion versions.example_compile_sdk
versionCode 1
versionName '1.0'
@@ -49,9 +49,6 @@ android {
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile).all {
- kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlin.Experimental"]
- kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi"]
- kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlinx.coroutines.FlowPreview"]
kotlinOptions.freeCompilerArgs += ["-Xallow-result-return-type"]
}
diff --git a/example/src/androidTest/kotlin/com/example/afterpay/AfterpayCheckoutTest.kt b/example/src/androidTest/kotlin/com/example/afterpay/AfterpayCheckoutTest.kt
index 0a9060d6..16b1d9db 100644
--- a/example/src/androidTest/kotlin/com/example/afterpay/AfterpayCheckoutTest.kt
+++ b/example/src/androidTest/kotlin/com/example/afterpay/AfterpayCheckoutTest.kt
@@ -10,6 +10,7 @@ import androidx.test.espresso.IdlingResource
import androidx.test.espresso.UiController
import androidx.test.espresso.ViewAction
import androidx.test.espresso.action.ViewActions.click
+import androidx.test.espresso.action.ViewActions.replaceText
import androidx.test.espresso.action.ViewActions.typeText
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.RecyclerViewActions.actionOnItemAtPosition
@@ -51,7 +52,7 @@ class AfterpayCheckoutTest {
private val destinationObserver =
NavController.OnDestinationChangedListener { _, destination, _ ->
- idlingResource.isIdleNow(destination.id == nav_graph.dest.receipt)
+ idlingResource.isIdleNow(destination.id == NavGraph.dest.receipt)
}
@Before
@@ -75,14 +76,14 @@ class AfterpayCheckoutTest {
onView(withId(R.id.shopping_recyclerView)).perform(
actionOnItemAtPosition(
0,
- clickChildWithId(R.id.shoppingItem_button_addToCart)
- )
+ clickChildWithId(R.id.shoppingItem_button_addToCart),
+ ),
)
onView(withId(R.id.shopping_button_viewCart)).perform(click())
onView(withId(R.id.cart_editText_emailAddress))
- .perform(typeText("user@example.com"))
+ .perform(replaceText("user@example.com"))
onView(withId(R.id.cart_expressCheckBox)).check(matches(isNotChecked()))
onView(withId(R.id.cart_buyNowCheckBox)).check(matches(isNotChecked()))
@@ -90,11 +91,9 @@ class AfterpayCheckoutTest {
onView(withId(R.id.cart_shippingOptionsRequiredCheckBox)).check(matches(isNotChecked()))
onView(withId(R.id.cart_button_checkout)).perform(click())
-
IdlingRegistry.getInstance().register(idlingResource)
onView(withId(R.id.receipt_afterpayWidget_container)).check(matches(isDisplayed()))
-
IdlingRegistry.getInstance().unregister(idlingResource)
onWebView(withId(R.id.receipt_afterpayWidget))
@@ -135,7 +134,9 @@ class AfterpayCheckoutTest {
private val isIdle = AtomicBoolean(false)
- override fun getName(): String = javaClass.name
+ override fun getName(): String {
+ return javaClass.name
+ }
override fun isIdleNow(): Boolean = isIdle.get()
@@ -144,6 +145,9 @@ class AfterpayCheckoutTest {
}
fun isIdleNow(isIdle: Boolean) {
+ if (isIdle) {
+ this.callback.onTransitionToIdle()
+ }
this.isIdle.set(isIdle)
}
}
diff --git a/example/src/main/kotlin/com/example/afterpay/Dependencies.kt b/example/src/main/kotlin/com/example/afterpay/Dependencies.kt
index a283bccc..866861e2 100644
--- a/example/src/main/kotlin/com/example/afterpay/Dependencies.kt
+++ b/example/src/main/kotlin/com/example/afterpay/Dependencies.kt
@@ -23,15 +23,15 @@ fun initializeDependencies(application: Application) = check(dependencies == nul
MoshiConverterFactory.create(
Moshi.Builder()
.add(KotlinJsonAdapterFactory())
- .build()
- )
+ .build(),
+ ),
)
.build()
.create(MerchantApi::class.java),
sharedPreferences = application.getSharedPreferences(
application.getString(R.string.preferences),
- Context.MODE_PRIVATE
- )
+ Context.MODE_PRIVATE,
+ ),
)
}
diff --git a/example/src/main/kotlin/com/example/afterpay/ExampleApplication.kt b/example/src/main/kotlin/com/example/afterpay/ExampleApplication.kt
index 5065cf4e..66cdc421 100644
--- a/example/src/main/kotlin/com/example/afterpay/ExampleApplication.kt
+++ b/example/src/main/kotlin/com/example/afterpay/ExampleApplication.kt
@@ -16,7 +16,7 @@ class ExampleApplication : Application() {
StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
- .build()
+ .build(),
)
StrictMode.setVmPolicy(
StrictMode.VmPolicy.Builder()
@@ -24,7 +24,7 @@ class ExampleApplication : Application() {
.detectLeakedClosableObjects()
.detectLeakedRegistrationObjects()
.penaltyLog()
- .build()
+ .build(),
)
}
diff --git a/example/src/main/kotlin/com/example/afterpay/MainActivity.kt b/example/src/main/kotlin/com/example/afterpay/MainActivity.kt
index 8363bb6e..09ba9ecc 100644
--- a/example/src/main/kotlin/com/example/afterpay/MainActivity.kt
+++ b/example/src/main/kotlin/com/example/afterpay/MainActivity.kt
@@ -28,7 +28,7 @@ class MainActivity : AppCompatActivity() {
private val afterpayRepository by lazy {
AfterpayRepository(
merchantApi = getDependencies().merchantApi,
- preferences = getDependencies().sharedPreferences
+ preferences = getDependencies().sharedPreferences,
)
}
@@ -39,31 +39,31 @@ class MainActivity : AppCompatActivity() {
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR
val navController = findNavController(R.id.nav_host_fragment).apply {
- graph = createGraph(nav_graph.id, nav_graph.dest.shopping) {
- fragment(nav_graph.dest.shopping) {
+ graph = createGraph(NavGraph.id, NavGraph.dest.shopping) {
+ fragment(NavGraph.dest.shopping) {
label = getString(R.string.title_shopping)
- action(nav_graph.action.to_checkout) {
- destinationId = nav_graph.dest.checkout
+ action(NavGraph.action.to_checkout) {
+ destinationId = NavGraph.dest.checkout
}
}
- fragment(nav_graph.dest.checkout) {
+ fragment(NavGraph.dest.checkout) {
label = getString(R.string.title_checkout)
- argument(nav_graph.args.total_cost) {
+ argument(NavGraph.args.total_cost) {
type = NavType.ParcelableType(BigDecimal::class.java)
}
- action(nav_graph.action.to_receipt) {
- destinationId = nav_graph.dest.receipt
+ action(NavGraph.action.to_receipt) {
+ destinationId = NavGraph.dest.receipt
}
}
- fragment(nav_graph.dest.receipt) {
+ fragment(NavGraph.dest.receipt) {
label = getString(R.string.title_receipt)
- argument(nav_graph.args.checkout_token) {
+ argument(NavGraph.args.checkout_token) {
type = NavType.StringType
}
- action(nav_graph.action.back_to_shopping) {
- destinationId = nav_graph.dest.shopping
+ action(NavGraph.action.back_to_shopping) {
+ destinationId = NavGraph.dest.shopping
navOptions {
- popUpTo(nav_graph.dest.shopping) {
+ popUpTo(NavGraph.dest.shopping) {
inclusive = true
}
launchSingleTop = true
@@ -110,14 +110,14 @@ class MainActivity : AppCompatActivity() {
maximumAmount = configuration.maximumAmount,
currencyCode = configuration.currency,
locale = Locale(configuration.language, configuration.country),
- environment = AfterpayEnvironment.SANDBOX
+ environment = AfterpayEnvironment.SANDBOX,
)
} catch (e: Exception) {
Snackbar
.make(
findViewById(android.R.id.content),
R.string.configuration_error_message,
- Snackbar.LENGTH_INDEFINITE
+ Snackbar.LENGTH_INDEFINITE,
)
.setAction(R.string.configuration_error_action_retry) {
lifecycleScope.launch {
diff --git a/example/src/main/kotlin/com/example/afterpay/nav_graph.kt b/example/src/main/kotlin/com/example/afterpay/NavGraph.kt
similarity index 96%
rename from example/src/main/kotlin/com/example/afterpay/nav_graph.kt
rename to example/src/main/kotlin/com/example/afterpay/NavGraph.kt
index 4e7d9c73..e971a776 100644
--- a/example/src/main/kotlin/com/example/afterpay/nav_graph.kt
+++ b/example/src/main/kotlin/com/example/afterpay/NavGraph.kt
@@ -1,6 +1,6 @@
package com.example.afterpay
-object nav_graph {
+object NavGraph {
private var uniqueId = 1
get() = field++
diff --git a/example/src/main/kotlin/com/example/afterpay/checkout/CheckoutFragment.kt b/example/src/main/kotlin/com/example/afterpay/checkout/CheckoutFragment.kt
index cc84cd6d..237d249e 100644
--- a/example/src/main/kotlin/com/example/afterpay/checkout/CheckoutFragment.kt
+++ b/example/src/main/kotlin/com/example/afterpay/checkout/CheckoutFragment.kt
@@ -16,10 +16,10 @@ import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import com.afterpay.android.Afterpay
import com.afterpay.android.view.AfterpayPaymentButton
+import com.example.afterpay.NavGraph
import com.example.afterpay.R
import com.example.afterpay.checkout.CheckoutViewModel.Command
import com.example.afterpay.getDependencies
-import com.example.afterpay.nav_graph
import com.google.android.material.checkbox.MaterialCheckBox
import com.google.android.material.snackbar.Snackbar
import kotlinx.coroutines.flow.collectLatest
@@ -32,9 +32,9 @@ class CheckoutFragment : Fragment() {
private val viewModel by viewModels {
CheckoutViewModel.factory(
- totalCost = requireNotNull(arguments?.get(nav_graph.args.total_cost) as? BigDecimal),
+ totalCost = requireNotNull(arguments?.get(NavGraph.args.total_cost) as? BigDecimal),
merchantApi = getDependencies().merchantApi,
- preferences = getDependencies().sharedPreferences
+ preferences = getDependencies().sharedPreferences,
)
}
@@ -44,7 +44,7 @@ class CheckoutFragment : Fragment() {
private val checkoutHandler = CheckoutHandler(
onDidCommenceCheckout = { viewModel.loadCheckoutToken() },
onShippingAddressDidChange = { viewModel.selectAddress(it) },
- onShippingOptionDidChange = { viewModel.selectShippingOption(it) }
+ onShippingOptionDidChange = { viewModel.selectShippingOption(it) },
)
override fun onCreate(savedInstanceState: Bundle?) {
@@ -56,7 +56,7 @@ class CheckoutFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
- savedInstanceState: Bundle?
+ savedInstanceState: Bundle?,
): View? = inflater.inflate(R.layout.fragment_checkout, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@@ -106,6 +106,7 @@ class CheckoutFragment : Fragment() {
}
totalCost.text = state.totalCost
+ versionCheckBox.isChecked = state.useV1
expressCheckBox.isChecked = state.express
buyNowCheckBox.isChecked = state.buyNow
pickupCheckBox.isChecked = state.pickup
@@ -131,7 +132,7 @@ class CheckoutFragment : Fragment() {
checkoutHandler.provideShippingOptionsResult(command.shippingOptionsResult)
is Command.ProvideShippingOptionUpdateResult ->
checkoutHandler.provideShippingOptionUpdateResult(
- command.shippingOptionUpdateResult
+ command.shippingOptionUpdateResult,
)
}
}
@@ -150,8 +151,8 @@ class CheckoutFragment : Fragment() {
"A token is always associated with a successful Afterpay transaction"
}
findNavController().navigate(
- nav_graph.action.to_receipt,
- bundleOf(nav_graph.args.checkout_token to token)
+ NavGraph.action.to_receipt,
+ bundleOf(NavGraph.args.checkout_token to token),
)
}
CHECKOUT_WITH_AFTERPAY to AppCompatActivity.RESULT_CANCELED -> {
diff --git a/example/src/main/kotlin/com/example/afterpay/checkout/CheckoutHandler.kt b/example/src/main/kotlin/com/example/afterpay/checkout/CheckoutHandler.kt
index 2fe64d69..75c56d84 100644
--- a/example/src/main/kotlin/com/example/afterpay/checkout/CheckoutHandler.kt
+++ b/example/src/main/kotlin/com/example/afterpay/checkout/CheckoutHandler.kt
@@ -9,7 +9,7 @@ import com.afterpay.android.model.ShippingOptionsResult
class CheckoutHandler(
val onDidCommenceCheckout: () -> Unit,
val onShippingAddressDidChange: (ShippingAddress) -> Unit,
- val onShippingOptionDidChange: (ShippingOption) -> Unit
+ val onShippingOptionDidChange: (ShippingOption) -> Unit,
) : AfterpayCheckoutV2Handler {
private var onTokenLoaded: (Result) -> Unit = {}
@@ -23,7 +23,7 @@ class CheckoutHandler(
override fun shippingAddressDidChange(
address: ShippingAddress,
- onProvideShippingOptions: (ShippingOptionsResult) -> Unit
+ onProvideShippingOptions: (ShippingOptionsResult) -> Unit,
) = onShippingAddressDidChange(address).also {
this.onProvideShippingOptions = onProvideShippingOptions
}
@@ -35,7 +35,7 @@ class CheckoutHandler(
override fun shippingOptionDidChange(
shippingOption: ShippingOption,
- onProvideShippingOptionUpdate: (ShippingOptionUpdateResult?) -> Unit
+ onProvideShippingOptionUpdate: (ShippingOptionUpdateResult?) -> Unit,
) = onShippingOptionDidChange(shippingOption).also {
this.onProvideShippingOptionUpdate = onProvideShippingOptionUpdate
}
diff --git a/example/src/main/kotlin/com/example/afterpay/checkout/CheckoutViewModel.kt b/example/src/main/kotlin/com/example/afterpay/checkout/CheckoutViewModel.kt
index c2abbec3..9774528a 100644
--- a/example/src/main/kotlin/com/example/afterpay/checkout/CheckoutViewModel.kt
+++ b/example/src/main/kotlin/com/example/afterpay/checkout/CheckoutViewModel.kt
@@ -39,7 +39,7 @@ import java.util.Locale
class CheckoutViewModel(
totalCost: BigDecimal,
private val merchantApi: MerchantApi,
- private val preferences: SharedPreferences
+ private val preferences: SharedPreferences,
) : ViewModel() {
data class State(
val emailAddress: String,
@@ -48,7 +48,7 @@ class CheckoutViewModel(
val express: Boolean,
val buyNow: Boolean,
val pickup: Boolean,
- val shippingOptionsRequired: Boolean
+ val shippingOptionsRequired: Boolean,
) {
val totalCost: String
get() = total.asCurrency()
@@ -64,7 +64,7 @@ class CheckoutViewModel(
data class ProvideShippingOptionsResult(val shippingOptionsResult: ShippingOptionsResult) :
Command()
data class ProvideShippingOptionUpdateResult(
- val shippingOptionUpdateResult: ShippingOptionUpdateResult?
+ val shippingOptionUpdateResult: ShippingOptionUpdateResult?,
) : Command()
}
@@ -76,8 +76,8 @@ class CheckoutViewModel(
express = preferences.getExpress(),
buyNow = preferences.getBuyNow(),
pickup = preferences.getPickup(),
- shippingOptionsRequired = preferences.getShippingOptionsRequired()
- )
+ shippingOptionsRequired = preferences.getShippingOptionsRequired(),
+ ),
)
private val commandChannel = Channel(Channel.CONFLATED)
@@ -130,7 +130,7 @@ class CheckoutViewModel(
isPickup,
isBuyNow,
isShippingOptionsRequired,
- enableSingleShippingOptionUpdate = true
+ enableSingleShippingOptionUpdate = true,
)
commandChannel.trySend(Command.ShowAfterpayCheckoutV2(options))
}
@@ -171,7 +171,7 @@ class CheckoutViewModel(
"",
Money("0.00".toBigDecimal(), currency),
Money("50.00".toBigDecimal(), currency),
- Money("0.00".toBigDecimal(), currency)
+ Money("0.00".toBigDecimal(), currency),
),
ShippingOption(
"priority",
@@ -179,8 +179,8 @@ class CheckoutViewModel(
"Next business day",
Money("10.00".toBigDecimal(), currency),
Money("60.00".toBigDecimal(), currency),
- null
- )
+ null,
+ ),
)
val result = ShippingOptionsSuccessResult(shippingOptions)
@@ -207,7 +207,7 @@ class CheckoutViewModel(
"standard",
Money("0.00".toBigDecimal(), currency),
Money("50.00".toBigDecimal(), currency),
- Money("2.00".toBigDecimal(), currency)
+ Money("2.00".toBigDecimal(), currency),
)
result = ShippingOptionUpdateSuccessResult(updatedShippingOption)
@@ -223,12 +223,12 @@ class CheckoutViewModel(
fun factory(
totalCost: BigDecimal,
merchantApi: MerchantApi,
- preferences: SharedPreferences
+ preferences: SharedPreferences,
) = viewModelFactory {
CheckoutViewModel(
totalCost = totalCost,
merchantApi = merchantApi,
- preferences = preferences
+ preferences = preferences,
)
}
}
diff --git a/example/src/main/kotlin/com/example/afterpay/data/AfterpayRepository.kt b/example/src/main/kotlin/com/example/afterpay/data/AfterpayRepository.kt
index b376e4bc..6dfadf09 100644
--- a/example/src/main/kotlin/com/example/afterpay/data/AfterpayRepository.kt
+++ b/example/src/main/kotlin/com/example/afterpay/data/AfterpayRepository.kt
@@ -8,14 +8,14 @@ import org.threeten.bp.format.DateTimeFormatter
class AfterpayRepository(
private val merchantApi: MerchantApi,
- private val preferences: SharedPreferences
+ private val preferences: SharedPreferences,
) {
data class Configuration(
val minimumAmount: String?,
val maximumAmount: String,
val currency: String,
val language: String,
- val country: String
+ val country: String,
)
suspend fun fetchConfiguration(forceRefresh: Boolean = false): Configuration {
@@ -28,7 +28,7 @@ class AfterpayRepository(
maximumAmount = it.maximumAmount.amount,
currency = it.maximumAmount.currency,
language = it.locale.language,
- country = it.locale.country
+ country = it.locale.country,
)
}.also { configuration ->
preferences.edit {
@@ -68,7 +68,7 @@ private fun SharedPreferences.getConfiguration(): AfterpayRepository.Configurati
maximumAmount = getString(PreferenceKey.maximumAmount, null) ?: return null,
currency = getString(PreferenceKey.currency, null) ?: return null,
language = getString(PreferenceKey.language, null) ?: return null,
- country = getString(PreferenceKey.country, null) ?: return null
+ country = getString(PreferenceKey.country, null) ?: return null,
)
}
diff --git a/example/src/main/kotlin/com/example/afterpay/data/Cart.kt b/example/src/main/kotlin/com/example/afterpay/data/Cart.kt
index 4a1418b0..cae24d0e 100644
--- a/example/src/main/kotlin/com/example/afterpay/data/Cart.kt
+++ b/example/src/main/kotlin/com/example/afterpay/data/Cart.kt
@@ -10,11 +10,11 @@ import java.util.UUID
class Cart {
private data class State(
val lastUpdated: Date,
- val items: MutableMap
+ val items: MutableMap,
)
data class Summary(
- val items: List-
+ val items: List
- ,
) {
val totalCost: BigDecimal
get() = items.fold(0.toBigDecimal()) { acc, item -> acc + item.totalCost }
@@ -25,7 +25,7 @@ class Cart {
data class Item(
val product: Product,
- var quantity: Int
+ var quantity: Int,
) {
val totalCost: BigDecimal
get() = product.price * quantity.toBigDecimal()
diff --git a/example/src/main/kotlin/com/example/afterpay/data/CheckoutRequest.kt b/example/src/main/kotlin/com/example/afterpay/data/CheckoutRequest.kt
index bd58ea4f..6d12ea64 100644
--- a/example/src/main/kotlin/com/example/afterpay/data/CheckoutRequest.kt
+++ b/example/src/main/kotlin/com/example/afterpay/data/CheckoutRequest.kt
@@ -2,11 +2,11 @@ package com.example.afterpay.data
enum class CheckoutMode(val string: String) {
STANDARD("standard"),
- EXPRESS("express")
+ EXPRESS("express"),
}
data class CheckoutRequest(
val email: String,
val amount: String,
- val mode: CheckoutMode
+ val mode: CheckoutMode,
)
diff --git a/example/src/main/kotlin/com/example/afterpay/data/CheckoutResponse.kt b/example/src/main/kotlin/com/example/afterpay/data/CheckoutResponse.kt
index fc04ff25..35324f6e 100644
--- a/example/src/main/kotlin/com/example/afterpay/data/CheckoutResponse.kt
+++ b/example/src/main/kotlin/com/example/afterpay/data/CheckoutResponse.kt
@@ -2,5 +2,5 @@ package com.example.afterpay.data
data class CheckoutResponse(
val url: String,
- val token: String
+ val token: String,
)
diff --git a/example/src/main/kotlin/com/example/afterpay/data/ConfigurationResponse.kt b/example/src/main/kotlin/com/example/afterpay/data/ConfigurationResponse.kt
index 48ef3685..62266388 100644
--- a/example/src/main/kotlin/com/example/afterpay/data/ConfigurationResponse.kt
+++ b/example/src/main/kotlin/com/example/afterpay/data/ConfigurationResponse.kt
@@ -3,16 +3,16 @@ package com.example.afterpay.data
data class ConfigurationResponse(
val minimumAmount: Money?,
val maximumAmount: Money,
- val locale: Locale
+ val locale: Locale,
) {
data class Money(
val amount: String,
- val currency: String
+ val currency: String,
)
data class Locale(
val identifier: String,
val language: String,
- val country: String
+ val country: String,
)
}
diff --git a/example/src/main/kotlin/com/example/afterpay/data/Product.kt b/example/src/main/kotlin/com/example/afterpay/data/Product.kt
index 41b342f9..ac4f6c11 100644
--- a/example/src/main/kotlin/com/example/afterpay/data/Product.kt
+++ b/example/src/main/kotlin/com/example/afterpay/data/Product.kt
@@ -7,5 +7,5 @@ data class Product(
val id: UUID,
val name: String,
val description: String,
- val price: BigDecimal
+ val price: BigDecimal,
)
diff --git a/example/src/main/kotlin/com/example/afterpay/receipt/ReceiptFragment.kt b/example/src/main/kotlin/com/example/afterpay/receipt/ReceiptFragment.kt
index 947613cf..3f185a91 100644
--- a/example/src/main/kotlin/com/example/afterpay/receipt/ReceiptFragment.kt
+++ b/example/src/main/kotlin/com/example/afterpay/receipt/ReceiptFragment.kt
@@ -17,8 +17,8 @@ import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import com.afterpay.android.model.Money
import com.afterpay.android.view.AfterpayWidgetView
+import com.example.afterpay.NavGraph
import com.example.afterpay.R
-import com.example.afterpay.nav_graph
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.flow.conflate
@@ -30,21 +30,21 @@ import kotlinx.coroutines.flow.onEach
class ReceiptFragment : Fragment() {
private val token: String
- get() = requireNotNull(arguments?.getString(nav_graph.args.checkout_token))
+ get() = requireNotNull(arguments?.getString(NavGraph.args.checkout_token))
private val viewModel by viewModels { ReceiptViewModel.factory(token) }
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
- savedInstanceState: Bundle?
+ savedInstanceState: Bundle?,
): View? = inflater.inflate(R.layout.fragment_receipt, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
requireActivity().onBackPressedDispatcher.addCallback(this) {
- findNavController().navigate(nav_graph.action.back_to_shopping)
+ findNavController().navigate(NavGraph.action.back_to_shopping)
}
view.findViewById(R.id.receipt_afterpayWidget)
diff --git a/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingFragment.kt b/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingFragment.kt
index 2009bc4c..96c431f0 100644
--- a/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingFragment.kt
+++ b/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingFragment.kt
@@ -22,9 +22,9 @@ import com.afterpay.android.view.AfterpayModalLinkStyle
import com.afterpay.android.view.AfterpayModalTheme
import com.afterpay.android.view.AfterpayMoreInfoOptions
import com.afterpay.android.view.AfterpayPriceBreakdown
+import com.example.afterpay.NavGraph
import com.example.afterpay.R
import com.example.afterpay.data.Product
-import com.example.afterpay.nav_graph
import com.example.afterpay.shopping.ShoppingViewModel.Command
import com.example.afterpay.shopping.ShoppingViewModel.ShoppingItem
import kotlinx.coroutines.flow.collectLatest
@@ -40,7 +40,7 @@ class ShoppingFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
- savedInstanceState: Bundle?
+ savedInstanceState: Bundle?,
): View? = inflater.inflate(R.layout.fragment_shopping, container, false)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@@ -49,7 +49,7 @@ class ShoppingFragment : Fragment() {
viewManager = LinearLayoutManager(requireContext())
viewAdapter = ShoppingListAdapter(
onAddProduct = viewModel::add,
- onRemoveProduct = viewModel::remove
+ onRemoveProduct = viewModel::remove,
)
recyclerView = view.findViewById(R.id.shopping_recyclerView).apply {
@@ -71,7 +71,7 @@ class ShoppingFragment : Fragment() {
afterpayBreakdown.logoType = AfterpayLogoType.LOCKUP
afterpayBreakdown.moreInfoOptions = AfterpayMoreInfoOptions(
modalLinkStyle = AfterpayModalLinkStyle.CircledInfoIcon,
- modalTheme = AfterpayModalTheme.WHITE
+ modalTheme = AfterpayModalTheme.WHITE,
)
lifecycleScope.launchWhenCreated {
@@ -87,8 +87,8 @@ class ShoppingFragment : Fragment() {
when (command) {
is Command.Checkout ->
findNavController().navigate(
- nav_graph.action.to_checkout,
- bundleOf(nav_graph.args.total_cost to command.totalCost)
+ NavGraph.action.to_checkout,
+ bundleOf(NavGraph.args.total_cost to command.totalCost),
)
}
}
@@ -98,7 +98,7 @@ class ShoppingFragment : Fragment() {
class ShoppingListAdapter(
private val onAddProduct: (Product) -> Unit,
- private val onRemoveProduct: (Product) -> Unit
+ private val onRemoveProduct: (Product) -> Unit,
) : ListAdapter(itemDiff) {
class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val name: TextView = view.findViewById(R.id.shoppingItem_title)
@@ -110,7 +110,7 @@ class ShoppingListAdapter(
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder = ViewHolder(
- LayoutInflater.from(parent.context).inflate(R.layout.view_shopping_item, parent, false)
+ LayoutInflater.from(parent.context).inflate(R.layout.view_shopping_item, parent, false),
)
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
diff --git a/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingViewModel.kt b/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingViewModel.kt
index 1510651d..2b5d7760 100644
--- a/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingViewModel.kt
+++ b/example/src/main/kotlin/com/example/afterpay/shopping/ShoppingViewModel.kt
@@ -20,26 +20,26 @@ private val allProducts = listOf(
id = UUID.randomUUID(),
name = "Coffee",
description = "Ground 250g",
- price = BigDecimal(12.99)
+ price = BigDecimal(12.99),
),
Product(
id = UUID.randomUUID(),
name = "Milk",
description = "Full Cream 2L",
- price = BigDecimal(3.49)
+ price = BigDecimal(3.49),
),
Product(
id = UUID.randomUUID(),
name = "Nestle Milo",
description = "Malted Drinking Chocolate 460g",
- price = BigDecimal(7.00)
+ price = BigDecimal(7.00),
),
Product(
id = UUID.randomUUID(),
name = "Coca-cola",
description = "Bottle 600ml",
- price = BigDecimal(3.75)
- )
+ price = BigDecimal(3.75),
+ ),
)
class ShoppingViewModel(val cart: Cart) : ViewModel() {
@@ -90,7 +90,7 @@ class ShoppingViewModel(val cart: Cart) : ViewModel() {
fun checkout() {
viewModelScope.launch {
val summary = cart.summary.first()
- commandChannel.offer(Command.Checkout(totalCost = summary.totalCost))
+ commandChannel.trySend(Command.Checkout(totalCost = summary.totalCost)).isSuccess
}
}
diff --git a/example/src/main/kotlin/com/example/afterpay/util/ViewModel.kt b/example/src/main/kotlin/com/example/afterpay/util/ViewModel.kt
index fedbaa48..2d9ee7c7 100644
--- a/example/src/main/kotlin/com/example/afterpay/util/ViewModel.kt
+++ b/example/src/main/kotlin/com/example/afterpay/util/ViewModel.kt
@@ -5,7 +5,7 @@ import androidx.lifecycle.ViewModelProvider
inline fun viewModelFactory(
viewModelClass: Class = T::class.java,
- crossinline factory: () -> T
+ crossinline factory: () -> T,
): ViewModelProvider.Factory = object : ViewModelProvider.Factory {
@Suppress("UNCHECKED_CAST")
override fun create(modelClass: Class): T =
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index cfdba51f..3d8afbe6 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip