Change summary
src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java | 37
1 file changed, 30 insertions(+), 7 deletions(-)
Detailed changes
@@ -571,6 +571,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;
@@ -688,6 +691,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) {
@@ -704,13 +718,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);
@@ -883,6 +891,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();
}
@Override