mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 20:18:36 +00:00
Remove outline on generated call link preview.
This commit is contained in:
committed by
Greyson Parrelli
parent
9a72833e06
commit
29ead80e17
@@ -220,6 +220,7 @@ public class LinkPreviewView extends FrameLayout {
|
|||||||
thumbnailState.applyState(thumbnail);
|
thumbnailState.applyState(thumbnail);
|
||||||
thumbnail.get().setImageResource(requestManager, new ImageSlide(linkPreview.getThumbnail().get()), type == TYPE_CONVERSATION && !scheduleMessageMode, false);
|
thumbnail.get().setImageResource(requestManager, new ImageSlide(linkPreview.getThumbnail().get()), type == TYPE_CONVERSATION && !scheduleMessageMode, false);
|
||||||
thumbnail.get().showSecondaryText(false);
|
thumbnail.get().showSecondaryText(false);
|
||||||
|
thumbnail.get().setOutlineEnabled(true);
|
||||||
} else if (callLinkRootKey != null) {
|
} else if (callLinkRootKey != null) {
|
||||||
thumbnail.setVisibility(VISIBLE);
|
thumbnail.setVisibility(VISIBLE);
|
||||||
thumbnailState.applyState(thumbnail);
|
thumbnailState.applyState(thumbnail);
|
||||||
@@ -228,9 +229,10 @@ public class LinkPreviewView extends FrameLayout {
|
|||||||
new FallbackAvatarDrawable(
|
new FallbackAvatarDrawable(
|
||||||
getContext(),
|
getContext(),
|
||||||
new FallbackAvatar.Resource.CallLink(AvatarColorHash.forCallLink(callLinkRootKey.getKeyBytes()))
|
new FallbackAvatar.Resource.CallLink(AvatarColorHash.forCallLink(callLinkRootKey.getKeyBytes()))
|
||||||
)
|
).circleCrop()
|
||||||
);
|
);
|
||||||
thumbnail.get().showSecondaryText(false);
|
thumbnail.get().showSecondaryText(false);
|
||||||
|
thumbnail.get().setOutlineEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
thumbnail.setVisibility(GONE);
|
thumbnail.setVisibility(GONE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,17 +3,25 @@ package org.thoughtcrime.securesms.components;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Parcelable;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.core.os.BundleCompat;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.R;
|
import org.thoughtcrime.securesms.R;
|
||||||
|
|
||||||
public class OutlinedThumbnailView extends ThumbnailView {
|
public class OutlinedThumbnailView extends ThumbnailView {
|
||||||
|
|
||||||
|
private static final String STATE_OUTLINE_ENABLED = "state.outline.enabled";
|
||||||
|
private static final String STATE_ROOT = "state.root";
|
||||||
|
|
||||||
private CornerMask cornerMask;
|
private CornerMask cornerMask;
|
||||||
private Outliner outliner;
|
private Outliner outliner;
|
||||||
|
private boolean isOutlineEnabled;
|
||||||
|
|
||||||
public OutlinedThumbnailView(Context context) {
|
public OutlinedThumbnailView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@@ -52,9 +60,39 @@ public class OutlinedThumbnailView extends ThumbnailView {
|
|||||||
protected void dispatchDraw(Canvas canvas) {
|
protected void dispatchDraw(Canvas canvas) {
|
||||||
super.dispatchDraw(canvas);
|
super.dispatchDraw(canvas);
|
||||||
|
|
||||||
|
if (isOutlineEnabled) {
|
||||||
cornerMask.mask(canvas);
|
cornerMask.mask(canvas);
|
||||||
outliner.draw(canvas);
|
outliner.draw(canvas);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected @NonNull Parcelable onSaveInstanceState() {
|
||||||
|
Parcelable root = super.onSaveInstanceState();
|
||||||
|
Bundle state = new Bundle();
|
||||||
|
|
||||||
|
state.putParcelable(STATE_ROOT, root);
|
||||||
|
state.putBoolean(STATE_OUTLINE_ENABLED, isOutlineEnabled);
|
||||||
|
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onRestoreInstanceState(Parcelable state) {
|
||||||
|
if (state instanceof Bundle) {
|
||||||
|
Parcelable root = BundleCompat.getParcelable((Bundle) state, STATE_ROOT, Parcelable.class);
|
||||||
|
|
||||||
|
this.isOutlineEnabled = ((Bundle) state).getBoolean(STATE_OUTLINE_ENABLED, true);
|
||||||
|
super.onRestoreInstanceState(root);
|
||||||
|
} else {
|
||||||
|
super.onRestoreInstanceState(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOutlineEnabled(boolean isOutlineEnabled) {
|
||||||
|
this.isOutlineEnabled = isOutlineEnabled;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
public void setCorners(int topLeft, int topRight, int bottomRight, int bottomLeft) {
|
public void setCorners(int topLeft, int topRight, int bottomRight, int bottomLeft) {
|
||||||
cornerMask.setRadii(topLeft, topRight, bottomRight, bottomLeft);
|
cornerMask.setRadii(topLeft, topRight, bottomRight, bottomLeft);
|
||||||
|
|||||||
Reference in New Issue
Block a user