├── .gitignore
├── LICENSE
├── README.md
├── app
├── app.iml
├── build.gradle
├── build
│ └── intermediates
│ │ └── transforms
│ │ └── instantRunSlicer
│ │ └── debug
│ │ └── folders
│ │ └── 1
│ │ └── 5
│ │ └── slice_1
│ │ └── buildId.txt
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ └── ocraextended.ttf
│ ├── java
│ └── com
│ │ └── cooltechworks
│ │ └── creditcarddesign
│ │ └── sample
│ │ └── MainActivity.java
│ └── res
│ ├── layout
│ └── activity_main.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── values-v21
│ └── styles.xml
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── creditcarddesign
├── build.gradle
├── creditcarddesign.iml
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── cooltechworks
│ │ └── creditcarddesign
│ │ ├── CardEditActivity.java
│ │ ├── CardSelector.java
│ │ ├── CreditCardUtils.java
│ │ ├── CreditCardView.java
│ │ ├── FlipAnimator.java
│ │ ├── pager
│ │ ├── CardCVVFragment.java
│ │ ├── CardExpiryFragment.java
│ │ ├── CardFragmentAdapter.java
│ │ ├── CardNameFragment.java
│ │ ├── CardNumberFragment.java
│ │ ├── CreditCardFragment.java
│ │ ├── IActionListener.java
│ │ └── IFocus.java
│ │ └── views
│ │ └── HeightWrappingViewPager.java
│ └── res
│ ├── drawable
│ ├── card_color_round_rect_blue.xml
│ ├── card_color_round_rect_brown.xml
│ ├── card_color_round_rect_default.xml
│ ├── card_color_round_rect_green.xml
│ ├── card_color_round_rect_pink.xml
│ ├── card_color_round_rect_purple.xml
│ ├── chip.xml
│ ├── chip_inner.xml
│ ├── chip_yellow.xml
│ ├── chip_yellow_inner.xml
│ ├── discover_back.xml
│ ├── discover_back_bg.xml
│ ├── ic_billing_amex_logo.png
│ ├── ic_billing_amex_logo1.png
│ ├── ic_billing_discover_logo.png
│ ├── ic_billing_mastercard_logo.png
│ ├── ic_billing_visa_logo.png
│ ├── img_amex_center_face.png
│ ├── master_back.xml
│ ├── mastercard_back_bg.xml
│ ├── sign_strip.png
│ ├── sign_strip_mod.xml
│ ├── visacard_back.xml
│ └── visacard_back_bg.xml
│ ├── layout
│ ├── activity_card_edit.xml
│ ├── back_card.xml
│ ├── front_card.xml
│ ├── front_card_outline.xml
│ ├── lyt_card_cvv.xml
│ ├── lyt_card_expiry.xml
│ ├── lyt_card_holder_name.xml
│ ├── lyt_card_number.xml
│ └── view_creditcard.xml
│ ├── values-fr
│ └── strings.xml
│ ├── values-pt-rBR
│ └── strings.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── local.properties
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
3 | # built application files
4 | *.apk
5 | *.ap_
6 |
7 | # files for the dex VM
8 | *.dex
9 |
10 | # Java class files
11 | *.class
12 |
13 | # generated files
14 | bin/
15 | gen/
16 |
17 | # Local configuration file (sdk path, etc)
18 | local.properties
19 |
20 | # Eclipse project files
21 | .classpath
22 | .project
23 |
24 | # Android Studio
25 | /.idea
26 | .gradle
27 | /*/local.properties
28 | /*/out
29 | /*/*/build
30 | build
31 | /*/*/production
32 | *.iml
33 | *.iws
34 | *.ipr
35 | *~
36 | *.swp
37 | *.alloc
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CreditCardView
2 |
3 |
4 | Intro
5 | ------
6 |
7 | CreditCardView is a rich UX custom view to accomodate Credit Cards / Debit Cards while handling payment systems. The library consists of
8 |
9 | * CreditCardView which looks like below
10 |
11 | | FRONT VIEW | BACK VIEW |
12 | | ---------------------------- | ----------------------------- |
13 | | ![MASTER FRONT][master_front] | ![MASTER BACK][master_back] |
14 |
15 | * CardEditActivity which behaves as below.
16 |
17 |
18 |
19 | (GIF from - )
20 |
21 |
22 |
23 | Creating a CreditCardView
24 | --------------------------
25 | ##### XML
26 | ```xml
27 |
36 | ```
37 |
38 | ##### JAVA
39 |
40 | ```java
41 |
42 | CreditCardView creditCardView = new CreditCardView(getContext());
43 |
44 | String name = "HARISH SRIDHARAN";
45 | String cvv = "522";
46 | String expiry = "01/17";
47 | String cardNumber = "38056789000000000";
48 |
49 | creditCardView.setCVV(cvv);
50 | creditCardView.setCardHolderName(name);
51 | creditCardView.setCardExpiry(expiry);
52 | creditCardView.setCardNumber(cardNumber);
53 |
54 | ```
55 |
56 | Fetch new card info
57 | ---------------------
58 |
59 | To get a card information from the user, you can simply start the CardEditActivity as below and get the details of the card
60 | from onActivityResult() in your activity.
61 |
62 | ##### Starting the activity
63 | ```java
64 | final int GET_NEW_CARD = 2;
65 |
66 | Intent intent = new Intent(MainActivity.this, CardEditActivity.class);
67 | startActivityForResult(intent,GET_NEW_CARD);
68 | ```
69 |
70 | ##### Getting the card details
71 | ```java
72 |
73 | public void onActivityResult(int reqCode, int resultCode, Intent data) {
74 |
75 | if(resultCode == RESULT_OK) {
76 |
77 | String cardHolderName = data.getStringExtra(CreditCardUtils.EXTRA_CARD_HOLDER_NAME);
78 | String cardNumber = data.getStringExtra(CreditCardUtils.EXTRA_CARD_NUMBER);
79 | String expiry = data.getStringExtra(CreditCardUtils.EXTRA_CARD_EXPIRY);
80 | String cvv = data.getStringExtra(CreditCardUtils.EXTRA_CARD_CVV);
81 |
82 | // Your processing goes here.
83 |
84 | }
85 | }
86 | }
87 | ```
88 |
89 |
90 | Edit existing card
91 | ------------------
92 |
93 | To edit the card details, you can start CardEditActivity passing the extras and get back the edited card information in onActivityResult() method of your activity just like above.
94 | ```java
95 |
96 | final int EDIT_CARD = 5;
97 | Intent intent = new Intent(MainActivity.this, CardEditActivity.class);
98 | intent.putExtra(CreditCardUtils.EXTRA_CARD_HOLDER_NAME, cardHolderName);
99 | intent.putExtra(CreditCardUtils.EXTRA_CARD_NUMBER, cardNumber);
100 | intent.putExtra(CreditCardUtils.EXTRA_CARD_EXPIRY, expiry);
101 | intent.putExtra(CreditCardUtils.EXTRA_CARD_SHOW_CARD_SIDE, CreditCardUtils.CARD_SIDE_BACK);
102 | intent.putExtra(CreditCardUtils.EXTRA_VALIDATE_EXPIRY_DATE, true); // pass "false" to discard expiry date validation.
103 |
104 |
105 | startActivityForResult(intent, EDIT_CARD);
106 | ```
107 |
108 | Sample Demo Video
109 | ------------------
110 | [](https://youtu.be/uPJr0WrO-X0 "CreditCardView Demo Video")
111 |
112 |
113 | Adding to your project
114 | ------------------------
115 |
116 | - Add the following configuration in your build.gradle file.
117 |
118 | ```gradle
119 | repositories {
120 | jcenter()
121 | maven { url "https://jitpack.io" }
122 | }
123 |
124 | dependencies {
125 | compile 'com.github.sharish:CreditCardView:v1.0.4'
126 | }
127 | ```
128 | - Add the following activity to your AndroidManifest.xml
129 |
130 | ```xml
131 |
134 | ```
135 |
136 | Design Credits
137 | --------------
138 | * Ramakrishna -
139 |
140 | Developed By
141 | ------------
142 |
143 | * Harish Sridharan -
144 |
145 | Acknowledgements
146 | ----------------
147 |
148 | * Michele Lacorte for his [Swipeable Cards][1] involving CreditCardView
149 |
150 |
151 |
152 | License
153 | --------
154 | ```
155 | Copyright 2016 Harish Sridharan
156 |
157 | Licensed under the Apache License, Version 2.0 (the "License");
158 | you may not use this file except in compliance with the License.
159 | You may obtain a copy of the License at
160 |
161 | http://www.apache.org/licenses/LICENSE-2.0
162 |
163 | Unless required by applicable law or agreed to in writing, software
164 | distributed under the License is distributed on an "AS IS" BASIS,
165 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
166 | See the License for the specific language governing permissions and
167 | limitations under the License.
168 | ```
169 |
170 |
171 | [master_front]:https://cloud.githubusercontent.com/assets/13122232/12871102/8b681fae-cd8e-11e5-8831-7b1fc1970194.png
172 | [master_back]:https://cloud.githubusercontent.com/assets/13122232/12871095/4ce9a234-cd8e-11e5-8c4e-384ce6874029.png
173 | [visa_front]:https://cloud.githubusercontent.com/assets/13122232/12871145/b57f92f2-cd90-11e5-8f36-086b227d06c3.png
174 | [amex_front]:https://cloud.githubusercontent.com/assets/13122232/12871146/c22cf74c-cd90-11e5-85e4-3ab45d50ba76.png
175 | [amex_back]:https://cloud.githubusercontent.com/assets/13122232/12871156/3124d570-cd91-11e5-8b71-f333e46192bb.png
176 | [visa_back]:https://cloud.githubusercontent.com/assets/13122232/12871157/31625b5c-cd91-11e5-87f7-f42a6404842b.png
177 | [1]: https://github.com/michelelacorte/SwipeableCard
178 |
179 |
180 |
181 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.1"
6 |
7 | defaultConfig {
8 | vectorDrawables.useSupportLibrary = true
9 | applicationId "com.cooltechworks.checkoutflow"
10 | minSdkVersion 10
11 | targetSdkVersion 25
12 | versionCode 2
13 | versionName "1.1"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | compile fileTree(include: ['*.jar'], dir: 'libs')
25 | compile project(':creditcarddesign')
26 | }
27 |
--------------------------------------------------------------------------------
/app/build/intermediates/transforms/instantRunSlicer/debug/folders/1/5/slice_1/buildId.txt:
--------------------------------------------------------------------------------
1 | 341292733940663
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/sharish/ADT_BASE/adt-bundle-mac-x86_64-20130729/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
10 |
14 |
15 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/assets/ocraextended.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sharish/CreditCardView/9ac891404756997b4ecf0f06526ddb11314530bf/app/src/main/assets/ocraextended.ttf
--------------------------------------------------------------------------------
/app/src/main/java/com/cooltechworks/creditcarddesign/sample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.cooltechworks.creditcarddesign.sample;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.AppCompatActivity;
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.Button;
8 | import android.widget.LinearLayout;
9 |
10 | import com.cooltechworks.checkoutflow.R;
11 | import com.cooltechworks.creditcarddesign.CreditCardView;
12 | import com.cooltechworks.creditcarddesign.CardEditActivity;
13 | import com.cooltechworks.creditcarddesign.CreditCardUtils;
14 |
15 | /**
16 | * Created by glarencezhao on 10/23/16.
17 | */
18 |
19 | public class MainActivity extends AppCompatActivity {
20 |
21 | private final int CREATE_NEW_CARD = 0;
22 |
23 | private LinearLayout cardContainer;
24 | private Button addCardButton;
25 |
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_main);
30 |
31 | initialize();
32 | listeners();
33 | }
34 |
35 | private void initialize() {
36 | addCardButton = (Button) findViewById(R.id.add_card);
37 | cardContainer = (LinearLayout) findViewById(R.id.card_container);
38 | // getSupportActionBar().setTitle("Payment");
39 | populate();
40 | }
41 |
42 | private void populate() {
43 | CreditCardView sampleCreditCardView = new CreditCardView(this);
44 |
45 | String name = "Glarence Zhao";
46 | String cvv = "420";
47 | String expiry = "01/18";
48 | String cardNumber = "4242424242424242";
49 |
50 | sampleCreditCardView.setCVV(cvv);
51 | sampleCreditCardView.setCardHolderName(name);
52 | sampleCreditCardView.setCardExpiry(expiry);
53 | sampleCreditCardView.setCardNumber(cardNumber);
54 |
55 | cardContainer.addView(sampleCreditCardView);
56 | int index = cardContainer.getChildCount() - 1;
57 | addCardListener(index, sampleCreditCardView);
58 | }
59 |
60 | private void listeners() {
61 | addCardButton.setOnClickListener(new View.OnClickListener() {
62 | @Override
63 | public void onClick(View v) {
64 |
65 | Intent intent = new Intent(MainActivity.this, CardEditActivity.class);
66 | startActivityForResult(intent, CREATE_NEW_CARD);
67 | }
68 | });
69 | }
70 |
71 | private void addCardListener(final int index, CreditCardView creditCardView) {
72 | creditCardView.setOnClickListener(new View.OnClickListener() {
73 | @Override
74 | public void onClick(View v) {
75 |
76 | CreditCardView creditCardView = (CreditCardView) v;
77 | String cardNumber = creditCardView.getCardNumber();
78 | String expiry = creditCardView.getExpiry();
79 | String cardHolderName = creditCardView.getCardHolderName();
80 | String cvv = creditCardView.getCVV();
81 |
82 | Intent intent = new Intent(MainActivity.this, CardEditActivity.class);
83 | intent.putExtra(CreditCardUtils.EXTRA_CARD_HOLDER_NAME, cardHolderName);
84 | intent.putExtra(CreditCardUtils.EXTRA_CARD_NUMBER, cardNumber);
85 | intent.putExtra(CreditCardUtils.EXTRA_CARD_EXPIRY, expiry);
86 | intent.putExtra(CreditCardUtils.EXTRA_CARD_SHOW_CARD_SIDE, CreditCardUtils.CARD_SIDE_BACK);
87 | intent.putExtra(CreditCardUtils.EXTRA_VALIDATE_EXPIRY_DATE, false);
88 |
89 | // start at the CVV activity to edit it as it is not being passed
90 | intent.putExtra(CreditCardUtils.EXTRA_ENTRY_START_PAGE, CreditCardUtils.CARD_CVV_PAGE);
91 | startActivityForResult(intent, index);
92 | }
93 | });
94 | }
95 |
96 | public void onActivityResult(int reqCode, int resultCode, Intent data) {
97 |
98 | if (resultCode == RESULT_OK) {
99 | // Debug.printToast("Result Code is OK", getApplicationContext());
100 |
101 | String name = data.getStringExtra(CreditCardUtils.EXTRA_CARD_HOLDER_NAME);
102 | String cardNumber = data.getStringExtra(CreditCardUtils.EXTRA_CARD_NUMBER);
103 | String expiry = data.getStringExtra(CreditCardUtils.EXTRA_CARD_EXPIRY);
104 | String cvv = data.getStringExtra(CreditCardUtils.EXTRA_CARD_CVV);
105 |
106 | if (reqCode == CREATE_NEW_CARD) {
107 |
108 | CreditCardView creditCardView = new CreditCardView(this);
109 |
110 | creditCardView.setCVV(cvv);
111 | creditCardView.setCardHolderName(name);
112 | creditCardView.setCardExpiry(expiry);
113 | creditCardView.setCardNumber(cardNumber);
114 |
115 | cardContainer.addView(creditCardView);
116 | int index = cardContainer.getChildCount() - 1;
117 | addCardListener(index, creditCardView);
118 |
119 | } else {
120 |
121 | CreditCardView creditCardView = (CreditCardView) cardContainer.getChildAt(reqCode);
122 |
123 | creditCardView.setCardExpiry(expiry);
124 | creditCardView.setCardNumber(cardNumber);
125 | creditCardView.setCardHolderName(name);
126 | creditCardView.setCVV(cvv);
127 |
128 | }
129 | }
130 |
131 | }
132 |
133 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sharish/CreditCardView/9ac891404756997b4ecf0f06526ddb11314530bf/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sharish/CreditCardView/9ac891404756997b4ecf0f06526ddb11314530bf/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sharish/CreditCardView/9ac891404756997b4ecf0f06526ddb11314530bf/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sharish/CreditCardView/9ac891404756997b4ecf0f06526ddb11314530bf/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 | >
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 12dp
6 | 18dp
7 | 16dp
8 | 2dp
9 | 19sp
10 | 20sp
11 | 8dp
12 | 16dp
13 | 20dp
14 | 16sp
15 |
16 |
17 | #88FFFFFF
18 | #FBFBFB
19 | #ff9e9e9e
20 | #7F000000
21 | #FFFFFF
22 |
23 | 2dp
24 | 1dp
25 | 16dp
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | CheckoutFlow
3 |
4 | Hello world!
5 | Settings
6 |
7 | NEXT
8 | PREVIOUS
9 | DONE
10 | CreditCardView Sample
11 | 22
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.2'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | maven{
19 | url "https://jitpack.io"
20 | }
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/creditcarddesign/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 |
5 | compileSdkVersion 25
6 | buildToolsVersion "25.0.1"
7 | defaultConfig {
8 | vectorDrawables.useSupportLibrary = true
9 | minSdkVersion 10
10 | targetSdkVersion 25
11 | versionCode 1
12 | versionName "1.0.3"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | final SUPPORT_VERSION = "25.0.1"
24 | compile fileTree(dir: 'libs', include: ['*.jar'])
25 | compile "com.android.support:appcompat-v7:$SUPPORT_VERSION"
26 | compile "com.android.support:cardview-v7:$SUPPORT_VERSION"
27 | compile 'com.github.ozodrukh:CircularReveal:1.0.5'
28 | }
29 |
--------------------------------------------------------------------------------
/creditcarddesign/creditcarddesign.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/creditcarddesign/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/Harish/Android_SDK/android-sdk-macosx/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/CardEditActivity.java:
--------------------------------------------------------------------------------
1 | package com.cooltechworks.creditcarddesign;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.content.res.Configuration;
6 | import android.os.Bundle;
7 | import android.support.v4.view.ViewPager;
8 | import android.support.v7.app.AppCompatActivity;
9 | import android.view.View;
10 | import android.view.WindowManager;
11 | import android.view.inputmethod.InputMethodManager;
12 | import android.widget.EditText;
13 | import android.widget.RelativeLayout;
14 | import android.widget.TextView;
15 |
16 | import com.cooltechworks.creditcarddesign.pager.CardFragmentAdapter;
17 | import com.cooltechworks.creditcarddesign.pager.CardFragmentAdapter.ICardEntryCompleteListener;
18 |
19 | import static com.cooltechworks.creditcarddesign.CreditCardUtils.CARD_NAME_PAGE;
20 | import static com.cooltechworks.creditcarddesign.CreditCardUtils.EXTRA_CARD_CVV;
21 | import static com.cooltechworks.creditcarddesign.CreditCardUtils.EXTRA_CARD_EXPIRY;
22 | import static com.cooltechworks.creditcarddesign.CreditCardUtils.EXTRA_CARD_HOLDER_NAME;
23 | import static com.cooltechworks.creditcarddesign.CreditCardUtils.EXTRA_CARD_NUMBER;
24 | import static com.cooltechworks.creditcarddesign.CreditCardUtils.EXTRA_ENTRY_START_PAGE;
25 |
26 |
27 | public class CardEditActivity extends AppCompatActivity {
28 |
29 |
30 | int mLastPageSelected = 0;
31 | private CreditCardView mCreditCardView;
32 |
33 | private String mCardNumber;
34 | private String mCVV;
35 | private String mCardHolderName;
36 | private String mExpiry;
37 | private int mStartPage = 0;
38 | private CardFragmentAdapter mCardAdapter;
39 |
40 | @Override
41 | protected void onCreate(Bundle savedInstanceState) {
42 | super.onCreate(savedInstanceState);
43 | setContentView(R.layout.activity_card_edit);
44 |
45 | findViewById(R.id.next).setOnClickListener(new View.OnClickListener() {
46 | @Override
47 | public void onClick(View v) {
48 |
49 | ViewPager pager = (ViewPager) findViewById(R.id.card_field_container_pager);
50 |
51 | int max = pager.getAdapter().getCount();
52 |
53 | if (pager.getCurrentItem() == max - 1) {
54 | // if last card.
55 | onDoneTapped();
56 | } else {
57 | showNext();
58 | }
59 | }
60 | });
61 | findViewById(R.id.previous).setOnClickListener(new View.OnClickListener() {
62 | @Override
63 | public void onClick(View v) {
64 | showPrevious();
65 | }
66 | });
67 |
68 | setKeyboardVisibility(true);
69 | mCreditCardView = (CreditCardView) findViewById(R.id.credit_card_view);
70 | Bundle args = savedInstanceState != null ? savedInstanceState : getIntent().getExtras();
71 |
72 | loadPager(args);
73 | checkParams(args);
74 | }
75 |
76 | private void checkParams(Bundle bundle) {
77 | if (bundle == null) {
78 | return;
79 | }
80 | mCardHolderName = bundle.getString(EXTRA_CARD_HOLDER_NAME);
81 | mCVV = bundle.getString(EXTRA_CARD_CVV);
82 | mExpiry = bundle.getString(EXTRA_CARD_EXPIRY);
83 | mCardNumber = bundle.getString(EXTRA_CARD_NUMBER);
84 | mStartPage = bundle.getInt(EXTRA_ENTRY_START_PAGE);
85 |
86 | final int maxCvvLength = CardSelector.selectCard(mCardNumber).getCvvLength();
87 | if (mCVV != null && mCVV.length() > maxCvvLength) {
88 | mCVV = mCVV.substring(0, maxCvvLength);
89 | }
90 |
91 | mCreditCardView.setCVV(mCVV);
92 | mCreditCardView.setCardHolderName(mCardHolderName);
93 | mCreditCardView.setCardExpiry(mExpiry);
94 | mCreditCardView.setCardNumber(mCardNumber);
95 |
96 | if (mCardAdapter != null) {
97 | mCreditCardView.post(new Runnable() {
98 | @Override
99 | public void run() {
100 | mCardAdapter.setMaxCVV(maxCvvLength);
101 | mCardAdapter.notifyDataSetChanged();
102 | }});
103 | }
104 |
105 | int cardSide = bundle.getInt(CreditCardUtils.EXTRA_CARD_SHOW_CARD_SIDE, CreditCardUtils.CARD_SIDE_FRONT);
106 | if (cardSide == CreditCardUtils.CARD_SIDE_BACK) {
107 | mCreditCardView.showBack();
108 | }
109 | if (mStartPage > 0 && mStartPage <= CARD_NAME_PAGE) {
110 | getViewPager().setCurrentItem(mStartPage);
111 | }
112 | }
113 |
114 | public void refreshNextButton() {
115 | ViewPager pager = (ViewPager) findViewById(R.id.card_field_container_pager);
116 |
117 | int max = pager.getAdapter().getCount();
118 |
119 | int text = R.string.next;
120 |
121 | if (pager.getCurrentItem() == max - 1) {
122 | text = R.string.done;
123 | }
124 |
125 | ((TextView) findViewById(R.id.next)).setText(text);
126 | }
127 |
128 | ViewPager getViewPager() {
129 | return (ViewPager) findViewById(R.id.card_field_container_pager);
130 | }
131 |
132 | public void loadPager(Bundle bundle) {
133 | ViewPager pager = getViewPager();
134 | pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
135 | @Override
136 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
137 | }
138 |
139 | @Override
140 | public void onPageSelected(int position) {
141 |
142 | mCardAdapter.focus(position);
143 |
144 | if ((mCreditCardView.getCardType() != CreditCardUtils.CardType.AMEX_CARD) && (position == 2)) {
145 | mCreditCardView.showBack();
146 | } else if (((position == 1) || (position == 3)) && (mLastPageSelected == 2) && (mCreditCardView.getCardType() != CreditCardUtils.CardType.AMEX_CARD)) {
147 | mCreditCardView.showFront();
148 | }
149 |
150 | mLastPageSelected = position;
151 |
152 | refreshNextButton();
153 |
154 | }
155 |
156 | @Override
157 | public void onPageScrollStateChanged(int state) {
158 | }
159 | });
160 | pager.setOffscreenPageLimit(4);
161 |
162 | mCardAdapter = new CardFragmentAdapter(getSupportFragmentManager(), bundle);
163 | mCardAdapter.setOnCardEntryCompleteListener(new ICardEntryCompleteListener() {
164 | @Override
165 | public void onCardEntryComplete(int currentIndex) {
166 | showNext();
167 | }
168 |
169 | @Override
170 | public void onCardEntryEdit(int currentIndex, String entryValue) {
171 | switch (currentIndex) {
172 | case 0:
173 | mCardNumber = entryValue.replace(CreditCardUtils.SPACE_SEPERATOR, "");
174 | mCreditCardView.setCardNumber(mCardNumber);
175 | if (mCardAdapter != null) {
176 | mCardAdapter.setMaxCVV(CardSelector.selectCard(mCardNumber).getCvvLength());
177 | }
178 | break;
179 | case 1:
180 | mExpiry = entryValue;
181 | mCreditCardView.setCardExpiry(entryValue);
182 | break;
183 | case 2:
184 | mCVV = entryValue;
185 | mCreditCardView.setCVV(entryValue);
186 | break;
187 | case 3:
188 | mCardHolderName = entryValue;
189 | mCreditCardView.setCardHolderName(entryValue);
190 | break;
191 | }
192 | }
193 | });
194 |
195 | pager.setAdapter(mCardAdapter);
196 | }
197 |
198 | public void onSaveInstanceState(Bundle outState) {
199 | outState.putString(EXTRA_CARD_CVV, mCVV);
200 | outState.putString(EXTRA_CARD_HOLDER_NAME, mCardHolderName);
201 | outState.putString(EXTRA_CARD_EXPIRY, mExpiry);
202 | outState.putString(EXTRA_CARD_NUMBER, mCardNumber);
203 |
204 | super.onSaveInstanceState(outState);
205 | }
206 |
207 | public void onRestoreInstanceState(Bundle inState) {
208 | super.onRestoreInstanceState(inState);
209 | checkParams(inState);
210 | }
211 |
212 |
213 | public void showPrevious() {
214 | final ViewPager pager = (ViewPager) findViewById(R.id.card_field_container_pager);
215 | int currentIndex = pager.getCurrentItem();
216 |
217 | if (currentIndex == 0) {
218 | setResult(RESULT_CANCELED);
219 | finish();
220 | }
221 |
222 | if (currentIndex - 1 >= 0) {
223 | pager.setCurrentItem(currentIndex - 1);
224 | }
225 |
226 | refreshNextButton();
227 | }
228 |
229 | public void showNext() {
230 | final ViewPager pager = (ViewPager) findViewById(R.id.card_field_container_pager);
231 | CardFragmentAdapter adapter = (CardFragmentAdapter) pager.getAdapter();
232 |
233 | int max = adapter.getCount();
234 | int currentIndex = pager.getCurrentItem();
235 |
236 | if (currentIndex + 1 < max) {
237 |
238 | pager.setCurrentItem(currentIndex + 1);
239 | } else {
240 | // completed the card entry.
241 | setKeyboardVisibility(false);
242 | }
243 |
244 | refreshNextButton();
245 | }
246 |
247 | private void onDoneTapped() {
248 | Intent intent = new Intent();
249 |
250 | intent.putExtra(EXTRA_CARD_CVV, mCVV);
251 | intent.putExtra(EXTRA_CARD_HOLDER_NAME, mCardHolderName);
252 | intent.putExtra(EXTRA_CARD_EXPIRY, mExpiry);
253 | intent.putExtra(EXTRA_CARD_NUMBER, mCardNumber);
254 |
255 | setResult(RESULT_OK, intent);
256 | finish();
257 | }
258 |
259 | // from the link above
260 | @Override
261 | public void onConfigurationChanged(Configuration newConfig) {
262 | super.onConfigurationChanged(newConfig);
263 |
264 | // Checks whether a hardware keyboard is available
265 | if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
266 |
267 | RelativeLayout parent = (RelativeLayout) findViewById(R.id.parent);
268 | RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) parent.getLayoutParams();
269 | layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, 0);
270 | parent.setLayoutParams(layoutParams);
271 |
272 | }
273 | }
274 |
275 | private void setKeyboardVisibility(boolean visible) {
276 | final EditText editText = (EditText) findViewById(R.id.card_number_field);
277 |
278 | if (!visible) {
279 |
280 | InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
281 | imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
282 | } else {
283 | getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
284 | }
285 | }
286 |
287 | @Override
288 | public void onBackPressed() {
289 | this.finish();
290 | }
291 | }
292 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/CardSelector.java:
--------------------------------------------------------------------------------
1 | package com.cooltechworks.creditcarddesign;
2 |
3 | /**
4 | * Created by Harish on 01/01/16.
5 | */
6 | public class CardSelector {
7 |
8 | public static final CardSelector VISA = new CardSelector(R.drawable.card_color_round_rect_purple, R.drawable.chip, R.drawable.chip_inner, android.R.color.transparent, R.drawable.ic_billing_visa_logo, CardSelector.CVV_LENGHT_DEFAULT);
9 | public static final CardSelector MASTER = new CardSelector(R.drawable.card_color_round_rect_pink, R.drawable.chip_yellow, R.drawable.chip_yellow_inner, android.R.color.transparent, R.drawable.ic_billing_mastercard_logo, CardSelector.CVV_LENGHT_DEFAULT);
10 | public static final CardSelector AMEX = new CardSelector(R.drawable.card_color_round_rect_green, android.R.color.transparent, android.R.color.transparent, R.drawable.img_amex_center_face, R.drawable.ic_billing_amex_logo1, CardSelector.CVV_LENGHT_AMEX);
11 | public static final CardSelector DISCOVER = new CardSelector(R.drawable.card_color_round_rect_brown, android.R.color.transparent, android.R.color.transparent, android.R.color.transparent, R.drawable.ic_billing_discover_logo, CardSelector.CVV_LENGHT_DEFAULT);
12 | public static final CardSelector DEFAULT = new CardSelector(R.drawable.card_color_round_rect_default, R.drawable.chip, R.drawable.chip_inner, android.R.color.transparent, android.R.color.transparent, CardSelector.CVV_LENGHT_DEFAULT);
13 |
14 | public static final int CVV_LENGHT_DEFAULT = 3;
15 | public static final int CVV_LENGHT_AMEX = 4;
16 |
17 |
18 | private int mResCardId;
19 | private int mResChipOuterId;
20 | private int mResChipInnerId;
21 | private int mResCenterImageId;
22 | private int mResLogoId;
23 | private int mCvvLength = CVV_LENGHT_DEFAULT;
24 |
25 | public CardSelector(int mDrawableCard, int mDrawableChipOuter, int mDrawableChipInner, int mDrawableCenterImage, int logoId, int cvvLength) {
26 | this.mResCardId = mDrawableCard;
27 | this.mResChipOuterId = mDrawableChipOuter;
28 | this.mResChipInnerId = mDrawableChipInner;
29 | this.mResCenterImageId = mDrawableCenterImage;
30 | this.mResLogoId = logoId;
31 | this.mCvvLength = cvvLength;
32 | }
33 |
34 | public int getResCardId() {
35 | return mResCardId;
36 | }
37 |
38 | public void setResCardId(int mResCardId) {
39 | this.mResCardId = mResCardId;
40 | }
41 |
42 | public int getResChipOuterId() {
43 | return mResChipOuterId;
44 | }
45 |
46 | public void setResChipOuterId(int mResChipOuterId) {
47 | this.mResChipOuterId = mResChipOuterId;
48 | }
49 |
50 | public int getResChipInnerId() {
51 | return mResChipInnerId;
52 | }
53 |
54 | public void setResChipInnerId(int mResChipInnerId) {
55 | this.mResChipInnerId = mResChipInnerId;
56 | }
57 |
58 | public int getResCenterImageId() {
59 | return mResCenterImageId;
60 | }
61 |
62 | public void setResCenterImageId(int mResCenterImageId) {
63 | this.mResCenterImageId = mResCenterImageId;
64 | }
65 |
66 | public int getResLogoId() {
67 | return mResLogoId;
68 | }
69 |
70 | public void setResLogoId(int mResLogoId) {
71 | this.mResLogoId = mResLogoId;
72 | }
73 |
74 | public int getCvvLength() {
75 | return mCvvLength;
76 | }
77 |
78 | public void setCvvLength(int mCvvLength) {
79 | this.mCvvLength = mCvvLength;
80 | }
81 |
82 | public static CardSelector selectCardType(CreditCardUtils.CardType cardType) {
83 | switch(cardType) {
84 | case AMEX_CARD:
85 | return AMEX;
86 | case DISCOVER_CARD:
87 | return DISCOVER;
88 | case MASTER_CARD:
89 | return MASTER;
90 | case VISA_CARD:
91 | return VISA;
92 | default:
93 | return DEFAULT;
94 | }
95 | }
96 |
97 | public static CardSelector selectCard(String cardNumber) {
98 | if (cardNumber != null && cardNumber.length() >= 1) {
99 | CreditCardUtils.CardType cardType = CreditCardUtils.selectCardType(cardNumber);
100 | CardSelector selector = selectCardType(cardType);
101 |
102 | if ((selector != DEFAULT) && (cardNumber.length() >= 3)) {
103 | int[] drawables = {R.drawable.card_color_round_rect_brown, R.drawable.card_color_round_rect_green, R.drawable.card_color_round_rect_pink, R.drawable.card_color_round_rect_purple, R.drawable.card_color_round_rect_blue};
104 | int hash = cardNumber.substring(0, 3).hashCode();
105 |
106 | if (hash < 0) {
107 | hash = hash * -1;
108 | }
109 |
110 | int index = hash % drawables.length;
111 |
112 | int chipIndex = hash % 3;
113 | int[] chipOuter = {R.drawable.chip, R.drawable.chip_yellow, android.R.color.transparent};
114 | int[] chipInner = {R.drawable.chip_inner, R.drawable.chip_yellow_inner, android.R.color.transparent};
115 |
116 | selector.setResCardId(drawables[index]);
117 | selector.setResChipOuterId(chipOuter[chipIndex]);
118 | selector.setResChipInnerId(chipInner[chipIndex]);
119 |
120 | return selector;
121 | }
122 | }
123 |
124 | return DEFAULT;
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/CreditCardUtils.java:
--------------------------------------------------------------------------------
1 | package com.cooltechworks.creditcarddesign;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | import java.util.Calendar;
6 | import java.util.regex.Pattern;
7 |
8 | /**
9 | * Created by Harish on 03/01/16.
10 | */
11 | public class CreditCardUtils {
12 | public enum CardType {
13 | UNKNOWN_CARD, AMEX_CARD, MASTER_CARD, VISA_CARD, DISCOVER_CARD
14 | }
15 |
16 | private static final String PATTERN_AMEX = "^3(4|7)[0-9 ]*";
17 | private static final String PATTERN_VISA = "^4[0-9 ]*";
18 | private static final String PATTERN_MASTER = "^5[0-9 ]*";
19 | private static final String PATTERN_DISCOVER = "^6[0-9 ]*";
20 |
21 | public static final int MAX_LENGTH_CARD_NUMBER = 16;
22 | public static final int MAX_LENGTH_CARD_NUMBER_AMEX = 15;
23 |
24 | public static final String CARD_NUMBER_FORMAT = "XXXX XXXX XXXX XXXX";
25 | public static final String CARD_NUMBER_FORMAT_AMEX = "XXXX XXXXXX XXXXX";
26 |
27 | public static final String EXTRA_CARD_NUMBER = "card_number";
28 | public static final String EXTRA_CARD_CVV = "card_cvv";
29 | public static final String EXTRA_CARD_EXPIRY = "card_expiry";
30 | public static final String EXTRA_CARD_HOLDER_NAME = "card_holder_name";
31 | public static final String EXTRA_CARD_SHOW_CARD_SIDE = "card_side";
32 | public static final String EXTRA_VALIDATE_EXPIRY_DATE = "expiry_date";
33 | public static final String EXTRA_ENTRY_START_PAGE = "start_page";
34 |
35 | public static final int CARD_SIDE_FRONT = 1,CARD_SIDE_BACK=0;
36 |
37 | public static final int CARD_NUMBER_PAGE = 0, CARD_EXPIRY_PAGE = 1;
38 | public static final int CARD_CVV_PAGE = 2, CARD_NAME_PAGE = 3;
39 |
40 | public static final String SPACE_SEPERATOR = " ";
41 | public static final String SLASH_SEPERATOR = "/";
42 | public static final char CHAR_X = 'X';
43 |
44 | public static String handleCardNumber(String inputCardNumber) {
45 |
46 | return handleCardNumber(inputCardNumber,SPACE_SEPERATOR);
47 | }
48 |
49 | public static CardType selectCardType(String cardNumber) {
50 | Pattern pCardType = Pattern.compile(PATTERN_VISA);
51 | if(pCardType.matcher(cardNumber).matches())
52 | return CardType.VISA_CARD;
53 | pCardType = Pattern.compile(PATTERN_MASTER);
54 | if(pCardType.matcher(cardNumber).matches())
55 | return CardType.MASTER_CARD;
56 | pCardType = Pattern.compile(PATTERN_AMEX);
57 | if(pCardType.matcher(cardNumber).matches())
58 | return CardType.AMEX_CARD;
59 | pCardType = Pattern.compile(PATTERN_DISCOVER);
60 | if(pCardType.matcher(cardNumber).matches())
61 | return CardType.DISCOVER_CARD;
62 | return CardType.UNKNOWN_CARD;
63 | }
64 |
65 | public static int selectCardLength(CardType cardType) {
66 | return cardType == CardType.AMEX_CARD ? MAX_LENGTH_CARD_NUMBER_AMEX : MAX_LENGTH_CARD_NUMBER;
67 | }
68 |
69 | public static String handleCardNumber(String inputCardNumber, String seperator) {
70 | String unformattedText = inputCardNumber.replace(seperator, "");
71 | CardType cardType = selectCardType(inputCardNumber);
72 | String format = (cardType == CardType.AMEX_CARD) ? CARD_NUMBER_FORMAT_AMEX : CARD_NUMBER_FORMAT;
73 | StringBuilder sbFormattedNumber = new StringBuilder();
74 | for(int iIdx = 0, jIdx = 0; (iIdx < format.length()) && (unformattedText.length() > jIdx); iIdx++) {
75 | if(format.charAt(iIdx) == CHAR_X)
76 | sbFormattedNumber.append(unformattedText.charAt(jIdx++));
77 | else
78 | sbFormattedNumber.append(format.charAt(iIdx));
79 | }
80 |
81 | return sbFormattedNumber.toString();
82 | }
83 |
84 | public static String formatCardNumber(String inputCardNumber, String seperator) {
85 | String unformattedText = inputCardNumber.replace(seperator, "");
86 | CardType cardType = selectCardType(inputCardNumber);
87 | String format = (cardType == CardType.AMEX_CARD) ? CARD_NUMBER_FORMAT_AMEX : CARD_NUMBER_FORMAT;
88 | StringBuilder sbFormattedNumber = new StringBuilder();
89 | for(int iIdx = 0, jIdx = 0; iIdx < format.length(); iIdx++) {
90 | if((format.charAt(iIdx) == CHAR_X) && (unformattedText.length() > jIdx))
91 | sbFormattedNumber.append(unformattedText.charAt(jIdx++));
92 | else
93 | sbFormattedNumber.append(format.charAt(iIdx));
94 | }
95 |
96 | return sbFormattedNumber.toString().replace(SPACE_SEPERATOR, SPACE_SEPERATOR + SPACE_SEPERATOR);
97 | }
98 |
99 | public static String handleExpiration(String month, String year) {
100 |
101 | return handleExpiration(month+year);
102 | }
103 |
104 |
105 | public static String handleExpiration(@NonNull String dateYear) {
106 |
107 | String expiryString = dateYear.replace(SLASH_SEPERATOR, "");
108 |
109 | String text;
110 | if(expiryString.length() >= 2) {
111 | String mm = expiryString.substring(0, 2);
112 | String yy;
113 | text = mm;
114 |
115 | try {
116 | if (Integer.parseInt(mm) > 12) {
117 | mm = "12"; // Cannot be more than 12.
118 | }
119 | }
120 | catch (Exception e) {
121 | mm = "01";
122 | }
123 |
124 | if(expiryString.length() >=4) {
125 | yy = expiryString.substring(2,4);
126 |
127 | try{
128 | Integer.parseInt(yy);
129 | }catch (Exception e) {
130 |
131 | Calendar calendar = Calendar.getInstance();
132 | int year = calendar.get(Calendar.YEAR);
133 | yy = String.valueOf(year).substring(2);
134 | }
135 |
136 | text = mm + SLASH_SEPERATOR + yy;
137 |
138 | }
139 | else if(expiryString.length() > 2){
140 | yy = expiryString.substring(2);
141 | text = mm + SLASH_SEPERATOR + yy;
142 | }
143 | }
144 | else {
145 | text = expiryString;
146 | }
147 |
148 | return text;
149 | }
150 | }
151 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/CreditCardView.java:
--------------------------------------------------------------------------------
1 | package com.cooltechworks.creditcarddesign;
2 |
3 | import android.animation.Animator;
4 | import android.animation.AnimatorListenerAdapter;
5 | import android.content.Context;
6 | import android.content.res.TypedArray;
7 | import android.os.Build;
8 | import android.os.Handler;
9 | import android.util.AttributeSet;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.animation.AccelerateDecelerateInterpolator;
13 | import android.view.animation.OvershootInterpolator;
14 | import android.widget.FrameLayout;
15 | import android.widget.ImageView;
16 | import android.widget.TextView;
17 |
18 | import io.codetail.animation.SupportAnimator;
19 | import io.codetail.animation.ViewAnimationUtils;
20 |
21 | /**
22 | * Created by Harish on 03/01/16.
23 | */
24 | public class CreditCardView extends FrameLayout {
25 |
26 | private static final int TEXTVIEW_CARD_HOLDER_ID = R.id.front_card_holder_name;
27 | private static final int TEXTVIEW_CARD_EXPIRY_ID = R.id.front_card_expiry;
28 | private static final int TEXTVIEW_CARD_NUMBER_ID = R.id.front_card_number;
29 | private static final int TEXTVIEW_CARD_CVV_ID = R.id.back_card_cvv;
30 | private static final int TEXTVIEW_CARD_CVV_AMEX_ID = R.id.front_card_cvv;
31 | private static final int FRONT_CARD_ID = R.id.front_card_container;
32 | private static final int BACK_CARD_ID = R.id.back_card_container;
33 | private static final int FRONT_CARD_OUTLINE_ID = R.id.front_card_outline;
34 | private static final int BACK_CARD_OUTLINE_ID = R.id.back_card_outline;
35 |
36 |
37 | private int mCurrentDrawable;
38 | private String mRawCardNumber;
39 | private ICustomCardSelector mSelectorLogic;
40 |
41 | private String mCardHolderName, mCVV, mExpiry;
42 |
43 | private CreditCardUtils.CardType mCardType;
44 |
45 | private boolean changeCardColor;
46 | private boolean showCardAnimation;
47 |
48 | int mCardnameLen;
49 |
50 | public CreditCardView(Context context) {
51 | super(context);
52 | init();
53 | }
54 |
55 | public CreditCardView(Context context, AttributeSet attrs) {
56 | super(context, attrs);
57 | init(attrs);
58 | }
59 |
60 | public CreditCardView(Context context, AttributeSet attrs, int defStyleAttr) {
61 | super(context, attrs, defStyleAttr);
62 | init(attrs);
63 | }
64 |
65 | public String getCardHolderName() {
66 | return mCardHolderName;
67 | }
68 |
69 | public String getCVV() {
70 | return mCVV;
71 | }
72 |
73 | public String getExpiry() {
74 | return mExpiry;
75 | }
76 |
77 | public CreditCardUtils.CardType getCardType() { return mCardType; }
78 |
79 | interface ICustomCardSelector {
80 | CardSelector getCardSelector(String cardNumber);
81 | }
82 |
83 | private void init() {
84 |
85 | mCurrentDrawable = R.drawable.card_color_round_rect_default;
86 | mRawCardNumber = "";
87 | mCardnameLen = getResources().getInteger(R.integer.card_name_len);
88 | LayoutInflater inflater = (LayoutInflater) getContext()
89 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
90 | inflater.inflate(R.layout.view_creditcard, this, true);
91 |
92 | }
93 |
94 | private void init(AttributeSet attrs) {
95 |
96 | init();
97 |
98 | TypedArray a = getContext().obtainStyledAttributes(attrs,
99 | R.styleable.creditcard, 0, 0);
100 |
101 |
102 | String cardHolderName = a.getString(R.styleable.creditcard_card_holder_name);
103 | String expiry = a.getString(R.styleable.creditcard_card_expiration);
104 | String cardNumber = a.getString(R.styleable.creditcard_card_number);
105 |
106 | changeCardColor = a.getBoolean(R.styleable.creditcard_change_card_color, true);
107 | showCardAnimation = a.getBoolean(R.styleable.creditcard_show_card_animation, true);
108 | boolean showChipOnCard = a.getBoolean(R.styleable.creditcard_show_chip_on_card, true);
109 | if(!showChipOnCard) {
110 | View chipContainer = findViewById(R.id.chip_container);
111 | if(chipContainer != null) {
112 | chipContainer.setVisibility(View.INVISIBLE);
113 | }
114 | }
115 |
116 | int cvv = a.getInt(R.styleable.creditcard_cvv, 0);
117 | int cardSide = a.getInt(R.styleable.creditcard_card_side,CreditCardUtils.CARD_SIDE_FRONT);
118 |
119 | setCardNumber(cardNumber);
120 | setCVV(cvv);
121 | setCardExpiry(expiry);
122 | setCardHolderName(cardHolderName);
123 |
124 | if(cardSide == CreditCardUtils.CARD_SIDE_BACK) {
125 | showBackImmediate();
126 | }
127 |
128 | paintCard();
129 |
130 | a.recycle();
131 |
132 | }
133 |
134 |
135 | private void flip(final boolean ltr, boolean isImmediate) {
136 |
137 | View layoutContainer = findViewById(R.id.card_outline_container);
138 | View frontView = findViewById(FRONT_CARD_OUTLINE_ID);
139 | View backView = findViewById(BACK_CARD_OUTLINE_ID);
140 |
141 | final View frontContentView = findViewById(FRONT_CARD_ID);
142 | final View backContentView = findViewById(BACK_CARD_ID);
143 | View layoutContentContainer = findViewById(R.id.card_container);
144 |
145 |
146 | if(isImmediate) {
147 | frontContentView.setVisibility(ltr?VISIBLE:GONE);
148 | backContentView.setVisibility(ltr?GONE:VISIBLE);
149 |
150 | }
151 | else {
152 |
153 | int duration = 600;
154 |
155 | FlipAnimator flipAnimator = new FlipAnimator(frontView, backView, frontView.getWidth() / 2, backView.getHeight() / 2);
156 | flipAnimator.setInterpolator(new OvershootInterpolator(0.5f));
157 | flipAnimator.setDuration(duration);
158 |
159 | if (ltr) {
160 | flipAnimator.reverse();
161 | }
162 |
163 | flipAnimator.setTranslateDirection(FlipAnimator.DIRECTION_Z);
164 | flipAnimator.setRotationDirection(FlipAnimator.DIRECTION_Y);
165 | layoutContainer.startAnimation(flipAnimator);
166 |
167 | FlipAnimator flipAnimator1 = new FlipAnimator(frontContentView, backContentView, frontContentView.getWidth() / 2, backContentView.getHeight() / 2);
168 | flipAnimator1.setInterpolator(new OvershootInterpolator(0.5f));
169 | flipAnimator1.setDuration(duration);
170 |
171 | if (ltr) {
172 | flipAnimator1.reverse();
173 | }
174 |
175 | flipAnimator1.setTranslateDirection(FlipAnimator.DIRECTION_Z);
176 | flipAnimator1.setRotationDirection(FlipAnimator.DIRECTION_Y);
177 |
178 | layoutContentContainer.startAnimation(flipAnimator1);
179 | }
180 |
181 | }
182 |
183 | public void setCardNumber(String rawCardNumber) {
184 |
185 |
186 | this.mRawCardNumber = rawCardNumber == null ? "" : rawCardNumber;
187 | this.mCardType = CreditCardUtils.selectCardType(this.mRawCardNumber);
188 | String cardNumber = CreditCardUtils.formatCardNumber(this.mRawCardNumber, CreditCardUtils.SPACE_SEPERATOR);
189 |
190 | ((TextView)findViewById(TEXTVIEW_CARD_NUMBER_ID)).setText(cardNumber);
191 | ((TextView)findViewById(TEXTVIEW_CARD_CVV_AMEX_ID)).setVisibility(mCardType == CreditCardUtils.CardType.AMEX_CARD ? View.VISIBLE : View.GONE);
192 |
193 | if(this.mCardType != CreditCardUtils.CardType.UNKNOWN_CARD) {
194 | this.post(new Runnable() {
195 | @Override
196 | public void run() {
197 | revealCardAnimation();
198 | }
199 | });
200 | }
201 | else {
202 | paintCard();
203 | }
204 |
205 | }
206 |
207 | public void setCVV(int cvvInt) {
208 |
209 | if(cvvInt == 0) {
210 | setCVV("");
211 | }
212 | else {
213 | String cvv = String.valueOf(cvvInt);
214 | setCVV(cvv);
215 | }
216 |
217 | }
218 |
219 | public void showFront() {
220 | flip(true,false);
221 | }
222 |
223 | public void showFrontImmediate() {
224 | flip(true,true);
225 | }
226 |
227 | public void showBack() {
228 | flip(false,false);
229 | }
230 |
231 | public void showBackImmediate() {
232 | flip(false,true);
233 | }
234 |
235 | public void setCVV(String cvv) {
236 | if(cvv == null) {
237 | cvv = "";
238 | }
239 |
240 | this.mCVV = cvv;
241 | ((TextView)findViewById(TEXTVIEW_CARD_CVV_ID)).setText(cvv);
242 | ((TextView)findViewById(TEXTVIEW_CARD_CVV_AMEX_ID)).setText(cvv);
243 | }
244 |
245 | public void setCardExpiry(String dateYear) {
246 |
247 | dateYear = dateYear == null ? "": CreditCardUtils.handleExpiration(dateYear);
248 |
249 | this.mExpiry = dateYear;
250 |
251 | ((TextView) findViewById(TEXTVIEW_CARD_EXPIRY_ID)).setText(dateYear);
252 |
253 |
254 | }
255 |
256 | public void setCardHolderName(String cardHolderName) {
257 |
258 | cardHolderName = cardHolderName == null ? "" : cardHolderName;
259 | if(cardHolderName.length() > mCardnameLen) {
260 | cardHolderName = cardHolderName.substring(0,mCardnameLen);
261 | }
262 |
263 | this.mCardHolderName = cardHolderName;
264 |
265 | ((TextView)findViewById(TEXTVIEW_CARD_HOLDER_ID)).setText(cardHolderName);
266 | }
267 |
268 | public void paintCard() {
269 |
270 | CardSelector card = selectCard();
271 |
272 | View cardContainer = findViewById(R.id.card_outline_container);
273 |
274 | View chipContainer = findViewById(R.id.chip_container);
275 | View chipInner = findViewById(R.id.chip_inner_view);
276 |
277 | View cardBack = findViewById(BACK_CARD_OUTLINE_ID);
278 | View cardFront = findViewById(FRONT_CARD_OUTLINE_ID);
279 |
280 |
281 | chipContainer.setBackgroundResource(card.getResChipOuterId());
282 | chipInner.setBackgroundResource(card.getResChipInnerId());
283 |
284 | ImageView frontLogoImageView = (ImageView) cardContainer.findViewById(R.id.logo_img);
285 | frontLogoImageView.setImageResource(card.getResLogoId());
286 |
287 | ImageView centerImageView = (ImageView) cardContainer.findViewById(R.id.logo_center_img);
288 | centerImageView.setImageResource(card.getResCenterImageId());
289 |
290 |
291 | ImageView backLogoImageView = (ImageView) findViewById(BACK_CARD_ID).findViewById(R.id.logo_img);
292 | backLogoImageView.setImageResource(card.getResLogoId());
293 |
294 | if(changeCardColor) {
295 | cardBack.setBackgroundResource(card.getResCardId());
296 | cardFront.setBackgroundResource(card.getResCardId());
297 | }
298 | }
299 |
300 |
301 | public void revealCardAnimation() {
302 |
303 | CardSelector card = selectCard();
304 |
305 | View cardFront = findViewById(FRONT_CARD_OUTLINE_ID);
306 | View cardContainer = findViewById(R.id.card_outline_container);
307 |
308 | paintCard();
309 |
310 | if(showCardAnimation && changeCardColor) {
311 | animateChange(cardContainer, cardFront, card.getResCardId());
312 | }
313 | }
314 |
315 | public CardSelector selectCard() {
316 | if(mSelectorLogic != null) {
317 | return mSelectorLogic.getCardSelector(mRawCardNumber);
318 | }
319 | return CardSelector.selectCard(mRawCardNumber);
320 | }
321 |
322 | public void animateChange(final View cardContainer, final View v, final int drawableId) {
323 | showAnimation(cardContainer, v, drawableId);
324 | }
325 |
326 | public void showAnimation(final View cardContainer, final View v, final int drawableId) {
327 |
328 | final View mRevealView = v;
329 | mRevealView.setBackgroundResource(drawableId);
330 |
331 | if (mCurrentDrawable == drawableId) {
332 | return;
333 | }
334 |
335 | int duration = 1000;
336 | int cx = mRevealView.getLeft();
337 | int cy = mRevealView.getTop();
338 |
339 | int radius = Math.max(mRevealView.getWidth(), mRevealView.getHeight()) * 4;
340 |
341 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
342 |
343 |
344 | SupportAnimator animator =
345 | ViewAnimationUtils.createCircularReveal(mRevealView, cx, cy, 0, radius);
346 | animator.setInterpolator(new AccelerateDecelerateInterpolator());
347 | animator.setDuration(duration);
348 |
349 | new Handler().postDelayed(new Runnable() {
350 | @Override
351 | public void run() {
352 | cardContainer.setBackgroundResource(drawableId);
353 | }
354 | }, duration);
355 |
356 | mRevealView.setVisibility(View.VISIBLE);
357 | animator.start();
358 | mCurrentDrawable = drawableId;
359 |
360 | } else {
361 | Animator anim = android.view.ViewAnimationUtils.createCircularReveal(mRevealView, cx, cy, 0, radius);
362 | mRevealView.setVisibility(View.VISIBLE);
363 | anim.setDuration(duration);
364 | anim.start();
365 | anim.addListener(new AnimatorListenerAdapter() {
366 | @Override
367 | public void onAnimationEnd(Animator animation) {
368 | super.onAnimationEnd(animation);
369 |
370 | cardContainer.setBackgroundResource(drawableId);
371 | }
372 | });
373 |
374 | mCurrentDrawable = drawableId;
375 | }
376 | }
377 |
378 | public void setSelectorLogic(ICustomCardSelector mSelectorLogic) {
379 | this.mSelectorLogic = mSelectorLogic;
380 | }
381 |
382 | public String getCardNumber() {
383 | return mRawCardNumber;
384 | }
385 |
386 |
387 | }
388 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/FlipAnimator.java:
--------------------------------------------------------------------------------
1 | package com.cooltechworks.creditcarddesign;
2 |
3 | import android.graphics.Camera;
4 | import android.graphics.Matrix;
5 | import android.view.View;
6 | import android.view.animation.AccelerateDecelerateInterpolator;
7 | import android.view.animation.Animation;
8 | import android.view.animation.Transformation;
9 |
10 | public class FlipAnimator extends Animation {
11 |
12 | public static final int DIRECTION_X = 1, DIRECTION_Y = 2, DIRECTION_Z = 3;
13 | private Camera camera;
14 |
15 | private View fromView;
16 |
17 | private View toView;
18 |
19 | private final float centerX;
20 |
21 | private final float centerY;
22 |
23 | private boolean forward = true;
24 |
25 | private boolean visibilitySwapped;
26 |
27 | private int rotationDirection = DIRECTION_X;
28 |
29 | private int translateDirection = DIRECTION_Z;
30 |
31 | /**
32 | * Creates a 3D flip animation between two views. If forward is true, its
33 | * assumed that view1 is "visible" and view2 is "gone" before the animation
34 | * starts. At the end of the animation, view1 will be "gone" and view2 will
35 | * be "visible". If forward is false, the reverse is assumed.
36 | *
37 | * @param fromView First view in the transition.
38 | * @param toView Second view in the transition.
39 | * @param centerX The center of the views in the x-axis.
40 | * @param centerY The center of the views in the y-axis.
41 | */
42 | public FlipAnimator(View fromView, View toView, int centerX, int centerY) {
43 | this.fromView = fromView;
44 | this.toView = toView;
45 | this.centerX = centerX;
46 | this.centerY = centerY;
47 |
48 | setDuration(500);
49 | setFillAfter(true);
50 | setInterpolator(new AccelerateDecelerateInterpolator());
51 | }
52 |
53 | public int getRotationDirection() {
54 | return rotationDirection;
55 | }
56 |
57 | public void setRotationDirection(int rotationDirection) {
58 | this.rotationDirection = rotationDirection;
59 | }
60 |
61 | public int getTranslateDirection() {
62 | return translateDirection;
63 | }
64 |
65 | public void setTranslateDirection(int translateDirection) {
66 | this.translateDirection = translateDirection;
67 | }
68 |
69 | public void reverse() {
70 | forward = false;
71 | View temp = toView;
72 | toView = fromView;
73 | fromView = temp;
74 | }
75 |
76 | @Override
77 | public void initialize(int width, int height, int parentWidth, int parentHeight) {
78 | super.initialize(width, height, parentWidth, parentHeight);
79 | camera = new Camera();
80 | }
81 |
82 | @Override
83 | protected void applyTransformation(float interpolatedTime, Transformation t) {
84 | // Angle around the y-axis of the rotation at the given time. It is
85 | // calculated both in radians and in the equivalent degrees.
86 | final double radians = Math.PI * interpolatedTime;
87 | float degrees = (float) (180.0 * radians / Math.PI);
88 |
89 | // Once we reach the midpoint in the animation, we need to hide the
90 | // source view and show the destination view. We also need to change
91 | // the angle by 180 degrees so that the destination does not come in
92 | // flipped around. This is the main problem with SDK sample, it does not
93 | // do this.
94 | if (interpolatedTime >= 0.5f) {
95 | degrees -= 180.f;
96 |
97 | if (!visibilitySwapped) {
98 | fromView.setVisibility(View.GONE);
99 | toView.setVisibility(View.VISIBLE);
100 |
101 | visibilitySwapped = true;
102 | }
103 | }
104 |
105 | if (forward)
106 | degrees = -degrees;
107 |
108 | final Matrix matrix = t.getMatrix();
109 |
110 | camera.save();
111 |
112 | if(translateDirection == DIRECTION_Z) {
113 | camera.translate(0.0f, 0.0f, (float) (150.0 * Math.sin(radians)));
114 | }
115 | else if(translateDirection == DIRECTION_Y) {
116 | camera.translate(0.0f, (float) (150.0 * Math.sin(radians)), 0.0f);
117 | }
118 | else {
119 | camera.translate( (float) (150.0 * Math.sin(radians)), 0.0f, 0.0f);
120 | }
121 |
122 | if(rotationDirection == DIRECTION_Z) {
123 | camera.rotateZ(degrees);
124 | }
125 | else if(rotationDirection == DIRECTION_Y) {
126 | camera.rotateY(degrees);
127 | }
128 | else {
129 | camera.rotateX(degrees);
130 | }
131 |
132 | camera.getMatrix(matrix);
133 | camera.restore();
134 |
135 | matrix.preTranslate(-centerX, -centerY);
136 | matrix.postTranslate(centerX, centerY);
137 | }
138 | }
--------------------------------------------------------------------------------
/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/CardCVVFragment.java:
--------------------------------------------------------------------------------
1 | package com.cooltechworks.creditcarddesign.pager;
2 |
3 | import android.os.Bundle;
4 | import android.text.Editable;
5 | import android.text.InputFilter;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.EditText;
10 |
11 | import com.cooltechworks.creditcarddesign.CardSelector;
12 | import com.cooltechworks.creditcarddesign.R;
13 |
14 | import static com.cooltechworks.creditcarddesign.CreditCardUtils.EXTRA_CARD_CVV;
15 | import static com.cooltechworks.creditcarddesign.CreditCardUtils.EXTRA_CARD_EXPIRY;
16 |
17 | /**
18 | * Created by sharish on 9/1/15.
19 | */
20 | public class CardCVVFragment extends CreditCardFragment {
21 |
22 | private EditText mCardCVVView;
23 | private int mMaxCVV = CardSelector.CVV_LENGHT_DEFAULT;
24 |
25 | public CardCVVFragment() {
26 | }
27 |
28 | public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle state) {
29 | View v = inflater.inflate(R.layout.lyt_card_cvv, group, false);
30 | mCardCVVView = (EditText) v.findViewById(R.id.card_cvv);
31 |
32 | String cvv = null;
33 | if (getArguments() != null && getArguments().containsKey(EXTRA_CARD_CVV)) {
34 | cvv = getArguments().getString(EXTRA_CARD_CVV);
35 | }
36 |
37 | if (cvv == null) {
38 | cvv = "";
39 | }
40 |
41 | mCardCVVView.setText(cvv);
42 | mCardCVVView.addTextChangedListener(this);
43 |
44 | return v;
45 | }
46 |
47 | @Override
48 | public void afterTextChanged(Editable s) {
49 | onEdit(s.toString());
50 | if (s.length() == mMaxCVV) {
51 | onComplete();
52 | }
53 | }
54 |
55 | @Override
56 | public void focus() {
57 | if (isAdded()) {
58 | mCardCVVView.selectAll();
59 | }
60 | }
61 |
62 | public void setMaxCVV(int maxCVVLength) {
63 | if (mCardCVVView != null && (mCardCVVView.getText().toString().length() > maxCVVLength)) {
64 | mCardCVVView.setText(mCardCVVView.getText().toString().substring(0, maxCVVLength));
65 | }
66 |
67 | InputFilter[] FilterArray = new InputFilter[1];
68 | FilterArray[0] = new InputFilter.LengthFilter(maxCVVLength);
69 | mCardCVVView.setFilters(FilterArray);
70 | mMaxCVV = maxCVVLength;
71 | String hintCVV = "";
72 | for (int i = 0; i < maxCVVLength; i++) {
73 | hintCVV += "X";
74 | }
75 | mCardCVVView.setHint(hintCVV);
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/CardExpiryFragment.java:
--------------------------------------------------------------------------------
1 | package com.cooltechworks.creditcarddesign.pager;
2 |
3 | import android.os.Bundle;
4 | import android.text.Editable;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.EditText;
9 | import com.cooltechworks.creditcarddesign.CreditCardUtils;
10 | import com.cooltechworks.creditcarddesign.R;
11 |
12 | import java.util.Calendar;
13 |
14 | import static com.cooltechworks.creditcarddesign.CreditCardUtils.EXTRA_CARD_EXPIRY;
15 | import static com.cooltechworks.creditcarddesign.CreditCardUtils.EXTRA_VALIDATE_EXPIRY_DATE;
16 |
17 | /**
18 | * Created by sharish on 9/1/15.
19 | */
20 | public class CardExpiryFragment extends CreditCardFragment {
21 |
22 | EditText cardExpiryView;
23 |
24 | private boolean mValidateCard = true;
25 |
26 | public CardExpiryFragment() {
27 |
28 | }
29 |
30 | public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle state) {
31 |
32 | View v = inflater.inflate(R.layout.lyt_card_expiry, group, false);
33 | cardExpiryView = (EditText) v.findViewById(R.id.card_expiry);
34 |
35 | String expiry = "";
36 |
37 | Bundle args = getArguments();
38 |
39 | if(args != null) {
40 |
41 | if(args.containsKey(EXTRA_CARD_EXPIRY)) {
42 | expiry = getArguments().getString(EXTRA_CARD_EXPIRY);
43 | }
44 |
45 | mValidateCard = args.getBoolean(EXTRA_VALIDATE_EXPIRY_DATE, true);
46 | }
47 |
48 | if(expiry == null) {
49 | expiry = "";
50 | }
51 |
52 | cardExpiryView.setText(expiry);
53 |
54 | cardExpiryView.addTextChangedListener(this);
55 |
56 | return v;
57 | }
58 |
59 | @Override
60 | public void afterTextChanged(Editable s) {
61 |
62 | String text = s.toString().replace(CreditCardUtils.SLASH_SEPERATOR, "");
63 |
64 | String month, year="";
65 | if(text.length() >= 2) {
66 | month = text.substring(0, 2);
67 |
68 | if(text.length() > 2) {
69 | year = text.substring(2);
70 | }
71 |
72 | if(mValidateCard) {
73 | int mm = Integer.parseInt(month);
74 |
75 | if (mm <= 0 || mm >= 13) {
76 | cardExpiryView.setError(getString(R.string.error_invalid_month));
77 | return;
78 | }
79 |
80 | if (text.length() >= 4) {
81 |
82 | int yy = Integer.parseInt(year);
83 |
84 | final Calendar calendar = Calendar.getInstance();
85 | int currentYear = calendar.get(Calendar.YEAR);
86 | int currentMonth = calendar.get(Calendar.MONTH) + 1;
87 |
88 | int millenium = (currentYear / 1000) * 1000;
89 |
90 |
91 | if (yy + millenium < currentYear) {
92 | cardExpiryView.setError(getString(R.string.error_card_expired));
93 | return;
94 | } else if (yy + millenium == currentYear && mm < currentMonth) {
95 | cardExpiryView.setError(getString(R.string.error_card_expired));
96 | return;
97 | }
98 | }
99 | }
100 |
101 | }
102 | else {
103 | month = text;
104 | }
105 |
106 | int previousLength = cardExpiryView.getText().length();
107 | int cursorPosition = cardExpiryView.getSelectionEnd();
108 |
109 | text = CreditCardUtils.handleExpiration(month,year);
110 |
111 | cardExpiryView.removeTextChangedListener(this);
112 | cardExpiryView.setText(text);
113 | cardExpiryView.setSelection(text.length());
114 | cardExpiryView.addTextChangedListener(this);
115 |
116 | int modifiedLength = text.length();
117 |
118 | if(modifiedLength <= previousLength && cursorPosition < modifiedLength) {
119 | cardExpiryView.setSelection(cursorPosition);
120 | }
121 |
122 | onEdit(text);
123 |
124 | if(text.length() == 5) {
125 | onComplete();
126 | }
127 |
128 | }
129 |
130 |
131 | @Override
132 | public void focus() {
133 |
134 | if(isAdded()) {
135 | cardExpiryView.selectAll();
136 | }
137 | }
138 |
139 |
140 | public void onSaveInstanceState(Bundle outState) {
141 |
142 | outState.putBoolean(EXTRA_VALIDATE_EXPIRY_DATE, mValidateCard);
143 | super.onSaveInstanceState(outState);
144 | }
145 |
146 | public void onActivityCreated(Bundle instate) {
147 |
148 | if(instate != null) {
149 | mValidateCard = instate.getBoolean(EXTRA_VALIDATE_EXPIRY_DATE, mValidateCard);
150 | }
151 |
152 | super.onActivityCreated(instate);
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/CardFragmentAdapter.java:
--------------------------------------------------------------------------------
1 | package com.cooltechworks.creditcarddesign.pager;
2 |
3 | import android.os.Bundle;
4 | import android.os.Parcelable;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v4.app.FragmentManager;
7 | import android.support.v4.app.FragmentStatePagerAdapter;
8 |
9 | /**
10 | * Created by sharish on 9/1/15.
11 | */
12 | public class CardFragmentAdapter extends FragmentStatePagerAdapter implements IActionListener {
13 |
14 | public void focus(int position) {
15 | ((IFocus) getItem(position)).focus();
16 | }
17 |
18 | public interface ICardEntryCompleteListener {
19 | void onCardEntryComplete(int currentIndex);
20 |
21 | void onCardEntryEdit(int currentIndex, String entryValue);
22 | }
23 |
24 | private final CardNumberFragment mCardNumberFragment;
25 | private final CardExpiryFragment mCardExpiryFragment;
26 | private final CardCVVFragment mCardCVVFragment;
27 | private final CardNameFragment mCardNameFragment;
28 |
29 | private ICardEntryCompleteListener mCardEntryCompleteListener;
30 |
31 | public CardFragmentAdapter(FragmentManager fm, Bundle args) {
32 | super(fm);
33 |
34 | mCardCVVFragment = new CardCVVFragment();
35 | mCardCVVFragment.setArguments(args);
36 |
37 | mCardNameFragment = new CardNameFragment();
38 | mCardNameFragment.setArguments(args);
39 |
40 | mCardNumberFragment = new CardNumberFragment();
41 | mCardNumberFragment.setArguments(args);
42 |
43 | mCardExpiryFragment = new CardExpiryFragment();
44 | mCardExpiryFragment.setArguments(args);
45 |
46 | mCardNameFragment.setActionListener(this);
47 | mCardNumberFragment.setActionListener(this);
48 | mCardExpiryFragment.setActionListener(this);
49 | mCardCVVFragment.setActionListener(this);
50 | }
51 |
52 | public void setOnCardEntryCompleteListener(ICardEntryCompleteListener listener) {
53 | this.mCardEntryCompleteListener = listener;
54 | }
55 |
56 | @Override
57 | public Fragment getItem(int position) {
58 | return new Fragment[]{mCardNumberFragment, mCardExpiryFragment, mCardCVVFragment, mCardNameFragment}[position];
59 | }
60 |
61 | @Override
62 | public int getCount() {
63 | return 4;
64 | }
65 |
66 |
67 | @Override
68 | public void onActionComplete(CreditCardFragment fragment) {
69 | int index = getIndex(fragment);
70 | if (index >= 0 && mCardEntryCompleteListener != null) {
71 | mCardEntryCompleteListener.onCardEntryComplete(index);
72 | }
73 | }
74 |
75 | public int getIndex(CreditCardFragment fragment) {
76 | int index = -1;
77 | if (fragment == mCardNumberFragment) {
78 | index = 0;
79 | } else if (fragment == mCardExpiryFragment) {
80 | index = 1;
81 | } else if (fragment == mCardCVVFragment) {
82 | index = 2;
83 | } else if (fragment == mCardNameFragment) {
84 | index = 3;
85 | }
86 |
87 | return index;
88 | }
89 |
90 | public void setMaxCVV(int maxCVV) {
91 | if (mCardCVVFragment != null) {
92 | mCardCVVFragment.setMaxCVV(maxCVV);
93 | }
94 | }
95 |
96 | @Override
97 | public void onEdit(CreditCardFragment fragment, String edit) {
98 | int index = getIndex(fragment);
99 |
100 | if (index >= 0 && mCardEntryCompleteListener != null) {
101 | mCardEntryCompleteListener.onCardEntryEdit(index, edit);
102 | }
103 | }
104 |
105 | @Override
106 | public void restoreState(Parcelable parcelable, ClassLoader classLoader) {
107 | //do nothing here! no call to super.restoreState(parcelable, classLoader);
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/CardNameFragment.java:
--------------------------------------------------------------------------------
1 | package com.cooltechworks.creditcarddesign.pager;
2 |
3 | import android.os.Bundle;
4 | import android.text.Editable;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.EditText;
9 |
10 | import com.cooltechworks.creditcarddesign.R;
11 |
12 | import static com.cooltechworks.creditcarddesign.CreditCardUtils.EXTRA_CARD_CVV;
13 | import static com.cooltechworks.creditcarddesign.CreditCardUtils.EXTRA_CARD_HOLDER_NAME;
14 | /**
15 | * Created by sharish on 9/1/15.
16 | */
17 | public class CardNameFragment extends CreditCardFragment {
18 |
19 |
20 | private EditText mCardNameView;
21 |
22 | public CardNameFragment() {
23 |
24 | }
25 |
26 | public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle state) {
27 |
28 | View v = inflater.inflate(R.layout.lyt_card_holder_name, group,false);
29 | mCardNameView = (EditText) v.findViewById(R.id.card_name);
30 |
31 | String name = "";
32 | if(getArguments() != null && getArguments().containsKey(EXTRA_CARD_HOLDER_NAME)) {
33 | name = getArguments().getString(EXTRA_CARD_HOLDER_NAME);
34 | }
35 |
36 |
37 | if(name == null) {
38 | name = "";
39 | }
40 |
41 | mCardNameView.setText(name);
42 | mCardNameView.addTextChangedListener(this);
43 |
44 | return v;
45 | }
46 |
47 | @Override
48 | public void afterTextChanged(Editable s) {
49 |
50 | onEdit(s.toString());
51 | if(s.length() == getResources().getInteger(R.integer.card_name_len)) {
52 | onComplete();
53 | }
54 | }
55 |
56 | @Override
57 | public void focus() {
58 |
59 | if(isAdded()) {
60 | mCardNameView.selectAll();
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/CardNumberFragment.java:
--------------------------------------------------------------------------------
1 | package com.cooltechworks.creditcarddesign.pager;
2 |
3 | import android.os.Bundle;
4 | import android.text.Editable;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.EditText;
9 |
10 | import com.cooltechworks.creditcarddesign.CreditCardUtils;
11 | import com.cooltechworks.creditcarddesign.R;
12 |
13 | import static com.cooltechworks.creditcarddesign.CreditCardUtils.CARD_NUMBER_FORMAT;
14 | import static com.cooltechworks.creditcarddesign.CreditCardUtils.CARD_NUMBER_FORMAT_AMEX;
15 | import static com.cooltechworks.creditcarddesign.CreditCardUtils.EXTRA_CARD_NUMBER;
16 |
17 | /**
18 | * Created by sharish on 9/1/15.
19 | */
20 | public class CardNumberFragment extends CreditCardFragment {
21 |
22 | EditText mCardNumberView;
23 |
24 | public CardNumberFragment() {
25 | }
26 |
27 | public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle state) {
28 | View v = inflater.inflate(R.layout.lyt_card_number, group, false);
29 | mCardNumberView = (EditText) v.findViewById(R.id.card_number_field);
30 |
31 | String number = "";
32 |
33 | if (getArguments() != null && getArguments().containsKey(EXTRA_CARD_NUMBER)) {
34 | number = getArguments().getString(EXTRA_CARD_NUMBER);
35 | }
36 |
37 | if (number == null) {
38 | number = "";
39 | }
40 |
41 | mCardNumberView.setText(number);
42 | mCardNumberView.addTextChangedListener(this);
43 |
44 | return v;
45 | }
46 |
47 |
48 | @Override
49 | public void afterTextChanged(Editable s) {
50 | int cursorPosition = mCardNumberView.getSelectionEnd();
51 | int previousLength = mCardNumberView.getText().length();
52 |
53 | String cardNumber = CreditCardUtils.handleCardNumber(s.toString());
54 | int modifiedLength = cardNumber.length();
55 |
56 | mCardNumberView.removeTextChangedListener(this);
57 | mCardNumberView.setText(cardNumber);
58 | String rawCardNumber = cardNumber.replace(CreditCardUtils.SPACE_SEPERATOR, "");
59 | CreditCardUtils.CardType cardType = CreditCardUtils.selectCardType(rawCardNumber);
60 | int maxLengthWithSpaces = ((cardType == CreditCardUtils.CardType.AMEX_CARD) ? CARD_NUMBER_FORMAT_AMEX : CARD_NUMBER_FORMAT).length();
61 | mCardNumberView.setSelection(cardNumber.length() > maxLengthWithSpaces ? maxLengthWithSpaces : cardNumber.length());
62 | mCardNumberView.addTextChangedListener(this);
63 |
64 | if (modifiedLength <= previousLength && cursorPosition < modifiedLength) {
65 | mCardNumberView.setSelection(cursorPosition);
66 | }
67 |
68 | onEdit(cardNumber);
69 |
70 | if (rawCardNumber.length() == CreditCardUtils.selectCardLength(cardType)) {
71 | onComplete();
72 | }
73 | }
74 |
75 | @Override
76 | public void focus() {
77 | if (isAdded()) {
78 | mCardNumberView.selectAll();
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/CreditCardFragment.java:
--------------------------------------------------------------------------------
1 | package com.cooltechworks.creditcarddesign.pager;
2 |
3 | import android.support.v4.app.Fragment;
4 | import android.text.TextWatcher;
5 |
6 | /**
7 | * Created by sharish on 9/1/15.
8 | */
9 | public abstract class CreditCardFragment extends Fragment implements TextWatcher, IFocus {
10 |
11 | protected IActionListener mActionListener;
12 |
13 | public void setActionListener(IActionListener listener) {
14 | mActionListener = listener;
15 | }
16 |
17 | @Override
18 | public void beforeTextChanged(CharSequence s, int start, int count, int after) {
19 |
20 | }
21 |
22 | @Override
23 | public void onTextChanged(CharSequence s, int start, int before, int count) {
24 |
25 | }
26 |
27 |
28 | public void onEdit(String edit) {
29 |
30 | if(mActionListener != null) {
31 | mActionListener.onEdit(this,edit);
32 | }
33 |
34 | }
35 |
36 | public void onComplete() {
37 |
38 | if(mActionListener != null) {
39 | mActionListener.onActionComplete(this);
40 | }
41 |
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/IActionListener.java:
--------------------------------------------------------------------------------
1 | package com.cooltechworks.creditcarddesign.pager;
2 |
3 | public interface IActionListener {
4 | public void onActionComplete(CreditCardFragment fragment);
5 | public void onEdit(CreditCardFragment fragment, String edit);
6 |
7 | }
--------------------------------------------------------------------------------
/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/IFocus.java:
--------------------------------------------------------------------------------
1 | package com.cooltechworks.creditcarddesign.pager;
2 |
3 | /**
4 | * Created by Harish on 17/01/16.
5 | */
6 | public interface IFocus {
7 | void focus();
8 | }
9 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/views/HeightWrappingViewPager.java:
--------------------------------------------------------------------------------
1 | package com.cooltechworks.creditcarddesign.views;
2 |
3 | import android.content.Context;
4 | import android.support.v4.view.ViewPager;
5 | import android.util.AttributeSet;
6 | import android.view.View;
7 |
8 | public class HeightWrappingViewPager extends ViewPager {
9 |
10 | public HeightWrappingViewPager(Context context) {
11 | super(context);
12 | }
13 |
14 | public HeightWrappingViewPager(Context context, AttributeSet attrs) {
15 | super(context, attrs);
16 | }
17 |
18 | @Override
19 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
20 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
21 | View firstChild = getChildAt(0);
22 | firstChild.measure(widthMeasureSpec, heightMeasureSpec);
23 | super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(firstChild.getMeasuredHeight(), MeasureSpec.EXACTLY));
24 | }
25 | }
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/card_color_round_rect_blue.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
12 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/card_color_round_rect_brown.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
12 |
13 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/card_color_round_rect_default.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
12 |
13 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/card_color_round_rect_green.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/card_color_round_rect_pink.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
12 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/card_color_round_rect_purple.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
11 |
12 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/chip.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/chip_inner.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/chip_yellow.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/chip_yellow_inner.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/discover_back.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
15 |
16 |
20 |
21 |
22 |
28 |
29 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/discover_back_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
11 |
12 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/ic_billing_amex_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sharish/CreditCardView/9ac891404756997b4ecf0f06526ddb11314530bf/creditcarddesign/src/main/res/drawable/ic_billing_amex_logo.png
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/ic_billing_amex_logo1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sharish/CreditCardView/9ac891404756997b4ecf0f06526ddb11314530bf/creditcarddesign/src/main/res/drawable/ic_billing_amex_logo1.png
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/ic_billing_discover_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sharish/CreditCardView/9ac891404756997b4ecf0f06526ddb11314530bf/creditcarddesign/src/main/res/drawable/ic_billing_discover_logo.png
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/ic_billing_mastercard_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sharish/CreditCardView/9ac891404756997b4ecf0f06526ddb11314530bf/creditcarddesign/src/main/res/drawable/ic_billing_mastercard_logo.png
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/ic_billing_visa_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sharish/CreditCardView/9ac891404756997b4ecf0f06526ddb11314530bf/creditcarddesign/src/main/res/drawable/ic_billing_visa_logo.png
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/img_amex_center_face.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sharish/CreditCardView/9ac891404756997b4ecf0f06526ddb11314530bf/creditcarddesign/src/main/res/drawable/img_amex_center_face.png
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/master_back.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
15 |
16 |
20 |
21 |
22 |
28 |
29 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/mastercard_back_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
11 |
12 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/sign_strip.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sharish/CreditCardView/9ac891404756997b4ecf0f06526ddb11314530bf/creditcarddesign/src/main/res/drawable/sign_strip.png
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/sign_strip_mod.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/visacard_back.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | -
7 |
8 |
9 |
10 |
11 |
12 |
13 | -
14 |
15 |
16 |
17 |
18 | -
19 |
20 |
21 |
22 |
23 |
24 |
25 | -
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/drawable/visacard_back_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
11 |
12 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/layout/activity_card_edit.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
14 |
15 |
20 |
21 |
22 |
29 |
30 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
50 |
51 |
64 |
65 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/layout/back_card.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
17 |
18 |
30 |
31 |
40 |
41 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/layout/front_card.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
15 |
16 |
34 |
35 |
36 |
37 |
54 |
55 |
60 |
61 |
66 |
67 |
77 |
78 |
94 |
95 |
96 |
97 |
98 |
99 |
104 |
105 |
115 |
116 |
132 |
133 |
134 |
135 |
136 |
137 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/layout/front_card_outline.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
16 |
17 |
23 |
24 |
25 |
36 |
37 |
38 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/layout/lyt_card_cvv.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
21 |
22 |
27 |
28 |
29 |
35 |
36 |
37 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/layout/lyt_card_expiry.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
20 |
21 |
26 |
27 |
28 |
34 |
35 |
36 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/layout/lyt_card_holder_name.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
20 |
21 |
26 |
27 |
28 |
34 |
35 |
36 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/layout/lyt_card_number.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
19 |
20 |
25 |
26 |
27 |
33 |
34 |
35 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/layout/view_creditcard.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
15 |
16 |
17 |
18 |
19 |
24 |
25 |
26 |
27 |
28 |
29 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/values-fr/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | SUIVANT
4 | PRECEDENT
5 | TERMINER
6 | JEAN MARTIN
7 | TITULAIRE
8 | EXPIRATION
9 | MM/AA
10 | EXPIRATION
11 | MM/AA
12 | NOM SUR LA CARTE
13 | NUMERO DE CARTE
14 | Mois invalide
15 | Carte expirée
16 |
17 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/values-pt-rBR/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | PRÓXIMO
4 | ANTERIOR
5 | PRONTO
6 | JOÃO SILVA
7 | TITULAR
8 | VENCIMENTO
9 | MM/AA
10 | VENCIMENTO
11 | MM/AA
12 | NOME NO CARTÃO
13 | NÚMERO DO CARTÃO
14 | Mês inválido
15 | Cartão vencido
16 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | #1fc055
5 | #d4edfa
6 | #e0e4e4
7 | #fbe191
8 | #eed280
9 |
10 | #5515a9
11 | #651dc4
12 |
13 | #108b4c
14 | #1caf57
15 |
16 | #5D8BF2
17 | #3545AE
18 |
19 | #d04c84
20 | #d04882
21 |
22 | #363434
23 | #434141
24 |
25 | #800000
26 | #A52A2A
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 12dp
6 | 18dp
7 | 16dp
8 | 2dp
9 | 13sp
10 | 19sp
11 | 20sp
12 | 8dp
13 | 16dp
14 | 20dp
15 | 16sp
16 |
17 |
18 | #88FFFFFF
19 | #FBFBFB
20 | #ff9e9e9e
21 | #7F000000
22 | #FFFFFF
23 |
24 | 2dp
25 | 1dp
26 |
27 |
28 | 300dp
29 | 180dp
30 | 54dp
31 | 36dp
32 | 28dp
33 | 16dp
34 | 48dp
35 | 48dp
36 | 75dp
37 | 75dp
38 |
39 |
40 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | CheckoutFlow
3 |
4 | Hello world!
5 | Settings
6 |
7 | NEXT
8 | PREVIOUS
9 | DONE
10 | JOHN MATTHEW
11 | CARD HOLDER
12 | EXPIRY
13 | MM/YY
14 | CARD EXPIRY
15 | MM/YY
16 | 0000
17 | NAME ON CARD
18 | CARD NUMBER
19 | Invalid month
20 | Card expired
21 | 25
22 |
23 |
--------------------------------------------------------------------------------
/creditcarddesign/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sharish/CreditCardView/9ac891404756997b4ecf0f06526ddb11314530bf/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | #Sat Dec 26 14:43:24 IST 2015
11 | sdk.dir=/Users/Harish/Android_SDK/android-sdk-macosx
12 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':creditcarddesign'
2 |
--------------------------------------------------------------------------------