Skip to content
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.

Clear chat by long click in dialogs #989

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ protected boolean onItemLongClick(Dialog dialog) {
.setItems(new CharSequence[]{
getString(R.string.dialogs_menu_contact_view),
getString(R.string.dialogs_menu_contact_rename),
getString(R.string.dialogs_menu_conversation_clear),
getString(R.string.dialogs_menu_conversation_delete)
}, (d, which) -> {
if (which == 0) {
Expand All @@ -44,6 +45,26 @@ protected boolean onItemLongClick(Dialog dialog) {
// Rename user
startActivity(Intents.editUserName(dialog.getPeer().getPeerId(), getActivity()));
} else if (which == 2) {
// Clear chat
new AlertDialog.Builder(getActivity())
.setMessage(getString(R.string.alert_clear_chat_message, dialog.getDialogTitle()))
.setNegativeButton(R.string.dialog_cancel, null)
.setPositiveButton(R.string.alert_clear_chat_yes, (d1, which1) -> {
execute(messenger().clearChat(dialog.getPeer()), R.string.progress_common,
new CommandCallback<Void>() {
@Override
public void onResult(Void res) {

}

@Override
public void onError(Exception e) {
Toast.makeText(getActivity(), R.string.toast_unable_delete_chat, Toast.LENGTH_LONG).show();
}
});
})
.show();
} else if (which == 3) {
// Delete chat
new AlertDialog.Builder(getActivity())
.setMessage(getString(R.string.alert_delete_chat_message, dialog.getDialogTitle()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@

<string name="dialogs_menu_contact_view">Посмотреть контакт</string>
<string name="dialogs_menu_contact_rename">Переименовать контакт</string>
<string name="dialogs_menu_conversation_clear">Очистить чат</string>
<string name="dialogs_menu_conversation_delete">Удалить чат</string>

<string name="dialogs_menu_group_view">Информация о группе</string>
Expand Down Expand Up @@ -632,6 +633,9 @@
<string name="alert_delete_channel_title">Вы уверены, что хотите удалить канал "%1$s"?</string>
<string name="alert_delete_group_yes">Удалить</string>

<string name="alert_clear_chat_message">Очистить чат с "%1$s"?</string>
<string name="alert_clear_chat_yes">Очистить</string>

<string name="alert_delete_chat_message">Вы уверены, что хотите удалить чат с "%1$s"?</string>
<string name="alert_delete_chat_yes">Удалить</string>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@

<string name="dialogs_menu_contact_view">View contact</string>
<string name="dialogs_menu_contact_rename">Rename contact</string>
<string name="dialogs_menu_conversation_clear">Clear conversation</string>
<string name="dialogs_menu_conversation_delete">Delete conversation</string>

<string name="dialogs_menu_group_view">View group info</string>
Expand Down Expand Up @@ -631,6 +632,9 @@
<string name="alert_delete_channel_title">Delete "%1$s" channel?</string>
<string name="alert_delete_group_yes">Delete</string>

<string name="alert_clear_chat_message">Clear chat with "%1$s"?</string>
<string name="alert_clear_chat_yes">Clear</string>

<string name="alert_delete_chat_message">Delete chat with "%1$s"?</string>
<string name="alert_delete_chat_yes">Delete</string>

Expand Down