diff --git a/app/build.gradle b/app/build.gradle index 4fc5210..707a743 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,14 +2,15 @@ apply plugin: 'com.android.application' android { compileSdkVersion 25 - buildToolsVersion "25.0.0" + buildToolsVersion "25.0.1" defaultConfig { + vectorDrawables.useSupportLibrary = true applicationId "com.cooltechworks.checkoutflow" minSdkVersion 10 targetSdkVersion 25 - versionCode 1 - versionName "1.0" + versionCode 2 + versionName "1.1" } buildTypes { release { 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 db056ff..2ade401 100644 --- a/app/src/main/java/com/cooltechworks/creditcarddesign/sample/MainActivity.java +++ b/app/src/main/java/com/cooltechworks/creditcarddesign/sample/MainActivity.java @@ -1,37 +1,74 @@ package com.cooltechworks.creditcarddesign.sample; import android.content.Intent; -import android.os.Bundle; import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; import android.view.View; +import android.widget.Button; import android.widget.LinearLayout; import com.cooltechworks.checkoutflow.R; +import com.cooltechworks.creditcarddesign.CreditCardView; import com.cooltechworks.creditcarddesign.CardEditActivity; import com.cooltechworks.creditcarddesign.CreditCardUtils; -import com.cooltechworks.creditcarddesign.CreditCardView; + +/** + * Created by glarencezhao on 10/23/16. + */ public class MainActivity extends AppCompatActivity { + private final int CREATE_NEW_CARD = 0; + + private LinearLayout cardContainer; + private Button addCardButton; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); + initialize(); + listeners(); + } - findViewById(R.id.add_card).setOnClickListener(new View.OnClickListener() { + private void initialize() { + addCardButton = (Button) findViewById(R.id.add_card); + cardContainer = (LinearLayout) findViewById(R.id.card_container); +// getSupportActionBar().setTitle("Payment"); + populate(); + } + + private void populate() { + CreditCardView sampleCreditCardView = new CreditCardView(this); + + String name = "Glarence Zhao"; + String cvv = "420"; + String expiry = "01/18"; + String cardNumber = "4242424242424242"; + + sampleCreditCardView.setCVV(cvv); + sampleCreditCardView.setCardHolderName(name); + sampleCreditCardView.setCardExpiry(expiry); + sampleCreditCardView.setCardNumber(cardNumber); + + cardContainer.addView(sampleCreditCardView); + int index = cardContainer.getChildCount() - 1; + addCardListener(index, sampleCreditCardView); + } + + private void listeners() { + addCardButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + Intent intent = new Intent(MainActivity.this, CardEditActivity.class); - startActivityForResult(intent, 0); + startActivityForResult(intent, CREATE_NEW_CARD); } }); } - private void initListener(final int index, CreditCardView creditCardView) { - - + private void addCardListener(final int index, CreditCardView creditCardView) { creditCardView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -40,6 +77,7 @@ public void onClick(View v) { String cardNumber = creditCardView.getCardNumber(); String expiry = creditCardView.getExpiry(); String cardHolderName = creditCardView.getCardHolderName(); + String cvv = creditCardView.getCVV(); Intent intent = new Intent(MainActivity.this, CardEditActivity.class); intent.putExtra(CreditCardUtils.EXTRA_CARD_HOLDER_NAME, cardHolderName); @@ -50,31 +88,22 @@ public void onClick(View v) { // 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); - } }); - } - - public void onActivityResult(int reqCode, int resultCode, Intent data) { - if(resultCode == RESULT_OK) { - - LinearLayout cardContainer = (LinearLayout) findViewById(R.id.card_container); - + if (resultCode == RESULT_OK) { +// Debug.printToast("Result Code is OK", getApplicationContext()); String name = data.getStringExtra(CreditCardUtils.EXTRA_CARD_HOLDER_NAME); String cardNumber = data.getStringExtra(CreditCardUtils.EXTRA_CARD_NUMBER); String expiry = data.getStringExtra(CreditCardUtils.EXTRA_CARD_EXPIRY); String cvv = data.getStringExtra(CreditCardUtils.EXTRA_CARD_CVV); - - if(reqCode == 0) { - + if (reqCode == CREATE_NEW_CARD) { CreditCardView creditCardView = new CreditCardView(this); @@ -83,14 +112,11 @@ public void onActivityResult(int reqCode, int resultCode, Intent data) { creditCardView.setCardExpiry(expiry); creditCardView.setCardNumber(cardNumber); - int index = cardContainer.getChildCount(); cardContainer.addView(creditCardView); - initListener(index, creditCardView); - + int index = cardContainer.getChildCount() - 1; + addCardListener(index, creditCardView); - - } - else { + } else { CreditCardView creditCardView = (CreditCardView) cardContainer.getChildAt(reqCode); @@ -102,7 +128,6 @@ public void onActivityResult(int reqCode, int resultCode, Intent data) { } } - } -} +} \ No newline at end of file diff --git a/creditcarddesign/build.gradle b/creditcarddesign/build.gradle index a1be530..e70c8f3 100644 --- a/creditcarddesign/build.gradle +++ b/creditcarddesign/build.gradle @@ -3,12 +3,13 @@ apply plugin: 'com.android.library' android { compileSdkVersion 25 - buildToolsVersion "25.0.0" + buildToolsVersion "25.0.1" defaultConfig { + vectorDrawables.useSupportLibrary = true minSdkVersion 10 targetSdkVersion 25 versionCode 1 - versionName "1.0.2" + versionName "1.0.3" } buildTypes { release { @@ -19,10 +20,9 @@ android { } dependencies { - final SUPPORT_LIBRARY_VERSION = '25.0.0' - + final SUPPORT_VERSION = "25.0.1" compile fileTree(dir: 'libs', include: ['*.jar']) - compile "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION" - compile "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION" + compile "com.android.support:appcompat-v7:$SUPPORT_VERSION" + compile "com.android.support:cardview-v7:$SUPPORT_VERSION" compile 'com.github.ozodrukh:CircularReveal:1.0.5' } diff --git a/creditcarddesign/src/main/res/layout/activity_card_edit.xml b/creditcarddesign/src/main/res/layout/activity_card_edit.xml index 34757dc..aa43433 100644 --- a/creditcarddesign/src/main/res/layout/activity_card_edit.xml +++ b/creditcarddesign/src/main/res/layout/activity_card_edit.xml @@ -1,17 +1,17 @@ + xmlns:tools="http://schemas.android.com/tools" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + tools:context=".CardEditActivity"> + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/parent" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + tools:context=".CardEditActivity">