mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-25 19:29:54 +01:00
Blur avatar photos from unknown senders when in message request state.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package org.thoughtcrime.securesms.conversation;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
@@ -9,11 +11,15 @@ import android.widget.TextView;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.core.widget.ImageViewCompat;
|
||||
|
||||
import org.signal.core.util.concurrent.SignalExecutors;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.components.AvatarImageView;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.FallbackContactPhoto;
|
||||
import org.thoughtcrime.securesms.contacts.avatars.ResourceContactPhoto;
|
||||
import org.thoughtcrime.securesms.database.DatabaseFactory;
|
||||
import org.thoughtcrime.securesms.mms.GlideRequests;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
|
||||
@@ -24,6 +30,7 @@ public class ConversationBannerView extends ConstraintLayout {
|
||||
private TextView contactAbout;
|
||||
private TextView contactSubtitle;
|
||||
private TextView contactDescription;
|
||||
private View tapToView;
|
||||
|
||||
public ConversationBannerView(Context context) {
|
||||
this(context, null);
|
||||
@@ -43,12 +50,28 @@ public class ConversationBannerView extends ConstraintLayout {
|
||||
contactAbout = findViewById(R.id.message_request_about);
|
||||
contactSubtitle = findViewById(R.id.message_request_subtitle);
|
||||
contactDescription = findViewById(R.id.message_request_description);
|
||||
tapToView = findViewById(R.id.message_request_avatar_tap_to_view);
|
||||
|
||||
contactAvatar.setFallbackPhotoProvider(new FallbackPhotoProvider());
|
||||
}
|
||||
|
||||
public void setAvatar(@NonNull GlideRequests requests, @Nullable Recipient recipient) {
|
||||
contactAvatar.setAvatar(requests, recipient, false);
|
||||
|
||||
if (recipient.shouldBlurAvatar() && recipient.getContactPhoto() != null) {
|
||||
tapToView.setVisibility(VISIBLE);
|
||||
tapToView.setOnClickListener(v -> {
|
||||
SignalExecutors.BOUNDED.execute(() -> DatabaseFactory.getRecipientDatabase(getContext().getApplicationContext())
|
||||
.manuallyShowAvatar(recipient.getId()));
|
||||
});
|
||||
ImageViewCompat.setImageTintList(contactAvatar, ColorStateList.valueOf(ContextCompat.getColor(getContext(), R.color.transparent_black_40)));
|
||||
ImageViewCompat.setImageTintMode(contactAvatar, PorterDuff.Mode.SRC_ATOP);
|
||||
} else {
|
||||
tapToView.setVisibility(GONE);
|
||||
tapToView.setOnClickListener(null);
|
||||
ImageViewCompat.setImageTintList(contactAvatar, null);
|
||||
ImageViewCompat.setImageTintMode(contactAvatar, PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
}
|
||||
|
||||
public void setTitle(@Nullable CharSequence title) {
|
||||
|
||||
Reference in New Issue
Block a user