Skip to content

Commit

Permalink
Fixing bug for oev_text_color
Browse files Browse the repository at this point in the history
  • Loading branch information
swapnil1104 committed Nov 30, 2019
1 parent 73dd564 commit f68545d
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 7 deletions.
116 changes: 116 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
android:digits="0123456789"
android:maxLength="6"
android:padding="32dp"
app:oev_text_color="#dd1212"
android:textSize="30sp"
app:layout_constraintTop_toTopOf="parent"
app:oev_mask_character="ø¥"
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/values/integer.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<item name="maxLength" type="integer">5</item>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.ActionMode;
import android.view.ContextThemeWrapper;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand All @@ -27,6 +28,7 @@ public class OtpEditText extends AppCompatEditText implements TextWatcher {

private Paint mLinesPaint;
private Paint mStrokePaint;
private Paint mTextPaint;

private boolean mMaskInput;

Expand Down Expand Up @@ -72,6 +74,9 @@ private void init(Context context, AttributeSet attrs) {

getAttrsFromTypedArray(attrs);

mTextPaint = getPaint();
mTextPaint.setColor(mTextColor);

// Set the TextWatcher
this.addTextChangedListener(this);

Expand Down Expand Up @@ -119,7 +124,7 @@ public void onClick(View v) {
private void getAttrsFromTypedArray(AttributeSet attributeSet) {
final TypedArray a = getContext().obtainStyledAttributes(attributeSet, R.styleable.OtpEditText, defStyleAttr, 0);

mMaxLength = attributeSet.getAttributeIntValue(XML_NAMESPACE_ANDROID, "maxLength", 4);
mMaxLength = attributeSet.getAttributeIntValue(XML_NAMESPACE_ANDROID, "maxLength", 6);
mPrimaryColor = a.getColor(R.styleable.OtpEditText_oev_primary_color, getResources().getColor(android.R.color.holo_red_dark));
mSecondaryColor = a.getColor(R.styleable.OtpEditText_oev_secondary_color, getResources().getColor(R.color.light_gray));
mTextColor = a.getColor(R.styleable.OtpEditText_oev_text_color, getResources().getColor(android.R.color.black));
Expand Down
13 changes: 7 additions & 6 deletions otpedittext2/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="OtpEditText">
<attr name="oev_length" format="integer"/>
<attr name="oev_primary_color" format="color" />
<attr name="oev_secondary_color" format="color" />
<attr name="oev_text_color" format="color" />
<attr name="oev_box_style" format="string" />
<attr name="oev_length" format="integer|reference"/>
<attr name="oev_primary_color" format="color|reference" />
<attr name="oev_secondary_color" format="color|reference" />
<attr name="oev_text_color" format="color|reference" />

<attr name="oev_box_style" format="string|reference" />

<attr name="oev_mask_input" format="boolean" />
<attr name="oev_mask_character" format="string" />
<attr name="oev_mask_character" format="string|reference" />

</declare-styleable>

Expand Down

0 comments on commit f68545d

Please sign in to comment.