diff --git a/res/menu/conversation_archive.xml b/res/menu/conversation_archive.xml new file mode 100644 index 000000000..72eaa4985 --- /dev/null +++ b/res/menu/conversation_archive.xml @@ -0,0 +1,7 @@ + + + + + + diff --git a/res/menu/conversation_delete.xml b/res/menu/conversation_delete.xml index d8d0e417f..48cd127b6 100644 --- a/res/menu/conversation_delete.xml +++ b/res/menu/conversation_delete.xml @@ -1,9 +1,6 @@ - - diff --git a/res/menu/conversation_unarchive.xml b/res/menu/conversation_unarchive.xml new file mode 100644 index 000000000..fe5c30eea --- /dev/null +++ b/res/menu/conversation_unarchive.xml @@ -0,0 +1,7 @@ + + + + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index 1a18c4100..31b05ccef 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -172,6 +172,7 @@ %1$s %2$s 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. 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. + Delete this chat? It will no longer be shown in the chat list, its messages will remain on the server. @@ -232,9 +233,9 @@ Delete selected chats? Delete selected chats? - - This will permanently delete the selected chats. - This will permanently delete all %1$d selected chats. + + Delete the selected chat? It will no longer be shown in the chat list, its messages will remain on the server. + Delete %1%d selected chats? They will no longer be shown in the chat list, their messages will remain on the server. Deleting Deleting selected chats... @@ -1529,6 +1530,7 @@ Never View profile Archive chat + Unarchive chat Delete chat diff --git a/src/org/thoughtcrime/securesms/ConversationActivity.java b/src/org/thoughtcrime/securesms/ConversationActivity.java index f5f392931..5c7ce5177 100644 --- a/src/org/thoughtcrime/securesms/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/ConversationActivity.java @@ -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()); diff --git a/src/org/thoughtcrime/securesms/ConversationListFragment.java b/src/org/thoughtcrime/securesms/ConversationListFragment.java index f98bc2f38..8507a6c0e 100644 --- a/src/org/thoughtcrime/securesms/ConversationListFragment.java +++ b/src/org/thoughtcrime/securesms/ConversationListFragment.java @@ -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);