├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── assets
│ │ │ └── fonts
│ │ │ │ ├── kreditback.ttf
│ │ │ │ ├── ocramedium.ttf
│ │ │ │ └── kreditfront.ttf
│ │ ├── res
│ │ │ ├── drawable-hdpi
│ │ │ │ ├── ic_amex.png
│ │ │ │ ├── ic_chip.png
│ │ │ │ ├── ic_visa.png
│ │ │ │ ├── ic_card_bg.png
│ │ │ │ ├── ic_card_back.png
│ │ │ │ ├── ic_discover.png
│ │ │ │ └── ic_mastercard.png
│ │ │ ├── drawable-ldpi
│ │ │ │ ├── ic_chip.png
│ │ │ │ ├── ic_card_bg.png
│ │ │ │ └── ic_card_back.png
│ │ │ ├── drawable-mdpi
│ │ │ │ ├── ic_amex.png
│ │ │ │ ├── ic_chip.png
│ │ │ │ ├── ic_visa.png
│ │ │ │ ├── ic_card_bg.png
│ │ │ │ ├── ic_card_back.png
│ │ │ │ ├── ic_discover.png
│ │ │ │ └── ic_mastercard.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ ├── ic_amex.png
│ │ │ │ ├── ic_chip.png
│ │ │ │ ├── ic_visa.png
│ │ │ │ ├── ic_card_bg.png
│ │ │ │ ├── ic_discover.png
│ │ │ │ ├── ic_card_back.png
│ │ │ │ └── ic_mastercard.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ ├── ic_chip.png
│ │ │ │ └── ic_card_bg.png
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ ├── integers.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── styles.xml
│ │ │ ├── layout
│ │ │ │ ├── activity_check_out.xml
│ │ │ │ ├── fragment_ccnumber.xml
│ │ │ │ ├── fragment_ccvalidity.xml
│ │ │ │ ├── fragment_ccsecure_code.xml
│ │ │ │ ├── fragment_ccname.xml
│ │ │ │ ├── fragment_card_back.xml
│ │ │ │ └── fragment_card_front.xml
│ │ │ └── animator
│ │ │ │ ├── card_flip_left_out.xml
│ │ │ │ ├── card_flip_right_out.xml
│ │ │ │ ├── card_flip_left_in.xml
│ │ │ │ └── card_flip_right_in.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── droidmentor
│ │ │ └── checkoutflow
│ │ │ ├── Utils
│ │ │ ├── FontTypeChange.java
│ │ │ ├── ViewPagerAdapter.java
│ │ │ ├── CreditCardEditText.java
│ │ │ ├── CreditCardExpiryTextWatcher.java
│ │ │ ├── CreditCardFormattingTextWatcher.java
│ │ │ └── CreditCardUtils.java
│ │ │ ├── CardBackFragment.java
│ │ │ ├── CCFragment
│ │ │ ├── CCValidityFragment.java
│ │ │ ├── CCNumberFragment.java
│ │ │ ├── CCNameFragment.java
│ │ │ └── CCSecureCodeFragment.java
│ │ │ ├── CardFrontFragment.java
│ │ │ └── CheckOutActivity.java
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── droidmentor
│ │ │ └── checkoutflow
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── droidmentor
│ │ └── checkoutflow
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── .idea
├── copyright
│ └── profiles_settings.xml
├── encodings.xml
├── inspectionProfiles
│ ├── profiles_settings.xml
│ └── Project_Default.xml
├── modules.xml
├── runConfigurations.xml
├── gradle.xml
├── compiler.xml
└── misc.xml
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── gradle.properties
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/kreditback.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/assets/fonts/kreditback.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/ocramedium.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/assets/fonts/ocramedium.ttf
--------------------------------------------------------------------------------
/app/src/main/assets/fonts/kreditfront.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/assets/fonts/kreditfront.ttf
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_amex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-hdpi/ic_amex.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_chip.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-hdpi/ic_chip.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_visa.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-hdpi/ic_visa.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-ldpi/ic_chip.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-ldpi/ic_chip.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_amex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-mdpi/ic_amex.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_chip.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-mdpi/ic_chip.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_visa.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-mdpi/ic_visa.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_card_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-hdpi/ic_card_bg.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-ldpi/ic_card_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-ldpi/ic_card_bg.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_card_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-mdpi/ic_card_bg.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_amex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-xhdpi/ic_amex.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_chip.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-xhdpi/ic_chip.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_visa.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-xhdpi/ic_visa.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_chip.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-xxhdpi/ic_chip.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_card_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-hdpi/ic_card_back.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_discover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-hdpi/ic_discover.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-ldpi/ic_card_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-ldpi/ic_card_back.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_card_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-mdpi/ic_card_back.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_discover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-mdpi/ic_discover.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_card_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-xhdpi/ic_card_bg.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_discover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-xhdpi/ic_discover.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_card_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-xxhdpi/ic_card_bg.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_mastercard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-hdpi/ic_mastercard.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_mastercard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-mdpi/ic_mastercard.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_card_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-xhdpi/ic_card_back.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_mastercard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/drawable-xhdpi/ic_mastercard.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaisonfdo/CheckOutFlow/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri May 26 15:35:01 IST 2017
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-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/test/java/com/droidmentor/checkoutflow/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.droidmentor.checkoutflow;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #F3F3F3
7 |
8 | #FFFFFF
9 | #D4D9DC
10 | #383838
11 | #FFFFFF
12 | #32C25E
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/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 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | CheckOutFlow
3 |
4 | NFN CARD
5 | XXXX XXXX XXXX XXXX
6 | VALID UPTO
7 | MM/YY
8 | CARD HOLDER
9 |
10 |
11 | Hello blank fragment
12 | Card Holder\'s Name
13 | Card Number
14 | Expires
15 | CVV/CVC Number
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/values/integers.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 | 400
19 | 200
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/droidmentor/checkoutflow/Utils/FontTypeChange.java:
--------------------------------------------------------------------------------
1 | package com.droidmentor.checkoutflow.Utils;
2 |
3 | import android.content.Context;
4 | import android.graphics.Typeface;
5 |
6 | public class FontTypeChange {
7 |
8 | private Context c;
9 |
10 | public FontTypeChange(Context s) {
11 | // TODO Auto-generated constructor stub
12 | this.c=s;
13 | }
14 |
15 | public Typeface get_fontface(int n)
16 | {
17 | Typeface tf;
18 | if(n==1)
19 | tf=Typeface.createFromAsset(c.getAssets(), "fonts/kreditback.ttf");
20 | else if(n==2)
21 | tf=Typeface.createFromAsset(c.getAssets(), "fonts/kreditfront.ttf");
22 | else if(n==3)
23 | tf=Typeface.createFromAsset(c.getAssets(), "fonts/ocramedium.ttf");
24 | else
25 | tf=Typeface.createFromAsset(c.getAssets(), "fonts/kreditfront.ttf");
26 | return tf;
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/droidmentor/checkoutflow/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.droidmentor.checkoutflow;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.droidmentor.checkoutflow", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/droidmentor/checkoutflow/Utils/ViewPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.droidmentor.checkoutflow.Utils;
2 |
3 | import android.support.v4.app.Fragment;
4 | import android.support.v4.app.FragmentManager;
5 | import android.support.v4.app.FragmentPagerAdapter;
6 |
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 | /**
11 | * Created by Jaison on 23/10/16.
12 | */
13 |
14 |
15 | public class ViewPagerAdapter extends FragmentPagerAdapter {
16 | private final List mFragmentList = new ArrayList<>();
17 |
18 | public ViewPagerAdapter(FragmentManager manager) {
19 | super(manager);
20 | }
21 | @Override
22 | public Fragment getItem(int position) {
23 | return mFragmentList.get(position);
24 | }
25 |
26 | @Override
27 | public int getCount() {
28 | return mFragmentList.size();
29 | }
30 |
31 | public void addFragment(Fragment fragment) {
32 | mFragmentList.add(fragment);
33 | }
34 |
35 | }
--------------------------------------------------------------------------------
/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/Jaison/Library/Android/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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
27 | # Validator
28 |
29 | -dontwarn org.apache.commons.**
30 | -dontwarn java.beans.**
31 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_check_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 16dp
6 |
7 |
8 |
9 | 8sp
10 | 10sp
11 | 12sp
12 | 14sp
13 | 16sp
14 | 18sp
15 | 20sp
16 | 30sp
17 |
18 | 8dp
19 | 4dp
20 | 12dp
21 |
22 |
23 | 230dp
24 | 25dp
25 | 55dp
26 | 40dp
27 | 85dp
28 | 50dp
29 | 10dp
30 | 25dp
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_ccnumber.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
12 |
13 |
17 |
18 |
21 |
22 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_ccvalidity.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
12 |
13 |
17 |
18 |
21 |
22 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_ccsecure_code.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
12 |
13 |
17 |
18 |
21 |
22 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_ccname.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
14 |
18 |
19 |
22 |
23 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.2"
6 | defaultConfig {
7 | applicationId "com.droidmentor.checkoutflow"
8 | minSdkVersion 16
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 |
28 |
29 | compile ('commons-validator:commons-validator:1.6')
30 | { exclude group: 'commons-logging', module: 'commons-logging' }
31 |
32 | compile 'com.android.support:appcompat-v7:25.3.1'
33 | compile 'com.android.support:cardview-v7:25.3.1'
34 | compile 'com.android.support:design:25.3.1'
35 | compile 'com.jakewharton:butterknife:8.5.1'
36 | compile 'com.android.support:support-v4:25.3.1'
37 | testCompile 'junit:junit:4.12'
38 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_card_back.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
14 |
15 |
20 |
21 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/droidmentor/checkoutflow/Utils/CreditCardEditText.java:
--------------------------------------------------------------------------------
1 | package com.droidmentor.checkoutflow.Utils;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.util.Log;
6 | import android.view.KeyEvent;
7 |
8 |
9 | /**
10 | * Created by Jaison on 29/05/17.
11 | */
12 |
13 | public class CreditCardEditText extends android.support.v7.widget.AppCompatEditText {
14 |
15 |
16 | public Context context;
17 |
18 | BackButtonListener backButtonListener;
19 |
20 | public CreditCardEditText(Context context) {
21 | super(context);
22 | this.context=context;
23 | }
24 |
25 | public CreditCardEditText(Context context, AttributeSet attrs) {
26 | super(context, attrs);
27 | this.context=context;
28 | }
29 |
30 | public CreditCardEditText(Context context, AttributeSet attrs, int defStyleAttr) {
31 | super(context, attrs, defStyleAttr);
32 | this.context=context;
33 | }
34 |
35 | public void setOnBackButtonListener(BackButtonListener listener)
36 | {
37 | backButtonListener = listener;
38 | }
39 |
40 | @Override
41 | public boolean onKeyPreIme(int keyCode, KeyEvent event) {
42 | if (event.getAction()==KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
43 | // User has pressed Back key. So hide the keyboard
44 | Log.d("ET", "onKeyPreIme: ");
45 | if(backButtonListener!=null)
46 | backButtonListener.onBackClick();
47 | return true;
48 | // TODO: Hide your view as you do it in your activity
49 | }
50 | return false;
51 | }
52 |
53 | public interface BackButtonListener
54 | {
55 | public void onBackClick();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/java/com/droidmentor/checkoutflow/CardBackFragment.java:
--------------------------------------------------------------------------------
1 | package com.droidmentor.checkoutflow;
2 |
3 |
4 | import android.app.Fragment;
5 | import android.os.Bundle;
6 | import android.text.TextUtils;
7 | import android.util.Log;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.TextView;
12 |
13 | import com.droidmentor.checkoutflow.CCFragment.CCSecureCodeFragment;
14 | import com.droidmentor.checkoutflow.Utils.FontTypeChange;
15 |
16 | import butterknife.BindView;
17 | import butterknife.ButterKnife;
18 |
19 |
20 | /**
21 | * A simple {@link Fragment} subclass.
22 | */
23 | public class CardBackFragment extends Fragment {
24 |
25 | @BindView(R.id.tv_cvv)TextView tv_cvv;
26 | FontTypeChange fontTypeChange;
27 |
28 | CheckOutActivity activity;
29 | CCSecureCodeFragment securecode;
30 |
31 | public CardBackFragment() {
32 | // Required empty public constructor
33 | }
34 |
35 |
36 | @Override
37 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
38 | Bundle savedInstanceState) {
39 | // Inflate the layout for this fragment
40 |
41 | Log.d("BF", "onCreateView: ");
42 | View view=inflater.inflate(R.layout.fragment_card_back, container, false);
43 | ButterKnife.bind(this, view);
44 |
45 | fontTypeChange=new FontTypeChange(getActivity());
46 | tv_cvv.setTypeface(fontTypeChange.get_fontface(1));
47 |
48 | activity = (CheckOutActivity) getActivity();
49 | securecode = activity.secureCodeFragment;
50 | securecode.setCvv(tv_cvv);
51 |
52 | if(!TextUtils.isEmpty(securecode.getValue()))
53 | tv_cvv.setText(securecode.getValue());
54 |
55 | return view;
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/app/src/main/java/com/droidmentor/checkoutflow/Utils/CreditCardExpiryTextWatcher.java:
--------------------------------------------------------------------------------
1 | package com.droidmentor.checkoutflow.Utils;
2 |
3 | import android.text.Editable;
4 | import android.text.TextWatcher;
5 | import android.widget.EditText;
6 | import android.widget.TextView;
7 |
8 | /**
9 | * Created by Jaison on 28/05/17.
10 | */
11 |
12 | public class CreditCardExpiryTextWatcher implements TextWatcher {
13 |
14 | private EditText etCard;
15 | private TextView tvCard;
16 | private boolean isDelete;
17 |
18 | public CreditCardExpiryTextWatcher(EditText etcard,TextView tvcard) {
19 | this.etCard=etcard;
20 | this.tvCard=tvcard;
21 | }
22 |
23 | public CreditCardExpiryTextWatcher(EditText etcard) {
24 | this.etCard=etcard;
25 | }
26 |
27 | @Override
28 | public void beforeTextChanged(CharSequence s, int start, int count, int after) {
29 | }
30 |
31 | @Override
32 | public void onTextChanged(CharSequence s, int start, int before, int count) {
33 | if(before==0)
34 | isDelete=false;
35 | else
36 | isDelete=true;
37 | }
38 |
39 | @Override
40 | public void afterTextChanged(Editable s) {
41 | String source = s.toString();
42 | int length=source.length();
43 |
44 | StringBuilder stringBuilder = new StringBuilder();
45 | stringBuilder.append(source);
46 |
47 | if(length>0 && length==3)
48 | {
49 | if(isDelete)
50 | stringBuilder.deleteCharAt(length-1);
51 | else
52 | stringBuilder.insert(length-1,"/");
53 |
54 | etCard.setText(stringBuilder);
55 | etCard.setSelection(etCard.getText().length());
56 |
57 | // Log.d("test"+s.toString(), "afterTextChanged: append "+length);
58 | }
59 |
60 | if(tvCard!=null)
61 | {
62 | if(length==0)
63 | tvCard.setText("MM/YY");
64 | else
65 | tvCard.setText(stringBuilder);
66 | }
67 |
68 | }
69 |
70 | }
--------------------------------------------------------------------------------
/app/src/main/res/animator/card_flip_left_out.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
35 |
36 |
37 |
38 |
44 |
45 |
46 |
52 |
53 |
--------------------------------------------------------------------------------
/app/src/main/res/animator/card_flip_right_out.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
35 |
36 |
37 |
38 |
44 |
45 |
46 |
52 |
53 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
21 |
22 |
23 |
33 |
34 |
42 |
43 |
44 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/app/src/main/res/animator/card_flip_left_in.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
36 |
37 |
38 |
39 |
44 |
45 |
46 |
52 |
53 |
54 |
60 |
61 |
--------------------------------------------------------------------------------
/app/src/main/res/animator/card_flip_right_in.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
36 |
37 |
38 |
39 |
44 |
45 |
46 |
52 |
53 |
54 |
60 |
61 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/java/com/droidmentor/checkoutflow/CCFragment/CCValidityFragment.java:
--------------------------------------------------------------------------------
1 | package com.droidmentor.checkoutflow.CCFragment;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.v4.app.Fragment;
6 | import android.view.KeyEvent;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.view.inputmethod.EditorInfo;
11 | import android.widget.TextView;
12 |
13 | import com.droidmentor.checkoutflow.CardFrontFragment;
14 | import com.droidmentor.checkoutflow.CheckOutActivity;
15 | import com.droidmentor.checkoutflow.R;
16 | import com.droidmentor.checkoutflow.Utils.CreditCardEditText;
17 | import com.droidmentor.checkoutflow.Utils.CreditCardExpiryTextWatcher;
18 |
19 | import butterknife.BindView;
20 | import butterknife.ButterKnife;
21 |
22 | /**
23 | * A simple {@link Fragment} subclass.
24 | */
25 | public class CCValidityFragment extends Fragment {
26 |
27 |
28 | @BindView(R.id.et_validity)
29 | CreditCardEditText et_validity;
30 | TextView tv_validity;
31 |
32 | CheckOutActivity activity;
33 | CardFrontFragment cardFrontFragment;
34 |
35 | public CCValidityFragment() {
36 | // Required empty public constructor
37 | }
38 |
39 |
40 | @Override
41 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
42 | Bundle savedInstanceState) {
43 | // Inflate the layout for this fragment
44 | View view = inflater.inflate(R.layout.fragment_ccvalidity, container, false);
45 | ButterKnife.bind(this, view);
46 |
47 | activity = (CheckOutActivity) getActivity();
48 | cardFrontFragment = activity.cardFrontFragment;
49 |
50 |
51 | tv_validity = cardFrontFragment.getValidity();
52 | et_validity.addTextChangedListener(new CreditCardExpiryTextWatcher(et_validity, tv_validity));
53 |
54 | et_validity.setOnEditorActionListener(new TextView.OnEditorActionListener() {
55 | @Override
56 | public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
57 | if (actionId == EditorInfo.IME_ACTION_DONE) {
58 |
59 | if (activity != null) {
60 | activity.nextClick();
61 | return true;
62 | }
63 |
64 | }
65 | return false;
66 | }
67 | });
68 |
69 | et_validity.setOnBackButtonListener(new CreditCardEditText.BackButtonListener() {
70 | @Override
71 | public void onBackClick() {
72 | if(activity!=null)
73 | activity.onBackPressed();
74 | }
75 | });
76 |
77 |
78 | return view;
79 | }
80 |
81 | public String getValidity()
82 | {
83 | if(et_validity!=null)
84 | return et_validity.getText().toString().trim();
85 |
86 | return null;
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/app/src/main/java/com/droidmentor/checkoutflow/Utils/CreditCardFormattingTextWatcher.java:
--------------------------------------------------------------------------------
1 | package com.droidmentor.checkoutflow.Utils;
2 |
3 | import android.text.Editable;
4 | import android.text.TextWatcher;
5 | import android.widget.EditText;
6 | import android.widget.ImageView;
7 | import android.widget.TextView;
8 |
9 | /**
10 | * Created by Jaison on 27/05/17.
11 | */
12 |
13 | public class CreditCardFormattingTextWatcher implements TextWatcher {
14 |
15 | private EditText etCard;
16 | private TextView tvCard;
17 | private ImageView ivType;
18 | private boolean isDelete;
19 | CreditCardType creditCardType;
20 |
21 | public CreditCardFormattingTextWatcher(EditText etcard,TextView tvcard) {
22 | this.etCard=etcard;
23 | this.tvCard=tvcard;
24 | }
25 |
26 | public CreditCardFormattingTextWatcher(EditText etcard,TextView tvcard,CreditCardType creditCardType) {
27 | this.etCard=etcard;
28 | this.tvCard=tvcard;
29 | this.creditCardType=creditCardType;
30 | }
31 |
32 | public CreditCardFormattingTextWatcher(EditText etcard, TextView tvcard, ImageView ivType,CreditCardType creditCardType) {
33 | this.etCard=etcard;
34 | this.tvCard=tvcard;
35 | this.ivType=ivType;
36 | this.creditCardType=creditCardType;
37 | }
38 |
39 |
40 | public CreditCardFormattingTextWatcher(EditText etcard) {
41 | this.etCard=etcard;
42 | }
43 |
44 | @Override
45 | public void beforeTextChanged(CharSequence s, int start, int count, int after) {
46 | }
47 |
48 | @Override
49 | public void onTextChanged(CharSequence s, int start, int before, int count) {
50 | if(before==0)
51 | isDelete=false;
52 | else
53 | isDelete=true;
54 | }
55 |
56 | @Override
57 | public void afterTextChanged(Editable s) {
58 | String source = s.toString();
59 | int length=source.length();
60 |
61 | StringBuilder stringBuilder = new StringBuilder();
62 | stringBuilder.append(source);
63 |
64 | if(length>0 && length%5==0)
65 | {
66 | if(isDelete)
67 | stringBuilder.deleteCharAt(length-1);
68 | else
69 | stringBuilder.insert(length-1," ");
70 | etCard.setText(stringBuilder);
71 | etCard.setSelection(etCard.getText().length());
72 |
73 | }
74 |
75 | if(length>=4&&creditCardType!=null)
76 | creditCardType.setCardType(CreditCardUtils.getCardType(source.trim()));
77 |
78 | if(tvCard!=null)
79 | {
80 | if(length==0)
81 | tvCard.setText("XXXX XXXX XXXX XXXX");
82 | else
83 | tvCard.setText(stringBuilder);
84 | }
85 |
86 | if(ivType!=null&&length==0)
87 | ivType.setImageResource(android.R.color.transparent);
88 |
89 | }
90 |
91 | public interface CreditCardType
92 | {
93 | public void setCardType(int type);
94 | }
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/app/src/main/java/com/droidmentor/checkoutflow/CardFrontFragment.java:
--------------------------------------------------------------------------------
1 | package com.droidmentor.checkoutflow;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v4.content.ContextCompat;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.ImageView;
11 | import android.widget.TextView;
12 |
13 | import com.droidmentor.checkoutflow.Utils.FontTypeChange;
14 |
15 | import butterknife.BindView;
16 | import butterknife.ButterKnife;
17 |
18 | import static com.droidmentor.checkoutflow.Utils.CreditCardUtils.AMEX;
19 | import static com.droidmentor.checkoutflow.Utils.CreditCardUtils.DISCOVER;
20 | import static com.droidmentor.checkoutflow.Utils.CreditCardUtils.MASTERCARD;
21 | import static com.droidmentor.checkoutflow.Utils.CreditCardUtils.NONE;
22 | import static com.droidmentor.checkoutflow.Utils.CreditCardUtils.VISA;
23 |
24 |
25 | /**
26 | * A simple {@link Fragment} subclass.
27 | */
28 | public class CardFrontFragment extends Fragment {
29 |
30 |
31 | @BindView(R.id.tv_card_number)TextView tvNumber;
32 | @BindView(R.id.tv_member_name)TextView tvName;
33 | @BindView(R.id.tv_validity)TextView tvValidity;
34 | @BindView(R.id.ivType)ImageView ivType;
35 |
36 | FontTypeChange fontTypeChange;
37 |
38 | public CardFrontFragment() {
39 | // Required empty public constructor
40 | }
41 |
42 |
43 | @Override
44 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
45 | Bundle savedInstanceState) {
46 | // Inflate the layout for this fragment
47 |
48 | View view=inflater.inflate(R.layout.fragment_card_front, container, false);
49 | ButterKnife.bind(this, view);
50 | fontTypeChange=new FontTypeChange(getActivity());
51 | tvNumber.setTypeface(fontTypeChange.get_fontface(3));
52 | tvName.setTypeface(fontTypeChange.get_fontface(3));
53 |
54 | return view;
55 | }
56 |
57 | public TextView getNumber()
58 | {
59 | return tvNumber;
60 | }
61 | public TextView getName()
62 | {
63 | return tvName;
64 | }
65 | public TextView getValidity()
66 | {
67 | return tvValidity;
68 | }
69 |
70 | public ImageView getCardType()
71 | {
72 | return ivType;
73 | }
74 |
75 |
76 | public void setCardType(int type)
77 | {
78 | switch(type)
79 | {
80 | case VISA:
81 | ivType.setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.ic_visa));
82 | break;
83 | case MASTERCARD:
84 | ivType.setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.ic_mastercard));
85 | break;
86 | case AMEX:
87 | ivType.setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.ic_amex));
88 | break;
89 | case DISCOVER:
90 | ivType.setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.ic_discover));
91 | break;
92 | case NONE:
93 | ivType.setImageResource(android.R.color.transparent);
94 | break;
95 |
96 | }
97 |
98 |
99 | }
100 |
101 |
102 | }
103 |
--------------------------------------------------------------------------------
/app/src/main/java/com/droidmentor/checkoutflow/CCFragment/CCNumberFragment.java:
--------------------------------------------------------------------------------
1 | package com.droidmentor.checkoutflow.CCFragment;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.v4.app.Fragment;
6 | import android.util.Log;
7 | import android.view.KeyEvent;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.view.inputmethod.EditorInfo;
12 | import android.widget.TextView;
13 |
14 | import com.droidmentor.checkoutflow.CardFrontFragment;
15 | import com.droidmentor.checkoutflow.CheckOutActivity;
16 | import com.droidmentor.checkoutflow.R;
17 | import com.droidmentor.checkoutflow.Utils.CreditCardEditText;
18 | import com.droidmentor.checkoutflow.Utils.CreditCardFormattingTextWatcher;
19 |
20 | import butterknife.BindView;
21 | import butterknife.ButterKnife;
22 |
23 |
24 | /**
25 | * A simple {@link Fragment} subclass.
26 | */
27 | public class CCNumberFragment extends Fragment {
28 |
29 |
30 | @BindView(R.id.et_number)
31 | CreditCardEditText et_number;
32 | TextView tv_number;
33 |
34 | CheckOutActivity activity;
35 | CardFrontFragment cardFrontFragment;
36 |
37 | public CCNumberFragment() {
38 | // Required empty public constructor
39 | }
40 |
41 |
42 | @Override
43 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
44 | Bundle savedInstanceState) {
45 | // Inflate the layout for this fragment
46 | View view = inflater.inflate(R.layout.fragment_ccnumber, container, false);
47 | ButterKnife.bind(this, view);
48 |
49 | activity = (CheckOutActivity) getActivity();
50 | cardFrontFragment = activity.cardFrontFragment;
51 |
52 | tv_number = cardFrontFragment.getNumber();
53 |
54 | //Do your stuff
55 | et_number.addTextChangedListener(new CreditCardFormattingTextWatcher(et_number, tv_number,cardFrontFragment.getCardType(),new CreditCardFormattingTextWatcher.CreditCardType() {
56 | @Override
57 | public void setCardType(int type) {
58 | Log.d("Card", "setCardType: "+type);
59 |
60 | cardFrontFragment.setCardType(type);
61 | }
62 | }));
63 |
64 | et_number.setOnEditorActionListener(new TextView.OnEditorActionListener() {
65 | @Override
66 | public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
67 | if (actionId == EditorInfo.IME_ACTION_DONE) {
68 |
69 | if(activity!=null)
70 | {
71 | activity.nextClick();
72 | return true;
73 | }
74 |
75 | }
76 | return false;
77 | }
78 | });
79 |
80 | et_number.setOnBackButtonListener(new CreditCardEditText.BackButtonListener() {
81 | @Override
82 | public void onBackClick() {
83 | if(activity!=null)
84 | activity.onBackPressed();
85 | }
86 | });
87 |
88 | return view;
89 | }
90 |
91 | public String getCardNumber()
92 | {
93 | if(et_number!=null)
94 | return et_number.getText().toString().trim();
95 |
96 | return null;
97 | }
98 |
99 |
100 |
101 | }
102 |
--------------------------------------------------------------------------------
/app/src/main/java/com/droidmentor/checkoutflow/CCFragment/CCNameFragment.java:
--------------------------------------------------------------------------------
1 | package com.droidmentor.checkoutflow.CCFragment;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.v4.app.Fragment;
6 | import android.text.Editable;
7 | import android.text.TextUtils;
8 | import android.text.TextWatcher;
9 | import android.view.KeyEvent;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.view.inputmethod.EditorInfo;
14 | import android.widget.TextView;
15 |
16 | import com.droidmentor.checkoutflow.CardFrontFragment;
17 | import com.droidmentor.checkoutflow.CheckOutActivity;
18 | import com.droidmentor.checkoutflow.R;
19 | import com.droidmentor.checkoutflow.Utils.CreditCardEditText;
20 |
21 | import butterknife.BindView;
22 | import butterknife.ButterKnife;
23 |
24 | /**
25 | * A simple {@link Fragment} subclass.
26 | */
27 | public class CCNameFragment extends Fragment {
28 |
29 |
30 | @BindView(R.id.et_name)
31 | CreditCardEditText et_name;
32 | TextView tv_Name;
33 |
34 | CheckOutActivity activity;
35 | CardFrontFragment cardFrontFragment;
36 |
37 | public CCNameFragment() {
38 | // Required empty public constructor
39 | }
40 |
41 |
42 | @Override
43 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
44 | Bundle savedInstanceState) {
45 |
46 | // Inflate the layout for this fragment
47 | View view = inflater.inflate(R.layout.fragment_ccname, container, false);
48 | ButterKnife.bind(this, view);
49 |
50 | activity = (CheckOutActivity) getActivity();
51 | cardFrontFragment = activity.cardFrontFragment;
52 |
53 | tv_Name = cardFrontFragment.getName();
54 |
55 | et_name.addTextChangedListener(new TextWatcher() {
56 | @Override
57 | public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
58 |
59 | }
60 |
61 | @Override
62 | public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
63 |
64 | }
65 |
66 | @Override
67 | public void afterTextChanged(Editable editable) {
68 |
69 | if(tv_Name!=null)
70 | {
71 | if (TextUtils.isEmpty(editable.toString().trim()))
72 | tv_Name.setText("CARD HOLDER");
73 | else
74 | tv_Name.setText(editable.toString());
75 |
76 | }
77 |
78 | }
79 | });
80 |
81 | et_name.setOnEditorActionListener(new TextView.OnEditorActionListener() {
82 | @Override
83 | public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
84 | if (actionId == EditorInfo.IME_ACTION_DONE) {
85 |
86 | if(activity!=null)
87 | {
88 | activity.nextClick();
89 | return true;
90 | }
91 |
92 | }
93 | return false;
94 | }
95 | });
96 |
97 |
98 | et_name.setOnBackButtonListener(new CreditCardEditText.BackButtonListener() {
99 | @Override
100 | public void onBackClick() {
101 | if(activity!=null)
102 | activity.onBackPressed();
103 | }
104 | });
105 |
106 | return view;
107 | }
108 |
109 | public String getName()
110 | {
111 | if(et_name!=null)
112 | return et_name.getText().toString().trim();
113 |
114 | return null;
115 | }
116 |
117 |
118 | }
119 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_card_front.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
14 |
15 |
20 |
21 |
22 |
23 |
29 |
30 |
38 |
39 |
43 |
44 |
51 |
52 |
59 |
60 |
61 |
62 |
71 |
72 |
73 |
74 |
83 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/app/src/main/java/com/droidmentor/checkoutflow/CCFragment/CCSecureCodeFragment.java:
--------------------------------------------------------------------------------
1 | package com.droidmentor.checkoutflow.CCFragment;
2 |
3 |
4 | import android.os.Bundle;
5 | import android.support.v4.app.Fragment;
6 | import android.text.Editable;
7 | import android.text.TextUtils;
8 | import android.text.TextWatcher;
9 | import android.util.Log;
10 | import android.view.KeyEvent;
11 | import android.view.LayoutInflater;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 | import android.view.inputmethod.EditorInfo;
15 | import android.widget.TextView;
16 |
17 | import com.droidmentor.checkoutflow.CheckOutActivity;
18 | import com.droidmentor.checkoutflow.R;
19 | import com.droidmentor.checkoutflow.Utils.CreditCardEditText;
20 |
21 | import butterknife.BindView;
22 | import butterknife.ButterKnife;
23 |
24 | import static android.content.ContentValues.TAG;
25 | import static com.droidmentor.checkoutflow.R.id.et_number;
26 |
27 | /**
28 | * A simple {@link Fragment} subclass.
29 | */
30 | public class CCSecureCodeFragment extends Fragment {
31 |
32 |
33 | @BindView(R.id.et_cvv)
34 | CreditCardEditText et_cvv;
35 | TextView tv_cvv;
36 |
37 | CheckOutActivity activity;
38 |
39 | public CCSecureCodeFragment() {
40 | // Required empty public constructor
41 | }
42 |
43 |
44 | @Override
45 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
46 | Bundle savedInstanceState) {
47 |
48 | // Inflate the layout for this fragment
49 | View view = inflater.inflate(R.layout.fragment_ccsecure_code, container, false);
50 | ButterKnife.bind(this, view);
51 |
52 | activity = (CheckOutActivity) getActivity();
53 |
54 | et_cvv.addTextChangedListener(new TextWatcher() {
55 | @Override
56 | public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
57 |
58 | }
59 |
60 | @Override
61 | public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
62 |
63 | }
64 |
65 | @Override
66 | public void afterTextChanged(Editable editable) {
67 |
68 | if (tv_cvv != null) {
69 | if (TextUtils.isEmpty(editable.toString().trim()))
70 | tv_cvv.setText("XXX");
71 | else
72 | tv_cvv.setText(editable.toString());
73 |
74 | } else
75 | Log.d(TAG, "afterTextChanged: cvv null");
76 |
77 | }
78 | });
79 |
80 | et_cvv.setOnEditorActionListener(new TextView.OnEditorActionListener() {
81 | @Override
82 | public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
83 | if (actionId == EditorInfo.IME_ACTION_DONE) {
84 |
85 | if(activity!=null)
86 | {
87 | activity.nextClick();
88 | return true;
89 | }
90 |
91 | }
92 | return false;
93 | }
94 | });
95 |
96 | et_cvv.setOnBackButtonListener(new CreditCardEditText.BackButtonListener() {
97 | @Override
98 | public void onBackClick() {
99 | if(activity!=null)
100 | activity.onBackPressed();
101 | }
102 | });
103 |
104 | return view;
105 |
106 | }
107 |
108 | public void setCvv(TextView tv) {
109 | tv_cvv = tv;
110 | }
111 |
112 | public String getValue() {
113 |
114 | String getValue = "";
115 |
116 | if (et_cvv != null) {
117 | getValue = et_cvv.getText().toString().trim();
118 | }
119 | return getValue;
120 | }
121 |
122 | }
123 |
--------------------------------------------------------------------------------
/app/src/main/java/com/droidmentor/checkoutflow/Utils/CreditCardUtils.java:
--------------------------------------------------------------------------------
1 | package com.droidmentor.checkoutflow.Utils;
2 |
3 | import android.text.TextUtils;
4 | import android.util.Log;
5 |
6 | import java.util.Calendar;
7 |
8 | /**
9 | * Created by Jaison on 23/06/17.
10 | */
11 |
12 | public class CreditCardUtils {
13 | public static final int NONE = 0;
14 |
15 | public static final int VISA = 1;
16 | public static final int MASTERCARD = 2;
17 | public static final int DISCOVER = 3;
18 | public static final int AMEX = 4;
19 |
20 | public static final String VISA_PREFIX = "4";
21 | public static final String MASTERCARD_PREFIX = "51,52,53,54,55,";
22 | public static final String DISCOVER_PREFIX = "6011";
23 | public static final String AMEX_PREFIX = "34,37,";
24 |
25 | public static int getCardType(String cardNumber) {
26 |
27 | if (cardNumber.substring(0, 1).equals(VISA_PREFIX))
28 | return VISA;
29 | else if (MASTERCARD_PREFIX.contains(cardNumber.substring(0, 2) + ","))
30 | return MASTERCARD;
31 | else if (AMEX_PREFIX.contains(cardNumber.substring(0, 2) + ","))
32 | return AMEX;
33 | else if (cardNumber.substring(0, 4).equals(DISCOVER_PREFIX))
34 | return DISCOVER;
35 |
36 | return NONE;
37 | }
38 |
39 | public static boolean isValid(String cardNumber) {
40 | if (!TextUtils.isEmpty(cardNumber) && cardNumber.length() >= 4)
41 | if (getCardType(cardNumber) == VISA && ((cardNumber.length() == 13 || cardNumber.length() == 16)))
42 | return true;
43 | else if (getCardType(cardNumber) == MASTERCARD && cardNumber.length() == 16)
44 | return true;
45 | else if (getCardType(cardNumber) == AMEX && cardNumber.length() == 15)
46 | return true;
47 | else if (getCardType(cardNumber) == DISCOVER && cardNumber.length() == 16)
48 | return true;
49 | return false;
50 | }
51 |
52 | public static boolean isValidDate(String cardValidity) {
53 | if (!TextUtils.isEmpty(cardValidity) && cardValidity.length() == 5)
54 | {
55 | String month=cardValidity.substring(0,2);
56 | String year=cardValidity.substring(3,5);
57 |
58 | int monthpart=-1,yearpart=-1;
59 |
60 | try
61 | {
62 | monthpart=Integer.parseInt(month)-1;
63 | yearpart=Integer.parseInt(year);
64 |
65 | Calendar current = Calendar.getInstance();
66 | current.set(Calendar.DATE,1);
67 | current.set(Calendar.HOUR,12);
68 | current.set(Calendar.MINUTE,0);
69 | current.set(Calendar.SECOND,0);
70 | current.set(Calendar.MILLISECOND,0);
71 |
72 | Calendar validity=Calendar.getInstance();
73 | validity.set(Calendar.DATE,1);
74 | validity.set(Calendar.HOUR,12);
75 | validity.set(Calendar.MINUTE,0);
76 | validity.set(Calendar.SECOND,0);
77 | validity.set(Calendar.MILLISECOND,0);
78 |
79 | if(monthpart>-1&&monthpart<12&&yearpart>-1)
80 | {
81 | validity.set(Calendar.MONTH,monthpart);
82 | validity.set(Calendar.YEAR,yearpart+2000);
83 | }
84 | else
85 | return false;
86 |
87 | Log.d("Util", "isValidDate: "+current.compareTo(validity));
88 |
89 | if(current.compareTo(validity)<=0)
90 | return true;
91 | }
92 | catch(Exception e)
93 | {
94 | e.printStackTrace();
95 | }
96 | }
97 |
98 | return false;
99 | }
100 |
101 | }
102 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/java/com/droidmentor/checkoutflow/CheckOutActivity.java:
--------------------------------------------------------------------------------
1 | package com.droidmentor.checkoutflow;
2 |
3 | import android.app.FragmentManager;
4 | import android.os.Bundle;
5 | import android.support.v4.app.FragmentActivity;
6 | import android.support.v4.view.ViewPager;
7 | import android.text.TextUtils;
8 | import android.util.Log;
9 | import android.view.View;
10 | import android.widget.Button;
11 | import android.widget.Toast;
12 |
13 | import com.droidmentor.checkoutflow.CCFragment.CCNameFragment;
14 | import com.droidmentor.checkoutflow.CCFragment.CCNumberFragment;
15 | import com.droidmentor.checkoutflow.CCFragment.CCSecureCodeFragment;
16 | import com.droidmentor.checkoutflow.CCFragment.CCValidityFragment;
17 | import com.droidmentor.checkoutflow.Utils.CreditCardUtils;
18 | import com.droidmentor.checkoutflow.Utils.ViewPagerAdapter;
19 |
20 | import butterknife.BindView;
21 | import butterknife.ButterKnife;
22 |
23 | public class CheckOutActivity extends FragmentActivity implements FragmentManager.OnBackStackChangedListener {
24 |
25 | @BindView(R.id.btnNext)
26 | Button btnNext;
27 |
28 | public CardFrontFragment cardFrontFragment;
29 | public CardBackFragment cardBackFragment;
30 |
31 | //This is our viewPager
32 | private ViewPager viewPager;
33 |
34 | CCNumberFragment numberFragment;
35 | CCNameFragment nameFragment;
36 | CCValidityFragment validityFragment;
37 | CCSecureCodeFragment secureCodeFragment;
38 |
39 | int total_item;
40 | boolean backTrack = false;
41 |
42 | private boolean mShowingBack = false;
43 |
44 | String cardNumber, cardCVV, cardValidity, cardName;
45 |
46 |
47 | @Override
48 | protected void onCreate(Bundle savedInstanceState) {
49 | super.onCreate(savedInstanceState);
50 | setContentView(R.layout.activity_check_out);
51 |
52 | ButterKnife.bind(this);
53 |
54 |
55 | cardFrontFragment = new CardFrontFragment();
56 | cardBackFragment = new CardBackFragment();
57 |
58 | if (savedInstanceState == null) {
59 | // Add the fragment to the 'fragment_container' FrameLayout
60 | getSupportFragmentManager().beginTransaction()
61 | .add(R.id.fragment_container, cardFrontFragment).commit();
62 |
63 | } else {
64 | mShowingBack = (getFragmentManager().getBackStackEntryCount() > 0);
65 | }
66 |
67 | getFragmentManager().addOnBackStackChangedListener(this);
68 |
69 | //Initializing viewPager
70 | viewPager = (ViewPager) findViewById(R.id.viewpager);
71 | viewPager.setOffscreenPageLimit(4);
72 | setupViewPager(viewPager);
73 |
74 |
75 | viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
76 | @Override
77 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
78 |
79 | }
80 |
81 | @Override
82 | public void onPageSelected(int position) {
83 | if (position == total_item)
84 | btnNext.setText("SUBMIT");
85 | else
86 | btnNext.setText("NEXT");
87 |
88 | Log.d("track", "onPageSelected: " + position);
89 |
90 | if (position == total_item) {
91 | flipCard();
92 | backTrack = true;
93 | } else if (position == total_item - 1 && backTrack) {
94 | flipCard();
95 | backTrack = false;
96 | }
97 |
98 | }
99 |
100 | @Override
101 | public void onPageScrollStateChanged(int state) {
102 |
103 | }
104 | });
105 |
106 | btnNext.setOnClickListener(new View.OnClickListener() {
107 | @Override
108 | public void onClick(View view) {
109 | int pos = viewPager.getCurrentItem();
110 | if (pos < total_item) {
111 | viewPager.setCurrentItem(pos + 1);
112 | } else {
113 | checkEntries();
114 | }
115 |
116 | }
117 | });
118 |
119 |
120 | }
121 |
122 | public void checkEntries() {
123 | cardName = nameFragment.getName();
124 | cardNumber = numberFragment.getCardNumber();
125 | cardValidity = validityFragment.getValidity();
126 | cardCVV = secureCodeFragment.getValue();
127 |
128 | if (TextUtils.isEmpty(cardName)) {
129 | Toast.makeText(CheckOutActivity.this, "Enter Valid Name", Toast.LENGTH_SHORT).show();
130 | } else if (TextUtils.isEmpty(cardNumber) || !CreditCardUtils.isValid(cardNumber.replace(" ",""))) {
131 | Toast.makeText(CheckOutActivity.this, "Enter Valid card number", Toast.LENGTH_SHORT).show();
132 | } else if (TextUtils.isEmpty(cardValidity)||!CreditCardUtils.isValidDate(cardValidity)) {
133 | Toast.makeText(CheckOutActivity.this, "Enter correct validity", Toast.LENGTH_SHORT).show();
134 | } else if (TextUtils.isEmpty(cardCVV)||cardCVV.length()<3) {
135 | Toast.makeText(CheckOutActivity.this, "Enter valid security number", Toast.LENGTH_SHORT).show();
136 | } else
137 | Toast.makeText(CheckOutActivity.this, "Your card is added", Toast.LENGTH_SHORT).show();
138 |
139 | }
140 |
141 | @Override
142 | public void onBackStackChanged() {
143 | mShowingBack = (getFragmentManager().getBackStackEntryCount() > 0);
144 | }
145 |
146 | private void setupViewPager(ViewPager viewPager) {
147 | ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager());
148 | numberFragment = new CCNumberFragment();
149 | nameFragment = new CCNameFragment();
150 | validityFragment = new CCValidityFragment();
151 | secureCodeFragment = new CCSecureCodeFragment();
152 | adapter.addFragment(numberFragment);
153 | adapter.addFragment(nameFragment);
154 | adapter.addFragment(validityFragment);
155 | adapter.addFragment(secureCodeFragment);
156 |
157 | total_item = adapter.getCount() - 1;
158 | viewPager.setAdapter(adapter);
159 |
160 | }
161 |
162 | private void flipCard() {
163 | if (mShowingBack) {
164 | getFragmentManager().popBackStack();
165 | return;
166 | }
167 | // Flip to the back.
168 | //setCustomAnimations(int enter, int exit, int popEnter, int popExit)
169 |
170 | mShowingBack = true;
171 |
172 | getFragmentManager()
173 | .beginTransaction()
174 | .setCustomAnimations(
175 | R.animator.card_flip_right_in,
176 | R.animator.card_flip_right_out,
177 | R.animator.card_flip_left_in,
178 | R.animator.card_flip_left_out)
179 | .replace(R.id.fragment_container, cardBackFragment)
180 | .addToBackStack(null)
181 | .commit();
182 | }
183 |
184 | @Override
185 | public void onBackPressed() {
186 | int pos = viewPager.getCurrentItem();
187 | if (pos > 0) {
188 | viewPager.setCurrentItem(pos - 1);
189 | } else
190 | super.onBackPressed();
191 | }
192 |
193 | public void nextClick() {
194 | btnNext.performClick();
195 | }
196 | }
197 |
--------------------------------------------------------------------------------
/.idea/misc.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 |
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 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 | Android
112 |
113 |
114 | Android > Lint > Accessibility
115 |
116 |
117 | Android > Lint > Correctness
118 |
119 |
120 | Android > Lint > Performance
121 |
122 |
123 | Android > Lint > Usability > Icons
124 |
125 |
126 | Groovy
127 |
128 |
129 | Ignore
130 |
131 |
132 | Initialization issuesJava
133 |
134 |
135 | Internationalization issues
136 |
137 |
138 | Internationalization issuesJava
139 |
140 |
141 | JUnit issuesJava
142 |
143 |
144 | Java
145 |
146 |
147 | Probable bugsGroovy
148 |
149 |
150 | Serialization issuesJava
151 |
152 |
153 | Threading issuesGroovy
154 |
155 |
156 | Threading issuesJava
157 |
158 |
159 |
160 |
161 | Android > Lint > Correctness
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 | 1.8
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
--------------------------------------------------------------------------------