mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
implement archive/unarchive/delete/leave from chat-activity
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/conversation__menu_archive_chat"
|
||||
android:id="@+id/menu_archive_chat"/>
|
||||
|
||||
</menu>
|
||||
@@ -1,9 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:title="@string/conversation__menu_archive_chat"
|
||||
android:id="@+id/menu_archive_chat"/>
|
||||
|
||||
<item android:title="@string/conversation__menu_delete_chat"
|
||||
android:id="@+id/menu_delete_chat"/>
|
||||
|
||||
|
||||
@@ -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/conversation__menu_unarchive_chat"
|
||||
android:id="@+id/menu_archive_chat"/>
|
||||
|
||||
</menu>
|
||||
@@ -172,6 +172,7 @@
|
||||
<string name="ConversationActivity_quoted_contact_message">%1$s %2$s</string>
|
||||
<string name="ConversationActivity_NoMessagesHint">Send message to %1$s:\n\n• It is okay if %2$s does not use Delta Chat.\n\n• Delivering the first message may take a while.</string>
|
||||
<string name="ConversationActivity_MsgNewGroupDraftHint">Compose the first message, allowing others to reply within this group.\n\n• It is okay if not all members use Delta Chat.\n\n• Delivering the first message may take a while.</string>
|
||||
<string name="ConversationActivity_ask_delete_chat">Delete this chat? It will no longer be shown in the chat list, its messages will remain on the server.</string>
|
||||
|
||||
<!-- ConversationAdapter -->
|
||||
<plurals name="ConversationAdapter_n_unread_messages">
|
||||
@@ -232,9 +233,9 @@
|
||||
<item quantity="one">Delete selected chats?</item>
|
||||
<item quantity="other">Delete selected chats?</item>
|
||||
</plurals>
|
||||
<plurals name="ConversationListFragment_this_will_permanently_delete_all_n_selected_conversations">
|
||||
<item quantity="one">This will permanently delete the selected chats.</item>
|
||||
<item quantity="other">This will permanently delete all %1$d selected chats.</item>
|
||||
<plurals name="ConversationListFragment_ask_selected_chats">
|
||||
<item quantity="one">Delete the selected chat? It will no longer be shown in the chat list, its messages will remain on the server.</item>
|
||||
<item quantity="other">Delete %1%d selected chats? They will no longer be shown in the chat list, their messages will remain on the server.</item>
|
||||
</plurals>
|
||||
<string name="ConversationListFragment_deleting">Deleting</string>
|
||||
<string name="ConversationListFragment_deleting_selected_conversations">Deleting selected chats...</string>
|
||||
@@ -1529,6 +1530,7 @@
|
||||
<string name="never">Never</string>
|
||||
<string name="conversation__menu_view_profile">View profile</string>
|
||||
<string name="conversation__menu_archive_chat">Archive chat</string>
|
||||
<string name="conversation__menu_unarchive_chat">Unarchive chat</string>
|
||||
<string name="conversation__menu_delete_chat">Delete chat</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -489,8 +489,12 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
return true;
|
||||
}
|
||||
|
||||
if (recipient != null && recipient.isMuted()) inflater.inflate(R.menu.conversation_muted, menu);
|
||||
else inflater.inflate(R.menu.conversation_unmuted, menu);
|
||||
if (recipient != null && recipient.isMuted()) {
|
||||
inflater.inflate(R.menu.conversation_muted, menu);
|
||||
}
|
||||
else {
|
||||
inflater.inflate(R.menu.conversation_unmuted, menu);
|
||||
}
|
||||
|
||||
inflater.inflate(R.menu.conversation, menu);
|
||||
|
||||
@@ -500,6 +504,13 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
}
|
||||
|
||||
if( dcChat.getArchived()==0 ) {
|
||||
inflater.inflate(R.menu.conversation_archive, menu);
|
||||
}
|
||||
else {
|
||||
inflater.inflate(R.menu.conversation_unarchive, menu);
|
||||
}
|
||||
|
||||
inflater.inflate(R.menu.conversation_delete, menu);
|
||||
|
||||
super.onPrepareOptionsMenu(menu);
|
||||
@@ -510,14 +521,16 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
super.onOptionsItemSelected(item);
|
||||
switch (item.getItemId()) {
|
||||
case R.id.menu_add_attachment: handleAddAttachment(); return true;
|
||||
case R.id.menu_view_media: handleViewMedia(); return true;
|
||||
case R.id.menu_edit_group: handleEditPushGroup(); return true;
|
||||
case R.id.menu_leave: handleLeaveGroup(); return true;
|
||||
case R.id.menu_mute_notifications: handleMuteNotifications(); return true;
|
||||
case R.id.menu_unmute_notifications: handleUnmuteNotifications(); return true;
|
||||
case R.id.menu_conversation_settings: handleConversationSettings(); return true;
|
||||
case android.R.id.home: handleReturnToConversationList(); return true;
|
||||
case R.id.menu_add_attachment: handleAddAttachment(); return true;
|
||||
case R.id.menu_view_media: handleViewMedia(); return true;
|
||||
case R.id.menu_edit_group: handleEditPushGroup(); return true;
|
||||
case R.id.menu_leave: handleLeaveGroup(); return true;
|
||||
case R.id.menu_archive_chat: handleArchiveChat(); return true;
|
||||
case R.id.menu_delete_chat: handleDeleteChat(); return true;
|
||||
case R.id.menu_mute_notifications: handleMuteNotifications(); return true;
|
||||
case R.id.menu_unmute_notifications: handleUnmuteNotifications(); return true;
|
||||
case R.id.menu_conversation_settings: handleConversationSettings(); return true;
|
||||
case android.R.id.home: handleReturnToConversationList(); return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -604,11 +617,33 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
.setMessage(getString(R.string.ConversationActivity_are_you_sure_you_want_to_leave_this_group))
|
||||
.setPositiveButton(R.string.yes, (dialog, which) -> {
|
||||
dcContext.removeContactFromChat((int)threadId, DcContact.DC_CONTACT_ID_SELF);
|
||||
Toast.makeText(this, getString(R.string.done), Toast.LENGTH_SHORT).show();
|
||||
})
|
||||
.setNegativeButton(R.string.no, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void handleArchiveChat() {
|
||||
int doArchive = dcContext.getChat((int)threadId).getArchived()==0? 1: 0;
|
||||
dcContext.archiveChat((int)threadId, doArchive);
|
||||
Toast.makeText(this, getString(R.string.done), Toast.LENGTH_SHORT).show();
|
||||
if( doArchive == 1 ) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDeleteChat() {
|
||||
new AlertDialog.Builder(this)
|
||||
.setMessage(getString(R.string.ConversationActivity_ask_delete_chat))
|
||||
.setPositiveButton(R.string.yes, (dialog, which) -> {
|
||||
dcContext.deleteChat((int)threadId);
|
||||
Toast.makeText(this, getString(R.string.done), Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
})
|
||||
.setNegativeButton(R.string.no, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void handleEditPushGroup() {
|
||||
Intent intent = new Intent(ConversationActivity.this, GroupCreateActivity.class);
|
||||
intent.putExtra(GroupCreateActivity.GROUP_ADDRESS_EXTRA, recipient.getAddress());
|
||||
|
||||
@@ -273,10 +273,7 @@ public class ConversationListFragment extends Fragment
|
||||
final DcContext dcContext = DcHelper.getContext(getActivity());
|
||||
int conversationsCount = getListAdapter().getBatchSelections().size();
|
||||
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
|
||||
alert.setIconAttribute(R.attr.dialog_alert_icon);
|
||||
alert.setTitle(getActivity().getResources().getQuantityString(R.plurals.ConversationListFragment_delete_selected_conversations,
|
||||
conversationsCount, conversationsCount));
|
||||
alert.setMessage(getActivity().getResources().getQuantityString(R.plurals.ConversationListFragment_this_will_permanently_delete_all_n_selected_conversations,
|
||||
alert.setMessage(getActivity().getResources().getQuantityString(R.plurals.ConversationListFragment_ask_selected_chats,
|
||||
conversationsCount, conversationsCount));
|
||||
alert.setCancelable(true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user