Support opening unknown attachment types via openLink (#2044)

* Support opening unknown attachment types via openLink. #1970

* Fix label text for unknown attachment types
This commit is contained in:
Levi Bard 2021-01-18 13:53:13 +01:00 committed by GitHub
commit baa915a0a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 22 additions and 16 deletions

View file

@ -533,7 +533,6 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
@DrawableRes
private static int getLabelIcon(Attachment.Type type) {
switch (type) {
default:
case IMAGE:
return R.drawable.ic_photo_24dp;
case GIFV:
@ -541,6 +540,8 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
return R.drawable.ic_videocam_24dp;
case AUDIO:
return R.drawable.ic_music_box_24dp;
default:
return R.drawable.ic_attach_file_24dp;
}
}
@ -718,7 +719,7 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
setBookmarked(status.isBookmarked());
List<Attachment> attachments = status.getAttachments();
boolean sensitive = status.isSensitive();
if (statusDisplayOptions.mediaPreviewEnabled() && !hasAudioAttachment(attachments)) {
if (statusDisplayOptions.mediaPreviewEnabled() && hasPreviewableAttachment(attachments)) {
setMediaPreviews(attachments, sensitive, listener, status.isShowingContent(), statusDisplayOptions.useBlurhash());
if (attachments.size() == 0) {
@ -767,13 +768,13 @@ public abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
}
}
protected static boolean hasAudioAttachment(List<Attachment> attachments) {
protected static boolean hasPreviewableAttachment(List<Attachment> attachments) {
for (Attachment attachment : attachments) {
if (attachment.getType() == Attachment.Type.AUDIO) {
return true;
if (attachment.getType() == Attachment.Type.AUDIO || attachment.getType() == Attachment.Type.UNKNOWN) {
return false;
}
}
return false;
return true;
}
private void setDescriptionForStatus(@NonNull StatusViewData.Concrete status,