Skip to content

Commit

Permalink
3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
adyen-git-manager committed Sep 11, 2019
1 parent 89119d6 commit 88f29b7
Show file tree
Hide file tree
Showing 112 changed files with 2,580 additions and 1,465 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Rules to ignore by klint
[*.{kt,kts}]
disabled_rules=no-wildcard-imports,import-ordering
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@
[//]: <> (Add changes that not released yet into `Unreleased` section)
[//]: <> (Comment `Unreleased` section if there are no changes)
[//]: <> (## [Unreleased])
## [3.3.0] - 2019-09-11
### Added
- Created SepaComponent
- Created Card Component view specifically for DropIn to have more space to show supported card types in screen.
- DropIn will try to parse and use card brands from payment method response if there were no SupportedCard type in CardConfiguration
### Changed
- Component `observe()` will now notify the observer every time the user changes the input even though content and validation might not have changed.
- Refactored validation structure for fields
- CardType class moved from package `com.adyen.checkout.card.model` to package `com.adyen.checkout.card.data`
- CardType's regex updated
### Fixed
- Issue with image sometimes not loading
- Catching unexpected exception on Card encryption.

## [3.2.1] - 2019-08-29
### Added
- Created Settings screen on Example app to facilitate testing instead of hard coding values.
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ The Components are available through [jcenter][dl], you only need to add the Gra
Import the Component module for the Payment Method you want to use by adding it to your `build.gradle` file.
For example, for the Drop-in solution you should add:
```groovy
implementation "com.adyen.checkout:drop-in:3.2.1"
implementation "com.adyen.checkout:drop-in:3.3.0"
```
For a Credit Card component you should add:
```groovy
implementation "com.adyen.checkout:card-ui:3.2.1"
implementation "com.adyen.checkout:card-ui:3.3.0"
```
For and iDeal component you should add:
```groovy
implementation "com.adyen.checkout:ideal-ui:3.2.1"
implementation "com.adyen.checkout:ideal-ui:3.3.0"
```

## Drop-in
Expand Down Expand Up @@ -139,6 +139,7 @@ Please let us know if you find any issues.

```
-keep class com.adyen.checkout.base.model.** { *; }
-keep class com.adyen.threeds2.** { *; }
-keepclassmembers public class * implements com.adyen.checkout.base.PaymentComponent {
public <init>(...);
}
Expand Down
1 change: 1 addition & 0 deletions README_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ Please let us know if you find any issues.

```
-keep class com.adyen.checkout.base.model.** { *; }
-keep class com.adyen.threeds2.** { *; }
-keepclassmembers public class * implements com.adyen.checkout.base.PaymentComponent {
public <init>(...);
}
Expand Down
3 changes: 2 additions & 1 deletion RELEASE_NOTES
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<ul>
<li>Bug fixes</li>
<li>Added SEPA payment method</li>
<li>Bug Fixes</li>
</ul>
1 change: 1 addition & 0 deletions base-ui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dependencies {
// Dependencies
implementation "com.android.support:appcompat-v7:$version_support_library"
implementation "com.android.support:recyclerview-v7:$version_support_library"
implementation "com.android.support:design:$version_support_library"
}

// This sharedTasks.gradle script is applied at the end of this build.gradle script,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,25 @@
*
* This file is open source and available under the MIT license. See the LICENSE file for more info.
*
* Created by arman on 22/7/2019.
* Created by caiof on 26/8/2019.
*/

package com.adyen.checkout.card.ui;
package com.adyen.checkout.base.ui.view;

import android.content.Context;
import android.support.annotation.CallSuper;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.TextInputEditText;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextWatcher;
import android.util.AttributeSet;

public class AdyenTextInputEditText extends TextInputEditText {

protected static final int NO_MAX_LENGTH = -1;

@Nullable
private Listener mListener;

Expand All @@ -44,7 +47,7 @@ public void setOnChangeListener(@NonNull Listener listener) {

@NonNull
public String getRawValue() {
return getText().toString();
return getText() != null ? getText().toString() : "";
}

@CallSuper
Expand All @@ -54,6 +57,12 @@ protected void afterTextChanged(@NonNull Editable editable) {
}
}

protected void enforceMaxInputLength(int maxLength) {
if (maxLength != NO_MAX_LENGTH) {
setFilters(new InputFilter[]{new InputFilter.LengthFilter(maxLength)});
}
}

@NonNull
private TextWatcher getTextWatcher() {
return new TextWatcher() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

public class RoundCornerImageView extends AppCompatImageView {

private static final float DEFAULT_RADIUS = 9.0f;
private static final float DEFAULT_STROKE_WIDTH = 4f;
private static final int DEFAULT_STROKE_COLOR = Color.BLACK;
public static final float DEFAULT_RADIUS = 9.0f;
public static final int DEFAULT_STROKE_COLOR = Color.BLACK;
public static final float DEFAULT_STROKE_WIDTH = 4f;

private float mRadius;
private final Paint mStrokePaint = new Paint();
Expand Down Expand Up @@ -93,12 +93,14 @@ protected void onDraw(@NonNull Canvas canvas) {

mStrokePaint.reset();

mStrokePaint.setStyle(Paint.Style.STROKE);
mStrokePaint.setAntiAlias(true);
mStrokePaint.setColor(mStrokeColor);
mStrokePaint.setStrokeWidth(mStrokeWidth);
if (mStrokeWidth > 0) {
mStrokePaint.setStyle(Paint.Style.STROKE);
mStrokePaint.setAntiAlias(true);
mStrokePaint.setColor(mStrokeColor);
mStrokePaint.setStrokeWidth(mStrokeWidth);

canvas.drawRoundRect(rect, mRadius, mRadius, mStrokePaint);
canvas.drawRoundRect(rect, mRadius, mRadius, mStrokePaint);
}

final Path path = new Path();
path.addRoundRect(rect, mRadius, mRadius, Path.Direction.CW);
Expand Down
2 changes: 2 additions & 0 deletions base-ui/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@
<dimen name="logo_width">40dp</dimen>
<dimen name="logo_height">26dp</dimen>

<dimen name="input_height">55dp</dimen>

</resources>
10 changes: 10 additions & 0 deletions base-ui/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,14 @@
<item name="windowActionBar">false</item>
</style>

<style name="AdyenCheckout.HintTextStyle" parent="TextAppearance.AppCompat">
<item name="android:textColor">@color/primaryColor</item>
</style>

<style name="AdyenCheckout.TextInputLayout" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox">
<item name="boxStrokeColor">@color/primaryColor</item>
<item name="hintTextAppearance">@style/AdyenCheckout.HintTextStyle</item>
<item name="android:minHeight">90dp</item>
</style>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ public void load(@NonNull String txVariant, @NonNull String txSubVariant, @NonNu
final String id = txVariant + txSubVariant + view.getId();

if (mCallbacks.containsKey(id)) {
mLogoApi.cancelLogoRequest(txVariant, null, null);

mCallbacks.remove(id);
mImageViews.remove(id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import com.adyen.checkout.base.PaymentComponentState;
import com.adyen.checkout.base.analytics.AnalyticEvent;
import com.adyen.checkout.base.analytics.AnalyticsDispatcher;
import com.adyen.checkout.base.component.data.input.InputData;
import com.adyen.checkout.base.component.data.output.OutputData;
import com.adyen.checkout.base.component.lifecycle.PaymentComponentViewModel;
import com.adyen.checkout.base.model.paymentmethods.PaymentMethod;
import com.adyen.checkout.core.api.ThreadManager;
Expand Down Expand Up @@ -59,12 +57,28 @@ public abstract class BasePaymentComponent<ConfigurationT extends Configuration,
public BasePaymentComponent(@NonNull PaymentMethod paymentMethod, @NonNull ConfigurationT configuration) {
super(paymentMethod, configuration);
assertSupported(paymentMethod);
mOutputData = createOutputData(paymentMethod);
mOutputData = createEmptyOutputData();
mOutputLiveData.setValue(mOutputData);
}

@Override
public void observe(@NonNull LifecycleOwner lifecycleOwner, @NonNull Observer<PaymentComponentState> observer) {
mPaymentComponentStateLiveData.observe(lifecycleOwner, observer);
}

@Override
public void observeErrors(@NonNull LifecycleOwner lifecycleOwner, @NonNull Observer<ComponentError> observer) {
mComponentErrorLiveData.observe(lifecycleOwner, observer);
}

@Override
@Nullable
public PaymentComponentState getState() {
return mPaymentComponentStateLiveData.getValue();
}

/**
* Receives a net set of {@link InputData} from the user to be processed.
* Receives a set of {@link InputData} from the user to be processed.
*
* @param inputData {@link InputDataT}
*/
Expand All @@ -77,45 +91,55 @@ public final void inputDataChanged(@NonNull InputDataT inputData) {
}
}

@NonNull
protected OutputDataT getOutputData() {
return mOutputData;
/**
* Sets if the analytics events can be sent by the component.
* Default is True.
*
* @param isEnabled Is analytics should be enabled or not.
*/
public void setAnalyticsEnabled(boolean isEnabled) {
mIsAnalyticsEnabled = isEnabled;
}

@NonNull
protected abstract OutputDataT onInputDataChanged(@NonNull InputDataT inputData);
/**
* Send an analytic event about the Component being shown to the user.
*
* @param context The context where the component is.
*/
public void sendAnalyticsEvent(@NonNull Context context) {
if (mIsAnalyticsEnabled) {
final AnalyticEvent.Flavor flavor;
if (mIsCreatedForDropIn) {
flavor = AnalyticEvent.Flavor.DROPIN;
} else {
flavor = AnalyticEvent.Flavor.COMPONENT;
}

private void notifyStateChanged() {
final PaymentComponentState currentValue = mPaymentComponentStateLiveData.getValue();
final boolean wasValid = currentValue != null && currentValue.isValid();
// if last value was valid and new output data become invalid we need to notify observer
// in any other cases we notify observer when output data is valid.
final boolean shouldNotify = mOutputData.isValid() || mOutputData.isValid() != wasValid;
if (shouldNotify) {
ThreadManager.EXECUTOR.submit(new Runnable() {
@Override
public void run() {
mPaymentComponentStateLiveData.postValue(createComponentState());
}
});
final AnalyticEvent analyticEvent = AnalyticEvent.create(context, flavor, getPaymentMethodType(), getConfiguration().getShopperLocale());
AnalyticsDispatcher.dispatchEvent(context, getConfiguration().getEnvironment(), analyticEvent);
}
}

@Override
@Nullable
public PaymentComponentState getState() {
return mPaymentComponentStateLiveData.getValue();
@NonNull
protected OutputDataT getOutputData() {
return mOutputData;
}

@Override
public void observe(@NonNull LifecycleOwner lifecycleOwner, @NonNull Observer<PaymentComponentState> observer) {
mPaymentComponentStateLiveData.observe(lifecycleOwner, observer);
}
/**
* Called every time the {@link InputData} changes.
*
* @param inputData The new InputData
* @return The OutputData after processing.
*/
@NonNull
protected abstract OutputDataT onInputDataChanged(@NonNull InputDataT inputData);

@Override
public void observeErrors(@NonNull LifecycleOwner lifecycleOwner, @NonNull Observer<ComponentError> observer) {
mComponentErrorLiveData.observe(lifecycleOwner, observer);
}
@NonNull
protected abstract OutputDataT createEmptyOutputData();

@NonNull
@WorkerThread
protected abstract PaymentComponentState createComponentState();

protected void notifyException(@NonNull CheckoutException e) {
Logger.e(TAG, "notifyException - " + e.getMessage());
Expand All @@ -128,13 +152,14 @@ protected void observeOutputData(@NonNull LifecycleOwner lifecycleOwner, @NonNul
mOutputLiveData.observe(lifecycleOwner, observer);
}

@NonNull
protected abstract OutputDataT createOutputData(@NonNull PaymentMethod paymentMethod);


@NonNull
@WorkerThread
protected abstract PaymentComponentState createComponentState();
private void notifyStateChanged() {
ThreadManager.EXECUTOR.submit(new Runnable() {
@Override
public void run() {
mPaymentComponentStateLiveData.postValue(createComponentState());
}
});
}

private void assertSupported(@NonNull PaymentMethod paymentMethod) {
if (!isSupported(paymentMethod)) {
Expand All @@ -149,33 +174,4 @@ private boolean isSupported(@NonNull PaymentMethod paymentMethod) {
public void setCreatedForDropIn() {
mIsCreatedForDropIn = true;
}

/**
* Sets if the analytics events can be sent by the component.
* Default is True.
*
* @param isEnabled Is analytics should be enabled or not.
*/
public void setAnalyticsEnabled(boolean isEnabled) {
mIsAnalyticsEnabled = isEnabled;
}

/**
* Send an analytic event about the Component being shown to the user.
*
* @param context The context where the component is.
*/
public void sendAnalyticsEvent(@NonNull Context context) {
if (mIsAnalyticsEnabled) {
final AnalyticEvent.Flavor flavor;
if (mIsCreatedForDropIn) {
flavor = AnalyticEvent.Flavor.DROPIN;
} else {
flavor = AnalyticEvent.Flavor.COMPONENT;
}

final AnalyticEvent analyticEvent = AnalyticEvent.create(context, flavor, getPaymentMethodType(), getConfiguration().getShopperLocale());
AnalyticsDispatcher.dispatchEvent(context, getConfiguration().getEnvironment(), analyticEvent);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
*
* This file is open source and available under the MIT license. See the LICENSE file for more info.
*
* Created by ran on 18/3/2019.
* Created by caiof on 30/8/2019.
*/

package com.adyen.checkout.base.component.data.input;
package com.adyen.checkout.base.component;


public interface InputData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
*
* This file is open source and available under the MIT license. See the LICENSE file for more info.
*
* Created by ran on 19/3/2019.
* Created by caiof on 30/8/2019.
*/

package com.adyen.checkout.base.component.data.output;
package com.adyen.checkout.base.component;

public interface OutputData {
// Marker interface.
Expand Down
Loading

0 comments on commit 88f29b7

Please sign in to comment.