aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/eu/siacs/conversations/persistance/DatabaseBackend.java6
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java7
-rw-r--r--src/eu/siacs/conversations/ui/ConversationActivity.java33
3 files changed, 32 insertions, 14 deletions
diff --git a/src/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/eu/siacs/conversations/persistance/DatabaseBackend.java
index ad4555c2..c8c974de 100644
--- a/src/eu/siacs/conversations/persistance/DatabaseBackend.java
+++ b/src/eu/siacs/conversations/persistance/DatabaseBackend.java
@@ -288,6 +288,12 @@ public class DatabaseBackend extends SQLiteOpenHelper {
String[] args = { message.getUuid() };
db.delete(Message.TABLENAME, Message.UUID + "=?", args);
}
+
+ public void deleteMessagesInConversation(Conversation conversation) {
+ SQLiteDatabase db = this.getWritableDatabase();
+ String[] args = { conversation.getUuid() };
+ db.delete(Message.TABLENAME, Message.CONVERSATION + "=?", args);
+ }
public void deleteContact(Contact contact) {
SQLiteDatabase db = this.getWritableDatabase();
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 5e4e2561..49cb6288 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -1035,7 +1035,12 @@ public class XmppConnectionService extends Service {
}
public void clearConversationHistory(Conversation conversation) {
-
+ this.databaseBackend.deleteMessagesInConversation(conversation);
+ this.fileBackend.removeFiles(conversation);
+ conversation.getMessages().clear();
+ if (this.convChangedListener != null) {
+ this.convChangedListener.onConversationListChanged();
+ }
}
public int getConversationCount() {
diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java
index 6e56d2b3..41d9ad0f 100644
--- a/src/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/eu/siacs/conversations/ui/ConversationActivity.java
@@ -34,6 +34,7 @@ import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
+import android.widget.CheckBox;
import android.widget.ListView;
import android.widget.PopupMenu;
import android.widget.PopupMenu.OnMenuItemClickListener;
@@ -297,16 +298,7 @@ public class ConversationActivity extends XmppActivity {
startActivity(new Intent(this, ContactsActivity.class));
break;
case R.id.action_archive:
- Conversation conv = getSelectedConversation();
- conv.setStatus(Conversation.STATUS_ARCHIVED);
- paneShouldBeOpen = true;
- spl.openPane();
- xmppConnectionService.archiveConversation(conv);
- if (conversationList.size() > 0) {
- selectedConversation = conversationList.get(0);
- } else {
- selectedConversation = null;
- }
+ this.endConversation(getSelectedConversation());
break;
case R.id.action_contact_details:
Contact contact = this.getSelectedConversation().getContact();
@@ -400,18 +392,33 @@ public class ConversationActivity extends XmppActivity {
return super.onOptionsItemSelected(item);
}
- protected void clearHistoryDialog(Conversation conversation) {
+ private void endConversation(Conversation conversation) {
+ conversation.setStatus(Conversation.STATUS_ARCHIVED);
+ paneShouldBeOpen = true;
+ spl.openPane();
+ xmppConnectionService.archiveConversation(conversation);
+ if (conversationList.size() > 0) {
+ selectedConversation = conversationList.get(0);
+ } else {
+ selectedConversation = null;
+ }
+ }
+
+ protected void clearHistoryDialog(final Conversation conversation) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getString(R.string.clear_conversation_history));
View dialogView = getLayoutInflater().inflate(R.layout.dialog_clear_history, null);
+ final CheckBox endConversationCheckBox = (CheckBox) dialogView.findViewById(R.id.end_conversation_checkbox);
builder.setView(dialogView);
builder.setNegativeButton(getString(R.string.cancel), null);
builder.setPositiveButton(getString(R.string.delete_messages), new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
- // TODO Auto-generated method stub
-
+ activity.xmppConnectionService.clearConversationHistory(conversation);
+ if (endConversationCheckBox.isChecked()) {
+ endConversation(conversation);
+ }
}
});
builder.create().show();