How does android combine SDN numbers in the phone book with other common numbers?
The original default design will separate SDN with the title "SDN ",
The following modifications can be used to arrange the SDN and general numbers in the same order and in the first order.
In configureSelection () method of DefaultContactListAdapter. java
Annotate the following statement with selection IS_SDN_CONTACT + "<1" (five entries in total ):
/**
* M: New Feature SDN
* Origin code:
* Private void configureSelection (
*@{
*/
Protected void configureSelection (
CursorLoader loader, long directoryId, ContactListFilter filter ){
If (filter = null ){
Return;
}
If (directoryId! = Directory. DEFAULT ){
Return;
}
StringBuilder selection = new StringBuilder ();
List SelectionArgs = new ArrayList ();
Switch (filter. filterType ){
Case ContactListFilter. FILTER_TYPE_ALL_ACCOUNTS :{
// We have already added directory = 0 to the URI, which takes care of this
// Filter
/** M: New Feature SDN @{*/
// 1 selection. append (RawContacts. IS_SDN_CONTACT + "<1 ");
Selection. append (RawContacts. IS_SDN_CONTACT + "<2 ");
/**@}*/
Break;
}
Case ContactListFilter. FILTER_TYPE_SINGLE_CONTACT :{
// We have already added the lookup key to the URI, which takes care of this
// Filter
Break;
}
Case ContactListFilter. FILTER_TYPE_STARRED :{
Selection. append (Contacts. STARRED + "! = 0 ");
Break;
}
Case ContactListFilter. FILTER_TYPE_WITH_PHONE_NUMBERS_ONLY :{
Selection. append (Contacts. HAS_PHONE_NUMBER + "= 1 ");
/** M: New Feature SDN @{*/
// 2 selection. append ("AND" + RawContacts. IS_SDN_CONTACT + "<1 ");
/**@}*/
Break;
}
Case ContactListFilter. FILTER_TYPE_CUSTOM :{
Selection. append (Contacts. IN_VISIBLE_GROUP + "= 1 ");
If (isCustomFilterForPhoneNumbersOnly ()){
Selection. append ("AND" + Contacts. HAS_PHONE_NUMBER + "= 1 ");
}
/** M: New Feature SDN @{*/
// 3 selection. append ("AND" + RawContacts. IS_SDN_CONTACT + "<1 ");
/**@}*/
Break;
}
Case ContactListFilter. FILTER_TYPE_ACCOUNT :{
// We use query parameters for account filter, so no selection to add here.
/** M: Change Feature: As Local Phone account contains null account and Phone
* Account, the Account Query Parameter cocould not meet this requirement. So,
* We shoshould keep to query contacts with selection .@{*/
If (AccountType. ACCOUNT_TYPE_LOCAL_PHONE.equals (filter. accountType )){
Selection. append ("EXISTS ("
+ "Select distinct" + RawContacts. CONTACT_ID
+ "FROM view_raw_contacts"
+ "WHERE (");
// 4 selection. append (RawContacts. IS_SDN_CONTACT + "<1 AND ");
Selection. append (RawContacts. CONTACT_ID + "=" + "view_contacts ."
+ Contacts. _ ID
+ "AND (" + RawContacts. ACCOUNT_TYPE + "is null"
+ "AND" + RawContacts. ACCOUNT_NAME + "is null"
+ "AND" + RawContacts. DATA_SET + "is null"
+ "OR" + RawContacts. ACCOUNT_TYPE + "=? "
+ "AND" + RawContacts. ACCOUNT_NAME + "=? ");
} Else {
Selection. append ("EXISTS ("
+ "Select distinct" + RawContacts. CONTACT_ID
+ "FROM view_raw_contacts"
+ "WHERE (");
// 5 selection. append (RawContacts. IS_SDN_CONTACT + "<1 AND ");
Selection. append (RawContacts. CONTACT_ID + "=" + "view_contacts ."
+ Contacts. _ ID
+ "AND (" + RawContacts. ACCOUNT_TYPE + "=? "
+ "AND" + RawContacts. ACCOUNT_NAME + "=? ");
}
SelectionArgs. add (filter. accountType );
SelectionArgs. add (filter. accountName );
If (filter. dataSet! = Null ){
Selection. append ("AND" + RawContacts. DATA_SET + "=? )");
SelectionArgs. add (filter. dataSet );
} Else {
Selection. append ("AND" + RawContacts. DATA_SET + "is null )");
}
Selection. append ("))");
/**@}*/
Break;
}
}
/// M: Log the selection string.
Log. d (TAG, "[configureSelection] selection:" + selection. toString ());
Loader. setSelection (selection. toString ());
Loader. setSelectionArgs (selectionArgs. toArray (new String [0]);
}