issue 2890: Add an "ALT" sticker to the media preview container (#2942)
* issue 2890: Add an "ALT" sticker to the media preview container if there are descriptions * issue 2890: Use end and start for positioning * issue 2890: Adapt to new media view group * issue 2890: Use an indicator overlay for every (single) preview image * issue 2890: Reduce radius to match that of the preview layout * issue 2890: Remove (again) unused code * issue 2890: Set visibility in any case * issue 2890: Use a translatable text for ALT * issue 2890: Show ALT flag only when showing media * issue 2890: Call doOnLayout on the layout wrapper
This commit is contained in:
parent
2de2af0a8c
commit
6aed1c6806
7 changed files with 66 additions and 13 deletions
|
|
@ -411,14 +411,15 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
|||
return ImageLoadingHelper.decodeBlurHash(this.avatar.getContext(), blurhash);
|
||||
}
|
||||
|
||||
private void loadImage(MediaPreviewImageView imageView,
|
||||
private void loadImage(View wrapper,
|
||||
MediaPreviewImageView imageView,
|
||||
@Nullable String previewUrl,
|
||||
@Nullable MetaData meta,
|
||||
@Nullable String blurhash) {
|
||||
|
||||
Drawable placeholder = blurhash != null ? decodeBlurHash(blurhash) : mediaPreviewUnloaded;
|
||||
|
||||
ViewKt.doOnLayout(imageView, view -> {
|
||||
ViewKt.doOnLayout(wrapper, view -> {
|
||||
if (TextUtils.isEmpty(previewUrl)) {
|
||||
imageView.removeFocalPoint();
|
||||
|
||||
|
|
@ -433,7 +434,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
|||
if (focus != null) { // If there is a focal point for this attachment:
|
||||
imageView.setFocalPoint(focus);
|
||||
|
||||
Glide.with(imageView)
|
||||
Glide.with(imageView.getContext())
|
||||
.load(previewUrl)
|
||||
.placeholder(placeholder)
|
||||
.centerInside()
|
||||
|
|
@ -460,19 +461,21 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
|||
mediaPreview.setVisibility(View.VISIBLE);
|
||||
mediaPreview.setAspectRatios(AttachmentHelper.aspectRatios(attachments));
|
||||
|
||||
mediaPreview.forEachIndexed((i, imageView) -> {
|
||||
mediaPreview.forEachIndexed((i, wrapper, imageView, descriptionIndicator) -> {
|
||||
Attachment attachment = attachments.get(i);
|
||||
String previewUrl = attachment.getPreviewUrl();
|
||||
String description = attachment.getDescription();
|
||||
boolean hasDescription = !TextUtils.isEmpty(description);
|
||||
|
||||
if (TextUtils.isEmpty(description)) {
|
||||
imageView.setContentDescription(imageView.getContext()
|
||||
.getString(R.string.action_view_media));
|
||||
} else {
|
||||
if (hasDescription) {
|
||||
imageView.setContentDescription(description);
|
||||
} else {
|
||||
imageView.setContentDescription(imageView.getContext().getString(R.string.action_view_media));
|
||||
}
|
||||
descriptionIndicator.setVisibility(hasDescription ? View.VISIBLE : View.GONE);
|
||||
|
||||
loadImage(
|
||||
wrapper,
|
||||
imageView,
|
||||
showingContent ? previewUrl : null,
|
||||
attachment.getMeta(),
|
||||
|
|
@ -502,6 +505,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
|||
}
|
||||
v.setVisibility(View.GONE);
|
||||
sensitiveMediaWarning.setVisibility(View.VISIBLE);
|
||||
descriptionIndicator.setVisibility(View.GONE);
|
||||
});
|
||||
sensitiveMediaWarning.setOnClickListener(v -> {
|
||||
if (getBindingAdapterPosition() != RecyclerView.NO_POSITION) {
|
||||
|
|
@ -509,6 +513,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
|
|||
}
|
||||
v.setVisibility(View.GONE);
|
||||
sensitiveMediaShow.setVisibility(View.VISIBLE);
|
||||
descriptionIndicator.setVisibility(hasDescription ? View.VISIBLE : View.GONE);
|
||||
});
|
||||
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue