Skip to content

Commit

Permalink
Merge pull request #28 from sharish/PR
Browse files Browse the repository at this point in the history
v1.0.3 pushes
  • Loading branch information
sharish authored Jan 10, 2017
2 parents dd00f00 + 0c4b944 commit 49b1aa6
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 49 deletions.
7 changes: 4 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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);
Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -102,7 +128,6 @@ public void onActivityResult(int reqCode, int resultCode, Intent data) {
}
}


}

}
}
12 changes: 6 additions & 6 deletions creditcarddesign/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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'
}
27 changes: 14 additions & 13 deletions creditcarddesign/src/main/res/layout/activity_card_edit.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".CardEditActivity">

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
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">
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">

<LinearLayout
android:layout_width="match_parent"
Expand All @@ -21,15 +21,16 @@
<com.cooltechworks.creditcarddesign.CreditCardView
android:id="@+id/credit_card_view"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:layout_gravity="center"

/>

<android.support.v4.view.ViewPager
android:id="@+id/card_field_container_pager"
android:layout_width="match_parent"
android:layout_height="120dp"
android:layout_height="wrap_content"
android:minHeight="120dp"
android:orientation="horizontal"
>

Expand Down

0 comments on commit 49b1aa6

Please sign in to comment.