Merge "Use AppCompatContactsActivity as super class of activities (2/3)" into ub-contactsdialer-b-dev
diff --git a/src/com/android/contacts/common/CallUtil.java b/src/com/android/contacts/common/CallUtil.java
index 7640246..88fca92 100644
--- a/src/com/android/contacts/common/CallUtil.java
+++ b/src/com/android/contacts/common/CallUtil.java
@@ -17,6 +17,7 @@
package com.android.contacts.common;
import com.android.contacts.common.compat.CompatUtils;
+import com.android.contacts.common.compat.PhoneAccountSdkCompat;
import com.android.contacts.common.util.PermissionsUtil;
import com.android.contacts.common.util.PhoneNumberHelper;
import com.android.phone.common.PhoneConstants;
@@ -151,7 +152,7 @@
int videoCapabilities = VIDEO_CALLING_ENABLED;
if (account.hasCapabilities(
- PhoneAccount.CAPABILITY_VIDEO_CALLING_RELIES_ON_PRESENCE)) {
+ PhoneAccountSdkCompat.CAPABILITY_VIDEO_CALLING_RELIES_ON_PRESENCE)) {
videoCapabilities |= VIDEO_CALLING_PRESENCE;
}
return videoCapabilities;
diff --git a/src/com/android/contacts/common/compat/DirectoryCompat.java b/src/com/android/contacts/common/compat/DirectoryCompat.java
index b032fe9..5f6d8bf 100644
--- a/src/com/android/contacts/common/compat/DirectoryCompat.java
+++ b/src/com/android/contacts/common/compat/DirectoryCompat.java
@@ -17,7 +17,6 @@
package com.android.contacts.common.compat;
import android.net.Uri;
-import android.os.Build;
import android.provider.ContactsContract;
import android.provider.ContactsContract.Directory;
@@ -47,7 +46,7 @@
public static boolean isRemoteDirectory(long directoryId) {
// TODO: Use N APIs
if (ContactsUtils.FLAG_N_FEATURE && android.os.Build.VERSION.CODENAME.startsWith("N")) {
- return Directory.isRemoteDirectory(directoryId);
+ return DirectorySdkCompat.isRemoteDirectory(directoryId);
}
return !(directoryId == Directory.DEFAULT || directoryId == Directory.LOCAL_INVISIBLE);
}
diff --git a/src/com/android/contacts/common/dialog/CallSubjectDialog.java b/src/com/android/contacts/common/dialog/CallSubjectDialog.java
index 3c08b37..a17c4fc 100644
--- a/src/com/android/contacts/common/dialog/CallSubjectDialog.java
+++ b/src/com/android/contacts/common/dialog/CallSubjectDialog.java
@@ -48,6 +48,7 @@
import com.android.contacts.common.ContactPhotoManager;
import com.android.contacts.common.R;
import com.android.contacts.common.compat.CompatUtils;
+import com.android.contacts.common.compat.PhoneAccountSdkCompat;
import com.android.contacts.common.compat.telecom.TelecomManagerCompat;
import com.android.contacts.common.util.UriUtils;
import com.android.phone.common.animation.AnimUtils;
@@ -593,17 +594,18 @@
(TelecomManager) getSystemService(Context.TELECOM_SERVICE);
final PhoneAccount account = telecomManager.getPhoneAccount(mPhoneAccountHandle);
- Bundle phoneAccountExtras = account.getExtras();
+ Bundle phoneAccountExtras = PhoneAccountSdkCompat.getExtras(account);
if (phoneAccountExtras == null) {
return;
}
// Get limit, if provided; otherwise default to existing value.
- mLimit = phoneAccountExtras.getInt(PhoneAccount.EXTRA_CALL_SUBJECT_MAX_LENGTH, mLimit);
+ mLimit = phoneAccountExtras
+ .getInt(PhoneAccountSdkCompat.EXTRA_CALL_SUBJECT_MAX_LENGTH, mLimit);
// Get charset; default to none (e.g. count characters 1:1).
String charsetName = phoneAccountExtras.getString(
- PhoneAccount.EXTRA_CALL_SUBJECT_CHARACTER_ENCODING);
+ PhoneAccountSdkCompat.EXTRA_CALL_SUBJECT_CHARACTER_ENCODING);
if (!TextUtils.isEmpty(charsetName)) {
try {
diff --git a/src/com/android/contacts/common/model/ContactLoader.java b/src/com/android/contacts/common/model/ContactLoader.java
index 923e2f9..f925d1d 100644
--- a/src/com/android/contacts/common/model/ContactLoader.java
+++ b/src/com/android/contacts/common/model/ContactLoader.java
@@ -40,6 +40,7 @@
import com.android.contacts.common.GeoUtil;
import com.android.contacts.common.GroupMetaData;
+import com.android.contacts.common.compat.CompatUtils;
import com.android.contacts.common.model.account.AccountType;
import com.android.contacts.common.model.account.AccountTypeWithDataSet;
import com.android.contacts.common.util.Constants;
@@ -51,6 +52,7 @@
import com.android.contacts.common.model.dataitem.PhotoDataItem;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
@@ -113,7 +115,7 @@
* social stream items).
*/
private static class ContactQuery {
- static final String[] COLUMNS = new String[] {
+ static final String[] COLUMNS_INTERNAL = new String[] {
Contacts.NAME_RAW_CONTACT_ID,
Contacts.DISPLAY_NAME_SOURCE,
Contacts.LOOKUP_KEY,
@@ -183,10 +185,19 @@
Contacts.IS_USER_PROFILE,
Data.TIMES_USED,
- Data.LAST_TIME_USED,
- Data.CARRIER_PRESENCE
+ Data.LAST_TIME_USED
};
+ static final String[] COLUMNS;
+
+ static {
+ List<String> projectionList = Lists.newArrayList(COLUMNS_INTERNAL);
+ if (CompatUtils.isMarshmallowCompatible()) {
+ projectionList.add(Data.CARRIER_PRESENCE);
+ }
+ COLUMNS = projectionList.toArray(new String[projectionList.size()]);
+ }
+
public static final int NAME_RAW_CONTACT_ID = 0;
public static final int DISPLAY_NAME_SOURCE = 1;
public static final int LOOKUP_KEY = 2;
@@ -716,7 +727,9 @@
cursorColumnToContentValues(cursor, cv, ContactQuery.CHAT_CAPABILITY);
cursorColumnToContentValues(cursor, cv, ContactQuery.TIMES_USED);
cursorColumnToContentValues(cursor, cv, ContactQuery.LAST_TIME_USED);
- cursorColumnToContentValues(cursor, cv, ContactQuery.CARRIER_PRESENCE);
+ if (CompatUtils.isMarshmallowCompatible()) {
+ cursorColumnToContentValues(cursor, cv, ContactQuery.CARRIER_PRESENCE);
+ }
return cv;
}