diff options
10 files changed, 47 insertions, 43 deletions
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/CommentUserNoteBlock.java b/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/CommentUserNoteBlock.java index d80e2396b..6e6d543da 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/CommentUserNoteBlock.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/CommentUserNoteBlock.java @@ -5,16 +5,14 @@ import android.text.TextUtils; import android.view.View; import android.widget.TextView; -import com.android.volley.toolbox.NetworkImageView; - import org.json.JSONException; import org.json.JSONObject; import org.wordpress.android.R; -import org.wordpress.android.WordPress; import org.wordpress.android.models.CommentStatus; import org.wordpress.android.ui.notifications.utils.NotificationsUtils; import org.wordpress.android.util.DateTimeUtils; import org.wordpress.android.util.PhotonUtils; +import org.wordpress.android.widgets.WPNetworkImageView; // A user block with slightly different formatting for display in a comment detail public class CommentUserNoteBlock extends UserNoteBlock { @@ -73,7 +71,7 @@ public class CommentUserNoteBlock extends UserNoteBlock { if (hasImageMediaItem()) { String imageUrl = PhotonUtils.fixAvatar(getNoteMediaItem().optString("url", ""), getAvatarSize()); - noteBlockHolder.avatarImageView.setImageUrl(imageUrl, WordPress.imageLoader); + noteBlockHolder.avatarImageView.setImageUrl(imageUrl, WPNetworkImageView.ImageType.AVATAR); if (!TextUtils.isEmpty(getUserUrl())) { noteBlockHolder.avatarImageView.setOnTouchListener(mOnGravatarTouchListener); } else { @@ -161,7 +159,7 @@ public class CommentUserNoteBlock extends UserNoteBlock { } private class CommentUserNoteBlockHolder { - private final NetworkImageView avatarImageView; + private final WPNetworkImageView avatarImageView; private final TextView nameTextView; private final TextView agoTextView; private final TextView bulletTextView; @@ -177,7 +175,7 @@ public class CommentUserNoteBlock extends UserNoteBlock { siteTextView = (TextView)view.findViewById(R.id.user_comment_site); commentTextView = (TextView)view.findViewById(R.id.user_comment); commentTextView.setMovementMethod(new NoteBlockLinkMovementMethod()); - avatarImageView = (NetworkImageView)view.findViewById(R.id.user_avatar); + avatarImageView = (WPNetworkImageView)view.findViewById(R.id.user_avatar); dividerView = view.findViewById(R.id.divider_view); siteTextView.setOnClickListener(new View.OnClickListener() { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/HeaderUserNoteBlock.java b/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/HeaderUserNoteBlock.java index 2d28e150d..ca061b8fa 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/HeaderUserNoteBlock.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/HeaderUserNoteBlock.java @@ -7,14 +7,12 @@ import android.view.View; import android.view.animation.DecelerateInterpolator; import android.widget.TextView; -import com.android.volley.toolbox.NetworkImageView; - import org.json.JSONArray; import org.json.JSONObject; import org.wordpress.android.R; -import org.wordpress.android.WordPress; import org.wordpress.android.util.JSONUtil; import org.wordpress.android.util.PhotonUtils; +import org.wordpress.android.widgets.WPNetworkImageView; // Note header, displayed at top of detail view public class HeaderUserNoteBlock extends NoteBlock { @@ -52,7 +50,7 @@ public class HeaderUserNoteBlock extends NoteBlock { final NoteHeaderBlockHolder noteBlockHolder = (NoteHeaderBlockHolder)view.getTag(); noteBlockHolder.nameTextView.setText(getUserName()); - noteBlockHolder.avatarImageView.setImageUrl(getAvatarUrl(), WordPress.imageLoader); + noteBlockHolder.avatarImageView.setImageUrl(getAvatarUrl(), WPNetworkImageView.ImageType.AVATAR); if (!TextUtils.isEmpty(getUserUrl())) { noteBlockHolder.avatarImageView.setOnTouchListener(mOnGravatarTouchListener); } else { @@ -108,14 +106,14 @@ public class HeaderUserNoteBlock extends NoteBlock { private class NoteHeaderBlockHolder { private final TextView nameTextView; private final TextView snippetTextView; - private final NetworkImageView avatarImageView; + private final WPNetworkImageView avatarImageView; public NoteHeaderBlockHolder(View view) { View rootView = view.findViewById(R.id.header_root_view); rootView.setOnClickListener(mOnClickListener); nameTextView = (TextView)view.findViewById(R.id.header_user); snippetTextView = (TextView)view.findViewById(R.id.header_snippet); - avatarImageView = (NetworkImageView)view.findViewById(R.id.header_avatar); + avatarImageView = (WPNetworkImageView)view.findViewById(R.id.header_avatar); } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/UserNoteBlock.java b/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/UserNoteBlock.java index 335016ea6..3c24a17bb 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/UserNoteBlock.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/blocks/UserNoteBlock.java @@ -7,19 +7,12 @@ import android.view.View; import android.view.animation.DecelerateInterpolator; import android.widget.TextView; -import com.android.volley.toolbox.NetworkImageView; - -import org.json.JSONArray; -import org.json.JSONException; import org.json.JSONObject; import org.wordpress.android.R; -import org.wordpress.android.WordPress; import org.wordpress.android.ui.notifications.NotificationsConstants; -import org.wordpress.android.ui.notifications.utils.NotificationsUtils; -import org.wordpress.android.util.AppLog; import org.wordpress.android.util.JSONUtil; import org.wordpress.android.util.PhotonUtils; -import org.wordpress.android.util.UrlUtils; +import org.wordpress.android.widgets.WPNetworkImageView; /** * A block that displays information about a User (such as a user that liked a post) @@ -93,7 +86,7 @@ public class UserNoteBlock extends NoteBlock { if (hasImageMediaItem()) { String imageUrl = PhotonUtils.fixAvatar(getNoteMediaItem().optString("url", ""), getAvatarSize()); - noteBlockHolder.avatarImageView.setImageUrl(imageUrl, WordPress.imageLoader); + noteBlockHolder.avatarImageView.setImageUrl(imageUrl, WPNetworkImageView.ImageType.AVATAR); if (!TextUtils.isEmpty(getUserUrl())) { noteBlockHolder.avatarImageView.setOnTouchListener(mOnGravatarTouchListener); noteBlockHolder.rootView.setBackgroundResource(R.drawable.notifications_header_selector); @@ -128,14 +121,14 @@ public class UserNoteBlock extends NoteBlock { private final TextView nameTextView; private final TextView urlTextView; private final TextView taglineTextView; - private final NetworkImageView avatarImageView; + private final WPNetworkImageView avatarImageView; public UserActionNoteBlockHolder(View view) { rootView = view.findViewById(R.id.user_block_root_view); nameTextView = (TextView)view.findViewById(R.id.user_name); urlTextView = (TextView)view.findViewById(R.id.user_blog_url); taglineTextView = (TextView)view.findViewById(R.id.user_blog_tagline); - avatarImageView = (NetworkImageView)view.findViewById(R.id.user_avatar); + avatarImageView = (WPNetworkImageView)view.findViewById(R.id.user_avatar); } } diff --git a/WordPress/src/main/java/org/wordpress/android/widgets/WPNetworkImageView.java b/WordPress/src/main/java/org/wordpress/android/widgets/WPNetworkImageView.java index a3fb6c8a8..1969054b4 100644 --- a/WordPress/src/main/java/org/wordpress/android/widgets/WPNetworkImageView.java +++ b/WordPress/src/main/java/org/wordpress/android/widgets/WPNetworkImageView.java @@ -2,7 +2,10 @@ package org.wordpress.android.widgets; import android.animation.ObjectAnimator; import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.graphics.Point; +import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.ColorDrawable; import android.os.Handler; import android.text.TextUtils; @@ -20,6 +23,7 @@ import org.wordpress.android.datasets.ReaderThumbnailTable; import org.wordpress.android.ui.reader.utils.ReaderVideoUtils; import org.wordpress.android.util.AppLog; import org.wordpress.android.util.DisplayUtils; +import org.wordpress.android.util.ImageUtils; import org.wordpress.android.util.VolleyUtils; /** @@ -234,7 +238,14 @@ public class WPNetworkImageView extends ImageView { boolean isCached, boolean allowFadeIn) { if (response.getBitmap() != null) { - setImageBitmap(response.getBitmap()); + Bitmap bitmap = response.getBitmap(); + + // Apply circular rounding to avatars + if (mImageType == ImageType.AVATAR) { + bitmap = ImageUtils.getCircularBitmap(bitmap); + } + + setImageBitmap(bitmap); // fade in photos/videos if not cached (not used for other image types since animation can be expensive) if (!isCached && allowFadeIn && canFadeInImageType(mImageType)) @@ -288,6 +299,10 @@ public class WPNetworkImageView extends ImageView { // null default for mshots setImageDrawable(null); break; + case AVATAR: + // Grey circle for avatars + setImageResource(R.drawable.shape_oval_grey_light); + break; default : // light grey box for all others setImageDrawable(new ColorDrawable(getColorRes(R.color.grey_light))); @@ -301,8 +316,14 @@ public class WPNetworkImageView extends ImageView { // do nothing break; case AVATAR: - // "mystery man" for failed avatars - setImageResource(R.drawable.gravatar_placeholder); + if (getContext() == null) break; + // "mystery man" (circular) for failed avatars + setImageBitmap(ImageUtils.getCircularBitmap( + BitmapFactory.decodeResource( + getContext().getResources(), + R.drawable.gravatar_placeholder + ) + )); break; default : // medium grey box for all others diff --git a/WordPress/src/main/res/drawable/shape_oval_grey_light.xml b/WordPress/src/main/res/drawable/shape_oval_grey_light.xml new file mode 100644 index 000000000..b474551c5 --- /dev/null +++ b/WordPress/src/main/res/drawable/shape_oval_grey_light.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" > + <solid android:color="@color/grey_light" /> +</shape>
\ No newline at end of file diff --git a/WordPress/src/main/res/layout/note_block_comment_user.xml b/WordPress/src/main/res/layout/note_block_comment_user.xml index d8c09b509..dfe5b5540 100644 --- a/WordPress/src/main/res/layout/note_block_comment_user.xml +++ b/WordPress/src/main/res/layout/note_block_comment_user.xml @@ -8,12 +8,11 @@ android:paddingRight="@dimen/margin_extra_large" android:paddingTop="@dimen/comment_avatar_margin_top"> - <com.android.volley.toolbox.NetworkImageView + <org.wordpress.android.widgets.WPNetworkImageView android:id="@+id/user_avatar" android:layout_width="@dimen/avatar_sz_small" android:layout_height="@dimen/avatar_sz_small" - android:layout_marginTop="@dimen/comment_avatar_margin_top" - android:background="@color/grey_light" /> + android:layout_marginTop="@dimen/comment_avatar_margin_top" /> <RelativeLayout android:id="@+id/user_name_wrapper" diff --git a/WordPress/src/main/res/layout/note_block_user.xml b/WordPress/src/main/res/layout/note_block_user.xml index 1348ff0df..e40175402 100644 --- a/WordPress/src/main/res/layout/note_block_user.xml +++ b/WordPress/src/main/res/layout/note_block_user.xml @@ -17,13 +17,12 @@ android:paddingBottom="@dimen/margin_medium" android:paddingTop="@dimen/margin_medium"> - <com.android.volley.toolbox.NetworkImageView + <org.wordpress.android.widgets.WPNetworkImageView android:id="@+id/user_avatar" android:layout_width="@dimen/avatar_sz_medium" android:layout_height="@dimen/avatar_sz_medium" android:layout_gravity="center_vertical" - android:layout_marginRight="@dimen/notifications_adjusted_font_margin" - android:background="@color/grey_light" /> + android:layout_marginRight="@dimen/notifications_adjusted_font_margin" /> <LinearLayout android:layout_width="fill_parent" diff --git a/WordPress/src/main/res/layout/note_block_user_header.xml b/WordPress/src/main/res/layout/note_block_user_header.xml index cf1603613..b15df7875 100644 --- a/WordPress/src/main/res/layout/note_block_user_header.xml +++ b/WordPress/src/main/res/layout/note_block_user_header.xml @@ -17,13 +17,12 @@ android:paddingRight="@dimen/margin_extra_large" android:paddingTop="@dimen/comment_avatar_margin_top"> - <com.android.volley.toolbox.NetworkImageView + <org.wordpress.android.widgets.WPNetworkImageView android:id="@+id/header_avatar" android:layout_width="@dimen/avatar_sz_small" android:layout_height="@dimen/avatar_sz_small" android:layout_marginRight="@dimen/notifications_adjusted_font_margin" - android:layout_marginTop="@dimen/comment_avatar_margin_top" - android:background="@color/grey_light" /> + android:layout_marginTop="@dimen/comment_avatar_margin_top" /> <org.wordpress.android.widgets.WPTextView android:id="@+id/header_user" diff --git a/WordPress/src/main/res/layout/reader_include_post_detail.xml b/WordPress/src/main/res/layout/reader_include_post_detail.xml index 82e22b7b3..504455f12 100644 --- a/WordPress/src/main/res/layout/reader_include_post_detail.xml +++ b/WordPress/src/main/res/layout/reader_include_post_detail.xml @@ -29,8 +29,7 @@ <org.wordpress.android.widgets.WPNetworkImageView android:id="@+id/image_avatar" style="@style/ReaderImageView.Avatar" - android:layout_marginRight="@dimen/margin_large" - android:background="@color/grey_extra_light" /> + android:layout_marginRight="@dimen/margin_large" /> <LinearLayout android:layout_width="0dp" diff --git a/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/ImageUtils.java b/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/ImageUtils.java index 10c6fb478..fdba9fe5a 100644 --- a/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/ImageUtils.java +++ b/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/ImageUtils.java @@ -528,12 +528,6 @@ public class ImageUtils { paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); - // outline - paint.setStyle(Paint.Style.STROKE); - paint.setStrokeWidth(1f); - paint.setColor(Color.DKGRAY); - canvas.drawOval(rectF, paint); - return output; } |