mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 12:49:55 +01:00
Merge branch '1626-delete-all-messages-ui' into 'master'
Add conversation menu action to delete all messages Closes #1626 See merge request briar/briar!1159
This commit is contained in:
@@ -389,6 +389,9 @@ public class ConversationActivity extends BriarActivity
|
|||||||
AliasDialogFragment.newInstance().show(
|
AliasDialogFragment.newInstance().show(
|
||||||
getSupportFragmentManager(), AliasDialogFragment.TAG);
|
getSupportFragmentManager(), AliasDialogFragment.TAG);
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.action_delete_all_messages:
|
||||||
|
askToDeleteAllMessages();
|
||||||
|
return true;
|
||||||
case R.id.action_social_remove_person:
|
case R.id.action_social_remove_person:
|
||||||
askToRemoveContact();
|
askToRemoveContact();
|
||||||
return true;
|
return true;
|
||||||
@@ -727,6 +730,52 @@ public class ConversationActivity extends BriarActivity
|
|||||||
addConversationItem(h.accept(visitor));
|
addConversationItem(h.accept(visitor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void askToDeleteAllMessages() {
|
||||||
|
AlertDialog.Builder builder =
|
||||||
|
new AlertDialog.Builder(this, R.style.BriarDialogTheme);
|
||||||
|
builder.setTitle(getString(R.string.dialog_title_delete_all_messages));
|
||||||
|
builder.setMessage(
|
||||||
|
getString(R.string.dialog_message_delete_all_messages));
|
||||||
|
builder.setNegativeButton(R.string.delete,
|
||||||
|
(dialog, which) -> deleteAllMessages());
|
||||||
|
builder.setPositiveButton(R.string.cancel, null);
|
||||||
|
builder.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteAllMessages() {
|
||||||
|
list.showProgressBar();
|
||||||
|
runOnDbThread(() -> {
|
||||||
|
try {
|
||||||
|
boolean allDeleted =
|
||||||
|
conversationManager.deleteAllMessages(contactId);
|
||||||
|
reloadConversationAfterDeletingAllMessages(allDeleted);
|
||||||
|
} catch (DbException e) {
|
||||||
|
logException(LOG, WARNING, e);
|
||||||
|
runOnUiThreadUnlessDestroyed(() -> list.showData());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void reloadConversationAfterDeletingAllMessages(
|
||||||
|
boolean allDeleted) {
|
||||||
|
runOnUiThreadUnlessDestroyed(() -> {
|
||||||
|
adapter.clear();
|
||||||
|
loadMessages();
|
||||||
|
if (!allDeleted) showNotAllDeletedDialog();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showNotAllDeletedDialog() {
|
||||||
|
AlertDialog.Builder builder =
|
||||||
|
new AlertDialog.Builder(this, R.style.BriarDialogTheme);
|
||||||
|
builder.setTitle(
|
||||||
|
getString(R.string.dialog_title_not_all_messages_deleted));
|
||||||
|
builder.setMessage(
|
||||||
|
getString(R.string.dialog_message_not_all_messages_deleted));
|
||||||
|
builder.setPositiveButton(R.string.ok, null);
|
||||||
|
builder.show();
|
||||||
|
}
|
||||||
|
|
||||||
private void askToRemoveContact() {
|
private void askToRemoveContact() {
|
||||||
DialogInterface.OnClickListener okListener =
|
DialogInterface.OnClickListener okListener =
|
||||||
(dialog, which) -> removeContact();
|
(dialog, which) -> removeContact();
|
||||||
|
|||||||
@@ -16,6 +16,11 @@
|
|||||||
android:enabled="false"
|
android:enabled="false"
|
||||||
app:showAsAction="never"/>
|
app:showAsAction="never"/>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_delete_all_messages"
|
||||||
|
android:title="@string/delete_all_messages"
|
||||||
|
app:showAsAction="never"/>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_social_remove_person"
|
android:id="@+id/action_social_remove_person"
|
||||||
android:icon="@drawable/action_delete_white"
|
android:icon="@drawable/action_delete_white"
|
||||||
|
|||||||
@@ -135,6 +135,11 @@
|
|||||||
<string name="set_contact_alias">Change contact name</string>
|
<string name="set_contact_alias">Change contact name</string>
|
||||||
<string name="set_contact_alias_hint">Contact name</string>
|
<string name="set_contact_alias_hint">Contact name</string>
|
||||||
<string name="set_alias_button">Change</string>
|
<string name="set_alias_button">Change</string>
|
||||||
|
<string name="delete_all_messages">Delete all messages</string>
|
||||||
|
<string name="dialog_title_delete_all_messages">Confirm Message Deletion</string>
|
||||||
|
<string name="dialog_message_delete_all_messages">Are you sure that you want to delete all messages?</string>
|
||||||
|
<string name="dialog_title_not_all_messages_deleted">Could not delete all messages</string>
|
||||||
|
<string name="dialog_message_not_all_messages_deleted">Messages related to introductions or invitations cannot be deleted at the moment.</string>
|
||||||
<string name="delete_contact">Delete contact</string>
|
<string name="delete_contact">Delete contact</string>
|
||||||
<string name="dialog_title_delete_contact">Confirm Contact Deletion</string>
|
<string name="dialog_title_delete_contact">Confirm Contact Deletion</string>
|
||||||
<string name="dialog_message_delete_contact">Are you sure that you want to remove this contact and all messages exchanged with this contact?</string>
|
<string name="dialog_message_delete_contact">Are you sure that you want to remove this contact and all messages exchanged with this contact?</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user