forked from mirror/monocles_chat_clean
update fork #128
6 changed files with 459 additions and 162 deletions
Show comments for expanded posts
commit
a308ef2bc0
67
src/main/java/eu/siacs/conversations/entities/Comment.java
Normal file
67
src/main/java/eu/siacs/conversations/entities/Comment.java
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
package eu.siacs.conversations.entities;
|
||||
|
||||
import static eu.siacs.conversations.parser.AbstractParser.parseTimestamp;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import eu.siacs.conversations.xml.Element;
|
||||
import eu.siacs.conversations.xml.Namespace;
|
||||
import eu.siacs.conversations.xmpp.Jid;
|
||||
|
||||
public class Comment {
|
||||
|
||||
private final String id;
|
||||
private final String title;
|
||||
private final Jid author;
|
||||
private final Date published;
|
||||
|
||||
public Comment(String id, String title, Jid author, Date published) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
this.author = author;
|
||||
this.published = published;
|
||||
}
|
||||
|
||||
public static Comment fromElement(Element entry) {
|
||||
String id = entry.findChildContent("id", Namespace.ATOM);
|
||||
String title = entry.findChildContent("title", Namespace.ATOM);
|
||||
Element authorElement = entry.findChild("author", Namespace.ATOM);
|
||||
Jid author = null;
|
||||
if (authorElement != null) {
|
||||
String uri = authorElement.findChildContent("uri", Namespace.ATOM);
|
||||
if (uri != null && uri.startsWith("xmpp:")) {
|
||||
try {
|
||||
author = Jid.of(uri.substring(5));
|
||||
} catch (IllegalArgumentException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
Date published = null;
|
||||
final String publishedString = entry.findChildContent("published", Namespace.ATOM);
|
||||
if (publishedString != null) {
|
||||
try {
|
||||
published = new Date(parseTimestamp(publishedString));
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
return new Comment(id, title, author, published);
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public Jid getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public Date getPublished() {
|
||||
return published;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
package eu.siacs.conversations.ui.adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import java.text.DateFormat;
|
||||
import java.util.List;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.databinding.ItemCommentBinding;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.entities.Comment;
|
||||
import eu.siacs.conversations.entities.Contact;
|
||||
import eu.siacs.conversations.ui.XmppActivity;
|
||||
import eu.siacs.conversations.ui.util.AvatarWorkerTask;
|
||||
import eu.siacs.conversations.utils.AccountUtils;
|
||||
import eu.siacs.conversations.xmpp.Jid;
|
||||
|
||||
public class CommentsAdapter extends RecyclerView.Adapter<CommentsAdapter.CommentViewHolder> {
|
||||
|
||||
private final List<Comment> comments;
|
||||
private final XmppActivity mActivity;
|
||||
|
||||
public CommentsAdapter(XmppActivity activity, List<Comment> comments) {
|
||||
this.mActivity = activity;
|
||||
this.comments = comments;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public CommentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return new CommentViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_comment, parent, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull CommentViewHolder holder, int position) {
|
||||
holder.bind(comments.get(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return comments.size();
|
||||
}
|
||||
|
||||
class CommentViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private final ItemCommentBinding binding;
|
||||
|
||||
CommentViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
binding = ItemCommentBinding.bind(itemView);
|
||||
}
|
||||
|
||||
void bind(Comment comment) {
|
||||
if (comment.getAuthor() != null) {
|
||||
final Jid authorJid = comment.getAuthor();
|
||||
if (mActivity.xmppConnectionService != null) {
|
||||
Account account = AccountUtils.getFirstEnabled(mActivity.xmppConnectionService.getAccounts());
|
||||
if (account != null) {
|
||||
if (authorJid.asBareJid().equals(account.getJid().asBareJid())) {
|
||||
binding.commentAuthorName.setText(account.getDisplayName());
|
||||
AvatarWorkerTask.loadAvatar(account, binding.commentAuthorAvatar, R.dimen.posts_comments_avatar_size);
|
||||
} else {
|
||||
Contact contact = account.getRoster().getContact(authorJid);
|
||||
if (contact != null) {
|
||||
binding.commentAuthorName.setText(contact.getDisplayName());
|
||||
AvatarWorkerTask.loadAvatar(contact, binding.commentAuthorAvatar, R.dimen.posts_comments_avatar_size);
|
||||
} else {
|
||||
binding.commentAuthorName.setText(authorJid.asBareJid().toString());
|
||||
binding.commentAuthorAvatar.setImageResource(R.drawable.ic_person_24dp);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
binding.commentAuthorName.setText(authorJid.asBareJid().toString());
|
||||
binding.commentAuthorAvatar.setImageResource(R.drawable.ic_person_24dp);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
binding.commentAuthorName.setText(null);
|
||||
binding.commentAuthorAvatar.setImageResource(R.drawable.ic_person_24dp);
|
||||
}
|
||||
binding.commentContent.setText(comment.getTitle());
|
||||
if (comment.getPublished() != null) {
|
||||
binding.commentTimestamp.setText(DateFormat.getDateTimeInstance().format(comment.getPublished()));
|
||||
} else {
|
||||
binding.commentTimestamp.setText(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,25 +2,30 @@ package eu.siacs.conversations.ui.adapter;
|
|||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.databinding.ItemPostBinding;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.entities.Comment;
|
||||
import eu.siacs.conversations.entities.Contact;
|
||||
import eu.siacs.conversations.entities.Conversation;
|
||||
import eu.siacs.conversations.entities.Message;
|
||||
|
|
@ -32,6 +37,10 @@ import eu.siacs.conversations.ui.UiCallback;
|
|||
import eu.siacs.conversations.ui.XmppActivity;
|
||||
import eu.siacs.conversations.ui.util.AvatarWorkerTask;
|
||||
import eu.siacs.conversations.utils.AccountUtils;
|
||||
import eu.siacs.conversations.utils.XmppUri;
|
||||
import eu.siacs.conversations.xml.Element;
|
||||
import eu.siacs.conversations.xml.Namespace;
|
||||
import eu.siacs.conversations.xml.XmlReader;
|
||||
import eu.siacs.conversations.xmpp.Jid;
|
||||
|
||||
public class PostsAdapter extends RecyclerView.Adapter<PostsAdapter.PostViewHolder> {
|
||||
|
|
@ -72,6 +81,13 @@ public class PostsAdapter extends RecyclerView.Adapter<PostsAdapter.PostViewHold
|
|||
|
||||
void bind(Post post) {
|
||||
final boolean isExpanded = expandedPosts.contains(post);
|
||||
binding.postActions.setVisibility(isExpanded ?View.VISIBLE :View.GONE);
|
||||
if (isExpanded && post.getCommentsNode() != null) {
|
||||
loadComments(post, binding.commentsList);
|
||||
} else {
|
||||
binding.commentsList.setVisibility(View.GONE);
|
||||
binding.commentsList.setAdapter(null);
|
||||
}
|
||||
final boolean hasAttachment = post.getAttachmentUrl() != null;
|
||||
final boolean isImage = hasAttachment && post.getAttachmentType() != null && post.getAttachmentType().startsWith("image/");
|
||||
final boolean isVideo = hasAttachment && post.getAttachmentType() != null && post.getAttachmentType().startsWith("video/");
|
||||
|
|
@ -263,5 +279,55 @@ public class PostsAdapter extends RecyclerView.Adapter<PostsAdapter.PostViewHold
|
|||
binding.postTimestamp.setText(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void loadComments(final Post post, final RecyclerView recyclerView) {
|
||||
if (mActivity.xmppConnectionService == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final XmppUri uri = new XmppUri(post.getCommentsNode());
|
||||
final Jid jid = uri.getJid();
|
||||
final String node = uri.getParameter("node");
|
||||
if (jid != null && node != null) {
|
||||
mActivity.xmppConnectionService.fetchPubsubItems(jid, node, new XmppConnectionService.OnPubsubItemsFetched() {
|
||||
@Override
|
||||
public void onPubsubItemsFetched(String feedXml) {
|
||||
try {
|
||||
final XmlReader reader = new XmlReader();
|
||||
reader.setInputStream(new java.io.ByteArrayInputStream(feedXml.getBytes()));
|
||||
final Element feed = reader.readElement(reader.readTag());
|
||||
final List<Comment> comments = new ArrayList<>();
|
||||
if (feed != null && "feed".equals(feed.getName()) && Namespace.ATOM.equals(feed.getNamespace())) {
|
||||
for (Element child : feed.getChildren()) {
|
||||
if ("entry".equals(child.getName()) && Namespace.ATOM.equals(child.getNamespace())) {
|
||||
comments.add(Comment.fromElement(child));
|
||||
}
|
||||
}
|
||||
}
|
||||
mActivity.runOnUiThread(() -> {
|
||||
if (!comments.isEmpty()) {
|
||||
CommentsAdapter commentsAdapter = new CommentsAdapter(mActivity, comments);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
|
||||
recyclerView.setAdapter(commentsAdapter);
|
||||
recyclerView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Log.e(Config.LOGTAG, "error parsing comments", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPubsubItemsFetchFailed() {
|
||||
Log.e(Config.LOGTAG, "failed to fetch comments for post "+post.getId());
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
Log.e(Config.LOGTAG, "error parsing comments node uri", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
59
src/main/res/layout/item_comment.xml
Normal file
59
src/main/res/layout/item_comment.xml
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<eu.siacs.conversations.ui.widget.AvatarView
|
||||
android:id="@+id/comment_author_avatar"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:scaleType="centerCrop"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:src="@tools:sample/avatars" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/comment_author_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/comment_author_avatar"
|
||||
app:layout_constraintTop_toTopOf="@+id/comment_author_avatar"
|
||||
tools:text="Jane Doe" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/comment_timestamp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="10sp"
|
||||
app:layout_constraintStart_toEndOf="@+id/comment_author_avatar"
|
||||
app:layout_constraintTop_toBottomOf="@+id/comment_author_name"
|
||||
tools:text="1 hour ago" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/comment_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:autoLink="web"
|
||||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/comment_author_avatar"
|
||||
app:layout_constraintTop_toBottomOf="@+id/comment_timestamp"
|
||||
tools:text="This is a comment." />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
||||
|
|
@ -2,182 +2,195 @@
|
|||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp">
|
||||
android:layout_margin="8dp">
|
||||
|
||||
<eu.siacs.conversations.ui.widget.AvatarView
|
||||
android:id="@+id/post_author_avatar"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:scaleType="centerCrop"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:src="@tools:sample/avatars" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/post_author_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toEndOf="@+id/post_author_avatar"
|
||||
app:layout_constraintTop_toTopOf="@+id/post_author_avatar"
|
||||
tools:text="John Doe" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/post_timestamp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toEndOf="@+id/post_author_avatar"
|
||||
app:layout_constraintTop_toBottomOf="@+id/post_author_name"
|
||||
tools:text="2 hours ago" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/delete_button"
|
||||
style="?android:attr/actionButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_delete_24dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/edit_button"
|
||||
style="?android:attr/actionButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_edit_24dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toStartOf="@+id/delete_button"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/post_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Title"
|
||||
android:textIsSelectable="true"
|
||||
app:layout_constraintEnd_toStartOf="@+id/attachment_hint"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/post_author_avatar"
|
||||
tools:text="This is a post title" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/attachment_hint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:src="@drawable/ic_attach_file_white_24dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/post_title"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/post_title"
|
||||
app:layout_constraintTop_toTopOf="@+id/post_title"
|
||||
app:tint="?android:attr/textColorSecondary"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/post_image"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintTop_toBottomOf="@+id/post_title"
|
||||
tools:src="@tools:sample/backgrounds/scenic"
|
||||
tools:visibility="visible" />
|
||||
android:padding="16dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/download_button"
|
||||
style="@style/Widget.Material3.Button.TextButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/download_file"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintTop_toBottomOf="@id/post_title"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
tools:visibility="visible"
|
||||
/>
|
||||
<eu.siacs.conversations.ui.widget.AvatarView
|
||||
android:id="@+id/post_author_avatar"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:scaleType="centerCrop"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:src="@tools:sample/avatars" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/post_content_summary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="3"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/post_image"
|
||||
tools:text="This is the content of the post. It can be a long text spanning multiple lines." />
|
||||
<TextView
|
||||
android:id="@+id/post_author_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toEndOf="@+id/post_author_avatar"
|
||||
app:layout_constraintTop_toTopOf="@+id/post_author_avatar"
|
||||
tools:text="John Doe" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/post_content_full"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:autoLink="web"
|
||||
android:textIsSelectable="true"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/post_image"
|
||||
tools:text="This is the content of the post. It can be a long text spanning multiple lines." />
|
||||
<TextView
|
||||
android:id="@+id/post_timestamp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toEndOf="@+id/post_author_avatar"
|
||||
app:layout_constraintTop_toBottomOf="@+id/post_author_name"
|
||||
tools:text="2 hours ago" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/post_actions"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintTop_toBottomOf="@id/post_content_full"
|
||||
tools:visibility="visible">
|
||||
<ImageButton
|
||||
android:id="@+id/delete_button"
|
||||
style="?android:attr/actionButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_delete_24dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/edit_button"
|
||||
style="?android:attr/actionButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_edit_24dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toStartOf="@+id/delete_button"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/post_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Title"
|
||||
android:textIsSelectable="true"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/post_author_avatar"
|
||||
tools:text="This is a post title" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/attachment_hint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:src="@drawable/ic_attach_file_white_24dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/post_title"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toEndOf="@+id/post_title"
|
||||
app:layout_constraintTop_toTopOf="@+id/post_title"
|
||||
app:layout_constraintVertical_bias="1.0"
|
||||
app:tint="?android:attr/textColorSecondary"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/post_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitCenter"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintTop_toBottomOf="@+id/post_title"
|
||||
tools:src="@tools:sample/backgrounds/scenic"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/reply_button"
|
||||
android:id="@+id/download_button"
|
||||
style="@style/Widget.Material3.Button.TextButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/reply" />
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/download_file"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintTop_toBottomOf="@id/post_title"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/comment_button"
|
||||
style="@style/Widget.Material3.Button.TextButton"
|
||||
android:layout_width="wrap_content"
|
||||
<TextView
|
||||
android:id="@+id/post_content_summary"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/comment" />
|
||||
android:layout_marginTop="8dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="3"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/post_image"
|
||||
tools:text="This is the content of the post. It can be a long text spanning multiple lines." />
|
||||
|
||||
<Button
|
||||
android:id="@+id/share_button"
|
||||
style="@style/Widget.Material3.Button.TextButton"
|
||||
android:layout_width="wrap_content"
|
||||
<TextView
|
||||
android:id="@+id/post_content_full"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/share" />
|
||||
</LinearLayout>
|
||||
android:layout_marginTop="8dp"
|
||||
android:autoLink="web"
|
||||
android:textIsSelectable="true"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/post_image"
|
||||
tools:text="This is the content of the post. It can be a long text spanning multiple lines." />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/post_actions"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintTop_toBottomOf="@id/post_content_full"
|
||||
tools:visibility="visible">
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
<Button
|
||||
android:id="@+id/reply_button"
|
||||
style="@style/Widget.Material3.Button.TextButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/reply" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/comment_button"
|
||||
style="@style/Widget.Material3.Button.TextButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/comment" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/share_button"
|
||||
style="@style/Widget.Material3.Button.TextButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/share" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/comments_list"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/post_actions"
|
||||
tools:listitem="@layout/item_comment"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
</layout>
|
||||
|
|
@ -106,4 +106,5 @@
|
|||
<dimen name="presence_indicator_size">12dp</dimen>
|
||||
<dimen name="presence_indicator_offset">2dp</dimen>
|
||||
<dimen name="thumbnail_size">80dp</dimen>
|
||||
<dimen name="posts_comments_avatar_size">24dp</dimen>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue