2019-04-17 16:21:30 +02:00
|
|
|
package org.thoughtcrime.securesms.components;
|
|
|
|
|
|
|
|
import android.content.Context;
|
2020-08-19 02:06:26 +02:00
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
2019-04-17 16:21:30 +02:00
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.view.View;
|
|
|
|
import android.widget.FrameLayout;
|
|
|
|
|
2021-06-24 07:03:29 +02:00
|
|
|
import org.thoughtcrime.securesms.conversation.v2.utilities.ThumbnailView;
|
2019-04-17 16:21:30 +02:00
|
|
|
import org.thoughtcrime.securesms.mms.GlideRequests;
|
2021-01-21 05:42:43 +01:00
|
|
|
|
2019-04-17 16:21:30 +02:00
|
|
|
import org.thoughtcrime.securesms.mms.Slide;
|
|
|
|
import org.thoughtcrime.securesms.mms.SlideClickListener;
|
|
|
|
import org.thoughtcrime.securesms.mms.SlidesClickedListener;
|
|
|
|
|
2019-08-07 08:48:54 +02:00
|
|
|
import network.loki.messenger.R;
|
|
|
|
|
2019-04-17 16:21:30 +02:00
|
|
|
public class StickerView extends FrameLayout {
|
|
|
|
|
|
|
|
private ThumbnailView image;
|
|
|
|
private View missingShade;
|
|
|
|
|
|
|
|
public StickerView(@NonNull Context context) {
|
|
|
|
super(context);
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
public StickerView(@NonNull Context context, @Nullable AttributeSet attrs) {
|
|
|
|
super(context, attrs);
|
|
|
|
init();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void init() {
|
|
|
|
inflate(getContext(), R.layout.sticker_view, this);
|
|
|
|
|
|
|
|
this.image = findViewById(R.id.sticker_thumbnail);
|
|
|
|
this.missingShade = findViewById(R.id.sticker_missing_shade);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setFocusable(boolean focusable) {
|
|
|
|
image.setFocusable(focusable);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setClickable(boolean clickable) {
|
|
|
|
image.setClickable(clickable);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setOnLongClickListener(@Nullable OnLongClickListener l) {
|
|
|
|
image.setOnLongClickListener(l);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSticker(@NonNull GlideRequests glideRequests, @NonNull Slide stickerSlide) {
|
|
|
|
boolean showControls = stickerSlide.asAttachment().getDataUri() == null;
|
|
|
|
|
|
|
|
image.setImageResource(glideRequests, stickerSlide, showControls, false);
|
|
|
|
missingShade.setVisibility(showControls ? View.VISIBLE : View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setThumbnailClickListener(@NonNull SlideClickListener listener) {
|
|
|
|
image.setThumbnailClickListener(listener);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDownloadClickListener(@NonNull SlidesClickedListener listener) {
|
|
|
|
image.setDownloadClickListener(listener);
|
|
|
|
}
|
|
|
|
}
|