mirror of
https://github.com/oxen-io/session-android.git
synced 2025-04-21 07:51:31 +00:00
Fix icon in notification.
This commit is contained in:
parent
5038dec3d1
commit
88234c26a3
@ -108,12 +108,6 @@ public class AvatarImageView extends AppCompatImageView {
|
|||||||
super.setOnClickListener(listener);
|
super.setOnClickListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
|
||||||
super.onSizeChanged(w, h, oldw, oldh);
|
|
||||||
if (recipientContactPhoto != null) { updateAvatar(recipientContactPhoto.recipient); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(String hexEncodedPublicKey) {
|
public void update(String hexEncodedPublicKey) {
|
||||||
Address address = Address.fromSerialized(hexEncodedPublicKey);
|
Address address = Address.fromSerialized(hexEncodedPublicKey);
|
||||||
Recipient recipient = Recipient.from(getContext(), address, false);
|
Recipient recipient = Recipient.from(getContext(), address, false);
|
||||||
@ -144,7 +138,6 @@ public class AvatarImageView extends AppCompatImageView {
|
|||||||
setImageDrawable(fallbackContactPhotoDrawable);
|
setImageDrawable(fallbackContactPhotoDrawable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setAvatarClickHandler(recipient, quickContactEnabled);
|
|
||||||
} else {
|
} else {
|
||||||
recipientContactPhoto = null;
|
recipientContactPhoto = null;
|
||||||
requestManager.clear(this);
|
requestManager.clear(this);
|
||||||
|
@ -4,6 +4,13 @@ import android.app.Notification;
|
|||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.PorterDuffXfermode;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
import android.graphics.RectF;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@ -237,11 +244,34 @@ public class SingleRecipientNotificationBuilder extends AbstractNotificationBuil
|
|||||||
Bitmap recipientPhotoBitmap = BitmapUtil.createFromDrawable(drawable, largeIconTargetSize, largeIconTargetSize);
|
Bitmap recipientPhotoBitmap = BitmapUtil.createFromDrawable(drawable, largeIconTargetSize, largeIconTargetSize);
|
||||||
|
|
||||||
if (recipientPhotoBitmap != null) {
|
if (recipientPhotoBitmap != null) {
|
||||||
setLargeIcon(recipientPhotoBitmap);
|
setLargeIcon(getCircleBitmap(recipientPhotoBitmap));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Bitmap getCircleBitmap(Bitmap bitmap) {
|
||||||
|
final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
|
||||||
|
bitmap.getHeight(), Bitmap.Config.ARGB_8888);
|
||||||
|
final Canvas canvas = new Canvas(output);
|
||||||
|
|
||||||
|
final int color = Color.RED;
|
||||||
|
final Paint paint = new Paint();
|
||||||
|
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
|
||||||
|
final RectF rectF = new RectF(rect);
|
||||||
|
|
||||||
|
paint.setAntiAlias(true);
|
||||||
|
canvas.drawARGB(0, 0, 0, 0);
|
||||||
|
paint.setColor(color);
|
||||||
|
canvas.drawOval(rectF, paint);
|
||||||
|
|
||||||
|
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
|
||||||
|
canvas.drawBitmap(bitmap, rect, rect, paint);
|
||||||
|
|
||||||
|
bitmap.recycle();
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean hasBigPictureSlide(@Nullable SlideDeck slideDeck) {
|
private boolean hasBigPictureSlide(@Nullable SlideDeck slideDeck) {
|
||||||
if (slideDeck == null) {
|
if (slideDeck == null) {
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user