aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu
diff options
context:
space:
mode:
authorMichael <betheg@bitcloner.org>2014-11-23 21:36:44 +0100
committerMichael <betheg@bitcloner.org>2014-11-23 21:37:45 +0100
commit31b539daf74048d2a712e89e0c9a9de80af63ba5 (patch)
tree6d852f6c03bde609b2df3d0569ade7bfe46f7486 /src/main/java/eu
parent49403fda8410315b34677ebfa2e29f59a61f76bd (diff)
MUC: option to set/delete bookmark in conference details.
Diffstat (limited to 'src/main/java/eu')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
index 290842fb..0a97bc7a 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
@@ -27,6 +27,8 @@ import java.util.List;
import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.PgpEngine;
+import eu.siacs.conversations.entities.Account;
+import eu.siacs.conversations.entities.Bookmark;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.MucOptions.User;
@@ -149,6 +151,12 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
});
}
break;
+ case R.id.action_save_as_bookmark:
+ saveAsBookmark();
+ break;
+ case R.id.action_delete_bookmark:
+ deleteBookmark();
+ break;
}
return super.onOptionsItemSelected(menuItem);
}
@@ -176,6 +184,21 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
}
@Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ MenuItem menuItemSaveBookmark = menu.findItem(R.id.action_save_as_bookmark);
+ MenuItem menuItemDeleteBookmark = menu.findItem(R.id.action_delete_bookmark);
+ Account account = mConversation.getAccount();
+ if (account.hasBookmarkFor(mConversation.getContactJid().toBareJid())) {
+ menuItemSaveBookmark.setVisible(false);
+ menuItemDeleteBookmark.setVisible(true);
+ } else {
+ menuItemDeleteBookmark.setVisible(false);
+ menuItemSaveBookmark.setVisible(true);
+ }
+ return true;
+ }
+
+ @Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.muc_details, menu);
return true;
@@ -224,6 +247,22 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
}
}
+ protected void saveAsBookmark() {
+ Account account = mConversation.getAccount();
+ Bookmark bookmark = new Bookmark(account, mConversation.getContactJid().toBareJid());
+ account.getBookmarks().add(bookmark);
+ xmppConnectionService.pushBookmarks(account);
+ mConversation.setBookmark(bookmark);
+ }
+
+ protected void deleteBookmark() {
+ Account account = mConversation.getAccount();
+ Bookmark bookmark = mConversation.getBookmark();
+ bookmark.unregisterConversation();
+ account.getBookmarks().remove(bookmark);
+ xmppConnectionService.pushBookmarks(account);
+ }
+
@Override
void onBackendConnected() {
if (getIntent().getAction().equals(ACTION_VIEW_MUC)) {