From d08b8ae061ca8b5ef8da767e9f7d027afd503319 Mon Sep 17 00:00:00 2001 From: paynd Date: Tue, 7 Nov 2017 01:02:11 +0300 Subject: [PATCH 1/2] Changed internal textview positioning --- CreditCardEntry/build.gradle | 12 ++++++++---- .../creditcardentry/fields/CreditEntryFieldBase.java | 2 +- .../creditcardentry/internal/CreditCardEntry.java | 11 ++++++++++- CreditCardEntryDemo/build.gradle | 12 ++++++++---- CreditCardEntryDemo/res/layout/activity_main.xml | 2 +- build.gradle | 4 +++- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 7 files changed, 33 insertions(+), 14 deletions(-) diff --git a/CreditCardEntry/build.gradle b/CreditCardEntry/build.gradle index c1e8b0f..93f6c6d 100644 --- a/CreditCardEntry/build.gradle +++ b/CreditCardEntry/build.gradle @@ -2,12 +2,12 @@ apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' android { - compileSdkVersion 24 - buildToolsVersion "24.0.3" + compileSdkVersion 25 + buildToolsVersion '25.0.3' defaultConfig { minSdkVersion 16 - targetSdkVersion 24 + targetSdkVersion 25 versionCode 1 versionName "1.0.0" } @@ -36,5 +36,9 @@ artifacts { } dependencies { - compile 'com.android.support:support-v4:24.2.1' + compile 'com.android.support:support-compat:25.3.1' + compile 'com.android.support:support-core-utils:25.3.1' + compile 'com.android.support:support-core-ui:25.3.1' + compile 'com.android.support:support-media-compat:25.3.1' + compile 'com.android.support:support-fragment:25.3.1' } diff --git a/CreditCardEntry/src/com/devmarvel/creditcardentry/fields/CreditEntryFieldBase.java b/CreditCardEntry/src/com/devmarvel/creditcardentry/fields/CreditEntryFieldBase.java index f19ce60..c182886 100644 --- a/CreditCardEntry/src/com/devmarvel/creditcardentry/fields/CreditEntryFieldBase.java +++ b/CreditCardEntry/src/com/devmarvel/creditcardentry/fields/CreditEntryFieldBase.java @@ -73,7 +73,7 @@ void init(AttributeSet attrs) { addTextChangedListener(this); setOnKeyListener(this); setOnClickListener(this); - setPadding(20, 0, 20, 0); + setPadding(50, 0, 50, 0); setStyle(attrs); } diff --git a/CreditCardEntry/src/com/devmarvel/creditcardentry/internal/CreditCardEntry.java b/CreditCardEntry/src/com/devmarvel/creditcardentry/internal/CreditCardEntry.java index 38a096d..4c145c9 100644 --- a/CreditCardEntry/src/com/devmarvel/creditcardentry/internal/CreditCardEntry.java +++ b/CreditCardEntry/src/com/devmarvel/creditcardentry/internal/CreditCardEntry.java @@ -98,7 +98,7 @@ public CreditCardEntry(Context context, boolean includeExp, boolean includeSecur } else { textColor = null; } - textSize = typedArray.getDimensionPixelSize(R.styleable.CreditCardForm_text_size, 19); + textSize = typedArray.getDimensionPixelSize(R.styleable.CreditCardForm_text_size, 26); typedArray.recycle(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); @@ -217,6 +217,15 @@ public void onClick(View v) { }); } + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + super.onLayout(changed, l, t, r, b); + int shiftPadding = r - l - cardImage.getWidth() - expDateText.getWidth() - securityCodeText.getWidth() - 20; + if (shiftPadding > 0) { + textFourDigits.setPadding(0, 0, shiftPadding, 0); + } + } + @Override public void onCardTypeChange(CardType type) { cardImage.setImageResource(type.frontResource); diff --git a/CreditCardEntryDemo/build.gradle b/CreditCardEntryDemo/build.gradle index d2c71f2..3730ca5 100644 --- a/CreditCardEntryDemo/build.gradle +++ b/CreditCardEntryDemo/build.gradle @@ -1,12 +1,12 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 24 - buildToolsVersion "24.0.3" + compileSdkVersion 25 + buildToolsVersion '25.0.3' defaultConfig { minSdkVersion 16 - targetSdkVersion 24 + targetSdkVersion 25 applicationId "com.devmarvel.creditcardentry" versionCode 1 versionName "1.0.0" @@ -27,5 +27,9 @@ android { dependencies { compile project(':CreditCardEntry') - compile 'com.android.support:support-v4:24.2.1' + compile 'com.android.support:support-compat:25.3.1' + compile 'com.android.support:support-core-utils:25.3.1' + compile 'com.android.support:support-core-ui:25.3.1' + compile 'com.android.support:support-media-compat:25.3.1' + compile 'com.android.support:support-fragment:25.3.1' } diff --git a/CreditCardEntryDemo/res/layout/activity_main.xml b/CreditCardEntryDemo/res/layout/activity_main.xml index e30f8f8..0eb67e4 100644 --- a/CreditCardEntryDemo/res/layout/activity_main.xml +++ b/CreditCardEntryDemo/res/layout/activity_main.xml @@ -23,7 +23,7 @@ Date: Tue, 7 Nov 2017 01:02:11 +0300 Subject: [PATCH 2/2] Changed internal textview positioning --- CreditCardEntry/build.gradle | 12 ++++++++---- .../creditcardentry/fields/CreditEntryFieldBase.java | 2 +- .../creditcardentry/internal/CreditCardEntry.java | 11 ++++++++++- CreditCardEntryDemo/build.gradle | 12 ++++++++---- CreditCardEntryDemo/res/layout/activity_main.xml | 2 +- build.gradle | 4 +++- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 7 files changed, 33 insertions(+), 14 deletions(-) diff --git a/CreditCardEntry/build.gradle b/CreditCardEntry/build.gradle index c1e8b0f..93f6c6d 100644 --- a/CreditCardEntry/build.gradle +++ b/CreditCardEntry/build.gradle @@ -2,12 +2,12 @@ apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' android { - compileSdkVersion 24 - buildToolsVersion "24.0.3" + compileSdkVersion 25 + buildToolsVersion '25.0.3' defaultConfig { minSdkVersion 16 - targetSdkVersion 24 + targetSdkVersion 25 versionCode 1 versionName "1.0.0" } @@ -36,5 +36,9 @@ artifacts { } dependencies { - compile 'com.android.support:support-v4:24.2.1' + compile 'com.android.support:support-compat:25.3.1' + compile 'com.android.support:support-core-utils:25.3.1' + compile 'com.android.support:support-core-ui:25.3.1' + compile 'com.android.support:support-media-compat:25.3.1' + compile 'com.android.support:support-fragment:25.3.1' } diff --git a/CreditCardEntry/src/com/devmarvel/creditcardentry/fields/CreditEntryFieldBase.java b/CreditCardEntry/src/com/devmarvel/creditcardentry/fields/CreditEntryFieldBase.java index f19ce60..c182886 100644 --- a/CreditCardEntry/src/com/devmarvel/creditcardentry/fields/CreditEntryFieldBase.java +++ b/CreditCardEntry/src/com/devmarvel/creditcardentry/fields/CreditEntryFieldBase.java @@ -73,7 +73,7 @@ void init(AttributeSet attrs) { addTextChangedListener(this); setOnKeyListener(this); setOnClickListener(this); - setPadding(20, 0, 20, 0); + setPadding(50, 0, 50, 0); setStyle(attrs); } diff --git a/CreditCardEntry/src/com/devmarvel/creditcardentry/internal/CreditCardEntry.java b/CreditCardEntry/src/com/devmarvel/creditcardentry/internal/CreditCardEntry.java index 38a096d..4c145c9 100644 --- a/CreditCardEntry/src/com/devmarvel/creditcardentry/internal/CreditCardEntry.java +++ b/CreditCardEntry/src/com/devmarvel/creditcardentry/internal/CreditCardEntry.java @@ -98,7 +98,7 @@ public CreditCardEntry(Context context, boolean includeExp, boolean includeSecur } else { textColor = null; } - textSize = typedArray.getDimensionPixelSize(R.styleable.CreditCardForm_text_size, 19); + textSize = typedArray.getDimensionPixelSize(R.styleable.CreditCardForm_text_size, 26); typedArray.recycle(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); @@ -217,6 +217,15 @@ public void onClick(View v) { }); } + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + super.onLayout(changed, l, t, r, b); + int shiftPadding = r - l - cardImage.getWidth() - expDateText.getWidth() - securityCodeText.getWidth() - 20; + if (shiftPadding > 0) { + textFourDigits.setPadding(0, 0, shiftPadding, 0); + } + } + @Override public void onCardTypeChange(CardType type) { cardImage.setImageResource(type.frontResource); diff --git a/CreditCardEntryDemo/build.gradle b/CreditCardEntryDemo/build.gradle index d2c71f2..3730ca5 100644 --- a/CreditCardEntryDemo/build.gradle +++ b/CreditCardEntryDemo/build.gradle @@ -1,12 +1,12 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 24 - buildToolsVersion "24.0.3" + compileSdkVersion 25 + buildToolsVersion '25.0.3' defaultConfig { minSdkVersion 16 - targetSdkVersion 24 + targetSdkVersion 25 applicationId "com.devmarvel.creditcardentry" versionCode 1 versionName "1.0.0" @@ -27,5 +27,9 @@ android { dependencies { compile project(':CreditCardEntry') - compile 'com.android.support:support-v4:24.2.1' + compile 'com.android.support:support-compat:25.3.1' + compile 'com.android.support:support-core-utils:25.3.1' + compile 'com.android.support:support-core-ui:25.3.1' + compile 'com.android.support:support-media-compat:25.3.1' + compile 'com.android.support:support-fragment:25.3.1' } diff --git a/CreditCardEntryDemo/res/layout/activity_main.xml b/CreditCardEntryDemo/res/layout/activity_main.xml index e30f8f8..ea0798c 100644 --- a/CreditCardEntryDemo/res/layout/activity_main.xml +++ b/CreditCardEntryDemo/res/layout/activity_main.xml @@ -23,7 +23,7 @@