summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard MacGregor <rmacgregor@cyngn.com>2015-10-14 16:40:08 -0700
committerRichard MacGregor <rmacgregor@cyngn.com>2016-04-07 13:34:40 -0700
commitb25f3757676188caa76c9851c952eaa1bd048a0d (patch)
tree3341d05eeacdb373fe8b637152cc062fdb6af676
parent48f6d927f72659ca05bb96c6930ca79e81eeb155 (diff)
downloadpackages_providers_ContactsProvider-b25f3757676188caa76c9851c952eaa1bd048a0d.zip
packages_providers_ContactsProvider-b25f3757676188caa76c9851c952eaa1bd048a0d.tar.gz
packages_providers_ContactsProvider-b25f3757676188caa76c9851c952eaa1bd048a0d.tar.bz2
[1/3] Show incall plugin contacts in favorites
Add ability to show contacts with incall callable mimetypes as starred/favorites. Change-Id: Iccaee75cbf607c6a8ad10d81bd8abb3797748512 Tickets: CD-58 CD-60 CD-119
-rw-r--r--src/com/android/providers/contacts/ContactsProvider2.java35
1 files changed, 30 insertions, 5 deletions
diff --git a/src/com/android/providers/contacts/ContactsProvider2.java b/src/com/android/providers/contacts/ContactsProvider2.java
index 86f6213..3ec15c1 100644
--- a/src/com/android/providers/contacts/ContactsProvider2.java
+++ b/src/com/android/providers/contacts/ContactsProvider2.java
@@ -5541,12 +5541,17 @@ public class ContactsProvider2 extends AbstractContactsProvider
mDbHelper.get().getMimeTypeId(Phone.CONTENT_ITEM_TYPE);
final long sipMimeTypeId =
mDbHelper.get().getMimeTypeId(SipAddress.CONTENT_ITEM_TYPE);
+ final String additionalCallableMimeTypes = getCallableMimeTypesFromUri(uri);
+ String mimeTypeIdClauses = phoneMimeTypeId + ", " + sipMimeTypeId;
+ if (!TextUtils.isEmpty(additionalCallableMimeTypes)) {
+ mimeTypeIdClauses += ", " + additionalCallableMimeTypes;
+ }
qb.appendWhere(DbQueryUtils.concatenateClauses(
selection,
"(" + Contacts.STARRED + "=1",
DataColumns.MIMETYPE_ID + " IN (" +
- phoneMimeTypeId + ", " + sipMimeTypeId + ")) AND (" +
+ mimeTypeIdClauses + ")) AND (" +
RawContacts.CONTACT_ID + " IN " + Tables.DEFAULT_DIRECTORY + ")"));
starredInnerQuery = qb.buildQuery(subProjection, null, null,
null, Data.IS_SUPER_PRIMARY + " DESC," + SORT_BY_DATA_USAGE, null);
@@ -5575,7 +5580,7 @@ public class ContactsProvider2 extends AbstractContactsProvider
selection,
"(" + Contacts.STARRED + "=0 OR " + Contacts.STARRED + " IS NULL",
DataColumns.MIMETYPE_ID + " IN (" +
- phoneMimeTypeId + ", " + sipMimeTypeId + ")) AND (" +
+ mimeTypeIdClauses + ")) AND (" +
RawContacts.CONTACT_ID + " IN " + Tables.DEFAULT_DIRECTORY + ")"));
frequentInnerQuery = qb.buildQuery(subProjection, null, null, null,
SORT_BY_DATA_USAGE, "25");
@@ -6662,7 +6667,7 @@ public class ContactsProvider2 extends AbstractContactsProvider
private String appendMimeTypeQueryParameters(Uri uri) {
final String mimeTypesQueryParameter =
getQueryParameter(uri, ADDITIONAL_CALLABLE_MIMETYPES_PARAM_KEY);
- String appendWhere = "";
+ StringBuilder appendWhere = new StringBuilder();
if (!TextUtils.isEmpty(mimeTypesQueryParameter)) {
List<String> mimeTypesQueryParameterList =
Arrays.asList(mimeTypesQueryParameter.split("\\s*,\\s*"));
@@ -6671,11 +6676,31 @@ public class ContactsProvider2 extends AbstractContactsProvider
for (String mimeType : mimeTypesQueryParameterList) {
long mimeTypeId = mDbHelper.get().getMimeTypeId(mimeType);
String mimeTypeIsExpression = DataColumns.MIMETYPE_ID + "=" + mimeTypeId;
- appendWhere += " OR (" + mimeTypeIsExpression + ")";
+ appendWhere.append(" OR (" + mimeTypeIsExpression + ")");
+ }
+ }
+ }
+ return appendWhere.toString();
+ }
+
+ private String getCallableMimeTypesFromUri(Uri uri) {
+ final String mimeTypesQueryParameter =
+ getQueryParameter(uri, ADDITIONAL_CALLABLE_MIMETYPES_PARAM_KEY);
+ StringBuilder mimeTypeIds = new StringBuilder();
+ if (!TextUtils.isEmpty(mimeTypesQueryParameter)) {
+ List<String> mimeTypesQueryParameterList =
+ Arrays.asList(mimeTypesQueryParameter.split("\\s*,\\s*"));
+ if (mimeTypesQueryParameterList != null && !mimeTypesQueryParameterList.isEmpty()) {
+ // Parse URI
+ for (String mimeType : mimeTypesQueryParameterList) {
+ if (!TextUtils.isEmpty(mimeTypeIds.toString())) {
+ mimeTypeIds.append(", ");
+ }
+ mimeTypeIds.append(mDbHelper.get().getMimeTypeId(mimeType));
}
}
}
- return appendWhere;
+ return mimeTypeIds.toString();
}
// Rewrites query sort orders using SORT_KEY_{PRIMARY, ALTERNATIVE}