android 如何將電話簿中SDN號碼和其他普通號碼混合放在一起?

來源:互聯網
上載者:User

android 如何將電話簿中SDN號碼和其他普通號碼混合放在一起?
原始預設設計會將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]));
}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.