From facab1ae14e417c81c707fabfe706920de2f1361 Mon Sep 17 00:00:00 2001 From: Carlos Molina <57185359+Garlondrake@users.noreply.github.com> Date: Tue, 30 Jan 2024 18:18:14 +0100 Subject: [PATCH] fix: Lint problems that make lint analysis fail and not completing the build (#1600) --- .../src/main/java/com/reactnativestripesdk/CardFieldView.kt | 5 ++++- .../src/main/java/com/reactnativestripesdk/CardFormView.kt | 4 ++++ .../java/com/reactnativestripesdk/GooglePayButtonView.kt | 2 ++ .../src/main/java/com/reactnativestripesdk/utils/Mappers.kt | 3 +++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt b/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt index 8e4cf6b08..6b77d1545 100644 --- a/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +++ b/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt @@ -1,5 +1,6 @@ package com.reactnativestripesdk +import android.annotation.SuppressLint import android.content.res.ColorStateList import android.graphics.Color import android.os.Build @@ -204,7 +205,7 @@ class CardFieldView(context: ThemedReactContext) : FrameLayout(context) { fun setPostalCodeEnabled(isEnabled: Boolean) { mCardWidget.postalCodeEnabled = isEnabled - if (isEnabled === false) { + if (isEnabled == false) { mCardWidget.postalCodeRequired = false } } @@ -217,6 +218,7 @@ class CardFieldView(context: ThemedReactContext) : FrameLayout(context) { * We can reliable assume that setPostalCodeEnabled is called before * setCountryCode because of the order of the props in CardField.tsx */ + @SuppressLint("RestrictedApi") fun setCountryCode(countryString: String?) { if (mCardWidget.postalCodeEnabled) { val countryCode = CountryCode.create(value = countryString ?: LocaleListCompat.getAdjustedDefault()[0]?.country ?: "US") @@ -354,6 +356,7 @@ class CardFieldView(context: ThemedReactContext) : FrameLayout(context) { ) } + @SuppressLint("RestrictedApi") private fun createPostalCodeInputFilter(countryCode: CountryCode): InputFilter { return InputFilter { charSequence, start, end, _, _, _ -> for (i in start until end) { diff --git a/android/src/main/java/com/reactnativestripesdk/CardFormView.kt b/android/src/main/java/com/reactnativestripesdk/CardFormView.kt index 3ee8e2bdf..46fe00b23 100644 --- a/android/src/main/java/com/reactnativestripesdk/CardFormView.kt +++ b/android/src/main/java/com/reactnativestripesdk/CardFormView.kt @@ -1,5 +1,6 @@ package com.reactnativestripesdk +import android.annotation.SuppressLint import android.content.res.ColorStateList import android.graphics.Color import android.os.Build @@ -62,6 +63,7 @@ class CardFormView(context: ThemedReactContext) : FrameLayout(context) { cardForm.isEnabled = !isDisabled } + @SuppressLint("RestrictedApi") private fun setCountry(countryString: String?) { if (countryString != null) { cardFormViewBinding.countryLayout.setSelectedCountryCode(CountryCode(countryString)) @@ -122,6 +124,7 @@ class CardFormView(context: ThemedReactContext) : FrameLayout(context) { CardFocusEvent(id, currentFocusedField)) } + @SuppressLint("RestrictedApi") fun setCardStyle(value: ReadableMap) { val backgroundColor = getValOr(value, "backgroundColor", null) val textColor = getValOr(value, "textColor", null) @@ -287,6 +290,7 @@ class CardFormView(context: ThemedReactContext) : FrameLayout(context) { ) } + @SuppressLint("RestrictedApi") private fun createPostalCodeInputFilter(): InputFilter { return InputFilter { charSequence, start, end, _, _, _ -> if (cardFormViewBinding.countryLayout.getSelectedCountryCode() == CountryCode.US) { diff --git a/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt b/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt index 20f7bbc0e..fcdfe0cd0 100644 --- a/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +++ b/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt @@ -1,5 +1,6 @@ package com.reactnativestripesdk +import android.annotation.SuppressLint import android.util.Log import android.view.View import android.widget.FrameLayout @@ -41,6 +42,7 @@ class GooglePayButtonView(private val context: ThemedReactContext) : FrameLayout return googlePayButton } + @SuppressLint("RestrictedApi") private fun buildButtonOptions(): ButtonOptions { val allowedPaymentMethods = JSONArray().put( GooglePayJsonFactory(context).createCardPaymentMethod( diff --git a/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt b/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt index f06fb4038..05e77e01f 100644 --- a/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +++ b/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt @@ -1,5 +1,6 @@ package com.reactnativestripesdk.utils +import android.annotation.SuppressLint import android.os.Bundle import android.util.Log import com.facebook.react.bridge.* @@ -447,6 +448,7 @@ internal fun mapFromPaymentIntentResult(paymentIntent: PaymentIntent): WritableM return map } +@SuppressLint("RestrictedApi") internal fun mapFromMicrodepositType(type: MicrodepositType): String { return when (type) { MicrodepositType.AMOUNTS -> "amounts" @@ -455,6 +457,7 @@ internal fun mapFromMicrodepositType(type: MicrodepositType): String { } } +@SuppressLint("RestrictedApi") internal fun mapNextAction(type: NextActionType?, data: NextActionData?): WritableNativeMap? { val nextActionMap = WritableNativeMap() when (type) {