From 656b6fdca7eb2c0d810cc04bdfa351aed148b0f6 Mon Sep 17 00:00:00 2001 From: Cristian Ramirez Date: Tue, 23 Jun 2020 09:47:39 -0600 Subject: [PATCH 1/2] 20200623 094739 Changed marginleft and marginright to 35dp on linearlayout which contains tv_card_one to fix the last four digits which dissapears also added custom hint text for those input layout: til_card_name, til_card_no, til_card_month, til_card_year and til_card_cv, besides custom text for pay button was added --- .idea/StickySelectionHighlights.xml | 34 +++++++++++++++++++ app/src/main/res/layout/activity_main.xml | 6 ++++ .../com/fevziomurtekin/payview/Payview.kt | 26 ++++++++++++++ .../src/main/res/layout/payview_layout.xml | 4 +-- payview/src/main/res/values/attrs.xml | 6 ++++ 5 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 .idea/StickySelectionHighlights.xml diff --git a/.idea/StickySelectionHighlights.xml b/.idea/StickySelectionHighlights.xml new file mode 100644 index 0000000..1b52719 --- /dev/null +++ b/.idea/StickySelectionHighlights.xml @@ -0,0 +1,34 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 3705478..e55ca34 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -20,6 +20,12 @@ app:cardNameTextSize="15" app:cardMonthTextSize="13" app:cardAnimationType="vertical" + app:cardBtnPayText="Proceed to pay" + app:cardNameHintText="Name on card" + app:cardNoHintText="Card Number" + app:cardMonthHintText="MM" + app:cardYearHintText="YY" + app:cardCvHintText="CVV" app:cardCvErrorText="You must enter 3-digit characters" app:cardMonthErrorText="You must enter 2-digit characters and you'll enter to number the most digit-value is '12'" app:cardYearErrorText="You must enter 2-digit characters and you'll enter to number the most digit-value is '99'" diff --git a/payview/src/main/java/com/fevziomurtekin/payview/Payview.kt b/payview/src/main/java/com/fevziomurtekin/payview/Payview.kt index 0efbc84..f0fc667 100644 --- a/payview/src/main/java/com/fevziomurtekin/payview/Payview.kt +++ b/payview/src/main/java/com/fevziomurtekin/payview/Payview.kt @@ -50,6 +50,12 @@ class Payview : NestedScrollView, View.OnFocusChangeListener { private var cardYearTextSize : Int = 13 private var cardMonthTextSize : Int = 13 private var cardCvTextSize : Int = 14 + private var cardBtnPayText : String = resources.getString(R.string.pay) + private var cardNameHintText : String = resources.getString(R.string.cardname) + private var cardNoHintText : String = resources.getString(R.string.cardno) + private var cardMonthHintText : String = resources.getString(R.string.cardmonth) + private var cardYearHintText : String = resources.getString(R.string.cardyear) + private var cardCvHintText : String = resources.getString(R.string.cardcv) /** Views on layout.*/ @@ -141,6 +147,18 @@ class Payview : NestedScrollView, View.OnFocusChangeListener { cardYearTextSize=it.getInt(R.styleable.Payview_cardYearTextSize,13) cardMonthTextSize=it.getInt(R.styleable.Payview_cardMonthTextSize,13) cardCvTextSize=it.getInt(R.styleable.Payview_cardCvTextSize,14) + cardBtnPayText=it.getString(R.styleable.Payview_cardBtnPayText).let { s-> s?.toString() + ?: cardBtnPayText } + cardNameHintText=it.getString(R.styleable.Payview_cardNameHintText).let { s-> s?.toString() + ?: cardNameHintText } + cardNoHintText=it.getString(R.styleable.Payview_cardNoHintText).let { s-> s?.toString() + ?: cardNoHintText } + cardMonthHintText=it.getString(R.styleable.Payview_cardMonthHintText).let { s-> s?.toString() + ?: cardMonthHintText } + cardYearHintText=it.getString(R.styleable.Payview_cardYearHintText).let { s-> s?.toString() + ?: cardYearHintText } + cardCvHintText=it.getString(R.styleable.Payview_cardCvHintText).let { s-> s?.toString() + ?: cardCvHintText } cardAnimationType=it.getInt(R.styleable.Payview_cardAnimationType,AnimationType.HORIZONTAL) initViews() initData() @@ -219,6 +237,14 @@ class Payview : NestedScrollView, View.OnFocusChangeListener { tev_card_year.textSize = cardYearTextSize.toFloat() tev_card_month.textSize = cardMonthTextSize.toFloat() tev_card_cv.textSize = cardCvTextSize.toFloat() + btn_pay.text = cardBtnPayText + + // Custom Hint Text + til_card_name.hint = cardNameHintText + til_card_no.hint = cardNoHintText + til_card_month.hint = cardMonthHintText + til_card_year.hint = cardYearHintText + til_card_cv.hint = cardCvHintText tev_card_name.onFocusChangeListener = this tev_card_no.onFocusChangeListener = this diff --git a/payview/src/main/res/layout/payview_layout.xml b/payview/src/main/res/layout/payview_layout.xml index 788f8a4..6324204 100644 --- a/payview/src/main/res/layout/payview_layout.xml +++ b/payview/src/main/res/layout/payview_layout.xml @@ -82,8 +82,8 @@ android:id="@+id/lv_card_layout" android:orientation="horizontal" android:layout_above="@+id/iv_card_type" - android:layout_marginLeft="40dp" - android:layout_marginRight="40dp" + android:layout_marginLeft="35dp" + android:layout_marginRight="35dp" android:layout_marginBottom="5dp" > + + + + + + From cdba326f2645f30b1d634790fb505e42c210770d Mon Sep 17 00:00:00 2001 From: Cristian Ramirez Date: Tue, 23 Jun 2020 12:23:56 -0600 Subject: [PATCH 2/2] 20200623 122356 Added style for counter of the input text layout and fixed the validations when click on btnPay and the app crash because a NumberFormatException, a isNullOrEmpty validation was added also the validation of the others fields --- .idea/StickySelectionHighlights.xml | 30 +++++++++++ README.md | 52 ++++++++++++------- build.gradle | 4 +- gradle/wrapper/gradle-wrapper.properties | 4 +- payview/build.gradle | 10 ++-- .../com/fevziomurtekin/payview/Payview.kt | 46 ++++++++++------ .../src/main/res/layout/payview_layout.xml | 15 ++++-- payview/src/main/res/values/styles.xml | 5 ++ 8 files changed, 117 insertions(+), 49 deletions(-) diff --git a/.idea/StickySelectionHighlights.xml b/.idea/StickySelectionHighlights.xml index 1b52719..035f5e2 100644 --- a/.idea/StickySelectionHighlights.xml +++ b/.idea/StickySelectionHighlights.xml @@ -8,11 +8,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + @@ -28,6 +53,11 @@ + + + + + diff --git a/README.md b/README.md index 138c238..4cd9bfb 100644 --- a/README.md +++ b/README.md @@ -40,26 +40,32 @@ dependencies { ## Layout ```xml - + ``` ## Listeners @@ -101,6 +107,12 @@ dependencies { |`cardMonthErrorText`|Default text ""You must enter 2-digit characters and you'll enter to number the most digit-value is '12'"| |`cardYearErrorText`| Default text "You must enter 2-digit characters and you'll enter to number the most digit-value is '99'"| |`cardExpiredErrorText`| Default text "Your card has expired. Please enter the usage date correctly."| +|`cardBtnPayText`| Default text "Pay"| +|`cardNameHintText`| Default text "Card Name"| +|`cardNoHintText`| Default text "Card No"| +|`cardMonthHintText`| Default text "Month"| +|`cardYearHintText`| Default text "Year"| +|`cardCvHintText`| Default text "Cv Code"| ## License diff --git a/build.gradle b/build.gradle index 9d271a7..03ed29e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,14 +1,14 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.40' + ext.kotlin_version = '1.3.72' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.4.1' + classpath 'com.android.tools.build:gradle:4.0.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d269cab..ac1f915 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Jun 28 22:43:33 EET 2019 +#Tue Jun 23 10:58:51 CST 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/payview/build.gradle b/payview/build.gradle index 63914e8..5ec797d 100644 --- a/payview/build.gradle +++ b/payview/build.gradle @@ -1,14 +1,14 @@ apply plugin: 'com.android.library' -apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' android { - compileSdkVersion 28 + compileSdkVersion 29 defaultConfig { minSdkVersion 21 - targetSdkVersion 28 + targetSdkVersion 29 versionCode 1 versionName "1.0" @@ -28,11 +28,11 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'androidx.appcompat:appcompat:1.1.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' - implementation "androidx.core:core-ktx:1.0.2" + implementation "androidx.core:core-ktx:1.3.0" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'com.google.android.material:material:1.0.0' } diff --git a/payview/src/main/java/com/fevziomurtekin/payview/Payview.kt b/payview/src/main/java/com/fevziomurtekin/payview/Payview.kt index f0fc667..1f2f2da 100644 --- a/payview/src/main/java/com/fevziomurtekin/payview/Payview.kt +++ b/payview/src/main/java/com/fevziomurtekin/payview/Payview.kt @@ -520,7 +520,7 @@ class Payview : NestedScrollView, View.OnFocusChangeListener { && tev_card_cv.text.toString().length==3 && tev_card_month.text.toString().length==2 && tev_card_year.text.toString().length==2 - && tev_card_no.text?.toString()?.replace(" ","")?.length==16){ + && tev_card_no.text?.toString()?.replace(" ","")?.length in 14..16){ /** card month/card year compare to now date.*/ val nowMonth = Calendar.getInstance().get(Calendar.MONTH) @@ -534,34 +534,50 @@ class Payview : NestedScrollView, View.OnFocusChangeListener { }else true } else{ - if(tev_card_name.text.isNullOrEmpty()) + var valid = true + if(tev_card_name.text.isNullOrEmpty()) { tev_card_name.error = cardNameHelperText - if(tev_card_no.text?.toString()?.replace(" ","")?.length!=16) + valid = false + } + if(tev_card_no.text?.toString()?.replace(" ","")?.length!=16) { tev_card_no.error = cardNoHelperText + valid = false + } if(tev_card_cv.text.isNullOrEmpty() - || tev_card_cv.text.toString().length!=3) + || tev_card_cv.text.toString().length!=3) { tev_card_cv.error = cardCvErrorText + valid = false + } if(tev_card_year.text.isNullOrEmpty() || tev_card_year.text.toString().length!=2 - || tev_card_year.text.toString().toInt()>99) + || tev_card_year.text.toString().toInt()>99) { tev_card_year.error = cardYearErrorText + valid = false + } if(tev_card_month.text.isNullOrEmpty() || tev_card_month.text.toString().length!=2 - || tev_card_month.text.toString().toInt()<12) + || tev_card_month.text.toString().toInt()<12) { tev_card_month.error = cardMonthErrorText + valid = false + } - /** card month/card year compare to now date.*/ - val nowMonth = Calendar.getInstance().get(Calendar.MONTH) - val nowYear = Calendar.getInstance().get(Calendar.YEAR).toString().substring(2,4).toInt() - if(nowYear>tev_card_year.text.toString().toInt() - || (nowYear==tev_card_year.text.toString().toInt() - && nowMonth>=tev_card_month.text.toString().toInt())){ - tev_card_year.error = cardExpiredError - tev_card_month.error = cardExpiredError + if (valid) { + /** card month/card year compare to now date.*/ + val nowMonth = Calendar.getInstance().get(Calendar.MONTH) + val nowYear = + Calendar.getInstance().get(Calendar.YEAR).toString().substring(2, 4).toInt() + if (nowYear > tev_card_year.text.toString().toInt() + || (nowYear == tev_card_year.text.toString().toInt() + && nowMonth >= tev_card_month.text.toString().toInt()) + ) { + tev_card_year.error = cardExpiredError + tev_card_month.error = cardExpiredError + valid = false + } } - return false + return valid } } } diff --git a/payview/src/main/res/layout/payview_layout.xml b/payview/src/main/res/layout/payview_layout.xml index 6324204..fe4c2c1 100644 --- a/payview/src/main/res/layout/payview_layout.xml +++ b/payview/src/main/res/layout/payview_layout.xml @@ -250,7 +250,8 @@ android:textColorHint="@android:color/black" android:textColor="@android:color/black" android:layout_marginBottom="10dp" - app:counterEnabled="true"> + app:counterEnabled="true" + app:counterTextAppearance="@style/CounterText"> + app:counterEnabled="true" + app:counterTextAppearance="@style/CounterText"> + app:counterEnabled="true" + app:counterTextAppearance="@style/CounterText"> + app:counterEnabled="true" + app:counterTextAppearance="@style/CounterText"> + app:counterEnabled="true" + app:counterTextAppearance="@style/CounterText"> @android:color/black + + \ No newline at end of file