kopia lustrzana https://github.com/ryukoposting/Signal-Android
Only show copy if text is selected, remove newlines from copied text.
We now check if _any_ text is selected when doing a batch selection to determine if we should show the copy option. Also, previously it was putting in empty lines for messages that don't have any text. I changed it so empty messages have no effect on the text that is copied. Fixes #7472fork-5.53.8
rodzic
404610fbcd
commit
b8fbc91f33
|
@ -201,7 +201,7 @@ public class ConversationFragment extends Fragment
|
|||
private void setCorrectMenuVisibility(Menu menu) {
|
||||
Set<MessageRecord> messageRecords = getListAdapter().getSelectedItems();
|
||||
boolean actionMessage = false;
|
||||
boolean mediaMessage = false;
|
||||
boolean hasText = false;
|
||||
|
||||
if (actionMode != null && messageRecords.size() == 0) {
|
||||
actionMode.finish();
|
||||
|
@ -215,12 +215,11 @@ public class ConversationFragment extends Fragment
|
|||
messageRecord.isIdentityVerified() || messageRecord.isIdentityDefault())
|
||||
{
|
||||
actionMessage = true;
|
||||
break;
|
||||
} else if (messageRecord.isMms() &&
|
||||
!messageRecord.isMmsNotification() &&
|
||||
((MediaMmsMessageRecord)messageRecord).containsMediaSlide())
|
||||
{
|
||||
mediaMessage = true;
|
||||
}
|
||||
if (messageRecord.getBody().length() > 0) {
|
||||
hasText = true;
|
||||
}
|
||||
if (actionMessage && hasText) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -230,7 +229,6 @@ public class ConversationFragment extends Fragment
|
|||
menu.findItem(R.id.menu_context_details).setVisible(false);
|
||||
menu.findItem(R.id.menu_context_save_attachment).setVisible(false);
|
||||
menu.findItem(R.id.menu_context_resend).setVisible(false);
|
||||
menu.findItem(R.id.menu_context_copy).setVisible(!actionMessage && !mediaMessage);
|
||||
} else {
|
||||
MessageRecord messageRecord = messageRecords.iterator().next();
|
||||
|
||||
|
@ -242,8 +240,8 @@ public class ConversationFragment extends Fragment
|
|||
|
||||
menu.findItem(R.id.menu_context_forward).setVisible(!actionMessage);
|
||||
menu.findItem(R.id.menu_context_details).setVisible(!actionMessage);
|
||||
menu.findItem(R.id.menu_context_copy).setVisible(!actionMessage && !mediaMessage);
|
||||
}
|
||||
menu.findItem(R.id.menu_context_copy).setVisible(!actionMessage && hasText);
|
||||
}
|
||||
|
||||
private ConversationAdapter getListAdapter() {
|
||||
|
@ -293,17 +291,16 @@ public class ConversationFragment extends Fragment
|
|||
|
||||
StringBuilder bodyBuilder = new StringBuilder();
|
||||
ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
boolean first = true;
|
||||
|
||||
for (MessageRecord messageRecord : messageList) {
|
||||
String body = messageRecord.getDisplayBody().toString();
|
||||
|
||||
if (body != null) {
|
||||
if (!first) bodyBuilder.append('\n');
|
||||
bodyBuilder.append(body);
|
||||
first = false;
|
||||
if (!TextUtils.isEmpty(body)) {
|
||||
bodyBuilder.append(body).append('\n');
|
||||
}
|
||||
}
|
||||
if (bodyBuilder.length() > 0 && bodyBuilder.charAt(bodyBuilder.length() - 1) == '\n') {
|
||||
bodyBuilder.deleteCharAt(bodyBuilder.length() - 1);
|
||||
}
|
||||
|
||||
String result = bodyBuilder.toString();
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue