话不多说,直接上代码:
package com.sage.org.view;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Handler;
import android.text.Editable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextWatcher;
import android.text.style.ForegroundColorSpan;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import com.vogtec.uibase.R;
import com.vogtec.uibase.contacts.MM;
import com.vogtec.uibase.utils.AppUtils;
import java.util.ArrayList;
public class CustomEditTextView extends EditText implements TextWatcher, View.OnKeyListener {
private InputStatusChangeLinster inputStatusChangeLinster;
private boolean showPop = true;
private static final int SHOW_SELECT_TIME = 1300;
/**
* 0:Abc,1:abc,2:ABC,3:123,4:2aB,4:phone
*/
private int inputType = 0;
public static final int INPUTTYPE_Abc = 1;
public static final int INPUTTYPE_abc = 1 << 1;
public static final int INPUTTYPE_ABC = 1 << 2;
public static final int INPUTTYPE_123 = 1 << 3;
public static final int INPUTTYPE_2aB = 1 << 4;
public static final int INPUTTYPE_phone = 1 << 5;
public static final int INPUTTYPE_phone2 = 1 << 6;
private static String[] inputStringType = new String[]{
"Abc", "abc", "ABC", "123", "2aB", "phone", "phone2"};
static {
if (MM.isMfs(MM.MF_POLMOB)){
inputStringType = new String[]{
"Abc", "abc", "ABC", "123", "2aB", "Telefon", "Telefon2"};
}
}
private final boolean[] selectInputStringType = new boolean[]{
true, true, true, true, true, false, false};
private static String[][][] lib_char_abc;
private static final String[][][] lib_char_abc_en = {
{
{
" "},
{
".", "*", "#", ":", ",", "&", "@", "!", "'", "$", "%", "\"", "~", "(", ")", "+", "-", "/", "?",
";", "<", "=", ">", "[", "]", "_",},
{
"a", "b", "c"}, {
"d", "e", "f"},
{
"g", "h", "i"}, {
"j", "k", "l"}, {
"m", "n", "o"},
{
"p", "q", "r", "s"}, {
"t", "u", "v"}, {
"w", "x", "y", "z"},
{
".", "*", "#"}}, // Abc
{
{
" "},
{
".", "*", "#", ":", ",", "&", "@", "!", "'", "$", "%", "\"", "~", "(", ")", "+", "-", "/", "?",
";", "<", "=", ">", "[", "]", "_",},
{
"a", "b", "c"}, {
"d", "e", "f"},
{
"g", "h", "i"}, {
"j", "k", "l"}, {
"m", "n", "o"},
{
"p", "q", "r", "s"}, {
"t", "u", "v"}, {
"w", "x", "y", "z"},
{
".", "*", "#"}}, // abc
{
{
" "},
{
".", "*", "#", ":", ",", "&", "@", "!", "'", "$", "%", "\"", "~", "(", ")", "+", "-", "/", "?",
";", "<", "=", ">", "[", "]", "_",},
{
"A", "B", "C"}, {
"D", "E", "F"},
{
"G", "H", "I"}, {
"J", "K", "L"}, {
"M", "N", "O"},
{
"P", "Q", "R", "S"}, {
"T", "U", "V"}, {
"W", "X", "Y", "Z"},
{
".", "*", "#"}}, // ABC
{
{
"0"}, {
"1"}, {
"2"}, {
"3"}, {
"4"}, {
"5"}, {
"6"}, {
"7"}, {
"8"}, {
"9"}, {
"."}}, // 123
{
{
"0", " "},
{
"1", ".", "*", "#", ":", ",", "&", "@", "!", "'", "$", "%", "\"", "~", "(", ")", "+", "-", "/",
"?", ";", "<", "=", ">", "[", "]", "_",},
{
"2", "a", "A", "b", "B", "c", "C"},
{
"3", "d", "D", "e", "E", "f", "F"},
{
"4", "g", "G", "h", "H", "i", "I"}, {
"5", "j", "J", "k", "K", "l", "L"},
{
"6", "m", "M", "n", "N", "o", "O"},
{
"7", "p", "P", "q", "Q", "r", "R", "s", "S"},
{
"8", "t", "T", "u", "U", "v", "V"},
{
"9", "w", "W", "x", "X", "y", "Y", "z", "Z"}, {
".", "*", "#"}}, // 2aB
{
{
"0"}, {
"1"}, {
"2"}, {
"3"}, {
"4"}, {
"5"}, {
"6"}, {
"7"}, {
"8"}, {
"9"}, {
"+"}}, // phone
{
{
"0"}, {
"1"}, {
"2"}, {
"3"}, {
"4"}, {
"5"}, {
"6"}, {
"7"}, {
"8"}, {
"9"}, {
"*", "+", "#"}}, // phone2
};
//葡萄牙语
private static final String[][][] lib_char_abc_pt = {
{
{
" "},
{
".", "*", "#", ":", ",", "&", "@", "!", "'", "$", "%", "\"", "~", "(", ")", "+", "-", "/", "?",
";", "<", "=", ">", "[", "]", "_",},
{
"a", "b", "c", "á", "à", "â", "ã", "ç"}, {
"d", "e", "f", "é", "ê"},
{
"g", "h", "i", "í"}, {
"j", "k", "l"}, {
"m", "n", "o", "ó", "ô", "õ"},
{
"p", "q", "r", "s"}, {
"t", "u", "v", "ú", "ü"}, {