mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge branch 'adb-clear-chat'
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:title="@string/menu_delete_messages"
|
||||
android:id="@+id/menu_clear_chat"/>
|
||||
|
||||
</menu>
|
||||
@@ -489,6 +489,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
menu.findItem(R.id.menu_archive_chat).setTitle(R.string.menu_unarchive_chat);
|
||||
}
|
||||
|
||||
inflater.inflate(R.menu.conversation_clear, menu);
|
||||
inflater.inflate(R.menu.conversation_delete, menu);
|
||||
|
||||
try {
|
||||
@@ -531,6 +532,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_leave: handleLeaveGroup(); return true;
|
||||
case R.id.menu_archive_chat: handleArchiveChat(); return true;
|
||||
case R.id.menu_clear_chat: fragment.handleClearChat(); return true;
|
||||
case R.id.menu_delete_chat: handleDeleteChat(); return true;
|
||||
case R.id.menu_mute_notifications: handleMuteNotifications(); return true;
|
||||
case R.id.menu_show_map: handleShowMap(); return true;
|
||||
|
||||
@@ -331,6 +331,10 @@ public class ConversationAdapter <V extends View & BindableConversationItem>
|
||||
return Collections.unmodifiableSet(new HashSet<>(batchSelected));
|
||||
}
|
||||
|
||||
public int[] getMessageIds() {
|
||||
return dcMsgList;
|
||||
}
|
||||
|
||||
public void pulseHighlightItem(int position) {
|
||||
if (position>=0 && position < getItemCount()) {
|
||||
positionToPulseHighlight = position;
|
||||
|
||||
@@ -373,6 +373,10 @@ public class ConversationFragment extends MessageSelectorFragment
|
||||
return !dcMsg.isInfo() && dcMsg.getType() != DcMsg.DC_MSG_VIDEOCHAT_INVITATION;
|
||||
}
|
||||
|
||||
public void handleClearChat() {
|
||||
handleDeleteMessages((int) chatId, getListAdapter().getMessageIds());
|
||||
}
|
||||
|
||||
private ConversationAdapter getListAdapter() {
|
||||
return (ConversationAdapter) list.getAdapter();
|
||||
}
|
||||
|
||||
@@ -55,19 +55,21 @@ public abstract class MessageSelectorFragment
|
||||
}
|
||||
|
||||
protected void handleDeleteMessages(int chatId, final Set<DcMsg> messageRecords) {
|
||||
int messagesCount = messageRecords.size();
|
||||
handleDeleteMessages(chatId, DcMsg.msgSetToIds(messageRecords));
|
||||
}
|
||||
|
||||
protected void handleDeleteMessages(int chatId, final int[] messageIds) {
|
||||
DcChat dcChat = DcHelper.getContext(getActivity()).getChat(chatId);
|
||||
|
||||
String text = getActivity().getResources().getQuantityString(
|
||||
dcChat.isDeviceTalk()? R.plurals.ask_delete_messages_simple : R.plurals.ask_delete_messages,
|
||||
messagesCount, messagesCount);
|
||||
messageIds.length, messageIds.length);
|
||||
|
||||
new AlertDialog.Builder(getActivity())
|
||||
.setMessage(text)
|
||||
.setCancelable(true)
|
||||
.setPositiveButton(R.string.delete, (dialog, which) -> {
|
||||
int[] ids = DcMsg.msgSetToIds(messageRecords);
|
||||
dcContext.deleteMsgs(ids);
|
||||
dcContext.deleteMsgs(messageIds);
|
||||
if (actionMode != null) actionMode.finish();
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
|
||||
Reference in New Issue
Block a user