原始默認設計會將SDN單獨分出來,小標題為"SDN",
通過如下修改可以達到SDN和普通號碼一樣排列在一起,按首字母順序排列。
DefaultContactListAdapter.java 的 configureSelection() 方法中
對 selection 為 IS_SDN_CONTACT + " < 1" 的如下語句注解掉(總共有五處):
/**
* 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 could not meet this requirement. So,
* We should 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]));
}