Improve blog author clickability

resolves issue where clicking reblogged author opened reblogging author's blog
This commit is contained in:
Torsten Grote
2021-03-26 10:40:51 -03:00
parent dceeecf1fe
commit 6599093611
3 changed files with 17 additions and 25 deletions

View File

@@ -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);

View File

@@ -135,9 +135,10 @@ public class AuthorView extends ConstraintLayout {
}
public void setAuthorNotClickable() {
setClickable(false);
setBackgroundResource(0);
setOnClickListener(null);
setClickable(false);
setFocusable(false);
setBackgroundResource(0);
}
/**

View File

@@ -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" />