From 60b4c5649adf4719acf897ef6df0f567ca56aba7 Mon Sep 17 00:00:00 2001
From: Torsten Grote <t@grobox.de>
Date: Mon, 5 Sep 2016 14:33:44 -0300
Subject: [PATCH] Make blog post text clickable

by making it only selectable in detail view
---
 .../res/layout/list_item_blog_comment.xml      |  1 -
 .../res/layout/list_item_blog_post.xml         |  4 ++--
 .../android/blogs/BlogPostViewHolder.java      | 18 +++++++++++-------
 3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/briar-android/res/layout/list_item_blog_comment.xml b/briar-android/res/layout/list_item_blog_comment.xml
index bdbe42842d..1be478ab2f 100644
--- a/briar-android/res/layout/list_item_blog_comment.xml
+++ b/briar-android/res/layout/list_item_blog_comment.xml
@@ -29,7 +29,6 @@
 		android:paddingLeft="@dimen/listitem_vertical_margin"
 		android:paddingRight="@dimen/listitem_vertical_margin"
 		android:textColor="@color/briar_text_secondary"
-		android:textIsSelectable="true"
 		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."/>
 
diff --git a/briar-android/res/layout/list_item_blog_post.xml b/briar-android/res/layout/list_item_blog_post.xml
index 8b136f2b7d..d3cd14d489 100644
--- a/briar-android/res/layout/list_item_blog_post.xml
+++ b/briar-android/res/layout/list_item_blog_post.xml
@@ -6,7 +6,8 @@
 	xmlns:app="http://schemas.android.com/apk/res-auto"
 	xmlns:tools="http://schemas.android.com/tools"
 	android:layout_width="match_parent"
-	android:layout_height="wrap_content">
+	android:layout_height="wrap_content"
+	android:foreground="?android:attr/selectableItemBackground">
 
 	<LinearLayout
 		android:layout_width="match_parent"
@@ -55,7 +56,6 @@
 				android:layout_height="wrap_content"
 				android:layout_below="@+id/authorView"
 				android:textColor="@color/briar_text_secondary"
-				android:textIsSelectable="true"
 				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."/>
 
diff --git a/briar-android/src/org/briarproject/android/blogs/BlogPostViewHolder.java b/briar-android/src/org/briarproject/android/blogs/BlogPostViewHolder.java
index 9cc23d0797..186792a11b 100644
--- a/briar-android/src/org/briarproject/android/blogs/BlogPostViewHolder.java
+++ b/briar-android/src/org/briarproject/android/blogs/BlogPostViewHolder.java
@@ -10,6 +10,7 @@ import android.support.v4.view.ViewCompat;
 import android.support.v7.widget.RecyclerView;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.widget.ImageView;
 import android.widget.TextView;
@@ -81,14 +82,15 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
 
 	void bindItem(final BlogPostItem item) {
 		setTransitionName(item.getId());
-		layout.setOnClickListener(new View.OnClickListener() {
-			@Override
-			public void onClick(View v) {
-				if (listener != null) {
+		if (listener != null) {
+			layout.setClickable(true);
+			layout.setOnClickListener(new OnClickListener() {
+				@Override
+				public void onClick(View v) {
 					listener.onBlogPostClick(item);
 				}
-			}
-		});
+			});
+		}
 
 		// author and date
 		BlogPostHeader post = item.getPostHeader();
@@ -105,9 +107,10 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
 
 		// post body
 		body.setText(item.getBody());
+		if (listener == null) body.setTextIsSelectable(true);
 
 		// reblog button
-		reblogButton.setOnClickListener(new View.OnClickListener() {
+		reblogButton.setOnClickListener(new OnClickListener() {
 			@Override
 			public void onClick(View v) {
 				Intent i = new Intent(ctx, ReblogActivity.class);
@@ -154,6 +157,7 @@ class BlogPostViewHolder extends RecyclerView.ViewHolder {
 			// TODO make author clickable #624
 
 			body.setText(c.getComment());
+			if (listener == null) body.setTextIsSelectable(true);
 
 			commentContainer.addView(v);
 		}
-- 
GitLab