Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

// apply plugin: 'kotlin-kapt'


android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
compileSdkVersion 28

defaultConfig {
vectorDrawables.useSupportLibrary = true
applicationId "com.cooltechworks.checkoutflow"
minSdkVersion 10
targetSdkVersion 25
minSdkVersion 15
targetSdkVersion 28
versionCode 2
versionName "1.1"
}
Expand All @@ -21,6 +27,9 @@ android {
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':creditcarddesign')
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':creditcarddesign')
implementation 'androidx.appcompat:appcompat:1.0.2'
// implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.40'

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package com.cooltechworks.creditcarddesign.sample

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.LinearLayout
import androidx.appcompat.app.AppCompatActivity
import com.cooltechworks.checkoutflow.R
import com.cooltechworks.creditcarddesign.CardEditActivity
import com.cooltechworks.creditcarddesign.CreditCardUtils
import com.cooltechworks.creditcarddesign.CreditCardView
import kotlinx.android.synthetic.main.activity_main.*

/**
* Created by glarencezhao on 10/23/16.
*/

class MainActivity : AppCompatActivity() {

private val CREATE_NEW_CARD = 0


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

initialize()
listeners()
}

private fun initialize() {
// getSupportActionBar().setTitle("Payment");
populate()
}

private fun populate() {
val sampleCreditCardView = CreditCardView(this)

val name = "Glarence Zhao"
val cvv = "420"
val expiry = "01/18"
val cardNumber = "4242424242424242"

sampleCreditCardView.cvv = cvv
sampleCreditCardView.cardHolderName = name
sampleCreditCardView.setCardExpiry(expiry)
sampleCreditCardView.cardNumber = cardNumber

card_container.addView(sampleCreditCardView)
val index = card_container?.childCount ?: 1 - 1
addCardListener(index, sampleCreditCardView)
}

private fun listeners() {
add_card?.setOnClickListener {
val intent = Intent(this@MainActivity, CardEditActivity::class.java)
startActivityForResult(intent, CREATE_NEW_CARD)
}
}

private fun addCardListener(index: Int, creditCardView: CreditCardView) {
creditCardView.setOnClickListener { v ->
val creditCardView = v as CreditCardView
val cardNumber = creditCardView.cardNumber
val expiry = creditCardView.expiry
val cardHolderName = creditCardView.cardHolderName
val cvv = creditCardView.cvv

val intent = Intent(this@MainActivity, CardEditActivity::class.java)
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_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)
}
}

public override fun onActivityResult(reqCode: Int, resultCode: Int, data: Intent?) {

if (resultCode == Activity.RESULT_OK) {
// Debug.printToast("Result Code is OK", getApplicationContext());

val name = data?.getStringExtra(CreditCardUtils.EXTRA_CARD_HOLDER_NAME)
val cardNumber = data?.getStringExtra(CreditCardUtils.EXTRA_CARD_NUMBER)
val expiry = data?.getStringExtra(CreditCardUtils.EXTRA_CARD_EXPIRY)
val cvv = data?.getStringExtra(CreditCardUtils.EXTRA_CARD_CVV)

if (reqCode == CREATE_NEW_CARD) {

val creditCardView = CreditCardView(this)

creditCardView.cvv = cvv
creditCardView.cardHolderName = name
creditCardView.setCardExpiry(expiry)
creditCardView.cardNumber = cardNumber

card_container?.addView(creditCardView)
val index = card_container?.childCount ?: 1 - 1
addCardListener(index, creditCardView)

} else {

val creditCardView = card_container?.getChildAt(reqCode) as CreditCardView

creditCardView.setCardExpiry(expiry)
creditCardView.cardNumber = cardNumber
creditCardView.cardHolderName = name
creditCardView.cvv = cvv

}
}

}

}
12 changes: 11 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.40'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -18,6 +24,10 @@ allprojects {
maven{
url "https://jitpack.io"
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
}

}
24 changes: 15 additions & 9 deletions creditcarddesign/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
apply plugin: 'com.android.library'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

// apply plugin: 'kotlin-kapt'

android {

compileSdkVersion 25
buildToolsVersion "25.0.1"
compileSdkVersion 28
defaultConfig {
vectorDrawables.useSupportLibrary = true
minSdkVersion 10
targetSdkVersion 25
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0.3"
}
Expand All @@ -20,9 +25,10 @@ android {
}

dependencies {
final SUPPORT_VERSION = "25.0.1"
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:$SUPPORT_VERSION"
compile "com.android.support:cardview-v7:$SUPPORT_VERSION"
compile 'com.github.ozodrukh:CircularReveal:1.0.5'
// final SUPPORT_VERSION = "28.0.0"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.github.ozodrukh:CircularReveal:2.0.1'
// implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.40'
}
Loading