Skip to content

Commit

Permalink
Make avatar in conversation activity tappable
Browse files Browse the repository at this point in the history
Fixes signalapp#7025
// FREEBIE
  • Loading branch information
moxie0 committed Oct 4, 2017
1 parent 5270dad commit 5ad7e3b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions res/layout/conversation_title_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"/>
Expand Down
1 change: 1 addition & 0 deletions src/org/thoughtcrime/securesms/ConversationTitleView.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public void setVerified(boolean verified) {
@Override
public void setOnClickListener(@Nullable OnClickListener listener) {
this.content.setOnClickListener(listener);
this.avatar.setOnClickListener(listener);
}

public void setOnBackClickedListener(@Nullable OnClickListener listener) {
Expand Down
13 changes: 10 additions & 3 deletions src/org/thoughtcrime/securesms/components/AvatarImageView.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
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);
Expand All @@ -35,14 +36,20 @@ public AvatarImageView(Context context, AttributeSet attrs) {
}
}

@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();
setImageDrawable(recipient.getContactPhoto().asDrawable(getContext(), backgroundColor.toConversationColor(getContext()), inverted));
setAvatarClickHandler(recipient, quickContactEnabled);
} else {
setImageDrawable(ContactPhotoFactory.getDefaultContactPhoto(null).asDrawable(getContext(), ContactColors.UNKNOWN_COLOR.toConversationColor(getContext()), inverted));
setOnClickListener(null);
super.setOnClickListener(listener);
}
}

Expand All @@ -66,7 +73,7 @@ public void onClick(View v) {
}
});
} else {
setOnClickListener(null);
super.setOnClickListener(listener);
}
}
}

0 comments on commit 5ad7e3b

Please sign in to comment.