mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 21:59:54 +01:00
Make blog post text clickable
by making it only selectable in detail view
This commit is contained in:
@@ -29,7 +29,6 @@
|
|||||||
android:paddingLeft="@dimen/listitem_vertical_margin"
|
android:paddingLeft="@dimen/listitem_vertical_margin"
|
||||||
android:paddingRight="@dimen/listitem_vertical_margin"
|
android:paddingRight="@dimen/listitem_vertical_margin"
|
||||||
android:textColor="@color/briar_text_secondary"
|
android:textColor="@color/briar_text_secondary"
|
||||||
android:textIsSelectable="true"
|
|
||||||
android:textSize="@dimen/text_size_small"
|
android:textSize="@dimen/text_size_small"
|
||||||
tools:text="This is a comment that appears below a blog post. Usually, it is expected to be rather short. Not much longer than this one."/>
|
tools:text="This is a comment that appears below a blog post. Usually, it is expected to be rather short. Not much longer than this one."/>
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:foreground="?android:attr/selectableItemBackground">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -55,7 +56,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/authorView"
|
android:layout_below="@+id/authorView"
|
||||||
android:textColor="@color/briar_text_secondary"
|
android:textColor="@color/briar_text_secondary"
|
||||||
android:textIsSelectable="true"
|
|
||||||
android:textSize="@dimen/text_size_medium"
|
android:textSize="@dimen/text_size_medium"
|
||||||
tools:text="This is a body text that shows the content of a blog post.\n\nThis one is not short, but it is also not too long."/>
|
tools:text="This is a body text that shows the content of a blog post.\n\nThis one is not short, but it is also not too long."/>
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import android.support.v4.view.ViewCompat;
|
|||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -81,14 +82,15 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
|
|||||||
|
|
||||||
void bindItem(final BlogPostItem item) {
|
void bindItem(final BlogPostItem item) {
|
||||||
setTransitionName(item.getId());
|
setTransitionName(item.getId());
|
||||||
layout.setOnClickListener(new View.OnClickListener() {
|
if (listener != null) {
|
||||||
@Override
|
layout.setClickable(true);
|
||||||
public void onClick(View v) {
|
layout.setOnClickListener(new OnClickListener() {
|
||||||
if (listener != null) {
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
listener.onBlogPostClick(item);
|
listener.onBlogPostClick(item);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
// author and date
|
// author and date
|
||||||
BlogPostHeader post = item.getPostHeader();
|
BlogPostHeader post = item.getPostHeader();
|
||||||
@@ -105,9 +107,10 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
|
|||||||
|
|
||||||
// post body
|
// post body
|
||||||
body.setText(item.getBody());
|
body.setText(item.getBody());
|
||||||
|
if (listener == null) body.setTextIsSelectable(true);
|
||||||
|
|
||||||
// reblog button
|
// reblog button
|
||||||
reblogButton.setOnClickListener(new View.OnClickListener() {
|
reblogButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent i = new Intent(ctx, ReblogActivity.class);
|
Intent i = new Intent(ctx, ReblogActivity.class);
|
||||||
@@ -154,6 +157,7 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
|
|||||||
// TODO make author clickable #624
|
// TODO make author clickable #624
|
||||||
|
|
||||||
body.setText(c.getComment());
|
body.setText(c.getComment());
|
||||||
|
if (listener == null) body.setTextIsSelectable(true);
|
||||||
|
|
||||||
commentContainer.addView(v);
|
commentContainer.addView(v);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user