Don't allow quoting system messages and voice message invites

Swipe-to-reply already was disabled for them, now quoting by long-press
is disabled, too.
This commit is contained in:
Hocuri
2020-10-21 12:18:32 +02:00
parent c524543278
commit 1c1300cdff
2 changed files with 20 additions and 5 deletions
@@ -164,8 +164,7 @@ public class ConversationFragment extends Fragment
list.setItemAnimator(null);
new ConversationItemSwipeCallback(
msg -> actionMode == null &&
dcContext.getChat(msg.getChatId()).canSend(),
msg -> actionMode == null,
this::handleReplyMessage
).attachToRecyclerView(list);
@@ -343,12 +342,17 @@ public class ConversationFragment extends Fragment
DcChat chat = getListAdapter().getChat();
menu.findItem(R.id.menu_context_details).setVisible(true);
menu.findItem(R.id.menu_context_save_attachment).setVisible(messageRecord.hasFile());
menu.findItem(R.id.menu_context_reply).setVisible(chat.canSend());
boolean showReplyPrivately = chat.isGroup() && !messageRecord.isOutgoing();
boolean canReply = canReplyToMsg(messageRecord);
menu.findItem(R.id.menu_context_reply).setVisible(chat.canSend() && canReply);
boolean showReplyPrivately = chat.isGroup() && !messageRecord.isOutgoing() && canReply;
menu.findItem(R.id.menu_context_reply_privately).setVisible(showReplyPrivately);
}
}
static boolean canReplyToMsg(DcMsg dcMsg) {
return !dcMsg.isInfo() && dcMsg.getType() != DcMsg.DC_MSG_VIDEOCHAT_INVITATION;
}
private ConversationAdapter getListAdapter() {
return (ConversationAdapter) list.getAdapter();
}
@@ -215,9 +215,20 @@ public class ConversationItem extends LinearLayout
}
public boolean disallowSwipe(float downX, float downY) {
if (BuildConfig.DEBUG) {
// If it is possible to reply to a message, it should also be possible to swipe it.
// For this to be possible we need a non-null reply icon.
boolean replyNull = (reply == null);
boolean canReply = ConversationFragment.canReplyToMsg(messageRecord);
if (replyNull == canReply) {
String msg = "(reply == null) was " + replyNull + " but canReplyToMsg() was " + canReply;
throw new AssertionError(msg);
}
}
if (reply == null) return true;
if (!hasAudio(messageRecord)) return false;
if (!dcChat.canSend()) return true;
if (!hasAudio(messageRecord)) return false;
audioViewStub.get().getSeekBarGlobalVisibleRect(SWIPE_RECT);
return SWIPE_RECT.contains((int) downX, (int) downY);
}