-
Notifications
You must be signed in to change notification settings - Fork 658
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
Card-scanning in PaymentSheet #4804
Merged
Merged
Changes from all commits
Commits
Show all changes
153 commits
Select commit
Hold shift + click to select a range
c5ef5ec
[WIP]
michelleb-stripe 0c95106
Display and receive input for Credit Card number and CVC.
michelleb-stripe 75e54d1
Add in the credit billing fields, need hidden visibility to work on a…
michelleb-stripe cd4ff51
Merge with master.
michelleb-stripe da41eb0
Billing code now shows the correct fields.
michelleb-stripe a9a04ac
Billing now added to the credit element.
michelleb-stripe 2ceac10
Credit card number length verification corrected.
michelleb-stripe e35e2c7
Refactor Elements so each element (including sections) provide the fo…
michelleb-stripe f897f12
Add in the expiration date functionality.
michelleb-stripe 53661e1
Merge branch 'master' into michelleb/credit-card-compose
michelleb-stripe 4f20fb2
Refactor so that each element returns a flow of FormFieldEntries, so …
michelleb-stripe 940f304
Fix unit test
michelleb-stripe e8fc0ff
Merge with master.
michelleb-stripe 7e5ee6a
Rename class
michelleb-stripe c3d7b28
More rework
michelleb-stripe a61ea99
Merge with michelleb/refactor-section-form-fields
michelleb-stripe b3be29c
Get ready for merge with master
michelleb-stripe 9a258ec
Merge with master.
michelleb-stripe 57b617c
Merge with master
michelleb-stripe 3e60136
Merge with master.
michelleb-stripe 4d8ec20
Change from liveData to flow.
michelleb-stripe 591a73e
Merge branch 'michelleb/convert-to-flow' into michelleb/credit-card-c…
michelleb-stripe 2aeb3ef
Row is working but not expiry date
michelleb-stripe 9161d4f
Make the keypad just numbers.
michelleb-stripe 0441d0a
Make the keypad just numbers.
michelleb-stripe c41ec5d
Set the expiration month and date correctly in the formFieldValues
michelleb-stripe fdad41f
Update the focus to visit the CVC
michelleb-stripe 43c9127
Handle a full text field state.
michelleb-stripe 317a841
Merge with master
michelleb-stripe 8e649c8
Unit tests
michelleb-stripe 9ead541
ktlintFormat
michelleb-stripe 939dba9
Format card number based on max pan for card number
michelleb-stripe 60da73f
Cleanup date util for expiration month
michelleb-stripe f51f90b
Make the label flowable
michelleb-stripe fef63b3
Fix internals
michelleb-stripe f19cbe2
Cleanup
michelleb-stripe 07cfa62
Cleanup
michelleb-stripe bd5d754
Merge with master
michelleb-stripe 2722977
Fix unit tests
michelleb-stripe 4bee0c1
ktlintFormat
michelleb-stripe 4b78747
Undos
michelleb-stripe 9242d80
ktlintFormat
michelleb-stripe b1cd5b0
Merge with master
michelleb-stripe 239273d
Merge remote-tracking branch 'origin/master' into michelleb/credit-ca…
michelleb-stripe 8eb4204
Merge with master
michelleb-stripe 40fe6c0
Merge with master
michelleb-stripe adaed05
Ignore tests that cause other failures
michelleb-stripe 667bd39
Merge branch 'master' into michelleb/credit-card-compose
michelleb-stripe 7c5e474
Working on the merge.
michelleb-stripe 1eee681
Almost building
michelleb-stripe 7ed49f3
Get closer to master
michelleb-stripe e68a86a
Update files.
michelleb-stripe f0fa03a
Iterating
michelleb-stripe 5ad3f10
Building
michelleb-stripe a3c9eae
Fix unit tests
michelleb-stripe e2f39c4
Cleanup
michelleb-stripe 57677d8
Remove extra comment
michelleb-stripe 6bee0a4
Fix failing tests
epan-stripe 2c6e45c
Fix linting
epan-stripe 8b5d2ae
Fix SaveForFutureUseController.label not showing
epan-stripe 313f52a
Merge with master
michelleb-stripe c1e78f7
Cleanup
michelleb-stripe 6c9cb94
apiDump
michelleb-stripe 508b5ad
Merge with master
michelleb-stripe 33b754a
apiDump
michelleb-stripe 7819db6
Fix some failing tests, apiDump, ktlintFormat
michelleb-stripe b3917f9
Fix remaining failing tests, apiDump, ktlintFormat
michelleb-stripe 95d8557
Fix todo
michelleb-stripe 7af4ff5
Merge remote-tracking branch 'origin/master' into michelleb/credit-ca…
michelleb-stripe afd06c9
Simplify and add DateConfig tests and cleanup commented out code in T…
michelleb-stripe 98043bd
Merge with master
michelleb-stripe 8ca28d2
Merge remote-tracking branch 'origin/master' into michelleb/credit-ca…
michelleb-stripe 9bf81f2
ktlintFormat apiDump
michelleb-stripe 783039a
Merge with master
michelleb-stripe bf51053
Add icons to the IBAN, credit card and CVC fields. (#4359)
michelleb-stripe 7979d18
Merge with master
michelleb-stripe bd3fb81
Merge with remote
michelleb-stripe a18c6c2
Add Card Metadata Service to CardNumberController (#4573)
epan-stripe b4cacba
Don't show cardbrand if there are multiple possibilities
epan-stripe 06c5d00
Don't show cardbrand if there are multiple possibilities
epan-stripe c179b73
Merge branch 'michelleb/credit-card-compose' of github.com:stripe/str…
epan-stripe 61200f9
Merge remote-tracking branch 'origin/master' into michelleb/credit-ca…
michelleb-stripe 110ecd3
Merge with master
michelleb-stripe 067ea3b
Material Theme information gathering.
michelleb-stripe 36913d3
Revert "Material Theme information gathering."
michelleb-stripe 167b00f
Immediately detect invalid card numbers (no brand)
epan-stripe 8701f44
Fix invalid vs incomplete dateconfig error text
epan-stripe b6fff48
Fix CVC icon and next field focus
epan-stripe 3ed0104
Fix expiry date accessibility reader
epan-stripe 7f3d2f2
Merge branch 'master' into michelleb/credit-card-compose
epan-stripe d92df95
Fix merge issues
epan-stripe e2880f4
Add ability to move focus on delete
jameswoo-stripe 81042c0
Merge remote-tracking branch 'origin/master' into michelleb/credit-ca…
michelleb-stripe 219e999
Fix dark mode error underline
epan-stripe 126de9a
Fix cursor and spacing position in card details
epan-stripe 10f4f47
update icons and colors for future wardrobe work
skyler-stripe da16b49
Merge branch 'master' into michelleb/credit-card-compose
michelleb-stripe 0d7f077
Merge branch 'michelleb/credit-card-compose' of github.com:stripe/str…
michelleb-stripe ba21e4a
Add card information title
epan-stripe 0c87580
Add tests for card number formatting
epan-stripe 7a60b61
Revert "Add tests for card number formatting"
epan-stripe d2ff7ba
Add country list to card and sepa billing spec. (#4669)
michelleb-stripe 55a143b
Credit Card Address and focus bug fixes (#4665)
michelleb-stripe f111ac0
Fix width of rows (#4676)
epan-stripe f3d960b
Fix spacing for AMEX and Discover cards (#4672)
epan-stripe f8c7ec7
Don't show CVC error when CardBrand is unknown (#4681)
epan-stripe 5fbad06
Stop accessibility talkback reading textfields twice (#4683)
epan-stripe c6363f2
Merge with master
michelleb-stripe c5c70e5
Merge branch 'michelleb/credit-card-compose' of github.com:stripe/str…
michelleb-stripe 2ba55b8
ktformat
michelleb-stripe 6fb7a3f
Fix detekt
michelleb-stripe b9095ff
checkbox colors read from theme object now
skyler-stripe 74e4e3d
Initial implementation
epan-stripe 3fe4155
Fix camera icon
epan-stripe f57c34c
Move design changes to different branch
epan-stripe c8b3779
Update camera icon design
epan-stripe ecdeafc
Add string resource for scan card text and remove "test" name
epan-stripe 091965a
Use actual publishable key
epan-stripe 13b81ab
Add removeCardScanFragment to StripeCardScanProxy
epan-stripe 466d186
Restart fragment onResume and onPause
epan-stripe e768bc8
Restart fragment onResume and onPause
epan-stripe e2c7f3b
Merge branch 'elena/cardscanning' of github.com:stripe/stripe-android…
epan-stripe 5d9abea
Merge branch 'master' of github.com:stripe/stripe-android into elena/…
epan-stripe 3184ef0
Merge branch 'master' of github.com:stripe/stripe-android into elena/…
epan-stripe fabd5df
Merge branch 'elena/cardscanning' of github.com:stripe/stripe-android…
epan-stripe 4c69279
Update to match CardScanSheet changes
epan-stripe da2f828
Fix scan card button styling
epan-stripe c973df5
Fix scan card button styling
epan-stripe 51ed547
Merge branch 'elena/cardscanning' of github.com:stripe/stripe-android…
epan-stripe f8d4d13
Update CHANGELOG
epan-stripe accd9e8
Move CARD_SCAN_PARCELABLE_NAME to companion object
epan-stripe 0b9ada6
Stop passing context in and delete CardDetailsSpec
epan-stripe fc0d5cf
Make CardScanActivity internal
epan-stripe 40242b5
Make code segment more functional
epan-stripe 2cb02da
Fix comment
epan-stripe c329abb
Add tests for StripeCardScanProxy
epan-stripe 33cca0b
Fix tests
epan-stripe 4c3c836
Fix tests
epan-stripe e34a80e
Merge branch 'elena/cardscanning' of github.com:stripe/stripe-android…
epan-stripe 4ea2f2d
Stop setting Scan card button font weight
epan-stripe 5c75cfa
Merge branch 'master' into elena/cardscanning
epan-stripe c9a9a54
Merge branch 'master' of github.com:stripe/stripe-android into elena/…
epan-stripe 9fb81f7
Add context back to TransformSpecToElements
epan-stripe abfbea4
Add CardDetailsSectionController so credit card form values are passe…
epan-stripe 9404f8d
Merge branch 'master' into elena/cardscanning
epan-stripe 194c96b
Update CardScanActivity package
epan-stripe 42daf14
Remove context from FormUI
epan-stripe a1772de
Add clarifying comment
epan-stripe 8a21c3f
Remove unnecessary padding
epan-stripe 88ede33
Create ScanCardButtonUI composable
epan-stripe 6304213
Merge branch 'master' of github.com:stripe/stripe-android into elena/…
epan-stripe 1d305cb
Move isStripeCardScan object to controller instead of Composable
epan-stripe cff7e81
Use material camera icon
epan-stripe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24" | ||
android:viewportHeight="24" | ||
android:tint="?attr/colorControlNormal"> | ||
<path | ||
android:fillColor="@android:color/black" | ||
android:pathData="M12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0"/> | ||
<path | ||
android:fillColor="@android:color/black" | ||
android:pathData="M9,2L7.17,4L4,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2h-3.17L15,2L9,2zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z"/> | ||
</vector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<androidx.constraintlayout.widget.ConstraintLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<androidx.fragment.app.FragmentContainerView | ||
android:id="@+id/fragment_container" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:layout_constraintBottom_toBottomOf="parent"/> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
payments-ui-core/src/main/java/com/stripe/android/ui/core/IsStripeCardScanAvailable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.stripe.android.ui.core | ||
skyler-stripe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
internal interface IsStripeCardScanAvailable { | ||
operator fun invoke(): Boolean | ||
} | ||
|
||
internal class DefaultIsStripeCardScanAvailable : IsStripeCardScanAvailable { | ||
override fun invoke(): Boolean { | ||
return try { | ||
Class.forName("com.stripe.android.stripecardscan.cardscan.CardScanSheet") | ||
true | ||
} catch (_: Exception) { | ||
false | ||
} | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
payments-ui-core/src/main/java/com/stripe/android/ui/core/StripeCardScanProxy.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package com.stripe.android.ui.core | ||
|
||
import androidx.annotation.IdRes | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.fragment.app.Fragment | ||
import androidx.fragment.app.FragmentManager | ||
import androidx.lifecycle.LifecycleOwner | ||
import com.stripe.android.BuildConfig | ||
import com.stripe.android.stripecardscan.cardscan.CardScanSheet | ||
import com.stripe.android.stripecardscan.cardscan.CardScanSheetResult | ||
|
||
/** | ||
* Proxy to access stripecardscan code safely | ||
epan-stripe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* | ||
*/ | ||
internal interface StripeCardScanProxy { | ||
fun present() | ||
|
||
fun attachCardScanFragment( | ||
lifecycleOwner: LifecycleOwner, | ||
supportFragmentManager: FragmentManager, | ||
@IdRes fragmentContainer: Int, | ||
onFinished: (cardScanSheetResult: CardScanSheetResult) -> Unit | ||
) | ||
|
||
companion object { | ||
fun create( | ||
fragment: Fragment, | ||
stripePublishableKey: String, | ||
onFinished: (cardScanSheetResult: CardScanSheetResult) -> Unit, | ||
provider: () -> StripeCardScanProxy = { | ||
DefaultStripeCardScanProxy(CardScanSheet.create(fragment, stripePublishableKey, onFinished)) | ||
}, | ||
isStripeCardScanAvailable: IsStripeCardScanAvailable = DefaultIsStripeCardScanAvailable() | ||
): StripeCardScanProxy { | ||
return if (isStripeCardScanAvailable()) { | ||
provider() | ||
} else { | ||
UnsupportedStripeCardScanProxy() | ||
} | ||
} | ||
|
||
fun create( | ||
activity: AppCompatActivity, | ||
epan-stripe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
stripePublishableKey: String, | ||
onFinished: (cardScanSheetResult: CardScanSheetResult) -> Unit, | ||
provider: () -> StripeCardScanProxy = { | ||
DefaultStripeCardScanProxy(CardScanSheet.create(activity, stripePublishableKey, onFinished)) | ||
}, | ||
isStripeCardScanAvailable: IsStripeCardScanAvailable = DefaultIsStripeCardScanAvailable() | ||
): StripeCardScanProxy { | ||
return if (isStripeCardScanAvailable()) { | ||
provider() | ||
} else { | ||
UnsupportedStripeCardScanProxy() | ||
} | ||
} | ||
|
||
fun removeCardScanFragment( | ||
supportFragmentManager: FragmentManager, | ||
isStripeCardScanAvailable: IsStripeCardScanAvailable = DefaultIsStripeCardScanAvailable() | ||
) { | ||
if (isStripeCardScanAvailable()) { | ||
CardScanSheet.removeCardScanFragment(supportFragmentManager) | ||
} | ||
} | ||
} | ||
} | ||
|
||
internal class DefaultStripeCardScanProxy( | ||
private val cardScanSheet: CardScanSheet | ||
) : StripeCardScanProxy { | ||
override fun present() { | ||
cardScanSheet.present() | ||
} | ||
|
||
override fun attachCardScanFragment( | ||
lifecycleOwner: LifecycleOwner, | ||
supportFragmentManager: FragmentManager, | ||
fragmentContainer: Int, | ||
onFinished: (cardScanSheetResult: CardScanSheetResult) -> Unit | ||
) { | ||
cardScanSheet.attachCardScanFragment(lifecycleOwner, supportFragmentManager, fragmentContainer, onFinished) | ||
} | ||
} | ||
|
||
internal class UnsupportedStripeCardScanProxy : StripeCardScanProxy { | ||
override fun present() { | ||
if (BuildConfig.DEBUG) { | ||
throw IllegalStateException( | ||
"Missing stripecardscan dependency, please add it to your apps build.gradle" | ||
epan-stripe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
} | ||
} | ||
|
||
override fun attachCardScanFragment( | ||
lifecycleOwner: LifecycleOwner, | ||
supportFragmentManager: FragmentManager, | ||
fragmentContainer: Int, | ||
onFinished: (cardScanSheetResult: CardScanSheetResult) -> Unit | ||
) { | ||
if (BuildConfig.DEBUG) { | ||
throw IllegalStateException( | ||
"Missing stripecardscan dependency, please add it to your apps build.gradle" | ||
) | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
payments-ui-core/src/main/java/com/stripe/android/ui/core/cardscan/CardScanActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.stripe.android.ui.core.cardscan | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.stripe.android.PaymentConfiguration | ||
import com.stripe.android.stripecardscan.cardscan.CardScanSheetResult | ||
import com.stripe.android.ui.core.R | ||
import com.stripe.android.ui.core.StripeCardScanProxy | ||
import com.stripe.android.ui.core.databinding.ActivityCardScanBinding | ||
|
||
internal class CardScanActivity : AppCompatActivity() { | ||
epan-stripe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private val viewBinding by lazy { | ||
ActivityCardScanBinding.inflate(layoutInflater) | ||
} | ||
|
||
private lateinit var stripeCardScanProxy: StripeCardScanProxy | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(viewBinding.root) | ||
|
||
stripeCardScanProxy = StripeCardScanProxy.create( | ||
this, PaymentConfiguration.getInstance(this).publishableKey, this::onScanFinished | ||
) | ||
} | ||
|
||
override fun onStart() { | ||
super.onStart() | ||
stripeCardScanProxy.attachCardScanFragment( | ||
this, supportFragmentManager, R.id.fragment_container, this::onScanFinished | ||
) | ||
} | ||
|
||
private fun onScanFinished(result: CardScanSheetResult) { | ||
val intent = Intent() | ||
.putExtra( | ||
CARD_SCAN_PARCELABLE_NAME, | ||
result | ||
) | ||
setResult(RESULT_OK, intent) | ||
finish() | ||
} | ||
|
||
override fun onStop() { | ||
StripeCardScanProxy.removeCardScanFragment(supportFragmentManager) | ||
super.onStop() | ||
} | ||
|
||
companion object { | ||
const val CARD_SCAN_PARCELABLE_NAME = "CardScanActivityResult" | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...ui-core/src/main/java/com/stripe/android/ui/core/elements/CardDetailsSectionController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.stripe.android.ui.core.elements | ||
|
||
import android.content.Context | ||
import com.stripe.android.ui.core.DefaultIsStripeCardScanAvailable | ||
|
||
class CardDetailsSectionController(context: Context) : SectionFieldErrorController { | ||
|
||
internal val cardDetailsElement = CardDetailsElement( | ||
IdentifierSpec.Generic("card_detail"), context | ||
) | ||
|
||
internal val isStripeCardScanAvailable = DefaultIsStripeCardScanAvailable() | ||
|
||
override val error = cardDetailsElement.controller.error | ||
} |
19 changes: 19 additions & 0 deletions
19
...ts-ui-core/src/main/java/com/stripe/android/ui/core/elements/CardDetailsSectionElement.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.stripe.android.ui.core.elements | ||
|
||
import android.content.Context | ||
import androidx.annotation.RestrictTo | ||
import com.stripe.android.ui.core.forms.FormFieldEntry | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) | ||
data class CardDetailsSectionElement( | ||
val context: Context, | ||
override val identifier: IdentifierSpec, | ||
override val controller: CardDetailsSectionController = CardDetailsSectionController(context), | ||
) : FormElement() { | ||
override fun getFormFieldValueFlow(): Flow<List<Pair<IdentifierSpec, FormFieldEntry>>> = | ||
controller.cardDetailsElement.getFormFieldValueFlow() | ||
|
||
override fun getTextFieldIdentifiers(): Flow<List<IdentifierSpec>> = | ||
controller.cardDetailsElement.getTextFieldIdentifiers() | ||
} |
60 changes: 60 additions & 0 deletions
60
...-ui-core/src/main/java/com/stripe/android/ui/core/elements/CardDetailsSectionElementUI.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.stripe.android.ui.core.elements | ||
|
||
import androidx.annotation.RestrictTo | ||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.semantics.heading | ||
import androidx.compose.ui.semantics.semantics | ||
import com.stripe.android.stripecardscan.cardscan.CardScanSheetResult | ||
import com.stripe.android.stripecardscan.cardscan.exception.UnknownScanException | ||
import com.stripe.android.ui.core.R | ||
import com.stripe.android.ui.core.cardscan.CardScanActivity | ||
|
||
@Composable | ||
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) | ||
fun CardDetailsSectionElementUI( | ||
enabled: Boolean, | ||
controller: CardDetailsSectionController, | ||
hiddenIdentifiers: List<IdentifierSpec>? | ||
) { | ||
|
||
Row( | ||
horizontalArrangement = Arrangement.SpaceBetween, | ||
verticalAlignment = Alignment.CenterVertically, | ||
modifier = Modifier | ||
.fillMaxWidth() | ||
) { | ||
H6Text( | ||
text = stringResource(R.string.card_information), | ||
modifier = Modifier | ||
.semantics(mergeDescendants = true) { // Need to prevent form as focusable accessibility | ||
epan-stripe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
heading() | ||
} | ||
) | ||
if (controller.isStripeCardScanAvailable()) { | ||
ScanCardButtonUI { | ||
controller.cardDetailsElement.controller.numberElement.controller.onCardScanResult( | ||
it.getParcelableExtra(CardScanActivity.CARD_SCAN_PARCELABLE_NAME) | ||
?: CardScanSheetResult.Failed( | ||
UnknownScanException("No data in the result intent") | ||
) | ||
) | ||
} | ||
} | ||
} | ||
SectionElementUI( | ||
enabled, | ||
SectionElement( | ||
IdentifierSpec.Generic("credit_details"), | ||
listOf(controller.cardDetailsElement), | ||
SectionController(null, listOf(controller.cardDetailsElement.sectionFieldErrorController())) | ||
), | ||
hiddenIdentifiers ?: emptyList(), | ||
IdentifierSpec.Generic("card_details") | ||
) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am looking up the translated string in localize and adding it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, got it in localize, and it will update the next time we run the script. Best to wait until this other PR is merged to run the localize script again. #4892