aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-12-26 19:18:37 +0100
committerDaniel Gultsch <daniel@gultsch.de>2015-12-26 19:18:37 +0100
commitbe91c0741f5e6d28124981380fbff9d687f0edf2 (patch)
tree8cd1b53a80f9c0d50d662c30e0eceec867dbf0c3 /src/main/java/eu/siacs
parentc40372fc0d1bc81650321b0166c06a0be05ac0a2 (diff)
made text selectable again unless text contains more than 1 link
fixes #1615
Diffstat (limited to 'src/main/java/eu/siacs')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
index fd2e5751..add0bc08 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -18,6 +18,7 @@ import android.text.style.ForegroundColorSpan;
import android.text.style.RelativeSizeSpan;
import android.text.style.StyleSpan;
import android.util.DisplayMetrics;
+import android.util.Patterns;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
@@ -32,6 +33,7 @@ import android.widget.Toast;
import java.lang.ref.WeakReference;
import java.util.List;
import java.util.concurrent.RejectedExecutionException;
+import java.util.regex.Matcher;
import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
@@ -244,6 +246,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
viewHolder.messageBody.setText(text);
viewHolder.messageBody.setTextColor(getMessageTextColor(darkBackground, false));
viewHolder.messageBody.setTypeface(null, Typeface.ITALIC);
+ viewHolder.messageBody.setTextIsSelectable(false);
}
private void displayDecryptionFailed(ViewHolder viewHolder, boolean darkBackground) {
@@ -256,6 +259,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
R.string.decryption_failed));
viewHolder.messageBody.setTextColor(getMessageTextColor(darkBackground, false));
viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
+ viewHolder.messageBody.setTextIsSelectable(false);
}
private void displayHeartMessage(final ViewHolder viewHolder, final String body) {
@@ -330,8 +334,15 @@ public class MessageAdapter extends ArrayAdapter<Message> {
}
viewHolder.messageBody.setText(span);
}
+ int urlCount = 0;
+ Matcher matcher = Patterns.WEB_URL.matcher(body);
+ while (matcher.find()) {
+ urlCount++;
+ }
+ viewHolder.messageBody.setTextIsSelectable(urlCount <= 1);
} else {
viewHolder.messageBody.setText("");
+ viewHolder.messageBody.setTextIsSelectable(false);
}
viewHolder.messageBody.setTextColor(this.getMessageTextColor(darkBackground, true));
viewHolder.messageBody.setLinkTextColor(this.getMessageTextColor(darkBackground, true));