Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an issue where the primary button got extra wide on configuration changes. #6326

Merged
merged 4 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## XX.XX.XX - 2023-XX-XX

### PaymentSheet
* [FIXED][6326](https://github.com/stripe/stripe-android/pull/6326) Fixed an issue where the primary button would lose its padding on configuration changes.

## 20.19.5 - 2023-03-06

### Payments
Expand Down
2 changes: 1 addition & 1 deletion paymentsheet/api/paymentsheet.api
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ public final class com/stripe/android/paymentsheet/databinding/FragmentPrimaryBu
public final field primaryButton Lcom/stripe/android/paymentsheet/ui/PrimaryButton;
public static fun bind (Landroid/view/View;)Lcom/stripe/android/paymentsheet/databinding/FragmentPrimaryButtonContainerBinding;
public synthetic fun getRoot ()Landroid/view/View;
public fun getRoot ()Lcom/stripe/android/paymentsheet/ui/PrimaryButton;
public fun getRoot ()Landroid/widget/FrameLayout;
public static fun inflate (Landroid/view/LayoutInflater;)Lcom/stripe/android/paymentsheet/databinding/FragmentPrimaryButtonContainerBinding;
public static fun inflate (Landroid/view/LayoutInflater;Landroid/view/ViewGroup;Z)Lcom/stripe/android/paymentsheet/databinding/FragmentPrimaryButtonContainerBinding;
}
Expand Down
22 changes: 14 additions & 8 deletions paymentsheet/res/layout/fragment_primary_button_container.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<com.stripe.android.paymentsheet.ui.PrimaryButton xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/primary_button"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/stripe_paymentsheet_primary_button_height"
android:layout_marginTop="@dimen/stripe_paymentsheet_button_container_spacing"
android:layout_marginStart="@dimen/stripe_paymentsheet_outer_spacing_horizontal"
android:layout_marginEnd="@dimen/stripe_paymentsheet_outer_spacing_horizontal"
android:text="@string/stripe_paymentsheet_pay_button_label"
android:visibility="gone" />
android:layout_height="wrap_content">
<!-- Needs to be wrapped in a FrameLayout to prevent layout issues after configuration changes. -->
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess is it's a compose bug. But I didn't look to far into it since the mitigation was low cost.

I've run into this before, which is why I suspected this and fixed it here. The layout inflator isn't taking into account the root view (from this XML file) layout params into account when inflating the view. An easy way around that is to not have any layout params in the root view, but keep them in the nested view, which is what I did here.


<com.stripe.android.paymentsheet.ui.PrimaryButton
android:id="@+id/primary_button"
android:layout_width="match_parent"
android:layout_height="@dimen/stripe_paymentsheet_primary_button_height"
android:layout_marginTop="@dimen/stripe_paymentsheet_button_container_spacing"
android:layout_marginStart="@dimen/stripe_paymentsheet_outer_spacing_horizontal"
android:layout_marginEnd="@dimen/stripe_paymentsheet_outer_spacing_horizontal"
android:text="@string/stripe_paymentsheet_pay_button_label"
android:visibility="gone" />
</FrameLayout>