Skip to content

Commit

Permalink
Release 7.0.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
WorldlineConnect committed Sep 23, 2024
1 parent a9a24d6 commit 9aea39a
Show file tree
Hide file tree
Showing 14 changed files with 116 additions and 46 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.2.1'
classpath 'com.android.tools.build:gradle:8.4.0'
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.3"
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ org.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF
# org.gradle.parallel=true
POM_GROUP_ID=com.worldline-solutions.connect
POM_ARTIFACT_ID=connect-sdk-client-android
POM_VERSION=7.0.1
POM_VERSION=7.0.2
POM_NAME=connect-sdk-client-android
POM_DESCRIPTION=SDK to communicate with the Worldline Global Collect platform using the Worldline Connect Client API
POM_URL=https://github.com/Worldline-Global-Collect/connect-sdk-client-android
Expand Down
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Sep 20 14:52:46 CEST 2019
#Mon May 06 13:02:21 CEST 2024
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
14 changes: 8 additions & 6 deletions worldline-connect-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ android {
compileSdk 34
targetSdkVersion 34
versionCode 1
versionName "7.0.1"
versionName "7.0.2"
consumerProguardFiles 'consumer-rules.pro'
}

Expand Down Expand Up @@ -48,11 +48,13 @@ android {

dependencies {
implementation 'com.google.android.gms:play-services-wallet:19.3.0'
// The following dependency will be removed in the future, so its version can be ignored.
//noinspection GradleDependency
implementation 'org.apache.commons:commons-lang3:3.13.0'

testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:5.9.0'
testImplementation 'org.robolectric:robolectric:4.11.1'
testImplementation 'org.mockito:mockito-core:5.11.0'
testImplementation 'org.robolectric:robolectric:4.12.1'
testImplementation 'androidx.test:core:1.5.0'

// RX
Expand All @@ -61,10 +63,10 @@ dependencies {
implementation 'io.reactivex.rxjava3:rxandroid:3.0.2'

// Network
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.11.0'
implementation 'com.squareup.retrofit2:retrofit:2.11.0'
implementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
implementation 'com.squareup.retrofit2:adapter-rxjava3:2.9.0'
implementation 'com.squareup.retrofit2:adapter-rxjava3:2.11.0'
implementation 'com.google.code.gson:gson:2.10.1'
}

Expand Down
2 changes: 2 additions & 0 deletions worldline-connect-sdk/detekt-config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
complexity:
TooManyFunctions:
active: false
LongParameterList:
constructorThreshold: 8

style:
ReturnCount:
Expand Down
4 changes: 4 additions & 0 deletions worldline-connect-sdk/lint.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
<ignore path="src/main/java/com/worldline/connect/sdk/client/android/sdk/product/*" />
<ignore path="src/main/java/com/worldline/connect/sdk/client/android/sdk/productsgroup/*" />
</issue>
<!-- Dependency will be removed in the future, so its version can be ignored -->
<issue id="NewerVersionAvailable">
<ignore regexp="org.apache.commons:commons-lang3*"/>
</issue>
</lint>

Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ class ClientApi(
{ (onApiError::apiError)(it) },
{ (onFailure::failure)(it) }
)

compositeDisposable.add(disposable)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,22 @@ class ConnectSDKConfiguration private constructor(
private fun getValidSdkIdentifier(identifier: String): String {
val identifierParts = identifier.split("/")

if (identifierParts.size == 2
if (identifierParts.size == IDENTIFIER_PARTS_SIZE
&& identifierParts.first() == "FlutterClientSDK"
&& identifierParts.last().startsWith("v")) {
val versionParts = identifierParts.last().replace("v", "").split(".")

if (versionParts.size == 3 && versionParts.all { it.toIntOrNull() != null }) {
if (versionParts.size == VERSION_PARTS_SIZE && versionParts.all { it.toIntOrNull() != null }) {
return identifier
}
}

return Constants.SDK_IDENTIFIER
}

private companion object {
const val IDENTIFIER_PARTS_SIZE = 2;
const val VERSION_PARTS_SIZE = 3;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public class Constants {

/** SDK version **/
public final static String SDK_IDENTIFIER = "AndroidClientSDK/v7.0.1";
public final static String SDK_IDENTIFIER = "AndroidClientSDK/v7.0.2";

/** SDK creator **/
public final static String SDK_CREATOR = "Worldline Global Collect";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@file:JvmSynthetic

package com.worldline.connect.sdk.client.android.network.apicalls.product

import android.graphics.drawable.Drawable
import io.reactivex.rxjava3.core.Observer
import io.reactivex.rxjava3.disposables.Disposable

internal class DrawableObserver(
private val update: (Drawable) -> Unit,
private val error: () -> Unit
) :
Observer<Drawable> {
private var disposable: Disposable? = null
override fun onNext(t: Drawable) {
update(t)
disposable?.dispose()
}

override fun onSubscribe(d: Disposable) {
disposable?.dispose()
disposable = d
}

override fun onError(e: Throwable) {
error()
disposable?.dispose()
}

override fun onComplete() {
disposable?.dispose()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package com.worldline.connect.sdk.client.android.network.apicalls.product

import android.util.Log
import com.worldline.connect.sdk.client.android.configuration.ConnectSDKConfiguration
import com.worldline.connect.sdk.client.android.network.drawable.GetDrawableFromUrl
import com.worldline.connect.sdk.client.android.model.paymentcontext.PaymentContext
Expand All @@ -15,6 +16,8 @@ import io.reactivex.rxjava3.kotlin.Observables

internal class GetPaymentProduct {

private val tag = "GetPaymentProduct"

operator fun invoke(
paymentContext: PaymentContext,
connectSDKConfiguration: ConnectSDKConfiguration,
Expand Down Expand Up @@ -62,45 +65,49 @@ internal class GetPaymentProduct {
paymentProduct: PaymentProduct,
connectSDKConfiguration: ConnectSDKConfiguration,
): Observable<Unit> {
return Observable.create {
return Observable.create { observable ->
if (!paymentProduct.displayHints.logoUrl.isNullOrBlank()) {
GetDrawableFromUrl().invoke(
GetDrawableFromUrl()(
connectSDKConfiguration,
paymentProduct.displayHints.logoUrl
).subscribe({ drawable ->
paymentProduct.displayHints.logo = drawable
it.onComplete()
}, {})
} else it.onComplete()
).doFinally {
observable.onComplete()
}.subscribe(DrawableObserver({
paymentProduct.displayHints.logo = it
}) {
Log.w(tag, "Drawable for logo of paymentProduct: ${paymentProduct.id} cannot be loaded")
})

} else observable.onComplete()
}
}

private fun getTooltipImages(
paymentProduct: PaymentProduct,
connectSDKConfiguration: ConnectSDKConfiguration,
): Observable<Unit> {
return Observable.create {
return Observable.create { observable ->
var count = 0

if(paymentProduct.paymentProductFields.isNullOrEmpty()) it.onComplete()
if(paymentProduct.paymentProductFields.isNullOrEmpty()) observable.onComplete()

paymentProduct.paymentProductFields.forEach { paymentProductField ->
if (!paymentProductField.displayHints?.tooltip?.imageURL.isNullOrBlank()) {
GetDrawableFromUrl().invoke(
GetDrawableFromUrl()(
connectSDKConfiguration,
paymentProductField.displayHints.tooltip.imageURL
).doFinally {
count++
if (count == paymentProduct.paymentProductFields.count()) it.onComplete()
}
.subscribe({ drawable ->
paymentProductField.displayHints.tooltip.imageDrawable = drawable },
{}
)
if (count == paymentProduct.paymentProductFields.count()) observable.onComplete()
}.subscribe(DrawableObserver({
paymentProductField.displayHints.tooltip.imageDrawable = it
}) {
Log.w(tag, "Drawable for tooltip of paymentProduct: ${paymentProduct.id} cannot be loaded")
})
return@forEach
}
count++
if (count == paymentProduct.paymentProductFields.count()) it.onComplete()
if (count == paymentProduct.paymentProductFields.count()) observable.onComplete()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package com.worldline.connect.sdk.client.android.network.apicalls.product

import android.util.Log
import com.worldline.connect.sdk.client.android.configuration.ConnectSDKConfiguration
import com.worldline.connect.sdk.client.android.network.drawable.GetDrawableFromUrl
import com.worldline.connect.sdk.client.android.model.paymentcontext.PaymentContext
Expand All @@ -15,6 +16,8 @@ import io.reactivex.rxjava3.core.Observable

internal class GetPaymentProducts {

private val tag = "GetPaymentProducts"

operator fun invoke(
paymentContext: PaymentContext,
connectSDKConfiguration: ConnectSDKConfiguration
Expand Down Expand Up @@ -55,22 +58,24 @@ internal class GetPaymentProducts {
paymentProducts: List<BasicPaymentProduct>,
connectSDKConfiguration: ConnectSDKConfiguration,
): Observable<Unit> {
return Observable.create {
return Observable.create { observable ->
var count = 0
paymentProducts.forEach { basicPaymentProduct ->
if (!basicPaymentProduct.displayHints.logoUrl.isNullOrBlank()) {
GetDrawableFromUrl().invoke(
GetDrawableFromUrl()(
connectSDKConfiguration,
basicPaymentProduct.displayHints.logoUrl
).doFinally {
count++
if (count == paymentProducts.count()) it.onComplete()
}.subscribe({ drawable ->
basicPaymentProduct.displayHints.logo = drawable
}, {})
if (count == paymentProducts.count()) observable.onComplete()
}.subscribe(DrawableObserver({
basicPaymentProduct.displayHints.logo = it
}) {
Log.w(tag, "Drawable for logo of paymentProduct: ${basicPaymentProduct.id} cannot be loaded")
})
} else {
count++
if (count == paymentProducts.count()) it.onComplete()
if (count == paymentProducts.count()) observable.onComplete()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ import com.worldline.connect.sdk.client.android.network.NetworkResponse
import com.worldline.connect.sdk.client.android.network.UnknownNetworkResponseException
import com.worldline.connect.sdk.client.android.model.paymentcontext.PaymentContext
import com.worldline.connect.sdk.client.android.model.paymentproductgroup.BasicPaymentProductGroups
import com.worldline.connect.sdk.client.android.network.apicalls.product.DrawableObserver
import io.reactivex.rxjava3.core.Observable

internal class GetPaymentProductGroups {

private val tag = "GetPaymentProductGroups"

operator fun invoke(
paymentContext: PaymentContext,
connectSDKConfiguration: ConnectSDKConfiguration
Expand All @@ -39,16 +42,15 @@ internal class GetPaymentProductGroups {
).flatMap { networkResponse ->
if (networkResponse is NetworkResponse.Success) {
networkResponse.data?.basicPaymentProductGroups?.forEach { basicPaymentProductGroup ->
GetDrawableFromUrl().invoke(
GetDrawableFromUrl()(
connectSDKConfiguration,
basicPaymentProductGroup.displayHints.logoUrl
).subscribe ({
).subscribe(DrawableObserver({
basicPaymentProductGroup.displayHints.logo = it
},{
}) {
Log.w(
"ConnectSDK",
"Drawable for paymentProductGroup: ${basicPaymentProductGroup.id} can't be loaded",
it
tag,
"Drawable for logo of paymentProductGroup: ${basicPaymentProductGroup.id} cannot be loaded"
)
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,19 @@ internal object MetadataUtil {

internal fun getBase64EncodedMetadata(configuration: ConnectSDKConfiguration) : String {
val jsonMetadata = gson.toJson(
configuration.applicationContext.getMetadata(configuration.applicationId, configuration.ipAddress, configuration.sdkIdentifier)
configuration.applicationContext.getMetadata(
configuration.applicationId,
configuration.ipAddress,
configuration.sdkIdentifier
)
)
return jsonMetadata.encodeToByteArray().base64UrlEncode()
}
private fun Context.getMetadata(appIdentifier: String?, ipAddress: String?, sdkIdentifier: String) : Map<String, String> {
private fun Context.getMetadata(
appIdentifier: String?,
ipAddress: String?,
sdkIdentifier: String
) : Map<String, String> {
// appId is 'unknown' if appIdentifier is null or empty
val appId = appIdentifier?.ifEmpty { null } ?: "unknown"
val screenSize = getDefaultDisplayMetrics()
Expand Down

0 comments on commit 9aea39a

Please sign in to comment.