summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TestCommon/src/com/android/contacts/common/test/mocks/MockContactPhotoManager.java20
-rwxr-xr-xres/drawable-hdpi/ic_contact_picture_sim.pngbin0 -> 1533 bytes
-rwxr-xr-xres/drawable-hdpi/ic_contact_picture_sim_1.pngbin0 -> 1447 bytes
-rwxr-xr-xres/drawable-hdpi/ic_contact_picture_sim_2.pngbin0 -> 1718 bytes
-rwxr-xr-xres/drawable-hdpi/ic_contact_picture_sim_business.pngbin0 -> 1690 bytes
-rwxr-xr-xres/drawable-hdpi/ic_contact_picture_sim_personal.pngbin0 -> 2010 bytes
-rwxr-xr-xres/drawable-hdpi/ic_contact_picture_sim_primary.pngbin0 -> 2288 bytes
-rwxr-xr-xres/drawable-mdpi/ic_contact_picture_sim.pngbin0 -> 1365 bytes
-rwxr-xr-xres/drawable-mdpi/ic_contact_picture_sim_1.pngbin0 -> 1260 bytes
-rwxr-xr-xres/drawable-mdpi/ic_contact_picture_sim_2.pngbin0 -> 1429 bytes
-rwxr-xr-xres/drawable-mdpi/ic_contact_picture_sim_business.pngbin0 -> 1400 bytes
-rwxr-xr-xres/drawable-mdpi/ic_contact_picture_sim_personal.pngbin0 -> 1559 bytes
-rwxr-xr-xres/drawable-mdpi/ic_contact_picture_sim_primary.pngbin0 -> 1690 bytes
-rwxr-xr-xres/drawable-xhdpi/ic_contact_picture_sim.pngbin0 -> 1734 bytes
-rwxr-xr-xres/drawable-xhdpi/ic_contact_picture_sim_1.pngbin0 -> 1566 bytes
-rwxr-xr-xres/drawable-xhdpi/ic_contact_picture_sim_2.pngbin0 -> 1871 bytes
-rwxr-xr-xres/drawable-xhdpi/ic_contact_picture_sim_business.pngbin0 -> 1961 bytes
-rwxr-xr-xres/drawable-xhdpi/ic_contact_picture_sim_personal.pngbin0 -> 2365 bytes
-rwxr-xr-xres/drawable-xhdpi/ic_contact_picture_sim_primary.pngbin0 -> 2834 bytes
-rw-r--r--src/com/android/contacts/common/ContactPhotoManager.java109
-rw-r--r--src/com/android/contacts/common/ContactTileLoaderFactory.java39
-rw-r--r--src/com/android/contacts/common/MoreContactUtils.java31
-rw-r--r--src/com/android/contacts/common/lettertiles/LetterTileDrawable.java50
-rw-r--r--src/com/android/contacts/common/list/ContactEntry.java2
-rw-r--r--src/com/android/contacts/common/list/ContactEntryListAdapter.java20
-rw-r--r--src/com/android/contacts/common/list/ContactListAdapter.java29
-rw-r--r--src/com/android/contacts/common/list/ContactTileAdapter.java15
-rw-r--r--src/com/android/contacts/common/list/ContactTileView.java6
-rw-r--r--src/com/android/contacts/common/list/DefaultContactListAdapter.java3
-rw-r--r--src/com/android/contacts/common/list/PhoneNumberListAdapter.java22
-rw-r--r--src/com/android/contacts/common/list/ShortcutIntentBuilder.java52
31 files changed, 316 insertions, 82 deletions
diff --git a/TestCommon/src/com/android/contacts/common/test/mocks/MockContactPhotoManager.java b/TestCommon/src/com/android/contacts/common/test/mocks/MockContactPhotoManager.java
index db8f06f2..3b143deb 100644
--- a/TestCommon/src/com/android/contacts/common/test/mocks/MockContactPhotoManager.java
+++ b/TestCommon/src/com/android/contacts/common/test/mocks/MockContactPhotoManager.java
@@ -16,6 +16,7 @@
package com.android.contacts.common.test.mocks;
+import android.accounts.Account;
import android.graphics.Bitmap;
import android.net.Uri;
import android.view.View;
@@ -29,16 +30,19 @@ import com.android.contacts.common.ContactPhotoManager;
*/
public class MockContactPhotoManager extends ContactPhotoManager {
@Override
- public void loadThumbnail(ImageView view, long photoId, boolean darkTheme, boolean isCircular,
- DefaultImageRequest defaultImageRequest, DefaultImageProvider defaultProvider) {
- defaultProvider.applyDefaultImage(view, -1, darkTheme, null);
+ public void loadThumbnail(ImageView view, long photoId, Account account,
+ boolean darkTheme, boolean isCircular,
+ DefaultImageRequest defaultImageRequest,
+ DefaultImageProvider defaultProvider) {
+ defaultProvider.applyDefaultImage(view, account, -1, darkTheme, null);
}
@Override
- public void loadPhoto(ImageView view, Uri photoUri, int requestedExtent, boolean darkTheme,
- boolean isCircular, DefaultImageRequest defaultImageRequest,
+ public void loadPhoto(ImageView view, Uri photoUri, Account account,
+ int requestedExtent, boolean darkTheme, boolean isCircular,
+ DefaultImageRequest defaultImageRequest,
DefaultImageProvider defaultProvider) {
- defaultProvider.applyDefaultImage(view, requestedExtent, darkTheme, null);
+ defaultProvider.applyDefaultImage(view, account, requestedExtent, darkTheme, null);
}
@Override
@@ -69,4 +73,8 @@ public class MockContactPhotoManager extends ContactPhotoManager {
@Override
public void preloadPhotosInBackground() {
}
+
+ @Override
+ public void clear() {
+ }
}
diff --git a/res/drawable-hdpi/ic_contact_picture_sim.png b/res/drawable-hdpi/ic_contact_picture_sim.png
new file mode 100755
index 00000000..7b6cc26f
--- /dev/null
+++ b/res/drawable-hdpi/ic_contact_picture_sim.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_contact_picture_sim_1.png b/res/drawable-hdpi/ic_contact_picture_sim_1.png
new file mode 100755
index 00000000..ec2ebcb5
--- /dev/null
+++ b/res/drawable-hdpi/ic_contact_picture_sim_1.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_contact_picture_sim_2.png b/res/drawable-hdpi/ic_contact_picture_sim_2.png
new file mode 100755
index 00000000..3b68c682
--- /dev/null
+++ b/res/drawable-hdpi/ic_contact_picture_sim_2.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_contact_picture_sim_business.png b/res/drawable-hdpi/ic_contact_picture_sim_business.png
new file mode 100755
index 00000000..4df1ecd5
--- /dev/null
+++ b/res/drawable-hdpi/ic_contact_picture_sim_business.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_contact_picture_sim_personal.png b/res/drawable-hdpi/ic_contact_picture_sim_personal.png
new file mode 100755
index 00000000..44f4b930
--- /dev/null
+++ b/res/drawable-hdpi/ic_contact_picture_sim_personal.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_contact_picture_sim_primary.png b/res/drawable-hdpi/ic_contact_picture_sim_primary.png
new file mode 100755
index 00000000..a5bf9214
--- /dev/null
+++ b/res/drawable-hdpi/ic_contact_picture_sim_primary.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_contact_picture_sim.png b/res/drawable-mdpi/ic_contact_picture_sim.png
new file mode 100755
index 00000000..dd63d11d
--- /dev/null
+++ b/res/drawable-mdpi/ic_contact_picture_sim.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_contact_picture_sim_1.png b/res/drawable-mdpi/ic_contact_picture_sim_1.png
new file mode 100755
index 00000000..4793a07e
--- /dev/null
+++ b/res/drawable-mdpi/ic_contact_picture_sim_1.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_contact_picture_sim_2.png b/res/drawable-mdpi/ic_contact_picture_sim_2.png
new file mode 100755
index 00000000..665a6714
--- /dev/null
+++ b/res/drawable-mdpi/ic_contact_picture_sim_2.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_contact_picture_sim_business.png b/res/drawable-mdpi/ic_contact_picture_sim_business.png
new file mode 100755
index 00000000..c266e266
--- /dev/null
+++ b/res/drawable-mdpi/ic_contact_picture_sim_business.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_contact_picture_sim_personal.png b/res/drawable-mdpi/ic_contact_picture_sim_personal.png
new file mode 100755
index 00000000..f1e75966
--- /dev/null
+++ b/res/drawable-mdpi/ic_contact_picture_sim_personal.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_contact_picture_sim_primary.png b/res/drawable-mdpi/ic_contact_picture_sim_primary.png
new file mode 100755
index 00000000..493067a9
--- /dev/null
+++ b/res/drawable-mdpi/ic_contact_picture_sim_primary.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_contact_picture_sim.png b/res/drawable-xhdpi/ic_contact_picture_sim.png
new file mode 100755
index 00000000..a39b7df0
--- /dev/null
+++ b/res/drawable-xhdpi/ic_contact_picture_sim.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_contact_picture_sim_1.png b/res/drawable-xhdpi/ic_contact_picture_sim_1.png
new file mode 100755
index 00000000..300c0288
--- /dev/null
+++ b/res/drawable-xhdpi/ic_contact_picture_sim_1.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_contact_picture_sim_2.png b/res/drawable-xhdpi/ic_contact_picture_sim_2.png
new file mode 100755
index 00000000..c7ce4223
--- /dev/null
+++ b/res/drawable-xhdpi/ic_contact_picture_sim_2.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_contact_picture_sim_business.png b/res/drawable-xhdpi/ic_contact_picture_sim_business.png
new file mode 100755
index 00000000..abf631f9
--- /dev/null
+++ b/res/drawable-xhdpi/ic_contact_picture_sim_business.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_contact_picture_sim_personal.png b/res/drawable-xhdpi/ic_contact_picture_sim_personal.png
new file mode 100755
index 00000000..e5f0cf0a
--- /dev/null
+++ b/res/drawable-xhdpi/ic_contact_picture_sim_personal.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_contact_picture_sim_primary.png b/res/drawable-xhdpi/ic_contact_picture_sim_primary.png
new file mode 100755
index 00000000..543d6a7a
--- /dev/null
+++ b/res/drawable-xhdpi/ic_contact_picture_sim_primary.png
Binary files differ
diff --git a/src/com/android/contacts/common/ContactPhotoManager.java b/src/com/android/contacts/common/ContactPhotoManager.java
index deaf40e0..c4cde8bb 100644
--- a/src/com/android/contacts/common/ContactPhotoManager.java
+++ b/src/com/android/contacts/common/ContactPhotoManager.java
@@ -16,6 +16,7 @@
package com.android.contacts.common;
+import android.accounts.Account;
import android.app.ActivityManager;
import android.content.ComponentCallbacks2;
import android.content.ContentResolver;
@@ -122,17 +123,23 @@ public abstract class ContactPhotoManager implements ComponentCallbacks2 {
*/
public static Drawable getDefaultAvatarDrawableForContact(Resources resources, boolean hires,
DefaultImageRequest defaultImageRequest) {
+ return getDefaultAvatarDrawableForContact(null, resources, hires,
+ defaultImageRequest, null);
+ }
+
+ public static Drawable getDefaultAvatarDrawableForContact(Context context, Resources resources,
+ boolean hires, DefaultImageRequest defaultImageRequest, Account account) {
if (defaultImageRequest == null) {
if (sDefaultLetterAvatar == null) {
// Cache and return the letter tile drawable that is created by a null request,
// so that it doesn't have to be recreated every time it is requested again.
sDefaultLetterAvatar = LetterTileDefaultImageProvider.getDefaultImageForContact(
- resources, null);
+ context, resources, null, account);
}
return sDefaultLetterAvatar;
}
- return LetterTileDefaultImageProvider.getDefaultImageForContact(resources,
- defaultImageRequest);
+ return LetterTileDefaultImageProvider.getDefaultImageForContact(context, resources,
+ defaultImageRequest, account);
}
/**
@@ -374,6 +381,10 @@ public abstract class ContactPhotoManager implements ComponentCallbacks2 {
*/
public abstract void applyDefaultImage(ImageView view, int extent, boolean darkTheme,
DefaultImageRequest defaultImageRequest);
+
+ public void applyDefaultImage(ImageView view, Account account, int extent,
+ boolean darkTheme, DefaultImageRequest defaultImageRequest) {
+ }
}
/**
@@ -385,14 +396,21 @@ public abstract class ContactPhotoManager implements ComponentCallbacks2 {
@Override
public void applyDefaultImage(ImageView view, int extent, boolean darkTheme,
DefaultImageRequest defaultImageRequest) {
- final Drawable drawable = getDefaultImageForContact(view.getResources(),
- defaultImageRequest);
+ applyDefaultImage(view, null, extent, darkTheme, defaultImageRequest);
+ }
+
+ @Override
+ public void applyDefaultImage(ImageView view, Account account, int extent,
+ boolean darkTheme, DefaultImageRequest defaultImageRequest) {
+ final Drawable drawable = getDefaultImageForContact(view.getContext(),
+ view.getResources(), defaultImageRequest, account);
view.setImageDrawable(drawable);
}
- public static Drawable getDefaultImageForContact(Resources resources,
- DefaultImageRequest defaultImageRequest) {
- final LetterTileDrawable drawable = new LetterTileDrawable(resources);
+ public static Drawable getDefaultImageForContact(Context context, Resources resources,
+ DefaultImageRequest defaultImageRequest, Account account) {
+ final LetterTileDrawable drawable = new LetterTileDrawable(
+ context, resources, account);
if (defaultImageRequest != null) {
// If the contact identifier is null or empty, fallback to the
// displayName. In that case, use {@code null} for the contact's
@@ -448,6 +466,8 @@ public abstract class ContactPhotoManager implements ComponentCallbacks2 {
return new ContactPhotoManagerImpl(context);
}
+ public abstract void clear();
+
@VisibleForTesting
public static void injectContactPhotoManagerForTesting(ContactPhotoManager photoManager) {
sInstance = photoManager;
@@ -458,19 +478,32 @@ public abstract class ContactPhotoManager implements ComponentCallbacks2 {
* it is displayed immediately. Otherwise a request is sent to load the photo
* from the database.
*/
- public abstract void loadThumbnail(ImageView view, long photoId, boolean darkTheme,
- boolean isCircular, DefaultImageRequest defaultImageRequest,
+ public abstract void loadThumbnail(ImageView view, long photoId, Account account,
+ boolean darkTheme, boolean isCircular, DefaultImageRequest defaultImageRequest,
DefaultImageProvider defaultProvider);
/**
* Calls {@link #loadThumbnail(ImageView, long, boolean, DefaultImageRequest,
* DefaultImageProvider)} using the {@link DefaultImageProvider} {@link #DEFAULT_AVATAR}.
*/
+ public final void loadThumbnail(ImageView view, long photoId, Account account,
+ boolean darkTheme, boolean isCircular, DefaultImageRequest defaultImageRequest) {
+ loadThumbnail(view, photoId, account, darkTheme, isCircular,
+ defaultImageRequest, DEFAULT_AVATAR);
+ }
+
public final void loadThumbnail(ImageView view, long photoId, boolean darkTheme,
boolean isCircular, DefaultImageRequest defaultImageRequest) {
- loadThumbnail(view, photoId, darkTheme, isCircular, defaultImageRequest, DEFAULT_AVATAR);
+ loadThumbnail(view, photoId, null, darkTheme, isCircular,
+ defaultImageRequest, DEFAULT_AVATAR);
}
+ public final void loadThumbnail(ImageView view, long photoId, boolean darkTheme,
+ boolean isCircular, DefaultImageRequest defaultImageRequest,
+ DefaultImageProvider defaultProvider) {
+ loadThumbnail(view, photoId, null, darkTheme, isCircular,
+ defaultImageRequest, defaultProvider);
+ }
/**
* Load photo into the supplied image view. If the photo is already cached,
@@ -489,8 +522,9 @@ public abstract class ContactPhotoManager implements ComponentCallbacks2 {
* @param defaultProvider The provider of default avatars (this is used if photoUri doesn't
* refer to an existing image)
*/
- public abstract void loadPhoto(ImageView view, Uri photoUri, int requestedExtent,
- boolean darkTheme, boolean isCircular, DefaultImageRequest defaultImageRequest,
+ public abstract void loadPhoto(ImageView view, Uri photoUri,
+ Account account, int requestedExtent, boolean darkTheme,
+ boolean isCircular, DefaultImageRequest defaultImageRequest,
DefaultImageProvider defaultProvider);
/**
@@ -501,12 +535,25 @@ public abstract class ContactPhotoManager implements ComponentCallbacks2 {
* @param defaultImageRequest {@link DefaultImageRequest} object that specifies how a default
* letter tile avatar should be drawn.
*/
+ public final void loadPhoto(ImageView view, Uri photoUri, Account account, int requestedExtent,
+ boolean darkTheme, boolean isCircular, DefaultImageRequest defaultImageRequest) {
+ loadPhoto(view, photoUri, account, requestedExtent, darkTheme, isCircular,
+ defaultImageRequest, DEFAULT_AVATAR);
+ }
+
public final void loadPhoto(ImageView view, Uri photoUri, int requestedExtent,
boolean darkTheme, boolean isCircular, DefaultImageRequest defaultImageRequest) {
- loadPhoto(view, photoUri, requestedExtent, darkTheme, isCircular,
+ loadPhoto(view, photoUri, null, requestedExtent, darkTheme, isCircular,
defaultImageRequest, DEFAULT_AVATAR);
}
+ public final void loadPhoto(ImageView view, Uri photoUri, int requestedExtent,
+ boolean darkTheme, boolean isCircular, DefaultImageRequest defaultImageRequest,
+ DefaultImageProvider defaultProvider) {
+ loadPhoto(view, photoUri, null, requestedExtent, darkTheme, isCircular,
+ defaultImageRequest, defaultProvider);
+ }
+
/**
* Calls {@link #loadPhoto(ImageView, Uri, boolean, boolean, DefaultImageRequest,
* DefaultImageProvider)} with {@link #DEFAULT_AVATAR} and with the assumption, that
@@ -515,9 +562,17 @@ public abstract class ContactPhotoManager implements ComponentCallbacks2 {
* @param defaultImageRequest {@link DefaultImageRequest} object that specifies how a default
* letter tile avatar should be drawn.
*/
+ public final void loadDirectoryPhoto(ImageView view, Uri photoUri,
+ Account account, boolean darkTheme, boolean isCircular,
+ DefaultImageRequest defaultImageRequest) {
+ loadPhoto(view, photoUri, account, -1, darkTheme, isCircular,
+ defaultImageRequest, DEFAULT_AVATAR);
+ }
+
public final void loadDirectoryPhoto(ImageView view, Uri photoUri, boolean darkTheme,
boolean isCircular, DefaultImageRequest defaultImageRequest) {
- loadPhoto(view, photoUri, -1, darkTheme, isCircular, defaultImageRequest, DEFAULT_AVATAR);
+ loadPhoto(view, photoUri, null, -1, darkTheme, isCircular,
+ defaultImageRequest, DEFAULT_AVATAR);
}
/**
@@ -819,11 +874,12 @@ class ContactPhotoManagerImpl extends ContactPhotoManager implements Callback {
}
@Override
- public void loadThumbnail(ImageView view, long photoId, boolean darkTheme, boolean isCircular,
- DefaultImageRequest defaultImageRequest, DefaultImageProvider defaultProvider) {
+ public void loadThumbnail(ImageView view, long photoId, Account account,
+ boolean darkTheme, boolean isCircular, DefaultImageRequest defaultImageRequest,
+ DefaultImageProvider defaultProvider) {
if (photoId == 0) {
// No photo is needed
- defaultProvider.applyDefaultImage(view, -1, darkTheme, defaultImageRequest);
+ defaultProvider.applyDefaultImage(view, account, -1, darkTheme, defaultImageRequest);
mPendingRequests.remove(view);
} else {
if (DEBUG) Log.d(TAG, "loadPhoto request: " + photoId);
@@ -833,19 +889,19 @@ class ContactPhotoManagerImpl extends ContactPhotoManager implements Callback {
}
@Override
- public void loadPhoto(ImageView view, Uri photoUri, int requestedExtent, boolean darkTheme,
- boolean isCircular, DefaultImageRequest defaultImageRequest,
+ public void loadPhoto(ImageView view, Uri photoUri, Account account, int requestedExtent,
+ boolean darkTheme, boolean isCircular, DefaultImageRequest defaultImageRequest,
DefaultImageProvider defaultProvider) {
if (photoUri == null) {
// No photo is needed
- defaultProvider.applyDefaultImage(view, requestedExtent, darkTheme,
+ defaultProvider.applyDefaultImage(view, account, requestedExtent, darkTheme,
defaultImageRequest);
mPendingRequests.remove(view);
} else {
if (DEBUG) Log.d(TAG, "loadPhoto request: " + photoUri);
if (isDefaultImageUri(photoUri)) {
- createAndApplyDefaultImageForUri(view, photoUri, requestedExtent, darkTheme,
- isCircular, defaultProvider);
+ createAndApplyDefaultImageForUri(view, account, photoUri, requestedExtent,
+ darkTheme, isCircular, defaultProvider);
} else {
loadPhotoByIdOrUri(view, Request.createFromUri(photoUri, requestedExtent,
darkTheme, isCircular, defaultProvider));
@@ -853,11 +909,12 @@ class ContactPhotoManagerImpl extends ContactPhotoManager implements Callback {
}
}
- private void createAndApplyDefaultImageForUri(ImageView view, Uri uri, int requestedExtent,
- boolean darkTheme, boolean isCircular, DefaultImageProvider defaultProvider) {
+ private void createAndApplyDefaultImageForUri(ImageView view,
+ Account account, Uri uri, int requestedExtent, boolean darkTheme,
+ boolean isCircular, DefaultImageProvider defaultProvider) {
DefaultImageRequest request = getDefaultImageRequestFromUri(uri);
request.isCircular = isCircular;
- defaultProvider.applyDefaultImage(view, requestedExtent, darkTheme, request);
+ defaultProvider.applyDefaultImage(view, account, requestedExtent, darkTheme, request);
}
private void loadPhotoByIdOrUri(ImageView view, Request request) {
diff --git a/src/com/android/contacts/common/ContactTileLoaderFactory.java b/src/com/android/contacts/common/ContactTileLoaderFactory.java
index 4377d057..33d4ea68 100644
--- a/src/com/android/contacts/common/ContactTileLoaderFactory.java
+++ b/src/com/android/contacts/common/ContactTileLoaderFactory.java
@@ -37,19 +37,22 @@ public final class ContactTileLoaderFactory {
public final static int STARRED = 2;
public final static int PHOTO_URI = 3;
public final static int LOOKUP_KEY = 4;
- public final static int CONTACT_PRESENCE = 5;
- public final static int CONTACT_STATUS = 6;
+ public final static int ACCOUNT_TYPE = 5;
+ public final static int ACCOUNT_NAME = 6;
+
+ public final static int CONTACT_PRESENCE = 7;
+ public final static int CONTACT_STATUS = 8;
// Only used for StrequentPhoneOnlyLoader
- public final static int PHONE_NUMBER = 5;
- public final static int PHONE_NUMBER_TYPE = 6;
- public final static int PHONE_NUMBER_LABEL = 7;
- public final static int IS_DEFAULT_NUMBER = 8;
- public final static int PINNED = 9;
+ public final static int PHONE_NUMBER = 7;
+ public final static int PHONE_NUMBER_TYPE = 8;
+ public final static int PHONE_NUMBER_LABEL = 9;
+ public final static int IS_DEFAULT_NUMBER = 10;
+ public final static int PINNED = 11;
// The _ID field returned for strequent items actually contains data._id instead of
// contacts._id because the query is performed on the data table. In order to obtain the
// contact id for strequent items, we thus have to use Phone.contact_id instead.
- public final static int CONTACT_ID_FOR_DATA = 10;
+ public final static int CONTACT_ID_FOR_DATA = 12;
private static final String[] COLUMNS = new String[] {
Contacts._ID, // ..........................................0
@@ -57,8 +60,10 @@ public final class ContactTileLoaderFactory {
Contacts.STARRED, // ......................................2
Contacts.PHOTO_URI, // ....................................3
Contacts.LOOKUP_KEY, // ...................................4
- Contacts.CONTACT_PRESENCE, // .............................5
- Contacts.CONTACT_STATUS, // ...............................6
+ RawContacts.ACCOUNT_TYPE, // 5
+ RawContacts.ACCOUNT_NAME, // 6
+ Contacts.CONTACT_PRESENCE, // .............................7
+ Contacts.CONTACT_STATUS, // ...............................8
};
/**
@@ -74,12 +79,14 @@ public final class ContactTileLoaderFactory {
Contacts.STARRED, // ......................................2
Contacts.PHOTO_URI, // ....................................3
Contacts.LOOKUP_KEY, // ...................................4
- Phone.NUMBER, // ..........................................5
- Phone.TYPE, // ............................................6
- Phone.LABEL, // ...........................................7
- Phone.IS_SUPER_PRIMARY, //.................................8
- Contacts.PINNED, // .......................................9
- Phone.CONTACT_ID //........................................10
+ RawContacts.ACCOUNT_TYPE, // 5
+ RawContacts.ACCOUNT_NAME, // 6
+ Phone.NUMBER, // ..........................................7
+ Phone.TYPE, // ............................................8
+ Phone.LABEL, // ............................................9
+ Phone.IS_SUPER_PRIMARY, //.................................10
+ Contacts.PINNED, // .......................................11
+ Phone.CONTACT_ID //........................................12
};
private static final String STARRED_ORDER = Contacts.DISPLAY_NAME+" COLLATE NOCASE ASC";
diff --git a/src/com/android/contacts/common/MoreContactUtils.java b/src/com/android/contacts/common/MoreContactUtils.java
index e0cd9cf8..9d7965f0 100644
--- a/src/com/android/contacts/common/MoreContactUtils.java
+++ b/src/com/android/contacts/common/MoreContactUtils.java
@@ -90,8 +90,16 @@ public class MoreContactUtils {
public static final String[] MULTI_SIM_NAME = { "perferred_name_sub1",
"perferred_name_sub2" };
+ public static final String PREFERRED_SIM_ICON_INDEX = "preferred_sim_icon_index";
public static final String[] IPCALL_PREFIX = { "ipcall_prefix1",
"ipcall_prefix2" };
+ public final static int[] IC_SIM_PICTURE = {
+ R.drawable.ic_contact_picture_sim_1,
+ R.drawable.ic_contact_picture_sim_2,
+ R.drawable.ic_contact_picture_sim_personal,
+ R.drawable.ic_contact_picture_sim_business,
+ R.drawable.ic_contact_picture_sim_primary
+ };
/**
* Returns true if two data with mimetypes which represent values in contact entries are
* considered equal for collapsing in the GUI. For caller-id, use
@@ -730,6 +738,29 @@ public class MoreContactUtils {
}
/**
+ * Get SIM card icon index by subscription
+ */
+ public static int getCurrentSimIconIndex(Context context, int subscription) {
+ if (context == null || subscription < PhoneConstants.SUB1
+ || subscription >= TelephonyManager.getDefault().getPhoneCount()) {
+ return -1;
+ }
+
+ String simIconIndex = Settings.System.getString(context.getContentResolver(),
+ PREFERRED_SIM_ICON_INDEX);
+ if (TextUtils.isEmpty(simIconIndex)) {
+ return subscription;
+ } else {
+ String[] indexs = simIconIndex.split(",");
+ if (subscription >= indexs.length) {
+ return -1;
+ }
+ return Integer.parseInt(indexs[subscription]);
+ }
+ }
+
+
+ /**
* Display IP call setting dialog
*/
public static void showNoIPNumberDialog(final Context mContext, final int subscription) {
diff --git a/src/com/android/contacts/common/lettertiles/LetterTileDrawable.java b/src/com/android/contacts/common/lettertiles/LetterTileDrawable.java
index e62d4218..14548deb 100644
--- a/src/com/android/contacts/common/lettertiles/LetterTileDrawable.java
+++ b/src/com/android/contacts/common/lettertiles/LetterTileDrawable.java
@@ -16,6 +16,8 @@
package com.android.contacts.common.lettertiles;
+import android.accounts.Account;
+import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
@@ -28,8 +30,11 @@ import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
+import android.telephony.TelephonyManager;
import android.util.Log;
+import com.android.contacts.common.MoreContactUtils;
+import com.android.contacts.common.model.account.SimAccountType;
import com.android.contacts.common.R;
import com.android.contacts.common.util.BitmapUtil;
@@ -53,6 +58,9 @@ public class LetterTileDrawable extends Drawable {
private static Bitmap DEFAULT_PERSON_AVATAR;
private static Bitmap DEFAULT_BUSINESS_AVATAR;
private static Bitmap DEFAULT_VOICEMAIL_AVATAR;
+ private static Bitmap DEFAULT_SIM_PERSON_AVATAR;
+ private static Bitmap[] DEFAULT_CUSTOMIZE_SIM_PERSON_AVATAR =
+ new Bitmap[MoreContactUtils.IC_SIM_PICTURE.length];
/** Reusable components to avoid new allocations */
private static final Paint sPaint = new Paint();
@@ -70,12 +78,18 @@ public class LetterTileDrawable extends Drawable {
private int mContactType = TYPE_DEFAULT;
private float mScale = 1.0f;
private float mOffset = 0.0f;
+ private Account mAccount;
+ private Context mContext;
private boolean mIsCircle = false;
- public LetterTileDrawable(final Resources res) {
+
+ public LetterTileDrawable(final Context context, final Resources res,
+ final Account account) {
mPaint = new Paint();
mPaint.setFilterBitmap(true);
mPaint.setDither(true);
+ mAccount = account;
+ mContext = context;
if (sColors == null) {
sColors = res.obtainTypedArray(R.array.letter_tile_colors);
@@ -88,6 +102,13 @@ public class LetterTileDrawable extends Drawable {
R.drawable.ic_business_white_120dp);
DEFAULT_VOICEMAIL_AVATAR = BitmapFactory.decodeResource(res,
R.drawable.ic_voicemail_avatar);
+ DEFAULT_SIM_PERSON_AVATAR = BitmapFactory.decodeResource(res,
+ R.drawable.ic_contact_picture_sim);
+ for (int i = 0; i < MoreContactUtils.IC_SIM_PICTURE.length; i++) {
+ DEFAULT_CUSTOMIZE_SIM_PERSON_AVATAR[i] = BitmapFactory
+ .decodeResource(res, MoreContactUtils.IC_SIM_PICTURE[i]);
+ }
+
sPaint.setTypeface(Typeface.create(
res.getString(R.string.letter_tile_letter_font_family), Typeface.NORMAL));
sPaint.setTextAlign(Align.CENTER);
@@ -143,7 +164,10 @@ public class LetterTileDrawable extends Drawable {
}
// Draw letter/digit only if the first character is an english letter
- if (mDisplayName != null && isEnglishLetter(mDisplayName.charAt(0))) {
+ if (mDisplayName != null
+ && isEnglishLetter(mDisplayName.charAt(0))
+ && (mAccount == null || (mAccount != null && !mAccount.type
+ .equals(SimAccountType.ACCOUNT_TYPE)))) {
// Draw letter or digit.
sFirstChar[0] = Character.toUpperCase(mDisplayName.charAt(0));
@@ -160,9 +184,9 @@ public class LetterTileDrawable extends Drawable {
sPaint);
} else {
// Draw the default image if there is no letter/digit to be drawn
- final Bitmap bitmap = getBitmapForContactType(mContactType);
- drawBitmap(bitmap, bitmap.getWidth(), bitmap.getHeight(),
- canvas);
+ final Bitmap bitmap = getBitmapForContactType(mContactType,
+ mAccount, mContext);
+ drawBitmap(bitmap, bitmap.getWidth(), bitmap.getHeight(), canvas);
}
}
@@ -184,7 +208,21 @@ public class LetterTileDrawable extends Drawable {
return sColors.getColor(color, sDefaultColor);
}
- private static Bitmap getBitmapForContactType(int contactType) {
+ private static Bitmap getBitmapForContactType(int contactType,
+ Account account, Context context) {
+ if (account != null && SimAccountType.ACCOUNT_TYPE.equals(account.type)) {
+ if (TelephonyManager.getDefault().isMultiSimEnabled()) {
+ final int sub = MoreContactUtils.getSubscription(
+ SimAccountType.ACCOUNT_TYPE, account.name);
+ int index = MoreContactUtils.getCurrentSimIconIndex(context, sub);
+ if (index < 0) {
+ return DEFAULT_PERSON_AVATAR;
+ }
+ return DEFAULT_CUSTOMIZE_SIM_PERSON_AVATAR[index];
+ } else {
+ return DEFAULT_SIM_PERSON_AVATAR;
+ }
+ }
switch (contactType) {
case TYPE_PERSON:
return DEFAULT_PERSON_AVATAR;
diff --git a/src/com/android/contacts/common/list/ContactEntry.java b/src/com/android/contacts/common/list/ContactEntry.java
index 43fc19dd..66ae50d1 100644
--- a/src/com/android/contacts/common/list/ContactEntry.java
+++ b/src/com/android/contacts/common/list/ContactEntry.java
@@ -16,6 +16,7 @@
package com.android.contacts.common.list;
+import android.accounts.Account;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.provider.ContactsContract.PinnedPositions;
@@ -36,6 +37,7 @@ public class ContactEntry {
public int pinned = PinnedPositions.UNPINNED;
public boolean isFavorite = false;
public boolean isDefaultNumber = false;
+ public Account account;
public static final ContactEntry BLANK_ENTRY = new ContactEntry();
} \ No newline at end of file
diff --git a/src/com/android/contacts/common/list/ContactEntryListAdapter.java b/src/com/android/contacts/common/list/ContactEntryListAdapter.java
index 8500d816..63b5381d 100644
--- a/src/com/android/contacts/common/list/ContactEntryListAdapter.java
+++ b/src/com/android/contacts/common/list/ContactEntryListAdapter.java
@@ -15,6 +15,7 @@
*/
package com.android.contacts.common.list;
+import android.accounts.Account;
import android.content.Context;
import android.content.CursorLoader;
import android.content.res.Resources;
@@ -711,15 +712,24 @@ public abstract class ContactEntryListAdapter extends IndexerListAdapter {
* @param contactIdColumn Index of the contact id column
* @param lookUpKeyColumn Index of the lookup key column
* @param displayNameColumn Index of the display name column
+ * @param accountTypeColume Index of the account type column
+ * @param accountNameColume Index of the account name column
*/
protected void bindQuickContact(final ContactListItemView view, int partitionIndex,
Cursor cursor, int photoIdColumn, int photoUriColumn, int contactIdColumn,
- int lookUpKeyColumn, int displayNameColumn) {
+ int lookUpKeyColumn,int displayNameColumn, int accountTypeColume,
+ int accountNameColume) {
long photoId = 0;
if (!cursor.isNull(photoIdColumn)) {
photoId = cursor.getLong(photoIdColumn);
}
+ Account account = null;
+ if (!cursor.isNull(accountTypeColume) && !cursor.isNull(accountNameColume)) {
+ final String accountType = cursor.getString(accountTypeColume);
+ final String accountName = cursor.getString(accountNameColume);
+ account = new Account(accountName, accountType);
+ }
QuickContactBadge quickContact = view.getQuickContact();
quickContact.assignContactUri(
getContactUri(partitionIndex, cursor, contactIdColumn, lookUpKeyColumn));
@@ -729,8 +739,8 @@ public abstract class ContactEntryListAdapter extends IndexerListAdapter {
quickContact.setPrioritizedMimeType(Phone.CONTENT_ITEM_TYPE);
if (photoId != 0 || photoUriColumn == -1) {
- getPhotoLoader().loadThumbnail(quickContact, photoId, mDarkTheme, mCircularPhotos,
- null);
+ getPhotoLoader().loadThumbnail(quickContact, photoId, account,
+ mDarkTheme, mCircularPhotos, null);
} else {
final String photoUriString = cursor.getString(photoUriColumn);
final Uri photoUri = photoUriString == null ? null : Uri.parse(photoUriString);
@@ -739,8 +749,8 @@ public abstract class ContactEntryListAdapter extends IndexerListAdapter {
request = getDefaultImageRequestFromCursor(cursor, displayNameColumn,
lookUpKeyColumn);
}
- getPhotoLoader().loadPhoto(quickContact, photoUri, -1, mDarkTheme, mCircularPhotos,
- request);
+ getPhotoLoader().loadPhoto(quickContact, photoUri, account, -1,
+ mDarkTheme, mCircularPhotos, request);
}
}
diff --git a/src/com/android/contacts/common/list/ContactListAdapter.java b/src/com/android/contacts/common/list/ContactListAdapter.java
index 600d731a..4c91f3fb 100644
--- a/src/com/android/contacts/common/list/ContactListAdapter.java
+++ b/src/com/android/contacts/common/list/ContactListAdapter.java
@@ -15,12 +15,14 @@
*/
package com.android.contacts.common.list;
+import android.accounts.Account;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Directory;
+import android.provider.ContactsContract.RawContacts;
import android.provider.ContactsContract.SearchSnippets;
import android.text.TextUtils;
import android.view.View;
@@ -49,6 +51,8 @@ public abstract class ContactListAdapter extends ContactEntryListAdapter {
Contacts.PHOTO_THUMBNAIL_URI, // 5
Contacts.LOOKUP_KEY, // 6
Contacts.IS_USER_PROFILE, // 7
+ RawContacts.ACCOUNT_TYPE, // 8
+ RawContacts.ACCOUNT_NAME, // 9
};
private static final String[] CONTACT_PROJECTION_ALTERNATIVE = new String[] {
@@ -60,6 +64,8 @@ public abstract class ContactListAdapter extends ContactEntryListAdapter {
Contacts.PHOTO_THUMBNAIL_URI, // 5
Contacts.LOOKUP_KEY, // 6
Contacts.IS_USER_PROFILE, // 7
+ RawContacts.ACCOUNT_TYPE, // 8
+ RawContacts.ACCOUNT_NAME, // 9
};
private static final String[] FILTER_PROJECTION_PRIMARY = new String[] {
@@ -71,7 +77,9 @@ public abstract class ContactListAdapter extends ContactEntryListAdapter {
Contacts.PHOTO_THUMBNAIL_URI, // 5
Contacts.LOOKUP_KEY, // 6
Contacts.IS_USER_PROFILE, // 7
- SearchSnippets.SNIPPET, // 8
+ RawContacts.ACCOUNT_TYPE, // 8
+ RawContacts.ACCOUNT_NAME, // 9
+ SearchSnippets.SNIPPET, // 10
};
private static final String[] FILTER_PROJECTION_ALTERNATIVE = new String[] {
@@ -83,7 +91,9 @@ public abstract class ContactListAdapter extends ContactEntryListAdapter {
Contacts.PHOTO_THUMBNAIL_URI, // 5
Contacts.LOOKUP_KEY, // 6
Contacts.IS_USER_PROFILE, // 7
- SearchSnippets.SNIPPET, // 8
+ RawContacts.ACCOUNT_TYPE, // 8
+ RawContacts.ACCOUNT_NAME, // 9
+ SearchSnippets.SNIPPET, // 10
};
public static final int CONTACT_ID = 0;
@@ -94,7 +104,9 @@ public abstract class ContactListAdapter extends ContactEntryListAdapter {
public static final int CONTACT_PHOTO_URI = 5;
public static final int CONTACT_LOOKUP_KEY = 6;
public static final int CONTACT_IS_USER_PROFILE = 7;
- public static final int CONTACT_SNIPPET = 8;
+ public static final int CONTACT_ACCOUNT_TYPE = 8;
+ public static final int CONTACT_ACCOUNT_NAME = 9;
+ public static final int CONTACT_SNIPPET = 10;
}
private CharSequence mUnknownNameText;
@@ -230,8 +242,15 @@ public abstract class ContactListAdapter extends ContactEntryListAdapter {
photoId = cursor.getLong(ContactQuery.CONTACT_PHOTO_ID);
}
+ Account account = null;
+ if (!cursor.isNull(ContactQuery.CONTACT_ACCOUNT_TYPE)
+ && !cursor.isNull(ContactQuery.CONTACT_ACCOUNT_NAME)) {
+ final String accountType = cursor.getString(ContactQuery.CONTACT_ACCOUNT_TYPE);
+ final String accountName = cursor.getString(ContactQuery.CONTACT_ACCOUNT_NAME);
+ account = new Account(accountName, accountType);
+ }
if (photoId != 0) {
- getPhotoLoader().loadThumbnail(view.getPhotoView(), photoId, false,
+ getPhotoLoader().loadThumbnail(view.getPhotoView(), photoId, account, false,
getCircularPhotos(), null);
} else {
final String photoUriString = cursor.getString(ContactQuery.CONTACT_PHOTO_URI);
@@ -242,7 +261,7 @@ public abstract class ContactListAdapter extends ContactEntryListAdapter {
ContactQuery.CONTACT_DISPLAY_NAME,
ContactQuery.CONTACT_LOOKUP_KEY);
}
- getPhotoLoader().loadDirectoryPhoto(view.getPhotoView(), photoUri, false,
+ getPhotoLoader().loadDirectoryPhoto(view.getPhotoView(), photoUri, account, false,
getCircularPhotos(), request);
}
}
diff --git a/src/com/android/contacts/common/list/ContactTileAdapter.java b/src/com/android/contacts/common/list/ContactTileAdapter.java
index ac10f383..48c6923f 100644
--- a/src/com/android/contacts/common/list/ContactTileAdapter.java
+++ b/src/com/android/contacts/common/list/ContactTileAdapter.java
@@ -15,6 +15,7 @@
*/
package com.android.contacts.common.list;
+import android.accounts.Account;
import android.content.ContentUris;
import android.content.Context;
import android.content.res.Resources;
@@ -67,6 +68,8 @@ public class ContactTileAdapter extends BaseAdapter {
protected int mNameIndex;
protected int mPresenceIndex;
protected int mStatusIndex;
+ private int mAccountTypeIndex;
+ private int mAccountNameIndex;
private boolean mIsQuickContactEnabled = false;
private final int mPaddingInPixels;
@@ -149,6 +152,8 @@ public class ContactTileAdapter extends BaseAdapter {
mStarredIndex = ContactTileLoaderFactory.STARRED;
mPresenceIndex = ContactTileLoaderFactory.CONTACT_PRESENCE;
mStatusIndex = ContactTileLoaderFactory.CONTACT_STATUS;
+ mAccountTypeIndex = ContactTileLoaderFactory.ACCOUNT_TYPE;
+ mAccountNameIndex = ContactTileLoaderFactory.ACCOUNT_NAME;
}
private static boolean cursorIsValid(Cursor cursor) {
@@ -187,6 +192,9 @@ public class ContactTileAdapter extends BaseAdapter {
* Else use {@link ContactTileLoaderFactory}
*/
public void setContactCursor(Cursor cursor) {
+ if (cursor == null || cursor.isClosed()) {
+ return;
+ }
mContactCursor = cursor;
mDividerPosition = getDividerPosition(cursor);
@@ -271,6 +279,13 @@ public class ContactTileAdapter extends BaseAdapter {
}
contact.status = statusMessage;
+ if (!cursor.isNull(mAccountTypeIndex) && !cursor.isNull(mAccountTypeIndex)) {
+ final String accountType = cursor.getString(mAccountTypeIndex);
+ final String accountName = cursor.getString(mAccountNameIndex);
+ contact.account = new Account(accountName, accountType);
+ } else {
+ contact.account = null;
+ }
return contact;
}
diff --git a/src/com/android/contacts/common/list/ContactTileView.java b/src/com/android/contacts/common/list/ContactTileView.java
index 56552bb6..b42ab7bf 100644
--- a/src/com/android/contacts/common/list/ContactTileView.java
+++ b/src/com/android/contacts/common/list/ContactTileView.java
@@ -15,6 +15,7 @@
*/
package com.android.contacts.common.list;
+import android.accounts.Account;
import android.content.Context;
import android.graphics.Rect;
import android.net.Uri;
@@ -128,7 +129,8 @@ public abstract class ContactTileView extends FrameLayout {
DefaultImageRequest request = getDefaultImageRequest(entry.name, entry.lookupKey);
configureViewForImage(entry.photoUri == null);
if (mPhoto != null) {
- mPhotoManager.loadPhoto(mPhoto, entry.photoUri, getApproximateImageSize(),
+ mPhotoManager.loadPhoto(mPhoto, entry.photoUri,
+ entry.account, getApproximateImageSize(),
isDarkTheme(), isContactPhotoCircular(), request);
if (mQuickContact != null) {
@@ -136,7 +138,7 @@ public abstract class ContactTileView extends FrameLayout {
}
} else if (mQuickContact != null) {
mQuickContact.assignContactUri(mLookupUri);
- mPhotoManager.loadPhoto(mQuickContact, entry.photoUri,
+ mPhotoManager.loadPhoto(mQuickContact, entry.photoUri, entry.account,
getApproximateImageSize(), isDarkTheme(), isContactPhotoCircular(),
request);
}
diff --git a/src/com/android/contacts/common/list/DefaultContactListAdapter.java b/src/com/android/contacts/common/list/DefaultContactListAdapter.java
index 930ad5c1..f25f5d7f 100644
--- a/src/com/android/contacts/common/list/DefaultContactListAdapter.java
+++ b/src/com/android/contacts/common/list/DefaultContactListAdapter.java
@@ -248,7 +248,8 @@ public class DefaultContactListAdapter extends ContactListAdapter {
if (isQuickContactEnabled()) {
bindQuickContact(view, partition, cursor, ContactQuery.CONTACT_PHOTO_ID,
ContactQuery.CONTACT_PHOTO_URI, ContactQuery.CONTACT_ID,
- ContactQuery.CONTACT_LOOKUP_KEY, ContactQuery.CONTACT_DISPLAY_NAME);
+ ContactQuery.CONTACT_LOOKUP_KEY, ContactQuery.CONTACT_DISPLAY_NAME,
+ ContactQuery.CONTACT_ACCOUNT_TYPE, ContactQuery.CONTACT_ACCOUNT_NAME);
} else {
if (getDisplayPhotos()) {
bindPhoto(view, partition, cursor);
diff --git a/src/com/android/contacts/common/list/PhoneNumberListAdapter.java b/src/com/android/contacts/common/list/PhoneNumberListAdapter.java
index 17b95169..750f030e 100644
--- a/src/com/android/contacts/common/list/PhoneNumberListAdapter.java
+++ b/src/com/android/contacts/common/list/PhoneNumberListAdapter.java
@@ -15,6 +15,7 @@
*/
package com.android.contacts.common.list;
+import android.accounts.Account;
import android.content.ContentUris;
import android.content.Context;
import android.content.CursorLoader;
@@ -99,6 +100,8 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter {
Phone.PHOTO_ID, // 6
Phone.DISPLAY_NAME_PRIMARY, // 7
Phone.PHOTO_THUMBNAIL_URI, // 8
+ RawContacts.ACCOUNT_TYPE, // 9
+ RawContacts.ACCOUNT_NAME, // 10
};
public static final String[] PROJECTION_ALTERNATIVE = new String[] {
@@ -111,6 +114,8 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter {
Phone.PHOTO_ID, // 6
Phone.DISPLAY_NAME_ALTERNATIVE, // 7
Phone.PHOTO_THUMBNAIL_URI, // 8
+ RawContacts.ACCOUNT_TYPE, // 9
+ RawContacts.ACCOUNT_NAME, // 10
};
public static final int PHONE_ID = 0;
@@ -122,6 +127,8 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter {
public static final int PHOTO_ID = 6;
public static final int DISPLAY_NAME = 7;
public static final int PHOTO_URI = 8;
+ public static final int PHONE_ACCOUNT_TYPE = 9;
+ public static final int PHONE_ACCOUNT_NAME = 10;
}
private static final String IGNORE_NUMBER_TOO_LONG_CLAUSE =
@@ -407,7 +414,8 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter {
if (isQuickContactEnabled()) {
bindQuickContact(view, partition, cursor, PhoneQuery.PHOTO_ID,
PhoneQuery.PHOTO_URI, PhoneQuery.CONTACT_ID,
- PhoneQuery.LOOKUP_KEY, PhoneQuery.DISPLAY_NAME);
+ PhoneQuery.LOOKUP_KEY, PhoneQuery.DISPLAY_NAME,
+ PhoneQuery.PHONE_ACCOUNT_TYPE, PhoneQuery.PHONE_ACCOUNT_NAME);
} else {
if (getDisplayPhotos()) {
bindPhoto(view, partition, cursor);
@@ -477,9 +485,15 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter {
if (!cursor.isNull(PhoneQuery.PHOTO_ID)) {
photoId = cursor.getLong(PhoneQuery.PHOTO_ID);
}
-
+ Account account = null;
+ if (!cursor.isNull(PhoneQuery.PHONE_ACCOUNT_TYPE)
+ && !cursor.isNull(PhoneQuery.PHONE_ACCOUNT_NAME)) {
+ final String accountType = cursor.getString(PhoneQuery.PHONE_ACCOUNT_TYPE);
+ final String accountName = cursor.getString(PhoneQuery.PHONE_ACCOUNT_NAME);
+ account = new Account(accountName, accountType);
+ }
if (photoId != 0) {
- getPhotoLoader().loadThumbnail(view.getPhotoView(), photoId, false,
+ getPhotoLoader().loadThumbnail(view.getPhotoView(), photoId, account, false,
getCircularPhotos(), null);
} else {
final String photoUriString = cursor.getString(PhoneQuery.PHOTO_URI);
@@ -491,7 +505,7 @@ public class PhoneNumberListAdapter extends ContactEntryListAdapter {
final String lookupKey = cursor.getString(PhoneQuery.LOOKUP_KEY);
request = new DefaultImageRequest(displayName, lookupKey, getCircularPhotos());
}
- getPhotoLoader().loadDirectoryPhoto(view.getPhotoView(), photoUri, false,
+ getPhotoLoader().loadDirectoryPhoto(view.getPhotoView(), photoUri, account, false,
getCircularPhotos(), request);
}
}
diff --git a/src/com/android/contacts/common/list/ShortcutIntentBuilder.java b/src/com/android/contacts/common/list/ShortcutIntentBuilder.java
index 9e6b5e95..35c3ff21 100644
--- a/src/com/android/contacts/common/list/ShortcutIntentBuilder.java
+++ b/src/com/android/contacts/common/list/ShortcutIntentBuilder.java
@@ -15,6 +15,7 @@
*/
package com.android.contacts.common.list;
+import android.accounts.Account;
import android.app.ActivityManager;
import android.content.ContentResolver;
import android.content.Context;
@@ -39,6 +40,7 @@ import android.provider.ContactsContract.Data;
import android.support.v4.graphics.drawable.RoundedBitmapDrawable;
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory;
import android.telecom.PhoneAccount;
+import android.provider.ContactsContract.RawContacts;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.TextUtils.TruncateAt;
@@ -56,12 +58,16 @@ public class ShortcutIntentBuilder {
private static final String[] CONTACT_COLUMNS = {
Contacts.DISPLAY_NAME,
Contacts.PHOTO_ID,
- Contacts.LOOKUP_KEY
+ Contacts.LOOKUP_KEY,
+ RawContacts.ACCOUNT_TYPE,
+ RawContacts.ACCOUNT_NAME
};
private static final int CONTACT_DISPLAY_NAME_COLUMN_INDEX = 0;
private static final int CONTACT_PHOTO_ID_COLUMN_INDEX = 1;
private static final int CONTACT_LOOKUP_KEY_COLUMN_INDEX = 2;
+ private static final int CONTACT_ACCOUNT_TYPE_COLUMN_INDEX = 3;
+ private static final int CONTACT_ACCOUNT_NAME_COLUMN_INDEX = 4;
private static final String[] PHONE_COLUMNS = {
Phone.DISPLAY_NAME,
@@ -69,7 +75,9 @@ public class ShortcutIntentBuilder {
Phone.NUMBER,
Phone.TYPE,
Phone.LABEL,
- Phone.LOOKUP_KEY
+ Phone.LOOKUP_KEY,
+ RawContacts.ACCOUNT_TYPE,
+ RawContacts.ACCOUNT_NAME
};
private static final int PHONE_DISPLAY_NAME_COLUMN_INDEX = 0;
@@ -78,6 +86,8 @@ public class ShortcutIntentBuilder {
private static final int PHONE_TYPE_COLUMN_INDEX = 3;
private static final int PHONE_LABEL_COLUMN_INDEX = 4;
private static final int PHONE_LOOKUP_KEY_COLUMN_INDEX = 5;
+ private static final int PHONE_ACCOUNT_TYPE_COLUMN_INDEX = 6;
+ private static final int PHONE_ACCOUNT_NAME_COLUMN_INDEX = 7;
private static final String[] PHOTO_COLUMNS = {
Photo.PHOTO,
@@ -187,6 +197,8 @@ public class ShortcutIntentBuilder {
}
private final class ContactLoadingAsyncTask extends LoadingAsyncTask {
+ private Account mAccount;
+
public ContactLoadingAsyncTask(Uri uri) {
super(uri);
}
@@ -200,6 +212,13 @@ public class ShortcutIntentBuilder {
if (cursor.moveToFirst()) {
mDisplayName = cursor.getString(CONTACT_DISPLAY_NAME_COLUMN_INDEX);
mPhotoId = cursor.getLong(CONTACT_PHOTO_ID_COLUMN_INDEX);
+
+ final String accountType = cursor
+ .getString(CONTACT_ACCOUNT_TYPE_COLUMN_INDEX);
+ final String accountName = cursor
+ .getString(CONTACT_ACCOUNT_NAME_COLUMN_INDEX);
+ mAccount = new Account(accountName, accountType);
+
mLookupKey = cursor.getString(CONTACT_LOOKUP_KEY_COLUMN_INDEX);
}
} finally {
@@ -209,7 +228,8 @@ public class ShortcutIntentBuilder {
}
@Override
protected void onPostExecute(Void result) {
- createContactShortcutIntent(mUri, mContentType, mDisplayName, mLookupKey, mBitmapData);
+ createContactShortcutIntent(mUri, mContentType, mDisplayName,
+ mAccount, mLookupKey, mBitmapData);
}
}
@@ -218,6 +238,7 @@ public class ShortcutIntentBuilder {
private String mPhoneNumber;
private int mPhoneType;
private String mPhoneLabel;
+ private Account mAccount;
public PhoneNumberLoadingAsyncTask(Uri uri, String shortcutAction) {
super(uri);
@@ -236,6 +257,13 @@ public class ShortcutIntentBuilder {
mPhoneNumber = cursor.getString(PHONE_NUMBER_COLUMN_INDEX);
mPhoneType = cursor.getInt(PHONE_TYPE_COLUMN_INDEX);
mPhoneLabel = cursor.getString(PHONE_LABEL_COLUMN_INDEX);
+
+ final String accountType = cursor
+ .getString(PHONE_ACCOUNT_TYPE_COLUMN_INDEX);
+ final String accountName = cursor
+ .getString(PHONE_ACCOUNT_NAME_COLUMN_INDEX);
+ mAccount = new Account(accountName, accountType);
+
mLookupKey = cursor.getString(PHONE_LOOKUP_KEY_COLUMN_INDEX);
}
} finally {
@@ -247,23 +275,25 @@ public class ShortcutIntentBuilder {
@Override
protected void onPostExecute(Void result) {
createPhoneNumberShortcutIntent(mUri, mDisplayName, mLookupKey, mBitmapData,
- mPhoneNumber, mPhoneType, mPhoneLabel, mShortcutAction);
+ mPhoneNumber, mPhoneType, mPhoneLabel, mAccount, mShortcutAction);
}
}
- private Drawable getPhotoDrawable(byte[] bitmapData, String displayName, String lookupKey) {
+ private Drawable getPhotoDrawable(byte[] bitmapData, String displayName,
+ String lookupKey, Account account) {
if (bitmapData != null) {
Bitmap bitmap = BitmapFactory.decodeByteArray(bitmapData, 0, bitmapData.length, null);
return new BitmapDrawable(mContext.getResources(), bitmap);
} else {
- return ContactPhotoManager.getDefaultAvatarDrawableForContact(mContext.getResources(),
- false, new DefaultImageRequest(displayName, lookupKey, false));
+ return ContactPhotoManager.getDefaultAvatarDrawableForContact(mContext,
+ mContext.getResources(), false,
+ new DefaultImageRequest(displayName, lookupKey, false), account);
}
}
private void createContactShortcutIntent(Uri contactUri, String contentType, String displayName,
- String lookupKey, byte[] bitmapData) {
- Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey);
+ Account account, String lookupKey, byte[] bitmapData) {
+ Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey, account);
// Use an implicit intent without a package name set. It is reasonable for a disambiguation
// dialog to appear when opening QuickContacts from the launcher. Plus, this will be more
@@ -303,8 +333,8 @@ public class ShortcutIntentBuilder {
private void createPhoneNumberShortcutIntent(Uri uri, String displayName, String lookupKey,
byte[] bitmapData, String phoneNumber, int phoneType, String phoneLabel,
- String shortcutAction) {
- Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey);
+ Account account, String shortcutAction) {
+ Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey, account);
Bitmap bitmap;
Uri phoneUri;