mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-19 14:37:32 +00:00
94 lines
2.9 KiB
Java
94 lines
2.9 KiB
Java
package org.thoughtcrime.securesms.components;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.TypedArray;
|
|
import android.graphics.Canvas;
|
|
import android.net.Uri;
|
|
import android.support.annotation.NonNull;
|
|
import android.support.annotation.UiThread;
|
|
import android.util.AttributeSet;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.ImageView;
|
|
|
|
import com.bumptech.glide.RequestBuilder;
|
|
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
|
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
|
|
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
|
import com.bumptech.glide.load.resource.bitmap.FitCenter;
|
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
|
|
import com.bumptech.glide.request.RequestOptions;
|
|
|
|
import org.thoughtcrime.securesms.R;
|
|
import org.thoughtcrime.securesms.database.AttachmentDatabase;
|
|
import org.thoughtcrime.securesms.logging.Log;
|
|
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri;
|
|
import org.thoughtcrime.securesms.mms.GlideRequest;
|
|
import org.thoughtcrime.securesms.mms.GlideRequests;
|
|
import org.thoughtcrime.securesms.mms.Slide;
|
|
import org.thoughtcrime.securesms.mms.SlideClickListener;
|
|
import org.thoughtcrime.securesms.mms.SlidesClickedListener;
|
|
import org.thoughtcrime.securesms.util.ThemeUtil;
|
|
import org.thoughtcrime.securesms.util.Util;
|
|
import org.thoughtcrime.securesms.util.ViewUtil;
|
|
import org.thoughtcrime.securesms.util.concurrent.ListenableFuture;
|
|
import org.thoughtcrime.securesms.util.concurrent.SettableFuture;
|
|
import org.whispersystems.libsignal.util.guava.Optional;
|
|
|
|
import java.util.Collections;
|
|
import java.util.Locale;
|
|
|
|
import static com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions.withCrossFade;
|
|
|
|
public class OutlinedThumbnailView extends ThumbnailView {
|
|
|
|
private CornerMask cornerMask;
|
|
private Outliner outliner;
|
|
|
|
public OutlinedThumbnailView(Context context) {
|
|
super(context);
|
|
init();
|
|
}
|
|
|
|
public OutlinedThumbnailView(Context context, AttributeSet attrs) {
|
|
super(context, attrs);
|
|
init();
|
|
}
|
|
|
|
private void init() {
|
|
cornerMask = new CornerMask(this);
|
|
outliner = new Outliner();
|
|
|
|
outliner.setColor(ThemeUtil.getThemedColor(getContext(), R.attr.conversation_item_image_outline_color));
|
|
setRadius(0);
|
|
setWillNotDraw(false);
|
|
}
|
|
|
|
@Override
|
|
protected void onDraw(Canvas canvas) {
|
|
super.onDraw(canvas);
|
|
|
|
if (cornerMask.isLegacy()) {
|
|
cornerMask.mask(canvas);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected void dispatchDraw(Canvas canvas) {
|
|
super.dispatchDraw(canvas);
|
|
|
|
if (!cornerMask.isLegacy()) {
|
|
cornerMask.mask(canvas);
|
|
}
|
|
|
|
outliner.draw(canvas);
|
|
}
|
|
|
|
public void setCorners(int topLeft, int topRight, int bottomRight, int bottomLeft) {
|
|
cornerMask.setRadii(topLeft, topRight, bottomRight, bottomLeft);
|
|
outliner.setRadii(topLeft, topRight, bottomRight, bottomLeft);
|
|
postInvalidate();
|
|
}
|
|
}
|