From 048f1043cc5f4c8dfac5dbe746c17ae44245346d Mon Sep 17 00:00:00 2001 From: Leonardo Esparis Date: Mon, 13 Feb 2017 14:19:55 -0400 Subject: [PATCH] adding max length and singleline option by default --- .../main/java/com/github/leoxnidas/phoneedittext/Codes.java | 1 - .../java/com/github/leoxnidas/phoneedittext/PhoneEditText.java | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/phoneedittext/src/main/java/com/github/leoxnidas/phoneedittext/Codes.java b/phoneedittext/src/main/java/com/github/leoxnidas/phoneedittext/Codes.java index d5adcf6..bcbd165 100644 --- a/phoneedittext/src/main/java/com/github/leoxnidas/phoneedittext/Codes.java +++ b/phoneedittext/src/main/java/com/github/leoxnidas/phoneedittext/Codes.java @@ -1,7 +1,6 @@ package com.github.leoxnidas.phoneedittext; - public class Codes { public static final int AFG = 1; public static final int ALB = 2; diff --git a/phoneedittext/src/main/java/com/github/leoxnidas/phoneedittext/PhoneEditText.java b/phoneedittext/src/main/java/com/github/leoxnidas/phoneedittext/PhoneEditText.java index 99cb4a0..f743a5f 100644 --- a/phoneedittext/src/main/java/com/github/leoxnidas/phoneedittext/PhoneEditText.java +++ b/phoneedittext/src/main/java/com/github/leoxnidas/phoneedittext/PhoneEditText.java @@ -3,6 +3,7 @@ import android.content.Context; import android.content.res.TypedArray; import android.text.Editable; +import android.text.InputFilter; import android.text.InputType; import android.text.Selection; import android.text.TextWatcher; @@ -48,6 +49,8 @@ public void setCode(int code) { p_mCode = code; p_mCodeStr = Codes.asString(code); setText((PLUS + p_mCodeStr)); + setSingleLine(true); + setFilters(new InputFilter[]{new InputFilter.LengthFilter(14)}); } else { throw new RuntimeException("International code does not exists."); }