Messaging: allow selecting text inside the selected message

Test: receive a message, select it by long press, verify text is selectable.
Change-Id: I9f80df970c6ee1c06b8056c78bffe942eb8eb9bf
Signed-off-by: Timi Rautamäki <timi.rautamaki@gmail.com>
This commit is contained in:
Timi Rautamäki
2021-07-03 20:30:08 +02:00
parent 20d8640ba0
commit 78ecab8743

View File

@@ -708,6 +708,7 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
textBottomPadding = textBottomPaddingDefault; textBottomPadding = textBottomPaddingDefault;
textLeftPadding = messageTextLeftRightPadding; textLeftPadding = messageTextLeftRightPadding;
textRightPadding = messageTextLeftRightPadding; textRightPadding = messageTextLeftRightPadding;
mMessageTextView.setTextIsSelectable(isSelected());
} else { } else {
// Attachment(s) only // Attachment(s) only
contentLeftPadding = incoming ? arrowWidth : 0; contentLeftPadding = incoming ? arrowWidth : 0;
@@ -733,6 +734,7 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
textTopMargin = 0; textTopMargin = 0;
textTopPadding = textTopPaddingDefault; textTopPadding = textTopPaddingDefault;
textBottomPadding = textBottomPaddingDefault; textBottomPadding = textBottomPaddingDefault;
mMessageTextView.setTextIsSelectable(isSelected());
if (showArrow && incoming) { if (showArrow && incoming) {
textLeftPadding = messageTextLeftRightPadding + arrowWidth; textLeftPadding = messageTextLeftRightPadding + arrowWidth;
} else { } else {
@@ -1030,6 +1032,11 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
@Override @Override
public boolean onLongClick(final View view) { public boolean onLongClick(final View view) {
if (view == mMessageTextView) { if (view == mMessageTextView) {
// Avoid trying to reselect the message
if (isSelected()) {
return false;
}
// Preemptively handle the long click event on message text so it's not handled by // Preemptively handle the long click event on message text so it's not handled by
// the link spans. // the link spans.
return performLongClick(); return performLongClick();
@@ -1195,7 +1202,7 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
// This touch event is a long click, preemptively handle this touch event so that // This touch event is a long click, preemptively handle this touch event so that
// the link span won't get a onClicked() callback. // the link span won't get a onClicked() callback.
mIsLongClick = false; mIsLongClick = false;
return true; return false;
} }
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {