Make avatar in conversation activity tappable

Fixes #7025
// FREEBIE
This commit is contained in:
Moxie Marlinspike 2017-10-04 14:04:04 -07:00
parent 5270dad789
commit 5ad7e3b48a
3 changed files with 14 additions and 3 deletions

View File

@ -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"/>

View File

@ -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) {

View File

@ -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);
}
}
}