Miscellaneous contact-detail fixes.
Fix bug in carousel "Updates" tab, which would turn black when swiping
it all the way to the left. This was caused by a small negative alpha
being computed, and some incautious integer arithmetic to transform it
for use in setBackgroundColor(). Fix clamps the alpha value between 0
and 1 (using newly-introduced MoreMath class).
Fix visual glitch where the "Updates" label displays the "pushed" glow
when tapped.
Bug: 6009463
Change-Id: Iee041ee7793f198f1d51ea5e7c5bbcb07b9a41df
diff --git a/src/com/android/contacts/ContactLoader.java b/src/com/android/contacts/ContactLoader.java
index e85f5f5..bc0f3f4 100644
--- a/src/com/android/contacts/ContactLoader.java
+++ b/src/com/android/contacts/ContactLoader.java
@@ -410,6 +410,23 @@
&& mDirectoryId != Directory.LOCAL_INVISIBLE;
}
+ /**
+ * @return true if this is a contact (not group, etc.) with at least one
+ * writeable raw-contact, and false otherwise.
+ */
+ public boolean isWritableContact(Context context) {
+ if (isDirectoryEntry()) return false;
+ final AccountTypeManager accountTypes = AccountTypeManager.getInstance(context);
+ for (Entity rawContact : getEntities()) {
+ final ContentValues rawValues = rawContact.getEntityValues();
+ final String accountType = rawValues.getAsString(RawContacts.ACCOUNT_TYPE);
+ final String dataSet = rawValues.getAsString(RawContacts.DATA_SET);
+ final AccountType type = accountTypes.getAccountType(accountType, dataSet);
+ if (type != null && type.areContactsWritable()) return true;
+ }
+ return false;
+ }
+
public int getDirectoryExportSupport() {
return mDirectoryExportSupport;
}