diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..6df61b7
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,37 @@
+.DS_Store
+
+# built application files
+*.apk
+*.ap_
+
+# files for the dex VM
+*.dex
+
+# Java class files
+*.class
+
+# generated files
+bin/
+gen/
+
+# Local configuration file (sdk path, etc)
+local.properties
+
+# Eclipse project files
+.classpath
+.project
+
+# Android Studio
+.idea/
+.gradle
+/*/local.properties
+/*/out
+/*/*/build
+build
+/*/*/production
+*.iml
+*.iws
+*.ipr
+*~
+*.swp
+*.alloc
\ No newline at end of file
diff --git a/README.md b/README.md
index 6b9cc7b..92ccfb6 100644
--- a/README.md
+++ b/README.md
@@ -122,7 +122,7 @@ repositories {
}
dependencies {
- compile 'com.github.cooltechworks:CreditCardView:v1.0.1'
+ compile 'com.github.cooltechworks:CreditCardView:v1.0.2'
}
```
- Add the following activity to your AndroidManifest.xml
diff --git a/app/build/intermediates/transforms/instantRunSlicer/debug/folders/1/5/slice_1/buildId.txt b/app/build/intermediates/transforms/instantRunSlicer/debug/folders/1/5/slice_1/buildId.txt
new file mode 100644
index 0000000..9851264
--- /dev/null
+++ b/app/build/intermediates/transforms/instantRunSlicer/debug/folders/1/5/slice_1/buildId.txt
@@ -0,0 +1 @@
+341292733940663
\ No newline at end of file
diff --git a/app/src/main/java/com/cooltechworks/creditcarddesign/sample/MainActivity.java b/app/src/main/java/com/cooltechworks/creditcarddesign/sample/MainActivity.java
index aacb718..2ade401 100644
--- a/app/src/main/java/com/cooltechworks/creditcarddesign/sample/MainActivity.java
+++ b/app/src/main/java/com/cooltechworks/creditcarddesign/sample/MainActivity.java
@@ -83,10 +83,11 @@ public void onClick(View v) {
intent.putExtra(CreditCardUtils.EXTRA_CARD_HOLDER_NAME, cardHolderName);
intent.putExtra(CreditCardUtils.EXTRA_CARD_NUMBER, cardNumber);
intent.putExtra(CreditCardUtils.EXTRA_CARD_EXPIRY, expiry);
- intent.putExtra(CreditCardUtils.EXTRA_CARD_CVV, cvv);
- intent.putExtra(CreditCardUtils.EXTRA_CARD_SHOW_CARD_SIDE, CreditCardUtils.CARD_SIDE_FRONT);
- intent.putExtra(CreditCardUtils.EXTRA_VALIDATE_EXPIRY_DATE, true);
+ intent.putExtra(CreditCardUtils.EXTRA_CARD_SHOW_CARD_SIDE, CreditCardUtils.CARD_SIDE_BACK);
+ intent.putExtra(CreditCardUtils.EXTRA_VALIDATE_EXPIRY_DATE, false);
+ // start at the CVV activity to edit it as it is not being passed
+ intent.putExtra(CreditCardUtils.EXTRA_ENTRY_START_PAGE, CreditCardUtils.CARD_CVV_PAGE);
startActivityForResult(intent, index);
}
});
diff --git a/build.gradle b/build.gradle
index 175c431..66df64d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.2.1'
+ classpath 'com.android.tools.build:gradle:2.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
diff --git a/creditcarddesign/build.gradle b/creditcarddesign/build.gradle
index c214d0a..e70c8f3 100644
--- a/creditcarddesign/build.gradle
+++ b/creditcarddesign/build.gradle
@@ -20,7 +20,6 @@ android {
}
dependencies {
-
final SUPPORT_VERSION = "25.0.1"
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:$SUPPORT_VERSION"
diff --git a/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/CardEditActivity.java b/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/CardEditActivity.java
index 50a9ffd..c43e45a 100644
--- a/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/CardEditActivity.java
+++ b/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/CardEditActivity.java
@@ -17,11 +17,12 @@
import com.cooltechworks.creditcarddesign.pager.CardFragmentAdapter;
import com.cooltechworks.creditcarddesign.pager.CardFragmentAdapter.ICardEntryCompleteListener;
+import static com.cooltechworks.creditcarddesign.CreditCardUtils.CARD_NAME_PAGE;
import static com.cooltechworks.creditcarddesign.CreditCardUtils.EXTRA_CARD_CVV;
import static com.cooltechworks.creditcarddesign.CreditCardUtils.EXTRA_CARD_EXPIRY;
import static com.cooltechworks.creditcarddesign.CreditCardUtils.EXTRA_CARD_HOLDER_NAME;
-import static com.cooltechworks.creditcarddesign.CreditCardUtils.*;
-
+import static com.cooltechworks.creditcarddesign.CreditCardUtils.EXTRA_CARD_NUMBER;
+import static com.cooltechworks.creditcarddesign.CreditCardUtils.EXTRA_ENTRY_START_PAGE;
public class CardEditActivity extends AppCompatActivity {
@@ -34,6 +35,7 @@ public class CardEditActivity extends AppCompatActivity {
private String mCVV;
private String mCardHolderName;
private String mExpiry;
+ private int mStartPage = 0;
private CardFragmentAdapter mCardAdapter;
@Override
@@ -49,11 +51,10 @@ public void onClick(View v) {
int max = pager.getAdapter().getCount();
- if(pager.getCurrentItem() == max -1) {
+ if (pager.getCurrentItem() == max - 1) {
// if last card.
onDoneTapped();
- }
- else {
+ } else {
showNext();
}
}
@@ -67,65 +68,66 @@ public void onClick(View v) {
setKeyboardVisibility(true);
mCreditCardView = (CreditCardView) findViewById(R.id.credit_card_view);
+ Bundle args = savedInstanceState != null ? savedInstanceState : getIntent().getExtras();
+
+ checkParams(args);
+ loadPager(args);
-
- if(savedInstanceState != null) {
- checkParams(savedInstanceState);
+ if (mStartPage > 0 && mStartPage <= CARD_NAME_PAGE) {
+ getViewPager().setCurrentItem(mStartPage);
}
- else {
- checkParams(getIntent().getExtras());
- }
-
- loadPager();
-
}
private void checkParams(Bundle bundle) {
-
-
- if(bundle == null) {
+ if (bundle == null) {
return;
}
mCardHolderName = bundle.getString(EXTRA_CARD_HOLDER_NAME);
mCVV = bundle.getString(EXTRA_CARD_CVV);
mExpiry = bundle.getString(EXTRA_CARD_EXPIRY);
mCardNumber = bundle.getString(EXTRA_CARD_NUMBER);
+ mStartPage = bundle.getInt(EXTRA_ENTRY_START_PAGE);
-
+ int maxCvvLength = CardSelector.selectCard(mCardNumber).getCvvLength();
+ if (mCVV != null && mCVV.length() >= maxCvvLength) {
+ mCVV = mCVV.substring(0, maxCvvLength);
+ }
mCreditCardView.setCVV(mCVV);
mCreditCardView.setCardHolderName(mCardHolderName);
mCreditCardView.setCardExpiry(mExpiry);
mCreditCardView.setCardNumber(mCardNumber);
-
-
- if(mCardAdapter != null) {
+ if (mCardAdapter != null) {
+ mCardAdapter.setMaxCVV(maxCvvLength);
mCardAdapter.notifyDataSetChanged();
}
}
public void refreshNextButton() {
-
ViewPager pager = (ViewPager) findViewById(R.id.card_field_container_pager);
int max = pager.getAdapter().getCount();
int text = R.string.next;
- if(pager.getCurrentItem() == max -1) {
+ if (pager.getCurrentItem() == max - 1) {
text = R.string.done;
}
- ((TextView)findViewById(R.id.next)).setText(text);
+ ((TextView) findViewById(R.id.next)).setText(text);
}
- public void loadPager() {
+ ViewPager getViewPager() {
+ return (ViewPager) findViewById(R.id.card_field_container_pager);
+ }
- ViewPager pager = (ViewPager) findViewById(R.id.card_field_container_pager);
+ public void loadPager(Bundle bundle) {
+ ViewPager pager = getViewPager();
pager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
- public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {}
+ public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
+ }
@Override
public void onPageSelected(int position) {
@@ -145,15 +147,15 @@ public void onPageSelected(int position) {
}
@Override
- public void onPageScrollStateChanged(int state) {}
+ public void onPageScrollStateChanged(int state) {
+ }
});
pager.setOffscreenPageLimit(4);
- mCardAdapter = new CardFragmentAdapter(getSupportFragmentManager(),getIntent().getExtras());
+ mCardAdapter = new CardFragmentAdapter(getSupportFragmentManager(), bundle);
mCardAdapter.setOnCardEntryCompleteListener(new ICardEntryCompleteListener() {
@Override
public void onCardEntryComplete(int currentIndex) {
-
showNext();
}
@@ -161,9 +163,11 @@ public void onCardEntryComplete(int currentIndex) {
public void onCardEntryEdit(int currentIndex, String entryValue) {
switch (currentIndex) {
case 0:
-
- mCardNumber = entryValue.replace(CreditCardUtils.SPACE_SEPERATOR,"");
+ mCardNumber = entryValue.replace(CreditCardUtils.SPACE_SEPERATOR, "");
mCreditCardView.setCardNumber(mCardNumber);
+ if (mCardAdapter != null) {
+ mCardAdapter.setMaxCVV(CardSelector.selectCard(mCardNumber).getCvvLength());
+ }
break;
case 1:
mExpiry = entryValue;
@@ -174,7 +178,7 @@ public void onCardEntryEdit(int currentIndex, String entryValue) {
mCreditCardView.setCVV(entryValue);
break;
case 3:
- mCardHolderName = entryValue;
+ mCardHolderName = entryValue;
mCreditCardView.setCardHolderName(entryValue);
break;
}
@@ -184,18 +188,16 @@ public void onCardEntryEdit(int currentIndex, String entryValue) {
pager.setAdapter(mCardAdapter);
int cardSide = getIntent().getIntExtra(CreditCardUtils.EXTRA_CARD_SHOW_CARD_SIDE, CreditCardUtils.CARD_SIDE_FRONT);
- if(cardSide == CreditCardUtils.CARD_SIDE_BACK) {
- pager.setCurrentItem(2);
+ if (cardSide == CreditCardUtils.CARD_SIDE_BACK) {
+ pager.setCurrentItem(2);
}
}
public void onSaveInstanceState(Bundle outState) {
-
- outState.putString(EXTRA_CARD_CVV,mCVV);
- outState.putString(EXTRA_CARD_HOLDER_NAME,mCardHolderName);
- outState.putString(EXTRA_CARD_EXPIRY,mExpiry);
- outState.putString(EXTRA_CARD_NUMBER,mCardNumber);
-
+ outState.putString(EXTRA_CARD_CVV, mCVV);
+ outState.putString(EXTRA_CARD_HOLDER_NAME, mCardHolderName);
+ outState.putString(EXTRA_CARD_EXPIRY, mExpiry);
+ outState.putString(EXTRA_CARD_NUMBER, mCardNumber);
super.onSaveInstanceState(outState);
}
@@ -207,10 +209,14 @@ public void onRestoreInstanceState(Bundle inState) {
public void showPrevious() {
-
final ViewPager pager = (ViewPager) findViewById(R.id.card_field_container_pager);
int currentIndex = pager.getCurrentItem();
+ if (currentIndex == 0) {
+ setResult(RESULT_CANCELED);
+ finish();
+ }
+
if (currentIndex - 1 >= 0) {
pager.setCurrentItem(currentIndex - 1);
}
@@ -219,7 +225,6 @@ public void showPrevious() {
}
public void showNext() {
-
final ViewPager pager = (ViewPager) findViewById(R.id.card_field_container_pager);
CardFragmentAdapter adapter = (CardFragmentAdapter) pager.getAdapter();
@@ -238,7 +243,6 @@ public void showNext() {
}
private void onDoneTapped() {
-
Intent intent = new Intent();
intent.putExtra(EXTRA_CARD_CVV, mCVV);
@@ -246,11 +250,8 @@ private void onDoneTapped() {
intent.putExtra(EXTRA_CARD_EXPIRY, mExpiry);
intent.putExtra(EXTRA_CARD_NUMBER, mCardNumber);
-
- setResult(RESULT_OK,intent);
+ setResult(RESULT_OK, intent);
finish();
-
-
}
// from the link above
@@ -258,7 +259,6 @@ private void onDoneTapped() {
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
-
// Checks whether a hardware keyboard is available
if (newConfig.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
@@ -271,10 +271,8 @@ public void onConfigurationChanged(Configuration newConfig) {
}
private void setKeyboardVisibility(boolean visible) {
-
final EditText editText = (EditText) findViewById(R.id.card_number_field);
-
if (!visible) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
@@ -283,11 +281,9 @@ private void setKeyboardVisibility(boolean visible) {
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
}
-
+
@Override
public void onBackPressed() {
this.finish();
}
-
-
}
diff --git a/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/CardSelector.java b/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/CardSelector.java
index bd9912f..7b63422 100644
--- a/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/CardSelector.java
+++ b/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/CardSelector.java
@@ -5,11 +5,17 @@
*/
public class CardSelector {
- 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);
- 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);
- 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);
- 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);
- private static final java.lang.String AMEX_PREFIX = "3";
+ 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);
+ 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);
+ 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);
+ 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);
+
+ private static final char PREFIX_AMEX = '3';
+ private static final char PREFIX_VISA = '4';
+ private static final char PREFIX_MASTER = '5';
+
+ public static final int CVV_LENGHT_DEFAULT = 3;
+ public static final int CVV_LENGHT_AMEX = 4;
private int mResCardId;
@@ -17,16 +23,17 @@ public class CardSelector {
private int mResChipInnerId;
private int mResCenterImageId;
private int mResLogoId;
-
- public CardSelector(int mDrawableCard, int mDrawableChipOuter, int mDrawableChipInner, int mDrawableCenterImage, int logoId) {
+ private int mCvvLength = CVV_LENGHT_DEFAULT;
+
+ public CardSelector(int mDrawableCard, int mDrawableChipOuter, int mDrawableChipInner, int mDrawableCenterImage, int logoId, int cvvLength) {
this.mResCardId = mDrawableCard;
this.mResChipOuterId = mDrawableChipOuter;
this.mResChipInnerId = mDrawableChipInner;
this.mResCenterImageId = mDrawableCenterImage;
this.mResLogoId = logoId;
+ this.mCvvLength = cvvLength;
}
-
public int getResCardId() {
return mResCardId;
}
@@ -67,15 +74,21 @@ public void setResLogoId(int mResLogoId) {
this.mResLogoId = mResLogoId;
}
+ public int getCvvLength() {
+ return mCvvLength;
+ }
- public static CardSelector selectCard(char cardFirstChar) {
+ public void setCvvLength(int mCvvLength) {
+ this.mCvvLength = mCvvLength;
+ }
+ public static CardSelector selectCard(char cardFirstChar) {
switch (cardFirstChar) {
- case '4':
+ case PREFIX_VISA:
return VISA;
- case '5':
+ case PREFIX_MASTER:
return MASTER;
- case '3':
+ case PREFIX_AMEX:
return AMEX;
default:
return DEFAULT;
@@ -83,29 +96,22 @@ public static CardSelector selectCard(char cardFirstChar) {
}
public static CardSelector selectCard(String cardNumber) {
-
- if(cardNumber != null && cardNumber.length() >= 3) {
+ if (cardNumber != null && cardNumber.length() >= 3) {
CardSelector selector = selectCard(cardNumber.charAt(0));
-
- if(cardNumber.startsWith(AMEX_PREFIX)) {
- return AMEX;
- }
- if(selector != DEFAULT) {
+ if (selector != DEFAULT) {
+ 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};
+ int hash = cardNumber.substring(0, 3).hashCode();
- 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};
- int hash = cardNumber.substring(0,3).hashCode();
-
- if(hash<0) {
+ if (hash < 0) {
hash = hash * -1;
}
int index = hash % drawables.length;
int chipIndex = hash % 3;
- int[] chipOuter = { R.drawable.chip, R.drawable.chip_yellow, android.R.color.transparent};
- int[] chipInner = { R.drawable.chip_inner, R.drawable.chip_yellow_inner,android.R.color.transparent};
-
+ int[] chipOuter = {R.drawable.chip, R.drawable.chip_yellow, android.R.color.transparent};
+ int[] chipInner = {R.drawable.chip_inner, R.drawable.chip_yellow_inner, android.R.color.transparent};
selector.setResCardId(drawables[index]);
selector.setResChipOuterId(chipOuter[chipIndex]);
@@ -114,6 +120,7 @@ public static CardSelector selectCard(String cardNumber) {
return selector;
}
}
+
return DEFAULT;
}
}
diff --git a/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/CreditCardUtils.java b/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/CreditCardUtils.java
index 212bf57..05966f6 100755
--- a/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/CreditCardUtils.java
+++ b/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/CreditCardUtils.java
@@ -21,10 +21,13 @@ public class CreditCardUtils {
public static final String EXTRA_CARD_HOLDER_NAME = "card_holder_name";
public static final String EXTRA_CARD_SHOW_CARD_SIDE = "card_side";
public static final String EXTRA_VALIDATE_EXPIRY_DATE = "expiry_date";
-
+ public static final String EXTRA_ENTRY_START_PAGE = "start_page";
public static final int CARD_SIDE_FRONT = 1,CARD_SIDE_BACK=0;
+ public static final int CARD_NUMBER_PAGE = 0, CARD_EXPIRY_PAGE = 1;
+ public static final int CARD_CVV_PAGE = 2, CARD_NAME_PAGE = 3;
+
public static final String SPACE_SEPERATOR = " ";
public static final String DOUBLE_SPACE_SEPERATOR = " ";
diff --git a/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/CardCVVFragment.java b/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/CardCVVFragment.java
index 331bbb1..08a7d11 100644
--- a/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/CardCVVFragment.java
+++ b/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/CardCVVFragment.java
@@ -2,11 +2,13 @@
import android.os.Bundle;
import android.text.Editable;
+import android.text.InputFilter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
+import com.cooltechworks.creditcarddesign.CardSelector;
import com.cooltechworks.creditcarddesign.R;
import static com.cooltechworks.creditcarddesign.CreditCardUtils.EXTRA_CARD_CVV;
@@ -15,26 +17,24 @@
/**
* Created by sharish on 9/1/15.
*/
-public class CardCVVFragment extends CreditCardFragment {
+public class CardCVVFragment extends CreditCardFragment {
private EditText mCardCVVView;
+ private int mMaxCVV = CardSelector.CVV_LENGHT_DEFAULT;
public CardCVVFragment() {
-
}
-
public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle state) {
-
- View v = inflater.inflate(R.layout.lyt_card_cvv, group,false);
+ View v = inflater.inflate(R.layout.lyt_card_cvv, group, false);
mCardCVVView = (EditText) v.findViewById(R.id.card_cvv);
- String cvv = "";
- if(getArguments() != null && getArguments().containsKey(EXTRA_CARD_CVV)) {
+ String cvv = null;
+ if (getArguments() != null && getArguments().containsKey(EXTRA_CARD_CVV)) {
cvv = getArguments().getString(EXTRA_CARD_CVV);
}
- if(cvv == null) {
+ if (cvv == null) {
cvv = "";
}
@@ -46,19 +46,32 @@ public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle state)
@Override
public void afterTextChanged(Editable s) {
-
onEdit(s.toString());
- if(s.length() == 3) {
+ if (s.length() == mMaxCVV) {
onComplete();
}
-
}
@Override
public void focus() {
-
- if(isAdded()) {
+ if (isAdded()) {
mCardCVVView.selectAll();
}
}
+
+ public void setMaxCVV(int maxCVVLength) {
+ if (mCardCVVView != null && mCardCVVView.getText().toString().length() >= maxCVVLength) {
+ mCardCVVView.setText(mCardCVVView.getText().toString().substring(0, maxCVVLength));
+ }
+
+ InputFilter[] FilterArray = new InputFilter[1];
+ FilterArray[0] = new InputFilter.LengthFilter(maxCVVLength);
+ mCardCVVView.setFilters(FilterArray);
+ mMaxCVV = maxCVVLength;
+ String hintCVV = "";
+ for (int i = 0; i < maxCVVLength; i++) {
+ hintCVV += "X";
+ }
+ mCardCVVView.setHint(hintCVV);
+ }
}
diff --git a/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/CardExpiryFragment.java b/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/CardExpiryFragment.java
index 9d6c5c9..619cd35 100755
--- a/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/CardExpiryFragment.java
+++ b/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/CardExpiryFragment.java
@@ -73,7 +73,7 @@ public void afterTextChanged(Editable s) {
int mm = Integer.parseInt(month);
if (mm <= 0 || mm >= 13) {
- cardExpiryView.setError("Invalid month");
+ cardExpiryView.setError(getString(R.string.error_invalid_month));
return;
}
@@ -89,10 +89,10 @@ public void afterTextChanged(Editable s) {
if (yy + millenium < currentYear) {
- cardExpiryView.setError("Card expired");
+ cardExpiryView.setError(getString(R.string.error_card_expired));
return;
} else if (yy + millenium == currentYear && mm < currentMonth) {
- cardExpiryView.setError("Card expired");
+ cardExpiryView.setError(getString(R.string.error_card_expired));
return;
}
}
diff --git a/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/CardFragmentAdapter.java b/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/CardFragmentAdapter.java
index 9a1c9af..2d41a13 100644
--- a/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/CardFragmentAdapter.java
+++ b/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/CardFragmentAdapter.java
@@ -1,6 +1,7 @@
package com.cooltechworks.creditcarddesign.pager;
import android.os.Bundle;
+import android.os.Parcelable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
@@ -11,7 +12,7 @@
public class CardFragmentAdapter extends FragmentStatePagerAdapter implements IActionListener {
public void focus(int position) {
- ((IFocus)getItem(position)).focus();
+ ((IFocus) getItem(position)).focus();
}
public interface ICardEntryCompleteListener {
@@ -46,7 +47,6 @@ public CardFragmentAdapter(FragmentManager fm, Bundle args) {
mCardNumberFragment.setActionListener(this);
mCardExpiryFragment.setActionListener(this);
mCardCVVFragment.setActionListener(this);
-
}
public void setOnCardEntryCompleteListener(ICardEntryCompleteListener listener) {
@@ -66,22 +66,18 @@ public int getCount() {
@Override
public void onActionComplete(CreditCardFragment fragment) {
-
int index = getIndex(fragment);
if (index >= 0 && mCardEntryCompleteListener != null) {
mCardEntryCompleteListener.onCardEntryComplete(index);
}
-
}
public int getIndex(CreditCardFragment fragment) {
-
int index = -1;
if (fragment == mCardNumberFragment) {
index = 0;
} else if (fragment == mCardExpiryFragment) {
index = 1;
-
} else if (fragment == mCardCVVFragment) {
index = 2;
} else if (fragment == mCardNameFragment) {
@@ -91,13 +87,23 @@ public int getIndex(CreditCardFragment fragment) {
return index;
}
+ public void setMaxCVV(int maxCVV) {
+ if (mCardCVVFragment != null) {
+ mCardCVVFragment.setMaxCVV(maxCVV);
+ }
+ }
+
@Override
public void onEdit(CreditCardFragment fragment, String edit) {
-
int index = getIndex(fragment);
if (index >= 0 && mCardEntryCompleteListener != null) {
mCardEntryCompleteListener.onCardEntryEdit(index, edit);
}
}
+
+ @Override
+ public void restoreState(Parcelable parcelable, ClassLoader classLoader) {
+ //do nothing here! no call to super.restoreState(parcelable, classLoader);
+ }
}
diff --git a/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/CardNumberFragment.java b/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/CardNumberFragment.java
index ee74fc8..03abe9c 100644
--- a/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/CardNumberFragment.java
+++ b/creditcarddesign/src/main/java/com/cooltechworks/creditcarddesign/pager/CardNumberFragment.java
@@ -17,26 +17,24 @@
/**
* Created by sharish on 9/1/15.
*/
-public class CardNumberFragment extends CreditCardFragment {
+public class CardNumberFragment extends CreditCardFragment {
EditText mCardNumberView;
public CardNumberFragment() {
-
}
public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle state) {
-
View v = inflater.inflate(R.layout.lyt_card_number, group, false);
mCardNumberView = (EditText) v.findViewById(R.id.card_number_field);
String number = "";
- if(getArguments() != null && getArguments().containsKey(EXTRA_CARD_NUMBER)) {
+ if (getArguments() != null && getArguments().containsKey(EXTRA_CARD_NUMBER)) {
number = getArguments().getString(EXTRA_CARD_NUMBER);
}
- if(number == null) {
+ if (number == null) {
number = "";
}
@@ -49,7 +47,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle state)
@Override
public void afterTextChanged(Editable s) {
-
int cursorPosition = mCardNumberView.getSelectionEnd();
int previousLength = mCardNumberView.getText().length();
@@ -61,22 +58,20 @@ public void afterTextChanged(Editable s) {
mCardNumberView.setSelection(cardNumber.length() > MAX_LENGTH_CARD_NUMBER_WITH_SPACES ? MAX_LENGTH_CARD_NUMBER_WITH_SPACES : cardNumber.length());
mCardNumberView.addTextChangedListener(this);
- if(modifiedLength <= previousLength && cursorPosition < modifiedLength) {
+ if (modifiedLength <= previousLength && cursorPosition < modifiedLength) {
mCardNumberView.setSelection(cursorPosition);
}
onEdit(cardNumber);
-
- if(cardNumber.replace(CreditCardUtils.SPACE_SEPERATOR,"").length() == MAX_LENGTH_CARD_NUMBER) {
+ if (cardNumber.replace(CreditCardUtils.SPACE_SEPERATOR, "").length() == MAX_LENGTH_CARD_NUMBER) {
onComplete();
}
}
@Override
public void focus() {
-
- if(isAdded()) {
+ if (isAdded()) {
mCardNumberView.selectAll();
}
}
diff --git a/creditcarddesign/src/main/res/layout/front_card.xml b/creditcarddesign/src/main/res/layout/front_card.xml
index b8d7489..4010846 100644
--- a/creditcarddesign/src/main/res/layout/front_card.xml
+++ b/creditcarddesign/src/main/res/layout/front_card.xml
@@ -40,7 +40,7 @@
android:id="@+id/card_name_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="CARD HOLDER"
+ android:text="@string/card_holder"
android:textColor="@android:color/darker_gray"
android:textColorHint="@color/semi_white"
android:textSize="9sp"
@@ -78,7 +78,7 @@
android:id="@+id/card_expiry_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="EXPIRY"
+ android:text="@string/expiry"
android:textColor="@android:color/darker_gray"
android:textColorHint="@color/semi_white"
android:textSize="9sp"
@@ -90,7 +90,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
- android:hint="MM/YY"
+ android:hint="@string/mm_yy"
android:maxWidth="150dp"
android:minWidth="150dp"
android:paddingBottom="@dimen/padding_small"
diff --git a/creditcarddesign/src/main/res/layout/lyt_card_expiry.xml b/creditcarddesign/src/main/res/layout/lyt_card_expiry.xml
index 14d7b78..9212ba9 100644
--- a/creditcarddesign/src/main/res/layout/lyt_card_expiry.xml
+++ b/creditcarddesign/src/main/res/layout/lyt_card_expiry.xml
@@ -28,7 +28,7 @@
@@ -38,7 +38,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/margin_small"
- android:hint="MM/YY"
+ android:hint="@string/card_mm_yy"
android:inputType="number"
android:maxLength="5"
android:text="" />
diff --git a/creditcarddesign/src/main/res/layout/lyt_card_holder_name.xml b/creditcarddesign/src/main/res/layout/lyt_card_holder_name.xml
index b3fac1f..a9e8048 100644
--- a/creditcarddesign/src/main/res/layout/lyt_card_holder_name.xml
+++ b/creditcarddesign/src/main/res/layout/lyt_card_holder_name.xml
@@ -28,7 +28,7 @@
diff --git a/creditcarddesign/src/main/res/layout/lyt_card_number.xml b/creditcarddesign/src/main/res/layout/lyt_card_number.xml
index 2097b41..f27e74c 100644
--- a/creditcarddesign/src/main/res/layout/lyt_card_number.xml
+++ b/creditcarddesign/src/main/res/layout/lyt_card_number.xml
@@ -27,7 +27,7 @@
diff --git a/creditcarddesign/src/main/res/values-fr/strings.xml b/creditcarddesign/src/main/res/values-fr/strings.xml
new file mode 100644
index 0000000..e3dfd7f
--- /dev/null
+++ b/creditcarddesign/src/main/res/values-fr/strings.xml
@@ -0,0 +1,16 @@
+
+
+ SUIVANT
+ PRECEDENT
+ TERMINER
+ JEAN MARTIN
+ TITULAIRE
+ EXPIRATION
+ MM/AA
+ EXPIRATION
+ MM/AA
+ NOM SUR LA CARTE
+ NUMERO DE CARTE
+ Mois invalide
+ Carte expirée
+
diff --git a/creditcarddesign/src/main/res/values-pt-rBR/strings.xml b/creditcarddesign/src/main/res/values-pt-rBR/strings.xml
new file mode 100644
index 0000000..ad69a3a
--- /dev/null
+++ b/creditcarddesign/src/main/res/values-pt-rBR/strings.xml
@@ -0,0 +1,16 @@
+
+
+ PRÓXIMO
+ ANTERIOR
+ PRONTO
+ JOÃO SILVA
+ TITULAR
+ VENCIMENTO
+ MM/AA
+ VENCIMENTO
+ MM/AA
+ NOME NO CARTÃO
+ NÚMERO DO CARTÃO
+ Mês inválido
+ Cartão vencido
+
\ No newline at end of file
diff --git a/creditcarddesign/src/main/res/values/strings.xml b/creditcarddesign/src/main/res/values/strings.xml
index 4a55357..3c08228 100644
--- a/creditcarddesign/src/main/res/values/strings.xml
+++ b/creditcarddesign/src/main/res/values/strings.xml
@@ -8,4 +8,13 @@
PREVIOUS
DONE
JOHN MATTHEW
+ CARD HOLDER
+ EXPIRY
+ MM/YY
+ CARD EXPIRY
+ MM/YY
+ NAME ON CARD
+ CARD NUMBER
+ Invalid month
+ Card expired
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..13372ae
Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..04e285f
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon Dec 28 10:00:20 PST 2015
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
diff --git a/gradlew b/gradlew
index 91a7e26..9d82f78 100644
--- a/gradlew
+++ b/gradlew
@@ -42,11 +42,6 @@ case "`uname`" in
;;
esac
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
-if $cygwin ; then
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
-
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
@@ -61,9 +56,9 @@ while [ -h "$PRG" ] ; do
fi
done
SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >&-
+cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
-cd "$SAVED" >&-
+cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@@ -114,6 +109,7 @@ fi
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`