@Test public void getFocusRequestOnTouch_whenTouchInCardEditorSlop_returnsCardEditor() { StripeEditText focusRequester = mCardInputWidget.getFocusRequestOnTouch(300); assertNotNull(focusRequester); assertEquals(mCardNumberEditText, focusRequester); }
@VisibleForTesting @Nullable StripeEditText getFocusRequestOnTouch(int touchX) { int frameStart = mFrameLayout.getLeft(); if (mCardNumberIsViewed) { if (touchX < frameStart + mPlacementParameters.cardWidth) { return null; } else if (touchX < mPlacementParameters.cardTouchBufferLimit){ return mCardNumberEditText; } else if (touchX < mPlacementParameters.dateStartPosition) { return mExpiryDateEditText; } else { return null; } } else { if (touchX < frameStart + mPlacementParameters.peekCardWidth) { return null; } else if( touchX < mPlacementParameters.cardTouchBufferLimit) { return mCardNumberEditText; } else if (touchX < mPlacementParameters.dateStartPosition) { return mExpiryDateEditText; } else if (touchX < mPlacementParameters.dateStartPosition + mPlacementParameters.dateWidth) { return null; } else if (touchX < mPlacementParameters.dateRightTouchBufferLimit) { return mExpiryDateEditText; } else if (touchX < mPlacementParameters.cvcStartPosition) { return mCvcNumberEditText; } else { return null; } } }
CardInputWidget extends LinearLayout { @VisibleForTesting @Nullable StripeEditText getFocusRequestOnTouch(int touchX) { int frameStart = mFrameLayout.getLeft(); if (mCardNumberIsViewed) { if (touchX < frameStart + mPlacementParameters.cardWidth) { return null; } else if (touchX < mPlacementParameters.cardTouchBufferLimit){ return mCardNumberEditText; } else if (touchX < mPlacementParameters.dateStartPosition) { return mExpiryDateEditText; } else { return null; } } else { if (touchX < frameStart + mPlacementParameters.peekCardWidth) { return null; } else if( touchX < mPlacementParameters.cardTouchBufferLimit) { return mCardNumberEditText; } else if (touchX < mPlacementParameters.dateStartPosition) { return mExpiryDateEditText; } else if (touchX < mPlacementParameters.dateStartPosition + mPlacementParameters.dateWidth) { return null; } else if (touchX < mPlacementParameters.dateRightTouchBufferLimit) { return mExpiryDateEditText; } else if (touchX < mPlacementParameters.cvcStartPosition) { return mCvcNumberEditText; } else { return null; } } } }
CardInputWidget extends LinearLayout { @VisibleForTesting @Nullable StripeEditText getFocusRequestOnTouch(int touchX) { int frameStart = mFrameLayout.getLeft(); if (mCardNumberIsViewed) { if (touchX < frameStart + mPlacementParameters.cardWidth) { return null; } else if (touchX < mPlacementParameters.cardTouchBufferLimit){ return mCardNumberEditText; } else if (touchX < mPlacementParameters.dateStartPosition) { return mExpiryDateEditText; } else { return null; } } else { if (touchX < frameStart + mPlacementParameters.peekCardWidth) { return null; } else if( touchX < mPlacementParameters.cardTouchBufferLimit) { return mCardNumberEditText; } else if (touchX < mPlacementParameters.dateStartPosition) { return mExpiryDateEditText; } else if (touchX < mPlacementParameters.dateStartPosition + mPlacementParameters.dateWidth) { return null; } else if (touchX < mPlacementParameters.dateRightTouchBufferLimit) { return mExpiryDateEditText; } else if (touchX < mPlacementParameters.cvcStartPosition) { return mCvcNumberEditText; } else { return null; } } } CardInputWidget(Context context);  CardInputWidget(Context context, AttributeSet attrs);  CardInputWidget(Context context, AttributeSet attrs, int defStyleAttr); }
CardInputWidget extends LinearLayout { @VisibleForTesting @Nullable StripeEditText getFocusRequestOnTouch(int touchX) { int frameStart = mFrameLayout.getLeft(); if (mCardNumberIsViewed) { if (touchX < frameStart + mPlacementParameters.cardWidth) { return null; } else if (touchX < mPlacementParameters.cardTouchBufferLimit){ return mCardNumberEditText; } else if (touchX < mPlacementParameters.dateStartPosition) { return mExpiryDateEditText; } else { return null; } } else { if (touchX < frameStart + mPlacementParameters.peekCardWidth) { return null; } else if( touchX < mPlacementParameters.cardTouchBufferLimit) { return mCardNumberEditText; } else if (touchX < mPlacementParameters.dateStartPosition) { return mExpiryDateEditText; } else if (touchX < mPlacementParameters.dateStartPosition + mPlacementParameters.dateWidth) { return null; } else if (touchX < mPlacementParameters.dateRightTouchBufferLimit) { return mExpiryDateEditText; } else if (touchX < mPlacementParameters.cvcStartPosition) { return mCvcNumberEditText; } else { return null; } } } CardInputWidget(Context context);  CardInputWidget(Context context, AttributeSet attrs);  CardInputWidget(Context context, AttributeSet attrs, int defStyleAttr); @Nullable Card getCard(); void setCardInputListener(@Nullable CardInputListener listener); void setCardNumber(String cardNumber); void setExpiryDate(
            @IntRange(from = 1, to = 12) int month,
            @IntRange(from = 0, to = 9999) int year); void setCvcCode(String cvcCode); void clear(); void setEnabled(boolean isEnabled); @Override boolean isEnabled(); @Override boolean onInterceptTouchEvent(MotionEvent ev); @Override void onWindowFocusChanged(boolean hasWindowFocus); }
CardInputWidget extends LinearLayout { @VisibleForTesting @Nullable StripeEditText getFocusRequestOnTouch(int touchX) { int frameStart = mFrameLayout.getLeft(); if (mCardNumberIsViewed) { if (touchX < frameStart + mPlacementParameters.cardWidth) { return null; } else if (touchX < mPlacementParameters.cardTouchBufferLimit){ return mCardNumberEditText; } else if (touchX < mPlacementParameters.dateStartPosition) { return mExpiryDateEditText; } else { return null; } } else { if (touchX < frameStart + mPlacementParameters.peekCardWidth) { return null; } else if( touchX < mPlacementParameters.cardTouchBufferLimit) { return mCardNumberEditText; } else if (touchX < mPlacementParameters.dateStartPosition) { return mExpiryDateEditText; } else if (touchX < mPlacementParameters.dateStartPosition + mPlacementParameters.dateWidth) { return null; } else if (touchX < mPlacementParameters.dateRightTouchBufferLimit) { return mExpiryDateEditText; } else if (touchX < mPlacementParameters.cvcStartPosition) { return mCvcNumberEditText; } else { return null; } } } CardInputWidget(Context context);  CardInputWidget(Context context, AttributeSet attrs);  CardInputWidget(Context context, AttributeSet attrs, int defStyleAttr); @Nullable Card getCard(); void setCardInputListener(@Nullable CardInputListener listener); void setCardNumber(String cardNumber); void setExpiryDate(
            @IntRange(from = 1, to = 12) int month,
            @IntRange(from = 0, to = 9999) int year); void setCvcCode(String cvcCode); void clear(); void setEnabled(boolean isEnabled); @Override boolean isEnabled(); @Override boolean onInterceptTouchEvent(MotionEvent ev); @Override void onWindowFocusChanged(boolean hasWindowFocus);  }