From 5ad7e3b48afce9be8f8352013089b687e7051c7f Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Wed, 4 Oct 2017 14:04:04 -0700 Subject: [PATCH] Make avatar in conversation activity tappable Fixes #7025 // FREEBIE --- res/layout/conversation_title_view.xml | 3 +++ .../securesms/ConversationTitleView.java | 1 + .../securesms/components/AvatarImageView.java | 13 ++++++++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/res/layout/conversation_title_view.xml b/res/layout/conversation_title_view.xml index a9b70ff49e..45133bc685 100644 --- a/res/layout/conversation_title_view.xml +++ b/res/layout/conversation_title_view.xml @@ -13,6 +13,8 @@ android:layout_height="wrap_content" android:src="@drawable/ic_arrow_back_white_24dp" android:clickable="true" + android:paddingRight="15dp" + android:paddingEnd="15dp" android:layout_marginRight="15dp" android:layout_marginEnd="15dp" android:layout_alignParentLeft="true" @@ -32,6 +34,7 @@ android:layout_marginEnd="10dp" android:cropToPadding="true" android:transitionName="contact_photo" + android:clickable="true" app:inverted="true" tools:src="@drawable/ic_contact_picture" android:contentDescription="@string/conversation_list_item_view__contact_photo_image"/> diff --git a/src/org/thoughtcrime/securesms/ConversationTitleView.java b/src/org/thoughtcrime/securesms/ConversationTitleView.java index 6975910a85..cad04fa5b2 100644 --- a/src/org/thoughtcrime/securesms/ConversationTitleView.java +++ b/src/org/thoughtcrime/securesms/ConversationTitleView.java @@ -80,6 +80,7 @@ public class ConversationTitleView extends RelativeLayout { @Override public void setOnClickListener(@Nullable OnClickListener listener) { this.content.setOnClickListener(listener); + this.avatar.setOnClickListener(listener); } public void setOnBackClickedListener(@Nullable OnClickListener listener) { diff --git a/src/org/thoughtcrime/securesms/components/AvatarImageView.java b/src/org/thoughtcrime/securesms/components/AvatarImageView.java index 9c77299455..1b2ac07b32 100644 --- a/src/org/thoughtcrime/securesms/components/AvatarImageView.java +++ b/src/org/thoughtcrime/securesms/components/AvatarImageView.java @@ -15,9 +15,10 @@ import org.thoughtcrime.securesms.contacts.avatars.ContactColors; import org.thoughtcrime.securesms.contacts.avatars.ContactPhotoFactory; import org.thoughtcrime.securesms.recipients.Recipient; -public class AvatarImageView extends ImageView { +public class AvatarImageView extends android.support.v7.widget.AppCompatImageView { private boolean inverted; + private OnClickListener listener = null; public AvatarImageView(Context context) { super(context); @@ -35,6 +36,12 @@ public class AvatarImageView extends ImageView { } } + @Override + public void setOnClickListener(OnClickListener listener) { + this.listener = listener; + super.setOnClickListener(listener); + } + public void setAvatar(final @Nullable Recipient recipient, boolean quickContactEnabled) { if (recipient != null) { MaterialColor backgroundColor = recipient.getColor(); @@ -42,7 +49,7 @@ public class AvatarImageView extends ImageView { setAvatarClickHandler(recipient, quickContactEnabled); } else { setImageDrawable(ContactPhotoFactory.getDefaultContactPhoto(null).asDrawable(getContext(), ContactColors.UNKNOWN_COLOR.toConversationColor(getContext()), inverted)); - setOnClickListener(null); + super.setOnClickListener(listener); } } @@ -66,7 +73,7 @@ public class AvatarImageView extends ImageView { } }); } else { - setOnClickListener(null); + super.setOnClickListener(listener); } } }