diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-07-15 14:32:19 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-07-15 14:32:19 +0200 |
commit | 2ebd92b7a7b97c7ecca43eb1e3c7d408508aadb2 (patch) | |
tree | 1da6fc297af9d9fa655a0dbce407fa5ec1f878d4 /src/eu/siacs/conversations/ui | |
parent | 6031af86062757f86701e08962aa86121877fbf4 (diff) |
pushing bookmarks back to server
Diffstat (limited to 'src/eu/siacs/conversations/ui')
-rw-r--r-- | src/eu/siacs/conversations/ui/StartConversation.java | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/src/eu/siacs/conversations/ui/StartConversation.java b/src/eu/siacs/conversations/ui/StartConversation.java index e1186858..c9166c39 100644 --- a/src/eu/siacs/conversations/ui/StartConversation.java +++ b/src/eu/siacs/conversations/ui/StartConversation.java @@ -30,6 +30,7 @@ import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; +import android.widget.CheckBox; import android.widget.EditText; import android.widget.ImageView; import android.widget.ListView; @@ -222,6 +223,10 @@ public class StartConversation extends XmppActivity { Bookmark bookmark = (Bookmark) conferences.get(position); Conversation conversation = xmppConnectionService.findOrCreateConversation(bookmark.getAccount(), bookmark.getJid(), true); conversation.setBookmark(bookmark); + if (!bookmark.autojoin()) { + bookmark.setAutojoin(true); + xmppConnectionService.pushBookmarks(bookmark.getAccount()); + } switchToConversation(conversation); } @@ -237,6 +242,15 @@ public class StartConversation extends XmppActivity { xmppConnectionService.deleteContactOnServer(contact); filter(mSearchEditText.getText().toString()); } + + protected void deleteConference() { + int position = contact_context_id; + Bookmark bookmark = (Bookmark) conferences.get(position); + Account account = bookmark.getAccount(); + account.getBookmarks().remove(bookmark); + xmppConnectionService.pushBookmarks(account); + filter(mSearchEditText.getText().toString()); + } protected void showCreateContactDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); @@ -293,6 +307,7 @@ public class StartConversation extends XmppActivity { jid.setAdapter(new KnownHostsAdapter(this, android.R.layout.simple_list_item_1, mKnownConferenceHosts)); populateAccountSpinner(spinner); + final CheckBox bookmarkCheckBox = (CheckBox) dialogView.findViewById(R.id.bookmark); builder.setView(dialogView); builder.setNegativeButton(R.string.cancel, null); builder.setPositiveButton(R.string.join, null); @@ -309,10 +324,26 @@ public class StartConversation extends XmppActivity { String conferenceJid = jid.getText().toString(); Account account = xmppConnectionService .findAccountByJid(accountJid); - Conversation conversation = xmppConnectionService + if (bookmarkCheckBox.isChecked()) { + if (account.hasBookmarkFor(conferenceJid)) { + jid.setError(getString(R.string.bookmark_already_exists)); + } else { + Bookmark bookmark = new Bookmark(account, conferenceJid); + bookmark.setAutojoin(true); + account.getBookmarks().add(bookmark); + xmppConnectionService.pushBookmarks(account); + Conversation conversation = xmppConnectionService + .findOrCreateConversation(account, + conferenceJid, true); + conversation.setBookmark(bookmark); + switchToConversation(conversation); + } + } else { + Conversation conversation = xmppConnectionService .findOrCreateConversation(account, conferenceJid, true); - switchToConversation(conversation); + switchToConversation(conversation); + } } else { jid.setError(getString(R.string.invalid_jid)); } @@ -508,6 +539,8 @@ public class StartConversation extends XmppActivity { case R.id.context_join_conference: activity.openConversationForBookmark(); break; + case R.id.context_delete_conference: + activity.deleteConference(); } return true; } |