Fix message action inconsistencies

This commit is contained in:
nielsandriesse 2020-06-23 11:59:51 +10:00
parent 927bcce764
commit 21fab09d6c

View File

@ -375,9 +375,7 @@ public class ConversationFragment extends Fragment
} }
if (messageRecords.size() > 1) { if (messageRecords.size() > 1) {
// menu.findItem(R.id.menu_context_forward).setVisible(false);
menu.findItem(R.id.menu_context_reply).setVisible(false); menu.findItem(R.id.menu_context_reply).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);
} else { } else {
@ -390,32 +388,29 @@ public class ConversationFragment extends Fragment
((MediaMmsMessageRecord)messageRecord).containsMediaSlide() && ((MediaMmsMessageRecord)messageRecord).containsMediaSlide() &&
((MediaMmsMessageRecord)messageRecord).getSlideDeck().getStickerSlide() == null); ((MediaMmsMessageRecord)messageRecord).getSlideDeck().getStickerSlide() == null);
/*
menu.findItem(R.id.menu_context_forward).setVisible(!actionMessage && !sharedContact);
menu.findItem(R.id.menu_context_details).setVisible(!actionMessage);
*/
menu.findItem(R.id.menu_context_reply).setVisible(!actionMessage && menu.findItem(R.id.menu_context_reply).setVisible(!actionMessage &&
!messageRecord.isPending() && !messageRecord.isPending() &&
!messageRecord.isFailed() && !messageRecord.isFailed() &&
messageRecord.isSecure()); messageRecord.isSecure());
} }
menu.findItem(R.id.menu_context_copy).setVisible(!actionMessage && hasText); menu.findItem(R.id.menu_context_copy).setVisible(!actionMessage && hasText);
boolean isGroupChat = recipient.isGroupRecipient(); boolean isGroupChat = recipient.isGroupRecipient();
if (isGroupChat) { if (isGroupChat) {
LokiPublicChat publicChat = DatabaseFactory.getLokiThreadDatabase(getContext()).getPublicChat(threadId); LokiPublicChat publicChat = DatabaseFactory.getLokiThreadDatabase(getContext()).getPublicChat(threadId);
boolean isPublicChat = publicChat != null; boolean isPublicChat = (publicChat != null);
int selectedMessageCount = messageRecords.size(); int selectedMessageCount = messageRecords.size();
boolean areAllSentByUser = true; boolean areAllSentByUser = true;
for (MessageRecord message : messageRecords) { for (MessageRecord message : messageRecords) {
if (!message.isOutgoing()) { areAllSentByUser = false; } if (!message.isOutgoing()) { areAllSentByUser = false; }
} }
menu.findItem(R.id.menu_context_copy_public_key).setVisible(isPublicChat && selectedMessageCount == 1 && !areAllSentByUser); menu.findItem(R.id.menu_context_copy_public_key).setVisible(isPublicChat && selectedMessageCount == 1 && !areAllSentByUser);
menu.findItem(R.id.menu_context_reply).setVisible(isPublicChat && selectedMessageCount == 1); menu.findItem(R.id.menu_context_reply).setVisible(selectedMessageCount == 1);
String userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(getContext()); String userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(getContext());
boolean userCanModerate = isPublicChat && LokiPublicChatAPI.Companion.isUserModerator(userHexEncodedPublicKey, publicChat.getChannel(), publicChat.getServer()); boolean userCanModerate = isPublicChat && LokiPublicChatAPI.Companion.isUserModerator(userHexEncodedPublicKey, publicChat.getChannel(), publicChat.getServer());
boolean isDeleteOptionVisible = isPublicChat && (areAllSentByUser || userCanModerate); boolean isDeleteOptionVisible = !isPublicChat || (areAllSentByUser || userCanModerate);
menu.findItem(R.id.menu_context_delete_message).setVisible(isDeleteOptionVisible); menu.findItem(R.id.menu_context_delete_message).setVisible(isDeleteOptionVisible);
} else { } else {
menu.findItem(R.id.menu_context_copy_public_key).setVisible(false); menu.findItem(R.id.menu_context_copy_public_key).setVisible(false);