fixed #50
This commit is contained in:
parent
8003e53013
commit
d140ef6390
|
@ -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();
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue