Skip to content

Commit c194470

Browse files
committed
Make library available for API level 21 and above
1 parent 5fc81f0 commit c194470

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

app/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ android {
66

77
defaultConfig {
88
applicationId "com.dhairytripathi.edittextpin"
9-
minSdkVersion 23
9+
minSdkVersion 21
1010
targetSdkVersion 30
1111
versionCode 1
1212
versionName "1.0"
@@ -25,10 +25,10 @@ android {
2525
dependencies {
2626
implementation fileTree(dir: "libs", include: ["*.jar"])
2727
implementation 'androidx.appcompat:appcompat:1.2.0'
28-
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
28+
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
2929
implementation project(path: ':library')
3030
testImplementation 'junit:junit:4.13'
31-
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
32-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
31+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
32+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
3333

3434
}

library/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ android {
55
buildToolsVersion "30.0.2"
66

77
defaultConfig {
8-
minSdkVersion 23
8+
minSdkVersion 21
99
targetSdkVersion 30
1010
versionCode 1
1111
versionName "1.0"
@@ -26,8 +26,8 @@ dependencies {
2626
implementation fileTree(dir: "libs", include: ["*.jar"])
2727
implementation 'androidx.appcompat:appcompat:1.2.0'
2828
testImplementation 'junit:junit:4.13'
29-
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
30-
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
31-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
29+
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
30+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
31+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
3232

3333
}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="com.dhairytripathi.library">
3-
4-
/
53
</manifest>

library/src/main/java/com/dhairytripathi/library/EditTextPin.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import android.graphics.drawable.Drawable;
99
import android.graphics.drawable.GradientDrawable;
1010
import android.graphics.drawable.LayerDrawable;
11+
import android.os.Build;
1112
import android.text.Editable;
1213
import android.text.TextWatcher;
1314
import android.util.AttributeSet;
@@ -24,6 +25,8 @@ public class EditTextPin extends ConstraintLayout {
2425
private Context context;
2526
private int underlineColor = R.color.underlineColor;
2627
private int background = R.drawable.background;
28+
private static final String TAG = "EditTextPin";
29+
2730
public EditTextPin(Context context, AttributeSet attrs) {
2831
super(context, attrs);
2932
handleAttrs(attrs);
@@ -44,7 +47,9 @@ protected void onAttachedToWindow() {
4447
LayerDrawable shape = (LayerDrawable) ContextCompat.getDrawable(context,R.drawable.underline);
4548
GradientDrawable bgShape = (GradientDrawable) (shape.findDrawableByLayerId(R.id.underline));
4649
bgShape.setStroke(convertDpToPx(2), ContextCompat.getColor(context, underlineColor));
47-
shape.setDrawable(0, bgShape);
50+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
51+
shape.setDrawable(0, bgShape);
52+
}
4853
view.setBackground(shape);
4954
pin1 = findViewById(R.id.pin1);
5055
pin2 = findViewById(R.id.pin2);

0 commit comments

Comments
 (0)