mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user