diff options
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/StartConversationActivity.java')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/StartConversationActivity.java | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java index 85ae80f84..9ea3b48c4 100644 --- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java @@ -578,6 +578,9 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU return false; } switch (item.getItemId()) { + case android.R.id.home: + navigateBack(); + return true; case R.id.action_join_conference: showJoinConferenceDialog(null); return true; @@ -698,6 +701,17 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU } } + private void configureHomeButton() { + final ActionBar actionBar = getSupportActionBar(); + if (actionBar == null) { + return; + } + boolean openConversations = !xmppConnectionService.isConversationsListEmpty(null); + actionBar.setDisplayHomeAsUpEnabled(openConversations); + actionBar.setDisplayHomeAsUpEnabled(openConversations); + + } + @Override protected void onBackendConnected() { if (mPostponedActivityResult != null) { @@ -714,13 +728,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU } } } - final ActionBar ab = getSupportActionBar(); - boolean noConversations = xmppConnectionService.getConversations().size() == 0; - if (noConversations && ab != null) { - ab.setDisplayShowHomeEnabled(false); - ab.setDisplayHomeAsUpEnabled(false); - ab.setHomeButtonEnabled(false); - } + configureHomeButton(); Intent intent = pendingViewIntent.pop(); if (intent != null && processViewIntent(intent)) { filter(null); @@ -893,6 +901,21 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU if (mSearchEditText != null) { filter(mSearchEditText.getText().toString()); } + configureHomeButton(); + } + + @Override + public void onBackPressed() { + navigateBack(); + } + + private void navigateBack() { + if (xmppConnectionService != null && !xmppConnectionService.isConversationsListEmpty(null)) { + Intent intent = new Intent(this, ConversationsActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); + startActivity(intent); + } + finish(); } public boolean useBundledEmoji() { |