diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java index 948dc3d1..b2c2d41f 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/ComposeAdapter.java @@ -48,6 +48,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.accessibility.AccessibilityEvent; import android.view.inputmethod.InputMethodManager; +import android.webkit.URLUtil; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.GridView; @@ -59,6 +60,7 @@ import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.AppCompatEditText; import androidx.appcompat.widget.LinearLayoutCompat; import androidx.core.app.ActivityCompat; +import androidx.core.app.ActivityOptionsCompat; import androidx.core.content.ContextCompat; import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.ViewModelProvider; @@ -101,9 +103,11 @@ import app.fedilab.android.activities.MainActivity; import app.fedilab.android.databinding.ComposeAttachmentItemBinding; import app.fedilab.android.databinding.ComposePollBinding; import app.fedilab.android.databinding.ComposePollItemBinding; +import app.fedilab.android.databinding.DrawerMediaListBinding; import app.fedilab.android.databinding.DrawerStatusComposeBinding; import app.fedilab.android.databinding.DrawerStatusSimpleBinding; import app.fedilab.android.mastodon.activities.ComposeActivity; +import app.fedilab.android.mastodon.activities.MediaActivity; import app.fedilab.android.mastodon.client.entities.api.Account; import app.fedilab.android.mastodon.client.entities.api.Attachment; import app.fedilab.android.mastodon.client.entities.api.Emoji; @@ -1343,6 +1347,38 @@ public class ComposeAdapter extends RecyclerView.Adapter 0 ) { + holder.binding.simpleMedia.removeAllViews(); + List attachmentList = statusList.get(position).media_attachments; + for(Attachment attachment: attachmentList) { + DrawerMediaListBinding drawerMediaListBinding = DrawerMediaListBinding.inflate(LayoutInflater.from(context), holder.binding.simpleMedia, false); + Glide.with(drawerMediaListBinding.media.getContext()) + .load(attachment.preview_url) + .into(drawerMediaListBinding.media); + + if(attachment.filename != null) { + drawerMediaListBinding.mediaName.setText(attachment.filename); + } else if (attachment.preview_url != null){ + drawerMediaListBinding.mediaName.setText(URLUtil.guessFileName(attachment.preview_url, null, null)); + } + drawerMediaListBinding.getRoot().setOnClickListener(v->{ + Intent mediaIntent = new Intent(context, MediaActivity.class); + Bundle b = new Bundle(); + ArrayList attachments = new ArrayList<>(); + attachments.add(attachment); + b.putSerializable(Helper.ARG_MEDIA_ARRAY, attachments); + mediaIntent.putExtras(b); + ActivityOptionsCompat options = ActivityOptionsCompat + .makeSceneTransitionAnimation((Activity) context, drawerMediaListBinding.media, attachment.url); + context.startActivity(mediaIntent, options.toBundle()); + }); + holder.binding.simpleMedia.addView(drawerMediaListBinding.getRoot()); + + } + holder.binding.simpleMediaContainer.setVisibility(View.VISIBLE); + } else { + holder.binding.simpleMediaContainer.setVisibility(View.GONE); + } holder.binding.statusContent.setText( status.getSpanContent(context, new WeakReference<>(holder.binding.statusContent), () -> notifyItemChanged(position)), diff --git a/app/src/main/res/layouts/mastodon/layout/drawer_media_list.xml b/app/src/main/res/layouts/mastodon/layout/drawer_media_list.xml new file mode 100644 index 00000000..fc24bf21 --- /dev/null +++ b/app/src/main/res/layouts/mastodon/layout/drawer_media_list.xml @@ -0,0 +1,28 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layouts/mastodon/layout/drawer_status_simple.xml b/app/src/main/res/layouts/mastodon/layout/drawer_status_simple.xml index 344f88f1..2fb386fd 100644 --- a/app/src/main/res/layouts/mastodon/layout/drawer_status_simple.xml +++ b/app/src/main/res/layouts/mastodon/layout/drawer_status_simple.xml @@ -101,6 +101,25 @@ android:textIsSelectable="true" tools:maxLines="10" tools:text="@tools:sample/lorem/random" /> + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 07da9ce3..ea49a419 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -2035,4 +2035,5 @@ Color that will be applied to the light theme Color that will be applied to the dark theme + Thumbnail \ No newline at end of file