JB Version:
1.sim/usim Card Contact: You can directly use the editsimcontactactivity in the Usim_email_pattern, search and "Usim_email_pattern", the relevant code added to remove the comments can be
2. Phone Local Contact: Modify the code as follows
Contacteditorfragment.java (Packages\apps\contacts\src\com\android\contacts\editor)
A Introduction Package
Import Java.util.regex.Pattern;
B Add Variable
private static final String Usim_email_pattern = "0-9][a-z][a-z][_0-9][a-z][a-z][-_.*@0-9][a-z][a-z][-_.+";
In the C save function,
In the following statement:
if (!hasvalidstate () | | Mstatus! = status.editing) {
LOG.I (TAG, "[Save]!hasvalidstate ():" + (!hasvalidstate ())
+ " | Mstatus! = status.editing: "+ (mstatus! = status.editing)
+ ", Mstatus:" + mstatus);
return false;
}
Add later:
Email
for (int n = 0; n < mstate.size (); n++) {
Rawcontactdelta field = Mstate.get (n);
arraylist<valuesdelta> data = field.getmimeentries ("Vnd.android.cursor.item/email_v2");
if (data! = NULL)
for (int m = 0; m < data.size (); m++) {
String email = data.get (m). Getasstring ("Data1");
if (! Textutils.isempty (email)) {
if (! Pattern.matches (Usim_email_pattern, EMAIL)) {
Toast.maketext (Mcontext, R.string.email_invalid, Toast.length_short). Show ();
Getactivity (). Finish ();
return false;
}
}
}
}
KK version
1. Sim/usim Card Contact:
Simeditprocessor.java (Alps\packages\apps\contacts\src\com\mediatek\contacts\simservice)
Add Private Boolean memailinvalid = False first;
And then Modify
Private Boolean Isusimupdatevaluesinvalid ()
MTK Add
if (! Textutils.isempty (Mupdatemail)) {
if (! Pattern.matches (Usim_email_pattern, Mupdatemail)) {
Memailinvalid = true;
}
}
MTK Add End
LOGUTILS.I (TAG, "mnumberisnull:" + Mnumberisnull + ", Mnumberinvalid:" +
Mnumberinvalid + ", Mfixnumberinvalid:" + mfixnumberinvalid); Reference location
Re-Modify
Private Boolean Isinsertvaluesinvalid ()
if (! Textutils.isempty (Mupdateadditionalnumber)) {
if (! Pattern.matches (Sim_num_pattern, Phonenumberutilsex
. Extractclirportion (Mupdateadditionalnumber))) {
Mfixnumberinvalid = true;
}
}//Reference Position
MTK Add
if (! Textutils.isempty (Mupdatemail)) {
if (! Pattern.matches (Usim_email_pattern, Mupdatemail)) {
Memailinvalid = true;
}
}
MTK Add End
Last modified
Private Boolean Setsavefailtoasttext ()
}*/else if (memailinvalid) {
Msavefailtoaststrid = R.string.cannot_insert_error_format_email; Resources Please add yourself
Memailinvalid = false;
2. Phone Local Contact: Modify the code as follows
Contacteditorfragment.java (Packages\apps\contacts\src\com\android\contacts\editor)
A Introduction Package
Import Java.util.regex.Pattern;
B Add Variable
private static final String Usim_email_pattern = "0-9][a-z][a-z][_0-9][a-z][a-z][-_.*@0-9][a-z][a-z][-_.+";
In the C save function,
In the following statement:
if (!hasvalidstate () | | Mstatus! = status.editing) {
LOG.I (TAG, "[Save]!hasvalidstate ():" + (!hasvalidstate ())
+ " | Mstatus! = status.editing: "+ (mstatus! = status.editing)
+ ", Mstatus:" + mstatus);
return false;
}
Add later:
Email
for (int n = 0; n < mstate.size (); n++) {
Rawcontactdelta field = Mstate.get (n);
arraylist<valuesdelta> data = field.getmimeentries ("Vnd.android.cursor.item/email_v2");
if (data! = NULL)
for (int m = 0; m < data.size (); m++) {
String email = data.get (m). Getasstring ("Data1");
if (! Textutils.isempty (email)) {
if (! Pattern.matches (Usim_email_pattern, EMAIL)) {
Toast.maketext (Mcontext, R.string.email_invalid, Toast.length_short). Show ();
Getactivity (). Finish ();
return false;
}
}
}
}
Android new/edit contacts, detect the email/email address format is legal