summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwangqi <wangqi@google.com>2017-08-01 16:31:44 -0700
committerEric Erfanian <erfanian@google.com>2017-08-01 17:19:00 -0700
commit940ef54ff5a2dc652fe5a2813c636aa7b85da112 (patch)
tree0227a24077e375113539e1013df57e9e86cc6da8
parent9cc5a590ca34ac4f05c5bb5c733b0587b4422427 (diff)
Fix the blurry contact photo.
A high res sync update request should be sent to trigger the photo sync. Without this request, the contact photo will stay in low res until user action to trigger it in other ways such as click on quick contacts or open it in contacts app. Bug: 62390496 Test: manual PiperOrigin-RevId: 163905019 Change-Id: Iaf47934df02dc15f75e806505dfd425402fde07c
-rw-r--r--java/com/android/dialer/app/list/PhoneFavoriteTileView.java22
-rw-r--r--java/com/android/incallui/CallCardPresenter.java4
-rw-r--r--java/com/android/incallui/ContactInfoCache.java4
3 files changed, 24 insertions, 6 deletions
diff --git a/java/com/android/dialer/app/list/PhoneFavoriteTileView.java b/java/com/android/dialer/app/list/PhoneFavoriteTileView.java
index 455085d85..29147e7b3 100644
--- a/java/com/android/dialer/app/list/PhoneFavoriteTileView.java
+++ b/java/com/android/dialer/app/list/PhoneFavoriteTileView.java
@@ -18,6 +18,7 @@ package com.android.dialer.app.list;
import android.content.ClipData;
import android.content.Context;
+import android.net.Uri;
import android.provider.ContactsContract.PinnedPositions;
import android.text.TextUtils;
import android.util.AttributeSet;
@@ -26,10 +27,12 @@ import android.widget.ImageView;
import com.android.contacts.common.MoreContactUtils;
import com.android.contacts.common.list.ContactEntry;
import com.android.contacts.common.list.ContactTileView;
+import com.android.contacts.common.model.ContactLoader;
import com.android.dialer.app.R;
import com.android.dialer.callintent.CallInitiationType;
import com.android.dialer.callintent.CallSpecificAppData;
import com.android.dialer.callintent.SpeedDialContactType;
+import com.android.dialer.common.LogUtil;
import com.android.dialer.contactphoto.ContactPhotoManager.DefaultImageRequest;
import com.android.dialer.lettertile.LetterTileDrawable;
import com.android.dialer.logging.InteractionEvent;
@@ -94,6 +97,7 @@ public abstract class PhoneFavoriteTileView extends ContactTileView {
isPinned = (entry.pinned != PinnedPositions.UNPINNED);
isStarred = entry.isFavorite;
if (entry != null) {
+ sendViewNotification(getContext(), entry.lookupUri);
// Grab the phone-number to call directly. See {@link onClick()}.
mPhoneNumberString = entry.phoneNumber;
@@ -186,4 +190,22 @@ public abstract class PhoneFavoriteTileView extends ContactTileView {
public void setPosition(int position) {
this.position = position;
}
+
+ /**
+ * Send a notification using a {@link ContactLoader} to inform the sync adapter that we are
+ * viewing a particular contact, so that it can download the high-res photo.
+ */
+ private static void sendViewNotification(Context context, Uri contactUri) {
+ ContactLoader loader = new ContactLoader(context, contactUri, true /* postViewNotification */);
+ loader.registerListener(
+ 0,
+ (loader1, contact) -> {
+ try {
+ loader1.reset();
+ } catch (RuntimeException e) {
+ LogUtil.e("PhoneFavoriteTileView.onLoadComplete", "error resetting loader", e);
+ }
+ });
+ loader.startLoading();
+ }
}
diff --git a/java/com/android/incallui/CallCardPresenter.java b/java/com/android/incallui/CallCardPresenter.java
index afd2342bf..222b5b81e 100644
--- a/java/com/android/incallui/CallCardPresenter.java
+++ b/java/com/android/incallui/CallCardPresenter.java
@@ -587,8 +587,8 @@ public class CallCardPresenter
if (call != null) {
call.getLogState().contactLookupResult = entry.contactLookupResult;
}
- if (entry.contactUri != null) {
- CallerInfoUtils.sendViewNotification(mContext, entry.contactUri);
+ if (entry.lookupUri != null) {
+ CallerInfoUtils.sendViewNotification(mContext, entry.lookupUri);
}
}
diff --git a/java/com/android/incallui/ContactInfoCache.java b/java/com/android/incallui/ContactInfoCache.java
index d50a5c26d..353015313 100644
--- a/java/com/android/incallui/ContactInfoCache.java
+++ b/java/com/android/incallui/ContactInfoCache.java
@@ -699,8 +699,6 @@ public class ContactInfoCache implements OnImageLoadCompleteListener {
// Note in cache entry whether this is a pending async loading action to know whether to
// wait for its callback or not.
boolean hasPendingQuery;
- /** This will be used for the "view" notification. */
- public Uri contactUri;
/** Either a display photo or a thumbnail URI. */
Uri displayPhotoUri;
@@ -741,8 +739,6 @@ public class ContactInfoCache implements OnImageLoadCompleteListener {
+ photo
+ ", isSipCall="
+ isSipCall
- + ", contactUri="
- + contactUri
+ ", displayPhotoUri="
+ displayPhotoUri
+ ", contactLookupResult="