From 2c85995b62d919a4a5fd03979b305e4485a2c4be Mon Sep 17 00:00:00 2001 From: linyuh Date: Wed, 21 Feb 2018 14:45:47 -0800 Subject: Use the vector spam icon in the new call log. Bug: 73123894 Test: GlidePhotoManagerImplTest PiperOrigin-RevId: 186522766 Change-Id: I3950071e6af492e07972619a4933231b4341aaf4 --- .../dialer/glidephotomanager/PhotoInfo.java | 10 ---- .../impl/GlidePhotoManagerImpl.java | 55 +++++++++++++--------- .../impl/res/drawable/ic_report_red_48dp.xml | 36 -------------- 3 files changed, 32 insertions(+), 69 deletions(-) delete mode 100644 java/com/android/dialer/glidephotomanager/impl/res/drawable/ic_report_red_48dp.xml (limited to 'java/com/android/dialer/glidephotomanager') diff --git a/java/com/android/dialer/glidephotomanager/PhotoInfo.java b/java/com/android/dialer/glidephotomanager/PhotoInfo.java index e4dd87152..016221f40 100644 --- a/java/com/android/dialer/glidephotomanager/PhotoInfo.java +++ b/java/com/android/dialer/glidephotomanager/PhotoInfo.java @@ -61,13 +61,6 @@ public abstract class PhotoInfo { */ public abstract boolean isVideo(); - /** - * Should the result be circularized. - * - *

Defaults to true. - */ - public abstract boolean isCircular(); - /** Builder for {@link PhotoInfo} */ @AutoValue.Builder public abstract static class Builder { @@ -92,8 +85,6 @@ public abstract class PhotoInfo { public abstract Builder setIsVideo(boolean isVideo); - public abstract Builder setIsCircular(boolean isCircular); - public abstract PhotoInfo build(); } @@ -104,7 +95,6 @@ public abstract class PhotoInfo { .setIsVoicemail(false) .setIsBlocked(false) .setIsSpam(false) - .setIsCircular(true) .setIsVideo(false); } } diff --git a/java/com/android/dialer/glidephotomanager/impl/GlidePhotoManagerImpl.java b/java/com/android/dialer/glidephotomanager/impl/GlidePhotoManagerImpl.java index 10c4dfb4c..e14e604a1 100644 --- a/java/com/android/dialer/glidephotomanager/impl/GlidePhotoManagerImpl.java +++ b/java/com/android/dialer/glidephotomanager/impl/GlidePhotoManagerImpl.java @@ -51,16 +51,7 @@ public class GlidePhotoManagerImpl implements GlidePhotoManager { Assert.isMainThread(); badge.assignContactUri(parseUri(photoInfo.lookupUri())); badge.setOverlay(null); - LetterTileDrawable defaultDrawable = getDefaultDrawable(photoInfo); - GlideRequest request = - buildRequest(GlideApp.with(badge), photoInfo) - .placeholder(defaultDrawable) // when the photo is still loading. - .fallback(defaultDrawable); // when there's nothing to load. - - if (photoInfo.isCircular()) { - request.circleCrop(); - } - + GlideRequest request = buildRequest(GlideApp.with(badge), photoInfo); request.into(badge); } @@ -68,21 +59,39 @@ public class GlidePhotoManagerImpl implements GlidePhotoManager { // Warning: Glide ignores extra attributes on BitmapDrawable such as tint and draw the bitmap // directly so be sure not to set tint in the XML of any drawable referenced below. - // Whether the number is blocked takes precedence over the spam status. + GlideRequest request; + boolean circleCrop = true; // Photos are cropped to a circle by default. + if (photoInfo.isBlocked()) { - return requestManager.load(R.drawable.ic_block_grey_48dp); - } - if (photoInfo.isSpam()) { - return requestManager.load(R.drawable.ic_report_red_48dp); - } - if (!TextUtils.isEmpty(photoInfo.photoUri())) { - return requestManager.load(parseUri(photoInfo.photoUri())); + // Whether the number is blocked takes precedence over the spam status. + request = requestManager.load(R.drawable.ic_block_grey_48dp); + + } else if (photoInfo.isSpam()) { + 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 (photoInfo.photoId() != 0) { + request = + requestManager.load(ContentUris.withAppendedId(Data.CONTENT_URI, photoInfo.photoId())); + + } else { + // load null to indicate fallback should be used. + request = requestManager.load((Object) null); } - if (photoInfo.photoId() != 0) { - return requestManager.load(ContentUris.withAppendedId(Data.CONTENT_URI, photoInfo.photoId())); + + LetterTileDrawable defaultDrawable = getDefaultDrawable(photoInfo); + request + .placeholder(defaultDrawable) // when the photo is still loading. + .fallback(defaultDrawable); // when there's nothing to load. + + if (circleCrop) { + request.circleCrop(); } - // load null to indicate fallback should be used. - return requestManager.load((Object) null); + + return request; } /** @@ -108,7 +117,7 @@ public class GlidePhotoManagerImpl implements GlidePhotoManager { LetterTileDrawable.SHAPE_CIRCLE, LetterTileDrawable.getContactTypeFromPrimitives( photoInfo.isVoicemail(), - false, // TODO(twyen):implement + photoInfo.isSpam(), photoInfo.isBusiness(), TelecomManager.PRESENTATION_ALLOWED, // TODO(twyen):implement false)); // TODO(twyen):implement diff --git a/java/com/android/dialer/glidephotomanager/impl/res/drawable/ic_report_red_48dp.xml b/java/com/android/dialer/glidephotomanager/impl/res/drawable/ic_report_red_48dp.xml deleted file mode 100644 index 8a1ddcd99..000000000 --- a/java/com/android/dialer/glidephotomanager/impl/res/drawable/ic_report_red_48dp.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file -- cgit v1.2.3