From 1f2886717d5d5c9ab33adbaa2cc882ecff2d81fb Mon Sep 17 00:00:00 2001 From: "a.shishkin1" Date: Wed, 5 Dec 2018 14:06:18 +0300 Subject: [PATCH 01/13] custom localization init --- .../tinkoff/acquiring/payment/TinkoffPay.kt | 6 +- .../acquiring/sample/ui/MainActivity.java | 2 +- .../acquiring/sample/ui/PayableActivity.java | 2 +- sample/src/main/res/values/style_custom.xml | 5 - ui/build.gradle | 2 +- .../acquiring/sdk/AttachCardFormActivity.java | 59 +++--- .../acquiring/sdk/AttachCardFormFragment.java | 33 +++- .../acquiring/sdk/AttachCardFormStarter.java | 37 ++-- .../acquiring/sdk/CardListFragment.java | 17 +- .../tinkoff/acquiring/sdk/DialogsManager.java | 9 +- .../acquiring/sdk/EnterCardFragment.java | 180 ++++++------------ .../acquiring/sdk/FullCardScanner.java | 16 +- .../acquiring/sdk/IBaseSdkActivity.java | 4 +- .../sdk/LoopConfirmationFragment.java | 10 +- .../acquiring/sdk/PayFormActivity.java | 105 ++++------ .../tinkoff/acquiring/sdk/PayFormStarter.java | 68 ++++--- .../acquiring/sdk/TAcqIntentExtra.java | 42 ++++ .../inflate/attach/AttachCellInflater.java | 11 +- .../sdk/inflate/pay/PayCellInflater.java | 17 +- .../sdk/localization/AsdkLocalization.java | 108 +++++++++++ .../sdk/localization/AsdkLocalizations.java | 172 +++++++++++++++++ .../localization/FileLocalizationParser.java | 38 ++++ .../localization/GsonLocalizationParser.java | 20 ++ .../sdk/localization/HasAsdkLocalization.java | 40 ++++ .../sdk/localization/LocalizationParser.java | 19 ++ .../RawResourceLocalizationParser.java | 36 ++++ .../acquiring/sdk/localization/Utility.java | 24 +++ .../sdk/nfc/AsdkNfcScanActivity.java | 20 +- ui/src/main/res/layout/acq_activity_nfc.xml | 3 +- ui/src/main/res/layout/acq_cell_amount.xml | 2 +- .../acq_cell_payment_card_requisites.xml | 3 +- .../res/layout/acq_fragment_attach_card.xml | 80 -------- .../res/layout/acq_fragment_enter_card.xml | 146 -------------- .../layout/acq_fragment_loop_confirmation.xml | 5 +- ui/src/main/res/layout/acq_item_new_card.xml | 3 +- ui/src/main/res/menu/menu_delete_card.xml | 10 - ui/src/main/res/raw/acq_localization_en.json | 51 +++++ ui/src/main/res/raw/acq_localization_ru.json | 51 +++++ ui/src/main/res/values-ru/strings.xml | 42 ---- ui/src/main/res/values/attrs.xml | 3 - ui/src/main/res/values/ids.xml | 7 + ui/src/main/res/values/strings.xml | 40 ---- ui/src/main/res/values/styles.xml | 8 - 43 files changed, 907 insertions(+), 649 deletions(-) create mode 100644 ui/src/main/java/ru/tinkoff/acquiring/sdk/TAcqIntentExtra.java create mode 100644 ui/src/main/java/ru/tinkoff/acquiring/sdk/localization/AsdkLocalization.java create mode 100644 ui/src/main/java/ru/tinkoff/acquiring/sdk/localization/AsdkLocalizations.java create mode 100644 ui/src/main/java/ru/tinkoff/acquiring/sdk/localization/FileLocalizationParser.java create mode 100644 ui/src/main/java/ru/tinkoff/acquiring/sdk/localization/GsonLocalizationParser.java create mode 100644 ui/src/main/java/ru/tinkoff/acquiring/sdk/localization/HasAsdkLocalization.java create mode 100644 ui/src/main/java/ru/tinkoff/acquiring/sdk/localization/LocalizationParser.java create mode 100644 ui/src/main/java/ru/tinkoff/acquiring/sdk/localization/RawResourceLocalizationParser.java create mode 100644 ui/src/main/java/ru/tinkoff/acquiring/sdk/localization/Utility.java delete mode 100644 ui/src/main/res/layout/acq_fragment_attach_card.xml delete mode 100644 ui/src/main/res/layout/acq_fragment_enter_card.xml delete mode 100644 ui/src/main/res/menu/menu_delete_card.xml create mode 100644 ui/src/main/res/raw/acq_localization_en.json create mode 100644 ui/src/main/res/raw/acq_localization_ru.json create mode 100644 ui/src/main/res/values/ids.xml diff --git a/payment/src/main/java/ru/tinkoff/acquiring/payment/TinkoffPay.kt b/payment/src/main/java/ru/tinkoff/acquiring/payment/TinkoffPay.kt index 72d447d..8d5135b 100644 --- a/payment/src/main/java/ru/tinkoff/acquiring/payment/TinkoffPay.kt +++ b/payment/src/main/java/ru/tinkoff/acquiring/payment/TinkoffPay.kt @@ -48,10 +48,10 @@ class TinkoffPay private constructor(private var sdk: AcquiringSdk, private fun PayFormStarter.addPaymentUiData(paymentDataUi: PaymentDataUi): PayFormStarter { paymentDataUi.apply { if (card != null && paymentInfo != null) { - intent.putExtra(PayFormActivity.EXTRA_CARD_DATA, CardsArrayBundlePacker().pack(arrayOf(paymentDataUi.card))) - intent.putExtra(PayFormActivity.EXTRA_PAYMENT_INFO, PaymentInfoBundlePacker().pack(paymentDataUi.paymentInfo)) + intent.putExtra(TAcqIntentExtra.EXTRA_CARD_DATA, CardsArrayBundlePacker().pack(arrayOf(paymentDataUi.card))) + intent.putExtra(TAcqIntentExtra.EXTRA_PAYMENT_INFO, PaymentInfoBundlePacker().pack(paymentDataUi.paymentInfo)) } else if (threeDsData != null) { - intent.putExtra(PayFormActivity.EXTRA_THREE_DS, ThreeDsBundlePacker().pack(threeDsData)) + intent.putExtra(TAcqIntentExtra.EXTRA_THREE_DS, ThreeDsBundlePacker().pack(threeDsData)) } } return this diff --git a/sample/src/main/java/ru/tinkoff/acquiring/sample/ui/MainActivity.java b/sample/src/main/java/ru/tinkoff/acquiring/sample/ui/MainActivity.java index 3c048ea..6acb6c9 100644 --- a/sample/src/main/java/ru/tinkoff/acquiring/sample/ui/MainActivity.java +++ b/sample/src/main/java/ru/tinkoff/acquiring/sample/ui/MainActivity.java @@ -83,7 +83,7 @@ public boolean onOptionsItemSelected(MenuItem item) { .prepare(params.customerKey, settings.getCheckType(), settings.isCustomKeyboardEnabled(), params.customerEmail) .setTheme(settings.resolveAttachCardStyle()) .setCameraCardScanner(settings.getCameraScanner()) - .setDesignConfiguration(AttachCellType.ATTACH_BUTTON, AttachCellType.SECURE_LOGOS, AttachCellType.PAYMENT_CARD_REQUISITES) +// .setDesignConfiguration(AttachCellType.ATTACH_BUTTON, AttachCellType.SECURE_LOGOS, AttachCellType.PAYMENT_CARD_REQUISITES) .startActivityForResult(this, ATTACH_CARD_REQUEST_CODE); return true; case R.id.menu_action_about: diff --git a/sample/src/main/java/ru/tinkoff/acquiring/sample/ui/PayableActivity.java b/sample/src/main/java/ru/tinkoff/acquiring/sample/ui/PayableActivity.java index 9db4079..99bd708 100644 --- a/sample/src/main/java/ru/tinkoff/acquiring/sample/ui/PayableActivity.java +++ b/sample/src/main/java/ru/tinkoff/acquiring/sample/ui/PayableActivity.java @@ -137,7 +137,7 @@ protected void initPayment(final Money amount, //.setReceipt(createReceipt()) //.setData(createData()) .setTheme(settings.resolveStyle()) - .setDesignConfiguration(PayCellType.PAYMENT_CARD_REQUISITES, PayCellType.PAY_BUTTON, PayCellType.SECURE_LOGOS) +// .setDesignConfiguration(PayCellType.PAYMENT_CARD_REQUISITES, PayCellType.PAY_BUTTON, PayCellType.SECURE_LOGOS) .setGooglePayParams(settings.isGooglePayEnabled() ? googlePayParams : null) .startActivityForResult(this, REQUEST_CODE_PAY); } diff --git a/sample/src/main/res/values/style_custom.xml b/sample/src/main/res/values/style_custom.xml index 77bbefa..702c88a 100644 --- a/sample/src/main/res/values/style_custom.xml +++ b/sample/src/main/res/values/style_custom.xml @@ -15,14 +15,10 @@ @style/AcquiringPayEmailStyle.Custom overFields iconsUnderFieldsButtonOnBottom - @string/acq_screen_title_custom - @string/acq_pay_with_amount_custom - @string/acq_money_amount_format_custom @style/AcquiringKeyboardStyle.Custom @@ -56,14 +53,10 @@ @@ -91,11 +92,11 @@