diff options
Diffstat (limited to 'java/com/android/dialer/speeddial')
5 files changed, 33 insertions, 16 deletions
diff --git a/java/com/android/dialer/speeddial/DisambigDialog.java b/java/com/android/dialer/speeddial/DisambigDialog.java index 0d29a9c84..a76f648ab 100644 --- a/java/com/android/dialer/speeddial/DisambigDialog.java +++ b/java/com/android/dialer/speeddial/DisambigDialog.java @@ -159,7 +159,7 @@ public class DisambigDialog extends DialogFragment { .logImpression( DialerImpression.Type.LIGHTBRINGER_VIDEO_REQUESTED_FOR_FAVORITE_CONTACT_DISAMBIG); Intent intent = - DuoComponent.get(getContext()).getDuo().getIntent(getContext(), channel.number()); + DuoComponent.get(getContext()).getDuo().getCallIntent(channel.number()).orNull(); getActivity().startActivityForResult(intent, ActivityRequestCodes.DIALTACTS_DUO); return; } diff --git a/java/com/android/dialer/speeddial/FavoritesViewHolder.java b/java/com/android/dialer/speeddial/FavoritesViewHolder.java index 474516ef2..f06672d8d 100644 --- a/java/com/android/dialer/speeddial/FavoritesViewHolder.java +++ b/java/com/android/dialer/speeddial/FavoritesViewHolder.java @@ -68,10 +68,15 @@ public class FavoritesViewHolder extends RecyclerView.ViewHolder Assert.checkArgument(speedDialUiItem.isStarred()); nameView.setText(speedDialUiItem.name()); - if (speedDialUiItem.defaultChannel() != null) { - phoneType.setText(speedDialUiItem.defaultChannel().label()); - videoCallIcon.setVisibility( - speedDialUiItem.defaultChannel().isVideoTechnology() ? View.VISIBLE : View.GONE); + + Channel channel = speedDialUiItem.defaultChannel(); + if (channel == null) { + channel = speedDialUiItem.getDefaultVoiceChannel(); + } + + if (channel != null) { + phoneType.setText(channel.label()); + videoCallIcon.setVisibility(channel.isVideoTechnology() ? View.VISIBLE : View.GONE); } else { phoneType.setText(""); videoCallIcon.setVisibility(View.GONE); diff --git a/java/com/android/dialer/speeddial/SpeedDialFragment.java b/java/com/android/dialer/speeddial/SpeedDialFragment.java index f0ba186cd..db4c0245e 100644 --- a/java/com/android/dialer/speeddial/SpeedDialFragment.java +++ b/java/com/android/dialer/speeddial/SpeedDialFragment.java @@ -114,9 +114,7 @@ public class SpeedDialFragment extends Fragment { getActivity(), getChildFragmentManager(), new SpeedDialContextMenuItemListener( - getActivity(), - new UpdateSpeedDialAdapterListener(), - speedDialLoaderListener), + getActivity(), new UpdateSpeedDialAdapterListener(), speedDialLoaderListener), layoutManager); adapter = new SpeedDialAdapter(getContext(), favoritesListener, suggestedListener, headerListener); @@ -246,7 +244,8 @@ public class SpeedDialFragment extends Fragment { if (channel.technology() == Channel.DUO) { Logger.get(activity) .logImpression(DialerImpression.Type.LIGHTBRINGER_VIDEO_REQUESTED_FOR_FAVORITE_CONTACT); - Intent intent = DuoComponent.get(activity).getDuo().getIntent(activity, channel.number()); + Intent intent = + DuoComponent.get(activity).getDuo().getCallIntent(channel.number()).orNull(); activity.startActivityForResult(intent, ActivityRequestCodes.DIALTACTS_DUO); return; } @@ -346,7 +345,7 @@ public class SpeedDialFragment extends Fragment { .logImpression( DialerImpression.Type.LIGHTBRINGER_VIDEO_REQUESTED_FOR_SUGGESTED_CONTACT); Intent intent = - DuoComponent.get(getContext()).getDuo().getIntent(getContext(), channel.number()); + DuoComponent.get(getContext()).getDuo().getCallIntent(channel.number()).orNull(); getActivity().startActivityForResult(intent, ActivityRequestCodes.DIALTACTS_DUO); return; } @@ -430,7 +429,8 @@ public class SpeedDialFragment extends Fragment { if (channel.technology() == Channel.DUO) { Logger.get(activity) .logImpression(DialerImpression.Type.LIGHTBRINGER_VIDEO_REQUESTED_FOR_FAVORITE_CONTACT); - Intent intent = DuoComponent.get(activity).getDuo().getIntent(activity, channel.number()); + Intent intent = + DuoComponent.get(activity).getDuo().getCallIntent(channel.number()).orNull(); activity.startActivityForResult(intent, ActivityRequestCodes.DIALTACTS_DUO); return; } diff --git a/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java b/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java index f730d12a0..365b88f8c 100644 --- a/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java +++ b/java/com/android/dialer/speeddial/loader/SpeedDialUiItem.java @@ -16,6 +16,7 @@ package com.android.dialer.speeddial.loader; +import android.content.res.Resources; import android.database.Cursor; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.Contacts; @@ -102,7 +103,7 @@ public abstract class SpeedDialUiItem { * <p>If the cursor started at row X, this method will advance to row Y s.t. rows X, X + 1, ... Y * - 1 all belong to the same contact (that is, share the same contact id and lookup key). */ - public static SpeedDialUiItem fromCursor(Cursor cursor) { + public static SpeedDialUiItem fromCursor(Resources resources, Cursor cursor) { Assert.checkArgument(cursor != null); Assert.checkArgument(cursor.getCount() != 0); String lookupKey = cursor.getString(LOOKUP_KEY); @@ -125,7 +126,7 @@ public abstract class SpeedDialUiItem { Channel.builder() .setNumber(cursor.getString(NUMBER)) .setPhoneType(cursor.getInt(TYPE)) - .setLabel(TextUtils.isEmpty(cursor.getString(LABEL)) ? "" : cursor.getString(LABEL)) + .setLabel(getLabel(resources, cursor)) .setTechnology(Channel.VOICE) .build(); channels.add(channel); @@ -141,6 +142,17 @@ public abstract class SpeedDialUiItem { return builder.build(); } + private static String getLabel(Resources resources, Cursor cursor) { + int numberType = cursor.getInt(TYPE); + String numberLabel = cursor.getString(LABEL); + + // Returns empty label instead of "custom" if the custom label is empty. + if (numberType == Phone.TYPE_CUSTOM && TextUtils.isEmpty(numberLabel)) { + return ""; + } + return (String) Phone.getTypeLabel(resources, numberType, numberLabel); + } + public PhotoInfo getPhotoInfo() { return PhotoInfo.newBuilder() .setPhotoId(photoId()) diff --git a/java/com/android/dialer/speeddial/loader/SpeedDialUiItemMutator.java b/java/com/android/dialer/speeddial/loader/SpeedDialUiItemMutator.java index 0a2a241b3..1ad37dc2a 100644 --- a/java/com/android/dialer/speeddial/loader/SpeedDialUiItemMutator.java +++ b/java/com/android/dialer/speeddial/loader/SpeedDialUiItemMutator.java @@ -205,7 +205,7 @@ public final class SpeedDialUiItemMutator { return loadSpeedDialUiItemsInternal(); } Assert.checkArgument(cursor.moveToFirst(), "Cursor should never be empty"); - SpeedDialUiItem item = SpeedDialUiItem.fromCursor(cursor); + SpeedDialUiItem item = SpeedDialUiItem.fromCursor(appContext.getResources(), cursor); // Star the contact if it isn't starred already, then return. if (!item.isStarred()) { @@ -410,7 +410,7 @@ public final class SpeedDialUiItemMutator { null)) { Map<SpeedDialEntry, SpeedDialUiItem> map = new ArrayMap<>(); for (cursor.moveToFirst(); !cursor.isAfterLast(); /* Iterate in the loop */ ) { - SpeedDialUiItem item = SpeedDialUiItem.fromCursor(cursor); + SpeedDialUiItem item = SpeedDialUiItem.fromCursor(appContext.getResources(), cursor); for (SpeedDialEntry entry : entries) { if (entry.contactId() == item.contactId()) { // Update the id and pinned position to match it's corresponding SpeedDialEntry. @@ -513,7 +513,7 @@ public final class SpeedDialUiItemMutator { return contacts; } for (cursor.moveToFirst(); !cursor.isAfterLast(); /* Iterate in the loop */ ) { - contacts.add(SpeedDialUiItem.fromCursor(cursor)); + contacts.add(SpeedDialUiItem.fromCursor(appContext.getResources(), cursor)); } return contacts; } |