diff options
Diffstat (limited to 'src')
3 files changed, 51 insertions, 59 deletions
diff --git a/src/main/java/eu/siacs/conversations/parser/PresenceParser.java b/src/main/java/eu/siacs/conversations/parser/PresenceParser.java index 8b367970..12167a1e 100644 --- a/src/main/java/eu/siacs/conversations/parser/PresenceParser.java +++ b/src/main/java/eu/siacs/conversations/parser/PresenceParser.java @@ -22,30 +22,15 @@ public class PresenceParser extends AbstractParser implements public void parseConferencePresence(PresencePacket packet, Account account) { PgpEngine mPgpEngine = mXmppConnectionService.getPgpEngine(); - if (packet.hasChild("x", "http://jabber.org/protocol/muc#user")) { - final Conversation muc = packet.getFrom() == null ? null : mXmppConnectionService.find( - account, - packet.getFrom().toBareJid()); - if (muc != null) { - boolean before = muc.getMucOptions().online(); - muc.getMucOptions().processPacket(packet, mPgpEngine); - if (before != muc.getMucOptions().online()) { - mXmppConnectionService.updateConversationUi(); - } - mXmppConnectionService.getAvatarService().clear(muc); - } - } else if (packet.hasChild("x", "http://jabber.org/protocol/muc")) { - final Conversation conversation = mXmppConnectionService.find(account, - packet.getFrom().toBareJid()); - if (conversation != null) { - final MucOptions mucOptions = conversation.getMucOptions(); - boolean before = mucOptions.online(); - int count = mucOptions.getUsers().size(); - mucOptions.processPacket(packet, mPgpEngine); - mXmppConnectionService.getAvatarService().clear(conversation); - if (before != mucOptions.online() || (mucOptions.online() && count != mucOptions.getUsers().size())) { - mXmppConnectionService.updateConversationUi(); - } + final Conversation conversation = packet.getFrom() == null ? null : mXmppConnectionService.find(account, packet.getFrom().toBareJid()); + if (conversation != null) { + final MucOptions mucOptions = conversation.getMucOptions(); + boolean before = mucOptions.online(); + int count = mucOptions.getUsers().size(); + mucOptions.processPacket(packet, mPgpEngine); + mXmppConnectionService.getAvatarService().clear(conversation); + if (before != mucOptions.online() || (mucOptions.online() && count != mucOptions.getUsers().size())) { + mXmppConnectionService.updateConversationUi(); } } } @@ -56,7 +41,7 @@ public class PresenceParser extends AbstractParser implements if (packet.getFrom() == null) { return; } - final Jid from = packet.getFrom(); + final Jid from = packet.getFrom(); String type = packet.getAttribute("type"); if (from.toBareJid().equals(account.getJid().toBareJid())) { if (!from.isBareJid()) { diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 9abff281..6958a062 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -1273,6 +1273,7 @@ public class XmppConnectionService extends Service { String nick = conversation.getMucOptions().getProposedNick(); Jid joinJid = conversation.getMucOptions().createJoinJid(nick); PresencePacket packet = new PresencePacket(); + packet.setFrom(conversation.getAccount().getJid()); packet.setTo(joinJid); Element x = new Element("x"); x.setAttribute("xmlns", "http://jabber.org/protocol/muc"); diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index 74fe8432..0277f155 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -180,7 +180,6 @@ public class ConversationActivity extends XmppActivity implements hideConversationsOverview(); } }); - //registerForContextMenu(listView); mContentView = findViewById(R.id.content_view_spl); if (mContentView == null) { mContentView = findViewById(R.id.content_view_ll); @@ -195,12 +194,7 @@ public class ConversationActivity extends XmppActivity implements @Override public void onPanelOpened(View arg0) { - ActionBar ab = getActionBar(); - if (ab != null) { - ab.setDisplayHomeAsUpEnabled(false); - ab.setHomeButtonEnabled(false); - ab.setTitle(R.string.app_name); - } + updateActionBarTitle(); invalidateOptionsMenu(); hideKeyboard(); if (xmppConnectionServiceBound) { @@ -236,20 +230,32 @@ public class ConversationActivity extends XmppActivity implements }); } - public void openConversation() { + private void updateActionBarTitle() { + updateActionBarTitle(isConversationsOverviewHideable() && !isConversationsOverviewVisable()); + } + + private void updateActionBarTitle(boolean titleShouldBeName) { ActionBar ab = getActionBar(); if (ab != null) { - ab.setDisplayHomeAsUpEnabled(true); - ab.setHomeButtonEnabled(true); - if (getSelectedConversation().getMode() == Conversation.MODE_SINGLE - || ConversationActivity.this - .useSubjectToIdentifyConference()) { - ab.setTitle(getSelectedConversation().getName()); + if (titleShouldBeName) { + ab.setDisplayHomeAsUpEnabled(true); + ab.setHomeButtonEnabled(true); + if (getSelectedConversation().getMode() == Conversation.MODE_SINGLE || useSubjectToIdentifyConference()) { + ab.setTitle(getSelectedConversation().getName()); + } else { + ab.setTitle(getSelectedConversation().getContactJid().toBareJid().toString()); + } } else { - ab.setTitle(getSelectedConversation().getContactJid().toBareJid().toString()); + ab.setDisplayHomeAsUpEnabled(false); + ab.setHomeButtonEnabled(false); + ab.setTitle(R.string.app_name); } } - invalidateOptionsMenu(); + } + + private void openConversation() { + this.updateActionBarTitle(); + this.invalidateOptionsMenu(); if (xmppConnectionServiceBound) { xmppConnectionService.getNotificationService().setOpenConversation(getSelectedConversation()); if (!getSelectedConversation().isRead()) { @@ -638,14 +644,12 @@ public class ConversationActivity extends XmppActivity implements } @Override - public boolean onKeyDown(final int keyCode, final KeyEvent event) { - if (keyCode == KeyEvent.KEYCODE_BACK) { - if (!isConversationsOverviewVisable()) { - showConversationsOverview(); - return false; - } + public void onBackPressed() { + if (!isConversationsOverviewVisable()) { + showConversationsOverview(); + } else { + moveTaskToBack(true); } - return super.onKeyDown(keyCode, event); } @Override @@ -740,8 +744,9 @@ public class ConversationActivity extends XmppActivity implements this.mConversationFragment.appendText(text); } hideConversationsOverview(); + openConversation(); if (mContentView instanceof SlidingPaneLayout) { - openConversation(); + updateActionBarTitle(true); //fixes bug where slp isn't properly closed yet } } @@ -929,17 +934,15 @@ public class ConversationActivity extends XmppActivity implements @Override public void onAccountUpdate() { - final ConversationFragment fragment = (ConversationFragment) getFragmentManager() - .findFragmentByTag("conversation"); - if (fragment != null) { - runOnUiThread(new Runnable() { + runOnUiThread(new Runnable() { - @Override - public void run() { - fragment.updateMessages(); - } - }); - } + @Override + public void run() { + updateConversationList(); + ConversationActivity.this.mConversationFragment.updateMessages(); + updateActionBarTitle(); + } + }); } @Override @@ -955,6 +958,7 @@ public class ConversationActivity extends XmppActivity implements finish(); } ConversationActivity.this.mConversationFragment.updateMessages(); + updateActionBarTitle(); } }); } @@ -965,7 +969,9 @@ public class ConversationActivity extends XmppActivity implements @Override public void run() { + updateConversationList(); ConversationActivity.this.mConversationFragment.updateMessages(); + updateActionBarTitle(); } }); } |