made text selectable again unless text contains more than 1 link
fixes #1615
This commit is contained in:
parent
c40372fc0d
commit
be91c0741f
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue