diff options
author | Eric Erfanian <erfanian@google.com> | 2017-08-31 06:57:16 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-08-31 16:13:53 +0000 |
commit | 2ca4318cc1ee57dda907ba2069bd61d162b1baef (patch) | |
tree | e282668a9587cf6c1ec7b604dea860400c75c6c7 /java/com/android/dialer/app/list/PhoneFavoriteTileView.java | |
parent | 68038172793ee0e2ab3e2e56ddfbeb82879d1f58 (diff) |
Update Dialer source to latest internal Google revision.
Previously, Android's Dialer app was developed in an internal Google
source control system and only exported to public during AOSP drops.
The Dialer team is now switching to a public development model similar
to the telephony team.
This CL represents all internal Google changes that were committed to
Dialer between the public O release and today's tip of tree on internal
master. This CL squashes those changes into a single commit.
In subsequent changes, changes will be exported on a per-commit basis.
Test: make, flash install, run
Merged-In: I45270eaa8ce732d71a1bd84b08c7fa0e99af3160
Change-Id: I529aaeb88535b9533c0ae4ef4e6c1222d4e0f1c8
PiperOrigin-RevId: 167068436
Diffstat (limited to 'java/com/android/dialer/app/list/PhoneFavoriteTileView.java')
-rw-r--r-- | java/com/android/dialer/app/list/PhoneFavoriteTileView.java | 72 |
1 files changed, 64 insertions, 8 deletions
diff --git a/java/com/android/dialer/app/list/PhoneFavoriteTileView.java b/java/com/android/dialer/app/list/PhoneFavoriteTileView.java index db89cf3dc..e0961be4b 100644 --- a/java/com/android/dialer/app/list/PhoneFavoriteTileView.java +++ b/java/com/android/dialer/app/list/PhoneFavoriteTileView.java @@ -18,16 +18,25 @@ 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; import android.view.View; import android.widget.ImageView; -import com.android.contacts.common.ContactPhotoManager; -import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest; 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; +import com.android.dialer.logging.Logger; /** * A light version of the {@link com.android.contacts.common.list.ContactTileView} that is used in @@ -42,7 +51,6 @@ public abstract class PhoneFavoriteTileView extends ContactTileView { // tile is long pressed. static final String DRAG_PHONE_FAVORITE_TILE = "PHONE_FAVORITE_TILE"; private static final String TAG = PhoneFavoriteTileView.class.getSimpleName(); - private static final boolean DEBUG = false; // These parameters instruct the photo manager to display the default image/letter at 70% of // its normal size, and vertically offset upwards 12% towards the top of the letter tile, to // make room for the contact name and number label at the bottom of the image. @@ -55,6 +63,9 @@ public abstract class PhoneFavoriteTileView extends ContactTileView { private View mShadowOverlay; /** Users' most frequent phone number. */ private String mPhoneNumberString; + private boolean isPinned; + private boolean isStarred; + private int position = -1; public PhoneFavoriteTileView(Context context, AttributeSet attrs) { super(context, attrs); @@ -83,12 +94,14 @@ public abstract class PhoneFavoriteTileView extends ContactTileView { super.loadFromContact(entry); // Set phone number to null in case we're reusing the view. mPhoneNumberString = null; + 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; - // If this is a blank entry, don't show anything. - // TODO krelease: Just hide the view for now. For this to truly look like an empty row + // If this is a blank entry, don't show anything. For this to truly look like an empty row // the entire ContactTileRow needs to be hidden. if (entry == ContactEntry.BLANK_ENTRY) { setVisibility(View.INVISIBLE); @@ -113,16 +126,37 @@ public abstract class PhoneFavoriteTileView extends ContactTileView { if (mListener == null) { return; } + + CallSpecificAppData.Builder callSpecificAppData = + CallSpecificAppData.newBuilder() + .setAllowAssistedDialing(true) + .setCallInitiationType(CallInitiationType.Type.SPEED_DIAL) + .setSpeedDialContactPosition(position); + if (isStarred) { + callSpecificAppData.addSpeedDialContactType(SpeedDialContactType.Type.STARRED_CONTACT); + } else { + callSpecificAppData.addSpeedDialContactType(SpeedDialContactType.Type.FREQUENT_CONTACT); + } + if (isPinned) { + callSpecificAppData.addSpeedDialContactType(SpeedDialContactType.Type.PINNED_CONTACT); + } + if (TextUtils.isEmpty(mPhoneNumberString)) { + // Don't set performance report now, since user may spend some time on picking a number + // Copy "superclass" implementation + Logger.get(getContext()) + .logInteraction(InteractionEvent.Type.SPEED_DIAL_CLICK_CONTACT_WITH_AMBIGUOUS_NUMBER); mListener.onContactSelected( - getLookupUri(), MoreContactUtils.getTargetRectFromView(PhoneFavoriteTileView.this)); + getLookupUri(), + MoreContactUtils.getTargetRectFromView(PhoneFavoriteTileView.this), + callSpecificAppData.build()); } else { // When you tap a frequently-called contact, you want to // call them at the number that you usually talk to them // at (i.e. the one displayed in the UI), regardless of // whether that's their default number. - mListener.onCallNumberDirectly(mPhoneNumberString); + mListener.onCallNumberDirectly(mPhoneNumberString, callSpecificAppData.build()); } } }; @@ -133,7 +167,7 @@ public abstract class PhoneFavoriteTileView extends ContactTileView { return new DefaultImageRequest( displayName, lookupKey, - ContactPhotoManager.TYPE_DEFAULT, + LetterTileDrawable.TYPE_DEFAULT, DEFAULT_IMAGE_LETTER_SCALE, DEFAULT_IMAGE_LETTER_OFFSET, false); @@ -152,4 +186,26 @@ public abstract class PhoneFavoriteTileView extends ContactTileView { // Unlike Contacts' tiles, the Dialer's favorites tiles are square. return false; } + + 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(); + } } |