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