Loading java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java +9 −5 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.database.Cursor; import android.provider.CallLog.Calls; import android.support.annotation.DrawableRes; import android.support.v7.widget.RecyclerView; import android.text.TextUtils; import android.view.View; import android.widget.ImageView; import android.widget.QuickContactBadge; Loading @@ -35,6 +36,7 @@ import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.compat.AppCompatConstants; import com.android.dialer.compat.telephony.TelephonyManagerCompat; import com.android.dialer.glidephotomanager.GlidePhotoManager; import com.android.dialer.glidephotomanager.PhotoInfo; import com.android.dialer.oem.MotorolaUtils; import com.android.dialer.time.Clock; import com.google.common.util.concurrent.FutureCallback; Loading Loading @@ -150,11 +152,13 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { } private void setPhoto(CoalescedRow row) { glidePhotoManager.loadQuickContactBadge( quickContactBadge, NumberAttributesConverter.toPhotoInfoBuilder(row.numberAttributes()) .setFormattedNumber(row.formattedNumber()) .build()); PhotoInfo.Builder photoInfoBuilder = NumberAttributesConverter.toPhotoInfoBuilder(row.numberAttributes()); if (!TextUtils.isEmpty(row.formattedNumber())) { photoInfoBuilder.setFormattedNumber(row.formattedNumber()); } glidePhotoManager.loadQuickContactBadge(quickContactBadge, photoInfoBuilder.build()); } private void setFeatureIcons(CoalescedRow row) { Loading java/com/android/dialer/calllog/ui/menu/PrimaryAction.java +11 −5 Original line number Diff line number Diff line Loading @@ -18,10 +18,12 @@ package com.android.dialer.calllog.ui.menu; import android.content.Context; import android.provider.CallLog.Calls; import android.text.TextUtils; import com.android.dialer.calllog.model.CoalescedRow; import com.android.dialer.calllogutils.CallLogEntryText; import com.android.dialer.calllogutils.CallLogIntents; import com.android.dialer.calllogutils.NumberAttributesConverter; import com.android.dialer.glidephotomanager.PhotoInfo; import com.android.dialer.historyitemactions.HistoryItemPrimaryActionInfo; /** Configures the primary action row (top row) for the bottom sheet. */ Loading @@ -29,13 +31,17 @@ final class PrimaryAction { static HistoryItemPrimaryActionInfo fromRow(Context context, CoalescedRow row) { CharSequence primaryText = CallLogEntryText.buildPrimaryText(context, row); PhotoInfo.Builder photoInfoBuilder = NumberAttributesConverter.toPhotoInfoBuilder(row.numberAttributes()) .setIsVideo((row.features() & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO); if (!TextUtils.isEmpty(row.formattedNumber())) { photoInfoBuilder.setFormattedNumber(row.formattedNumber()); } return HistoryItemPrimaryActionInfo.builder() .setNumber(row.number()) .setPhotoInfo( NumberAttributesConverter.toPhotoInfoBuilder(row.numberAttributes()) .setFormattedNumber(row.formattedNumber()) .setIsVideo((row.features() & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO) .build()) .setPhotoInfo(photoInfoBuilder.build()) .setPrimaryText(primaryText) .setSecondaryText(CallLogEntryText.buildSecondaryTextForBottomSheet(context, row)) .setIntent(CallLogIntents.getCallBackIntent(context, row)) Loading java/com/android/dialer/calllogutils/NumberAttributesConverter.java +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ public final class NumberAttributesConverter { /** Converts {@link NumberAttributes} to {@link PhotoInfo.Builder} */ public static PhotoInfo.Builder toPhotoInfoBuilder(NumberAttributes numberAttributes) { return PhotoInfo.builder() return PhotoInfo.newBuilder() .setName(numberAttributes.getName()) .setPhotoUri(numberAttributes.getPhotoUri()) .setPhotoId(numberAttributes.getPhotoId()) Loading java/com/android/dialer/glidephotomanager/PhotoInfo.javadeleted 100644 → 0 +0 −100 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.dialer.glidephotomanager; import android.support.annotation.Nullable; import com.google.auto.value.AutoValue; /** The number information used to create the photo.. */ @AutoValue public abstract class PhotoInfo { /** The display name of the number */ @Nullable public abstract String name(); /** The number displayed to the user. */ @Nullable public abstract String formattedNumber(); /** The URI to the photo */ @Nullable public abstract String photoUri(); /** Value of {@link android.provider.ContactsContract.CommonDataKinds.Photo#_ID} */ public abstract long photoId(); /** The contacts provider lookup URI for the contact associated with the number */ @Nullable public abstract String lookupUri(); /** Should a business icon be displayed */ public abstract boolean isBusiness(); /** Should a voicemail icon be displayed */ public abstract boolean isVoicemail(); /** Should a blocked icon be displayed */ public abstract boolean isBlocked(); /** Should a spam icon be displayed */ public abstract boolean isSpam(); /** * Should the photo be badged as video call. * * <p>Defaults to false. */ public abstract boolean isVideo(); /** Builder for {@link PhotoInfo} */ @AutoValue.Builder public abstract static class Builder { public abstract Builder setName(@Nullable String name); public abstract Builder setFormattedNumber(@Nullable String formattedNumber); public abstract Builder setPhotoUri(@Nullable String uri); public abstract Builder setPhotoId(long id); public abstract Builder setLookupUri(@Nullable String uri); public abstract Builder setIsBusiness(boolean isBusiness); public abstract Builder setIsVoicemail(boolean isVoicemail); public abstract Builder setIsBlocked(boolean isBlocked); public abstract Builder setIsSpam(boolean isSpam); public abstract Builder setIsVideo(boolean isVideo); public abstract PhotoInfo build(); } public static PhotoInfo.Builder builder() { return new AutoValue_PhotoInfo.Builder() .setPhotoId(0) .setIsBusiness(false) .setIsVoicemail(false) .setIsBlocked(false) .setIsSpam(false) .setIsVideo(false); } } java/com/android/dialer/glidephotomanager/impl/GlidePhotoManagerImpl.java +16 −14 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ public class GlidePhotoManagerImpl implements GlidePhotoManager { @Override public void loadQuickContactBadge(QuickContactBadge badge, PhotoInfo photoInfo) { Assert.isMainThread(); badge.assignContactUri(parseUri(photoInfo.lookupUri())); badge.assignContactUri(parseUri(photoInfo.getLookupUri())); badge.setOverlay(null); GlideRequest<Drawable> request = buildRequest(GlideApp.with(badge), photoInfo); request.into(badge); Loading @@ -62,20 +62,20 @@ public class GlidePhotoManagerImpl implements GlidePhotoManager { GlideRequest<Drawable> request; boolean circleCrop = true; // Photos are cropped to a circle by default. if (photoInfo.isBlocked()) { if (photoInfo.getIsBlocked()) { // Whether the number is blocked takes precedence over the spam status. request = requestManager.load(R.drawable.ic_block_grey_48dp); } else if (photoInfo.isSpam()) { } else if (photoInfo.getIsSpam()) { request = requestManager.load(R.drawable.quantum_ic_report_vd_red_24); circleCrop = false; // The spam icon is an octagon so we don't crop it. } else if (!TextUtils.isEmpty(photoInfo.photoUri())) { request = requestManager.load(parseUri(photoInfo.photoUri())); } else if (!TextUtils.isEmpty(photoInfo.getPhotoUri())) { request = requestManager.load(parseUri(photoInfo.getPhotoUri())); } else if (photoInfo.photoId() != 0) { } else if (photoInfo.getPhotoId() != 0) { request = requestManager.load(ContentUris.withAppendedId(Data.CONTENT_URI, photoInfo.photoId())); requestManager.load(ContentUris.withAppendedId(Data.CONTENT_URI, photoInfo.getPhotoId())); } else { // load null to indicate fallback should be used. Loading @@ -102,23 +102,25 @@ public class GlidePhotoManagerImpl implements GlidePhotoManager { LetterTileDrawable letterTileDrawable = new LetterTileDrawable(appContext.getResources()); String displayName; String identifier; if (TextUtils.isEmpty(photoInfo.lookupUri())) { if (TextUtils.isEmpty(photoInfo.getLookupUri())) { // Use generic avatar instead of letter for non-contacts. displayName = null; identifier = TextUtils.isEmpty(photoInfo.name()) ? photoInfo.formattedNumber() : photoInfo.name(); TextUtils.isEmpty(photoInfo.getName()) ? photoInfo.getFormattedNumber() : photoInfo.getName(); } else { displayName = photoInfo.name(); identifier = photoInfo.lookupUri(); displayName = photoInfo.getName(); identifier = photoInfo.getLookupUri(); } letterTileDrawable.setCanonicalDialerLetterTileDetails( displayName, identifier, LetterTileDrawable.SHAPE_CIRCLE, LetterTileDrawable.getContactTypeFromPrimitives( photoInfo.isVoicemail(), photoInfo.isSpam(), photoInfo.isBusiness(), photoInfo.getIsVoicemail(), photoInfo.getIsSpam(), photoInfo.getIsBusiness(), TelecomManager.PRESENTATION_ALLOWED, // TODO(twyen):implement false)); // TODO(twyen):implement return letterTileDrawable; Loading Loading
java/com/android/dialer/calllog/ui/NewCallLogViewHolder.java +9 −5 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.database.Cursor; import android.provider.CallLog.Calls; import android.support.annotation.DrawableRes; import android.support.v7.widget.RecyclerView; import android.text.TextUtils; import android.view.View; import android.widget.ImageView; import android.widget.QuickContactBadge; Loading @@ -35,6 +36,7 @@ import com.android.dialer.common.concurrent.DialerExecutorComponent; import com.android.dialer.compat.AppCompatConstants; import com.android.dialer.compat.telephony.TelephonyManagerCompat; import com.android.dialer.glidephotomanager.GlidePhotoManager; import com.android.dialer.glidephotomanager.PhotoInfo; import com.android.dialer.oem.MotorolaUtils; import com.android.dialer.time.Clock; import com.google.common.util.concurrent.FutureCallback; Loading Loading @@ -150,11 +152,13 @@ final class NewCallLogViewHolder extends RecyclerView.ViewHolder { } private void setPhoto(CoalescedRow row) { glidePhotoManager.loadQuickContactBadge( quickContactBadge, NumberAttributesConverter.toPhotoInfoBuilder(row.numberAttributes()) .setFormattedNumber(row.formattedNumber()) .build()); PhotoInfo.Builder photoInfoBuilder = NumberAttributesConverter.toPhotoInfoBuilder(row.numberAttributes()); if (!TextUtils.isEmpty(row.formattedNumber())) { photoInfoBuilder.setFormattedNumber(row.formattedNumber()); } glidePhotoManager.loadQuickContactBadge(quickContactBadge, photoInfoBuilder.build()); } private void setFeatureIcons(CoalescedRow row) { Loading
java/com/android/dialer/calllog/ui/menu/PrimaryAction.java +11 −5 Original line number Diff line number Diff line Loading @@ -18,10 +18,12 @@ package com.android.dialer.calllog.ui.menu; import android.content.Context; import android.provider.CallLog.Calls; import android.text.TextUtils; import com.android.dialer.calllog.model.CoalescedRow; import com.android.dialer.calllogutils.CallLogEntryText; import com.android.dialer.calllogutils.CallLogIntents; import com.android.dialer.calllogutils.NumberAttributesConverter; import com.android.dialer.glidephotomanager.PhotoInfo; import com.android.dialer.historyitemactions.HistoryItemPrimaryActionInfo; /** Configures the primary action row (top row) for the bottom sheet. */ Loading @@ -29,13 +31,17 @@ final class PrimaryAction { static HistoryItemPrimaryActionInfo fromRow(Context context, CoalescedRow row) { CharSequence primaryText = CallLogEntryText.buildPrimaryText(context, row); PhotoInfo.Builder photoInfoBuilder = NumberAttributesConverter.toPhotoInfoBuilder(row.numberAttributes()) .setIsVideo((row.features() & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO); if (!TextUtils.isEmpty(row.formattedNumber())) { photoInfoBuilder.setFormattedNumber(row.formattedNumber()); } return HistoryItemPrimaryActionInfo.builder() .setNumber(row.number()) .setPhotoInfo( NumberAttributesConverter.toPhotoInfoBuilder(row.numberAttributes()) .setFormattedNumber(row.formattedNumber()) .setIsVideo((row.features() & Calls.FEATURES_VIDEO) == Calls.FEATURES_VIDEO) .build()) .setPhotoInfo(photoInfoBuilder.build()) .setPrimaryText(primaryText) .setSecondaryText(CallLogEntryText.buildSecondaryTextForBottomSheet(context, row)) .setIntent(CallLogIntents.getCallBackIntent(context, row)) Loading
java/com/android/dialer/calllogutils/NumberAttributesConverter.java +1 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,7 @@ public final class NumberAttributesConverter { /** Converts {@link NumberAttributes} to {@link PhotoInfo.Builder} */ public static PhotoInfo.Builder toPhotoInfoBuilder(NumberAttributes numberAttributes) { return PhotoInfo.builder() return PhotoInfo.newBuilder() .setName(numberAttributes.getName()) .setPhotoUri(numberAttributes.getPhotoUri()) .setPhotoId(numberAttributes.getPhotoId()) Loading
java/com/android/dialer/glidephotomanager/PhotoInfo.javadeleted 100644 → 0 +0 −100 Original line number Diff line number Diff line /* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.dialer.glidephotomanager; import android.support.annotation.Nullable; import com.google.auto.value.AutoValue; /** The number information used to create the photo.. */ @AutoValue public abstract class PhotoInfo { /** The display name of the number */ @Nullable public abstract String name(); /** The number displayed to the user. */ @Nullable public abstract String formattedNumber(); /** The URI to the photo */ @Nullable public abstract String photoUri(); /** Value of {@link android.provider.ContactsContract.CommonDataKinds.Photo#_ID} */ public abstract long photoId(); /** The contacts provider lookup URI for the contact associated with the number */ @Nullable public abstract String lookupUri(); /** Should a business icon be displayed */ public abstract boolean isBusiness(); /** Should a voicemail icon be displayed */ public abstract boolean isVoicemail(); /** Should a blocked icon be displayed */ public abstract boolean isBlocked(); /** Should a spam icon be displayed */ public abstract boolean isSpam(); /** * Should the photo be badged as video call. * * <p>Defaults to false. */ public abstract boolean isVideo(); /** Builder for {@link PhotoInfo} */ @AutoValue.Builder public abstract static class Builder { public abstract Builder setName(@Nullable String name); public abstract Builder setFormattedNumber(@Nullable String formattedNumber); public abstract Builder setPhotoUri(@Nullable String uri); public abstract Builder setPhotoId(long id); public abstract Builder setLookupUri(@Nullable String uri); public abstract Builder setIsBusiness(boolean isBusiness); public abstract Builder setIsVoicemail(boolean isVoicemail); public abstract Builder setIsBlocked(boolean isBlocked); public abstract Builder setIsSpam(boolean isSpam); public abstract Builder setIsVideo(boolean isVideo); public abstract PhotoInfo build(); } public static PhotoInfo.Builder builder() { return new AutoValue_PhotoInfo.Builder() .setPhotoId(0) .setIsBusiness(false) .setIsVoicemail(false) .setIsBlocked(false) .setIsSpam(false) .setIsVideo(false); } }
java/com/android/dialer/glidephotomanager/impl/GlidePhotoManagerImpl.java +16 −14 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ public class GlidePhotoManagerImpl implements GlidePhotoManager { @Override public void loadQuickContactBadge(QuickContactBadge badge, PhotoInfo photoInfo) { Assert.isMainThread(); badge.assignContactUri(parseUri(photoInfo.lookupUri())); badge.assignContactUri(parseUri(photoInfo.getLookupUri())); badge.setOverlay(null); GlideRequest<Drawable> request = buildRequest(GlideApp.with(badge), photoInfo); request.into(badge); Loading @@ -62,20 +62,20 @@ public class GlidePhotoManagerImpl implements GlidePhotoManager { GlideRequest<Drawable> request; boolean circleCrop = true; // Photos are cropped to a circle by default. if (photoInfo.isBlocked()) { if (photoInfo.getIsBlocked()) { // Whether the number is blocked takes precedence over the spam status. request = requestManager.load(R.drawable.ic_block_grey_48dp); } else if (photoInfo.isSpam()) { } else if (photoInfo.getIsSpam()) { request = requestManager.load(R.drawable.quantum_ic_report_vd_red_24); circleCrop = false; // The spam icon is an octagon so we don't crop it. } else if (!TextUtils.isEmpty(photoInfo.photoUri())) { request = requestManager.load(parseUri(photoInfo.photoUri())); } else if (!TextUtils.isEmpty(photoInfo.getPhotoUri())) { request = requestManager.load(parseUri(photoInfo.getPhotoUri())); } else if (photoInfo.photoId() != 0) { } else if (photoInfo.getPhotoId() != 0) { request = requestManager.load(ContentUris.withAppendedId(Data.CONTENT_URI, photoInfo.photoId())); requestManager.load(ContentUris.withAppendedId(Data.CONTENT_URI, photoInfo.getPhotoId())); } else { // load null to indicate fallback should be used. Loading @@ -102,23 +102,25 @@ public class GlidePhotoManagerImpl implements GlidePhotoManager { LetterTileDrawable letterTileDrawable = new LetterTileDrawable(appContext.getResources()); String displayName; String identifier; if (TextUtils.isEmpty(photoInfo.lookupUri())) { if (TextUtils.isEmpty(photoInfo.getLookupUri())) { // Use generic avatar instead of letter for non-contacts. displayName = null; identifier = TextUtils.isEmpty(photoInfo.name()) ? photoInfo.formattedNumber() : photoInfo.name(); TextUtils.isEmpty(photoInfo.getName()) ? photoInfo.getFormattedNumber() : photoInfo.getName(); } else { displayName = photoInfo.name(); identifier = photoInfo.lookupUri(); displayName = photoInfo.getName(); identifier = photoInfo.getLookupUri(); } letterTileDrawable.setCanonicalDialerLetterTileDetails( displayName, identifier, LetterTileDrawable.SHAPE_CIRCLE, LetterTileDrawable.getContactTypeFromPrimitives( photoInfo.isVoicemail(), photoInfo.isSpam(), photoInfo.isBusiness(), photoInfo.getIsVoicemail(), photoInfo.getIsSpam(), photoInfo.getIsBusiness(), TelecomManager.PRESENTATION_ALLOWED, // TODO(twyen):implement false)); // TODO(twyen):implement return letterTileDrawable; Loading