mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Improve blog author clickability
resolves issue where clicking reblogged author opened reblogging author's blog
This commit is contained in:
@@ -16,8 +16,6 @@ import org.briarproject.briar.android.view.AuthorView;
|
||||
import org.briarproject.briar.api.blog.BlogCommentHeader;
|
||||
import org.briarproject.briar.api.blog.BlogPostHeader;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import androidx.annotation.UiThread;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
@@ -81,15 +79,15 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
|
||||
return "blogPost" + id.hashCode();
|
||||
}
|
||||
|
||||
void bindItem(@Nullable BlogPostItem item) {
|
||||
if (item == null) return;
|
||||
|
||||
void bindItem(BlogPostItem item) {
|
||||
setTransitionName(item.getId());
|
||||
if (!fullText) {
|
||||
layout.setClickable(true);
|
||||
layout.setOnClickListener(v -> listener.onBlogPostClick(item));
|
||||
}
|
||||
|
||||
boolean isReblog = item instanceof BlogCommentItem;
|
||||
|
||||
// author and date
|
||||
BlogPostHeader post = item.getPostHeader();
|
||||
author.setAuthor(post.getAuthor(), post.getAuthorInfo());
|
||||
@@ -97,7 +95,7 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
|
||||
author.setPersona(
|
||||
item.isRssFeed() ? AuthorView.RSS_FEED : AuthorView.NORMAL);
|
||||
// TODO make author clickable more often #624
|
||||
if (authorClickable) {
|
||||
if (authorClickable && !isReblog) {
|
||||
author.setAuthorClickable(v -> listener.onAuthorClick(item));
|
||||
} else {
|
||||
author.setAuthorNotClickable();
|
||||
@@ -126,19 +124,21 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
// comments
|
||||
commentContainer.removeAllViews();
|
||||
if (item instanceof BlogCommentItem) {
|
||||
onBindComment((BlogCommentItem) item);
|
||||
if (isReblog) {
|
||||
onBindComment((BlogCommentItem) item, authorClickable);
|
||||
} else {
|
||||
reblogger.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void onBindComment(BlogCommentItem item) {
|
||||
private void onBindComment(BlogCommentItem item, boolean authorClickable) {
|
||||
// reblogger
|
||||
reblogger.setAuthor(item.getAuthor(), item.getAuthorInfo());
|
||||
reblogger.setDate(item.getTimestamp());
|
||||
if (!fullText) {
|
||||
if (authorClickable) {
|
||||
reblogger.setAuthorClickable(v -> listener.onAuthorClick(item));
|
||||
} else {
|
||||
reblogger.setAuthorNotClickable();
|
||||
}
|
||||
reblogger.setVisibility(VISIBLE);
|
||||
reblogger.setPersona(REBLOGGER);
|
||||
|
||||
@@ -135,9 +135,10 @@ public class AuthorView extends ConstraintLayout {
|
||||
}
|
||||
|
||||
public void setAuthorNotClickable() {
|
||||
setClickable(false);
|
||||
setBackgroundResource(0);
|
||||
setOnClickListener(null);
|
||||
setClickable(false);
|
||||
setFocusable(false);
|
||||
setBackgroundResource(0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,27 +16,18 @@
|
||||
android:id="@+id/rebloggerView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/listitem_vertical_margin"
|
||||
android:layout_marginLeft="@dimen/listitem_vertical_margin"
|
||||
android:layout_marginTop="@dimen/listitem_vertical_margin"
|
||||
android:layout_marginEnd="@dimen/listitem_vertical_margin"
|
||||
android:layout_marginRight="@dimen/listitem_vertical_margin"
|
||||
android:layout_marginBottom="@dimen/listitem_horizontal_margin"
|
||||
android:padding="@dimen/listitem_vertical_margin"
|
||||
app:layout_constraintEnd_toStartOf="@+id/commentView"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:persona="reblogger" />
|
||||
app:persona="reblogger"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<org.briarproject.briar.android.view.AuthorView
|
||||
android:id="@+id/authorView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/listitem_vertical_margin"
|
||||
android:layout_marginLeft="@dimen/listitem_vertical_margin"
|
||||
android:layout_marginTop="@dimen/listitem_vertical_margin"
|
||||
android:layout_marginEnd="@dimen/listitem_vertical_margin"
|
||||
android:layout_marginRight="@dimen/listitem_vertical_margin"
|
||||
android:layout_marginBottom="@dimen/listitem_horizontal_margin"
|
||||
android:padding="@dimen/listitem_vertical_margin"
|
||||
app:layout_constraintEnd_toStartOf="@+id/commentView"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/rebloggerView" />
|
||||
|
||||
Reference in New Issue
Block a user