Add display item for unknown/file attachments
Co-authored-by: LucasGGamerM <lucassggabriel@gmail.com>
This commit is contained in:
parent
6abfe6ddd7
commit
274bca84d9
|
@ -0,0 +1,58 @@
|
|||
package org.joinmastodon.android.ui.displayitems;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.joinmastodon.android.R;
|
||||
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
||||
import org.joinmastodon.android.model.Attachment;
|
||||
import org.joinmastodon.android.model.Card;
|
||||
import org.joinmastodon.android.model.Status;
|
||||
import org.joinmastodon.android.ui.drawables.BlurhashCrossfadeDrawable;
|
||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||
|
||||
import me.grishka.appkit.imageloader.ImageLoaderViewHolder;
|
||||
|
||||
public class FileStatusDisplayItem extends StatusDisplayItem{
|
||||
private final Attachment attachment;
|
||||
|
||||
public FileStatusDisplayItem(String parentID, BaseStatusListFragment<?> parentFragment, Attachment attachment) {
|
||||
super(parentID, parentFragment);
|
||||
this.attachment=attachment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return Type.FILE;
|
||||
}
|
||||
|
||||
public static class Holder extends StatusDisplayItem.Holder<FileStatusDisplayItem> {
|
||||
private final TextView title, domain;
|
||||
|
||||
public Holder(Context context, ViewGroup parent) {
|
||||
super(context, R.layout.display_item_file, parent);
|
||||
title=findViewById(R.id.title);
|
||||
domain=findViewById(R.id.domain);
|
||||
findViewById(R.id.inner).setOnClickListener(this::onClick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBind(FileStatusDisplayItem item) {
|
||||
title.setText(item.attachment.description == null
|
||||
? title.getContext().getText(R.string.sk_attachment)
|
||||
: item.attachment.description);
|
||||
domain.setText(Uri.parse(item.attachment.url).getHost());
|
||||
}
|
||||
|
||||
private void onClick(View v) {
|
||||
UiUtils.openURL(itemView.getContext(), item.parentFragment.getAccountID(), item.attachment.url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -78,6 +78,7 @@ public abstract class StatusDisplayItem{
|
|||
case EXTENDED_FOOTER -> new ExtendedFooterStatusDisplayItem.Holder(activity, parent);
|
||||
case MEDIA_GRID -> new MediaGridStatusDisplayItem.Holder(activity, parent);
|
||||
case WARNING -> new WarningFilteredStatusDisplayItem.Holder(activity, parent);
|
||||
case FILE -> new FileStatusDisplayItem.Holder(activity, parent);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -171,7 +172,10 @@ public abstract class StatusDisplayItem{
|
|||
replyLine.needBottomPadding=true;
|
||||
else
|
||||
header.needBottomPadding=true;
|
||||
List<Attachment> imageAttachments=statusForContent.mediaAttachments.stream().filter(att->att.type.isImage()).collect(Collectors.toList());
|
||||
|
||||
List<Attachment> imageAttachments=statusForContent.mediaAttachments.stream()
|
||||
.filter(att->att.type.isImage() && !att.type.equals(Attachment.Type.UNKNOWN))
|
||||
.collect(Collectors.toList());
|
||||
if(!imageAttachments.isEmpty()){
|
||||
PhotoLayoutHelper.TiledLayoutResult layout=PhotoLayoutHelper.processThumbs(imageAttachments);
|
||||
items.add(new MediaGridStatusDisplayItem(parentID, fragment, layout, imageAttachments, statusForContent));
|
||||
|
@ -181,6 +185,12 @@ public abstract class StatusDisplayItem{
|
|||
items.add(new AudioStatusDisplayItem(parentID, fragment, statusForContent, att));
|
||||
}
|
||||
}
|
||||
|
||||
statusForContent.mediaAttachments.stream()
|
||||
.filter(att->att.type.equals(Attachment.Type.UNKNOWN))
|
||||
.map(att -> new FileStatusDisplayItem(parentID, fragment, att))
|
||||
.forEach(items::add);
|
||||
|
||||
if(statusForContent.poll!=null){
|
||||
buildPollItems(parentID, fragment, statusForContent.poll, items);
|
||||
}
|
||||
|
@ -230,7 +240,8 @@ public abstract class StatusDisplayItem{
|
|||
GAP,
|
||||
EXTENDED_FOOTER,
|
||||
MEDIA_GRID,
|
||||
WARNING
|
||||
WARNING,
|
||||
FILE
|
||||
}
|
||||
|
||||
public static abstract class Holder<T extends StatusDisplayItem> extends BindableViewHolder<T> implements UsableRecyclerView.DisableableClickable{
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ripple
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="?android:attr/colorControlHighlight">
|
||||
<item>
|
||||
<shape>
|
||||
<solid android:color="?colorSearchField"/>
|
||||
<corners android:radius="6dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
</ripple>
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:pathData="M11.772,3.744C14.114,1.4 17.913,1.4 20.256,3.744C22.539,6.027 22.597,9.692 20.431,12.046L20.243,12.243L11.443,21.041L11.407,21.072C9.945,22.388 7.691,22.344 6.284,20.936C4.965,19.617 4.843,17.555 5.918,16.098C5.941,16.052 5.969,16.009 6.002,15.968L6.056,15.908L6.143,15.82L6.284,15.672L6.287,15.675L13.723,8.221C13.989,7.954 14.405,7.93 14.699,8.147L14.783,8.22C15.05,8.485 15.075,8.902 14.857,9.196L14.785,9.28L7.19,16.893C6.473,17.769 6.522,19.063 7.34,19.881C8.169,20.71 9.488,20.749 10.364,19.999L19.197,11.168C20.952,9.411 20.952,6.562 19.195,4.804C17.493,3.102 14.766,3.049 12.999,4.645L12.831,4.804L12.819,4.819L3.282,14.355C2.989,14.648 2.515,14.648 2.222,14.355C1.955,14.089 1.931,13.672 2.149,13.378L2.222,13.294L11.771,3.744L11.772,3.744Z"
|
||||
android:fillColor="@color/fluent_default_icon_tint"/>
|
||||
</vector>
|
|
@ -0,0 +1,59 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<org.joinmastodon.android.ui.views.MaxWidthFrameLayout
|
||||
android:id="@+id/inner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:maxWidth="@dimen/layout_max_width">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginVertical="4dp"
|
||||
android:background="@drawable/bg_search_field"
|
||||
android:paddingVertical="12dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginStart="18dp"
|
||||
android:importantForAccessibility="no"
|
||||
android:src="@drawable/ic_fluent_attach_24_regular" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/m3_body_large"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="end"
|
||||
tools:text="Link title"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/domain"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/m3_body_medium"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
tools:text="example.com"/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</org.joinmastodon.android.ui.views.MaxWidthFrameLayout>
|
||||
</FrameLayout>
|
|
@ -274,4 +274,5 @@
|
|||
<string name="sk_settings_confirm_before_reblog">Vor dem Teilen bestätigen</string>
|
||||
<string name="sk_reacted">hat reagiert</string>
|
||||
<string name="sk_reacted_with">hat mit %s reagiert</string>
|
||||
<string name="sk_attachment">Anhang</string>
|
||||
</resources>
|
|
@ -286,4 +286,5 @@
|
|||
<string name="sk_settings_content_types_explanation">Allows setting a content type like Markdown when creating a post. Keep in mind that not all instances support this.</string>
|
||||
<string name="sk_settings_default_content_type">Default content type</string>
|
||||
<string name="sk_settings_default_content_type_explanation">This lets you have a content type be pre-selected when creating new posts, overriding the value set in “Posting preferences”.</string>
|
||||
<string name="sk_attachment">Attachment</string>
|
||||
</resources>
|
Loading…
Reference in New Issue