diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FileStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FileStatusDisplayItem.java index 35fc8e312..847cec989 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FileStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FileStatusDisplayItem.java @@ -46,18 +46,14 @@ public class FileStatusDisplayItem extends StatusDisplayItem{ public static class Holder extends StatusDisplayItem.Holder{ private final TextView title, domain; - private final View inner; private final ImageView icon; private final Context context; - private PhotoViewer currentPhotoViewer; - public Holder(Context context, ViewGroup parent){ super(context, R.layout.display_item_file, parent); title=findViewById(R.id.title); domain=findViewById(R.id.domain); icon=findViewById(R.id.imageView); - inner=findViewById(R.id.inner); this.context=context; findViewById(R.id.inner).setOnClickListener(this::onClick); @@ -67,42 +63,18 @@ public class FileStatusDisplayItem extends StatusDisplayItem{ public void onBind(FileStatusDisplayItem item) { Uri url = Uri.parse(getUrl()); - if(!item.attachment.type.isImage()) { - title.setText(item.attachment.description != null - ? item.attachment.description - : url.getLastPathSegment()); + title.setText(item.attachment.description != null + ? item.attachment.description + : url.getLastPathSegment()); - title.setEllipsize(item.attachment.description != null ? TextUtils.TruncateAt.END : TextUtils.TruncateAt.MIDDLE); - domain.setText(url.getHost()); + title.setEllipsize(item.attachment.description != null ? TextUtils.TruncateAt.END : TextUtils.TruncateAt.MIDDLE); + domain.setText(url.getHost()); - icon.setImageDrawable(context.getDrawable(R.drawable.ic_fluent_attach_24_regular)); - } else { - title.setText(item.attachment.description != null - ? item.attachment.description - : context.getString(R.string.sk_no_alt_text)); - title.setSingleLine(false); - - domain.setText(item.status.sensitive ? context.getString(R.string.sensitive_content_explain) : null); - domain.setVisibility(item.status.sensitive ? View.VISIBLE : View.GONE); - - if(item.attachment.type == Attachment.Type.IMAGE) - icon.setImageDrawable(context.getDrawable(R.drawable.ic_fluent_image_24_regular)); - if(item.attachment.type == Attachment.Type.VIDEO) - icon.setImageDrawable(context.getDrawable(R.drawable.ic_fluent_video_clip_24_regular)); - if(item.attachment.type == Attachment.Type.GIFV) - icon.setImageDrawable(context.getDrawable(R.drawable.ic_fluent_gif_24_regular)); - - } + icon.setImageDrawable(context.getDrawable(R.drawable.ic_fluent_attach_24_regular)); } private void onClick(View v) { - if(!item.attachment.type.isImage()) { - UiUtils.openURL(itemView.getContext(), item.parentFragment.getAccountID(), getUrl()); - } else { - // TODO make the cool animation work decently with multiple FileStatusDisplayItems - currentPhotoViewer=new PhotoViewer((Activity) context, item.status.mediaAttachments, item.status.mediaAttachments.indexOf(item.attachment), - new SingleImagePhotoViewerListener(title, inner, new int[]{V.dp(28), V.dp(28), V.dp(28), V.dp(28)}, item.parentFragment, ()->currentPhotoViewer=null, ()->context.getDrawable(R.drawable.bg_search_field), null, null)); - } + UiUtils.openURL(itemView.getContext(), item.parentFragment.getAccountID(), getUrl()); } private String getUrl() {