Coder Social home page Coder Social logo

dbachelder / creditcardentry Goto Github PK

View Code? Open in Web Editor NEW
499.0 25.0 165.0 1.98 MB

Smooth UI for Credit Card Entry on Android device, regex check for supported credit card types and luhn check. Inspired by Square credit card entry interface

License: MIT License

Java 100.00%

creditcardentry's Introduction

CreditCardEntry

Join the chat at https://gitter.im/dbachelder/CreditCardEntry Android Arsenal

Introduction

This library provides an elegant form for credit card entry that can be easily added to a activity or fragment. Regex is used to validate credit card types and a Luhn check is performed on the card numbers. This form was inspired by the credit entry UI on Square.

  • Smooth interface
  • Identifies credit card type
  • Hides number for privacy
  • Supports VISA, MasterCard, Discover and AMEX

Including in your project

This project uses JitPack to build and release.

Add JitPack to the end of your repositories

    repositories {

        ...

        maven { url "https://jitpack.io" }
    }

Add the project to your dependencies

    dependencies {

        ...

        compile 'com.github.dbachelder:CreditCardEntry:1.4.7'
    }

Using the library

Please see below for an example.

XML

        <com.devmarvel.creditcardentry.library.CreditCardForm
            android:id="@+id/credit_card_form"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:helper_text_color="@color/yellow_500"
            app:include_helper="false"
            app:include_zip="false"/>

  • app:text_color - change the input field's text color (Color.BLACK by default).
  • app:hint_text_color - change the input field's hint text color (Color.LTGRAY by default).
  • app:cursor_color - change the input field's cursor color (Color.BLACK by default).
  • app:default_text_colors - If true, use text colors provided by the app's theme instead of the values provided by app:text_color,app:hint_text_color, and app:cursor_color. This overrides the values for those three text colors and causes the text inputs to use the colors provided by the application's theme.
  • app:include_helper - boolean to show/hide the helper text under the widget (true by default (i.e. helper is shown))
  • app:helper_text_color - change the text color of the hints that appear below the widget by default.
  • app:include_zip - boolean to show/hide the zip code in the form (true by default (i.e. zip is shown))
  • app:include_exp - boolean to show/hide the exp in the form (true by default (i.e. exp is shown))
  • app:include_security - boolean to show/hide the security code in the form (true by default (i.e. security is shown))
  • app:card_number_hint - string to put in as a placeholder (hint) in the credit card number field
  • app:input_background - the drawable to use as a background (defaults to white square with black 1px border)

In code:

    public class MainActivity extends Activity {
  
      private LinearLayout linearLayout;
      private CreditCardForm form;
  
      protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
  
        setContentView(R.layout.activity_main);
    	linearLayout = (LinearLayout) findViewById(R.id.layer);
		
        form = new CreditCardForm(this);
    	linearLayout.addView(form);
    	
    	buttonAuthorize = (Button) findViewById(R.id.buttonAuthorize);
    	buttonAuthorize.setOnClickListener(new OnClickListener() {
    		
    		@Override
    		public void onClick(View arg0) {
    			if(form.isCreditCardValid())
    			{
    				CreditCard card = form.getCreditCard();
    				//Pass credit card to service
    			}
    			else
    			{
    				//Alert Credit card invalid
    			}
    		}
    	});
    }

TODO

  • Diner's Club is not yet implemented, although the assets and regex seem to be in place

Version History

7/25/2017

  • added InterSwitch Verve card image
  • added InterSwitch Verve Regex to Card Enum

3/30/2016

  • made the CreditCardForm work in RTL layout
  • added getHelperText/setHelperText to CreditEntryFieldBase
  • added setting hint & helper texts to fields

9/17/2015

  • Changed how the ZipCodeText is validating zip codes so it will work with other countries.
  • fix for isCreditCardValid() returning true when it is not

9/8/2015

  • fix bug where isValidCard would be called many times
  • allow for using colors from theme

8/21/2015

  • don't drop key strokes after backspace

8/21/2015

  • focus change behavior can now keep up with very fast typing
  • several minor performance tweaks

8/18/2015

  • fix typo in hint for exp date
  • fix for dates not being able to exceed 2034
  • fix for current month being invalid

7/27/2015

  • fix occasional NPE

7/15/2015

  • fix for order of operations when invalidating card and calling delegate methods

7/07/2015

  • Be able to change input field's text, hint and cursor color

5/16/2015

  • use an animator to do the scroll

5/14/2015

  • don't call complete callback twice

5/13/2015

  • add setters for other CC fields
  • correctly manage state such that more than one form on a screen can handle state change

5/11/2015

  • Added clearForm()

4/27/2015

  • removed a bunch of dead resources reducing aar size by ~17%

4/26/2015

  • fixed corner radius of card back
  • allow setting an invalid number programmatically

4/24/2015

  • Done IME causes validation check and keyboard dismiss
  • All fields except credit card # are now optional
  • Allow setting credit card number programmatically

4/21/2015

  • Don't focus credit card by default. Add mechanism for clients to focus any field if desired.
  • CardType now contains image drawable ids for front and back of card
  • The credit card placeholder hint can now be specified via xml
  • Setting focus change listener now delegates to all internal fields.
  • Background of widget is now configurable

4/20/2015

  • Flip the card image back to the front after CVV field loses focus
  • Expose CardType on CreditCard object
  • Transferred repo ownership

4/19/2015

  • Don't scroll when scrolling is already happening

4/18/2015

  • Made helper optional (app:include_helper="false")
  • Fixed a ton of lint warnings
  • Fixed vertical alignment of form fields
  • Fixed over excited animation scroll
  • Last 4 of card now tappable to enter edit mode
  • updated image assets

4/8/2015

  • Always return CreditCard object when requested even when invalid

4/7/2015

  • Made zip code optional (app:include_zip="false")
  • added callback when data entry is complete and card is valid
  • optionally specify helper text color in XML attrs

5/11/2013

  • Updated Demo added screenshots

4/2/2013

  • Initial Commit

creditcardentry's People

Contributors

aardouin avatar dbachelder avatar evyatar-via avatar gitter-badger avatar ifiok avatar jgrana avatar josefernand avatar kojustin avatar mbmc avatar mrsasha avatar ralfgehrer avatar sandyscoffable avatar stephenvinouze avatar zafrani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

creditcardentry's Issues

java.lang.IndexOutOfBoundsException: setSpan (3 ... 3) ends beyond length 0

<com.devmarvel.creditcardentry.library.CreditCardForm
        android:id="@+id/credit_card_form"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:helper_text_color="@color/rosaXceed"
        app:input_background="@drawable/input_credit_card"
        app:include_helper="false"
        app:include_zip="false"
        app:include_exp="false"
        app:include_security="false"/>

And this is the code

 Form = (CreditCardForm) findViewById(R.id.credit_card_form); 
 Form.setCardNumber("4242 4242 4242 4242", false)

If I put without setCardNumber() all works. But If I put it, app crashes with this error
04-26 00:52:53.532 6585-6585/me.xceed.xceed E/AndroidRuntime๏น• FATAL EXCEPTION: main
Process: me.xceed.xceed, PID: 6585
java.lang.RuntimeException: Unable to start activity ComponentInfo{me.xceed.xceed/me.xceed.xceed.AddCreditCardActivity}: java.lang.IndexOutOfBoundsException: setSpan (3 ... 3) ends beyond length 0
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2658)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)
at android.app.ActivityThread.access$900(ActivityThread.java:172)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.IndexOutOfBoundsException: setSpan (3 ... 3) ends beyond length 0
at android.text.SpannableStringBuilder.checkRange(SpannableStringBuilder.java:1022)
at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:615)
at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:611)
at android.text.Selection.setSelection(Selection.java:123)
at android.text.Selection.setSelection(Selection.java:134)
at android.widget.EditText.setSelection(EditText.java:115)
at com.devmarvel.creditcardentry.fields.CreditCardText.afterTextChanged(CreditCardText.java:55)
at android.widget.TextView.sendAfterTextChanged(TextView.java:8615)
at android.widget.TextView.setText(TextView.java:4645)
at android.widget.TextView.setText(TextView.java:4489)
at android.widget.EditText.setText(EditText.java:101)
at android.widget.TextView.setText(TextView.java:4464)
at com.devmarvel.creditcardentry.internal.CreditCardEntry.setCardNumber(CreditCardEntry.java:346)
at com.devmarvel.creditcardentry.library.CreditCardForm.setCardNumber(CreditCardForm.java:211)
at me.xceed.xceed.AddCreditCardActivity.onCreate(AddCreditCardActivity.java:44)
at android.app.Activity.performCreate(Activity.java:6221)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2611)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2723)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.ActivityThread.access$900(ActivityThread.java:172)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1422)
ย ย ย ย ย ย ย ย ย ย ย ย at android.os.Handler.dispatchMessage(Handler.java:102)
ย ย ย ย ย ย ย ย ย ย ย ย at android.os.Looper.loop(Looper.java:145)
ย ย ย ย ย ย ย ย ย ย ย ย at android.app.ActivityThread.main(ActivityThread.java:5832)
ย ย ย ย ย ย ย ย ย ย ย ย at java.lang.reflect.Method.invoke(Native Method)
ย ย ย ย ย ย ย ย ย ย ย ย at java.lang.reflect.Method.invoke(Method.java:372)
ย ย ย ย ย ย ย ย ย ย ย ย at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
ย ย ย ย ย ย ย ย ย ย ย ย at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

Doesn't build with build tools 28.0.2

Lots of failures of the type:

AGPBI: {"kind":"error","text":"error: \u003citem\u003e inner element must either be a resource reference or empty.","sources":[{"file":"/Users/XXXX/.gradle/caches/transforms-1/files-1.1/CreditCardEntry-1.4.7.aar/a4f38cbb1d005ade4b971a4553de5145/res/values/values.xml","position":{"startLine":11,"startColumn":4,"startOffset":988,"endColumn":46,"endOffset":1030}}],"original":"","tool":"AAPT"}

Not really too sure how to proceed.

Weird issue with the UI element

I have CreditCardForm in my xml and it shows up in the view, but when I tap it nothing happens, no soft keyboard or anything.

<com.devmarvel.creditcardentry.library.CreditCardForm
            android:layout_marginLeft="@dimen/pad4"
            android:layout_marginRight="@dimen/pad4"
            android:layout_marginTop="@dimen/pad8"
            android:layout_marginBottom="@dimen/pad8"
            android:id="@+id/cc_input"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:include_exp="false"
            app:include_helper="false"
            app:include_security="false"
            app:include_zip="false"/>

Any idea what might be the issue?
p.s: it's inside a recyclerview.

Wrong scroll when setting the credit card number

Hi!

I'm having problems when I set the credit card number in the form:
This is if I don't focus the credit card number:
Image1

And this is after focus the credit card number

Image2

If I enter a CVV it will validate it right.

Very nice library btw.
Regards

Duplicate Classes with com.github.tipsi

> Task :app:checkDebugDuplicateClasses FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> 1 exception was raised by workers:
  java.lang.RuntimeException: java.lang.RuntimeException: Duplicate class com.devmarvel.creditcardentry.BuildConfig found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.fields.CreditCardText found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.fields.CreditEntryFieldBase found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.fields.CreditEntryFieldBase$BackInputConnection found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.fields.ExpDateText found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.fields.SecurityCodeText found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.fields.ZipCodeText found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.internal.CreditCardEntry found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.internal.CreditCardEntry$1 found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.internal.CreditCardEntry$2 found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.internal.CreditCardEntry$3 found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.internal.CreditCardEntry$4 found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.internal.CreditCardEntry$5 found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.internal.CreditCardEntry$6 found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.internal.CreditCardEntry$7 found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.internal.CreditCardEntry$8 found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.internal.CreditCardEntry$SavedState found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.internal.CreditCardEntry$SavedState$1 found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.internal.CreditCardFieldDelegate found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.internal.CreditCardUtil found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.internal.CreditCardUtil$1 found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.internal.FlipAnimator found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.library.CardRegex found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.library.CardType found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.library.CardValidCallback found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.library.CreditCard found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.library.CreditCardForm found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.library.CreditCardForm$1 found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.library.CreditCardForm$SavedState found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)
  Duplicate class com.devmarvel.creditcardentry.library.CreditCardForm$SavedState$1 found in modules classes.jar (com.github.dbachelder:CreditCardEntry:1.4.9) and classes.jar (com.github.tipsi:CreditCardEntry:1.5.1)

Looks like a huge number of the classes are duplicated between the two libraries and I'm not sure how to deal with it.

Android resource compilation fails on newer build tools.

> Task :app:mergeDebugResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> 1 exception was raised by workers:
  com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
  /Users/bram/.gradle/caches/transforms-2/files-2.1/91118a1b64f76d22fcf69aad06bd0026/res/values/values.xml:12:5-47: AAPT: error: <item> inner element must either be a resource reference or empty.

  /Users/bram/.gradle/caches/transforms-2/files-2.1/91118a1b64f76d22fcf69aad06bd0026/res/values/values.xml:13:5-46: AAPT: error: <item> inner element must either be a resource reference or empty.

  /Users/bram/.gradle/caches/transforms-2/files-2.1/91118a1b64f76d22fcf69aad06bd0026/res/values/values.xml:14:5-48: AAPT: error: <item> inner element must either be a resource reference or empty.

  /Users/bram/.gradle/caches/transforms-2/files-2.1/91118a1b64f76d22fcf69aad06bd0026/res/values/values.xml:15:5-57: AAPT: error: <item> inner element must either be a resource reference or empty.

  /Users/bram/.gradle/caches/transforms-2/files-2.1/91118a1b64f76d22fcf69aad06bd0026/res/values/values.xml:16:5-46: AAPT: error: <item> inner element must either be a resource reference or empty.

  /Users/bram/.gradle/caches/transforms-2/files-2.1/91118a1b64f76d22fcf69aad06bd0026/res/values/values.xml:17:5-54: AAPT: error: <item> inner element must either be a resource reference or empty.

  /Users/bram/.gradle/caches/transforms-2/files-2.1/91118a1b64f76d22fcf69aad06bd0026/res/values/values.xml:18:5-46: AAPT: error: <item> inner element must either be a resource reference or empty.

  /Users/bram/.gradle/caches/transforms-2/files-2.1/91118a1b64f76d22fcf69aad06bd0026/res/values/values.xml:19:5-51: AAPT: error: <item> inner element must either be a resource reference or empty.

  /Users/bram/source/applydigital/zo-react-native/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml: error: file failed to compile.

Larger font for tablet

Is there a way to increase the size of the font? I'm on a tablet and it seems too small.

android:padding seems to set a margin instead?

Hi,

In my XML I'm using 'android:padding="15dp"' on the CardForm, however it seems to be adding a margin around the entire view. Is there a way I can set the padding in XML between the white background and the text, to make the input field bigger? I would like the ability to add different paddings for different screen sizes, but I can handle that bit as long as I find a way to actually adjust the padding.

Is this a bug or something I'm just missing?

Thanks.

This project could not be access

When I added this paths to my gradle file it will show error message telling "Failed to resolve:com.github.dbachelder:CreditCardEntry:v1.3.0" like that.

Setting card to invisible in layout and then visible renders the view unsuable

I have noticed that we I set the view to android:visibility="invisible" in the layout and then later make it visible via code. The view will display, but I can't seem to focus on it or tap on the view to try and enter data.

However, you can programmatically make the view "GONE" or "INVISIBLE" and then later make is visible. I'm using android version 6 on a nexus 6p is that helps. I haven't dug into the source code to find the problem because there's an easy work around but it might be worth having it documented as a issue for other too see.

Is there a chance to build programatically?

Hi,

I'm using this amazing library (thanks for that;) and I'm concerned about how to give an already filled version of the form, from the second time the user visualizes it. (when I already have the data).

thanks a lot and congrats for the tool
;)

Widget is hard to style for dark themes

The credit card entry form doesn't really fit in when it is placed in an application with a dark theme. The defaults for app:cursor_color, app:text_color, app:input_background, etc. are dark colors and are not very visible on dark themes. It's possible to manually set these colors, but it would be nicer if the widget just used the default colors that are provided by the theme.

I tried going through and just removing the places where the underlying EditTexts have colors assigned, and it worked pretty well for me.

diff --git a/CreditCardEntry/src/com/devmarvel/creditcardentry/fields/CreditEntryFieldBase.java b/CreditCardEntry/src/com/devmarvel/creditcardentry/fields/CreditEntryFieldBase.java
index 064b1b9..de368a8 100644
--- a/CreditCardEntry/src/com/devmarvel/creditcardentry/fields/CreditEntryFieldBase.java
+++ b/CreditCardEntry/src/com/devmarvel/creditcardentry/fields/CreditEntryFieldBase.java
@@ -82,9 +82,9 @@ public abstract class CreditEntryFieldBase extends EditText implements
        }

        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CreditCardForm);
-       setTextColor(typedArray.getColor(R.styleable.CreditCardForm_text_color, Color.BLACK));
-       setHintTextColor(typedArray.getColor(R.styleable.CreditCardForm_hint_text_color, Color.LTGRAY));
-       setCursorDrawableColor(typedArray.getColor(R.styleable.CreditCardForm_cursor_color, Color.BLACK));
+//     setTextColor(typedArray.getColor(R.styleable.CreditCardForm_text_color, Color.BLACK));
+//     setHintTextColor(typedArray.getColor(R.styleable.CreditCardForm_hint_text_color, Color.LTGRAY));
+//     setCursorDrawableColor(typedArray.getColor(R.styleable.CreditCardForm_cursor_color, Color.BLACK));
        typedArray.recycle();
    }

diff --git a/CreditCardEntry/src/com/devmarvel/creditcardentry/internal/CreditCardEntry.java b/CreditCardEntry/src/com/devmarvel/creditcardentry/internal/CreditCardEntry.java
index 6987b28..e586971 100644
--- a/CreditCardEntry/src/com/devmarvel/creditcardentry/internal/CreditCardEntry.java
+++ b/CreditCardEntry/src/com/devmarvel/creditcardentry/internal/CreditCardEntry.java
@@ -86,7 +86,7 @@ public class CreditCardEntry extends HorizontalScrollView implements
         this.context = context;

         TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CreditCardForm, 0, 0);
-        textColor = typedArray.getColor(R.styleable.CreditCardForm_text_color, Color.BLACK);
+//        textColor = typedArray.getColor(R.styleable.CreditCardForm_text_color, Color.BLACK);
         typedArray.recycle();

         WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
@@ -123,7 +123,8 @@ public class CreditCardEntry extends HorizontalScrollView implements

         textFourDigits = new TextView(context);
         textFourDigits.setTextSize(20);
-        textFourDigits.setTextColor(textColor);
+        textColor = textFourDigits.getCurrentTextColor();
+//        textFourDigits.setTextColor(textColor);
         container.addView(textFourDigits);

         expDateText = new ExpDateText(context, attrs);

Please provide 'cardInvalid(...)' method in CardValidCallback interface

In my code I need to enable/disable 'save card' button dynamically.
Case:
I can disable 'save card' button by default, and then enable it when card became valid (from callback). But if user will edit the card info then - it may became invalid, and there is no way to know about it, while user types. I think I can do it in 'hacky' way, but no reason for this :) Please provide such callback.

Can you take out the android:icon in the manifest of the demo?

It is causing a really unnessary error for me:
Error:(46, 9) Attribute application@icon value=(@drawable/halplogo) from AndroidManifest.xml:46:9
Error:(46, 9) Execution failed for task ':app:processDebugManifest'.

Manifest merger failed : Attribute application@icon value=(@drawable/halplogo) from AndroidManifest.xml:46:9
is also present at com.github.dbachelder:CreditCardEntry:v1.2.1:13:9 value=(@drawable/ic_launcher)
Suggestion: add 'tools:replace="android:icon"' to element at AndroidManifest.xml:44:5 to override

I have added tools:replace="android:icon" in application but I still get the error. It would be awesome if you could just delete that line since there is no point in a library having an icon. Thanks man!

isCreditCardValid returns true after editing number to be incorrect

After the form is correctly filled out, and isCreditCardValid correctly returns true, I'm able to click on the credit card number, erase a bunch of the numbers (thus rendering the number incorrect), focus on some other field on the screen, and have isCreditCardValid still return true (when, in fact, I had expected it to return false).

I'm working with Stripe, which went on to fail because the data in the CreditCardForm was actually invalid at that point.

Add support for `setTypeface` method.

The only reason I can't use this library is because our app is using a font and there doesn't seem to be a way to apply fonts in CreditCardForm. At least let CreditCardForm return actual underlying TextViews so that user can apply fonts on it.

Component scrolls at the beginning when typing ccv / expiration date

To reproduce:
Type in credit card number -> component scrolls and focuses into expiration date.

Expected:
I can type expiration date and component keeps its "state" and doesn't scroll away from the expiration date while typing

Actual:
When typing, component scrolls into the credit card number but cursor still seems to remain in expiration date.

Save behaviour is also repeated with CCV. I have reproduced this with the example app.

Only found one device which reproduces this: Sony Xperia XA (F3111 with Android version 7.0). Sadly couldn't find a virtual device setup where this could be reproduced.

Could not see any obvious reason by debugging, why this is happening. Any idea?

A typo in strings

When typed in the expired date, the helper text was "Expiration date (MM/DD)".
I guess it should be "MM/YY". :)

Request: After card number entered, show 'dots' to denote hidden numbers

After you enter the 16 numbers, only 4 are shown, with the first 12 being hidden. Very cool!

However, I think it would be a bit more obvious to users if the first 12 digits were replaced with 'dots' (or some such symbol) to make it really obvious that the card was entered successfully and that we're only hiding numbers from them as a security measure.

Would something like this be possible? I've seen it elsewhere and it felt more user friendly. Perhaps configurable with a true/false attribute?

Weird layout issues? margin/padding

Have you noticed that when using this library that the field to enter the details has a weird margin/padding around it?

I want to be able to put another EditText right below this view with no spaces and it won't let me. It has a padding/margin somewhere that is sticks too.

I can't seem to find anywhere in the code to change this, do you know where I can change it in the library?

It looks very weird, because this view sits at the top of my layout, then there's a gap and all my other EditTexts are below that gap, but that are sitting close to each other with no margins or padding.

Is it possible to modify the UI

Mainly is there an option to not have a background resource on the linear layout and one to add a background resource to the edit text field?

Support for non-English languages

Currently the strings for this project are available in English only.
It would be nice to have support for other languages as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.