Skip to content

Commit

Permalink
Merge pull request #1528 from Adyen/fix/lookup-localization
Browse files Browse the repository at this point in the history
Fix address lookup localization issues
  • Loading branch information
ozgur00 authored Mar 22, 2024
2 parents 21749fd + c1f358f commit 52e05ce
Show file tree
Hide file tree
Showing 33 changed files with 88 additions and 104 deletions.
68 changes: 1 addition & 67 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,71 +8,5 @@
[//]: # (## Deprecated)
[//]: # ( - Configurations public constructor are deprecated, please use each Configuration's builder to make a Configuration object)

## New
- A new way to create a configuration using DSL to be more declarative and concise:
```Kotlin
CheckoutConfiguration(
environment = environment,
clientKey = clientKey,
shopperLocale = shopperLocale,
amount = amount,
) {
dropIn {
setEnableRemovingStoredPaymentMethods(true)
}

card {
setHolderNameRequired(true)
setShopperReference("...")
}

adyen3DS2 {
setThreeDSRequestorAppURL("...")
}
}
```

- For the Card Component, you can use the new [Address Lookup functionality](docs/ADDRESS_LOOKUP.md).
- For voucher actions: when the `url` or `downloadUrl` is not included, the shopper has the option to select **Save as image** and save the voucher to the device's `Downloads` folder.
- You can now set your own `AdyenLogger` instance with `AdyenLogger.setLogger`. This gives the ability to intercept logs and handle them in your own way.
- [Instructions](example-app/README.md) to use the testing app in the repository. You can follow `How to migrate` section [here](https://github.com/Adyen/adyen-android/pull/1505).
- Payment methods:
- Multibanco. Payment method type: **multibanco**.
- Pay Easy. Payment method type: **econtext_atm**.
- Convenience Stores Japan. Payment method type: **econtext_stores**
- Online Banking Japan. Payment method type: **econtext_online**.
- Seven-Eleven: Payment method type: **econtext_seven_eleven**

## Fixed
- When building `minifyEnabled` without the `kotlin-parcelize` plugin in your project, the build should no longer crash.
- When handling actions, you no longer get the `IllegalArgumentException: Unsupported delegate type` error that causes a crash.

## Deprecated
- When creating a configuration, the `Builder` constructors with a `Context` is deprecated. You can now omit the `context` parameter.
- `PermissionException`. Handle permissions through `ActionComponentCallback`, `SessionComponentCallback`, or `ComponentCallback` callbacks instead.
- The styles for vouchers have been changed:
- | Previous (v5.2.0 or earlier) | Now (v5.3.0) |
|---------------------------------------------|-----------------------------------------------|
| `AdyenCheckout.Voucher.Description.Bacs` | `AdyenCheckout.Voucher.Simple.Description` |
| `AdyenCheckout.Voucher.Description.Boleto` | `AdyenCheckout.Voucher.Full.Description` |
| `AdyenCheckout.Voucher.ExpirationDateLabel` | `AdyenCheckout.Voucher.InformationFieldLabel` |
| `AdyenCheckout.Voucher.ExpirationDate` | `AdyenCheckout.Voucher.InformationFieldValue` |
| `AdyenCheckout.Voucher.ButtonCopyCode` | `AdyenCheckout.Voucher.Button.CopyCode` |
| `AdyenCheckout.Voucher.ButtonDownloadPdf` | `AdyenCheckout.Voucher.Button.DownloadPdf` |
- Logger.LogLevel has been deprecated.
- | Previous (v5.2.0 or earlier) | Now (v5.3.0) |
|------------------------------------------|-------------------------------------------------|
| `Logger.LogLevel` | `AdyenLogLevel` |
| `AdyenLogger.setLogLevel(logLevel: Int)` | `AdyenLogger.setLogLevel(level: AdyenLogLevel)` |

## Changed
- When creating a configuration, the `shopperLocale` parameter is now optional.
- Sessions flow: when you don't set it, the shopper locale is set to the value included in the `/sessions` request.
- Advanced flow: when you don't set it, the shopper local is set to the primary user locale on the device.
- For Drop-in, all actions now start in expanded mode.
- For the Google Pay Component, you no longer need to manually import the `3ds2` module to handle transactions that require Native 3D Secure 2 challenge.
- If you use `DropInServiceResult.Error` without specifying an error message, the default has changed from `Error sending payment. Please try again.` to `An unknown error occurred`.
- For the Sessions flow:
- When starting Drop-in (with `DropIn.startPayment`) or creating a Component (with `YourComponent.PROVIDER.get`), the `configuration` parameter is now optional.
- When using `CheckoutSessionProvider.createSession` to create a `CheckoutSession`, you can pass only `environment` and `clientKey` instead of the whole configuration.
- Removing stored payment methods is now handled internally. You no longer need to override the `onRemoveStoredPaymentMethod` function.
- Localization issues in address lookup functionality.
3 changes: 1 addition & 2 deletions card/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@
<item name="android:layout_width">match_parent</item>
<item name="android:layout_marginBottom">@dimen/standard_margin</item>
<item name="android:minHeight">@dimen/input_height</item>
<item name="android:hint">Search Address</item>
<item name="android:text">@string/checkout_address_lookup_hint</item>
<item name="android:hint">@string/checkout_address_lookup_hint</item>
<item name="drawableTint">?android:attr/textColor</item>
</style>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.adyen.checkout.ui.core.internal.ui.AddressLookupDelegate
import com.adyen.checkout.ui.core.internal.ui.ComponentView
import com.adyen.checkout.ui.core.internal.ui.model.AddressLookupState
import com.adyen.checkout.ui.core.internal.util.formatStringWithHyperlink
import com.adyen.checkout.ui.core.internal.util.setLocalizedQueryHintFromStyle
import com.adyen.checkout.ui.core.internal.util.setLocalizedTextFromStyle
import com.adyen.checkout.ui.core.internal.util.showKeyboard
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -98,7 +99,10 @@ class AddressLookupView @JvmOverloads constructor(
}

private fun initLocalizedStrings(localizedContext: Context) {
binding.addressFormInput.initLocalizedContext(localizedContext)
binding.textInputLayoutAddressLookupQuerySearch.setLocalizedQueryHintFromStyle(
styleResId = R.style.AdyenCheckout_AddressLookup_Query,
localizedContext = localizedContext,
)

binding.textViewInitialDisclaimer.setLocalizedTextFromStyle(
styleResId = R.style.AdyenCheckout_AddressLookup_InitialDisclaimer_Title,
Expand All @@ -119,6 +123,18 @@ class AddressLookupView @JvmOverloads constructor(
localizedContext = localizedContext,
formatHyperLink = true,
)

binding.buttonManualEntry.setLocalizedTextFromStyle(
styleResId = R.style.AdyenCheckout_AddressLookup_Button_Manual,
localizedContext = localizedContext,
)

binding.buttonSubmitAddress.setLocalizedTextFromStyle(
styleResId = R.style.AdyenCheckout_AddressLookup_Button_Submit,
localizedContext = localizedContext,
)

binding.addressFormInput.initLocalizedContext(localizedContext)
}

private fun initAddressLookupQuery() {
Expand Down Expand Up @@ -169,7 +185,7 @@ class AddressLookupView @JvmOverloads constructor(
}

private fun initSubmitAddressButton() {
binding.submitAddressButton.setOnClickListener {
binding.buttonSubmitAddress.setOnClickListener {
addressLookupDelegate.submitAddress()
}
}
Expand All @@ -195,7 +211,7 @@ class AddressLookupView @JvmOverloads constructor(
binding.progressBar.isVisible = false
binding.buttonManualEntry.isVisible = false
binding.divider.isVisible = false
binding.submitAddressButton.isVisible = false
binding.buttonSubmitAddress.isVisible = false
binding.textViewManualEntryError.text =
localizedContext.getString(R.string.checkout_address_lookup_empty_description, addressLookupState.query)
.formatStringWithHyperlink("#")
Expand All @@ -211,7 +227,7 @@ class AddressLookupView @JvmOverloads constructor(
binding.progressBar.isVisible = false
binding.buttonManualEntry.isVisible = false
binding.divider.isVisible = false
binding.submitAddressButton.isVisible = false
binding.buttonSubmitAddress.isVisible = false
}

private fun handleLoadingState() {
Expand All @@ -224,7 +240,7 @@ class AddressLookupView @JvmOverloads constructor(
binding.progressBar.isVisible = true
binding.buttonManualEntry.isVisible = false
binding.divider.isVisible = false
binding.submitAddressButton.isVisible = false
binding.buttonSubmitAddress.isVisible = false
}

private fun handleFormState(addressLookupState: AddressLookupState.Form) {
Expand All @@ -237,7 +253,7 @@ class AddressLookupView @JvmOverloads constructor(
binding.progressBar.isVisible = false
binding.buttonManualEntry.isVisible = false
binding.divider.isVisible = false
binding.submitAddressButton.isVisible = true
binding.buttonSubmitAddress.isVisible = true
addressLookupDelegate.addressDelegate.updateAddressInputData {
if (addressLookupState.selectedAddress == null) {
this.resetAll()
Expand All @@ -257,7 +273,7 @@ class AddressLookupView @JvmOverloads constructor(
binding.progressBar.isVisible = false
binding.buttonManualEntry.isVisible = true
binding.divider.isVisible = true
binding.submitAddressButton.isVisible = false
binding.buttonSubmitAddress.isVisible = false
setAddressOptions(addressLookupState.options)
}

Expand All @@ -271,7 +287,7 @@ class AddressLookupView @JvmOverloads constructor(
binding.progressBar.isVisible = false
binding.buttonManualEntry.isVisible = false
binding.divider.isVisible = false
binding.submitAddressButton.isVisible = true
binding.buttonSubmitAddress.isVisible = true
highlightValidationErrors()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.text.style.URLSpan
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT
import android.widget.SearchView
import android.widget.TextView
import androidx.annotation.RestrictTo
import androidx.annotation.StyleRes
Expand Down Expand Up @@ -47,6 +48,14 @@ fun TextView.setLocalizedTextFromStyle(
typedArray.recycle()
}

@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
fun SearchView.setLocalizedQueryHintFromStyle(@StyleRes styleResId: Int, localizedContext: Context) {
val attrs = intArrayOf(android.R.attr.queryHint)
val typedArray = localizedContext.obtainStyledAttributes(styleResId, attrs)
queryHint = typedArray.getString(0)
typedArray.recycle()
}

internal fun String.formatStringWithHyperlink(replacementToken: String = "%#"): CharSequence {
// check if the string contains the replacement token twice
val counter = this.split(replacementToken).size - 1
Expand Down
2 changes: 1 addition & 1 deletion ui-core/src/main/res/layout/address_lookup_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
tools:visibility="visible" />

<com.google.android.material.button.MaterialButton
android:id="@+id/submitAddressButton"
android:id="@+id/button_submitAddress"
style="@style/AdyenCheckout.AddressLookup.Button.Submit"
android:visibility="gone" />
</merge>
1 change: 1 addition & 0 deletions ui-core/src/main/res/template/values/strings.xml.tt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<string name="checkout_address_lookup_empty">%%address.lookup.search.empty.title.noResults%%</string>
<string name="checkout_address_lookup_empty_description">%%address.lookup.search.empty.subtitle.noResults%%</string>
<string name="checkout_address_lookup_enter_manually">%%address.enterManually%%</string>
<string name="checkout_address_lookup_submit">%%address.lookup.submit%%</string>

<!-- Untranslatable strings -->
<string name="checkout_country_name_format" translatable="false">%1$s (%2$s)</string>
Expand Down
1 change: 1 addition & 0 deletions ui-core/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@
<string name="checkout_address_lookup_empty">لم يتم العثور على نتائج</string>
<string name="checkout_address_lookup_empty_description">لم يتطابق \'%s\' مع أي شيء، حاول مرة أخرى أو استخدم #إدخال العنوان يدويًا#</string>
<string name="checkout_address_lookup_enter_manually">أدخل العنوان يدويًا</string>
<string name="checkout_address_lookup_submit">استخدم هذا العنوان</string>

</resources>
5 changes: 3 additions & 2 deletions ui-core/src/main/res/values-cs-rCZ/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@
<string name="checkout_address_form_province_territory_hint_optional">Provincie nebo teritorium</string>
<string name="checkout_address_form_city_town_hint_optional">Město (nepovinné)</string>

<string name="checkout_address_lookup_hint">Vyhledat vaši adresu</string>
<string name="checkout_address_lookup_initial">Nedaří se vám vyhledat vaši adresu?</string>
<string name="checkout_address_lookup_hint">Vyhledat svou adresu</string>
<string name="checkout_address_lookup_initial">Nemůžete najít svou adresu?</string>
<string name="checkout_address_lookup_initial_description">Vždy můžete #zadat svou adresu ručně#</string>
<string name="checkout_address_lookup_empty">Nebyly nalezeny žádné výsledky</string>
<string name="checkout_address_lookup_empty_description">„%s“ se s ničím neshoduje, zkuste to znovu nebo použijte #ruční zadání adresy#</string>
<string name="checkout_address_lookup_enter_manually">Zadejte adresu ručně</string>
<string name="checkout_address_lookup_submit">Použijte tuto adresu</string>

</resources>
5 changes: 3 additions & 2 deletions ui-core/src/main/res/values-da-rDK/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@
<string name="checkout_address_form_province_territory_hint_optional">Provins eller territorium (valgfrit)</string>
<string name="checkout_address_form_city_town_hint_optional">By (valgfrit)</string>

<string name="checkout_address_lookup_hint">Søg din adresse</string>
<string name="checkout_address_lookup_initial">Kan du ikke søge din adresse?</string>
<string name="checkout_address_lookup_hint">Søg efter din adresse</string>
<string name="checkout_address_lookup_initial">Kan du ikke søge efter din adresse?</string>
<string name="checkout_address_lookup_initial_description">Du kan altid #indtaste din adresse manuelt#</string>
<string name="checkout_address_lookup_empty">Ingen resultater fundet</string>
<string name="checkout_address_lookup_empty_description">Fandt ikke noget match for \'%s\'. Prøv igen eller #indtast adresse manuelt#.</string>
<string name="checkout_address_lookup_enter_manually">Indtast adresse manuelt</string>
<string name="checkout_address_lookup_submit">Brug denne adresse</string>

</resources>
7 changes: 4 additions & 3 deletions ui-core/src/main/res/values-de-rDE/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@
<string name="checkout_address_form_province_territory_hint_optional">Provinz oder Territorium (optional)</string>
<string name="checkout_address_form_city_town_hint_optional">Ort (optional)</string>

<string name="checkout_address_lookup_hint">Suchen Sie Ihre Adresse</string>
<string name="checkout_address_lookup_initial">Sie können Ihre Adresse nicht suchen?</string>
<string name="checkout_address_lookup_hint">Suchen Sie nach Ihrer Adresse</string>
<string name="checkout_address_lookup_initial">Sie können nicht nach Ihrer Adresse suchen?</string>
<string name="checkout_address_lookup_initial_description">Sie können Ihre Adresse jederzeit manuell #eingeben#</string>
<string name="checkout_address_lookup_empty">Keine Ergebnisse gefunden</string>
<string name="checkout_address_lookup_empty_description">\'%s\' stimmt nicht mit irgendetwas überein, versuchen Sie es erneut oder verwenden Sie #manual address entry#</string>
<string name="checkout_address_lookup_enter_manually">Geben Sie die Adresse manuell ein</string>
<string name="checkout_address_lookup_submit">Diese Adresse verwenden</string>

</resources>
</resources>
3 changes: 2 additions & 1 deletion ui-core/src/main/res/values-el-rGR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@
<string name="checkout_address_form_city_town_hint_optional">Πόλη / Δήμος (προαιρετικό)</string>

<string name="checkout_address_lookup_hint">Αναζητήστε τη διεύθυνσή σας</string>
<string name="checkout_address_lookup_initial">Δεν μπορείτε να κάνετε αναζήτηση της διεύθυνσής σας;</string>
<string name="checkout_address_lookup_initial">Δεν μπορείτε να αναζητήσετε τη διεύθυνσή σας;</string>
<string name="checkout_address_lookup_initial_description">Μπορείτε πάντα να #εισαγάγετε τη διεύθυνσή σας μη αυτόματα#</string>
<string name="checkout_address_lookup_empty">Δεν βρέθηκαν αποτελέσματα</string>
<string name="checkout_address_lookup_empty_description">Το \'%s\' δεν ταιριάζει με τίποτα. Προσπαθήστε ξανά ή χρησιμοποιήστε #μη αυτόματη εισαγωγή διεύθυνσης#</string>
<string name="checkout_address_lookup_enter_manually">Εισαγάγετε τη διεύθυνση μη αυτόματα</string>
<string name="checkout_address_lookup_submit">Χρησιμοποιήστε αυτήν τη διεύθυνση</string>

</resources>
1 change: 1 addition & 0 deletions ui-core/src/main/res/values-es-rES/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@
<string name="checkout_address_lookup_empty">No se han encontrado resultados</string>
<string name="checkout_address_lookup_empty_description">"%s" no ha coincidido con nada, inténtelo de nuevo o #introduzca su dirección manualmente#</string>
<string name="checkout_address_lookup_enter_manually">Introduzca la dirección manualmente</string>
<string name="checkout_address_lookup_submit">Usar esta dirección</string>

</resources>
1 change: 1 addition & 0 deletions ui-core/src/main/res/values-fi-rFI/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@
<string name="checkout_address_lookup_empty">Tuloksia ei löytynyt</string>
<string name="checkout_address_lookup_empty_description">\'%s\' ei tuottanut tuloksia. Yritä uudelleen tai käytä #manuaalista osoitteen syöttöä#</string>
<string name="checkout_address_lookup_enter_manually">Syötä osoite manuaalisesti</string>
<string name="checkout_address_lookup_submit">Käytä tätä osoitetta</string>

</resources>
3 changes: 2 additions & 1 deletion ui-core/src/main/res/values-fr-rFR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@
<string name="checkout_address_form_province_territory_hint_optional">Province ou territoire (facultatif)</string>
<string name="checkout_address_form_city_town_hint_optional">Ville (facultatif)</string>

<string name="checkout_address_lookup_hint">Rechercher votre adresse</string>
<string name="checkout_address_lookup_hint">Recherchez votre adresse</string>
<string name="checkout_address_lookup_initial">Vous ne pouvez pas rechercher votre adresse ?</string>
<string name="checkout_address_lookup_initial_description">Vous pouvez toujours #saisir votre adresse manuellement#</string>
<string name="checkout_address_lookup_empty">Aucun résultat trouvé</string>
<string name="checkout_address_lookup_empty_description">Aucune correspondance pour \'%s\', réessayez ou #saisissez votre adresse manuellement#</string>
<string name="checkout_address_lookup_enter_manually">Saisissez l\'adresse manuellement</string>
<string name="checkout_address_lookup_submit">Utiliser cette adresse</string>

</resources>
Loading

0 comments on commit 52e05ce

Please sign in to comment.