Skip to content

Commit

Permalink
Make StripeEditText public (#1745)
Browse files Browse the repository at this point in the history
Some users would like to access properties on this class

Also fix doc links
  • Loading branch information
mshafrir-stripe authored Oct 22, 2019
1 parent 9bb0144 commit c133b29
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DependencyHandler(

/**
* Attach a listener that creates a token using the [android.os.AsyncTask]-based method.
* Only gets attached once, unless you call [.clearReferences].
* Only gets attached once, unless you call [clearReferences].
*
* @param button a button that, when clicked, gets a token.
*/
Expand All @@ -56,7 +56,7 @@ class DependencyHandler(
* Attach a listener that creates a token using a [rx.Subscription] and the
* synchronous [com.stripe.android.Stripe.createCardTokenSynchronous] method.
*
* Only gets attached once, unless you call [.clearReferences].
* Only gets attached once, unless you call [clearReferences].
*
* @param button a button that, when clicked, gets a token.
*/
Expand Down
6 changes: 2 additions & 4 deletions stripe/src/main/java/com/stripe/android/PaymentController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,14 @@ internal open class PaymentController @VisibleForTesting constructor(
}

/**
* Decide whether [.handlePaymentResult]
* should be called.
* Decide whether [handlePaymentResult] should be called.
*/
open fun shouldHandlePaymentResult(requestCode: Int, data: Intent?): Boolean {
return requestCode == PAYMENT_REQUEST_CODE && data != null
}

/**
* Decide whether [.handleSetupResult]
* should be called.
* Decide whether [handleSetupResult] should be called.
*/
open fun shouldHandleSetupResult(requestCode: Int, data: Intent?): Boolean {
return requestCode == SETUP_REQUEST_CODE && data != null
Expand Down
3 changes: 1 addition & 2 deletions stripe/src/main/java/com/stripe/android/PaymentSession.kt
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ class PaymentSession @VisibleForTesting internal constructor(
* @param paymentSessionConfig a [PaymentSessionConfig] used to decide which items are
* necessary in the PaymentSession.
* @param savedInstanceState a `Bundle` containing the saved state of a
* PaymentSession that was stored in
* [.savePaymentSessionInstanceState]
* PaymentSession that was stored in [savePaymentSessionInstanceState]
* @param shouldPrefetchCustomer If true, will immediately fetch the [Customer] associated
* with this session. Otherwise, will only fetch when needed.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ internal class StripeApiRepository @JvmOverloads internal constructor(
}

/**
* @param dnsCacheData first object - flag to reset [.DNS_CACHE_TTL_PROPERTY_NAME]
* @param dnsCacheData first object - flag to reset [DNS_CACHE_TTL_PROPERTY_NAME]
* second object - the original DNS cache TTL value
*/
private fun resetDnsCacheTtl(dnsCacheData: Pair<Boolean, String>) {
Expand Down
4 changes: 2 additions & 2 deletions stripe/src/main/java/com/stripe/android/model/Source.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ data class Source private constructor(
/**
* Gets the [SourceType] of this Source, as one of the enumerated values.
* If a custom source type has been created, this returns [SourceType.UNKNOWN]. To get
* the raw value of an [SourceType.UNKNOWN] type, use [.getTypeRaw].
* the raw value of an [SourceType.UNKNOWN] type, use [typeRaw].
*
* @return the [SourceType] of this Source
*/
Expand All @@ -48,7 +48,7 @@ data class Source private constructor(

/**
* Gets the type of this source as a String. If it is a known type, this will return
* a string equal to the [SourceType] returned from [.getType]. This
* a string equal to the [SourceType] returned from [type]. This
* method is not restricted to known types
*
* @return the type of this Source as a string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ internal object StripeJsonUtils {
}

/**
* Calls through to [JSONObject.optJSONObject] and then
* uses [.jsonObjectToMap] on the result.
* Calls through to [JSONObject.optJSONObject] and then uses [jsonObjectToMap] on the result.
*
* @param jsonObject the input object
* @param fieldName the required field name
Expand All @@ -138,8 +137,7 @@ internal object StripeJsonUtils {
}

/**
* Calls through to [JSONObject.optJSONObject] and then
* uses [.jsonObjectToStringMap] on the result.
* Calls through to [JSONObject.optJSONObject] and then uses [jsonObjectToStringMap] on the result.
*
* @param jsonObject the input object
* @param fieldName the required field name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package com.stripe.android.view
* from one text field to the previous. We use this to simulate multiple fields being all part
* of the same EditText, so a delete key entry from field N+1 deletes the last character in
* field N. Each BackUpFieldDeleteListener is attached to the N+1 field, from which it gets
* its [.onDeleteEmpty] call, and given a reference to the N field, upon which
* its [onDeleteEmpty] call, and given a reference to the N field, upon which
* it will be acting.
*/
internal class BackUpFieldDeleteListener(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public void onExpiryDateComplete() {
mCvcEditText.setAfterTextChangedListener(
new StripeEditText.AfterTextChangedListener() {
@Override
public void onTextChanged(String text) {
public void onTextChanged(@NonNull String text) {
if (ViewUtils.isCvcMaximalLength(mCardBrand, text)) {
updateBrand(mCardBrand);
if (mShouldShowPostalCode) {
Expand All @@ -195,7 +195,7 @@ public void onTextChanged(String text) {
mPostalCodeEditText.setAfterTextChangedListener(
new StripeEditText.AfterTextChangedListener() {
@Override
public void onTextChanged(String text) {
public void onTextChanged(@NonNull String text) {
if (isPostalCodeMaximalLength(true, text)
&& mCardInputListener != null) {
mCardInputListener.onPostalCodeComplete();
Expand Down
3 changes: 1 addition & 2 deletions stripe/src/main/java/com/stripe/android/view/DateUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ internal object DateUtils {
* @param expiryYear An integer representing the full year (2017, not 17). Only positive values
* are valid, but this is called by user input, so we have to check outside
* for otherwise nonsensical dates. This code cannot validate years greater
* than [9980][.MAX_VALID_YEAR] because of how we parse years in
* [.convertTwoDigitYearToFour].
* than [9980][MAX_VALID_YEAR] because of how we parse years in [convertTwoDigitYearToFour].
* @return `true` if the current month and year is the same as or later than the input
* month and year, `false` otherwise. Note that some cards expire on the first of the
* month, but we don't validate that here.
Expand Down
10 changes: 5 additions & 5 deletions stripe/src/main/java/com/stripe/android/view/StripeEditText.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import com.stripe.android.R
* but we listen here for hardware key presses, older Android soft keyboard delete presses,
* and modern Google Keyboard delete key presses.
*/
internal open class StripeEditText @JvmOverloads constructor(
open class StripeEditText @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = androidx.appcompat.R.attr.editTextStyle
Expand All @@ -34,6 +34,7 @@ internal open class StripeEditText @JvmOverloads constructor(
private var deleteEmptyListener: DeleteEmptyListener? = null
var cachedColorStateList: ColorStateList? = null
private set

/**
* Gets whether or not the text should be displayed in error mode.
*
Expand Down Expand Up @@ -83,10 +84,9 @@ internal open class StripeEditText @JvmOverloads constructor(

override fun onCreateInputConnection(outAttrs: EditorInfo): InputConnection? {
val inputConnection = super.onCreateInputConnection(outAttrs)
return if (inputConnection != null)
SoftDeleteInputConnection(inputConnection, true, deleteEmptyListener)
else
null
return inputConnection?.let {
SoftDeleteInputConnection(it, true, deleteEmptyListener)
}
}

/**
Expand Down
3 changes: 1 addition & 2 deletions stripe/src/test/java/com/stripe/android/view/BaseViewTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ abstract class BaseViewTest<T : Activity> protected constructor(private val mCla
}

/**
* Call resume() and visible() on an Activity that was created with
* [.createStartedActivity].
* Call resume() and visible() on an Activity that was created with [createStartedActivity].
*/
protected fun resumeStartedActivity(activity: T) {
val activityController = mActivityControllers[activity.hashCode()]
Expand Down

0 comments on commit c133b29

Please sign in to comment.