Skip to content

Commit

Permalink
Merge pull request #1581 from Adyen/feature/ui-neutrality
Browse files Browse the repository at this point in the history
UI neutrality
  • Loading branch information
OscarSpruit authored Apr 24, 2024
2 parents 89bb2f4 + 9ee42a7 commit 1741e5b
Show file tree
Hide file tree
Showing 34 changed files with 354 additions and 307 deletions.
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@

## Fixed
- Fixed various memory leaks.

## Changed
- Flags are replaced by ISO codes in the phone number inputs (affected payment methods: MB Way, Pay Easy, Convenience Stores Japan, Online Banking Japan and Seven-Eleven).
- Strings containing "country" are changed to "country/region".

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.adyen.checkout.components.core.internal.util

import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import java.util.Locale

internal class CountryUtilsTest {

@Nested
inner class GetCountriesTest {

@Test
fun `when passing nothing, then all countries are returned`() {
val actual = CountryUtils.getCountries()

assertEquals(CountryUtils.countries, actual)
}

@Test
fun `when passing list of countries, then only specified countries are returned`() {
val specifiedCountries = listOf(
"NL",
"US",
"DE",
)
val actual = CountryUtils.getCountries(specifiedCountries)

val expected = listOf(
CountryInfo(isoCode = "DE", callingCode = "+49"),
CountryInfo(isoCode = "NL", callingCode = "+31"),
CountryInfo(isoCode = "US", callingCode = "+1"),
)
assertEquals(expected, actual)
}
}

@Test
fun `when getting country name, then it is returned localized`() {
val actual = CountryUtils.getCountryName("NL", Locale.US)

val expected = "Netherlands"
assertEquals(expected, actual)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,19 @@ internal class EContextView @JvmOverloads constructor(
private fun initLocalizedStrings(localizedContext: Context) {
binding.textInputLayoutFirstName.setLocalizedHintFromStyle(
R.style.AdyenCheckout_EContext_FirstNameInput,
localizedContext
localizedContext,
)
binding.textInputLayoutLastName.setLocalizedHintFromStyle(
R.style.AdyenCheckout_EContext_LastNameInput,
localizedContext
localizedContext,
)
binding.textInputLayoutMobileNumber.setLocalizedHintFromStyle(
R.style.AdyenCheckout_EContext_PhoneNumberInput,
localizedContext
localizedContext,
)
binding.textInputLayoutEmailAddress.setLocalizedHintFromStyle(
R.style.AdyenCheckout_EContext_ShopperEmailInput,
localizedContext
localizedContext,
)
}

Expand Down Expand Up @@ -163,7 +163,6 @@ internal class EContextView @JvmOverloads constructor(
isoCode = it.isoCode,
countryName = CountryUtils.getCountryName(it.isoCode, delegate.componentParams.shopperLocale),
callingCode = it.callingCode,
emoji = it.emoji
)
}
countryAdapter = CountryAdapter(context, localizedContext).apply {
Expand Down
4 changes: 2 additions & 2 deletions example-app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<string name="gift_card_component_entry">Gift Card</string>
<string name="gift_card_with_session_component_entry">Gift Card</string>

<string name="country_code_error">Your country code must be %s</string>
<string name="country_code_error">Your country/region code must be %s</string>
<string name="currency_code_error">Your currency code must be %s</string>
<string name="google_pay_unavailable_error">Google Pay is unavailable on this device</string>

Expand Down Expand Up @@ -45,7 +45,7 @@
<string name="threeds_mode_key">threeds_mode</string>
<string name="threeds_mode_title">3D Secure</string>
<string name="shopper_country_key">shopper_country</string>
<string name="shopper_country_title">Country</string>
<string name="shopper_country_title">Country/region</string>
<string name="shopper_locale_key">shopper_locale</string>
<string name="shopper_locale_title">Shopper Locale</string>
<string name="shopper_email_key">shopper_email</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ internal class MbWayView @JvmOverloads constructor(
isoCode = it.isoCode,
countryName = CountryUtils.getCountryName(it.isoCode, delegate.componentParams.shopperLocale),
callingCode = it.callingCode,
emoji = it.emoji,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ internal class CountryViewHolder(private val binding: CountryViewBinding) : Recy

fun bindItem(country: CountryModel) {
with(binding) {
textViewFlag.text = country.emoji
textViewCountryCode.text = country.isoCode
textViewCountry.text = root.context.getString(
R.string.checkout_country_name_format,
country.countryName,
country.callingCode
country.callingCode,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ data class CountryModel(
val isoCode: String,
val countryName: String,
val callingCode: String,
val emoji: String
) {
fun toShortString(): String {
return "$emoji $callingCode"
return "$isoCode $callingCode"
}
}
4 changes: 2 additions & 2 deletions ui-core/src/main/res/layout/country_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
android:padding="@dimen/standard_three_quarters_margin">

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/textView_flag"
android:id="@+id/textView_countryCode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="@dimen/standard_half_margin"
android:textSize="16sp"
tools:text="🇳🇱" />
tools:text="NL" />

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/textView_country"
Expand Down
4 changes: 2 additions & 2 deletions ui-core/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<string name="checkout_address_form_house_number_hint">رقم المنزل</string>
<string name="checkout_address_form_apartment_suite_hint">الشقة / الجناح</string>
<string name="checkout_address_form_city_hint">المدينة</string>
<string name="checkout_address_form_country_hint">البلد</string>
<string name="checkout_address_form_country_hint">البلد/المنطقة</string>
<string name="checkout_address_form_states_hint">الولاية</string>
<string name="checkout_address_postal_code_hint">الرمز البريدي</string>
<string name="checkout_address_form_zip_code_hint">الرمز البريدي</string>
Expand All @@ -40,7 +40,7 @@
<string name="checkout_address_form_house_number_hint_optional">رقم المنزل (اختياري)</string>
<string name="checkout_address_form_apartment_suite_hint_optional">الشقة / الجناح (اختياري)</string>
<string name="checkout_address_form_city_hint_optional"> المدينة (اختياري)</string>
<string name="checkout_address_form_country_hint_optional">البلد (اختياري)</string>
<string name="checkout_address_form_country_hint_optional">البلد/المنطقة (اختياري)</string>
<string name="checkout_address_form_states_hint_optional">الولاية (اختياري)</string>
<string name="checkout_address_postal_code_hint_optional">الرمز البريدي (اختياري)</string>
<string name="checkout_address_form_zip_code_hint_optional">الرمز البريدي (اختياري)</string>
Expand Down
4 changes: 2 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 @@ -28,7 +28,7 @@
<string name="checkout_address_form_house_number_hint">Číslo popisné</string>
<string name="checkout_address_form_apartment_suite_hint">Byt</string>
<string name="checkout_address_form_city_hint">Město</string>
<string name="checkout_address_form_country_hint">Země</string>
<string name="checkout_address_form_country_hint">Země/region</string>
<string name="checkout_address_form_states_hint">Stát</string>
<string name="checkout_address_postal_code_hint">PSČ</string>
<string name="checkout_address_form_zip_code_hint">PSČ</string>
Expand All @@ -40,7 +40,7 @@
<string name="checkout_address_form_house_number_hint_optional">Číslo popisné (nepovinné)</string>
<string name="checkout_address_form_apartment_suite_hint_optional">Byt (nepovinné)</string>
<string name="checkout_address_form_city_hint_optional"> Město (nepovinné)</string>
<string name="checkout_address_form_country_hint_optional">Země (nepovinné)</string>
<string name="checkout_address_form_country_hint_optional">Země/region (nepovinné)</string>
<string name="checkout_address_form_states_hint_optional">Stát (nepovinné)</string>
<string name="checkout_address_postal_code_hint_optional">Poštovní směrovací číslo (nepovinné)</string>
<string name="checkout_address_form_zip_code_hint_optional">PSČ (nepovinné)</string>
Expand Down
4 changes: 2 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 @@ -28,7 +28,7 @@
<string name="checkout_address_form_house_number_hint">Husnummer</string>
<string name="checkout_address_form_apartment_suite_hint">Lejlighed/suite</string>
<string name="checkout_address_form_city_hint">By</string>
<string name="checkout_address_form_country_hint">Land</string>
<string name="checkout_address_form_country_hint">Land/region</string>
<string name="checkout_address_form_states_hint">Stat</string>
<string name="checkout_address_postal_code_hint">Postnummer</string>
<string name="checkout_address_form_zip_code_hint">Postnummer</string>
Expand All @@ -40,7 +40,7 @@
<string name="checkout_address_form_house_number_hint_optional">Husnummer (valgfrit)</string>
<string name="checkout_address_form_apartment_suite_hint_optional">Lejlighed/suite (valgfrit)</string>
<string name="checkout_address_form_city_hint_optional"> By (valgfrit)</string>
<string name="checkout_address_form_country_hint_optional">Land (valgfrit)</string>
<string name="checkout_address_form_country_hint_optional">Land/region (valgfrit)</string>
<string name="checkout_address_form_states_hint_optional">Stat (valgfrit)</string>
<string name="checkout_address_postal_code_hint_optional">Postnummer (valgfrit)</string>
<string name="checkout_address_form_zip_code_hint_optional">Postnummer (valgfrit)</string>
Expand Down
4 changes: 2 additions & 2 deletions ui-core/src/main/res/values-de-rDE/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<string name="checkout_address_form_house_number_hint">Hausnummer</string>
<string name="checkout_address_form_apartment_suite_hint">Wohnung/Geschoss</string>
<string name="checkout_address_form_city_hint">Stadt</string>
<string name="checkout_address_form_country_hint">Land</string>
<string name="checkout_address_form_country_hint">Land/Region</string>
<string name="checkout_address_form_states_hint">Bundesstaat</string>
<string name="checkout_address_postal_code_hint">Postleitzahl</string>
<string name="checkout_address_form_zip_code_hint">PLZ</string>
Expand All @@ -40,7 +40,7 @@
<string name="checkout_address_form_house_number_hint_optional">Hausnummer (optional)</string>
<string name="checkout_address_form_apartment_suite_hint_optional">Wohnung/Geschoss (optional)</string>
<string name="checkout_address_form_city_hint_optional"> Stadt (optional)</string>
<string name="checkout_address_form_country_hint_optional">Land (optional)</string>
<string name="checkout_address_form_country_hint_optional">Land/Region (optional)</string>
<string name="checkout_address_form_states_hint_optional">Bundesstaat (optional)</string>
<string name="checkout_address_postal_code_hint_optional">Postleitzahl (optional)</string>
<string name="checkout_address_form_zip_code_hint_optional">PLZ (optional)</string>
Expand Down
4 changes: 2 additions & 2 deletions ui-core/src/main/res/values-el-rGR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<string name="checkout_address_form_house_number_hint">Αριθμός οικίας</string>
<string name="checkout_address_form_apartment_suite_hint">Διαμέρισμα/Γραφείο</string>
<string name="checkout_address_form_city_hint">Πόλη</string>
<string name="checkout_address_form_country_hint">Χώρα</string>
<string name="checkout_address_form_country_hint">Χώρα/Περιοχή</string>
<string name="checkout_address_form_states_hint">Πολιτεία</string>
<string name="checkout_address_postal_code_hint">Ταχυδρομικός κωδικός</string>
<string name="checkout_address_form_zip_code_hint">Ταχυδρομικός κώδικας</string>
Expand All @@ -40,7 +40,7 @@
<string name="checkout_address_form_house_number_hint_optional">Αριθμός οικίας (προαιρετικό)</string>
<string name="checkout_address_form_apartment_suite_hint_optional">Διαμέρισμα/Γραφείο (προαιρετικό)</string>
<string name="checkout_address_form_city_hint_optional"> Πόλη (προαιρετικό)</string>
<string name="checkout_address_form_country_hint_optional">Χώρα (προαιρετικό)</string>
<string name="checkout_address_form_country_hint_optional">Χώρα/Περιοχή (προαιρετικό)</string>
<string name="checkout_address_form_states_hint_optional">Πολιτεία (προαιρετικό)</string>
<string name="checkout_address_postal_code_hint_optional">Ταχυδρομικός κωδικός (προαιρετικό)</string>
<string name="checkout_address_form_zip_code_hint_optional">Ταχυδρομικός κωδικός (προαιρετικό)</string>
Expand Down
4 changes: 2 additions & 2 deletions ui-core/src/main/res/values-es-rES/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<string name="checkout_address_form_house_number_hint">Número de vivienda</string>
<string name="checkout_address_form_apartment_suite_hint">Apartamento/suite</string>
<string name="checkout_address_form_city_hint">Ciudad</string>
<string name="checkout_address_form_country_hint">País</string>
<string name="checkout_address_form_country_hint">País o región</string>
<string name="checkout_address_form_states_hint">Estado</string>
<string name="checkout_address_postal_code_hint">Código postal</string>
<string name="checkout_address_form_zip_code_hint">Código postal</string>
Expand All @@ -40,7 +40,7 @@
<string name="checkout_address_form_house_number_hint_optional">Número de vivienda (opcional)</string>
<string name="checkout_address_form_apartment_suite_hint_optional">Apartamento/suite (opcional)</string>
<string name="checkout_address_form_city_hint_optional"> Ciudad (opcional)</string>
<string name="checkout_address_form_country_hint_optional">País (opcional)</string>
<string name="checkout_address_form_country_hint_optional">País o región (opcional)</string>
<string name="checkout_address_form_states_hint_optional">Estado (opcional)</string>
<string name="checkout_address_postal_code_hint_optional">Código postal (opcional)</string>
<string name="checkout_address_form_zip_code_hint_optional">Código postal (opcional)</string>
Expand Down
4 changes: 2 additions & 2 deletions ui-core/src/main/res/values-fi-rFI/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<string name="checkout_address_form_house_number_hint">Talon numero</string>
<string name="checkout_address_form_apartment_suite_hint">Huoneisto / sviitti</string>
<string name="checkout_address_form_city_hint">Kaupunki</string>
<string name="checkout_address_form_country_hint">Maa</string>
<string name="checkout_address_form_country_hint">Maa/alue</string>
<string name="checkout_address_form_states_hint">Osavaltio</string>
<string name="checkout_address_postal_code_hint">Postinumero</string>
<string name="checkout_address_form_zip_code_hint">Postinumero</string>
Expand All @@ -40,7 +40,7 @@
<string name="checkout_address_form_house_number_hint_optional">Talon numero (valinnainen)</string>
<string name="checkout_address_form_apartment_suite_hint_optional">Huoneisto / sviitti (valinnainen)</string>
<string name="checkout_address_form_city_hint_optional"> Kaupunki (valinnainen)</string>
<string name="checkout_address_form_country_hint_optional">Maa (valinnainen)</string>
<string name="checkout_address_form_country_hint_optional">Maa/alue (valinnainen)</string>
<string name="checkout_address_form_states_hint_optional">Osavaltio (valinnainen)</string>
<string name="checkout_address_postal_code_hint_optional">Postinumero (valinnainen)</string>
<string name="checkout_address_form_zip_code_hint_optional">Postinumero (valinnainen)</string>
Expand Down
4 changes: 2 additions & 2 deletions ui-core/src/main/res/values-fr-rFR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<string name="checkout_address_form_house_number_hint">Numéro de rue</string>
<string name="checkout_address_form_apartment_suite_hint">Appartement</string>
<string name="checkout_address_form_city_hint">Ville</string>
<string name="checkout_address_form_country_hint">Pays</string>
<string name="checkout_address_form_country_hint">Pays/Région</string>
<string name="checkout_address_form_states_hint">État</string>
<string name="checkout_address_postal_code_hint">Code postal</string>
<string name="checkout_address_form_zip_code_hint">Code postal</string>
Expand All @@ -40,7 +40,7 @@
<string name="checkout_address_form_house_number_hint_optional">Numéro de rue (facultatif)</string>
<string name="checkout_address_form_apartment_suite_hint_optional">Appartement (facultatif)</string>
<string name="checkout_address_form_city_hint_optional"> Ville (facultatif)</string>
<string name="checkout_address_form_country_hint_optional">Pays (facultatif)</string>
<string name="checkout_address_form_country_hint_optional">Pays/Région (facultatif)</string>
<string name="checkout_address_form_states_hint_optional">État (facultatif)</string>
<string name="checkout_address_postal_code_hint_optional">Code postal (facultatif)</string>
<string name="checkout_address_form_zip_code_hint_optional">Code postal (facultatif)</string>
Expand Down
4 changes: 2 additions & 2 deletions ui-core/src/main/res/values-hr-rHR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<string name="checkout_address_form_house_number_hint">Kućni broj</string>
<string name="checkout_address_form_apartment_suite_hint">Stan/apartman</string>
<string name="checkout_address_form_city_hint">Grad</string>
<string name="checkout_address_form_country_hint">Zemlja</string>
<string name="checkout_address_form_country_hint">Zemlja/regija</string>
<string name="checkout_address_form_states_hint">Savezna država</string>
<string name="checkout_address_postal_code_hint">Poštanski broj</string>
<string name="checkout_address_form_zip_code_hint">Poštanski broj</string>
Expand All @@ -40,7 +40,7 @@
<string name="checkout_address_form_house_number_hint_optional">Kućni broj (neobavezno)</string>
<string name="checkout_address_form_apartment_suite_hint_optional">Stan/apartman (neobavezno)</string>
<string name="checkout_address_form_city_hint_optional"> Grad (nije obvezno)</string>
<string name="checkout_address_form_country_hint_optional">Zemlja (neobavezno)</string>
<string name="checkout_address_form_country_hint_optional">Zemlja/regija (neobavezno)</string>
<string name="checkout_address_form_states_hint_optional">Savezna država (neobavezno)</string>
<string name="checkout_address_postal_code_hint_optional">Poštanski broj (nije obvezno)</string>
<string name="checkout_address_form_zip_code_hint_optional">Poštanski broj (neobavezno)</string>
Expand Down
Loading

0 comments on commit 1741e5b

Please sign in to comment.