Skip to content

Commit

Permalink
Merge pull request #52 from verygoodsecurity/develop
Browse files Browse the repository at this point in the history
Preparetion to release
  • Loading branch information
Dmytro Kos authored Nov 30, 2020
2 parents bd3d1c1 + b0f92ae commit 95e77c3
Show file tree
Hide file tree
Showing 78 changed files with 1,780 additions and 1,230 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/local.properties
.DS_Store
/build
/docs

.gradle
.idea
Expand Down
6 changes: 4 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.verygoodsecurity.demoapp"
minSdkVersion 21
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName "1.0"
Expand Down Expand Up @@ -76,7 +76,9 @@ dependencies {

implementation project(":vgscollect")
implementation project(":vgscollect-cardio")
implementation project(":vgscollect-bouncer")
// implementation project(":vgscollect-bouncer")

implementation 'com.google.android.gms:play-services-auth:19.0.0'

implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package com.verygoodsecurity.demoapp
import android.app.Application
import android.os.StrictMode
import android.view.View
import com.google.android.gms.security.ProviderInstaller

class DemoApplication: Application() {
val leakedViews = mutableListOf<View>()

override fun onCreate() {
super.onCreate()
ProviderInstaller.installIfNeeded(getApplicationContext());
enabledStrictMode()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import android.view.MenuItem
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import com.verygoodsecurity.api.bouncer.ScanActivity
import com.verygoodsecurity.api.cardio.ScanActivity
import com.verygoodsecurity.demoapp.R
import com.verygoodsecurity.demoapp.StartActivity
import com.verygoodsecurity.vgscollect.core.Environment
Expand All @@ -30,7 +30,6 @@ import com.verygoodsecurity.vgscollect.view.card.icon.CardIconAdapter
import com.verygoodsecurity.vgscollect.view.card.validation.payment.ChecksumAlgorithm
import com.verygoodsecurity.vgscollect.view.card.validation.rules.PaymentCardNumberRule
import com.verygoodsecurity.vgscollect.view.card.validation.rules.PersonNameRule
import com.verygoodsecurity.vgscollect.view.date.DatePickerMode
import kotlinx.android.synthetic.main.activity_collect_demo.*

class VGSCollectActivity: AppCompatActivity(), VgsCollectResponseListener, View.OnClickListener {
Expand Down Expand Up @@ -71,7 +70,7 @@ class VGSCollectActivity: AppCompatActivity(), VgsCollectResponseListener, View.
vgsForm.bindView(cardExpDateField)
cardExpDateField?.setOnFieldStateChangeListener(object : OnFieldStateChangeListener {
override fun onStateChange(state: FieldState) {
if(!state.isEmpty && !state.isValid && !state.hasFocus) {
if (!state.isEmpty && !state.isValid && !state.hasFocus) {
cardExpDateFieldLay?.setError("fill it please")
} else {
cardExpDateFieldLay?.setError(null)
Expand All @@ -92,7 +91,7 @@ class VGSCollectActivity: AppCompatActivity(), VgsCollectResponseListener, View.
vgsForm.bindView(cardHolderField)
cardHolderField?.setOnFieldStateChangeListener(object : OnFieldStateChangeListener {
override fun onStateChange(state: FieldState) {
if(!state.isEmpty && !state.isValid && !state.hasFocus) {
if (!state.isEmpty && !state.isValid && !state.hasFocus) {
cardHolderFieldLay?.setError("fill it please")
} else {
cardHolderFieldLay?.setError(null)
Expand All @@ -105,7 +104,7 @@ class VGSCollectActivity: AppCompatActivity(), VgsCollectResponseListener, View.
vgsForm.bindView(cardCVCField)
cardCVCField?.setOnFieldStateChangeListener(object : OnFieldStateChangeListener {
override fun onStateChange(state: FieldState) {
if(!state.isEmpty && !state.isValid && !state.hasFocus) {
if (!state.isEmpty && !state.isValid && !state.hasFocus) {
cardCVCFieldLay?.setError("fill it please")
} else {
cardCVCFieldLay?.setError(null)
Expand Down Expand Up @@ -168,7 +167,7 @@ class VGSCollectActivity: AppCompatActivity(), VgsCollectResponseListener, View.

cardNumberField.setCardIconAdapter(object : CardIconAdapter(this) {
override fun getIcon(cardType: CardType, name: String?, resId: Int, r: Rect): Drawable {
return if(cardType == CardType.VISA) {
return if (cardType == CardType.VISA) {
getDrawable(R.drawable.ic_visa_light)
} else {
super.getIcon(cardType, name, resId, r)
Expand All @@ -183,7 +182,7 @@ class VGSCollectActivity: AppCompatActivity(), VgsCollectResponseListener, View.
bin: String,
mask: String
): String {
return when(cardType) {
return when (cardType) {
CardType.UNKNOWN -> {
if (bin == "7771") {
"# # # #"
Expand Down Expand Up @@ -214,12 +213,18 @@ class VGSCollectActivity: AppCompatActivity(), VgsCollectResponseListener, View.
val bndl = intent?.extras

vault_id = bndl?.getString(StartActivity.VAULT_ID, "")?:""
path = bndl?.getString(StartActivity.PATH,"/")?:""
path = bndl?.getString(StartActivity.PATH, "/")?:""

val envId = bndl?.getInt(StartActivity.ENVIROMENT, 0)?:0
env = Environment.values()[envId]

vgsForm = VGSCollect(this, vault_id, env)
vgsForm = VGSCollect.Builder(this, vault_id)
.setEnvironment(env)
.setHostname("collect-android-testing.verygoodsecurity.io/test")
.create()

val cacheSize = 10 * 1024 * 1024 // 10MB
vgsForm.getFileProvider().resize(cacheSize)
}

override fun onCreateOptionsMenu(menu: Menu): Boolean {
Expand All @@ -238,29 +243,18 @@ class VGSCollectActivity: AppCompatActivity(), VgsCollectResponseListener, View.
}

private fun scanCard() {
val bndl = with(Bundle()) {
val scanSettings = hashMapOf<String?, Int>().apply {
this[cardNumberField?.getFieldName()] = ScanActivity.CARD_NUMBER
this[cardCVCField?.getFieldName()] = ScanActivity.CARD_CVC
this[cardHolderField?.getFieldName()] = ScanActivity.CARD_HOLDER
this[cardExpDateField?.getFieldName()] = ScanActivity.CARD_EXP_DATE
}

putSerializable(ScanActivity.SCAN_CONFIGURATION, scanSettings)

putString(ScanActivity.API_KEY, "<user_bouncer_key>")
val intent = Intent(this, ScanActivity::class.java)

putBoolean(ScanActivity.ENABLE_EXPIRY_EXTRACTION, false)
putBoolean(ScanActivity.ENABLE_NAME_EXTRACTION, false)
putBoolean(ScanActivity.DISPLAY_CARD_PAN, false)
putBoolean(ScanActivity.DISPLAY_CARD_HOLDER_NAME, false)
putBoolean(ScanActivity.DISPLAY_CARD_SCAN_LOGO, false)
putBoolean(ScanActivity.ENABLE_DEBUG, false)

this
val scanSettings = hashMapOf<String?, Int>().apply {
this[cardNumberField?.getFieldName()] = ScanActivity.CARD_NUMBER
this[cardCVCField?.getFieldName()] = ScanActivity.CARD_CVC
this[cardHolderField?.getFieldName()] = ScanActivity.CARD_HOLDER
this[cardExpDateField?.getFieldName()] = ScanActivity.CARD_EXP_DATE
}

ScanActivity.scan(this, USER_SCAN_REQUEST_CODE, bndl)
intent.putExtra(ScanActivity.SCAN_CONFIGURATION, scanSettings)

startActivityForResult(intent, USER_SCAN_REQUEST_CODE)
}

private fun getOnFieldStateChangeListener(): OnFieldStateChangeListener {
Expand Down Expand Up @@ -294,6 +288,11 @@ class VGSCollectActivity: AppCompatActivity(), VgsCollectResponseListener, View.
}

override fun onDestroy() {
vgsForm.unbindView(cardNumberField)
vgsForm.unbindView(cardCVCField)
vgsForm.unbindView(cardExpDateField)
vgsForm.unbindView(cardHolderField)

vgsForm.onDestroy()
super.onDestroy()
}
Expand All @@ -317,12 +316,12 @@ class VGSCollectActivity: AppCompatActivity(), VgsCollectResponseListener, View.
setStateLoading(false)

when (response) {
is VGSResponse.SuccessResponse -> responseContainerView.text = response.toString()
is VGSResponse.SuccessResponse -> responseContainerView.text = "Code: ${response.successCode}"
is VGSResponse.ErrorResponse -> responseContainerView.text = response.toString()
}
}

private fun setStateLoading(state:Boolean) {
private fun setStateLoading(state: Boolean) {
if(state) {
progressBar?.visibility = View.VISIBLE
submitBtn?.isEnabled = false
Expand All @@ -334,16 +333,16 @@ class VGSCollectActivity: AppCompatActivity(), VgsCollectResponseListener, View.
}
}

private fun setEnabledResponseHeader(isEnabled:Boolean) {
private fun setEnabledResponseHeader(isEnabled: Boolean) {
if(isEnabled) {
attachBtn.setTextColor(ContextCompat.getColor(this,
R.color.state_active
))
attachBtn.setTextColor(
ContextCompat.getColor(this, R.color.state_active)
)
} else {
responseContainerView.text = ""
attachBtn.setTextColor(ContextCompat.getColor(this,
R.color.state_unactive
))
attachBtn.setTextColor(
ContextCompat.getColor(this, R.color.state_unactive)
)
}
}

Expand Down
6 changes: 5 additions & 1 deletion app/src/main/res/layout/activity_collect_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@
android:id="@+id/cardNumberField"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:fieldName="card_data.cardNumber"
app:fieldName="cardNumber"
style="@style/AppTheme.PaymentField"
app:text="4111-1111-1111-1111"
app:numberDivider="-"
app:validationRule="acceptUnknown"
app:fontFamily="@font/robotomono_light"
Expand Down Expand Up @@ -166,6 +167,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
style="@style/AppTheme.PaymentField"
app:text="John G"
android:nextFocusDown="@+id/cardExpDateField"
app:imeOptions="actionNext"
app:fontFamily="@font/robotomono_light"
Expand Down Expand Up @@ -197,6 +199,7 @@
android:nextFocusDown="@+id/cardCVCField"
app:imeOptions="actionNext"
app:inputType="date"
app:text="09/2025"
app:fontFamily="@font/robotomono_light"
app:datePickerModes="input"
app:outputPattern="yyyy-MM-dd'T'HH:mm:ss.SSSSSSS"
Expand All @@ -217,6 +220,7 @@
android:layout_height="match_parent"
style="@style/AppTheme.PaymentField"
app:fieldName="card_data.cardCvc"
app:text="123"
app:fontFamily="@font/robotomono_light"
app:imeOptions="actionDone"/>
</com.verygoodsecurity.vgscollect.widget.VGSTextInputLayout>
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.4.10'
ext.kotlin_version = '1.4.20'
ext.dokka_version = '1.4.0-rc'

repositories {
Expand All @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.android.tools.build:gradle:4.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
Expand All @@ -18,7 +18,7 @@ buildscript {
}

ext {
mockito_version = '3.5.0'
mockito_version = '3.6.0'
android_support_libraries = '1.2.0'
}

Expand Down
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Thu Oct 22 13:07:50 EEST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
5 changes: 2 additions & 3 deletions vgscollect-bouncer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,13 @@ android {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "androidx.appcompat:appcompat:$android_support_libraries"
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.core:core-ktx:1.3.2'

dokkaHtmlPlugin("org.jetbrains.dokka:dokka-base:$dokka_version")

api project(':vgscollect')
implementation 'com.getbouncer:cardscan-ui:2.0.0018'
implementation 'com.getbouncer:cardscan-ui:2.0.0055'
}

apply from: rootProject.file('release-bintray.gradle')
4 changes: 2 additions & 2 deletions vgscollect-bouncer/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ POM_DESCRIPTION=CardScan - fast and modern SDK for scanning Card Numbers. Integr
POM_BINTRAY_NAME=adapter-bouncer
POM_ARTIFACT_ID=adapter-bouncer
POM_PACKAGING=aar
POM_VERSION=1.0.0
CODE_VERSION=100
POM_VERSION=1.0.1
CODE_VERSION=101
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ class ScanActivity: BaseTransmitActivity(), CardScanActivityResultHandler {
key,
enableEnterCardManually,
enableExpiryExtraction,
enableNameExtraction,
displayCardPan,
displayCardholderName,
displayCardScanLogo,
enableDebug
enableNameExtraction
)
}

Expand Down Expand Up @@ -170,22 +166,22 @@ class ScanActivity: BaseTransmitActivity(), CardScanActivityResultHandler {
/**
If true, display the card pan once the card has started to scan.
*/
const val DISPLAY_CARD_PAN = "displayCardPan"
private const val DISPLAY_CARD_PAN = "displayCardPan"

/**
If true, display the name of the card owner if extracted.
*/
const val DISPLAY_CARD_HOLDER_NAME = "displayCardholderName"
private const val DISPLAY_CARD_HOLDER_NAME = "displayCardholderName"

/**
If true, display the cardscan.io logo at the top of the screen.
*/
const val DISPLAY_CARD_SCAN_LOGO = "displayCardScanLogo"
private const val DISPLAY_CARD_SCAN_LOGO = "displayCardScanLogo"

/**
If true, enable debug views in card scan.
*/
const val ENABLE_DEBUG = "enableDebug"
private const val ENABLE_DEBUG = "enableDebug"

/**
Start the card scanner activity.
Expand Down
8 changes: 5 additions & 3 deletions vgscollect/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ android {
versionCode CODE_VERSION.toInteger()
versionName POM_VERSION

buildConfigField "String", "VERSION_NAME", "\"$POM_VERSION\""

vectorDrawables.useSupportLibrary = true
javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -69,13 +71,13 @@ tasks.withType(Javadoc).all {
dependencies {
implementation "androidx.appcompat:appcompat:$android_support_libraries"
implementation "com.google.android.material:material:1.2.1"
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'com.squareup.okhttp3:okhttp:4.8.0'

testImplementation 'junit:junit:4.13'
testImplementation 'junit:junit:4.13.1'
testImplementation "org.mockito:mockito-core:$mockito_version"
testImplementation "org.mockito:mockito-inline:$mockito_version"
testImplementation 'org.json:json:20200518'
testImplementation 'org.json:json:20201115'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
testImplementation "org.robolectric:robolectric:4.4"
Expand Down
4 changes: 2 additions & 2 deletions vgscollect/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ POM_DESCRIPTION=VGS Collect - is a product suite that allows customers to collec
POM_BINTRAY_NAME=vgscollect
POM_ARTIFACT_ID=vgscollect
POM_PACKAGING=aar
POM_VERSION=1.2.5
CODE_VERSION=1205
POM_VERSION=1.3.0
CODE_VERSION=1300
Loading

0 comments on commit 95e77c3

Please sign in to comment.