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) {
|
private void setCorrectMenuVisibility(Menu menu) {
|
||||||
Set<MessageRecord> messageRecords = getListAdapter().getSelectedItems();
|
Set<MessageRecord> messageRecords = getListAdapter().getSelectedItems();
|
||||||
boolean actionMessage = false;
|
boolean actionMessage = false;
|
||||||
boolean mediaMessage = false;
|
boolean hasText = false;
|
||||||
|
|
||||||
if (actionMode != null && messageRecords.size() == 0) {
|
if (actionMode != null && messageRecords.size() == 0) {
|
||||||
actionMode.finish();
|
actionMode.finish();
|
||||||
|
@ -215,12 +215,11 @@ public class ConversationFragment extends Fragment
|
||||||
messageRecord.isIdentityVerified() || messageRecord.isIdentityDefault())
|
messageRecord.isIdentityVerified() || messageRecord.isIdentityDefault())
|
||||||
{
|
{
|
||||||
actionMessage = true;
|
actionMessage = true;
|
||||||
break;
|
}
|
||||||
} else if (messageRecord.isMms() &&
|
if (messageRecord.getBody().length() > 0) {
|
||||||
!messageRecord.isMmsNotification() &&
|
hasText = true;
|
||||||
((MediaMmsMessageRecord)messageRecord).containsMediaSlide())
|
}
|
||||||
{
|
if (actionMessage && hasText) {
|
||||||
mediaMessage = true;
|
|
||||||
break;
|
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_details).setVisible(false);
|
||||||
menu.findItem(R.id.menu_context_save_attachment).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_resend).setVisible(false);
|
||||||
menu.findItem(R.id.menu_context_copy).setVisible(!actionMessage && !mediaMessage);
|
|
||||||
} else {
|
} else {
|
||||||
MessageRecord messageRecord = messageRecords.iterator().next();
|
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_forward).setVisible(!actionMessage);
|
||||||
menu.findItem(R.id.menu_context_details).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() {
|
private ConversationAdapter getListAdapter() {
|
||||||
|
@ -293,17 +291,16 @@ public class ConversationFragment extends Fragment
|
||||||
|
|
||||||
StringBuilder bodyBuilder = new StringBuilder();
|
StringBuilder bodyBuilder = new StringBuilder();
|
||||||
ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
|
ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
boolean first = true;
|
|
||||||
|
|
||||||
for (MessageRecord messageRecord : messageList) {
|
for (MessageRecord messageRecord : messageList) {
|
||||||
String body = messageRecord.getDisplayBody().toString();
|
String body = messageRecord.getDisplayBody().toString();
|
||||||
|
if (!TextUtils.isEmpty(body)) {
|
||||||
if (body != null) {
|
bodyBuilder.append(body).append('\n');
|
||||||
if (!first) bodyBuilder.append('\n');
|
|
||||||
bodyBuilder.append(body);
|
|
||||||
first = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (bodyBuilder.length() > 0 && bodyBuilder.charAt(bodyBuilder.length() - 1) == '\n') {
|
||||||
|
bodyBuilder.deleteCharAt(bodyBuilder.length() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
String result = bodyBuilder.toString();
|
String result = bodyBuilder.toString();
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue