summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Kennedy <skennedy@google.com>2013-11-13 23:58:08 (GMT)
committerScott Kennedy <skennedy@google.com>2013-11-14 17:43:35 (GMT)
commit3e8176df16950c067bcb1b37e62b2fc07d74065a (patch)
tree3015ce491d513fb452665aa7f093138599800a20
parent72dbb5bf7e2e40cc5c2a31d09b079cb053b1b639 (diff)
downloadandroid_frameworks_ex-3e8176df16950c067bcb1b37e62b2fc07d74065a.zip
android_frameworks_ex-3e8176df16950c067bcb1b37e62b2fc07d74065a.tar.gz
android_frameworks_ex-3e8176df16950c067bcb1b37e62b2fc07d74065a.tar.bz2
Don't show the alternates dialog for GAL contacts
There's a bug in the chips code that causes this to show either no alternates, or a different person, which is scaring people. The proper future fix is to store some more information about GAL contacts so we can do a proper lookup. Bug: 11535331 Change-Id: Id8b6fc834446afe33bd6ec4e99b3d2b75b985bde
-rw-r--r--chips/src/com/android/ex/chips/BaseRecipientAdapter.java22
-rw-r--r--chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java6
-rw-r--r--chips/src/com/android/ex/chips/RecipientEditTextView.java3
-rw-r--r--chips/src/com/android/ex/chips/RecipientEntry.java28
-rw-r--r--chips/src/com/android/ex/chips/recipientchip/BaseRecipientChip.java7
-rw-r--r--chips/src/com/android/ex/chips/recipientchip/InvisibleRecipientChip.java5
-rw-r--r--chips/src/com/android/ex/chips/recipientchip/SimpleRecipientChip.java5
-rw-r--r--chips/src/com/android/ex/chips/recipientchip/VisibleRecipientChip.java5
-rw-r--r--chips/tests/src/com/android/ex/chips/RecipientAlternatesAdapterTest.java14
9 files changed, 70 insertions, 25 deletions
diff --git a/chips/src/com/android/ex/chips/BaseRecipientAdapter.java b/chips/src/com/android/ex/chips/BaseRecipientAdapter.java
index d9eb64e..cdab4f3 100644
--- a/chips/src/com/android/ex/chips/BaseRecipientAdapter.java
+++ b/chips/src/com/android/ex/chips/BaseRecipientAdapter.java
@@ -152,6 +152,7 @@ public abstract class BaseRecipientAdapter extends BaseAdapter implements Filter
public final long dataId;
public final String thumbnailUriString;
public final int displayNameSource;
+ public final boolean isGalContact;
public TemporaryEntry(
String displayName,
@@ -161,7 +162,8 @@ public abstract class BaseRecipientAdapter extends BaseAdapter implements Filter
long contactId,
long dataId,
String thumbnailUriString,
- int displayNameSource) {
+ int displayNameSource,
+ boolean isGalContact) {
this.displayName = displayName;
this.destination = destination;
this.destinationType = destinationType;
@@ -170,9 +172,10 @@ public abstract class BaseRecipientAdapter extends BaseAdapter implements Filter
this.dataId = dataId;
this.thumbnailUriString = thumbnailUriString;
this.displayNameSource = displayNameSource;
+ this.isGalContact = isGalContact;
}
- public TemporaryEntry(Cursor cursor) {
+ public TemporaryEntry(Cursor cursor, boolean isGalContact) {
this.displayName = cursor.getString(Queries.Query.NAME);
this.destination = cursor.getString(Queries.Query.DESTINATION);
this.destinationType = cursor.getInt(Queries.Query.DESTINATION_TYPE);
@@ -181,6 +184,7 @@ public abstract class BaseRecipientAdapter extends BaseAdapter implements Filter
this.dataId = cursor.getLong(Queries.Query.DATA_ID);
this.thumbnailUriString = cursor.getString(Queries.Query.PHOTO_THUMBNAIL_URI);
this.displayNameSource = cursor.getInt(Queries.Query.DISPLAY_NAME_SOURCE);
+ this.isGalContact = isGalContact;
}
}
@@ -251,7 +255,8 @@ public abstract class BaseRecipientAdapter extends BaseAdapter implements Filter
while (defaultDirectoryCursor.moveToNext()) {
// Note: At this point each entry doesn't contain any photo
// (thus getPhotoBytes() returns null).
- putOneEntry(new TemporaryEntry(defaultDirectoryCursor),
+ putOneEntry(new TemporaryEntry(defaultDirectoryCursor,
+ false /* isGalContact */),
true, entryMap, nonAggregatedEntries, existingDestinations);
}
@@ -382,7 +387,7 @@ public abstract class BaseRecipientAdapter extends BaseAdapter implements Filter
if (cursor != null) {
while (cursor.moveToNext()) {
- tempEntries.add(new TemporaryEntry(cursor));
+ tempEntries.add(new TemporaryEntry(cursor, true /* isGalContact */));
}
}
} finally {
@@ -683,7 +688,8 @@ public abstract class BaseRecipientAdapter extends BaseAdapter implements Filter
entry.displayName,
entry.displayNameSource,
entry.destination, entry.destinationType, entry.destinationLabel,
- entry.contactId, entry.dataId, entry.thumbnailUriString, true));
+ entry.contactId, entry.dataId, entry.thumbnailUriString, true,
+ entry.isGalContact));
} else if (entryMap.containsKey(entry.contactId)) {
// We already have a section for the person.
final List<RecipientEntry> entryList = entryMap.get(entry.contactId);
@@ -691,14 +697,16 @@ public abstract class BaseRecipientAdapter extends BaseAdapter implements Filter
entry.displayName,
entry.displayNameSource,
entry.destination, entry.destinationType, entry.destinationLabel,
- entry.contactId, entry.dataId, entry.thumbnailUriString, true));
+ entry.contactId, entry.dataId, entry.thumbnailUriString, true,
+ entry.isGalContact));
} else {
final List<RecipientEntry> entryList = new ArrayList<RecipientEntry>();
entryList.add(RecipientEntry.constructTopLevelEntry(
entry.displayName,
entry.displayNameSource,
entry.destination, entry.destinationType, entry.destinationLabel,
- entry.contactId, entry.dataId, entry.thumbnailUriString, true));
+ entry.contactId, entry.dataId, entry.thumbnailUriString, true,
+ entry.isGalContact));
entryMap.put(entry.contactId, entryList);
}
}
diff --git a/chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java b/chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java
index f64c166..b9a7c80 100644
--- a/chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java
+++ b/chips/src/com/android/ex/chips/RecipientAlternatesAdapter.java
@@ -229,7 +229,8 @@ public class RecipientAlternatesAdapter extends CursorAdapter {
c.getLong(Queries.Query.CONTACT_ID),
c.getLong(Queries.Query.DATA_ID),
c.getString(Queries.Query.PHOTO_THUMBNAIL_URI),
- true);
+ true,
+ false /* isGalContact TODO(skennedy) We should look these up eventually */);
/*
* In certain situations, we may have two results for one address, where one of the
@@ -429,7 +430,8 @@ public class RecipientAlternatesAdapter extends CursorAdapter {
c.getLong(Queries.Query.CONTACT_ID),
c.getLong(Queries.Query.DATA_ID),
c.getString(Queries.Query.PHOTO_THUMBNAIL_URI),
- true);
+ true,
+ false /* isGalContact TODO(skennedy) We should look these up eventually */);
}
@Override
diff --git a/chips/src/com/android/ex/chips/RecipientEditTextView.java b/chips/src/com/android/ex/chips/RecipientEditTextView.java
index 6ee9986..0a1cdff 100644
--- a/chips/src/com/android/ex/chips/RecipientEditTextView.java
+++ b/chips/src/com/android/ex/chips/RecipientEditTextView.java
@@ -1987,7 +1987,8 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements
return constructChipSpan(
RecipientEntry.constructFakeEntry((String) text, isValid(text.toString())),
true, false);
- } else if (currentChip.getContactId() == RecipientEntry.GENERATED_CONTACT) {
+ } else if (currentChip.getContactId() == RecipientEntry.GENERATED_CONTACT
+ || currentChip.isGalContact()) {
int start = getChipStart(currentChip);
int end = getChipEnd(currentChip);
getSpannable().removeSpan(currentChip);
diff --git a/chips/src/com/android/ex/chips/RecipientEntry.java b/chips/src/com/android/ex/chips/RecipientEntry.java
index 44bc767..30fccae 100644
--- a/chips/src/com/android/ex/chips/RecipientEntry.java
+++ b/chips/src/com/android/ex/chips/RecipientEntry.java
@@ -74,9 +74,11 @@ public class RecipientEntry {
*/
private byte[] mPhotoBytes;
+ private final boolean mIsGalContact;
+
private RecipientEntry(int entryType, String displayName, String destination,
int destinationType, String destinationLabel, long contactId, long dataId,
- Uri photoThumbnailUri, boolean isFirstLevel, boolean isValid) {
+ Uri photoThumbnailUri, boolean isFirstLevel, boolean isValid, boolean isGalContact) {
mEntryType = entryType;
mIsFirstLevel = isFirstLevel;
mDisplayName = displayName;
@@ -89,6 +91,7 @@ public class RecipientEntry {
mPhotoBytes = null;
mIsDivider = false;
mIsValid = isValid;
+ mIsGalContact = isGalContact;
}
public boolean isValid() {
@@ -114,7 +117,7 @@ public class RecipientEntry {
return new RecipientEntry(ENTRY_TYPE_PERSON, tokenizedAddress, tokenizedAddress,
INVALID_DESTINATION_TYPE, null,
- INVALID_CONTACT, INVALID_CONTACT, null, true, isValid);
+ INVALID_CONTACT, INVALID_CONTACT, null, true, isValid, false /* isGalContact */);
}
/**
@@ -124,7 +127,7 @@ public class RecipientEntry {
final boolean isValid) {
return new RecipientEntry(ENTRY_TYPE_PERSON, phoneNumber, phoneNumber,
INVALID_DESTINATION_TYPE, null,
- INVALID_CONTACT, INVALID_CONTACT, null, true, isValid);
+ INVALID_CONTACT, INVALID_CONTACT, null, true, isValid, false /* isGalContact */);
}
/**
@@ -146,34 +149,35 @@ public class RecipientEntry {
public static RecipientEntry constructGeneratedEntry(String display, String address,
boolean isValid) {
return new RecipientEntry(ENTRY_TYPE_PERSON, display, address, INVALID_DESTINATION_TYPE,
- null, GENERATED_CONTACT, GENERATED_CONTACT, null, true, isValid);
+ null, GENERATED_CONTACT, GENERATED_CONTACT, null, true, isValid,
+ false /* isGalContact */);
}
public static RecipientEntry constructTopLevelEntry(String displayName, int displayNameSource,
String destination, int destinationType, String destinationLabel, long contactId,
- long dataId, Uri photoThumbnailUri, boolean isValid) {
+ long dataId, Uri photoThumbnailUri, boolean isValid, boolean isGalContact) {
return new RecipientEntry(ENTRY_TYPE_PERSON, pickDisplayName(displayNameSource,
displayName, destination), destination, destinationType, destinationLabel,
- contactId, dataId, photoThumbnailUri, true, isValid);
+ contactId, dataId, photoThumbnailUri, true, isValid, isGalContact);
}
public static RecipientEntry constructTopLevelEntry(String displayName, int displayNameSource,
String destination, int destinationType, String destinationLabel, long contactId,
- long dataId, String thumbnailUriAsString, boolean isValid) {
+ long dataId, String thumbnailUriAsString, boolean isValid, boolean isGalContact) {
return new RecipientEntry(ENTRY_TYPE_PERSON, pickDisplayName(displayNameSource,
displayName, destination), destination, destinationType, destinationLabel,
contactId, dataId, (thumbnailUriAsString != null ? Uri.parse(thumbnailUriAsString)
- : null), true, isValid);
+ : null), true, isValid, isGalContact);
}
public static RecipientEntry constructSecondLevelEntry(String displayName,
int displayNameSource, String destination, int destinationType,
String destinationLabel, long contactId, long dataId, String thumbnailUriAsString,
- boolean isValid) {
+ boolean isValid, boolean isGalContact) {
return new RecipientEntry(ENTRY_TYPE_PERSON, pickDisplayName(displayNameSource,
displayName, destination), destination, destinationType, destinationLabel,
contactId, dataId, (thumbnailUriAsString != null ? Uri.parse(thumbnailUriAsString)
- : null), false, isValid);
+ : null), false, isValid, isGalContact);
}
public int getEntryType() {
@@ -230,6 +234,10 @@ public class RecipientEntry {
return mEntryType == ENTRY_TYPE_PERSON;
}
+ public boolean isGalContact() {
+ return mIsGalContact;
+ }
+
@Override
public String toString() {
return mDisplayName + " <" + mDestination + ">, isValid=" + mIsValid;
diff --git a/chips/src/com/android/ex/chips/recipientchip/BaseRecipientChip.java b/chips/src/com/android/ex/chips/recipientchip/BaseRecipientChip.java
index a080ee7..032d3b2 100644
--- a/chips/src/com/android/ex/chips/recipientchip/BaseRecipientChip.java
+++ b/chips/src/com/android/ex/chips/recipientchip/BaseRecipientChip.java
@@ -70,4 +70,11 @@ interface BaseRecipientChip {
* before any reverse lookups.
*/
CharSequence getOriginalText();
+
+ /**
+ * Checks if this contact was retrieved from a GAL lookup.
+ *
+ * @return <code>true</code> if it came from GAL, <code>false</code> otherwise
+ */
+ boolean isGalContact();
}
diff --git a/chips/src/com/android/ex/chips/recipientchip/InvisibleRecipientChip.java b/chips/src/com/android/ex/chips/recipientchip/InvisibleRecipientChip.java
index 0380a81..11a66da 100644
--- a/chips/src/com/android/ex/chips/recipientchip/InvisibleRecipientChip.java
+++ b/chips/src/com/android/ex/chips/recipientchip/InvisibleRecipientChip.java
@@ -82,6 +82,11 @@ public class InvisibleRecipientChip extends ReplacementSpan implements DrawableR
}
@Override
+ public boolean isGalContact() {
+ return mDelegate.isGalContact();
+ }
+
+ @Override
public void draw(final Canvas canvas, final CharSequence text, final int start, final int end,
final float x, final int top, final int y, final int bottom, final Paint paint) {
// Do nothing.
diff --git a/chips/src/com/android/ex/chips/recipientchip/SimpleRecipientChip.java b/chips/src/com/android/ex/chips/recipientchip/SimpleRecipientChip.java
index c04b3be..ac8e897 100644
--- a/chips/src/com/android/ex/chips/recipientchip/SimpleRecipientChip.java
+++ b/chips/src/com/android/ex/chips/recipientchip/SimpleRecipientChip.java
@@ -93,6 +93,11 @@ class SimpleRecipientChip implements BaseRecipientChip {
}
@Override
+ public boolean isGalContact() {
+ return mEntry.isGalContact();
+ }
+
+ @Override
public String toString() {
return mDisplay + " <" + mValue + ">";
}
diff --git a/chips/src/com/android/ex/chips/recipientchip/VisibleRecipientChip.java b/chips/src/com/android/ex/chips/recipientchip/VisibleRecipientChip.java
index acade7f..4637f69 100644
--- a/chips/src/com/android/ex/chips/recipientchip/VisibleRecipientChip.java
+++ b/chips/src/com/android/ex/chips/recipientchip/VisibleRecipientChip.java
@@ -83,6 +83,11 @@ public class VisibleRecipientChip extends ImageSpan implements DrawableRecipient
}
@Override
+ public boolean isGalContact() {
+ return mDelegate.isGalContact();
+ }
+
+ @Override
public Rect getBounds() {
return getDrawable().getBounds();
}
diff --git a/chips/tests/src/com/android/ex/chips/RecipientAlternatesAdapterTest.java b/chips/tests/src/com/android/ex/chips/RecipientAlternatesAdapterTest.java
index a1a1c7a..d4c0460 100644
--- a/chips/tests/src/com/android/ex/chips/RecipientAlternatesAdapterTest.java
+++ b/chips/tests/src/com/android/ex/chips/RecipientAlternatesAdapterTest.java
@@ -120,7 +120,8 @@ public class RecipientAlternatesAdapterTest extends AndroidTestCase {
{
final RecipientEntry entry1 =
RecipientEntry.constructTopLevelEntry("Android", DisplayNameSources.NICKNAME,
- "1@android.com", 0, null, 0, 0, (Uri) null, true);
+ "1@android.com", 0, null, 0, 0, (Uri) null, true,
+ false /* isGalContact */);
final RecipientEntry entry2 = RecipientEntry.constructFakeEntry("1@android.com", true);
assertEquals(RecipientAlternatesAdapter.getBetterRecipient(entry1, entry2), entry1);
@@ -132,10 +133,12 @@ public class RecipientAlternatesAdapterTest extends AndroidTestCase {
{
final RecipientEntry entry1 =
RecipientEntry.constructTopLevelEntry("Android", DisplayNameSources.NICKNAME,
- "1@android.com", 0, null, 0, 0, (Uri) null, true);
+ "1@android.com", 0, null, 0, 0, (Uri) null, true,
+ false /* isGalContact */);
final RecipientEntry entry2 =
RecipientEntry.constructTopLevelEntry("2@android.com", DisplayNameSources.EMAIL,
- "2@android.com", 0, null, 0, 0, (Uri) null, true);
+ "2@android.com", 0, null, 0, 0, (Uri) null, true,
+ false /* isGalContact */);
assertEquals(RecipientAlternatesAdapter.getBetterRecipient(entry1, entry2), entry1);
assertEquals(RecipientAlternatesAdapter.getBetterRecipient(entry2, entry1), entry1);
@@ -146,10 +149,11 @@ public class RecipientAlternatesAdapterTest extends AndroidTestCase {
final RecipientEntry entry1 =
RecipientEntry.constructTopLevelEntry("Android", DisplayNameSources.NICKNAME,
"1@android.com", 0, null, 0, 0, Uri.parse("http://www.android.com"),
- true);
+ true, false /* isGalContact */);
final RecipientEntry entry2 =
RecipientEntry.constructTopLevelEntry("Android", DisplayNameSources.EMAIL,
- "2@android.com", 0, null, 0, 0, (Uri) null, true);
+ "2@android.com", 0, null, 0, 0, (Uri) null, true,
+ false /* isGalContact */);
assertEquals(RecipientAlternatesAdapter.getBetterRecipient(entry1, entry2), entry1);
assertEquals(RecipientAlternatesAdapter.getBetterRecipient(entry2, entry1), entry1);