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

Update positioning of progress view in CardNumberTextInputLayout #3257

Merged
merged 1 commit into from
Jan 13, 2021
Merged
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
2 changes: 1 addition & 1 deletion stripe/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -75,6 +75,6 @@
<!-- Avoid collisions with CTA button -->
<dimen name="stripe_paymentsheet_form_bottom_margin">84dp</dimen>

<dimen name="stripe_card_number_text_input_layout_progress_start_margin">25dp</dimen>
<dimen name="stripe_card_number_text_input_layout_progress_end_margin">14dp</dimen>
<dimen name="stripe_card_number_text_input_layout_progress_top_margin">10dp</dimen>
</resources>
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import android.util.AttributeSet
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.core.view.children
import androidx.core.view.doOnNextLayout
import androidx.core.view.updateLayoutParams
import com.google.android.material.textfield.TextInputLayout
import com.stripe.android.R
@@ -32,20 +33,26 @@ internal class CardNumberTextInputLayout @JvmOverloads constructor(
}
}

override fun onAttachedToWindow() {
super.onAttachedToWindow()
init {
doOnNextLayout {
attachProgressView()
}
}

private fun attachProgressView() {
// remove parent from the progress view if already attached earlier
(progressView.parent as? ViewGroup)?.removeView(progressView)

// add the progress view to the `TextInputLayout`'s `FrameLayout` container
(children.first() as FrameLayout).addView(progressView)
val progressViewParent = children.first() as FrameLayout
progressViewParent.addView(progressView)

// absolutely position the progress view over the brand icon
progressView.updateLayoutParams<FrameLayout.LayoutParams> {
marginStart = resources.getDimensionPixelSize(
R.dimen.stripe_card_number_text_input_layout_progress_start_margin
)
marginStart = progressViewParent.width -
resources.getDimensionPixelSize(
R.dimen.stripe_card_number_text_input_layout_progress_end_margin
)
topMargin = resources.getDimensionPixelSize(
R.dimen.stripe_card_number_text_input_layout_progress_top_margin
)
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ import android.view.View
import android.view.animation.Animation
import android.view.animation.AnimationUtils
import android.widget.FrameLayout
import androidx.core.view.isInvisible
import androidx.core.view.updateLayoutParams
import com.stripe.android.R
import com.stripe.android.databinding.CardWidgetProgressViewBinding
@@ -63,7 +64,7 @@ internal class CardWidgetProgressView @JvmOverloads constructor(

setBackgroundResource(R.drawable.stripe_card_progress_background)
clipToOutline = true
visibility = View.INVISIBLE
isInvisible = true
}

override fun onAttachedToWindow() {